diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a546d9b5a1..b48bcbebee 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -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; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 820476dbb1..85952b9975 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -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: diff --git a/src/qemu/qemu_processpriv.h b/src/qemu/qemu_processpriv.h index 17f981829b..237d7bad58 100644 --- a/src/qemu/qemu_processpriv.h +++ b/src/qemu/qemu_processpriv.h @@ -38,4 +38,6 @@ int qemuProcessHandleDeviceDeleted(qemuMonitorPtr mon, const char *devAlias, void *opaque); +int qemuProcessQMPInitMonitor(qemuMonitorPtr mon); + #endif /* LIBVIRT_QEMU_PROCESSPRIV_H */ diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index fab77db7ce..8d47133e6f 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -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;