mirror of https://gitee.com/openkylin/libvirt.git
conf: Introduce optional 'uuid' element for NVDIMM memory
ppc64 NVDIMM support was implemented in QEMU by commit [1].
The support is similar to what x86 already does, aside from
an extra 'uuid' element.
This patch introduces a new optional 'uuid' element for the
NVDIMM memory model. This element behaves like the 'uuid'
element of the domain definition - if absent, we'll create
a new one, otherwise use the one provided by the XML.
The 'uuid' element is exclusive to pseries guests and are
unavailable for other architectures.
Next patch will use this new element to add NVDIMM support
for ppc64.
[1] ee3a71e366
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1d5f16ba81
commit
08ed673901
|
@ -5754,6 +5754,11 @@
|
|||
</attribute>
|
||||
</optional>
|
||||
<interleave>
|
||||
<optional>
|
||||
<element name="uuid">
|
||||
<ref name="UUID"/>
|
||||
</element>
|
||||
</optional>
|
||||
<optional>
|
||||
<ref name="memorydev-source"/>
|
||||
</optional>
|
||||
|
|
|
@ -16588,6 +16588,7 @@ static virDomainMemoryDefPtr
|
|||
virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||
xmlNodePtr memdevNode,
|
||||
xmlXPathContextPtr ctxt,
|
||||
const virDomainDef *dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt);
|
||||
|
@ -16634,6 +16635,25 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||
|
||||
def->discard = val;
|
||||
}
|
||||
VIR_FREE(tmp);
|
||||
|
||||
if (def->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
|
||||
ARCH_IS_PPC64(dom->os.arch)) {
|
||||
/* Extract nvdimm uuid or generate a new one */
|
||||
tmp = virXPathString("string(./uuid[1])", ctxt);
|
||||
|
||||
if (!tmp) {
|
||||
if (virUUIDGenerate(def->uuid) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Failed to generate UUID"));
|
||||
goto error;
|
||||
}
|
||||
} else if (virUUIDParse(tmp, def->uuid) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("malformed uuid element"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* source */
|
||||
if ((node = virXPathNode("./source", ctxt)) &&
|
||||
|
@ -16931,7 +16951,8 @@ virDomainDeviceDefParse(const char *xmlStr,
|
|||
break;
|
||||
case VIR_DOMAIN_DEVICE_MEMORY:
|
||||
if (!(dev->data.memory = virDomainMemoryDefParseXML(xmlopt, node,
|
||||
ctxt, flags)))
|
||||
ctxt, def,
|
||||
flags)))
|
||||
return NULL;
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_IOMMU:
|
||||
|
@ -21877,6 +21898,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||
virDomainMemoryDefPtr mem = virDomainMemoryDefParseXML(xmlopt,
|
||||
nodes[i],
|
||||
ctxt,
|
||||
def,
|
||||
flags);
|
||||
if (!mem)
|
||||
goto error;
|
||||
|
@ -27092,6 +27114,7 @@ virDomainMemoryTargetDefFormat(virBufferPtr buf,
|
|||
static int
|
||||
virDomainMemoryDefFormat(virBufferPtr buf,
|
||||
virDomainMemoryDefPtr def,
|
||||
const virDomainDef *dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
const char *model = virDomainMemoryModelTypeToString(def->model);
|
||||
|
@ -27106,6 +27129,14 @@ virDomainMemoryDefFormat(virBufferPtr buf,
|
|||
virBufferAddLit(buf, ">\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
|
||||
if (def->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
|
||||
ARCH_IS_PPC64(dom->os.arch)) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
|
||||
virUUIDFormat(def->uuid, uuidstr);
|
||||
virBufferAsprintf(buf, "<uuid>%s</uuid>\n", uuidstr);
|
||||
}
|
||||
|
||||
if (virDomainMemorySourceDefFormat(buf, def) < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -29435,7 +29466,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
|
|||
}
|
||||
|
||||
for (n = 0; n < def->nmems; n++) {
|
||||
if (virDomainMemoryDefFormat(buf, def->mems[n], flags) < 0)
|
||||
if (virDomainMemoryDefFormat(buf, def->mems[n], def, flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -30548,7 +30579,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
|
|||
rc = virDomainPanicDefFormat(&buf, src->data.panic);
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_MEMORY:
|
||||
rc = virDomainMemoryDefFormat(&buf, src->data.memory, flags);
|
||||
rc = virDomainMemoryDefFormat(&buf, src->data.memory, def, flags);
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_SHMEM:
|
||||
rc = virDomainShmemDefFormat(&buf, src->data.shmem, flags);
|
||||
|
|
|
@ -2189,6 +2189,9 @@ struct _virDomainMemoryDef {
|
|||
unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
|
||||
bool readonly; /* valid only for NVDIMM */
|
||||
|
||||
/* required for QEMU NVDIMM ppc64 support */
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
|
||||
virDomainDeviceInfo info;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
|
||||
<memory unit='KiB'>1267710</memory>
|
||||
<currentMemory unit='KiB'>1267710</currentMemory>
|
||||
<vcpu placement='static' cpuset='0-1'>2</vcpu>
|
||||
<os>
|
||||
<type arch='ppc64' machine='pseries'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<cpu>
|
||||
<topology sockets='2' dies='1' cores='1' threads='1'/>
|
||||
<numa>
|
||||
<cell id='0' cpus='0-1' memory='1048576' unit='KiB'/>
|
||||
</numa>
|
||||
</cpu>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-ppc64</emulator>
|
||||
<controller type='usb' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
|
||||
</controller>
|
||||
<controller type='pci' index='0' model='pci-root'>
|
||||
<model name='spapr-pci-host-bridge'/>
|
||||
<target index='0'/>
|
||||
</controller>
|
||||
<memballoon model='virtio'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||
</memballoon>
|
||||
<panic model='pseries'/>
|
||||
<memory model='nvdimm'>
|
||||
<uuid>49545eb3-75e1-2d0a-acdd-f0294406c99e</uuid>
|
||||
<source>
|
||||
<path>/tmp/nvdimm</path>
|
||||
</source>
|
||||
<target>
|
||||
<size unit='KiB'>523264</size>
|
||||
<node>0</node>
|
||||
</target>
|
||||
<address type='dimm' slot='0'/>
|
||||
</memory>
|
||||
</devices>
|
||||
</domain>
|
|
@ -0,0 +1,47 @@
|
|||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
|
||||
<memory unit='KiB'>1267710</memory>
|
||||
<currentMemory unit='KiB'>1267710</currentMemory>
|
||||
<vcpu placement='static' cpuset='0-1'>2</vcpu>
|
||||
<os>
|
||||
<type arch='ppc64' machine='pseries'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<cpu>
|
||||
<topology sockets='2' dies='1' cores='1' threads='1'/>
|
||||
<numa>
|
||||
<cell id='0' cpus='0-1' memory='1048576' unit='KiB'/>
|
||||
</numa>
|
||||
</cpu>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-ppc64</emulator>
|
||||
<controller type='usb' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
|
||||
</controller>
|
||||
<controller type='pci' index='0' model='pci-root'>
|
||||
<model name='spapr-pci-host-bridge'/>
|
||||
<target index='0'/>
|
||||
</controller>
|
||||
<memballoon model='virtio'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||
</memballoon>
|
||||
<panic model='pseries'/>
|
||||
<memory model='nvdimm'>
|
||||
<uuid>49545eb3-75e1-2d0a-acdd-f0294406c99e</uuid>
|
||||
<source>
|
||||
<path>/tmp/nvdimm</path>
|
||||
</source>
|
||||
<target>
|
||||
<size unit='KiB'>523264</size>
|
||||
<node>0</node>
|
||||
</target>
|
||||
<address type='dimm' slot='0'/>
|
||||
</memory>
|
||||
</devices>
|
||||
</domain>
|
|
@ -1246,6 +1246,8 @@ mymain(void)
|
|||
DO_TEST("memory-hotplug-nvdimm-align", QEMU_CAPS_DEVICE_NVDIMM);
|
||||
DO_TEST("memory-hotplug-nvdimm-pmem", QEMU_CAPS_DEVICE_NVDIMM);
|
||||
DO_TEST("memory-hotplug-nvdimm-readonly", QEMU_CAPS_DEVICE_NVDIMM);
|
||||
DO_TEST("memory-hotplug-nvdimm-ppc64", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
|
||||
QEMU_CAPS_DEVICE_NVDIMM);
|
||||
DO_TEST("net-udp", NONE);
|
||||
|
||||
DO_TEST("video-virtio-gpu-device", QEMU_CAPS_DEVICE_VIRTIO_GPU);
|
||||
|
|
Loading…
Reference in New Issue