Run 'qmp_capabilities' command at QEMU monitor startup
When in JSON mode, QEMU requires that 'qmp_capabilities' is run as the first command in the monitor. This is a no-op when run in the text mode monitor * src/qemu/qemu_driver.c: Run capabilities negotiation when connecting to the monitor * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h: Add support for the 'qmp_capabilities' command, no-op in text mode.
This commit is contained in:
parent
c841a1fa7f
commit
5d72a89442
@ -830,9 +830,10 @@ static qemuMonitorCallbacks monitorCallbacks = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuConnectMonitor(virDomainObjPtr vm)
|
qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Hold an extra reference because we can't allow 'vm' to be
|
/* Hold an extra reference because we can't allow 'vm' to be
|
||||||
* deleted while the monitor is active */
|
* deleted while the monitor is active */
|
||||||
@ -846,7 +847,16 @@ qemuConnectMonitor(virDomainObjPtr vm)
|
|||||||
return -1;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -868,7 +878,7 @@ qemuReconnectDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaq
|
|||||||
priv = obj->privateData;
|
priv = obj->privateData;
|
||||||
|
|
||||||
/* XXX check PID liveliness & EXE path */
|
/* XXX check PID liveliness & EXE path */
|
||||||
if (qemuConnectMonitor(obj) < 0)
|
if (qemuConnectMonitor(driver, obj) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (qemuUpdateActivePciHostdevs(driver, obj->def) < 0) {
|
if (qemuUpdateActivePciHostdevs(driver, obj->def) < 0) {
|
||||||
@ -1577,7 +1587,7 @@ qemudWaitForMonitor(struct qemud_driver* driver,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
VIR_DEBUG("Connect monitor to %p '%s'", vm, vm->def->name);
|
VIR_DEBUG("Connect monitor to %p '%s'", vm, vm->def->name);
|
||||||
if (qemuConnectMonitor(vm) < 0)
|
if (qemuConnectMonitor(driver, vm) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Try to get the pty path mappings again via the monitor. This is much more
|
/* Try to get the pty path mappings again via the monitor. This is much more
|
||||||
|
@ -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
|
int
|
||||||
qemuMonitorStartCPUs(qemuMonitorPtr mon,
|
qemuMonitorStartCPUs(qemuMonitorPtr mon,
|
||||||
virConnectPtr conn)
|
virConnectPtr conn)
|
||||||
|
@ -99,6 +99,8 @@ qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
|
|||||||
|
|
||||||
int qemuMonitorClose(qemuMonitorPtr mon);
|
int qemuMonitorClose(qemuMonitorPtr mon);
|
||||||
|
|
||||||
|
int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
|
||||||
|
|
||||||
void qemuMonitorLock(qemuMonitorPtr mon);
|
void qemuMonitorLock(qemuMonitorPtr mon);
|
||||||
void qemuMonitorUnlock(qemuMonitorPtr mon);
|
void qemuMonitorUnlock(qemuMonitorPtr mon);
|
||||||
|
|
||||||
|
@ -476,6 +476,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
|
int
|
||||||
qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
|
qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
|
||||||
virConnectPtr conn ATTRIBUTE_UNUSED)
|
virConnectPtr conn ATTRIBUTE_UNUSED)
|
||||||
|
@ -34,6 +34,8 @@ int qemuMonitorJSONIOProcess(qemuMonitorPtr mon,
|
|||||||
size_t len,
|
size_t len,
|
||||||
qemuMonitorMessagePtr msg);
|
qemuMonitorMessagePtr msg);
|
||||||
|
|
||||||
|
int qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon);
|
||||||
|
|
||||||
int qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
|
int qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
|
||||||
virConnectPtr conn);
|
virConnectPtr conn);
|
||||||
int qemuMonitorJSONStopCPUs(qemuMonitorPtr mon);
|
int qemuMonitorJSONStopCPUs(qemuMonitorPtr mon);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user