[libvirt] [PATCH 0/4] Publish disk backing chains in domain XML

This series depends on Peter's "Get rid of virStorageFileMetadata" sent about 10 hours ago. Jiri Denemark (4): conf: Output disk backing store details in domain XML conf: Format and parse backing chains in domain XML tests: More output options for xml2xml tests tests: Test backing store XML formatting and parsing docs/formatdomain.html.in | 59 ++++++++++ docs/schemas/domaincommon.rng | 48 +++++++- src/conf/domain_conf.c | 128 +++++++++++++++++++++ tests/domainschemadata/backing-chains.xml | 94 +++++++++++++++ .../qemuxml2argv-disk-backing-chains.xml | 94 +++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml | 4 + .../qemuxml2argv-seclabel-static-labelskip.xml | 1 + .../qemuxml2xmlout-disk-backing-chains-active.xml | 96 ++++++++++++++++ ...qemuxml2xmlout-disk-backing-chains-inactive.xml | 59 ++++++++++ tests/qemuxml2xmltest.c | 46 ++++++-- tests/sexpr2xmldata/sexpr2xml-boot-grub.xml | 1 + tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml | 1 + tests/sexpr2xmldata/sexpr2xml-curmem.xml | 1 + .../sexpr2xml-disk-block-shareable.xml | 1 + tests/sexpr2xmldata/sexpr2xml-disk-block.xml | 1 + .../sexpr2xml-disk-drv-blktap-qcow.xml | 1 + .../sexpr2xml-disk-drv-blktap-raw.xml | 1 + .../sexpr2xml-disk-drv-blktap2-raw.xml | 1 + tests/sexpr2xmldata/sexpr2xml-disk-file.xml | 1 + tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml | 1 + tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml | 1 + tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml | 2 + .../sexpr2xml-fv-serial-dev-2-ports.xml | 2 + .../sexpr2xml-fv-serial-dev-2nd-port.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 2 + .../sexpr2xml-fv-serial-tcp-telnet.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-sound.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-utc.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-v2.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv.xml | 2 + tests/sexpr2xmldata/sexpr2xml-net-bridged.xml | 1 + tests/sexpr2xmldata/sexpr2xml-net-e1000.xml | 1 + tests/sexpr2xmldata/sexpr2xml-net-routed.xml | 1 + tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 2 + tests/sexpr2xmldata/sexpr2xml-pci-devs.xml | 1 + .../sexpr2xml-pv-bootloader-cmdline.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-vcpus.xml | 1 + .../sexpr2xml-pv-vfb-new-vncdisplay.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml | 1 + .../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv.xml | 1 + 61 files changed, 691 insertions(+), 16 deletions(-) create mode 100644 tests/domainschemadata/backing-chains.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-backing-chains.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-inactive.xml -- 1.9.2

The XML for quite a longish backing chain is shown below: <disk type='network' device='disk'> <driver name='qemu' type='qcow2'/> <source protocol='nbd' name='bar'> <host transport='unix' socket='/var/run/nbdsock'/> </source> <backingStore type='block' index='1'> <format type='qcow2'/> <source dev='/dev/HostVG/QEMUGuest1'/> <backingStore type='file' index='2'> <format type='qcow2'/> <source file='/tmp/image2.qcow'/> <backingStore type='file' index='3'> <format type='qcow2'/> <source file='/tmp/image3.qcow'/> <backingStore type='file' index='4'> <format type='qcow2'/> <source file='/tmp/image4.qcow'/> <backingStore type='file' index='5'> <format type='qcow2'/> <source file='/tmp/image5.qcow'/> <backingStore type='file' index='6'> <format type='raw'/> <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/> <backingStore/> </backingStore> </backingStore> </backingStore> </backingStore> </backingStore> </backingStore> <target dev='vdb' bus='virtio'/> </disk> Various disk types and formats can be mixed in one chain. The <backingStore/> empty element marks the end of the backing chain and it is there mostly for future support of parsing the chain provided by a user. If it's missing, we are supposed to probe for the rest of the chain ourselves, otherwise complete chain was provided by the user. The index attributes of backingStore elements can be used to unambiguously identify a specific part of the image chain. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- docs/formatdomain.html.in | 59 +++++++++++++++++++ docs/schemas/domaincommon.rng | 48 ++++++++++++++-- tests/domainschemadata/backing-chains.xml | 94 +++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 tests/domainschemadata/backing-chains.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e851f85..a6fccd9 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1624,6 +1624,20 @@ </auth> <target dev='vda' bus='virtio'/> </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2'/> + <source file='/var/lib/libvirt/images/domain.qcow'/> + <backingStore type='file'> + <format type='qcow2'/> + <source file='/var/lib/libvirt/images/snapshot.qcow'/> + <backingStore type='block'> + <format type='raw'/> + <source dev='/dev/mapper/base'/> + <backingStore/> + </backingStore> + </backingStore> + <target dev='vda' bus='virtio'/> + </disk> </devices> ...</pre> @@ -1814,6 +1828,51 @@ This feature doesn't support migration currently. </p> </dd> + <dt><code>backingStore</code></dt> + <dd> + This element describes the backing store used by the disk specified by + sibling <code>source</code> element. <span class="since">Since + 1.2.4</span>. An empty <code>backingStore</code> element means the + sibling source is self-contained and is not based on any backing store. + The following attributes and sub-elements are supported in + <code>backingStore</code>: + <dl> + <dt><code>type</code> attribute</dt> + <dd> + The <code>type</code> attribute represents the type of disk used + by the backing store, see disk type attribute above for more + details and possible values. + </dd> + <dt><code>index</code> attribute</dt> + <dd> + This attribute is only valid in output (and ignored on input) and + it can be used to refer to a specific part of the disk chain when + doing block operations (such as via the + <code>virDomainBlockRebase</code> API). For example, + <code>vda[2]</code> refers to the backing store with + <code>index='2'</code> of the disk with <code>vda</code> target. + </dd> + <dt><code>format</code> sub-element</dt> + <dd> + The <code>format</code> element contains <code>type</code> + attribute which specifies the internal format of the backing + store, such as <code>raw</code> or <code>qcow2</code>. + </dd> + <dt><code>source</code> sub-element</dt> + <dd> + This element has the same structure as the <code>source</code> + element in <code>driver</code>. It specifies which file, device, + or network location contains the data of the described backing + store. + </dd> + <dt><code>backingStore</code> sub-element</dt> + <dd> + If the backing store is not self-contained, the next element + in the chain is described by nested <code>backingStore</code> + element. + </dd> + </dl> + </dd> <dt><code>mirror</code></dt> <dd> This element is present if the hypervisor has started a block diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d2235e1..4249ed5 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1196,10 +1196,51 @@ <optional> <ref name="snapshot"/> </optional> - <ref name="diskSource"/> + <interleave> + <ref name="diskSource"/> + <ref name="storageSourceExtra"/> + <ref name="diskBackingChain"/> + </interleave> + </element> + </define> + + <define name="diskBackingChain"> + <choice> + <ref name="diskBackingStore"/> + <ref name="diskBackingStoreLast"/> + </choice> + </define> + + <define name="diskBackingStore"> + <element name="backingStore"> + <attribute name="index"> + <ref name="positiveInteger"/> + </attribute> + <interleave> + <ref name="diskSource"/> + <ref name="diskBackingChain"/> + <ref name="diskFormat"/> + </interleave> + </element> + </define> + + <define name="diskFormat"> + <element name="format"> + <attribute name="type"> + <ref name="storageFormat"/> + </attribute> + <empty/> </element> </define> + <define name="diskBackingStoreLast"> + <optional> + <element name="backingStore"> + <empty/> + </element> + </optional> + </define> + <define name="diskSource"> <choice> <ref name="diskSourceFile"/> @@ -1232,7 +1273,6 @@ </optional> </element> </optional> - <ref name='storageSourceExtra'/> </interleave> </define> @@ -1256,7 +1296,6 @@ </optional> </element> </optional> - <ref name='storageSourceExtra'/> </interleave> </define> @@ -1276,7 +1315,6 @@ <empty/> </element> </optional> - <ref name='storageSourceExtra'/> </interleave> </define> @@ -1340,7 +1378,6 @@ </zeroOrMore> <empty/> </element> - <ref name='storageSourceExtra'/> </interleave> </define> @@ -1373,7 +1410,6 @@ </optional> </element> </optional> - <ref name='storageSourceExtra'/> </interleave> </define> diff --git a/tests/domainschemadata/backing-chains.xml b/tests/domainschemadata/backing-chains.xml new file mode 100644 index 0000000..84df1db --- /dev/null +++ b/tests/domainschemadata/backing-chains.xml @@ -0,0 +1,94 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='gluster' name='Volume2/Image'> + <host transport='unix' socket='/path/to/sock'/> + </source> + <backingStore type='file' index='1'> + <format type='qcow2'/> + <source file='/tmp/missing-backing-store.qcow'/> + </backingStore> + <target dev='vda' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='nbd' name='bar'> + <host transport='unix' socket='/var/run/nbdsock'/> + </source> + <backingStore type='block' index='1'> + <format type='qcow2'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <backingStore type='file' index='2'> + <format type='qcow2'/> + <source file='/tmp/image2.qcow'/> + <backingStore type='file' index='3'> + <format type='qcow2'/> + <source file='/tmp/image3.qcow'/> + <backingStore type='file' index='4'> + <format type='qcow2'/> + <source file='/tmp/image4.qcow'/> + <backingStore type='file' index='5'> + <source file='/tmp/image5.qcow'/> + <format type='qcow2'/> + <backingStore type='file' index='6'> + <format type='raw'/> + <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/> + <backingStore/> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + <target dev='vdb' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <backingStore/> + <source protocol='gluster' name='Volume1/Image'> + <host name='example.org' port='6000'/> + </source> + <target dev='vdc' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <auth username='myname'> + <secret type='ceph' usage='mycluster_myname'/> + </auth> + <source protocol='rbd' name='pool/image'> + <host name='mon1.example.org' port='6321'/> + <host name='mon2.example.org' port='6322'/> + <host name='mon3.example.org' port='6322'/> + </source> + <backingStore type='file' index='1'> + <source file='/tmp/image.qcow'/> + <backingStore/> + <format type='qcow2'/> + </backingStore> + <target dev='vdd' bus='virtio'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2'/> + <source dev='/dev/HostVG/QEMUGuest11'/> + <target dev='vde' bus='virtio'/> + </disk> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> -- 1.9.2

On 04/21/14 10:32, Jiri Denemark wrote:
The XML for quite a longish backing chain is shown below:
<disk type='network' device='disk'> <driver name='qemu' type='qcow2'/> <source protocol='nbd' name='bar'> <host transport='unix' socket='/var/run/nbdsock'/> </source> <backingStore type='block' index='1'> <format type='qcow2'/> <source dev='/dev/HostVG/QEMUGuest1'/> <backingStore type='file' index='2'> <format type='qcow2'/> <source file='/tmp/image2.qcow'/> <backingStore type='file' index='3'> <format type='qcow2'/> <source file='/tmp/image3.qcow'/> <backingStore type='file' index='4'> <format type='qcow2'/> <source file='/tmp/image4.qcow'/> <backingStore type='file' index='5'> <format type='qcow2'/> <source file='/tmp/image5.qcow'/> <backingStore type='file' index='6'> <format type='raw'/> <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/> <backingStore/> </backingStore> </backingStore> </backingStore> </backingStore> </backingStore> </backingStore> <target dev='vdb' bus='virtio'/> </disk>
Various disk types and formats can be mixed in one chain. The <backingStore/> empty element marks the end of the backing chain and it is there mostly for future support of parsing the chain provided by a user. If it's missing, we are supposed to probe for the rest of the chain ourselves, otherwise complete chain was provided by the user. The index attributes of backingStore elements can be used to unambiguously identify a specific part of the image chain.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- docs/formatdomain.html.in | 59 +++++++++++++++++++ docs/schemas/domaincommon.rng | 48 ++++++++++++++-- tests/domainschemadata/backing-chains.xml | 94 +++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 tests/domainschemadata/backing-chains.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e851f85..a6fccd9 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in
...
@@ -1814,6 +1828,51 @@ This feature doesn't support migration currently. </p> </dd> + <dt><code>backingStore</code></dt> + <dd> + This element describes the backing store used by the disk specified by + sibling <code>source</code> element. <span class="since">Since + 1.2.4</span>. An empty <code>backingStore</code> element means the + sibling source is self-contained and is not based on any backing store. + The following attributes and sub-elements are supported in + <code>backingStore</code>: + <dl> + <dt><code>type</code> attribute</dt> + <dd> + The <code>type</code> attribute represents the type of disk used + by the backing store, see disk type attribute above for more + details and possible values. + </dd> + <dt><code>index</code> attribute</dt> + <dd> + This attribute is only valid in output (and ignored on input) and + it can be used to refer to a specific part of the disk chain when + doing block operations (such as via the + <code>virDomainBlockRebase</code> API). For example, + <code>vda[2]</code> refers to the backing store with + <code>index='2'</code> of the disk with <code>vda</code> target. + </dd> + <dt><code>format</code> sub-element</dt> + <dd> + The <code>format</code> element contains <code>type</code> + attribute which specifies the internal format of the backing + store, such as <code>raw</code> or <code>qcow2</code>. + </dd> + <dt><code>source</code> sub-element</dt> + <dd> + This element has the same structure as the <code>source</code> + element in <code>driver</code>. It specifies which file, device,
s/driver/disk/ ?
+ or network location contains the data of the described backing + store. + </dd> + <dt><code>backingStore</code> sub-element</dt> + <dd> + If the backing store is not self-contained, the next element + in the chain is described by nested <code>backingStore</code> + element. + </dd> + </dl> + </dd> <dt><code>mirror</code></dt> <dd> This element is present if the hypervisor has started a block
Maybe we should also document that user-specified backing chains aren't currently supported. ACK with the two issues above addressed. Peter

On Tue, Apr 22, 2014 at 13:02:17 +0200, Peter Krempa wrote:
On 04/21/14 10:32, Jiri Denemark wrote:
The XML for quite a longish backing chain is shown below: ...
s/driver/disk/ ?
+ or network location contains the data of the described backing + store. + </dd> + <dt><code>backingStore</code> sub-element</dt> + <dd> + If the backing store is not self-contained, the next element + in the chain is described by nested <code>backingStore</code> + element. + </dd> + </dl> + </dd> <dt><code>mirror</code></dt> <dd> This element is present if the hypervisor has started a block
Maybe we should also document that user-specified backing chains aren't currently supported.
ACK with the two issues above addressed.
I did the suggested modifications and pushed this series. Thanks. Jirka

This patch implements formating and parsing code for the backing store schema defined and documented by the previous patch. This patch does not aim at providing full persistent storage of disk backing chains yet. The formatter is supposed to provide the backing chain detected when starting a domain and thus it is not formatted into an inactive domain XML. The parser is implemented mainly for the purpose of testing the XML generated by the formatter and thus it does not distinguish between no backingStore element and an empty backingStore element. This will have to change once we fully implement support for user-supplied backing chains. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/conf/domain_conf.c | 128 +++++++++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml | 4 + .../qemuxml2argv-seclabel-static-labelskip.xml | 1 + tests/sexpr2xmldata/sexpr2xml-boot-grub.xml | 1 + tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml | 1 + tests/sexpr2xmldata/sexpr2xml-curmem.xml | 1 + .../sexpr2xml-disk-block-shareable.xml | 1 + tests/sexpr2xmldata/sexpr2xml-disk-block.xml | 1 + .../sexpr2xml-disk-drv-blktap-qcow.xml | 1 + .../sexpr2xml-disk-drv-blktap-raw.xml | 1 + .../sexpr2xml-disk-drv-blktap2-raw.xml | 1 + tests/sexpr2xmldata/sexpr2xml-disk-file.xml | 1 + tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml | 1 + tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml | 1 + tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml | 2 + .../sexpr2xml-fv-serial-dev-2-ports.xml | 2 + .../sexpr2xml-fv-serial-dev-2nd-port.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 2 + .../sexpr2xml-fv-serial-tcp-telnet.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-sound.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-utc.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv-v2.xml | 2 + tests/sexpr2xmldata/sexpr2xml-fv.xml | 2 + tests/sexpr2xmldata/sexpr2xml-net-bridged.xml | 1 + tests/sexpr2xmldata/sexpr2xml-net-e1000.xml | 1 + tests/sexpr2xmldata/sexpr2xml-net-routed.xml | 1 + tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 2 + tests/sexpr2xmldata/sexpr2xml-pci-devs.xml | 1 + .../sexpr2xml-pv-bootloader-cmdline.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-vcpus.xml | 1 + .../sexpr2xml-pv-vfb-new-vncdisplay.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml | 1 + .../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 1 + tests/sexpr2xmldata/sexpr2xml-pv.xml | 1 + 54 files changed, 211 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 99b57ee..9dbe0af 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5084,6 +5084,74 @@ virDomainDiskSourceParse(xmlNodePtr node, } +static int +virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, + virStorageSourcePtr src) +{ + virStorageSourcePtr backingStore = NULL; + xmlNodePtr save_ctxt = ctxt->node; + xmlNodePtr source; + char *type = NULL; + char *format = NULL; + int ret = -1; + + if (!(ctxt->node = virXPathNode("./backingStore[*]", ctxt))) { + ret = 0; + goto cleanup; + } + + if (VIR_ALLOC(backingStore) < 0) + goto cleanup; + + if (!(type = virXMLPropString(ctxt->node, "type"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing disk backing store type")); + goto cleanup; + } + + backingStore->type = virStorageTypeFromString(type); + if (backingStore->type < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk backing store type '%s'"), type); + goto cleanup; + } + + if (!(format = virXPathString("string(./format/@type)", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing disk backing store format")); + goto cleanup; + } + + backingStore->format = virStorageFileFormatTypeFromString(format); + if (backingStore->format < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk backing store format '%s'"), format); + goto cleanup; + } + + if (!(source = virXPathNode("./source", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing disk backing store source")); + goto cleanup; + } + + if (virDomainDiskSourceParse(source, backingStore) < 0 || + virDomainDiskBackingStoreParse(ctxt, backingStore) < 0) + goto cleanup; + + src->backingStore = backingStore; + ret = 0; + + cleanup: + if (ret < 0) + virStorageSourceFree(backingStore); + VIR_FREE(type); + VIR_FREE(format); + ctxt->node = save_ctxt; + return ret; +} + + #define VENDOR_LEN 8 #define PRODUCT_LEN 16 @@ -5842,6 +5910,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, && virDomainDiskDefAssignAddress(xmlopt, def) < 0) goto error; + if (virDomainDiskBackingStoreParse(ctxt, &def->src) < 0) + goto error; + cleanup: VIR_FREE(bus); VIR_FREE(type); @@ -14890,6 +14961,55 @@ virDomainDiskSourceFormat(virBufferPtr buf, static int +virDomainDiskBackingStoreFormat(virBufferPtr buf, + virStorageSourcePtr backingStore, + const char *backingStoreRaw, + unsigned int index) +{ + const char *type; + const char *format; + + if (!backingStore) { + if (!backingStoreRaw) + virBufferAddLit(buf, "<backingStore/>\n"); + return 0; + } + + if (!backingStore->type || + !(type = virStorageTypeToString(backingStore->type))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk backing store type %d"), + backingStore->type); + return -1; + } + + if (backingStore->format <= 0 || + !(format = virStorageFileFormatTypeToString(backingStore->format))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk backing store format %d"), + backingStore->format); + return -1; + } + + virBufferAsprintf(buf, "<backingStore type='%s' index='%u'>\n", + type, index); + virBufferAdjustIndent(buf, 2); + + virBufferAsprintf(buf, "<format type='%s'/>\n", format); + if (virDomainDiskSourceFormat(buf, backingStore, 0, 0) < 0 || + virDomainDiskBackingStoreFormat(buf, + backingStore->backingStore, + backingStore->backingStoreRaw, + index + 1) < 0) + return -1; + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "</backingStore>\n"); + return 0; +} + + +static int virDomainDiskDefFormat(virBufferPtr buf, virDomainDiskDefPtr def, unsigned int flags) @@ -15015,6 +15135,14 @@ virDomainDiskDefFormat(virBufferPtr buf, if (virDomainDiskSourceFormat(buf, &def->src, def->startupPolicy, flags) < 0) return -1; + + /* Don't format backingStore to inactive XMLs until the code for + * persistent storage of backing chains is ready. */ + if (!(flags & VIR_DOMAIN_XML_INACTIVE) && + virDomainDiskBackingStoreFormat(buf, def->src.backingStore, + def->src.backingStoreRaw, 1) < 0) + return -1; + virDomainDiskGeometryDefFormat(buf, def); virDomainDiskBlockIoDefFormat(buf, def); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml index aa16a7e..faa0b8c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml @@ -16,23 +16,27 @@ <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> <source dev='/dev/HostVG/QEMUGuest1'/> + <backingStore/> <mirror file='/dev/HostVG/QEMUGuest1Copy' ready='yes'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='block' device='cdrom'> <source dev='/dev/HostVG/QEMUGuest2'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <disk type='file' device='disk'> <source file='/tmp/data.img'/> + <backingStore/> <mirror file='/tmp/copy.img' format='qcow2'/> <target dev='vda' bus='virtio'/> </disk> <disk type='file' device='disk'> <source file='/tmp/logs.img'/> + <backingStore/> <target dev='vdb' bus='virtio'/> </disk> <controller type='usb' index='0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-labelskip.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-labelskip.xml index a743448..7978f5b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-labelskip.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-labelskip.xml @@ -18,6 +18,7 @@ <source dev='/dev/HostVG/QEMUGuest1'> <seclabel model='selinux' labelskip='yes'/> </source> + <backingStore/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-boot-grub.xml b/tests/sexpr2xmldata/sexpr2xml-boot-grub.xml index cc3fd48..1220407 100644 --- a/tests/sexpr2xmldata/sexpr2xml-boot-grub.xml +++ b/tests/sexpr2xmldata/sexpr2xml-boot-grub.xml @@ -17,6 +17,7 @@ <disk type='block' device='disk'> <driver name='phy'/> <source dev='/dev/MainVG/GuestVG'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml b/tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml index e17e1e5..9b5cc3a 100644 --- a/tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml +++ b/tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <interface type='bridge'> diff --git a/tests/sexpr2xmldata/sexpr2xml-curmem.xml b/tests/sexpr2xmldata/sexpr2xml-curmem.xml index 2e68fc4..39d954a 100644 --- a/tests/sexpr2xmldata/sexpr2xml-curmem.xml +++ b/tests/sexpr2xmldata/sexpr2xml-curmem.xml @@ -19,6 +19,7 @@ <disk type='file' device='disk'> <driver name='tap' type='raw'/> <source file='/xen/rhel5.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <interface type='bridge'> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml b/tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml index 571b349..40e8903 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml @@ -16,6 +16,7 @@ <disk type='file' device='disk'> <driver name='tap' type='raw'/> <source file='/var/lib/xen/images/rhel5pv.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> <shareable/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-block.xml b/tests/sexpr2xmldata/sexpr2xml-disk-block.xml index 7716576..51e3b3a 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-block.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-block.xml @@ -18,6 +18,7 @@ <disk type='block' device='disk'> <driver name='phy'/> <source dev='/dev/MainVG/GuestVG'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml index 38ae2fe..315c68a 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='tap' type='qcow'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml index df8e7ec..c56582d 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='tap' type='raw'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap2-raw.xml b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap2-raw.xml index ea93195..7afc6b5 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap2-raw.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap2-raw.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='tap2' type='raw'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-disk-file.xml b/tests/sexpr2xmldata/sexpr2xml-disk-file.xml index 7496539..36b8c1e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-disk-file.xml +++ b/tests/sexpr2xmldata/sexpr2xml-disk-file.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml index 0f29f03..69fe9ef 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml @@ -21,11 +21,13 @@ <disk type='block' device='disk'> <driver name='phy'/> <source dev='/iscsi/winxp'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/net/heaped/export/netimage/windows/xp-sp2-vol.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml b/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml index b5bd19b..3c3147d 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml index ae056c8..716f16b 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml @@ -23,11 +23,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml index 27090be..3dd648b 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml @@ -23,11 +23,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml b/tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml index 320835a..29c1335 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml @@ -19,6 +19,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <serial type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml b/tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml index d28ba98..9c59644 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml @@ -26,6 +26,7 @@ <disk type='block' device='disk'> <driver name='phy'/> <source dev='/dev/zvol/dsk/export/s10u4-root'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <input type='mouse' bus='ps2'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml b/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml index b896e51..67b0b95 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml b/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml index 8dda7ff..86b32e9 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml index 788d319..ed7da80 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml index a9450ec..ed3fde6 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml index f05db8d..7f5a729 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml index 10a331e..10f84dc 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml index c1c717e..a3fd231 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml index ea19144..b3f77c9 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml index 447d4a3..e217161 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml index 328bc45..3ad2264 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml index 5a92433..001df56 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml index 1f800bc..c2496fd 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml index 23dabbd..6dc047e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml index 29ba6e5..7ccaeac 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml index 0379e0d..b5ad413 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml b/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml index 0785041..7183e79 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml b/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml index 0785041..7183e79 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml b/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml index b9c2aaf..ae90e33 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml index 44a0867..f81c47a 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml b/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml index 584fbfb..c783d93 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml b/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml index f910412..bd3b107 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv.xml b/tests/sexpr2xmldata/sexpr2xml-fv.xml index 584fbfb..c783d93 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv.xml @@ -21,11 +21,13 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/foo.img'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> <driver name='file'/> <source file='/root/boot.iso'/> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-net-bridged.xml b/tests/sexpr2xmldata/sexpr2xml-net-bridged.xml index da403bd..ce7954d 100644 --- a/tests/sexpr2xmldata/sexpr2xml-net-bridged.xml +++ b/tests/sexpr2xmldata/sexpr2xml-net-bridged.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <interface type='bridge'> diff --git a/tests/sexpr2xmldata/sexpr2xml-net-e1000.xml b/tests/sexpr2xmldata/sexpr2xml-net-e1000.xml index 1ce7067..286209b 100644 --- a/tests/sexpr2xmldata/sexpr2xml-net-e1000.xml +++ b/tests/sexpr2xmldata/sexpr2xml-net-e1000.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <interface type='bridge'> diff --git a/tests/sexpr2xmldata/sexpr2xml-net-routed.xml b/tests/sexpr2xmldata/sexpr2xml-net-routed.xml index 3a31f5f..0ab3b6d 100644 --- a/tests/sexpr2xmldata/sexpr2xml-net-routed.xml +++ b/tests/sexpr2xmldata/sexpr2xml-net-routed.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <interface type='ethernet'> diff --git a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml index 055b0d3..00d18ce 100644 --- a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml +++ b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml @@ -23,9 +23,11 @@ <disk type='block' device='disk'> <driver name='phy'/> <source dev='/dev/sda8'/> + <backingStore/> <target dev='hda' bus='ide'/> </disk> <disk type='file' device='cdrom'> + <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> </disk> diff --git a/tests/sexpr2xmldata/sexpr2xml-pci-devs.xml b/tests/sexpr2xmldata/sexpr2xml-pci-devs.xml index 146b779..a404484 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pci-devs.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pci-devs.xml @@ -18,6 +18,7 @@ <disk type='block' device='disk'> <driver name='phy'/> <source dev='/dev/MainVG/GuestVG'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-bootloader-cmdline.xml b/tests/sexpr2xmldata/sexpr2xml-pv-bootloader-cmdline.xml index f0e34f7..0e92d0e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-bootloader-cmdline.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-bootloader-cmdline.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml b/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml index 80efe82..bafe97f 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml @@ -17,6 +17,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml index 348049a..fc57fa9 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vcpus.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vcpus.xml index 6f7cffc..a55f83e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vcpus.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vcpus.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml index e8c3cda..9ae7bff 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml index 365d3c9..c2eb798 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml index 365d3c9..c2eb798 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml index 5333292..0fee41c 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml @@ -17,6 +17,7 @@ <disk type='block' device='disk'> <driver name='phy'/> <source dev='/dev/vg_dom0test/test2vm'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <interface type='bridge'> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv.xml b/tests/sexpr2xmldata/sexpr2xml-pv.xml index 7496539..36b8c1e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv.xml @@ -18,6 +18,7 @@ <disk type='file' device='disk'> <driver name='file'/> <source file='/root/some.img'/> + <backingStore/> <target dev='xvda' bus='xen'/> </disk> <console type='pty'> -- 1.9.2

On 04/21/14 10:32, Jiri Denemark wrote:
This patch implements formating and parsing code for the backing store schema defined and documented by the previous patch.
This patch does not aim at providing full persistent storage of disk backing chains yet. The formatter is supposed to provide the backing chain detected when starting a domain and thus it is not formatted into an inactive domain XML. The parser is implemented mainly for the purpose of testing the XML generated by the formatter and thus it does not distinguish between no backingStore element and an empty backingStore element. This will have to change once we fully implement support for user-supplied backing chains.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/conf/domain_conf.c | 128 +++++++++++++++++++++
...
54 files changed, 211 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 99b57ee..9dbe0af 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c
...
@@ -5842,6 +5910,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, && virDomainDiskDefAssignAddress(xmlopt, def) < 0) goto error;
+ if (virDomainDiskBackingStoreParse(ctxt, &def->src) < 0) + goto error; + cleanup: VIR_FREE(bus); VIR_FREE(type);
Hmmm, I think we should notify the user somehow that the parsed input will be ignored, but that can be done later as we still have time until the release. ACK. Peter

So far, qemuxml2xml test was only able to check if the result matches the original or the appropriate XML in qemuxml2xmloutdata regardless on flags used to format the XML. Since the result can be different depending on VIR_DOMAIN_XML_INACTIVE flag being used or not, this patch adds support for qemuxml2xmlout-%s-active.xml and qemuxml2xmlout-%s-inactive.xml output files. If the file specific to the flag used exists, it is used in preference to the generic qemuxml2xmlout-%s.xml file when reading the expected output. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- tests/qemuxml2xmltest.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index bf9d736..abad2f4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -81,31 +81,55 @@ testCompareXMLToXMLHelper(const void *data) const struct testInfo *info = data; char *xml_in = NULL; char *xml_out = NULL; + char *xml_out_active = NULL; + char *xml_out_inactive = NULL; int ret = -1; if (virAsprintf(&xml_in, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml", abs_srcdir, info->name) < 0 || virAsprintf(&xml_out, "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s.xml", + abs_srcdir, info->name) < 0 || + virAsprintf(&xml_out_active, + "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s-active.xml", + abs_srcdir, info->name) < 0 || + virAsprintf(&xml_out_inactive, + "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s-inactive.xml", abs_srcdir, info->name) < 0) goto cleanup; - if ((info->when & WHEN_INACTIVE) && - testCompareXMLToXMLFiles(xml_in, - info->different ? xml_out : xml_in, - false) < 0) - goto cleanup; + if ((info->when & WHEN_INACTIVE)) { + char *out; + if (!info->different) + out = xml_in; + else if (virFileExists(xml_out_inactive)) + out = xml_out_inactive; + else + out = xml_out; + + if (testCompareXMLToXMLFiles(xml_in, out, false) < 0) + goto cleanup; + } - if ((info->when & WHEN_ACTIVE) && - testCompareXMLToXMLFiles(xml_in, - info->different ? xml_out : xml_in, - true) < 0) - goto cleanup; + if ((info->when & WHEN_ACTIVE)) { + char *out; + if (!info->different) + out = xml_in; + else if (virFileExists(xml_out_active)) + out = xml_out_active; + else + out = xml_out; + + if (testCompareXMLToXMLFiles(xml_in, out, true) < 0) + goto cleanup; + } ret = 0; cleanup: VIR_FREE(xml_in); VIR_FREE(xml_out); + VIR_FREE(xml_out_active); + VIR_FREE(xml_out_inactive); return ret; } -- 1.9.2

On 04/21/14 10:32, Jiri Denemark wrote:
So far, qemuxml2xml test was only able to check if the result matches the original or the appropriate XML in qemuxml2xmloutdata regardless on flags used to format the XML. Since the result can be different depending on VIR_DOMAIN_XML_INACTIVE flag being used or not, this patch adds support for qemuxml2xmlout-%s-active.xml and qemuxml2xmlout-%s-inactive.xml output files. If the file specific to the flag used exists, it is used in preference to the generic qemuxml2xmlout-%s.xml file when reading the expected output.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- tests/qemuxml2xmltest.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-)
ACK. Peter

Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- .../qemuxml2argv-disk-backing-chains.xml | 94 +++++++++++++++++++++ .../qemuxml2xmlout-disk-backing-chains-active.xml | 96 ++++++++++++++++++++++ ...qemuxml2xmlout-disk-backing-chains-inactive.xml | 59 +++++++++++++ tests/qemuxml2xmltest.c | 2 + 4 files changed, 251 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-backing-chains.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-inactive.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-backing-chains.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-backing-chains.xml new file mode 100644 index 0000000..b80b9d2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-backing-chains.xml @@ -0,0 +1,94 @@ +<domain type='qemu' id='1'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='gluster' name='Volume2/Image'> + <host transport='unix' socket='/path/to/sock'/> + </source> + <backingStore type='file' index='1'> + <format type='qcow2'/> + <source file='/tmp/missing-backing-store.qcow'/> + </backingStore> + <target dev='vda' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='nbd' name='bar'> + <host transport='unix' socket='/var/run/nbdsock'/> + </source> + <backingStore type='block' index='1'> + <format type='qcow2'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <backingStore type='file' index='2'> + <format type='qcow2'/> + <source file='/tmp/image2.qcow'/> + <backingStore type='file' index='3'> + <format type='qcow2'/> + <source file='/tmp/image3.qcow'/> + <backingStore type='file' index='4'> + <format type='qcow2'/> + <source file='/tmp/image4.qcow'/> + <backingStore type='file' index='5'> + <source file='/tmp/image5.qcow'/> + <format type='qcow2'/> + <backingStore type='file' index='6'> + <format type='raw'/> + <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/> + <backingStore/> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + <target dev='vdb' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <backingStore/> + <source protocol='gluster' name='Volume1/Image'> + <host name='example.org' port='6000'/> + </source> + <target dev='vdc' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <auth username='myname'> + <secret type='ceph' usage='mycluster_myname'/> + </auth> + <source protocol='rbd' name='pool/image'> + <host name='mon1.example.org' port='6321'/> + <host name='mon2.example.org' port='6322'/> + <host name='mon3.example.org' port='6322'/> + </source> + <backingStore type='file' index='1'> + <source file='/tmp/image.qcow'/> + <backingStore/> + <format type='qcow2'/> + </backingStore> + <target dev='vdd' bus='virtio'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2'/> + <source dev='/dev/HostVG/QEMUGuest11'/> + <target dev='vde' bus='virtio'/> + </disk> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml new file mode 100644 index 0000000..482ee59 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml @@ -0,0 +1,96 @@ +<domain type='qemu' id='1'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='gluster' name='Volume2/Image'> + <host transport='unix' socket='/path/to/sock'/> + </source> + <backingStore type='file' index='1'> + <format type='qcow2'/> + <source file='/tmp/missing-backing-store.qcow'/> + <backingStore/> + </backingStore> + <target dev='vda' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='nbd' name='bar'> + <host transport='unix' socket='/var/run/nbdsock'/> + </source> + <backingStore type='block' index='1'> + <format type='qcow2'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <backingStore type='file' index='2'> + <format type='qcow2'/> + <source file='/tmp/image2.qcow'/> + <backingStore type='file' index='3'> + <format type='qcow2'/> + <source file='/tmp/image3.qcow'/> + <backingStore type='file' index='4'> + <format type='qcow2'/> + <source file='/tmp/image4.qcow'/> + <backingStore type='file' index='5'> + <format type='qcow2'/> + <source file='/tmp/image5.qcow'/> + <backingStore type='file' index='6'> + <format type='raw'/> + <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/> + <backingStore/> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + </backingStore> + <target dev='vdb' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='gluster' name='Volume1/Image'> + <host name='example.org' port='6000'/> + </source> + <backingStore/> + <target dev='vdc' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <auth username='myname'> + <secret type='ceph' usage='mycluster_myname'/> + </auth> + <source protocol='rbd' name='pool/image'> + <host name='mon1.example.org' port='6321'/> + <host name='mon2.example.org' port='6322'/> + <host name='mon3.example.org' port='6322'/> + </source> + <backingStore type='file' index='1'> + <format type='qcow2'/> + <source file='/tmp/image.qcow'/> + <backingStore/> + </backingStore> + <target dev='vdd' bus='virtio'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2'/> + <source dev='/dev/HostVG/QEMUGuest11'/> + <backingStore/> + <target dev='vde' bus='virtio'/> + </disk> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-inactive.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-inactive.xml new file mode 100644 index 0000000..5b59aad --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-inactive.xml @@ -0,0 +1,59 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='gluster' name='Volume2/Image'> + <host transport='unix' socket='/path/to/sock'/> + </source> + <target dev='vda' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='nbd' name='bar'> + <host transport='unix' socket='/var/run/nbdsock'/> + </source> + <target dev='vdb' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='gluster' name='Volume1/Image'> + <host name='example.org' port='6000'/> + </source> + <target dev='vdc' bus='virtio'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <auth username='myname'> + <secret type='ceph' usage='mycluster_myname'/> + </auth> + <source protocol='rbd' name='pool/image'> + <host name='mon1.example.org' port='6321'/> + <host name='mon2.example.org' port='6322'/> + <host name='mon3.example.org' port='6322'/> + </source> + <target dev='vdd' bus='virtio'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2'/> + <source dev='/dev/HostVG/QEMUGuest11'/> + <target dev='vde' bus='virtio'/> + </disk> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index abad2f4..3ea03e6 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -360,6 +360,8 @@ mymain(void) DO_TEST("panic"); + DO_TEST_DIFFERENT("disk-backing-chains"); + virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); -- 1.9.2

On 04/21/14 10:32, Jiri Denemark wrote:
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- .../qemuxml2argv-disk-backing-chains.xml | 94 +++++++++++++++++++++ .../qemuxml2xmlout-disk-backing-chains-active.xml | 96 ++++++++++++++++++++++ ...qemuxml2xmlout-disk-backing-chains-inactive.xml | 59 +++++++++++++ tests/qemuxml2xmltest.c | 2 + 4 files changed, 251 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-backing-chains.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-inactive.xml
ACK. Peter
participants (2)
-
Jiri Denemark
-
Peter Krempa