From nobody Mon Feb 9 16:35:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669912344; cv=none; d=zohomail.com; s=zohoarc; b=YK9Lkg1EkXM68CmnKZFJy91VzzDPrA5+vHGqGmh9OuxolY6F7v8ZwUZsy4H4lwIo399eeRTWeyPt4s+BuJOSl0OuFk3u7SI/0K5MvLn1gLAvWH0/GZ0AFpoIJMXg8cMH5QCu2kftaxT1QmUNbJO7/DjOFGT6kHJcANpJjGJrsII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912344; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FMCGfGHMoWBe2jyBfIF2XsDYQrCLbExFaMqnZX1SSNI=; b=mB3x4BemnRo4tITFQAbzjm9Q3Crg4iTVgC5GpdO7m5OjcojVGWF9Yuqx1WXWETW05b6WhbH4g2LeIInhV6n1XOy2SGIY6PCSe7iqNDC3yW1kntGstGwuXZy+tOcnAd7dcAA/XDTeJcipdH8vuQGtQgxPRUTpfk3aFKoEcU33shQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1669912344439146.74902989004772; Thu, 1 Dec 2022 08:32:24 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-e9QtxqrhOIGWmO9u--vxLQ-1; Thu, 01 Dec 2022 11:31:41 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AAE673C0F23D; Thu, 1 Dec 2022 16:31:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 971F740C2065; Thu, 1 Dec 2022 16:31:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8757019465B1; Thu, 1 Dec 2022 16:31:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8B54F19465B2 for ; Thu, 1 Dec 2022 16:31:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7F339C15BB4; Thu, 1 Dec 2022 16:31:28 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAAEEC2C7D9 for ; Thu, 1 Dec 2022 16:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912342; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FMCGfGHMoWBe2jyBfIF2XsDYQrCLbExFaMqnZX1SSNI=; b=ixlMZon5MKzgOhbC9plFQWPu5SaFwK/vifJR446Xs7uqVUvxg3UllyINY2y1QX35F7y8YH /sy0/dGwjmIZTjannYP/OB8KVS839nSQbbCZejp/N+9sBhl+jFXu2Kg2wB7aMT9rh2ZeCX pK6iD47p0faCThZLW1XI0gf3SJ6KZ60= X-MC-Unique: e9QtxqrhOIGWmO9u--vxLQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/12] qemu: monitor: Use qemuMonitorJSONGetReply in conjunction with virJSONValueArrayToStringList Date: Thu, 1 Dec 2022 17:31:14 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669912345182100003 Content-Type: text/plain; charset="utf-8" In two instances (qemuMonitorJSONGetStringListProperty, qemuMonitorJSONGetStringArray) the return value is checked by qemuMonitorJSONCheckReply and extracted by virJSONValueObjectGetStringArray. We can use qemuMonitorJSONGetReply which returns it directly and then virJSONValueArrayToStringList to convert it without the additional lookup. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 1deb755130..39f313c2af 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5522,6 +5522,7 @@ qemuMonitorJSONGetStringListProperty(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; + virJSONValue *data; *strList =3D NULL; @@ -5534,10 +5535,10 @@ qemuMonitorJSONGetStringListProperty(qemuMonitor *m= on, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return -1; - if (!(*strList =3D virJSONValueObjectGetStringArray(reply, "return"))) + if (!(*strList =3D virJSONValueArrayToStringList(data))) return -1; return 0; @@ -6297,6 +6298,7 @@ qemuMonitorJSONGetStringArray(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; + virJSONValue *data; *array =3D NULL; @@ -6309,10 +6311,10 @@ qemuMonitorJSONGetStringArray(qemuMonitor *mon, if (qemuMonitorJSONHasError(reply, "CommandNotFound")) return 0; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return -1; - if (!(*array =3D virJSONValueObjectGetStringArray(reply, "return"))) + if (!(*array =3D virJSONValueArrayToStringList(data))) return -1; return 0; --=20 2.38.1