conf: Reorder elements inside memballoon

All the devices we have format their address as its last sub-element, so
let's change memballoon to follow suit.  Also adjust RNG to allow any
order of them so 'virsh edit' doesn't shout at us.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2015-03-13 16:16:57 +01:00
parent 3a13e4f178
commit 02ce97bca6
4 changed files with 61 additions and 30 deletions

View File

@ -3440,19 +3440,21 @@
<value>none</value> <value>none</value>
</choice> </choice>
</attribute> </attribute>
<optional> <interleave>
<ref name="alias"/> <optional>
</optional> <ref name="alias"/>
<optional> </optional>
<ref name="address"/> <optional>
</optional> <ref name="address"/>
<optional> </optional>
<element name="stats"> <optional>
<attribute name="period"> <element name="stats">
<ref name="positiveInteger"/> <attribute name="period">
</attribute> <ref name='positiveInteger'/>
</element> </attribute>
</optional> </element>
</optional>
</interleave>
</element> </element>
</define> </define>
<define name="parallel"> <define name="parallel">

View File

@ -18826,7 +18826,8 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
unsigned int flags) unsigned int flags)
{ {
const char *model = virDomainMemballoonModelTypeToString(def->model); const char *model = virDomainMemballoonModelTypeToString(def->model);
bool noopts = true; virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
int indent = virBufferGetIndent(buf, false);
if (!model) { if (!model) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -18835,27 +18836,24 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
} }
virBufferAsprintf(buf, "<memballoon model='%s'", model); virBufferAsprintf(buf, "<memballoon model='%s'", model);
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(&childrenBuf, indent + 2);
if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { if (def->period)
virBufferAddLit(buf, ">\n"); virBufferAsprintf(&childrenBuf, "<stats period='%u'/>\n", def->period);
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
noopts = false; virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) {
virBufferFreeAndReset(&childrenBuf);
return -1;
} }
if (def->period) { if (!virBufferUse(&childrenBuf)) {
if (noopts)
virBufferAddLit(buf, ">\n");
virBufferAsprintf(buf, "<stats period='%u'/>\n", def->period);
noopts = false;
}
virBufferAdjustIndent(buf, -2);
if (noopts)
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
else } else {
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childrenBuf);
virBufferAddLit(buf, "</memballoon>\n"); virBufferAddLit(buf, "</memballoon>\n");
}
return 0; return 0;
} }

View File

@ -0,0 +1,30 @@
<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='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'/>
<memballoon model='virtio'>
<stats period='10'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
</memballoon>
</devices>
</domain>

View File

@ -354,6 +354,7 @@ mymain(void)
/* These tests generate different XML */ /* These tests generate different XML */
DO_TEST_DIFFERENT("balloon-device-auto"); DO_TEST_DIFFERENT("balloon-device-auto");
DO_TEST_DIFFERENT("balloon-device-period");
DO_TEST_DIFFERENT("channel-virtio-auto"); DO_TEST_DIFFERENT("channel-virtio-auto");
DO_TEST_DIFFERENT("console-compat-auto"); DO_TEST_DIFFERENT("console-compat-auto");
DO_TEST_DIFFERENT("disk-scsi-device-auto"); DO_TEST_DIFFERENT("disk-scsi-device-auto");