libvirt/tests/qemuxml2xmloutdata
John Ferlan e0e290552b disk: Disallow duplicated target 'dev' values
https://bugzilla.redhat.com/show_bug.cgi?id=1142631

This patch resolves a situation where the same "<target dev='$name'...>"
can be used for multiple disks in the domain.

While the $name is "mostly" advisory regarding the expected order that
the disk is added to the domain and not guaranteed to map to the device
name in the guest OS, it still should be unique enough such that other
domblk* type operations can be performed.

Without the patch, the domblklist will list the same Target twice:

$ virsh domblklist $dom
Target     Source
------------------------------------------------
sda        /var/lib/libvirt/images/file.qcow2
sda        /var/lib/libvirt/images/file.img

Additionally, getting domblkstat, domblkerror, domblkinfo, and other block*
type calls will not be able to reference the second target.

Fortunately, hotplug disallows adding a "third" sda value:

$ qemu-img create -f raw /var/lib/libvirt/images/file2.img 10M
$ virsh attach-disk $dom /var/lib/libvirt/images/file2.img sda
error: Failed to attach disk
error: operation failed: target sda already exists

$

BUT, it since 'sdb' doesn't exist one would get the following on the same
hotplug attempt, but changing to use 'sdb' instead of 'sda'

$ virsh attach-disk $dom /var/lib/libvirt/images/file2.img sdb
error: Failed to attach disk
error: internal error: unable to execute QEMU command 'device_add': Duplicate ID 'scsi0-0-1' for device

$

Since we cannot fix this issue at parsing time, the best that can be done so
as to not "lose" a domain is to make the check prior to starting the guest
with the results as follows:

$ virsh start $dom
error: Failed to start domain $dom
error: XML error: target 'sda' duplicated for disk sources '/var/lib/libvirt/images/file.qcow2' and '/var/lib/libvirt/images/file.img'

$

Running 'make check' found a few more instances in the tests where this
duplicated target dev value was being used. These also exhibited some
duplicated 'id=' values (negating the uniqueness argument of aliases) in
the corresponding .args file and of course the *xmlout version of a few
input XML files.
2015-03-02 22:38:36 -05:00
..
qemuxml2xmlout-balloon-device-auto.xml conf: Swap order of AddImplicitControllers and DomainDefPostParse 2013-06-28 09:52:00 +02:00
qemuxml2xmlout-boot-menu-disable-with-timeout.xml docs, conf: add support for bootmenu timeout 2014-08-25 14:10:54 +02:00
qemuxml2xmlout-channel-virtio-auto.xml conf: Swap order of AddImplicitControllers and DomainDefPostParse 2013-06-28 09:52:00 +02:00
qemuxml2xmlout-channel-virtio-state-active.xml conf: Add channel state for virtio channels to the XML 2014-11-21 11:00:11 +01:00
qemuxml2xmlout-channel-virtio-state-inactive.xml conf: Add channel state for virtio channels to the XML 2014-11-21 11:00:11 +01:00
qemuxml2xmlout-console-compat-auto.xml
qemuxml2xmlout-console-virtio.xml conf: Swap order of AddImplicitControllers and DomainDefPostParse 2013-06-28 09:52:00 +02:00
qemuxml2xmlout-cpu-numa1.xml cpu_conf: Allow specification of 'units' for @memory on numa nodes. 2014-11-10 14:55:45 +01:00
qemuxml2xmlout-cpu-numa2.xml cpu_conf: Allow specification of 'units' for @memory on numa nodes. 2014-11-10 14:55:45 +01:00
qemuxml2xmlout-cputune-iothreads.xml cputune: allow interleaved xml 2014-09-15 18:59:40 -06:00
qemuxml2xmlout-cputune-iothreadsched.xml docs, schema, conf: Add support for setting scheduler parameters of guest threads 2015-02-11 17:30:06 +01:00
qemuxml2xmlout-disk-backing-chains-active.xml tests: Test backing store XML formatting and parsing 2014-04-24 16:07:56 +02:00
qemuxml2xmlout-disk-backing-chains-inactive.xml tests: Test backing store XML formatting and parsing 2014-04-24 16:07:56 +02:00
qemuxml2xmlout-disk-drive-discard.xml conf: fix omission of <driver> in domain dumpxml 2014-04-16 10:49:07 +02:00
qemuxml2xmlout-disk-mirror-old-inactive.xml conf: alter disk mirror xml output 2014-06-06 11:48:09 -06:00
qemuxml2xmlout-disk-mirror-old.xml blockcommit: track job type in xml 2014-07-30 06:32:38 -06:00
qemuxml2xmlout-disk-mirror.xml
qemuxml2xmlout-disk-scsi-device-auto.xml conf: Swap order of AddImplicitControllers and DomainDefPostParse 2013-06-28 09:52:00 +02:00
qemuxml2xmlout-disk-source-pool.xml disk: Disallow duplicated target 'dev' values 2015-03-02 22:38:36 -05:00
qemuxml2xmlout-graphics-listen-network2.xml video: cleanup usage of vram attribute and update documentation 2014-11-24 22:05:55 +01:00
qemuxml2xmlout-graphics-spice-timeout.xml video: cleanup usage of vram attribute and update documentation 2014-11-24 22:05:55 +01:00
qemuxml2xmlout-hostdev-scsi-autogen-address.xml
qemuxml2xmlout-memtune-unlimited.xml conf: don't format memtune with unlimited values 2013-12-10 09:11:26 +01:00
qemuxml2xmlout-memtune.xml
qemuxml2xmlout-metadata.xml
qemuxml2xmlout-numad-auto-memory-vcpu-cpuset.xml
qemuxml2xmlout-numad-auto-memory-vcpu-no-cpuset-and-placement.xml
qemuxml2xmlout-numad-auto-vcpu-no-numatune.xml
qemuxml2xmlout-numatune-auto-prefer.xml cpu_conf: Allow specification of 'units' for @memory on numa nodes. 2014-11-10 14:55:45 +01:00
qemuxml2xmlout-numatune-memnode.xml conf: numa: Don't duplicate NUMA cell cpumask 2015-02-20 17:43:03 +01:00
qemuxml2xmlout-pci-autoadd-addr.xml video: cleanup usage of vram attribute and update documentation 2014-11-24 22:05:55 +01:00
qemuxml2xmlout-pci-autoadd-idx.xml video: cleanup usage of vram attribute and update documentation 2014-11-24 22:05:55 +01:00
qemuxml2xmlout-pci-bridge-many-disks.xml disk: Disallow duplicated target 'dev' values 2015-03-02 22:38:36 -05:00
qemuxml2xmlout-pcie-root.xml qemu: fix handling of default/implicit devices for q35 2013-08-05 15:47:49 -04:00
qemuxml2xmlout-pcihole64-gib.xml Add pcihole64 element to root PCI controllers 2013-08-27 17:42:29 +02:00
qemuxml2xmlout-pmu-feature.xml docs, schema, conf: Add support for PMU feature 2015-01-16 13:43:46 +01:00
qemuxml2xmlout-q35.xml qemu-command: introduce new vgamem attribute for QXL video device 2014-11-24 22:20:13 +01:00
qemuxml2xmlout-s390-defaultconsole.xml Prevent default creation of usb controller on s390 and s390x 2015-02-23 14:50:15 -05:00
qemuxml2xmlout-seclabel-dynamic-labelskip.xml selinux: distinguish failure to label from request to avoid label 2013-08-20 10:39:03 -06:00
qemuxml2xmlout-seclabel-dynamic-none-relabel.xml tests: Add test cases for previous commit 2014-09-05 08:35:34 +02:00
qemuxml2xmlout-seclabel-dynamic-relabel.xml tests: Add test cases for previous commit 2014-09-05 08:35:34 +02:00
qemuxml2xmlout-seclabel-none.xml tests: Add test cases for previous commit 2014-09-05 08:35:34 +02:00
qemuxml2xmlout-serial-target-port-auto.xml
qemuxml2xmlout-tap-vhost-incorrect.xml Only parse custom vhost path for virtio interfaces 2015-02-06 12:52:50 +01:00
qemuxml2xmlout-usb-ich9-ehci-addr.xml