mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
virStorageVolDefFormat: Don't format empty <source>
If there are no source extents the volume XML has an empty <source> element. Remove it if there's nothing in it by using virXMLFormatElement. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
80d9ef8068
commit
6423e30828
@ -1678,6 +1678,7 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
|||||||
{
|
{
|
||||||
virStorageVolOptionsPtr options;
|
virStorageVolOptionsPtr options;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
g_auto(virBuffer) sourceChildBuf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
options = virStorageVolOptionsForPoolType(pool->type);
|
options = virStorageVolOptionsForPoolType(pool->type);
|
||||||
if (options == NULL)
|
if (options == NULL)
|
||||||
@ -1689,14 +1690,13 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
|||||||
|
|
||||||
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
|
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
|
||||||
virBufferEscapeString(&buf, "<key>%s</key>\n", def->key);
|
virBufferEscapeString(&buf, "<key>%s</key>\n", def->key);
|
||||||
virBufferAddLit(&buf, "<source>\n");
|
|
||||||
virBufferAdjustIndent(&buf, 2);
|
virBufferSetIndent(&sourceChildBuf, virBufferGetIndent(&buf) + 2);
|
||||||
|
|
||||||
if (def->source.nextent)
|
if (def->source.nextent)
|
||||||
virStorageVolDefFormatSourceExtents(&buf, def);
|
virStorageVolDefFormatSourceExtents(&sourceChildBuf, def);
|
||||||
|
|
||||||
virBufferAdjustIndent(&buf, -2);
|
virXMLFormatElement(&buf, "source", NULL, &sourceChildBuf);
|
||||||
virBufferAddLit(&buf, "</source>\n");
|
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "<capacity unit='bytes'>%llu</capacity>\n",
|
virBufferAsprintf(&buf, "<capacity unit='bytes'>%llu</capacity>\n",
|
||||||
def->target.capacity);
|
def->target.capacity);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>sparse.img</name>
|
<name>sparse.img</name>
|
||||||
<key>/var/lib/libvirt/images/sparse.img</key>
|
<key>/var/lib/libvirt/images/sparse.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>10000000000</capacity>
|
<capacity unit='bytes'>10000000000</capacity>
|
||||||
<allocation unit='bytes'>0</allocation>
|
<allocation unit='bytes'>0</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>test.iso</name>
|
<name>test.iso</name>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>1048576</capacity>
|
<capacity unit='bytes'>1048576</capacity>
|
||||||
<allocation unit='bytes'>1048576</allocation>
|
<allocation unit='bytes'>1048576</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name><sparse>.img</name>
|
<name><sparse>.img</name>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>1099511627776</capacity>
|
<capacity unit='bytes'>1099511627776</capacity>
|
||||||
<allocation unit='bytes'>0</allocation>
|
<allocation unit='bytes'>0</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>sparse.img</name>
|
<name>sparse.img</name>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>1099511627776</capacity>
|
<capacity unit='bytes'>1099511627776</capacity>
|
||||||
<allocation unit='bytes'>0</allocation>
|
<allocation unit='bytes'>0</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='netdir'>
|
<volume type='netdir'>
|
||||||
<name>dir</name>
|
<name>dir</name>
|
||||||
<key>vol/dir</key>
|
<key>vol/dir</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>0</capacity>
|
<capacity unit='bytes'>0</capacity>
|
||||||
<allocation unit='bytes'>0</allocation>
|
<allocation unit='bytes'>0</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='netdir'>
|
<volume type='netdir'>
|
||||||
<name>dir</name>
|
<name>dir</name>
|
||||||
<key>vol/dir</key>
|
<key>vol/dir</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>0</capacity>
|
<capacity unit='bytes'>0</capacity>
|
||||||
<allocation unit='bytes'>0</allocation>
|
<allocation unit='bytes'>0</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='block'>
|
<volume type='block'>
|
||||||
<name>Swap</name>
|
<name>Swap</name>
|
||||||
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
|
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>2080374784</capacity>
|
<capacity unit='bytes'>2080374784</capacity>
|
||||||
<allocation unit='bytes'>2080374784</allocation>
|
<allocation unit='bytes'>2080374784</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='block'>
|
<volume type='block'>
|
||||||
<name>Swap</name>
|
<name>Swap</name>
|
||||||
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
|
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>2080374784</capacity>
|
<capacity unit='bytes'>2080374784</capacity>
|
||||||
<allocation unit='bytes'>2080374784</allocation>
|
<allocation unit='bytes'>2080374784</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>LuksDemo.img</name>
|
<name>LuksDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/LuksDemo.img</key>
|
<key>/var/lib/libvirt/images/LuksDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>LuksDemo.img</name>
|
<name>LuksDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/LuksDemo.img</key>
|
<key>/var/lib/libvirt/images/LuksDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='block'>
|
<volume type='block'>
|
||||||
<name>sda1</name>
|
<name>sda1</name>
|
||||||
<key>/dev/sda1</key>
|
<key>/dev/sda1</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>106896384</capacity>
|
<capacity unit='bytes'>106896384</capacity>
|
||||||
<allocation unit='bytes'>106896384</allocation>
|
<allocation unit='bytes'>106896384</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>OtherDemo.img</name>
|
<name>OtherDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>OtherDemo.img</name>
|
<name>OtherDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>OtherDemo.img</name>
|
<name>OtherDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>OtherDemo.img</name>
|
<name>OtherDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>OtherDemoLuks.img</name>
|
<name>OtherDemoLuks.img</name>
|
||||||
<key>/var/lib/libvirt/images/OtherDemoLuks.img</key>
|
<key>/var/lib/libvirt/images/OtherDemoLuks.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>OtherDemo.img</name>
|
<name>OtherDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>OtherDemo.img</name>
|
<name>OtherDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>0</capacity>
|
<capacity unit='bytes'>0</capacity>
|
||||||
<allocation unit='bytes'>0</allocation>
|
<allocation unit='bytes'>0</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<volume type='file'>
|
<volume type='file'>
|
||||||
<name>OtherDemo.img</name>
|
<name>OtherDemo.img</name>
|
||||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>5368709120</capacity>
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
<allocation unit='bytes'>294912</allocation>
|
<allocation unit='bytes'>294912</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<volume type='network'>
|
<volume type='network'>
|
||||||
<name>test2</name>
|
<name>test2</name>
|
||||||
<source>
|
|
||||||
</source>
|
|
||||||
<capacity unit='bytes'>1024</capacity>
|
<capacity unit='bytes'>1024</capacity>
|
||||||
<allocation unit='bytes'>0</allocation>
|
<allocation unit='bytes'>0</allocation>
|
||||||
<target>
|
<target>
|
||||||
|
Loading…
Reference in New Issue
Block a user