From nobody Sun Feb 8 10:33:57 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 1529642584517396.6165913570379; Thu, 21 Jun 2018 21:43:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3ACCC37EEA; Fri, 22 Jun 2018 04:43:03 +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 02C5A7839D; Fri, 22 Jun 2018 04:43:03 +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 ABB0418037EC; Fri, 22 Jun 2018 04:43:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5M4gjjf022129 for ; Fri, 22 Jun 2018 00:42:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 819BB1C700; Fri, 22 Jun 2018 04:42:45 +0000 (UTC) Received: from cv1.lan (ovpn-120-56.rdu2.redhat.com [10.10.120.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02CFB1C718; Fri, 22 Jun 2018 04:42:44 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Thu, 21 Jun 2018 23:42:09 -0500 Message-Id: <20180622044211.2212-11-cventeic@redhat.com> In-Reply-To: <20180622044211.2212-1-cventeic@redhat.com> References: <20180622044211.2212-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCHv1 10/12] qemu_capabilities: Introduce virQEMUCapsNewQMPCommandConnection 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: , MIME-Version: 1.0 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 22 Jun 2018 04:43:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Start and connect to QEMU so QMP commands can be performed. Isolates code for starting QEMU and establishing Monitor connections from code for obtaining capabilities so that arbitrary QMP commands can be exchanged with QEMU. --- src/qemu/qemu_capabilities.c | 40 +++++++++++++++++++++++++++++++++++- src/qemu/qemu_capabilities.h | 5 +++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2bbbfc83f3..658f88b327 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4285,7 +4285,7 @@ virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPComma= ndPtr cmd) =20 =20 static virQEMUCapsInitQMPCommandPtr -virQEMUCapsInitQMPCommandNew(char *binary, +virQEMUCapsInitQMPCommandNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, @@ -4426,6 +4426,44 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPComma= ndPtr cmd, } =20 =20 +/* Start and connect to QEMU so QMP commands can be performed. + */ +virQEMUCapsInitQMPCommandPtr +virQEMUCapsNewQMPCommandConnection(const char *exec, + const char *libDir, uid_t runUid, gid_t runGid, + bool forceTCG) +{ + virQEMUCapsInitQMPCommandPtr cmd =3D NULL; + virQEMUCapsInitQMPCommandPtr rtn_cmd =3D NULL; + + VIR_DEBUG("exec =3D%s", NULLSTR(exec)); + + /* Allocate and initialize QMPCommand structure */ + if (!(cmd =3D virQEMUCapsInitQMPCommandNew(exec, libDir, + runUid, runGid, NULL))) + goto cleanup; + + /* Spawn QEMU and establish connection for QMP commands */ + if (virQEMUCapsInitQMPCommandRun(cmd, forceTCG) !=3D 0) + goto cleanup; + + /* Exit capabilities negotiation mode and enter QEMU command mode + * by issuing qmp_capabilities command to QEMU */ + if (qemuMonitorSetCapabilities(cmd->mon) < 0) { + VIR_DEBUG("Failed to set monitor capabilities %s", + virGetLastErrorMessage()); + goto cleanup; + } + + VIR_STEAL_PTR(rtn_cmd, cmd); + + cleanup: + virQEMUCapsInitQMPCommandFree(cmd); + + return rtn_cmd; +} + + static int virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, const char *libDir, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index c9618bb754..9a62b014ac 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -507,6 +507,11 @@ struct _virQEMUCapsInitQMPCommand { virDomainObjPtr vm; }; =20 +virQEMUCapsInitQMPCommandPtr +virQEMUCapsNewQMPCommandConnection(const char *exec, + const char *libDir, uid_t runUid, gid_t= runGid, + bool forceTCG); + void virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPCommandPtr cmd); =20 typedef struct _virQEMUCaps virQEMUCaps; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list