mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
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: Chris Venteicher <cventeic@redhat.com> Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5724dca135
commit
5b13da5ca2
@ -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, µ,
|
||||
&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;
|
||||
|
Loading…
Reference in New Issue
Block a user