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 | 30 ++++++++++++++++++++++++++++-- src/qemu/qemu_domain.h | 2 ++ src/qemu/qemu_driver.c | 8 ++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b6f7e8bacc..04301c0a15 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2652,6 +2652,24 @@ qemuDomainHasSlirp(virDomainObjPtr vm) } +static bool +qemuDomainGetSlirpHelperOk(virDomainObjPtr vm) +{ + size_t i; + + for (i = 0; i < vm->def->nnets; i++) { + virDomainNetDefPtr net = vm->def->nets[i]; + + /* if there is a builtin slirp, prevent slirp-helper */ + if (net->type == VIR_DOMAIN_NET_TYPE_USER && + !QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) + return false; + } + + return true; +} + + static int qemuDomainObjPrivateXMLFormatSlirp(virBufferPtr buf, virDomainObjPtr vm) @@ -14546,7 +14564,7 @@ qemuDomainSaveCookieDispose(void *obj) qemuDomainSaveCookiePtr -qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED) +qemuDomainSaveCookieNew(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainSaveCookiePtr cookie = NULL; @@ -14560,7 +14578,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->slirpHelper = qemuDomainGetSlirpHelperOk(vm); + + VIR_DEBUG("Save cookie %p, cpu=%p, slirpHelper=%d", + cookie, cookie->cpu, cookie->slirpHelper); return cookie; @@ -14586,6 +14607,8 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED, &cookie->cpu) < 0) goto error; + cookie->slirpHelper = virXPathBoolean("boolean(./slirpHelper)", ctxt) > 0; + *obj = (virObjectPtr) cookie; return 0; @@ -14605,6 +14628,9 @@ qemuDomainSaveCookieFormat(virBufferPtr buf, virCPUDefFormatBufFull(buf, cookie->cpu, NULL) < 0) return -1; + if (cookie->slirpHelper) + virBufferAddLit(buf, "<slirpHelper/>\n"); + return 0; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 84c39dfb54..caa2aff965 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -394,6 +394,7 @@ struct _qemuDomainObjPrivate { virHashTablePtr blockjobs; virHashTablePtr dbusVMStates; + bool disableSlirp; }; #define QEMU_DOMAIN_PRIVATE(vm) \ @@ -559,6 +560,7 @@ struct _qemuDomainSaveCookie { virObject parent; virCPUDefPtr cpu; + bool slirpHelper; }; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ff83d1c024..4b49203738 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6971,6 +6971,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, bool start_paused, qemuDomainAsyncJob asyncJob) { + qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; bool restored = false; virObjectEventPtr event; @@ -7011,6 +7012,9 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) goto cleanup; + if (!cookie->slirpHelper) + priv->disableSlirp = true; + if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, asyncJob, "stdio", *fd, path, NULL, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, @@ -16654,6 +16658,10 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, virCPUDefFree(priv->origCPU); VIR_STEAL_PTR(priv->origCPU, origCPU); } + + if (cookie && !cookie->slirpHelper) + priv->disableSlirp = true; + } else { /* Transitions 2, 3 */ load: -- 2.23.0.rc1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list