From nobody Mon Feb 9 10:33:22 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 --- 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