From nobody Sat Feb 7 17:54:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1669912295; cv=none; d=zohomail.com; s=zohoarc; b=ZCIxrllyQvZsBxTY601vNfXFk1E+m3ezK4PbH0ra7fzSFVPhZhjUV98gE0LiTxWKVOoO0kulXMg4ozv4YmY9xo0Xz7lT+yQ50SQGQu+esX82Jt/LT4jgptqf6QlphE42wLaWMXaYWAKq5xBysoeP51AqPmINxpnn4qM3NejF1d8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912295; 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=Whsp8Vse6kGQa3RfWSrG3GxJJIeE0yUm3PrvvSgWNvs=; b=U/vO801NNdODXOX364HGJk0ooYH0Tzs//kNEx6sb+wN3e8gqFRsUA7xoHn0ouO1b0cOnYgROFWbdfCS0phAGhKoT9zTiimGjDtZ6kuIRz/anHA0lzcU6RKftsstDbPrNSrlImJq6Ou1CHKA1lMakhKnY1kAoRI9bY3Nk39HCopk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1669912295426673.8797810887266; Thu, 1 Dec 2022 08:31:35 -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-357-vFwlgjgaPhaLPiG37ntqJw-1; Thu, 01 Dec 2022 11:31:30 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6DE69296A60E; Thu, 1 Dec 2022 16:31:22 +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 5A1AD492B28; Thu, 1 Dec 2022 16:31:22 +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 7FFA81946A68; Thu, 1 Dec 2022 16:31:20 +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 2815F19465A8 for ; Thu, 1 Dec 2022 16:31:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 18883C154AB; Thu, 1 Dec 2022 16:31:19 +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 869AAC15BB4 for ; Thu, 1 Dec 2022 16:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912294; 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=Whsp8Vse6kGQa3RfWSrG3GxJJIeE0yUm3PrvvSgWNvs=; b=VnHaD2QZpxlP5MFGWGNAp0AQglKOuvNbHypZg/Nhc6PTRbxiuuAtA+PjDjvV+bpq214R7B o7pracsCpXWdn9Me+4TM5OKuRDUSzGMncReFje+N0BYX71kp/ExxKa2u7prrqbXc2Nz/nd 2XvpIvW2oBntbgTim7tZmMEzLMHww0I= X-MC-Unique: vFwlgjgaPhaLPiG37ntqJw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/12] qemu: monitor: Introduce qemuMonitorJSONGetReply, a better qemuMonitorJSONCheckReply Date: Thu, 1 Dec 2022 17:31:05 +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.10 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: 1669912296832100001 Content-Type: text/plain; charset="utf-8" Rather than simply checking that the 'return' field is of the expected type we can directly return it as the caller is very likely going to use it. Extract the code into the new function and add a wrapper to preserve old functionality. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index f4e942a32f..e6cfaaf0e9 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -396,15 +396,15 @@ qemuMonitorJSONCheckError(virJSONValue *cmd, } -static int -qemuMonitorJSONCheckReply(virJSONValue *cmd, - virJSONValue *reply, - virJSONType type) +static virJSONValue * +qemuMonitorJSONGetReply(virJSONValue *cmd, + virJSONValue *reply, + virJSONType type) { virJSONValue *data; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - return -1; + return NULL; data =3D virJSONValueObjectGet(reply, "return"); if (virJSONValueGetType(data) !=3D type) { @@ -417,9 +417,21 @@ qemuMonitorJSONCheckReply(virJSONValue *cmd, _("unexpected type returned by QEMU command '%s'"), qemuMonitorJSONCommandName(cmd)); - return -1; + return NULL; } + return data; +} + + +static int +qemuMonitorJSONCheckReply(virJSONValue *cmd, + virJSONValue *reply, + virJSONType type) +{ + if (!qemuMonitorJSONGetReply(cmd, reply, type)) + return -1; + return 0; } --=20 2.38.1 From nobody Sat Feb 7 17:54:42 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=1669912356; cv=none; d=zohomail.com; s=zohoarc; b=ci1ibfVm3WFiqeo7bkhcQvFdBoVOiUizD7PZ3t0HRnto7sPVnIgnZCAC6kPsv0JGYFtZCxFRlqdalE8nCmpQL6CfMcVia+H7h2xQd1gID8efGpjwl9RbAZVhuxXfkfdqK+FN7Gr2emCni6KRJp+Kq5Chr6WOTBr+TmbaoYXuCOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912356; 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=IjlePN8a3vBSz7YjBsBxjBa1u41TKWqRqljYRtrUhzo=; b=A5I42gexc6WZ43WXKProZSpc9AwabalGPAVdMdLoEalPDukXQpMdBQoCDg8Ehy1cy0b+jWjANLziXxgWDWX9DtxSGt2DBPdyqm5KDNnnE902hioNLdsvw2c6KELR3xo52GD5rQb+mw6DeIwE7aEXvIH9UGhGciUoRwzsv39okEo= 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 1669912356656100.6967825505609; Thu, 1 Dec 2022 08:32:36 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-ZQHcnDrjNKauTm264v3ABg-1; Thu, 01 Dec 2022 11:31:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12A77101E167; Thu, 1 Dec 2022 16:31:23 +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 D794C2037E6F; Thu, 1 Dec 2022 16:31:22 +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 B92871947046; Thu, 1 Dec 2022 16:31:20 +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 232E41946A67 for ; Thu, 1 Dec 2022 16:31:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0760DC16922; Thu, 1 Dec 2022 16:31:20 +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 7331CC15BB4 for ; Thu, 1 Dec 2022 16:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912355; 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=IjlePN8a3vBSz7YjBsBxjBa1u41TKWqRqljYRtrUhzo=; b=f6Fmk2eJg94abcNrFtE7pHo2NZmxOiwHfg08qbME8BqWKBgmf17hyVrceDuFpAju/LF1DO drZuwuGpjGJQlSSz3d1QMv5JDu4XGwFhBsfJ0Nf9jDHXopiQS9k5aC3fK82x0O4j+HQI0N KyW9tK+lp+5PJUbuwm5aHS1u2zIOIno= X-MC-Unique: ZQHcnDrjNKauTm264v3ABg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/12] qemu: monitor: Use qemuMonitorJSONGetReply for VIR_JSON_TYPE_OBJECT Date: Thu, 1 Dec 2022 17:31:06 +0100 Message-Id: <12d861013191b5c40758161564f617236eee9fa0.1669912195.git.pkrempa@redhat.com> 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.4 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: 1669912357424100001 Content-Type: text/plain; charset="utf-8" Replace usage of the following pattern with the new helper: if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) return -1; data =3D virJSONValueObjectGetObject(reply, "return"); Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 52 +++++++++--------------------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e6cfaaf0e9..e3fe068c1b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1481,11 +1481,9 @@ qemuMonitorJSONGetStatus(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (virJSONValueObjectGetBoolean(data, "running", running) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-status reply was missing running state")); @@ -1866,11 +1864,9 @@ qemuMonitorJSONGetBalloonInfo(qemuMonitor *mon, } /* See if any other fatal error occurred */ - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (virJSONValueObjectGetNumberUlong(data, "actual", &mem) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("info balloon reply was missing balloon data")); @@ -1964,11 +1960,9 @@ qemuMonitorJSONGetMemoryStats(qemuMonitor *mon, } } - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return got; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (!(statsdata =3D virJSONValueObjectGet(data, "stats"))) { VIR_DEBUG("data does not include 'stats'"); return got; @@ -3165,11 +3159,9 @@ qemuMonitorJSONGetMigrationBlockers(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (!(jblockers =3D virJSONValueObjectGetArray(data, "blocked-reasons"= ))) return 0; @@ -3244,11 +3236,9 @@ qemuMonitorJSONQueryDump(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(result =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJ= ECT))) return -1; - result =3D virJSONValueObjectGetObject(reply, "return"); - return qemuMonitorJSONExtractDumpStats(result, stats); } @@ -3270,11 +3260,9 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMoni= tor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(caps =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - caps =3D virJSONValueObjectGetObject(reply, "return"); - if (!(formats =3D virJSONValueObjectGetArray(caps, "formats"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing supported dump formats")); @@ -4656,11 +4644,9 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (!(qemu =3D virJSONValueObjectGetObject(data, "qemu"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-version reply was missing 'qemu' data")); @@ -5155,11 +5141,9 @@ qemuMonitorJSONGetCPUModelBaseline(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-baseline", false, &cpu_model, &cpu_props, &cpu_name) < 0) @@ -5322,11 +5306,9 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (virJSONValueObjectGetBoolean(data, "enabled", enabled) < 0 || virJSONValueObjectGetBoolean(data, "present", present) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -5761,11 +5743,9 @@ qemuMonitorJSONGetTargetArch(qemuMonitor *mon) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return NULL; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return NULL; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (!(arch =3D virJSONValueObjectGetString(data, "arch"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-target reply was missing arch data")); @@ -7521,11 +7501,9 @@ qemuMonitorJSONGetRTCTime(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - data =3D virJSONValueObjectGet(reply, "return"); - if (virJSONValueObjectGetNumberInt(data, "tm_year", &tm->tm_year) < 0 = || virJSONValueObjectGetNumberInt(data, "tm_mon", &tm->tm_mon) < 0 || virJSONValueObjectGetNumberInt(data, "tm_mday", &tm->tm_mday) < 0 = || @@ -7973,11 +7951,9 @@ qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return NULL; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return NULL; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (!(tmp =3D virJSONValueObjectGetString(data, "data"))) return NULL; @@ -8016,11 +7992,9 @@ qemuMonitorJSONGetSEVInfo(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJEC= T))) return -1; - data =3D virJSONValueObjectGetObject(reply, "return"); - if (virJSONValueObjectGetNumberUint(data, "api-major", apiMajor) < 0 || virJSONValueObjectGetNumberUint(data, "api-minor", apiMinor) < 0 || virJSONValueObjectGetNumberUint(data, "build-id", buildID) < 0 || --=20 2.38.1 From nobody Sat Feb 7 17:54:42 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=1669912303; cv=none; d=zohomail.com; s=zohoarc; b=kGPfIOoegzuFdU0SwIsoib+Rv8xvJbv6nDYEaRZj67XcZ/D+MWxpP+mo1rOSv6xHMUiCDIakehYLdkc2ut9CtX/Z8wKiLVOVWye9S/S11KvgbfRUlzjsjWRtQyYAeqfBoTAg6Ing3hHODFF6BBcr4XCqtAsx3tiSQvrwFA0iU2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912303; 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=7xyr53SMIxDHvOCmvHFroq0Tt0v1zlY8RYfjUKYkiwI=; b=mYN+af6c66J6bH8zNlKo8ohZM67epZIu4JPaQHJlMBfkRMO4N//B6Nnsr2+0ZK1YCcZda9+Dp/lNlZJABXtwimLusNfSxzaoWioqQnVOH2acGUtz5DS1biOc1naDR++Py9g13FCrCpSlWrexoKvVA0IljbPwDwu1bWjWjcK7UQI= 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 1669912303726578.4166808296002; Thu, 1 Dec 2022 08:31:43 -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-340-kzitF536NqK7nlKMVZOYpA-1; Thu, 01 Dec 2022 11:31:39 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9404B1C0050C; Thu, 1 Dec 2022 16:31:23 +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 74D8D1401C39; Thu, 1 Dec 2022 16:31:23 +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 0638419465B1; Thu, 1 Dec 2022 16:31:23 +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 B116719465A8 for ; Thu, 1 Dec 2022 16:31:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 84406C1908C; Thu, 1 Dec 2022 16:31:21 +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 7844FC15BB4 for ; Thu, 1 Dec 2022 16:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912302; 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=7xyr53SMIxDHvOCmvHFroq0Tt0v1zlY8RYfjUKYkiwI=; b=fPUJklA5wk+Bln1G6uN5IIaYBI58Tp/Nl2DTtgLNpG201tLIVXzYGNnCB4lgqr19AuyLBd oKBPnJQ7CIj3EYaE2FmoMFYFe3+IBWWN21oJ4SNIiqOD8B7fV2ABjI4JjfET9cgcJEsoCA Wt+T4H/WgNbMRsROH95Fq3BLbEZYBEM= X-MC-Unique: kzitF536NqK7nlKMVZOYpA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/12] qemu: monitor: Use qemuMonitorJSONGetReply for VIR_JSON_TYPE_ARRAY Date: Thu, 1 Dec 2022 17:31:07 +0100 Message-Id: <838ebea11721b326e0e374f638707c0947c084c7.1669912195.git.pkrempa@redhat.com> 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.7 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: 1669912304959100001 Content-Type: text/plain; charset="utf-8" Replace usage of the following pattern with the new helper: if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) return -1; data =3D virJSONValueObjectGetArray(reply, "return"); Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 48 +++++++++++------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e3fe068c1b..79729e0a9a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4702,10 +4702,9 @@ int qemuMonitorJSONGetMachines(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) goto cleanup; - data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); /* null-terminated list */ @@ -4830,10 +4829,9 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon, if (qemuMonitorJSONHasError(reply, "GenericError")) return 0; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return -1; - data =3D virJSONValueObjectGetArray(reply, "return"); ncpus =3D virJSONValueArraySize(data); if (!(defs =3D qemuMonitorCPUDefsNew(ncpus))) @@ -5214,10 +5212,9 @@ int qemuMonitorJSONGetCommands(qemuMonitor *mon, 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; - data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); /* null-terminated list */ @@ -5339,10 +5336,9 @@ qemuMonitorJSONGetObjectTypes(qemuMonitor *mon, 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; - data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); /* null-terminated list */ @@ -5388,10 +5384,9 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitor *m= on, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) goto cleanup; - data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); /* null-terminated list */ @@ -5620,10 +5615,9 @@ qemuMonitorJSONParsePropsList(virJSONValue *cmd, size_t count =3D 0; size_t i; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return -1; - data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); /* null-terminated list */ @@ -5776,10 +5770,9 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitor = *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(caps =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return -1; - caps =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(caps); list =3D g_new0(char *, n + 1); @@ -5871,10 +5864,9 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, if (qemuMonitorJSONHasError(reply, "CommandNotFound")) return 0; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(caps =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return -1; - caps =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(caps); /* If the returned array was empty we have to return successfully */ @@ -6754,10 +6746,9 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitor *mon, 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; - data =3D virJSONValueObjectGetArray(reply, "return"); if (!(*cpudata =3D qemuMonitorJSONParseCPUx86Features(data))) return -1; @@ -6795,10 +6786,9 @@ qemuMonitorJSONCheckCPUx86(qemuMonitor *mon, } } - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return -1; - data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); for (i =3D 0; i < n; i++) { @@ -7031,10 +7021,9 @@ qemuMonitorJSONGetIOThreads(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) goto cleanup; - data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); /* null-terminated list */ @@ -7174,11 +7163,9 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, 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; - data =3D virJSONValueObjectGetArray(reply, "return"); - for (i =3D 0; i < virJSONValueArraySize(data); i++) { virJSONValue *elem =3D virJSONValueArrayGet(data, i); g_autofree qemuMonitorMemoryDeviceInfo *meminfo =3D NULL; @@ -7659,10 +7646,9 @@ qemuMonitorJSONGetHotpluggableCPUs(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) goto cleanup; - data =3D virJSONValueObjectGet(reply, "return"); ninfo =3D virJSONValueArraySize(data); info =3D g_new0(struct qemuMonitorQueryHotpluggableCpusEntry, ninfo); @@ -8372,11 +8358,9 @@ qemuMonitorJSONGetJobInfo(qemuMonitor *mon, 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; - data =3D virJSONValueObjectGetArray(reply, "return"); - for (i =3D 0; i < virJSONValueArraySize(data); i++) { qemuMonitorJobInfo *job =3D NULL; @@ -8783,11 +8767,9 @@ qemuMonitorJSONQueryStatsSchema(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return NULL; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(ret =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY)= )) return NULL; - ret =3D virJSONValueObjectGetArray(reply, "return"); - return qemuMonitorJSONExtractQueryStatsSchema(ret); } --=20 2.38.1 From nobody Sat Feb 7 17:54:42 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=1669912333; cv=none; d=zohomail.com; s=zohoarc; b=AZ0kKgFkRyyuJnt3pE8gLN2Mwn4hOnEDt4QC492JNCxYiLUaMLWaoCzNqmh4f4xvfrwtPKEHT80KTPDC652rAUVbmxc3RPqLfkibOyAhZiW0lFFvHrs2PJOQlaMOQDVvbG52emrNgsEhs+mkpE8jSR7EmQPfM5xH9EBChUtUbB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912333; 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=696JjNyTulGkDCUyS4PRT+T+YY/SqG2/yqT8yBkNy8Y=; b=H0NV0dMIg7Zzvds8m2ktps0PydEL85JHuLH9WzUoFEJpEZzfaG2GAEjIMN5LGiemCoJ/0i91atyoxA8g5dR7mLENZ5lmAroBzOPUxyjAeoQwDHJpsi6ihjnJiM2GHquU72+htLi46b+kWK7nOpIeSMRoH4Im85glasjZTzRxytA= 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 1669912333316468.78191782725673; Thu, 1 Dec 2022 08:32:13 -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-395-qJ-I59UtN8ugoa78L3mYOw-1; Thu, 01 Dec 2022 11:31:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0AA953813F3F; Thu, 1 Dec 2022 16:31:24 +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 D83BE63AED; Thu, 1 Dec 2022 16:31:23 +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 CCA9619465A8; Thu, 1 Dec 2022 16:31:23 +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 A42E619465A8 for ; Thu, 1 Dec 2022 16:31:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 89C31C154AB; Thu, 1 Dec 2022 16:31:22 +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 DC939C15BB4 for ; Thu, 1 Dec 2022 16:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912332; 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=696JjNyTulGkDCUyS4PRT+T+YY/SqG2/yqT8yBkNy8Y=; b=T2aSw8juuw7whi72QhgW0RDP9/Ns6iRdcEmo8ynaJmZnT8EZNtq79st9xmnTT/yCgWOQtS Iw8G9i0PUZahyigEqpn1cR0RFDDpEIG4RToF98R0HD0CyT2rJXeqgK51NXEk4sJ1Va0K/2 EUAkPNo+Uo+qYktP9wNHTm+SWMM1DpM= X-MC-Unique: qJ-I59UtN8ugoa78L3mYOw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/12] qemu: monitor: Use qemuMonitorJSONGetReply when the value is extracted directly Date: Thu, 1 Dec 2022 17:31:08 +0100 Message-Id: <29ce9848150c58792744b20bde545b568aa5d429.1669912195.git.pkrempa@redhat.com> 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.5 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: 1669912335100100001 Content-Type: text/plain; charset="utf-8" Use qemuMonitorJSONGetReply in cases where qemuMonitorJSONCheckReply is followed by virJSONValueObjectGet*(reply, "return"). Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 79729e0a9a..47df4a5160 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5267,6 +5267,7 @@ qemuMonitorJSONGetCommandLineOptions(qemuMonitor *mon) g_autoptr(GHashTable) ret =3D virHashNew(virJSONValueHashFree); g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; + virJSONValue *data; if (!(cmd =3D qemuMonitorJSONMakeCommand("query-command-line-options",= NULL))) return NULL; @@ -5274,10 +5275,10 @@ qemuMonitorJSONGetCommandLineOptions(qemuMonitor *m= on) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return NULL; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return NULL; - if (virJSONValueArrayForeachSteal(virJSONValueObjectGetArray(reply, "r= eturn"), + if (virJSONValueArrayForeachSteal(data, qemuMonitorJSONGetCommandLineOptions= Worker, ret) < 0) return NULL; @@ -5673,6 +5674,7 @@ qemuMonitorJSONGetDeviceProps(qemuMonitor *mon, g_autoptr(GHashTable) props =3D virHashNew(virJSONValueHashFree); g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; + virJSONValue *data; if (!(cmd =3D qemuMonitorJSONMakeCommand("device-list-properties", "s:typename", device, @@ -5686,10 +5688,10 @@ qemuMonitorJSONGetDeviceProps(qemuMonitor *mon, if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) return g_steal_pointer(&props); - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_ARRAY= ))) return NULL; - if (virJSONValueArrayForeachSteal(virJSONValueObjectGetArray(reply, "r= eturn"), + if (virJSONValueArrayForeachSteal(data, qemuMonitorJSONGetDevicePropsWorker, props) < 0) return NULL; @@ -8381,6 +8383,7 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; + virJSONValue *data; if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-get", "s:path", cpuQOMPath, @@ -8394,11 +8397,10 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitor *mon, if (qemuMonitorJSONHasError(reply, "GenericError")) return 1; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_BOOLEAN) < 0) + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_BOOLE= AN))) return -1; - return virJSONValueGetBoolean(virJSONValueObjectGet(reply, "return"), - migratable); + return virJSONValueGetBoolean(data, migratable); } --=20 2.38.1 From nobody Sat Feb 7 17:54:42 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=1669912367; cv=none; d=zohomail.com; s=zohoarc; b=nU5L/SaBxygwhI1R9l69I7wXet+JOq9EcGW4teppqfCyRLCpf5OaPWegi2UHAWjQWfVX9jvxVD1h52xbl5afDyr8TiX4XeB6qMcj+u1NEDtfyaqHflqSEhe9b6dZzRH5KRg0PnhydZT33rRuQ9F3M60i/2JtFyZjS/4MYvAsNuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912367; 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=HepPiYIlPgMGoXXxx7W3VTmfp/ll6Kxz0GHE8oIyMdc=; b=fg2ESW9/AcbRcaLol7JCHlcIO1rFuv6p3FTEeHiFlKzNk8QScx2h5NWwaUZcH6l4zudA5nV0u9QYb6xDHz7gZzdijJEaDrPGfM8mQYcDcBjElwUXPStrDhQOXghPRNrNmnkSROM5/bNsJhgwZxoe2vSbpiMEL48TTm6j9k2Znbw= 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 1669912367159152.146308253558; Thu, 1 Dec 2022 08:32:47 -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-340-qWV4C3bzMjqEn7ypUbZfvg-1; Thu, 01 Dec 2022 11:31:45 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D9112A5955B; Thu, 1 Dec 2022 16:31:24 +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 426806D663; Thu, 1 Dec 2022 16:31:24 +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 199011946A4B; Thu, 1 Dec 2022 16:31:24 +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 8D72E19465A8 for ; Thu, 1 Dec 2022 16:31:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7EE9EC4C9D3; Thu, 1 Dec 2022 16:31:23 +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 EB29AC2E09B for ; Thu, 1 Dec 2022 16:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912366; 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=HepPiYIlPgMGoXXxx7W3VTmfp/ll6Kxz0GHE8oIyMdc=; b=f5ZfiCyfDrnovXxdE+Ll9nq9Hyj+lM5clCEp8yk/F2lyhe6EczytzU87Xx7/DkH0SWcNuY 3519hoZ7emEnfs7Gt+8g/NZBOVWZNgQnRyDsMQhZuyZwY2DbhDzHD+4ZdBqQv4DoaYKzIj /2WpWrGoq/pXTMtobVtGD/lQ9O41ewM= X-MC-Unique: qWV4C3bzMjqEn7ypUbZfvg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/12] qemu: monitor: Unify and refactor 'PTY' case in qemuMonitorJSONAttachCharDev Date: Thu, 1 Dec 2022 17:31:09 +0100 Message-Id: <3a742e19e478833de683552ddb4ff57ef702ee70.1669912195.git.pkrempa@redhat.com> 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.5 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: 1669912369323100001 Content-Type: text/plain; charset="utf-8" Use qemuMonitorJSONGetReply and unify the two blocks with the same condition. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 47df4a5160..a5800e182c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6578,24 +6578,19 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon, return -1; if (chr->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY) { - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < = 0) - return -1; - } else { - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - return -1; - } + virJSONValue *data; - if (chr->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY) { - virJSONValue *data =3D virJSONValueObjectGetObject(reply, "return"= ); - const char *path; + if (!(data =3D qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_O= BJECT))) + return -1; - if (!(path =3D virJSONValueObjectGetString(data, "pty"))) { + if (!(chr->data.file.path =3D g_strdup(virJSONValueObjectGetString= (data, "pty")))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("chardev-add reply was missing pty path")); return -1; } - - chr->data.file.path =3D g_strdup(path); + } else { + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; } return 0; --=20 2.38.1 From nobody Sat Feb 7 17:54:42 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=1669912328; cv=none; d=zohomail.com; s=zohoarc; b=ZnP10aTcmAFES0Pj7lXWevim4spfGG5daSIWLEoaozvNtOEPz6/cOXJPj3tZuH2NrogVsbAkRm0X0SYmYYL3ZCujzECB70eWedqFPK7+V2l8jaTFhrKdcyxGuPxehXlCOlIkGGLCzVB7/Qw2BP8Km+MB4vrbIhLw79GlPiDOzWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912328; 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=+vzAoRQOH2r1e6UDQYhVTDJT1l0Di0W5Mj3cyyQKjBI=; b=oAkX3Ld+4mVE+y6dmPJQVQcqXfK+cgpNr3MHjHyW93wsRa9+812UieoFDVVaT1H1meN6eKERFtkL7FjbiglSJR86JhVreUcmoue4pYDoe5bRLBb9Itn5yhZb4T4oG0Oy95zgwoSoflnaJoaE2EDe54oU3TtW+7NbNX6KdtDnTtU= 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 1669912328788437.389889566684; Thu, 1 Dec 2022 08:32:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-191-TANfkVDzPV6TH-vGM5rJNQ-1; Thu, 01 Dec 2022 11:31:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75C7E8828CF; Thu, 1 Dec 2022 16:31:25 +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 5ED6020290A2; Thu, 1 Dec 2022 16:31:25 +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 4488119465A8; Thu, 1 Dec 2022 16:31:25 +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 911B119465A8 for ; Thu, 1 Dec 2022 16:31:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7506FC1D3AD; Thu, 1 Dec 2022 16:31:24 +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 D5A47C2DF60 for ; Thu, 1 Dec 2022 16:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912327; 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=+vzAoRQOH2r1e6UDQYhVTDJT1l0Di0W5Mj3cyyQKjBI=; b=SLWbzq4NWbQ+ECLzrA1fXH5mfyRPNbFrGrgSqhYoykJsoX9JpIKjAgEYzxwawjjh0Qv5tQ o948RqNurDbYVIiM4ldVQULe1ZcnnkMVjs0VXP0oJabO1guTCo2QpCRL/kpLnNIWHAn9fY hDcMSUNKZB5UXUGuj4LXbJZqrblo1S0= X-MC-Unique: TANfkVDzPV6TH-vGM5rJNQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/12] util: json: Split out array->strinlist conversion from virJSONValueObjectGetStringArray Date: Thu, 1 Dec 2022 17:31:10 +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.4 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: 1669912329079100001 Content-Type: text/plain; charset="utf-8" Introduce virJSONValueArrayToStringList which does only the conversion from an array to a stringlist. This will allow refactoring the callers to be more careful in case when they want to handle the existance of the member in the parent object differently. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virjson.c | 43 ++++++++++++++++++++++------------------ src/util/virjson.h | 2 ++ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ebd7bc61a8..a5bb44a9f8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2564,6 +2564,7 @@ virJSONValueArrayForeachSteal; virJSONValueArrayGet; virJSONValueArraySize; virJSONValueArraySteal; +virJSONValueArrayToStringList; virJSONValueCopy; virJSONValueFree; virJSONValueFromString; diff --git a/src/util/virjson.c b/src/util/virjson.c index ef59b5deb4..5701c09bfd 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1316,10 +1316,7 @@ virJSONValueObjectStealObject(virJSONValue *object, char ** virJSONValueObjectGetStringArray(virJSONValue *object, const char *key) { - g_auto(GStrv) ret =3D NULL; virJSONValue *data; - size_t n; - size_t i; data =3D virJSONValueObjectGetArray(object, key); if (!data) { @@ -1329,32 +1326,40 @@ virJSONValueObjectGetStringArray(virJSONValue *obje= ct, const char *key) return NULL; } - n =3D virJSONValueArraySize(data); - ret =3D g_new0(char *, n + 1); + return virJSONValueArrayToStringList(data); +} + + +/** + * virJSONValueArrayToStringList: + * @data: a JSON array containing strings to convert + * + * Converts @data a JSON array containing strings to a NULL-terminated str= ing + * list. @data must be a JSON array. In case @data is doesn't contain only + * strings an error is reported. + */ +char ** +virJSONValueArrayToStringList(virJSONValue *data) +{ + size_t n =3D virJSONValueArraySize(data); + g_auto(GStrv) ret =3D g_new0(char *, n + 1); + size_t i; + for (i =3D 0; i < n; i++) { virJSONValue *child =3D virJSONValueArrayGet(data, i); - const char *tmp; - if (!child) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("%s array element is missing item %zu"), - key, i); + if (!child || + !(ret[i] =3D g_strdup(virJSONValueGetString(child)))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("JSON string array contains non-string elemen= t")); return NULL; } - - if (!(tmp =3D virJSONValueGetString(child))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("%s array element does not contain a string"), - key); - return NULL; - } - - ret[i] =3D g_strdup(tmp); } return g_steal_pointer(&ret); } + /** * virJSONValueObjectForeachKeyValue: * @object: JSON object to iterate diff --git a/src/util/virjson.h b/src/util/virjson.h index ce181dcb82..49a89e0910 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -172,6 +172,8 @@ virJSONValueObjectGetString(virJSONValue *object, char ** virJSONValueObjectGetStringArray(virJSONValue *object, const char *key); +char ** +virJSONValueArrayToStringList(virJSONValue *data); const char * virJSONValueObjectGetStringOrNumber(virJSONValue *object, const char *key); --=20 2.38.1 From nobody Sat Feb 7 17:54:42 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=1669912342; cv=none; d=zohomail.com; s=zohoarc; b=FwepeKI983BdixbmjYZkO/2FquX4vIbHepNU6skmpB6hGPV140dMrUZXf2QdcIfhtpZftExhEF8BIq4vXLaace/xgjDv7AcZ6ubtfhT0Mm/mnQ/IkJ6VrxxoljG+hOdXMwYUXYpkcPKuQWHaCuQHOCktHWiOLPvKRLITlGn836k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912342; 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=1/iYCuNExmC5dzzU0+hWrh8uEPn5n/r/clKixdFRbFM=; b=jKye1qccMutRw9GCC28FXV9IKa6GI0jv8d7okjl1ERibN6TFYH5oiqOXnQlff3x3LZQQV7wd8KWJjFkRXvo6LVnccEnat+LtNsS5TJHjR2ZvlA2pJZVPvJBFkF1uRviAK5o2xdcdEC7FLpGtd4pkBsLIVN2Pybjrd1Jtfklk5MQ= 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 1669912342006662.1306129651113; Thu, 1 Dec 2022 08:32:22 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-232-caRjtXIyNqO3XtviRGFtRg-1; Thu, 01 Dec 2022 11:31:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B19C6811E81; Thu, 1 Dec 2022 16:31:26 +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 9A0B563A55; Thu, 1 Dec 2022 16:31:26 +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 837F719465A8; Thu, 1 Dec 2022 16:31:26 +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 7D7C31946A4B for ; Thu, 1 Dec 2022 16:31:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 62525C16922; Thu, 1 Dec 2022 16:31:25 +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 CEF0DC15BB4 for ; Thu, 1 Dec 2022 16:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912341; 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=1/iYCuNExmC5dzzU0+hWrh8uEPn5n/r/clKixdFRbFM=; b=LK1ORHa7wqVgM3DMBs0kGlJGS3ack5Ze5C1bxk1Wy5pU9StJgWgIg+iNNBqum07ZaTTVqq Gl/T0yl0oL3ey+N1MxImzgkKpR5tC8JuG9V8bK+p8k2YpyArNxIiYJJt8EyRdRNI9aUJLG 5q6Oz+9D0EW4jmuX9dS/uzrb9fFHGGw= X-MC-Unique: caRjtXIyNqO3XtviRGFtRg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/12] qemuAgentGetDisks: Don't use virJSONValueObjectGetStringArray for optional data Date: Thu, 1 Dec 2022 17:31:11 +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.5 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: 1669912343155100001 Content-Type: text/plain; charset="utf-8" The 'dependencies' field in the return data may be missing in some cases. Historically 'virJSONValueObjectGetStringArray' didn't report error in such case, but later refactor (commit 043b50b948ef3c2 ) added an error in order to use it in other places too. Unfortunately this results in the error log being spammed with an irrelevant error in case when qemuAgentGetDisks is invoked on a VM running windows. Replace the use of virJSONValueObjectGetStringArray by fetching the array first and calling virJSONValueArrayToStringList only when we have an array. Fixes: 043b50b948ef3c2a4adf5fa32a93ec2589851ac6 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2149752 Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_agent.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index d420b2b901..70d45955b2 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2545,6 +2545,7 @@ int qemuAgentGetDisks(qemuAgent *agent, for (i =3D 0; i < ndata; i++) { virJSONValue *addr; virJSONValue *entry =3D virJSONValueArrayGet(data, i); + virJSONValue *dependencies; qemuAgentDiskInfo *disk; if (!entry) { @@ -2570,7 +2571,11 @@ int qemuAgentGetDisks(qemuAgent *agent, goto error; } - disk->dependencies =3D virJSONValueObjectGetStringArray(entry, "de= pendencies"); + if ((dependencies =3D virJSONValueObjectGetArray(entry, "dependenc= ies"))) { + if (!(disk->dependencies =3D virJSONValueArrayToStringList(dep= endencies))) + goto error; + } + disk->alias =3D g_strdup(virJSONValueObjectGetString(entry, "alias= ")); addr =3D virJSONValueObjectGetObject(entry, "address"); if (addr) { --=20 2.38.1 From nobody Sat Feb 7 17:54:42 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=1669912427; cv=none; d=zohomail.com; s=zohoarc; b=hcb0lG6MlL9NDQ1fAFUpgrSc+e43T8GW1W/GBscz3uuPsS0EEf/xk1vmPWhulAcxAxXB2JXajCo5F7lFjqbnkR8xvS2/eMG1NSi1ZSgmvcMFH7DGnnXYgyuNL7sgid3ke1AXJsmhQl5GhjSQ/qoTODZat3nPQrCexpSAQc9woy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912427; 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=nzRuU+Unlj2XZ8RzxfAx5S2jIzRzq3IUWbve9koRSzw=; b=Oxv2+t8AVLBAArtGFY8QXwT+PQphw58FidbRz3tdhGgCF10ECs/nvwVBtNn+gzsT5n1R00ijjxEE+NiID7RuaNCctftJzFlmFU97YseF82PzPQLcQK1Pu6pxpnb2QQQPWy/xbV+Ew3JGfGIxAiz1nErupJfyfMmF/7zGFarVAU4= 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 1669912427915763.4526292576072; Thu, 1 Dec 2022 08:33:47 -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-596-0HZnahPQO0OkK95DNz8q7w-1; Thu, 01 Dec 2022 11:31:47 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA5332A59560; Thu, 1 Dec 2022 16:31:26 +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 CEFE4C1908B; Thu, 1 Dec 2022 16:31:26 +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 C21671946A4B; Thu, 1 Dec 2022 16:31:26 +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 5AC0619465A0 for ; Thu, 1 Dec 2022 16:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4E4D8C15BB4; Thu, 1 Dec 2022 16:31:26 +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 B9FDCC1908D for ; Thu, 1 Dec 2022 16:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912391; 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=nzRuU+Unlj2XZ8RzxfAx5S2jIzRzq3IUWbve9koRSzw=; b=HcMZM2zPw1JTitoFGi4agOydqDTOUtUvo5B0X8DZIcCCMeb8wz0E3VsaWgSnWljlYn2h+3 CYRYRAI3pZNw57PUynoDHD7kBZCiSUxeICyVJTcM36iFYAfnheDxxBvlC7GBxdXK1E+8fW gz/BoELaX2o3+IEtuj8vUd8/6ZIuEYo= X-MC-Unique: 0HZnahPQO0OkK95DNz8q7w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/12] qemuMonitorJSONGetCPUDefinitions: Rework lookup of 'unavailable-features' Date: Thu, 1 Dec 2022 17:31:12 +0100 Message-Id: <3649f75ed5f9ca23d4900fb1d6163e1c51a3ea53.1669912195.git.pkrempa@redhat.com> 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.8 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: 1669912429847100001 Content-Type: text/plain; charset="utf-8" Rather than checking that the object has the correct key and then fetching it again use fetch the array first and then use virJSONValueArrayToStringList to directly convert it. Additionally we can avoid the conversion if there are no members simplifying the surrounding logic. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a5800e182c..cbd1eb6eec 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4841,6 +4841,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon, virJSONValue *child =3D virJSONValueArrayGet(data, i); const char *tmp; qemuMonitorCPUDefInfo *cpu =3D defs->cpus + i; + virJSONValue *feat; if (!(tmp =3D virJSONValueObjectGetString(child, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -4853,16 +4854,14 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon, if ((tmp =3D virJSONValueObjectGetString(child, "typename")) && *t= mp) cpu->type =3D g_strdup(tmp); - if (virJSONValueObjectHasKey(child, "unavailable-features")) { - if (!(cpu->blockers =3D virJSONValueObjectGetStringArray(child, - "unavai= lable-features"))) - return -1; + if ((feat =3D virJSONValueObjectGetArray(child, "unavailable-featu= res"))) { + if (virJSONValueArraySize(feat) > 0) { + if (!(cpu->blockers =3D virJSONValueArrayToStringList(feat= ))) + return -1; - if (g_strv_length(cpu->blockers) =3D=3D 0) { - cpu->usable =3D VIR_DOMCAPS_CPU_USABLE_YES; - g_clear_pointer(&cpu->blockers, g_strfreev); - } else { cpu->usable =3D VIR_DOMCAPS_CPU_USABLE_NO; + } else { + cpu->usable =3D VIR_DOMCAPS_CPU_USABLE_YES; } } --=20 2.38.1 From nobody Sat Feb 7 17:54:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1669912330; cv=none; d=zohomail.com; s=zohoarc; b=cF45ZnQgJRxqaMwE6jgtomIhZ2CJROcwQXNfaG+GSq0gdxpF/VJ4N2+5JE2IuzSG9hOm02j7sIiv4p92PWtQ7EqWxJMsrwyqZGa7AqFgdxdJf/ouzPelb61mwxjfT3HqJ6Yq9MOAPQwhMXAV1tHb6m0t3OxtiB07HoudVIp4b9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912330; 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=LQehEA70EqaJahF2KpvaAF8CY4FFkAS8kU0q2gJest4=; b=Sp1D1axJ0y0JGrW+31ooeGzXOxc+JpC+9mVLb5d8DL6WrPmV/FnrlXg8HF607KwI8d+0KGk8THicMk93SJtCpAjm0Jyg2Jlsaaz3vmffw18E2c36kKSV5+SJbarJF3LrU4937VpMt0fEIPXHYzmVTDUyg5VklU05o79QzpAsA+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 166991233062180.61817593714522; Thu, 1 Dec 2022 08:32:10 -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-531-e9mGAXP6OB6JehP3jy7kPw-1; Thu, 01 Dec 2022 11:31:47 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 584A93C0F235; Thu, 1 Dec 2022 16:31:28 +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 410D71401C31; Thu, 1 Dec 2022 16:31:28 +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 24FF019465A8; Thu, 1 Dec 2022 16:31:28 +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 577C619465A8 for ; Thu, 1 Dec 2022 16:31:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4D532C1908D; Thu, 1 Dec 2022 16:31:27 +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 A655EC15BB4 for ; Thu, 1 Dec 2022 16:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912328; 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=LQehEA70EqaJahF2KpvaAF8CY4FFkAS8kU0q2gJest4=; b=i1a3zI8E1JUnVg/Jcl1D03hFDjDy7E8ze0Von88Rq1T09T4x8wO561Ja94swRT6odVgGsm Fnp4pf75nKyhYVBAcbZy23uSugcu3wpsQZ3QYzk3ZXySGH72/LvIvW9gfqvsWIsnHndJAU xgJnVraRJW3NIvl7O4Ibk9NuEVuaTEE= X-MC-Unique: e9mGAXP6OB6JehP3jy7kPw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/12] qemuMonitorJSONGetCPUDefinitions: Avoid double lookup of object Date: Thu, 1 Dec 2022 17:31:13 +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.7 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: 1669912331103100003 Content-Type: text/plain; charset="utf-8" Using 'virJSONValueObjectHasKey' when we want to access the value afterwards is wasteful. Fetch the JSON value right away. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index cbd1eb6eec..1deb755130 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4842,6 +4842,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon, const char *tmp; qemuMonitorCPUDefInfo *cpu =3D defs->cpus + i; virJSONValue *feat; + virJSONValue *deprecated; if (!(tmp =3D virJSONValueObjectGetString(child, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -4865,8 +4866,8 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon, } } - if (virJSONValueObjectHasKey(child, "deprecated") && - virJSONValueObjectGetBoolean(child, "deprecated", &cpu->deprec= ated) < 0) + if ((deprecated =3D virJSONValueObjectGet(child, "deprecated")) && + virJSONValueGetBoolean(deprecated, &cpu->deprecated) < 0) return -1; } --=20 2.38.1 From nobody Sat Feb 7 17:54:42 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 Reviewed-by: Michal Privoznik --- 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 From nobody Sat Feb 7 17:54:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1669912311; cv=none; d=zohomail.com; s=zohoarc; b=OkY/xoyXQ2WQObQqmQwIT+AUMY64SQZIc1N4xHeQIkaPH2G8WNwiPVGhyWUQNBuJ0c/bswBTpXd5/HSi5mtVqHgnxP1/YYi23JF3pFoy8z4K1HioYKi1kcdmiBfwErI8kbXgACeO1piV7kyVrVnGhRUREg6tWXwTWpm18mC8XSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912311; 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=ddwqkL45PdQN2qt88BBU6P472++9Rgktz2q9i21hnAQ=; b=ibLMRBAeLHkdri+I13Mi17hTx+o2jRkFu3cHjydsMCuK8nQJSAWEVBH0RwbLJYiQFLUqZ9nM7a6koIAevgb1W0+mChQq76quecXrc5ecgnjQYz43eYdbrnKLo4IQ0Tq5RlONeBn9Xgp5rGa1lnchtIk/ffEyrhEbx/sc+nlWSys= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 166991231154125.781456401671676; Thu, 1 Dec 2022 08:31:51 -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-271-zd73-qI3MLiUfmh7NELYOg-1; Thu, 01 Dec 2022 11:31:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 388633C0F360; Thu, 1 Dec 2022 16:31:30 +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 187FB111F3DB; Thu, 1 Dec 2022 16:31:30 +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 D9C4219465A0; 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 77D4219465A0 for ; Thu, 1 Dec 2022 16:31:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6B01FC2C8C7; Thu, 1 Dec 2022 16:31:29 +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 D6469C15BB4 for ; Thu, 1 Dec 2022 16:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912309; 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=ddwqkL45PdQN2qt88BBU6P472++9Rgktz2q9i21hnAQ=; b=EkDf3FiF4V5TFZccatM/9HDYcMyvjgVZAuzL4i0uGWPD5IvhYJ0/ZiNWW+cRbXlsGAgNKd 1I/wveMOtO1s5Qx9gRp0rxR235HZIAqH602QRto7+H4Z7ZhWdHysHZ9v+JWmb6pTzpkiF1 IW/vjDuParfgbmpEbeZwulpnSXFdZgI= X-MC-Unique: zd73-qI3MLiUfmh7NELYOg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/12] qemuAgentSSHGetAuthorizedKeys: Convert last use ofvirJSONValueObjectGetStringArray Date: Thu, 1 Dec 2022 17:31:15 +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.3 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: 1669912313030100001 Content-Type: text/plain; charset="utf-8" Use virJSONValueObjectGetArray + virJSONValueArrayToStringList instead so that the ofvirJSONValueObjectGetStringArray wrapper can be removed. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_agent.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 70d45955b2..fa2c0bf915 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2413,6 +2413,7 @@ qemuAgentSSHGetAuthorizedKeys(qemuAgent *agent, g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data =3D NULL; + virJSONValue *arr =3D NULL; if (!(cmd =3D qemuAgentMakeCommand("guest-ssh-get-authorized-keys", "s:username", user, @@ -2422,13 +2423,14 @@ qemuAgentSSHGetAuthorizedKeys(qemuAgent *agent, if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) return -1; - if (!(data =3D virJSONValueObjectGetObject(reply, "return"))) { + if (!(data =3D virJSONValueObjectGetObject(reply, "return")) || + !(arr =3D virJSONValueObjectGetArray(data, "keys"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu agent didn't return an array of keys")); return -1; } - if (!(*keys =3D virJSONValueObjectGetStringArray(data, "keys"))) + if (!(*keys =3D virJSONValueArrayToStringList(arr))) return -1; return g_strv_length(*keys); --=20 2.38.1 From nobody Sat Feb 7 17:54:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1669912387; cv=none; d=zohomail.com; s=zohoarc; b=XjKTgelIEoYM4FbSraqeCxq82EsM3RRDPbjNihbRji+BdksiJueSl5o7DSIQulrrWfUnwM+Iq5HJSzXbqtsbognuipXceXzyX9j5eFKvE+dGngahUbJ+5oksRmPLnQGVPh01U6+P7T/zUiePF3QA1fj0FIjg3FcHo/jZ4UWVa8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912387; 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=DNlGloMvoA9Utz3lflcYrnvxPUOOIlWwL0C6jNgVMhU=; b=KFHSSrYOxEY/wbbIm11ywxNhsGIbSSHt/tHJysS/Wgf03SmdRJVjKFaaoKcSsXYX72rpjuN4Qi7EHkAJ3w1gwxOg+hT6WeaOcTNcwfP3XR+kLzE0tI39kjTBPh0Y6kcztvxHVvZEpdnyiQI0pCT1es+NIIllmxUIjRv98i9Hjh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 166991238723159.27452017505095; Thu, 1 Dec 2022 08:33:07 -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-605-S66IAEdrO3umNvap-KIRAQ-1; Thu, 01 Dec 2022 11:31:47 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8BB591C0CE65; Thu, 1 Dec 2022 16:31:31 +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 78904492B11; Thu, 1 Dec 2022 16:31:31 +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 6A5D419465A8; Thu, 1 Dec 2022 16:31:31 +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 7252D19465A0 for ; Thu, 1 Dec 2022 16:31:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5851AC16922; Thu, 1 Dec 2022 16:31:30 +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 C44D8C15BB4 for ; Thu, 1 Dec 2022 16:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912386; 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=DNlGloMvoA9Utz3lflcYrnvxPUOOIlWwL0C6jNgVMhU=; b=Iw7nUx8vAcPw0SzhPOg7T2QbN4MGcda1i9gQHmu4FFPGmOhwVBD07+a6nlJuosdj5Do5ti PgvFhV+GT8fw7lPbkzLQpXB9CI8y4g3uwkfit/1IpL5+Zkmd8/6AtuvOTV3ItagN7Mw2vT QTZ+oAUhdwCDxJasXICSk5BEq7VCef4= X-MC-Unique: S66IAEdrO3umNvap-KIRAQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/12] util: json: Remove unused virJSONValueObjectGetStringArray wrapper Date: Thu, 1 Dec 2022 17:31:16 +0100 Message-Id: <0d7712ae6304af3b12a01a7c284f5d47d66e6c2a.1669912195.git.pkrempa@redhat.com> 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.10 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: 1669912387490100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 - src/util/virjson.c | 17 ----------------- src/util/virjson.h | 3 --- 3 files changed, 21 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a5bb44a9f8..9389778db7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2616,7 +2616,6 @@ virJSONValueObjectGetNumberUint; virJSONValueObjectGetNumberUlong; virJSONValueObjectGetObject; virJSONValueObjectGetString; -virJSONValueObjectGetStringArray; virJSONValueObjectGetValue; virJSONValueObjectHasKey; virJSONValueObjectKeysNumber; diff --git a/src/util/virjson.c b/src/util/virjson.c index 5701c09bfd..1c3a50440e 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1313,23 +1313,6 @@ virJSONValueObjectStealObject(virJSONValue *object, } -char ** -virJSONValueObjectGetStringArray(virJSONValue *object, const char *key) -{ - virJSONValue *data; - - data =3D virJSONValueObjectGetArray(object, key); - if (!data) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("%s is missing or not an array"), - key); - return NULL; - } - - return virJSONValueArrayToStringList(data); -} - - /** * virJSONValueArrayToStringList: * @data: a JSON array containing strings to convert diff --git a/src/util/virjson.h b/src/util/virjson.h index 49a89e0910..0ea7caad23 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -170,9 +170,6 @@ const char * virJSONValueObjectGetString(virJSONValue *object, const char *key); char ** -virJSONValueObjectGetStringArray(virJSONValue *object, - const char *key); -char ** virJSONValueArrayToStringList(virJSONValue *data); const char * virJSONValueObjectGetStringOrNumber(virJSONValue *object, --=20 2.38.1