return -1;
if (virDomainDefHasMemoryHotplug(def)) {
- virBufferAsprintf(buf,
- "<maxMemory slots='%u' unit='KiB'>%llu</maxMemory>\n",
- def->mem.memory_slots, def->mem.max_memory);
+ g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) contentBuf = VIR_BUFFER_INITIALIZER;
+
+ if (def->mem.memory_slots > 0)
+ virBufferAsprintf(&attrBuf, " slots='%u'", def->mem.memory_slots);
+
+ virBufferAddLit(&attrBuf, " unit='KiB'");
+ virBufferAsprintf(&contentBuf, "%llu", def->mem.max_memory);
+
+ virXMLFormatElementInternal(buf, "maxMemory", &attrBuf, &contentBuf, false, false);
}
virBufferAddLit(buf, "<memory");
def->mem.cur_balloon == 0)
def->mem.cur_balloon = virDomainDefGetMemoryTotal(def);
- if ((def->mem.max_memory || def->mem.memory_slots) &&
- !(def->mem.max_memory && def->mem.memory_slots)) {
+ if (def->mem.max_memory == 0 && def->mem.memory_slots > 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
- _("both maximum memory size and memory slot count must be specified"));
+ _("maximum memory size must be specified when specifying number of memory slots"));
return -1;
}
<optional>
<element name="maxMemory">
<ref name="scaledInteger"/>
- <attribute name="slots">
- <ref name="unsignedInt"/>
- </attribute>
+ <optional>
+ <attribute name="slots">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
</element>
</optional>
<optional>
-machine pc,usb=off,dump-guest-core=off,acpi=off \
-accel kvm \
-cpu qemu64 \
--m size=2095104k,slots=1,maxmem=1099511627776k \
+-m size=2095104k,maxmem=1099511627776k \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":2145386496}' \
<domain type='kvm'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
- <maxMemory slots='1' unit='KiB'>1099511627776</maxMemory>
+ <maxMemory unit='KiB'>1099511627776</maxMemory>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static' cpuset='0-1'>2</vcpu>
-machine pc-i440fx-5.2,usb=off,dump-guest-core=off \
-accel kvm \
-cpu qemu64 \
--m size=2095104k,slots=16,maxmem=1099511627776k \
+-m size=2095104k,maxmem=1099511627776k \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object memory-backend-ram,id=ram-node0,size=2145386496 \
-machine pc,usb=off,dump-guest-core=off,acpi=off \
-accel kvm \
-cpu qemu64 \
--m size=2095104k,slots=16,maxmem=1099511627776k \
+-m size=2095104k,maxmem=1099511627776k \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":2145386496}' \
<domain type='kvm'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
- <maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
+ <maxMemory unit='KiB'>1099511627776</maxMemory>
<memory unit='KiB'>2095104</memory>
<currentMemory unit='KiB'>2095104</currentMemory>
<vcpu placement='static' cpuset='0-1'>2</vcpu>