On Wed, Dec 20, 2017 at 04:47:49PM +0000, Daniel P. Berrange wrote:
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_driver.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_process.c | 31 ++++++++++++++++++---------
src/qemu/qemu_process.h | 1 +
3 files changed, 79 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 97b194b057..fea1f24250 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16300,6 +16300,62 @@ static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn,
}
+static virDomainPtr qemuDomainQemuReconnect(virConnectPtr conn,
+ const char *name,
+ unsigned int flags)
+{
+ virQEMUDriverPtr driver = conn->privateData;
+ virDomainObjPtr vm = NULL;
+ virDomainPtr dom = NULL;
+ virCapsPtr caps = NULL;
+ virQEMUDriverConfigPtr cfg;
+
+ virCheckFlags(0, NULL);
+
+ cfg = virQEMUDriverGetConfig(driver);
+
+ if (strchr(name, '/')) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("name %s cannot contain '/'"), name);
+ goto cleanup;
+ }
+
+ vm = virDomainObjListFindByName(driver->domains, name);
+ if (vm) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("Domain '%s' already exists"), name);
+ goto cleanup;
+ }
+
It should be possible to start existing inactive domain.
+ if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
You are leaking vm here. And we should start a job on it.
+ if (!(vm = virDomainObjListLoadStatus(driver->domains,
+ cfg->stateDir,
+ name,
+ caps,
+ driver->xmlopt,
+ NULL, NULL))) {
+ goto cleanup;
+ }
+
+ if (virDomainQemuReconnectEnsureACL(conn, vm->def) < 0) {
+ qemuDomainRemoveInactive(driver, vm);
Of course adjust according to above.