From nobody Wed May 14 06:43:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525687677794165.18566450629987; Mon, 7 May 2018 03:07:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CB2E30023C6; Mon, 7 May 2018 10:07:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D31622010CA5; Mon, 7 May 2018 10:07:55 +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 7D48B180BADC; Mon, 7 May 2018 10:07:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47A6i1K022992 for ; Mon, 7 May 2018 06:06:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2ED9111F3DB; Mon, 7 May 2018 10:06:44 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67324111F3DA for ; Mon, 7 May 2018 10:06:44 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 7 May 2018 12:06:35 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 8/9] domain: Introduce virtDBusDomainGVariantToCpumap helper X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 07 May 2018 10:07:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/domain.c | 55 ++++++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/src/domain.c b/src/domain.c index c6dc744..2ba58e0 100644 --- a/src/domain.c +++ b/src/domain.c @@ -125,6 +125,25 @@ virtDBusDomainGVariantToMountpoints(GVariantIter *iter, } } =20 +static void +virtDBusDomainGVariantToCpumap(GVariantIter *iter, + guchar **cpumap, + guint *cpumaplen) +{ + gboolean usable; + guint cpus =3D g_variant_iter_n_children(iter); + guint cnt =3D 0; + + *cpumaplen =3D VIR_CPU_MAPLEN(cpus); + *cpumap =3D g_new0(guchar, cpumaplen); + + while (g_variant_iter_loop(iter, "b", &usable)) { + if (usable) + VIR_USE_CPU(*cpumap, cnt); + cnt++; + } +} + static virDomainPtr virtDBusDomainGetVirDomain(virtDBusConnect *connect, const gchar *objectPath, @@ -1996,22 +2015,12 @@ virtDBusDomainPinEmulator(GVariant *inArgs, g_autoptr(virDomain) domain =3D NULL; g_autoptr(GVariantIter) iter =3D NULL; guint flags; - guint cpus; guint cpumaplen; g_autofree guchar *cpumap =3D NULL; - gboolean usable; - guint cnt =3D 0; =20 g_variant_get(inArgs, "(abu)", &iter, &flags); =20 - cpus =3D g_variant_iter_n_children(iter); - cpumaplen =3D VIR_CPU_MAPLEN(cpus); - cpumap =3D g_new0(guchar, cpumaplen); - while (g_variant_iter_loop(iter, "b", &usable)) { - if (usable) - VIR_USE_CPU(cpumap, cnt); - cnt++; - } + virtDBusDomainGVariantToCpumap(iter, &cpumap, &cpumaplen); =20 domain =3D virtDBusDomainGetVirDomain(connect, objectPath, error); if (!domain) @@ -2036,22 +2045,12 @@ virtDBusDomainPinIOThread(GVariant *inArgs, guint iothreadId; g_autoptr(GVariantIter) iter =3D NULL; guint flags; - guint cpus; guint cpumaplen; g_autofree guchar *cpumap =3D NULL; - gboolean usable; - guint cnt =3D 0; =20 g_variant_get(inArgs, "(uabu)", &iothreadId, &iter, &flags); =20 - cpus =3D g_variant_iter_n_children(iter); - cpumaplen =3D VIR_CPU_MAPLEN(cpus); - cpumap =3D g_new0(guchar, cpumaplen); - while (g_variant_iter_loop(iter, "b", &usable)) { - if (usable) - VIR_USE_CPU(cpumap, cnt); - cnt++; - } + virtDBusDomainGVariantToCpumap(iter, &cpumap, &cpumaplen); =20 domain =3D virtDBusDomainGetVirDomain(connect, objectPath, error); if (!domain) @@ -2076,22 +2075,12 @@ virtDBusDomainPinVcpu(GVariant *inArgs, guint vcpu; g_autoptr(GVariantIter) iter =3D NULL; guint flags; - guint cpus; guint cpumaplen; g_autofree guchar *cpumap =3D NULL; - gboolean usable; - guint cnt =3D 0; =20 g_variant_get(inArgs, "(uabu)", &vcpu, &iter, &flags); =20 - cpus =3D g_variant_iter_n_children(iter); - cpumaplen =3D VIR_CPU_MAPLEN(cpus); - cpumap =3D g_new0(guchar, cpumaplen); - while (g_variant_iter_loop(iter, "b", &usable)) { - if (usable) - VIR_USE_CPU(cpumap, cnt); - cnt++; - } + virtDBusDomainGVariantToCpumap(iter, &cpumap, &cpumaplen); =20 domain =3D virtDBusDomainGetVirDomain(connect, objectPath, error); if (!domain) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list