From nobody Mon Dec 15 23:05:26 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 1524215397773576.7415971371928; Fri, 20 Apr 2018 02:09:57 -0700 (PDT) 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 511D930014A3; Fri, 20 Apr 2018 09:09:56 +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 2589C5D780; Fri, 20 Apr 2018 09:09:56 +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 49516180596E; Fri, 20 Apr 2018 09:09:55 +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 w3K99dGV006779 for ; Fri, 20 Apr 2018 05:09:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id DED3AAFD4C; Fri, 20 Apr 2018 09:09:39 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46CB2AB5BC; Fri, 20 Apr 2018 09:09:39 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 20 Apr 2018 11:09:27 +0200 Message-Id: <7441f71238b2003ece4d2138d131aeae5cdc33c3.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 1/5] qemuMonitorJSONGetDeviceProps: Separate props processing 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 20 Apr 2018 09:09:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The code that processes list of device properties is going to be reused. Therefore put it into a separate function. Signed-off-by: Michal Privoznik Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_monitor_json.c | 59 +++++++++++++++++++++++++++-------------= ---- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 24d37eb41d..95b9d60aff 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6053,35 +6053,19 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr= mon, #undef MAKE_SET_CMD =20 =20 -int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, - const char *device, - char ***props) +static int +qemuMonitorJSONParsePropsList(virJSONValuePtr cmd, + virJSONValuePtr reply, + char ***props) { - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; virJSONValuePtr data; char **proplist =3D NULL; ssize_t n =3D 0; size_t i; - - *props =3D NULL; - - if (!(cmd =3D qemuMonitorJSONMakeCommand("device-list-properties", - "s:typename", device, - NULL))) - return -1; - - if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) { - ret =3D 0; - goto cleanup; - } + int ret =3D -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return ret; =20 data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); @@ -6110,8 +6094,37 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, =20 cleanup: virStringListFree(proplist); - virJSONValueFree(cmd); + return ret; +} + + +int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon, + const char *device, + char ***props) +{ + int ret =3D -1; + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + + *props =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("device-list-properties", + "s:typename", device, + 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; } =20 --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list