Bug 1346265
Summary: | Disallow disk hot-plugging with invalid target labels (e.g. disk partition number for non-paravirt disks) | ||
---|---|---|---|
Product: | [Community] Virtualization Tools | Reporter: | Kashyap Chamarthy <kchamart> |
Component: | libvirt | Assignee: | Pavel Mores <pmores> |
Status: | CLOSED NEXTRELEASE | QA Contact: | |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | unspecified | CC: | jferlan, libvirt-maint, mprivozn, pkrempa |
Target Milestone: | --- | Keywords: | Upstream |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | libvirt-5.8.0 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2019-10-02 12:04:18 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Kashyap Chamarthy
2016-06-14 12:01:09 UTC
A comment from John Ferlan on #virt (OFTC) IRC channel: "The addendum would be that virDiskNameToIndex passes NULL to virDiskNameParse. There's no callers other than a test to virDiskNameParse, so the virNameToIndex probably should not accept numerical suffices. The libvirt disk backend has it's own very special/unique way to handle partitions." - - - And re-posting this comment (by John) from the related upstream thread: http://www.redhat.com/archives/libvir-list/2016-June/msg00890.html -- libvirt disk labels and QEMU drive host alias generation ------------------------------------------------------------------------- "oh - this brings back some shorter term bad memories. This all gets even more complicated with <hostdev>'s. Try to follow both virDomainDiskDefAssignAddress and virDomainHostdevAssignAddress especially when the <address> is not supplied. I do agree with Dan - there should have been some failure on the second command since the source file is duplicated. It seems the only check is for duplicated target dev (see virDomainDiskDefCheckDuplicateInfo). A quick scan finds no disk->src->path comparison for FILE type - not sure a vanilla comparison would work for all "src->type"'s... Beyond that - if one just "reads" the comments for virDiskNameToIndex (and virDiskNameParse) they may assume that the code is attempting to "serially assign an address" based on the target name. Thus "vdb" would equate to the "2nd" disk while "vdb1" would equate to the "27th" disk. However, that would only be "true" if the "partition" parameter was supplied (e.g. a disk partition). If it's not (which is the more general case), then the partition number is "dropped": /* Count the trailing digits. */ size_t n_digits = strspn(ptr, "0123456789"); if (ptr[n_digits] != '\0') return -1; *disk = idx; If the "digit" mattered, then the "n_digits" would have been used to alter "idx" by "idx += *ptr - '0'; similar to how the 'a' math was done. The order of the code perhaps tricks the eyes into believing that the idx was adjusted. In any case, for a non "disk partition" case, the second target perhaps should have been "sdbb" and not "sdb1" (look at tests/utiltest.c). Furthermore, maybe the "solution" for this is the XML catching that the supplied target has a numerically ending value, but does that work for all cases? If one looks at : tests/qemuxml2argvdata/qemuxml2argv-pci-many.xml one will see usage of "vdaa", "vdab", etc. and not "vda1", "vda2", etc. I did not dig for other tests for many disks per controller. Still even with all that "resolved", there is another issue. There's no code currently that makes the "post parse" check if there was some disk or hostdev somehow assigned the same address. I believe this is something determined during review of the series: http://www.redhat.com/archives/libvir-list/2015-July/msg00870.html which went into August, but perhaps most relevant is patch 12: http://www.redhat.com/archives/libvir-list/2015-August/msg00058.html Based on that I started writing a patch that does a very nasty post parse address duplication check for both "disks" and "hostdevs"; however, I believe I was "waiting for" something that allowed us to call it before domain start. IOW: Before what now is Peter's domain configuration validation series (essentially through commit id '5972f185e'). The problem being that prior Peter's series, the only way we could stop something with a duplicate address was at startup time. Now with Peter's series, it would be possible to check for duplicates prior to start and actually list them before actually attempting the start." ------------------------------------------------------------------------- I've pushed patches upstream: 2346b2f656 remove a now redundant call to virDiskNameToIndex() ca437d0603 qemu: Refuse partitions in disk targets v5.8.0-rc1-4-g2346b2f656 |