mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +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;
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
g_auto(virBuffer) sourceChildBuf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
options = virStorageVolOptionsForPoolType(pool->type);
|
||||
if (options == NULL)
|
||||
@ -1689,14 +1690,13 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
||||
|
||||
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
|
||||
virBufferEscapeString(&buf, "<key>%s</key>\n", def->key);
|
||||
virBufferAddLit(&buf, "<source>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
|
||||
virBufferSetIndent(&sourceChildBuf, virBufferGetIndent(&buf) + 2);
|
||||
|
||||
if (def->source.nextent)
|
||||
virStorageVolDefFormatSourceExtents(&buf, def);
|
||||
virStorageVolDefFormatSourceExtents(&sourceChildBuf, def);
|
||||
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</source>\n");
|
||||
virXMLFormatElement(&buf, "source", NULL, &sourceChildBuf);
|
||||
|
||||
virBufferAsprintf(&buf, "<capacity unit='bytes'>%llu</capacity>\n",
|
||||
def->target.capacity);
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>sparse.img</name>
|
||||
<key>/var/lib/libvirt/images/sparse.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>10000000000</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<volume type='file'>
|
||||
<name>test.iso</name>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>1048576</capacity>
|
||||
<allocation unit='bytes'>1048576</allocation>
|
||||
<target>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<volume type='file'>
|
||||
<name><sparse>.img</name>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>1099511627776</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<volume type='file'>
|
||||
<name>sparse.img</name>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>1099511627776</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='netdir'>
|
||||
<name>dir</name>
|
||||
<key>vol/dir</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>0</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='netdir'>
|
||||
<name>dir</name>
|
||||
<key>vol/dir</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>0</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='block'>
|
||||
<name>Swap</name>
|
||||
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>2080374784</capacity>
|
||||
<allocation unit='bytes'>2080374784</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='block'>
|
||||
<name>Swap</name>
|
||||
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>2080374784</capacity>
|
||||
<allocation unit='bytes'>2080374784</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>LuksDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/LuksDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>LuksDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/LuksDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='block'>
|
||||
<name>sda1</name>
|
||||
<key>/dev/sda1</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>106896384</capacity>
|
||||
<allocation unit='bytes'>106896384</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>OtherDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>OtherDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>OtherDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>OtherDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>OtherDemoLuks.img</name>
|
||||
<key>/var/lib/libvirt/images/OtherDemoLuks.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>OtherDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>OtherDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>0</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<volume type='file'>
|
||||
<name>OtherDemo.img</name>
|
||||
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>5368709120</capacity>
|
||||
<allocation unit='bytes'>294912</allocation>
|
||||
<target>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<volume type='network'>
|
||||
<name>test2</name>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>1024</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
|
Loading…
Reference in New Issue
Block a user