提交 07552343 编写于 作者: M Marc-André Lureau 提交者: Michal Privoznik

qemu: add a flag to the cookie to prevent slirp-helper setup

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: NMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 6d5a9b9e
......@@ -2671,6 +2671,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)
......@@ -14707,7 +14725,7 @@ qemuDomainSaveCookieDispose(void *obj)
qemuDomainSaveCookiePtr
qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED)
qemuDomainSaveCookieNew(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainSaveCookiePtr cookie = NULL;
......@@ -14721,7 +14739,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;
......@@ -14747,6 +14768,8 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
&cookie->cpu) < 0)
goto error;
cookie->slirpHelper = virXPathBoolean("boolean(./slirpHelper)", ctxt) > 0;
*obj = (virObjectPtr) cookie;
return 0;
......@@ -14766,6 +14789,9 @@ qemuDomainSaveCookieFormat(virBufferPtr buf,
virCPUDefFormatBufFull(buf, cookie->cpu, NULL) < 0)
return -1;
if (cookie->slirpHelper)
virBufferAddLit(buf, "<slirpHelper/>\n");
return 0;
}
......
......@@ -395,6 +395,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;
};
......
......@@ -6995,6 +6995,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
bool start_paused,
qemuDomainAsyncJob asyncJob)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1;
bool restored = false;
virObjectEventPtr event;
......@@ -7035,6 +7036,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,
......@@ -16771,6 +16775,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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册