1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

conf: domain: Format out user provided backing chains in XML

If a user configures the backing chain in the XML we should not ignore
it. We already do parse it but don't format it out. As a
safety-precaution don't attempt to format detected chain into the
inactive XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2017-01-31 13:10:30 +01:00
parent a9854e4820
commit d6580c10a1
8 changed files with 369 additions and 2 deletions

View File

@ -23997,10 +23997,15 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
unsigned int flags)
{
const char *format;
bool inactive = flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE;
if (!backingStore)
return 0;
/* don't write detected backing chain members to inactive xml */
if (inactive && backingStore->detected)
return 0;
if (backingStore->type == VIR_STORAGE_TYPE_NONE) {
virBufferAddLit(buf, "<backingStore/>\n");
return 0;
@ -24266,8 +24271,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
/* Don't format backingStore to inactive XMLs until the code for
* persistent storage of backing chains is ready. */
if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
virDomainDiskBackingStoreFormat(buf, def->src->backingStore,
if (virDomainDiskBackingStoreFormat(buf, def->src->backingStore,
xmlopt, flags) < 0)
return -1;

View File

@ -19,6 +19,10 @@
<source protocol='gluster' name='Volume2/Image'>
<host transport='unix' socket='/path/to/sock'/>
</source>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/missing-backing-store.qcow'/>
</backingStore>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</disk>
@ -27,6 +31,31 @@
<source protocol='nbd' name='bar'>
<host transport='unix' socket='/var/run/nbdsock'/>
</source>
<backingStore type='block'>
<format type='qcow2'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image2.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image3.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image4.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image5.qcow'/>
<backingStore type='file'>
<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'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
@ -35,6 +64,7 @@
<source protocol='gluster' name='Volume1/Image'>
<host name='example.org' port='6000'/>
</source>
<backingStore/>
<target dev='vdc' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
@ -48,6 +78,11 @@
<host name='mon2.example.org' port='6322'/>
<host name='mon3.example.org' port='6322'/>
</source>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image.qcow'/>
<backingStore/>
</backingStore>
<target dev='vdd' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</disk>

View File

@ -19,6 +19,10 @@
<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'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</disk>
@ -27,6 +31,31 @@
<source protocol='nbd' name='bar'>
<host transport='unix' socket='/var/run/nbdsock'/>
</source>
<backingStore type='block' index='8'>
<format type='qcow2'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore type='file' index='7'>
<format type='vmdk'/>
<source file='/tmp/image2'/>
<backingStore type='file' index='6'>
<format type='qcow2'/>
<source file='/tmp/image3.qcow'/>
<backingStore type='file' index='5'>
<format type='qcow2'/>
<source file='/tmp/image4.qcow'/>
<backingStore type='file' index='4'>
<format type='qcow2'/>
<source file='/tmp/image5.qcow'/>
<backingStore type='file' index='3'>
<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'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
@ -35,6 +64,7 @@
<source protocol='gluster' name='Volume1/Image'>
<host name='example.org' port='6000'/>
</source>
<backingStore/>
<target dev='vdc' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
@ -48,6 +78,11 @@
<host name='mon2.example.org' port='6322'/>
<host name='mon3.example.org' port='6322'/>
</source>
<backingStore type='file' index='11'>
<format type='qcow2'/>
<source file='/tmp/image.qcow'/>
<backingStore/>
</backingStore>
<target dev='vdd' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</disk>
@ -60,6 +95,51 @@
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071880'/>
<backingStore type='file' index='24'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071877'/>
<backingStore type='file' index='23'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071876'/>
<backingStore type='file' index='22'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071872'/>
<backingStore type='file' index='21'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483615252'/>
<backingStore type='file' index='20'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483605924'/>
<backingStore type='file' index='19'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483605920'/>
<backingStore type='file' index='18'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483546244'/>
<backingStore type='file' index='17'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483545901'/>
<backingStore type='file' index='16'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483545313'/>
<backingStore type='file' index='15'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483536402'/>
<backingStore type='file' index='14'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.qcow2'/>
<backingStore/>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
<target dev='vdf' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>

View File

@ -19,6 +19,10 @@
<source protocol='gluster' name='Volume2/Image'>
<host transport='unix' socket='/path/to/sock'/>
</source>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/missing-backing-store.qcow'/>
</backingStore>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</disk>
@ -27,6 +31,31 @@
<source protocol='nbd' name='bar'>
<host transport='unix' socket='/var/run/nbdsock'/>
</source>
<backingStore type='block'>
<format type='qcow2'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore type='file'>
<format type='vmdk'/>
<source file='/tmp/image2'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image3.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image4.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image5.qcow'/>
<backingStore type='file'>
<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'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
@ -35,6 +64,7 @@
<source protocol='gluster' name='Volume1/Image'>
<host name='example.org' port='6000'/>
</source>
<backingStore/>
<target dev='vdc' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
@ -48,6 +78,11 @@
<host name='mon2.example.org' port='6322'/>
<host name='mon3.example.org' port='6322'/>
</source>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image.qcow'/>
<backingStore/>
</backingStore>
<target dev='vdd' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</disk>
@ -60,6 +95,51 @@
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071880'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071877'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071876'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071872'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483615252'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483605924'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483605920'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483546244'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483545901'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483545313'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483536402'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.qcow2'/>
<backingStore/>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
<target dev='vdf' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>

View File

@ -19,6 +19,10 @@
<source protocol='gluster' name='Volume2/Image'>
<host transport='unix' socket='/path/to/sock'/>
</source>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/missing-backing-store.qcow'/>
</backingStore>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</disk>
@ -27,6 +31,31 @@
<source protocol='nbd' name='bar'>
<host transport='unix' socket='/var/run/nbdsock'/>
</source>
<backingStore type='block'>
<format type='qcow2'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore type='file'>
<format type='vmdk'/>
<source file='/tmp/image2'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image3.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image4.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image5.qcow'/>
<backingStore type='file'>
<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'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
@ -35,6 +64,7 @@
<source protocol='gluster' name='Volume1/Image'>
<host name='example.org' port='6000'/>
</source>
<backingStore/>
<target dev='vdc' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
@ -48,6 +78,11 @@
<host name='mon2.example.org' port='6322'/>
<host name='mon3.example.org' port='6322'/>
</source>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image.qcow'/>
<backingStore/>
</backingStore>
<target dev='vdd' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</disk>
@ -60,6 +95,51 @@
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071880'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071877'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071876'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071872'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483615252'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483605924'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483605920'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483546244'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483545901'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483545313'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483536402'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.qcow2'/>
<backingStore/>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
<target dev='vdf' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>

View File

@ -19,6 +19,10 @@
<source protocol='gluster' name='Volume2/Image'>
<host transport='unix' socket='/path/to/sock'/>
</source>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/missing-backing-store.qcow'/>
</backingStore>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</disk>
@ -27,6 +31,31 @@
<source protocol='nbd' name='bar'>
<host transport='unix' socket='/var/run/nbdsock'/>
</source>
<backingStore type='block'>
<format type='qcow2'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore type='file'>
<format type='vmdk'/>
<source file='/tmp/image2'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image3.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image4.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image5.qcow'/>
<backingStore type='file'>
<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'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
@ -35,6 +64,7 @@
<source protocol='gluster' name='Volume1/Image'>
<host name='example.org' port='6000'/>
</source>
<backingStore/>
<target dev='vdc' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
@ -48,6 +78,11 @@
<host name='mon2.example.org' port='6322'/>
<host name='mon3.example.org' port='6322'/>
</source>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/tmp/image.qcow'/>
<backingStore/>
</backingStore>
<target dev='vdd' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</disk>
@ -60,6 +95,51 @@
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071880'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071877'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071876'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1484071872'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483615252'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483605924'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483605920'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483546244'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483545901'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483545313'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.1483536402'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/rhel7.qcow2'/>
<backingStore/>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
<target dev='vdf' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>

View File

@ -17,12 +17,14 @@
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest2'/>
<backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
@ -30,12 +32,14 @@
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/tmp/data.img'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/tmp/logs.img'/>
<backingStore/>
<target dev='vdb' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>

View File

@ -17,12 +17,14 @@
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<backingStore/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest2'/>
<backingStore/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
@ -30,12 +32,14 @@
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/tmp/data.img'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/tmp/logs.img'/>
<backingStore/>
<target dev='vdb' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>