From nobody Mon Feb 9 16:54:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1617971579; cv=none; d=zohomail.com; s=zohoarc; b=eGRnHmIBwzjlMANCcGGhRQTZRzh3l+BpigbPyxrXVT7oTDt3nOUn5OS6JGvsCjlVppmXDDO55Z4uhQGhsrzLgSSoIeVSk5WmVL+5kPITr99le+LsBaUGTeUVEYX6kw6kXkKUx24MFY9UgGU4EpnWDwOUfr1xL60A248YcEPnZVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617971579; 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=87hqDAnASlVoe9FNXDx9+PAsHqJm79tqim8CGIODQ6c=; b=lygrLl8jc/8ocNYJTNhrygHP2YUQaNutzml1k+Fb5fU7Nw4GtobrEyyYqk4SLnNV+r0yZRdXHwSc+DVsVHPdcxIW1CfmYhu2g/eBQB0E/EFXfdoe2Qea18P1J9wpP+ot8F451+YjveMkcXKQ7FbLBZdufwPYoy2gcRDiUfDMsd4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617971579816612.5306023949609; Fri, 9 Apr 2021 05:32:59 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-i99hNkh7Ob67AqrrimeRDw-1; Fri, 09 Apr 2021 08:32:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A36FE107ACC7; Fri, 9 Apr 2021 12:32:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7833D5DAA5; Fri, 9 Apr 2021 12:32:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B95F455345; Fri, 9 Apr 2021 12:32:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 139CWiKb006538 for ; Fri, 9 Apr 2021 08:32:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3576918400; Fri, 9 Apr 2021 12:32:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 904A9627DC for ; Fri, 9 Apr 2021 12:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617971578; 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=87hqDAnASlVoe9FNXDx9+PAsHqJm79tqim8CGIODQ6c=; b=NI+c+qB5ISz0d9E1kZtuYQxgozbKEGrGWvMe5ai3GJhEHnksFDo3TWokC/zpcI6gJiTTlt GnvieOh7tuVxmrKRiigxIzJ7CjtWfsqNVAEQvv6eciR0Z6geI1Pp7JcD5WLs1Wt1TpIKr5 tbpheLXgGV2JqBR1qbQB6F1+u1fzBCk= X-MC-Unique: i99hNkh7Ob67AqrrimeRDw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/3] virQEMUBuildCommandLineJSONArrayBitmap: Open code bitmap conversion Date: Fri, 9 Apr 2021 14:32:35 +0200 Message-Id: <21f3d18a8803013cb9a8da2882cf512fd4370f52.1617971454.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add a simpler algorithm converting the JSON array to bitmap so that virJSONValueGetArrayAsBitmap can be removed in next step. Signed-off-by: Peter Krempa --- src/util/virqemu.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index a1f57dea66..4d432651ee 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -28,6 +28,7 @@ #include "virqemu.h" #include "virstring.h" #include "viralloc.h" +#include "virbitmap.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -59,10 +60,19 @@ virQEMUBuildCommandLineJSONArrayBitmap(const char *key, { ssize_t pos =3D -1; ssize_t end; - g_autoptr(virBitmap) bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D virBitmapNew(0); + size_t i; - if (virJSONValueGetArrayAsBitmap(array, &bitmap) < 0) - return -1; + for (i =3D 0; i < virJSONValueArraySize(array); i++) { + virJSONValue *member =3D virJSONValueArrayGet(array, i); + unsigned long long value; + + if (virJSONValueGetNumberUlong(member, &value) < 0) + return -1; + + if (virBitmapSetBitExpand(bitmap, value) < 0) + return -1; + } while ((pos =3D virBitmapNextSetBit(bitmap, pos)) > -1) { if ((end =3D virBitmapNextClearBit(bitmap, pos)) < 0) --=20 2.30.2