From nobody Wed Feb 11 02:06:35 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 16255675654811004.3011675004055; Tue, 6 Jul 2021 03:32:45 -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-445-IIgYoeSHO_aUYohWo3Em4A-1; Tue, 06 Jul 2021 06:32:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1DC23100C610; Tue, 6 Jul 2021 10:32:37 +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 EBCEC60CA1; Tue, 6 Jul 2021 10:32:36 +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 B758B1809C99; Tue, 6 Jul 2021 10:32:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 166AWESt022120 for ; Tue, 6 Jul 2021 06:32:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1EB6F6E1DB; Tue, 6 Jul 2021 10:32:14 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16E882D47D for ; Tue, 6 Jul 2021 10:32:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 F3C7018A01A0 for ; Tue, 6 Jul 2021 10:32:13 +0000 (UTC) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-DAjmdOyQO8K4vlLhbK8cGg-1; Tue, 06 Jul 2021 06:32:12 -0400 Received: by mail-pf1-f170.google.com with SMTP id a127so19042943pfa.10 for ; Tue, 06 Jul 2021 03:32:11 -0700 (PDT) Received: from localhost ([38.94.109.10]) by smtp.gmail.com with ESMTPSA id p28sm5464760pfw.93.2021.07.06.03.32.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 03:32:10 -0700 (PDT) X-MC-Unique: IIgYoeSHO_aUYohWo3Em4A-1 X-MC-Unique: DAjmdOyQO8K4vlLhbK8cGg-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=2+ucMH79VLexNM9VB8Qb59y098/qsK6MXsUI73a1oTg=; b=JahlINyTaF1N4fRaqHEho5EUy8AksurWXOnOZYFefhe0oCeuiOo0X5/GLZs6dOE8Ji Y1uxvo2HLbgd6P1pUNoYFv+Vsov6Y6fNYxfNhyFZjzgLwQeJl73TKY6sc8U7SOXy2f3j MKk3D9BQk0KZ9yww9PnXEJnyCjqKycgMuq61yZ5JzxMF9XN1I5HPpsqKgttsDPeu2efl Nss9pGIoycI77gD/oUF/mWdCkOtkDm1RFBzE3ClQE28eJeeDH782LBjzgfXwRUyjZu+E Reozvk10jJrZLPtQiYF9aYLhKhCn+hGzmAUQ/TsFw+AljmGBIaPnGE78UI3vvy1nPbLM AVIw== X-Gm-Message-State: AOAM53148dr5EbVNED2a+dR9r1KhsgFJ43SpjEuFzcba5DPZVJk16NdB ylih+qeUGT/bTxc4TA1R3wegOfr4qwOC9Unt X-Google-Smtp-Source: ABdhPJzXWV07WcA7NyLS5en6JGRA9UtNVkA/4cCZwUhIgC8TM0LteoeoAm4hZSVH+hN4Ezc/uVW/eQ== X-Received: by 2002:aa7:8058:0:b029:2e9:ee0e:b106 with SMTP id y24-20020aa780580000b02902e9ee0eb106mr20025006pfm.4.1625567530780; Tue, 06 Jul 2021 03:32:10 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH 3/5] conf: domain: Introduce and use virDomainGetIOThreadsConfig() Date: Tue, 6 Jul 2021 18:31:56 +0800 Message-Id: <20210706103158.294765-4-lukedyue@gmail.com> In-Reply-To: <20210706103158.294765-1-lukedyue@gmail.com> References: <20210706103158.294765-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.79 on 10.11.54.5 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.12 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: 1625567573336100002 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/conf/domain_conf.c | 60 ++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 4 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 53 +---------------------------------- 4 files changed, 66 insertions(+), 52 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2721e2269e..03a0fb55fe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31219,3 +31219,63 @@ virDomainDelIOThreadCheck(virDomainDef *def, =20 return 0; } + + +/** + * virDomainGetIOThreadsConfig: + * @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 +virDomainGetIOThreadsConfig(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/conf/domain_conf.h b/src/conf/domain_conf.h index 0d06939e2b..7d2f1420ba 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4148,3 +4148,7 @@ virDomainAddIOThreadCheck(virDomainDef *def, int virDomainDelIOThreadCheck(virDomainDef *def, unsigned int iothread_id); + +int +virDomainGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fa0462a133..06b875e045 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -423,6 +423,7 @@ virDomainFSWrpolicyTypeFromString; virDomainFSWrpolicyTypeToString; virDomainGetBlkioParametersAssignFromDef; virDomainGetFilesystemForTarget; +virDomainGetIOThreadsConfig; virDomainGraphicsAuthConnectedTypeFromString; virDomainGraphicsAuthConnectedTypeToString; virDomainGraphicsDefFree; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 334c043b60..e7365570d4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5080,57 +5080,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, @@ -5157,7 +5106,7 @@ qemuDomainGetIOThreadInfo(virDomainPtr dom, if (!targetDef) ret =3D qemuDomainGetIOThreadsLive(driver, vm, info); else - ret =3D qemuDomainGetIOThreadsConfig(targetDef, info); + ret =3D virDomainGetIOThreadsConfig(targetDef, info); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.32.0