---
src/qemu/qemu_driver.c | 18 ++++++++++++++----
src/qemu/qemu_monitor.c | 13 +++++++++++++
src/qemu/qemu_monitor.h | 2 ++
src/qemu/qemu_monitor_json.c | 20 ++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 2 ++
5 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 03feaf4..e5b11bc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -829,9 +829,10 @@ static qemuMonitorCallbacks monitorCallbacks = {
};
static int
-qemuConnectMonitor(virDomainObjPtr vm)
+qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
+ int ret;
/* Hold an extra reference because we can't allow 'vm' to be
* deleted while the monitor is active */
@@ -845,7 +846,16 @@ qemuConnectMonitor(virDomainObjPtr vm)
return -1;
}
- return 0;
+ qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ ret = qemuMonitorSetCapabilities(priv->mon);
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+
+ if (ret < 0) {
+ qemuMonitorClose(priv->mon);
+ priv->mon = NULL;
+ }
+
+ return ret;
}
/*
@@ -867,7 +877,7 @@ qemuReconnectDomain(void *payload, const char *name ATTRIBUTE_UNUSED,
void *opaq
priv = obj->privateData;
/* XXX check PID liveliness & EXE path */
- if (qemuConnectMonitor(obj) < 0)
+ if (qemuConnectMonitor(driver, obj) < 0)
goto error;
if (qemuUpdateActivePciHostdevs(driver, obj->def) < 0) {
@@ -1576,7 +1586,7 @@ qemudWaitForMonitor(struct qemud_driver* driver,
return -1;
VIR_DEBUG("Connect monitor to %p '%s'", vm, vm->def->name);
- if (qemuConnectMonitor(vm) < 0)
+ if (qemuConnectMonitor(driver, vm) < 0)
return -1;
/* Try to get the pty path mappings again via the monitor. This is much more
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index c1d369b..b88532c 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -791,6 +791,19 @@ int qemuMonitorEmitStop(qemuMonitorPtr mon)
}
+int qemuMonitorSetCapabilities(qemuMonitorPtr mon)
+{
+ int ret;
+ DEBUG("mon=%p, fd=%d", mon, mon->fd);
+
+ if (mon->json)
+ ret = qemuMonitorJSONSetCapabilities(mon);
+ else
+ ret = 0;
+ return ret;
+}
+
+
int
qemuMonitorStartCPUs(qemuMonitorPtr mon,
virConnectPtr conn)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 786ad7a..0ac3957 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -99,6 +99,8 @@ qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
int qemuMonitorClose(qemuMonitorPtr mon);
+int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
+
void qemuMonitorLock(qemuMonitorPtr mon);
void qemuMonitorUnlock(qemuMonitorPtr mon);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index c9b8d60..f0dcf81 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -477,6 +477,26 @@ static void qemuMonitorJSONHandleStop(qemuMonitorPtr mon,
virJSONValuePtr data A
int
+qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon)
+{
+ int ret;
+ virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("qmp_capabilities",
NULL);
+ virJSONValuePtr reply = NULL;
+ if (!cmd)
+ return -1;
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
+
+int
qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
virConnectPtr conn ATTRIBUTE_UNUSED)
{
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 65a70e3..c6a6d51 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -34,6 +34,8 @@ int qemuMonitorJSONIOProcess(qemuMonitorPtr mon,
size_t len,
qemuMonitorMessagePtr msg);
+int qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon);
+
int qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
virConnectPtr conn);
int qemuMonitorJSONStopCPUs(qemuMonitorPtr mon);
--
1.6.6