From nobody Mon Feb 9 01:21:10 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1627560703315909.1393821350779; Thu, 29 Jul 2021 05:11:43 -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-435-6ovQnq02OiCK9dEU6jcAhQ-1; Thu, 29 Jul 2021 08:11:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74D9B94DD0; Thu, 29 Jul 2021 12:11:32 +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 59E0469FAD; Thu, 29 Jul 2021 12:11:32 +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 2817D180BAB2; Thu, 29 Jul 2021 12:11:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16TCBLVL014620 for ; Thu, 29 Jul 2021 08:11:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 13232202C0E5; Thu, 29 Jul 2021 12:11:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E34C202BFB9 for ; Thu, 29 Jul 2021 12:11:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E938A800883 for ; Thu, 29 Jul 2021 12:11:20 +0000 (UTC) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-T41tw9CGNImFcYV-t699aQ-1; Thu, 29 Jul 2021 08:11:18 -0400 Received: by mail-pl1-f176.google.com with SMTP id a20so6797639plm.0 for ; Thu, 29 Jul 2021 05:11:18 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id 11sm3809266pgh.52.2021.07.29.05.11.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:17 -0700 (PDT) X-MC-Unique: 6ovQnq02OiCK9dEU6jcAhQ-1 X-MC-Unique: T41tw9CGNImFcYV-t699aQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/SjR1Jtn+gmtzR6x8qR0yh4el7VZe4N71g1+tpLldV0=; b=OUCiEXQ6g2cG+jOi53vOmAOYKVVmwHXcGbrJ7Ak+z9w1OpCdNjptIs/K+LSOsd6SbN SGwQlk1/3KqCdbZNfsUz8AUS2pzlItvy+mcPR8eOXEa45HmFABZF8yQt3zZg3irxMVvx DEJ7YhCo++ubTLxtIIfiOZPEeiUyjAf8yzEPMzkrxJaQ9kU3EXC2r1GTe5Ma+LHI+9e0 m1ThtCoLAW39LFI+kRb8FjTemaozBvbkgo/JVvdLtQAK1rhZyIXH3xTRUQ5og0DhRwXH HPY5ys6lOAMCv2X5Fr3p8i0ItlXiBE4ASyhHgD0YdxfMQgQcxT7Q3TLr//L2Y+A0pxCM RXMQ== X-Gm-Message-State: AOAM533LyArjuB+DfCuBgmwXXfrDmEEKB5zFzKZRbmTh+buPKfwsebTj OqoAGAb0JwkujuEbE6rqR/ahAObUkSMdv+7WRXE2Pg== X-Google-Smtp-Source: ABdhPJzaxhpwL98y57wkz0sY0SGrNOIEgSPL4QbFwY7z95mKVNhizCNT6OWZAX8/W+3iNAEBpzFaKw== X-Received: by 2002:a17:90a:4fa4:: with SMTP id q33mr5044595pjh.75.1627560677415; Thu, 29 Jul 2021 05:11:17 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 05/11] domain_driver.c: Introduce and use virDomainDriverGetIOThreadsConfig() Date: Thu, 29 Jul 2021 20:10:52 +0800 Message-Id: <20210729121058.454431-6-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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.11 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-ZM-MESSAGEID: 1627560705623100002 Content-Type: text/plain; charset="utf-8" The test driver can share the same code with qemu driver when implement testDomainGetIOThreadsConfig, so extract it for test driver to use. Signed-off-by: Luke Yue --- src/hypervisor/domain_driver.c | 59 ++++++++++++++++++++++++++++++++++ src/hypervisor/domain_driver.h | 3 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 53 +----------------------------- 4 files changed, 64 insertions(+), 52 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 0d4d9ae5de..fd0665daaf 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -575,3 +575,62 @@ virDomainDriverDelIOThreadCheck(virDomainDef *def, =20 return 0; } + +/** + * virDomainDriverGetIOThreadsConfig: + * @targetDef: domain definition + * @info: information about the IOThread in a domain + * + * Returns the number of IOThreads in the given domain or -1 in case of er= ror + */ +int +virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info) +{ + virDomainIOThreadInfoPtr *info_ret =3D NULL; + virBitmap *bitmap =3D NULL; + virBitmap *cpumask =3D NULL; + size_t i; + int ret =3D -1; + + if (targetDef->niothreadids =3D=3D 0) + return 0; + + info_ret =3D g_new0(virDomainIOThreadInfoPtr, targetDef->niothreadids); + + for (i =3D 0; i < targetDef->niothreadids; i++) { + info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); + + /* IOThread ID's are taken from the iothreadids list */ + info_ret[i]->iothread_id =3D targetDef->iothreadids[i]->iothread_i= d; + + cpumask =3D targetDef->iothreadids[i]->cpumask; + if (!cpumask) { + if (targetDef->cpumask) { + cpumask =3D targetDef->cpumask; + } else { + if (!(bitmap =3D virHostCPUGetAvailableCPUsBitmap())) + goto cleanup; + cpumask =3D bitmap; + } + } + if (virBitmapToData(cpumask, &info_ret[i]->cpumap, + &info_ret[i]->cpumaplen) < 0) + goto cleanup; + virBitmapFree(bitmap); + bitmap =3D NULL; + } + + *info =3D g_steal_pointer(&info_ret); + ret =3D targetDef->niothreadids; + + cleanup: + if (info_ret) { + for (i =3D 0; i < targetDef->niothreadids; i++) + virDomainIOThreadInfoFree(info_ret[i]); + VIR_FREE(info_ret); + } + virBitmapFree(bitmap); + + return ret; +} diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index d91d21bc91..638f01274b 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -66,3 +66,6 @@ int virDomainDriverAddIOThreadCheck(virDomainDef *def, =20 int virDomainDriverDelIOThreadCheck(virDomainDef *def, unsigned int iothread_id); + +int virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fa2412c0dc..4db2c5362d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1535,6 +1535,7 @@ virDomainDriverAddIOThreadCheck; virDomainDriverDelIOThreadCheck; virDomainDriverGenerateMachineName; virDomainDriverGenerateRootHash; +virDomainDriverGetIOThreadsConfig; virDomainDriverMergeBlkioDevice; virDomainDriverNodeDeviceDetachFlags; virDomainDriverNodeDeviceGetPCIInfo; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b96ac985bf..81e3f94f8b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5079,57 +5079,6 @@ qemuDomainGetIOThreadsLive(virQEMUDriver *driver, return ret; } =20 -static int -qemuDomainGetIOThreadsConfig(virDomainDef *targetDef, - virDomainIOThreadInfoPtr **info) -{ - virDomainIOThreadInfoPtr *info_ret =3D NULL; - virBitmap *bitmap =3D NULL; - virBitmap *cpumask =3D NULL; - size_t i; - int ret =3D -1; - - if (targetDef->niothreadids =3D=3D 0) - return 0; - - info_ret =3D g_new0(virDomainIOThreadInfoPtr, targetDef->niothreadids); - - for (i =3D 0; i < targetDef->niothreadids; i++) { - info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); - - /* IOThread ID's are taken from the iothreadids list */ - info_ret[i]->iothread_id =3D targetDef->iothreadids[i]->iothread_i= d; - - cpumask =3D targetDef->iothreadids[i]->cpumask; - if (!cpumask) { - if (targetDef->cpumask) { - cpumask =3D targetDef->cpumask; - } else { - if (!(bitmap =3D virHostCPUGetAvailableCPUsBitmap())) - goto cleanup; - cpumask =3D bitmap; - } - } - if (virBitmapToData(cpumask, &info_ret[i]->cpumap, - &info_ret[i]->cpumaplen) < 0) - goto cleanup; - virBitmapFree(bitmap); - bitmap =3D NULL; - } - - *info =3D g_steal_pointer(&info_ret); - ret =3D targetDef->niothreadids; - - cleanup: - if (info_ret) { - for (i =3D 0; i < targetDef->niothreadids; i++) - virDomainIOThreadInfoFree(info_ret[i]); - VIR_FREE(info_ret); - } - virBitmapFree(bitmap); - - return ret; -} =20 static int qemuDomainGetIOThreadInfo(virDomainPtr dom, @@ -5156,7 +5105,7 @@ qemuDomainGetIOThreadInfo(virDomainPtr dom, if (!targetDef) ret =3D qemuDomainGetIOThreadsLive(driver, vm, info); else - ret =3D qemuDomainGetIOThreadsConfig(targetDef, info); + ret =3D virDomainDriverGetIOThreadsConfig(targetDef, info); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.32.0