提交 5b13da5c 编写于 作者: C Chris Venteicher 提交者: Jiri Denemark

qemu_process: Enter QMP command mode when starting QEMU Process

qemuProcessQMPStart starts a QEMU process and monitor connection that
can be used by multiple functions possibly for multiple QMP commands.

The QMP exchange to exit capabilities negotiation mode and enter command
mode can only be performed once after the monitor connection is
established.

Move responsibility for entering QMP command mode into the
qemuProcessQMP code so multiple functions can issue QMP commands in
arbitrary orders.

This also simplifies the functions using the connection provided by
qemuProcessQMPStart to issue QMP commands.

Test code now needs to call qemuMonitorSetCapabilities to send the
message to switch to command mode because the test code does not use the
qemuProcessQMP command that internally calls qemuMonitorSetCapabilities.
Signed-off-by: NChris Venteicher <cventeic@redhat.com>
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 5724dca1
......@@ -4149,12 +4149,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
/* @mon is supposed to be locked by callee */
if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage());
goto cleanup;
}
if (qemuMonitorGetVersion(mon,
&major, &minor, &micro,
&package) < 0) {
......@@ -4333,12 +4327,6 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
{
int ret = -1;
if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage());
goto cleanup;
}
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, true) < 0)
goto cleanup;
......
......@@ -8544,6 +8544,19 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
}
int
qemuProcessQMPInitMonitor(qemuMonitorPtr mon)
{
if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage());
return -1;
}
return 0;
}
static int
qemuProcessQMPConnectMonitor(qemuProcessQMPPtr proc)
{
......@@ -8570,6 +8583,9 @@ qemuProcessQMPConnectMonitor(qemuProcessQMPPtr proc)
virObjectLock(proc->mon);
if (qemuProcessQMPInitMonitor(proc->mon) < 0)
goto cleanup;
ret = 0;
cleanup:
......
......@@ -38,4 +38,6 @@ int qemuProcessHandleDeviceDeleted(qemuMonitorPtr mon,
const char *devAlias,
void *opaque);
int qemuProcessQMPInitMonitor(qemuMonitorPtr mon);
#endif /* LIBVIRT_QEMU_PROCESSPRIV_H */
......@@ -26,6 +26,8 @@
#include "qemu/qemu_capspriv.h"
#define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW
#include "qemu/qemu_monitor_priv.h"
#define LIBVIRT_QEMU_PROCESSPRIV_H_ALLOW
#include "qemu/qemu_processpriv.h"
#define VIR_FROM_THIS VIR_FROM_NONE
......@@ -60,6 +62,9 @@ testQemuCaps(const void *opaque)
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL)))
goto cleanup;
if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)
goto cleanup;
if (!(capsActual = virQEMUCapsNew()) ||
virQEMUCapsInitQMPMonitor(capsActual,
qemuMonitorTestGetMonitor(mon)) < 0)
......@@ -67,6 +72,10 @@ testQemuCaps(const void *opaque)
if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) {
qemuMonitorResetCommandID(qemuMonitorTestGetMonitor(mon));
if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)
goto cleanup;
if (virQEMUCapsInitQMPMonitorTCG(capsActual,
qemuMonitorTestGetMonitor(mon)) < 0)
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册