mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: domain: Extract parsing of NBD status XML
Extract the NBD portion of the 'job' status XML element parser into a separate function. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
0d6ec712d3
commit
35a8487ad9
@ -2367,16 +2367,50 @@ qemuDomainObjPrivateXMLParsePR(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm,
|
||||||
|
qemuDomainObjPrivatePtr priv,
|
||||||
|
xmlXPathContextPtr ctxt)
|
||||||
|
{
|
||||||
|
xmlNodePtr *nodes = NULL;
|
||||||
|
size_t i;
|
||||||
|
int n;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if ((n = virXPathNodeSet("./disk[@migrating='yes']", ctxt, &nodes)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (n > 0) {
|
||||||
|
if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) {
|
||||||
|
VIR_WARN("Found disks marked for migration but we were not "
|
||||||
|
"migrating");
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
char *dst = virXMLPropString(nodes[i], "dev");
|
||||||
|
virDomainDiskDefPtr disk;
|
||||||
|
|
||||||
|
if (dst && (disk = virDomainDiskByName(vm->def, dst, false)))
|
||||||
|
QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating = true;
|
||||||
|
VIR_FREE(dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(nodes);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm,
|
qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm,
|
||||||
qemuDomainObjPrivatePtr priv,
|
qemuDomainObjPrivatePtr priv,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
xmlNodePtr *nodes = NULL;
|
|
||||||
xmlNodePtr savedNode = ctxt->node;
|
xmlNodePtr savedNode = ctxt->node;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
size_t i;
|
|
||||||
int n;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(ctxt->node = virXPathNode("./job[1]", ctxt))) {
|
if (!(ctxt->node = virXPathNode("./job[1]", ctxt))) {
|
||||||
@ -2423,26 +2457,9 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n = virXPathNodeSet("./disk[@migrating='yes']", ctxt, &nodes)) < 0)
|
if (qemuDomainObjPrivateXMLParseJobNBD(vm, priv, ctxt) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (n > 0) {
|
|
||||||
if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) {
|
|
||||||
VIR_WARN("Found disks marked for migration but we were not "
|
|
||||||
"migrating");
|
|
||||||
n = 0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
char *dst = virXMLPropString(nodes[i], "dev");
|
|
||||||
virDomainDiskDefPtr disk;
|
|
||||||
|
|
||||||
if (dst && (disk = virDomainDiskByName(vm->def, dst, false)))
|
|
||||||
QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating = true;
|
|
||||||
VIR_FREE(dst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VIR_FREE(nodes);
|
|
||||||
|
|
||||||
if (qemuMigrationParamsParse(ctxt, &priv->job.migParams) < 0)
|
if (qemuMigrationParamsParse(ctxt, &priv->job.migParams) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -2451,7 +2468,6 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm,
|
|||||||
cleanup:
|
cleanup:
|
||||||
ctxt->node = savedNode;
|
ctxt->node = savedNode;
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
VIR_FREE(nodes);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user