From nobody Sun Feb 8 23:06:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1550567182845825.6664893786663; Tue, 19 Feb 2019 01:06:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 839BC787F0; Tue, 19 Feb 2019 09:06:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 422915D722; Tue, 19 Feb 2019 09:06:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D6490181A26B; Tue, 19 Feb 2019 09:06:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1J95IDE016253 for ; Tue, 19 Feb 2019 04:05:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 246435D6AA; Tue, 19 Feb 2019 09:05:18 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C45CD5D706 for ; Tue, 19 Feb 2019 09:05:17 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7B38D100116; Tue, 19 Feb 2019 10:05:09 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 19 Feb 2019 10:05:03 +0100 Message-Id: <9cbad94431aec33c4278fd8cdcc7c9e940082b4a.1550566126.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 20/20] qemu_process: Enter QMP command mode when starting QEMU Process X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 19 Feb 2019 09:06:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Chris Venteicher 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 Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 7: - qemuMonitorSetCapabilities call was moved into a new qemuProcessQMPInitMonitor function, which is called from qemuProcessQMPConnectMonitor and the tests src/qemu/qemu_capabilities.c | 12 ------------ src/qemu/qemu_process.c | 16 ++++++++++++++++ src/qemu/qemu_processpriv.h | 2 ++ tests/qemucapabilitiestest.c | 9 +++++++++ 4 files changed, 27 insertions(+), 12 deletions(-) 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, =20 /* @mon is supposed to be locked by callee */ =20 - 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 =3D -1; =20 - if (qemuMonitorSetCapabilities(mon) < 0) { - VIR_DEBUG("Failed to set monitor capabilities %s", - virGetLastErrorMessage()); - goto cleanup; - } - if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, true) < 0) goto cleanup; =20 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) } =20 =20 +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) =20 virObjectLock(proc->mon); =20 + if (qemuProcessQMPInitMonitor(proc->mon) < 0) + goto cleanup; + ret =3D 0; =20 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); =20 +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" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -60,6 +62,9 @@ testQemuCaps(const void *opaque) if (!(mon =3D qemuMonitorTestNewFromFileFull(repliesFile, &data->drive= r, NULL))) goto cleanup; =20 + if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0) + goto cleanup; + if (!(capsActual =3D virQEMUCapsNew()) || virQEMUCapsInitQMPMonitor(capsActual, qemuMonitorTestGetMonitor(mon)) < 0) @@ -67,6 +72,10 @@ testQemuCaps(const void *opaque) =20 if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) { qemuMonitorResetCommandID(qemuMonitorTestGetMonitor(mon)); + + if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0) + goto cleanup; + if (virQEMUCapsInitQMPMonitorTCG(capsActual, qemuMonitorTestGetMonitor(mon)) <= 0) goto cleanup; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list