From nobody Wed May 14 20:05:05 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 1520608106637121.59664318947557; Fri, 9 Mar 2018 07:08:26 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D52E17FDED; Fri, 9 Mar 2018 15:08:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2801880F60; Fri, 9 Mar 2018 15:08:16 +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 6A2CD4CAA4; Fri, 9 Mar 2018 15:08:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w29F8643023760 for ; Fri, 9 Mar 2018 10:08:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5A5EA215CDAE; Fri, 9 Mar 2018 15:08:06 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 019F8215CDAA for ; Fri, 9 Mar 2018 15:08:05 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Fri, 9 Mar 2018 16:07:51 +0100 Message-Id: <20180309150754.11341-6-abologna@redhat.com> In-Reply-To: <20180309150754.11341-1-abologna@redhat.com> References: <20180309150754.11341-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] qemu: Extract generic part from qemuMonitorJSONGetDeviceProps() 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 09 Mar 2018 15:08:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Querying properties for devices and objects is identical except for the specific QMP command that needs to be called. Take the existing qemuMonitorJSONGetDeviceProps(), scrub all the device-specific parts, thus turning it into the generic helper qemuMonitorJSONGetProps(), which is then used to reimplement the original function and will be used again once object properties are needed. Signed-off-by: Andrea Bolognani Reviewed-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index eb32811cd1..141873a705 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6058,9 +6058,11 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr = mon, #undef MAKE_SET_CMD =20 =20 -int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, - const char *type, - char ***props) +static int +qemuMonitorJSONGetProps(qemuMonitorPtr mon, + const char *type, + char ***props, + const char *impl) { int ret =3D -1; virJSONValuePtr cmd; @@ -6072,7 +6074,7 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, =20 *props =3D NULL; =20 - if (!(cmd =3D qemuMonitorJSONMakeCommand("device-list-properties", + if (!(cmd =3D qemuMonitorJSONMakeCommand(impl, "s:typename", type, NULL))) return -1; @@ -6090,8 +6092,9 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, =20 if (!(data =3D virJSONValueObjectGetArray(reply, "return")) || (n =3D virJSONValueArraySize(data)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("device-list-properties reply data was not an arr= ay")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s reply data was not an array"), + impl); goto cleanup; } =20 @@ -6104,8 +6107,9 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, const char *tmp; =20 if (!(tmp =3D virJSONValueObjectGetString(child, "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("device-list-properties reply data was missin= g 'name'")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s reply data was missing 'name'"), + impl); goto cleanup; } =20 @@ -6125,6 +6129,16 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, } =20 =20 +int +qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, + const char *type, + char ***props) +{ + return qemuMonitorJSONGetProps(mon, type, props, + "device-list-properties"); +} + + char * qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon) { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list