From nobody Wed May 14 13:55: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 1524215406663604.155139693579; Fri, 20 Apr 2018 02:10:06 -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 9FA3E3135AE6; Fri, 20 Apr 2018 09:10:04 +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 5180D61785; Fri, 20 Apr 2018 09:10:04 +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 C883865D19; Fri, 20 Apr 2018 09:10:03 +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 w3K99erB006785 for ; Fri, 20 Apr 2018 05:09:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD429AFD4C; Fri, 20 Apr 2018 09:09:40 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2556DAB5BC; Fri, 20 Apr 2018 09:09:40 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 20 Apr 2018 11:09:28 +0200 Message-Id: <88ae8e6d8e552744fbd647db190f156e7fe5a433.1524215100.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: zack.cornelius@kove.net, ehabkost@redhat.com Subject: [libvirt] [PATCH v4 2/5] qemu_monitor: Introduce qemuMonitorGetObjectProps 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.46]); Fri, 20 Apr 2018 09:10:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that we've gotten rid of misleading names we can introduce qemuMonitorGetObjectProps() function which queries -object properties. Again, some parts of code can be reused. Signed-off-by: Michal Privoznik Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_monitor.c | 13 +++++++++++++ src/qemu/qemu_monitor.h | 3 +++ src/qemu/qemu_monitor_json.c | 32 ++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ 4 files changed, 52 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index f642d9a51a..a1e2e40d0f 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3932,6 +3932,19 @@ qemuMonitorGetDeviceProps(qemuMonitorPtr mon, } =20 =20 +int +qemuMonitorGetObjectProps(qemuMonitorPtr mon, + const char *object, + char ***props) +{ + VIR_DEBUG("object=3D%s props=3D%p", object, props); + + QEMU_CHECK_MONITOR_JSON(mon); + + return qemuMonitorJSONGetObjectProps(mon, object, props); +} + + char * qemuMonitorGetTargetArch(qemuMonitorPtr mon) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index d6b68b44ca..0f648ce27c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1048,6 +1048,9 @@ int qemuMonitorGetObjectTypes(qemuMonitorPtr mon, int qemuMonitorGetDeviceProps(qemuMonitorPtr mon, const char *device, char ***props); +int qemuMonitorGetObjectProps(qemuMonitorPtr mon, + const char *object, + char ***props); char *qemuMonitorGetTargetArch(qemuMonitorPtr mon); =20 int qemuMonitorNBDServerStart(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 95b9d60aff..c6b9ccce39 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6129,6 +6129,38 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, } =20 =20 +int +qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon, + const char *object, + char ***props) +{ + int ret =3D -1; + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + + *props =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-list-properties", + "s:typename", object, + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) { + ret =3D 0; + goto cleanup; + } + + ret =3D qemuMonitorJSONParsePropsList(cmd, reply, props); + cleanup: + virJSONValueFree(reply); + virJSONValueFree(cmd); + return ret; +} + + char * qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon) { diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 665da27d6d..b4863a454a 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -445,6 +445,10 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, const char *device, char ***props) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); +int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon, + const char *object, + char ***props) + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); char *qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon); =20 int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon, --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list