From nobody Sun Feb 8 15:25:31 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=1654606450; cv=none; d=zohomail.com; s=zohoarc; b=KvThbOUlyLrLuZTuxyAlqLLFn2G4gzGaA0Kqvp8Qtk5Ta+utIzg5XPzvXvQ/feTwAVo30ZH48i/E9VN5U3F/mcuUdIiwmM2wSJzf/jn2RWQlXbIZixSts7KlsfxuaDR51/ZrPBv6gSe4OdvqZZ+fRVaxO41Rmpheo9qdhMEJ0NI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654606450; 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=pKeRp1+MR1fQbcs/7/puc9xGnLv2M9DtiJpbidA80TQ=; b=cWiKce+iac3K6cBKGLetxTC9MyBOcgUbt1Atc1ItCt+8CXQGxHpYtJmmo3QIL5YmKmPW+pHQS+FVroLL+3JAoCUHvOvHeTzfu+lS7V0OlEi9Z9PX+35Lg5cQHpV4MK8rIbYSarxMkoZ8OX+sv7bIqypQTicCZjlKzjqy7copeBw= 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 1654606450454332.2151376119573; Tue, 7 Jun 2022 05:54:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-573-L1GHy8yhOO-tf8pmIArUZw-1; Tue, 07 Jun 2022 08:53:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 29A1B8517E7; Tue, 7 Jun 2022 12:53:13 +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 108302026D64; Tue, 7 Jun 2022 12:53:13 +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 E0F1A1947B87; Tue, 7 Jun 2022 12:53:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6EA541947B8C for ; Tue, 7 Jun 2022 12:53:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6272B4050C40; Tue, 7 Jun 2022 12:53:11 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.246.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09B594050C41 for ; Tue, 7 Jun 2022 12:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654606449; 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=pKeRp1+MR1fQbcs/7/puc9xGnLv2M9DtiJpbidA80TQ=; b=b6/kSa6KoLrzRhP8saABZXTmz0OQu06Un/lhXXoqqiek1S142SNmvcipG73mhbK74pw5kV 5OwILf9hhHBLbOoPk17VImp/j1JNAmISMnlgBGnMC7T+xbEcYzcGR9DFfcTkJ1sahGhjiu YSQ0KBS4Yrsu74U0rciNaKzy0oL14r4= X-MC-Unique: L1GHy8yhOO-tf8pmIArUZw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 13/15] conf: Expose QEMU's main loop object Date: Tue, 7 Jun 2022 14:52:57 +0200 Message-Id: <54ff2d4983e6ec286b2cb44894360dd844bd82a0.1654606121.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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 2.78 on 10.11.54.4 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) X-ZM-MESSAGEID: 1654606450824100007 Content-Type: text/plain; charset="utf-8"; x-default="true" As of v7.0.0-877-g70ac26b9e5 QEMU exposes its main event loop as an QMP object. In the very next commit (v7.0.0-878-g71ad4713cc) it was extended for thread-pool-min and thread-pool-max attributes. Expose them under new element. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- docs/formatdomain.rst | 9 +++ src/conf/domain_conf.c | 63 +++++++++++++++++++ src/conf/domain_conf.h | 8 +++ src/conf/schemas/domaincommon.rng | 15 +++++ src/conf/virconftypes.h | 2 + .../iothreads-ids-pool-sizes.xml | 1 + 6 files changed, 98 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 2aa39b2f63..22eb540ba3 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -677,6 +677,7 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU on= ly)` + ... =20 @@ -699,6 +700,14 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU o= nly)` The element has two optional attributes ``thread_pool_min`` and ``hread_pool_max`` which allow setting lower and upper boundary for num= ber of worker threads for given IOThread. :since:`Since 8.5.0` +``defaultiothread`` + The element then can have ``thread_pool_min`` and/or ``thread_pool_max`` + attributes, which control the lower and upper boundary for number of wo= rker + threads for the emulator. Emulator might be multithreaded and spawn so + called worker threads on demand. In general neither of these attributes + should be set (leaving the emulator use its own default values), unless= the + emulator runs in a real time workload and thus can't afford unpredictab= ility + of time it takes to spawn new worker threads. :since:`Since 8.5.0` =20 =20 CPU Tuning diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8891289866..b1e7c2ef22 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3824,6 +3824,8 @@ void virDomainDefFree(virDomainDef *def) =20 virDomainIOThreadIDDefArrayFree(def->iothreadids, def->niothreadids); =20 + g_free(def->defaultIOThread); + virBitmapFree(def->cputune.emulatorpin); g_free(def->cputune.emulatorsched); =20 @@ -17016,6 +17018,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, * * * + * */ static virDomainIOThreadIDDef * virDomainIOThreadIDDefParseXML(xmlNodePtr node) @@ -17041,6 +17044,38 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node) } =20 =20 +static int +virDomainDefaultIOThreadDefParse(virDomainDef *def, + xmlXPathContextPtr ctxt) +{ + xmlNodePtr node =3D NULL; + g_autofree virDomainDefaultIOThreadDef *thrd =3D NULL; + + node =3D virXPathNode("./defaultiothread", ctxt); + if (!node) + return 0; + + thrd =3D g_new0(virDomainDefaultIOThreadDef, 1); + + if (virXMLPropInt(node, "thread_pool_min", 10, + VIR_XML_PROP_NONNEGATIVE, + &thrd->thread_pool_min, -1) < 0) + return -1; + + if (virXMLPropInt(node, "thread_pool_max", 10, + VIR_XML_PROP_NONNEGATIVE, + &thrd->thread_pool_max, -1) < 0) + return -1; + + if (thrd->thread_pool_min =3D=3D -1 && + thrd->thread_pool_max =3D=3D -1) + return 0; + + def->defaultIOThread =3D g_steal_pointer(&thrd); + return 0; +} + + static int virDomainDefParseIOThreads(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -17058,6 +17093,9 @@ virDomainDefParseIOThreads(virDomainDef *def, return -1; } =20 + if (virDomainDefaultIOThreadDefParse(def, ctxt) < 0) + return -1; + /* Extract any iothread id's defined */ if ((n =3D virXPathNodeSet("./iothreadids/iothread", ctxt, &nodes)) < = 0) return -1; @@ -27603,6 +27641,29 @@ virDomainDefIothreadShouldFormat(const virDomainDe= f *def) } =20 =20 +static void +virDomainDefaultIOThreadDefFormat(virBuffer *buf, + const virDomainDef *def) +{ + virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; + + if (!def->defaultIOThread) + return; + + if (def->defaultIOThread->thread_pool_min >=3D 0) { + virBufferAsprintf(&attrBuf, " thread_pool_min=3D'%d'", + def->defaultIOThread->thread_pool_min); + } + + if (def->defaultIOThread->thread_pool_max >=3D 0) { + virBufferAsprintf(&attrBuf, " thread_pool_max=3D'%d'", + def->defaultIOThread->thread_pool_max); + } + + virXMLFormatElement(buf, "defaultiothread", &attrBuf, NULL); +} + + static void virDomainDefIOThreadsFormat(virBuffer *buf, const virDomainDef *def) @@ -27640,6 +27701,8 @@ virDomainDefIOThreadsFormat(virBuffer *buf, } =20 virXMLFormatElement(buf, "iothreadids", NULL, &childrenBuf); + + virDomainDefaultIOThreadDefFormat(buf, def); } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2a5001f15c..98b8ce703c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2655,6 +2655,12 @@ void virDomainIOThreadIDDefFree(virDomainIOThreadIDD= ef *def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainIOThreadIDDef, virDomainIOThreadIDD= efFree); =20 =20 +struct _virDomainDefaultIOThreadDef { + int thread_pool_min; + int thread_pool_max; +}; + + struct _virDomainCputune { unsigned long long shares; bool sharesSpecified; @@ -2863,6 +2869,8 @@ struct _virDomainDef { size_t niothreadids; virDomainIOThreadIDDef **iothreadids; =20 + virDomainDefaultIOThreadDef *defaultIOThread; + virDomainCputune cputune; =20 virDomainResctrlDef **resctrls; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 7e6310832b..e64900d0cf 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -844,6 +844,21 @@ =20 + + + + + + + + + + + + + + + diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index 21420ba8ea..c3f1c5fa01 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -142,6 +142,8 @@ typedef struct _virDomainIOMMUDef virDomainIOMMUDef; =20 typedef struct _virDomainIOThreadIDDef virDomainIOThreadIDDef; =20 +typedef struct _virDomainDefaultIOThreadDef virDomainDefaultIOThreadDef; + typedef struct _virDomainIdMapDef virDomainIdMapDef; =20 typedef struct _virDomainIdMapEntry virDomainIdMapEntry; diff --git a/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml b/tests/qe= muxml2argvdata/iothreads-ids-pool-sizes.xml index 0f93d14f12..4cebdfada9 100644 --- a/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml +++ b/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml @@ -12,6 +12,7 @@ + hvm --=20 2.35.1