In order for the user to be able to fix broken domains function
qemuDomainGetXMLDesc() needs to be able to lookup invalid domain
definitions and handle them properly. When redefined, function
qemuDomainDefineXMLFlags() must clear the 'invalid XML' reason. As a
nice addition, qemuDomainGetState() can lookup such domains without any
other change and that allows virsh not only to get their status, but
also to list them.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_driver.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e89dfcd09d4a..0f8a19836c43 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2711,7 +2711,7 @@ qemuDomainGetState(virDomainPtr dom,
virCheckFlags(0, -1);
- if (!(vm = qemuDomObjFromDomain(dom)))
+ if (!(vm = qemuDomObjFromDomainInvalid(dom)))
goto cleanup;
if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
@@ -7086,19 +7086,23 @@ qemuDomainGetXMLDesc(virDomainPtr dom,
/* Flags checked by virDomainDefFormat */
- if (!(vm = qemuDomObjFromDomain(dom)))
+ if (!(vm = qemuDomObjFromDomainInvalid(dom)))
goto cleanup;
if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
- if (qemuDomainUpdateCurrentMemorySize(driver, vm) < 0)
- goto cleanup;
+ if (vm->def->parseError) {
+ ignore_value(VIR_STRDUP(ret, vm->def->xmlStr));
+ } else {
+ if (qemuDomainUpdateCurrentMemorySize(driver, vm) < 0)
+ goto cleanup;
- if ((flags & VIR_DOMAIN_XML_MIGRATABLE))
- flags |= QEMU_DOMAIN_FORMAT_LIVE_FLAGS;
+ if ((flags & VIR_DOMAIN_XML_MIGRATABLE))
+ flags |= QEMU_DOMAIN_FORMAT_LIVE_FLAGS;
- ret = qemuDomainFormatXML(driver, vm, flags);
+ ret = qemuDomainFormatXML(driver, vm, flags);
+ }
cleanup:
virDomainObjEndAPI(&vm);
@@ -7566,6 +7570,9 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
goto cleanup;
}
+ if (oldDef && oldDef->parseError)
+ virDomainObjSetState(vm, virDomainObjGetState(vm, NULL), 0);
+
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_DEFINED,
!oldDef ?
--
2.6.3