提交 0c10edad 编写于 作者: P Peter Krempa

qemu: domain: Modify <migrationSource> to look like <disk>

When adding <migrationSource> I've used a slightly unusual approach. To
allow using the disk source XML parser and formatter convert
<migrationSource> to look like <disk>. This means that <source> will be
added as a subelement of <migrationSource> rather than being formatted
inline.

Conversion from the old format in the parser is very simple as it
involves only moving the XPath context current node slightly if the new
format is found.

The status XML to XML test shows that the upgrade is done correctly.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 1af846dd
......@@ -2343,28 +2343,21 @@ qemuDomainObjPrivateXMLFormatPR(virBufferPtr buf,
static int
qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf,
virStorageSourcePtr src)
virStorageSourcePtr src,
virDomainXMLOptionPtr xmlopt)
{
VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
VIR_AUTOCLEAN(virBuffer) privateDataBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
virBufferSetChildIndent(&childBuf, buf);
virBufferSetChildIndent(&privateDataBuf, &childBuf);
virBufferAsprintf(&attrBuf, " type='%s' format='%s'",
virStorageTypeToString(src->type),
virStorageFileFormatTypeToString(src->format));
if (virDomainStorageSourceFormat(&attrBuf, &childBuf, src,
VIR_DOMAIN_DEF_FORMAT_STATUS) < 0)
goto cleanup;
if (qemuStorageSourcePrivateDataFormat(src, &privateDataBuf) < 0)
goto cleanup;
if (virXMLFormatElement(&childBuf, "privateData", NULL, &privateDataBuf) < 0)
if (virDomainDiskSourceFormat(&childBuf, src, 0, false,
VIR_DOMAIN_DEF_FORMAT_STATUS, xmlopt) < 0)
goto cleanup;
if (virXMLFormatElement(buf, "migrationSource", &attrBuf, &childBuf) < 0)
......@@ -2381,6 +2374,7 @@ static int
qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf,
virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
size_t i;
......@@ -2399,7 +2393,8 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf,
if (diskPriv->migrSource &&
qemuDomainObjPrivateXMLFormatNBDMigrationSource(&childBuf,
diskPriv->migrSource) < 0)
diskPriv->migrSource,
priv->driver->xmlopt) < 0)
goto cleanup;
if (virXMLFormatElement(buf, "disk", &attrBuf, &childBuf) < 0)
......@@ -2723,6 +2718,7 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node,
char *type = NULL;
int ret = -1;
VIR_AUTOUNREF(virStorageSourcePtr) migrSource = NULL;
xmlNodePtr sourceNode;
ctxt->node = node;
......@@ -2758,6 +2754,11 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node,
goto cleanup;
}
/* newer libvirt uses the <source> subelement instead of formatting the
* source directly into <migrationSource> */
if ((sourceNode = virXPathNode("./source", ctxt)))
ctxt->node = sourceNode;
if (virDomainStorageSourceParse(ctxt->node, ctxt, migrSource,
VIR_DOMAIN_DEF_PARSE_STATUS, NULL) < 0)
goto cleanup;
......
......@@ -237,14 +237,16 @@
</qemuCaps>
<job type='none' async='migration out' phase='perform3' flags='0x0'>
<disk dev='vdb' migrating='yes'>
<migrationSource type='network' format='raw' protocol='nbd' name='drive-virtio-disk1' tlsFromConfig='0'>
<host name='andariel.usersys.redhat.com' port='49152'/>
<privateData>
<nodenames>
<nodename type='storage' name='migration-vdb-storage'/>
<nodename type='format' name='migration-vdb-format'/>
</nodenames>
</privateData>
<migrationSource type='network' format='raw'>
<source protocol='nbd' name='drive-virtio-disk1' tlsFromConfig='0'>
<host name='andariel.usersys.redhat.com' port='49152'/>
<privateData>
<nodenames>
<nodename type='storage' name='migration-vdb-storage'/>
<nodename type='format' name='migration-vdb-format'/>
</nodenames>
</privateData>
</source>
</migrationSource>
</disk>
<disk dev='vdc' migrating='yes'>
......
......@@ -237,25 +237,29 @@
</qemuCaps>
<job type='none' async='migration out' phase='perform3' flags='0x0'>
<disk dev='vdb' migrating='yes'>
<migrationSource type='network' format='raw' protocol='nbd' name='drive-virtio-disk1' tlsFromConfig='0'>
<host name='andariel.usersys.redhat.com' port='49152'/>
<privateData>
<nodenames>
<nodename type='storage' name='migration-vdb-storage'/>
<nodename type='format' name='migration-vdb-format'/>
</nodenames>
</privateData>
<migrationSource type='network' format='raw'>
<source protocol='nbd' name='drive-virtio-disk1' tlsFromConfig='0'>
<host name='andariel.usersys.redhat.com' port='49152'/>
<privateData>
<nodenames>
<nodename type='storage' name='migration-vdb-storage'/>
<nodename type='format' name='migration-vdb-format'/>
</nodenames>
</privateData>
</source>
</migrationSource>
</disk>
<disk dev='vdc' migrating='yes'>
<migrationSource type='network' format='raw' protocol='nbd' name='drive-virtio-disk2' tlsFromConfig='0'>
<host name='andariel.usersys.redhat.com' port='49152'/>
<privateData>
<nodenames>
<nodename type='storage' name='migration-vdc-storage'/>
<nodename type='format' name='migration-vdc-format'/>
</nodenames>
</privateData>
<migrationSource type='network' format='raw'>
<source protocol='nbd' name='drive-virtio-disk2' tlsFromConfig='0'>
<host name='andariel.usersys.redhat.com' port='49152'/>
<privateData>
<nodenames>
<nodename type='storage' name='migration-vdc-storage'/>
<nodename type='format' name='migration-vdc-format'/>
</nodenames>
</privateData>
</source>
</migrationSource>
</disk>
<disk dev='hda' migrating='no'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册