From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> For VM started and migrated/saved without slirp-helpers, let's prevent the automatic setup (as it would fail to migrate otherwise). Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 12 ++++++++++-- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 11 +++++++++-- src/qemu/qemu_process.c | 6 ++++-- src/qemu/qemu_process.h | 1 + 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bc34cdb3bf..bb719fc3c4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13962,7 +13962,7 @@ qemuDomainSaveCookieDispose(void *obj) qemuDomainSaveCookiePtr -qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED) +qemuDomainSaveCookieNew(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainSaveCookiePtr cookie = NULL; @@ -13976,7 +13976,10 @@ qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED) if (priv->origCPU && !(cookie->cpu = virCPUDefCopy(vm->def->cpu))) goto error; - VIR_DEBUG("Save cookie %p, cpu=%p", cookie, cookie->cpu); + cookie->hasSlirpHelper = qemuDomainHasSlirp(vm); + + VIR_DEBUG("Save cookie %p, cpu=%p, hasSlirpHelper=%d", + cookie, cookie->cpu, cookie->hasSlirpHelper); return cookie; @@ -14002,6 +14005,8 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED, &cookie->cpu) < 0) goto error; + cookie->hasSlirpHelper = virXPathBoolean("boolean(./hasSlirpHelper)", ctxt) > 0; + *obj = (virObjectPtr) cookie; return 0; @@ -14021,6 +14026,9 @@ qemuDomainSaveCookieFormat(virBufferPtr buf, virCPUDefFormatBufFull(buf, cookie->cpu, NULL) < 0) return -1; + if (cookie->hasSlirpHelper) + virBufferAddLit(buf, "<hasSlirpHelper/>\n"); + return 0; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index d35c800064..9a56a90a9a 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -560,6 +560,7 @@ struct _qemuDomainSaveCookie { virObject parent; virCPUDefPtr cpu; + bool hasSlirpHelper; }; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9c05ab4ad1..dda9389776 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6788,6 +6788,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUSaveHeaderPtr header = &data->header; qemuDomainSaveCookiePtr cookie = NULL; + unsigned int flags; if (virSaveCookieParseString(data->cookie, (virObjectPtr *)&cookie, virDomainXMLOptionGetSaveCookie(driver->xmlopt)) < 0) @@ -6819,11 +6820,14 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) goto cleanup; + flags = VIR_QEMU_PROCESS_START_PAUSED | VIR_QEMU_PROCESS_START_GEN_VMID; + if (!cookie->hasSlirpHelper) + flags |= VIR_QEMU_PROCESS_START_NO_SLIRP; + if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, asyncJob, "stdio", *fd, path, NULL, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, - VIR_QEMU_PROCESS_START_PAUSED | - VIR_QEMU_PROCESS_START_GEN_VMID) == 0) + flags) == 0) restored = true; if (intermediatefd != -1) { @@ -16298,6 +16302,9 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, start_flags |= VIR_QEMU_PROCESS_START_PAUSED; + if (!cookie->hasSlirpHelper) + start_flags |= VIR_QEMU_PROCESS_START_NO_SLIRP; + /* Transitions 2, 3, 5, 6, 8, 9 */ /* When using the loadvm monitor command, qemu does not know * whether to pause or run the reverted domain, and just stays diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5e8184b0e2..93e06104f4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6680,7 +6680,8 @@ qemuProcessLaunch(virConnectPtr conn, VIR_QEMU_PROCESS_START_PAUSED | VIR_QEMU_PROCESS_START_AUTODESTROY | VIR_QEMU_PROCESS_START_NEW | - VIR_QEMU_PROCESS_START_GEN_VMID, -1); + VIR_QEMU_PROCESS_START_GEN_VMID | + VIR_QEMU_PROCESS_START_NO_SLIRP, -1); cfg = virQEMUDriverGetConfig(driver); @@ -7092,7 +7093,8 @@ qemuProcessStart(virConnectPtr conn, virCheckFlagsGoto(VIR_QEMU_PROCESS_START_COLD | VIR_QEMU_PROCESS_START_PAUSED | VIR_QEMU_PROCESS_START_AUTODESTROY | - VIR_QEMU_PROCESS_START_GEN_VMID, cleanup); + VIR_QEMU_PROCESS_START_GEN_VMID | + VIR_QEMU_PROCESS_START_NO_SLIRP, cleanup); if (!migrateFrom && !snapshot) flags |= VIR_QEMU_PROCESS_START_NEW; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 1d62319092..09ef124838 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -81,6 +81,7 @@ typedef enum { VIR_QEMU_PROCESS_START_GEN_VMID = 1 << 5, /* Generate a new VMID */ VIR_QEMU_PROCESS_START_STANDALONE = 1 << 6, /* Require CLI args to be usable standalone, ie no FD passing and the like */ + VIR_QEMU_PROCESS_START_NO_SLIRP = 1 << 7, /* do not setup slirp-helpers */ } qemuProcessStartFlags; int qemuProcessStart(virConnectPtr conn, -- 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list