提交 19bade7a 编写于 作者: J Jiri Denemark

qemu: Create a wrapper around qemuMonitorSetCapabilities

The new function is called qemuProcessInitMonitor and it will enter/exit
the monitor so that the caller doesn't have to deal with this.

The goal of this patch is to simplify the code in qemuConnectMonitor
which would otherwise be a bit hairy after the following patch.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 6094d6ec
...@@ -1730,12 +1730,31 @@ qemuProcessMonitorLogFree(void *opaque) ...@@ -1730,12 +1730,31 @@ qemuProcessMonitorLogFree(void *opaque)
virObjectUnref(logCtxt); virObjectUnref(logCtxt);
} }
static int
qemuProcessInitMonitor(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob)
{
int ret;
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1;
ret = qemuMonitorSetCapabilities(QEMU_DOMAIN_PRIVATE(vm)->mon);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
return ret;
}
static int static int
qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob, qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob,
qemuDomainLogContextPtr logCtxt) qemuDomainLogContextPtr logCtxt)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1;
qemuMonitorPtr mon = NULL; qemuMonitorPtr mon = NULL;
unsigned long long timeout = 0; unsigned long long timeout = 0;
...@@ -1794,13 +1813,12 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob, ...@@ -1794,13 +1813,12 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob,
return -1; return -1;
} }
if (qemuProcessInitMonitor(driver, vm, asyncJob) < 0)
return -1;
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1; return -1;
if (qemuMonitorSetCapabilities(priv->mon) < 0)
goto cleanup;
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT) && if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT) &&
qemuMonitorSetMigrationCapability(priv->mon, qemuMonitorSetMigrationCapability(priv->mon,
QEMU_MONITOR_MIGRATION_CAPS_EVENTS, QEMU_MONITOR_MIGRATION_CAPS_EVENTS,
...@@ -1809,12 +1827,10 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob, ...@@ -1809,12 +1827,10 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob,
virQEMUCapsClear(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT); virQEMUCapsClear(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
} }
ret = 0;
cleanup:
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1; return -1;
return ret;
return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册