From nobody Wed May 14 06:05:18 2025 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 1525542554465602.9392023400235; Sat, 5 May 2018 10:49:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F4D483F46; Sat, 5 May 2018 17:49:07 +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 181175C20D; Sat, 5 May 2018 17:49:06 +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 A7F4A180BAE5; Sat, 5 May 2018 17:49:04 +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 w45Hn1pr004359 for ; Sat, 5 May 2018 13:49:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id E1F0E7C37; Sat, 5 May 2018 17:49:00 +0000 (UTC) Received: from cv1.home.network (ovpn-120-127.rdu2.redhat.com [10.10.120.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id F30F6108486; Sat, 5 May 2018 17:48:59 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Sat, 5 May 2018 12:48:45 -0500 Message-Id: <20180505174849.31136-4-cventeic@redhat.com> In-Reply-To: <20180505174849.31136-1-cventeic@redhat.com> References: <20180505174849.31136-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 3/7] qemu_capabilities: Start and connect to QEMU 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 05 May 2018 17:49:13 +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 | 59 ++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 59 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index afce3eb2b7..097985cbe7 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4303,6 +4303,65 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPComma= ndPtr cmd, } =20 =20 +/* Start and connect to QEMU so QMP commands can be performed. + */ +static virQEMUCapsInitQMPCommandPtr +virQEMUCapsSpinUpQemu(const char *exec, + const char *libDir, uid_t runUid, gid_t runGid, + bool forceTCG) +{ + virQEMUCapsInitQMPCommandPtr cmd =3D NULL; + virQEMUCapsInitQMPCommandPtr rtn_cmd =3D NULL; + char *binary =3D NULL; + + if (exec) { + if (VIR_STRDUP(binary, exec) < 0) + goto cleanup; + } else { + /* Check for existence of base emulator, or alternate base + * which can be used with magic cpu choice + */ + virArch arch =3D virArchFromHost(); + binary =3D virQEMUCapsFindBinaryForArch(arch, arch); + } + + VIR_DEBUG("binary=3D%s", binary); + + /* Make sure the binary we are about to try exec'ing exists. + * Technically we could catch the exec() failure, but that's + * in a sub-process so it's hard to feed back a useful error. + */ + if (!virFileIsExecutable(binary)) { + virReportSystemError(errno, _("QEMU binary %s is not executable"), + binary); + goto cleanup; + } + + if (!(cmd =3D virQEMUCapsInitQMPCommandNew(binary, libDir, + runUid, runGid, NULL))) + goto cleanup; + + if ((virQEMUCapsInitQMPCommandRun(cmd, forceTCG)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error starting QEM= U")); + goto cleanup; + } + + if (!(cmd->mon)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Error connecting to QEMU")); + goto cleanup; + } + + VIR_STEAL_PTR(rtn_cmd, cmd); + + cleanup: + virQEMUCapsInitQMPCommandFree(cmd); + VIR_FREE(binary); + + return rtn_cmd; +} + + static int virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, const char *libDir, --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list