From nobody Mon Apr 29 11:27:07 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625567548769663.9570550396224; Tue, 6 Jul 2021 03:32:28 -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-54-L0IqgsxpN9qqXuf_1__gOw-1; Tue, 06 Jul 2021 06:32:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7973100C609; Tue, 6 Jul 2021 10:32:19 +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 871885C22A; Tue, 6 Jul 2021 10:32:18 +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 9758C4E9F4; Tue, 6 Jul 2021 10:32:16 +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 166AWF7L022130 for ; Tue, 6 Jul 2021 06:32:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 23A07200ACD8; Tue, 6 Jul 2021 10:32:15 +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 1D8EC2144B4F for ; Tue, 6 Jul 2021 10:32:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 EDFE1800B34 for ; Tue, 6 Jul 2021 10:32:08 +0000 (UTC) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-9LKWI9nBPaGf52LjGzNPlA-1; Tue, 06 Jul 2021 06:32:06 -0400 Received: by mail-pg1-f170.google.com with SMTP id t9so20952588pgn.4 for ; Tue, 06 Jul 2021 03:32:06 -0700 (PDT) Received: from localhost ([38.94.109.10]) by smtp.gmail.com with ESMTPSA id g1sm6007639pgs.23.2021.07.06.03.32.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 03:32:05 -0700 (PDT) X-MC-Unique: L0IqgsxpN9qqXuf_1__gOw-1 X-MC-Unique: 9LKWI9nBPaGf52LjGzNPlA-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=pm9gMNEnawupKSjEJu8jSt3IKqPDrKUFddLrnNcQ1Jc=; b=ewTr8/YSnKIhNLOe9hR27eubwan1JQXRm19p0tlaMMS2RS9Q2N+AchPC89jn41xBfY gyXo3BCOZU+msgOfALyRjYhOpCLzTuoo4s7Wcj1eT7kGI/o8ThCXcw4q0npZfbbrlx4J xyD0OBY4Chc30uz18g2vjaYsV0aVLTZHvlILLbi7NyN1x8NPcmQj8HvlomEqRDKlL2kQ WfipRuzpL1/k8X8hjVdEA1qi9WnwQoSK+KOBpwdeewrmzeW4XLQLvrNgtc24U5PFWutT otZ7l9PA7P5Edo6qZdeIfIKP+LiUMGmtRw0vO5HjfBs+ojvWNbBPmzEpnn8ClSjQdkK9 AxFg== X-Gm-Message-State: AOAM530HGuP+vtUfXpeXTjfJdRAg5konZ/Cly7zh+CIoQivUmjlbJubF Eyzd23nX+qS/WJwNZTS4Qv4Z/XuMlFuYoJD+ X-Google-Smtp-Source: ABdhPJxHywVo73QlK2vqrInVu5bDW3AdbX9L4g9tk91dKPcU/3awDmiwHnMpzxAgkfLDRuuNVNQN7Q== X-Received: by 2002:a05:6a00:1411:b029:302:d9d6:651d with SMTP id l17-20020a056a001411b0290302d9d6651dmr19445752pfu.56.1625567525690; Tue, 06 Jul 2021 03:32:05 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH 1/5] conf: domain: Introduce and use virDomainAddIOThreadCheck() Date: Tue, 6 Jul 2021 18:31:54 +0800 Message-Id: <20210706103158.294765-2-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.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.16 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: 1625567555878100001 Content-Type: text/plain; charset="utf-8" The test driver can share the same code with qemu driver when implement testDomainAddIOThreadCheck and testDomainDelIOThreadCheck, so extract them for test driver to use. Signed-off-by: Luke Yue --- src/conf/domain_conf.c | 66 ++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 8 +++++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_driver.c | 60 +++--------------------------------- 4 files changed, 80 insertions(+), 56 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 04c10df0a9..2721e2269e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31153,3 +31153,69 @@ virHostdevIsVFIODevice(const virDomainHostdevDef *= hostdev) hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI && hostdev->source.subsys.u.pci.backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI= _BACKEND_VFIO; } + + +/** + * virDomainAddIOThreadCheck: + * @def: domain definition + * @iothread_id: iothread id + * + * Returns -1 if an IOThread is already using the given iothread id + */ +int +virDomainAddIOThreadCheck(virDomainDef *def, + unsigned int iothread_id) +{ + if (virDomainIOThreadIDFind(def, iothread_id)) { + virReportError(VIR_ERR_INVALID_ARG, + _("an IOThread is already using iothread_id '%u'"), + iothread_id); + return -1; + } + + return 0; +} + + +/** + * virDomainDelIOThreadCheck: + * @def: domain definition + * @iothread_id: iothread id + * + * Returns -1 if there is no IOThread using the given iothread id + */ +int +virDomainDelIOThreadCheck(virDomainDef *def, + unsigned int iothread_id) +{ + size_t i; + + if (!virDomainIOThreadIDFind(def, iothread_id)) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot find IOThread '%u' in iothreadids list"), + iothread_id); + return -1; + } + + for (i =3D 0; i < def->ndisks; i++) { + if (def->disks[i]->iothread =3D=3D iothread_id) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot remove IOThread %u since it " + "is being used by disk '%s'"), + iothread_id, def->disks[i]->dst); + return -1; + } + } + + for (i =3D 0; i < def->ncontrollers; i++) { + if (def->controllers[i]->iothread =3D=3D iothread_id) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot remove IOThread '%u' since it " + "is being used by controller"), + iothread_id); + return -1; + } + } + + return 0; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4d9d499b16..0d06939e2b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4140,3 +4140,11 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *ho= stdev) bool virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); + +int +virDomainAddIOThreadCheck(virDomainDef *def, + unsigned int iothread_id); + +int +virDomainDelIOThreadCheck(virDomainDef *def, + unsigned int iothread_id); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 43e6398ae5..fa0462a133 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -226,6 +226,7 @@ virDiskNameParse; virDiskNameToBusDeviceIndex; virDiskNameToIndex; virDomainActualNetDefFree; +virDomainAddIOThreadCheck; virDomainAudioFormatTypeFromString; virDomainAudioFormatTypeToString; virDomainAudioIOCommonIsSet; @@ -349,6 +350,7 @@ virDomainDefSetVcpus; virDomainDefSetVcpusMax; virDomainDefVcpuOrderClear; virDomainDeleteConfig; +virDomainDelIOThreadCheck; virDomainDeviceAliasIsUserAlias; virDomainDeviceDefCopy; virDomainDeviceDefFree; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 235f575901..334c043b60 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5478,58 +5478,6 @@ qemuDomainHotplugDelIOThread(virQEMUDriver *driver, } =20 =20 -static int -qemuDomainAddIOThreadCheck(virDomainDef *def, - unsigned int iothread_id) -{ - if (virDomainIOThreadIDFind(def, iothread_id)) { - virReportError(VIR_ERR_INVALID_ARG, - _("an IOThread is already using iothread_id '%u'"), - iothread_id); - return -1; - } - - return 0; -} - - -static int -qemuDomainDelIOThreadCheck(virDomainDef *def, - unsigned int iothread_id) -{ - size_t i; - - if (!virDomainIOThreadIDFind(def, iothread_id)) { - virReportError(VIR_ERR_INVALID_ARG, - _("cannot find IOThread '%u' in iothreadids list"), - iothread_id); - return -1; - } - - for (i =3D 0; i < def->ndisks; i++) { - if (def->disks[i]->iothread =3D=3D iothread_id) { - virReportError(VIR_ERR_INVALID_ARG, - _("cannot remove IOThread %u since it " - "is being used by disk '%s'"), - iothread_id, def->disks[i]->dst); - return -1; - } - } - - for (i =3D 0; i < def->ncontrollers; i++) { - if (def->controllers[i]->iothread =3D=3D iothread_id) { - virReportError(VIR_ERR_INVALID_ARG, - _("cannot remove IOThread '%u' since it " - "is being used by controller"), - iothread_id); - return -1; - } - } - - return 0; -} - - /** * @params: Pointer to params list * @nparams: Number of params to be parsed @@ -5663,7 +5611,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, =20 switch (action) { case VIR_DOMAIN_IOTHREAD_ACTION_ADD: - if (qemuDomainAddIOThreadCheck(def, iothread.iothread_id) < 0) + if (virDomainAddIOThreadCheck(def, iothread.iothread_id) < 0) goto endjob; =20 if (qemuDomainHotplugAddIOThread(driver, vm, iothread.iothread= _id) < 0) @@ -5672,7 +5620,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, break; =20 case VIR_DOMAIN_IOTHREAD_ACTION_DEL: - if (qemuDomainDelIOThreadCheck(def, iothread.iothread_id) < 0) + if (virDomainDelIOThreadCheck(def, iothread.iothread_id) < 0) goto endjob; =20 if (qemuDomainHotplugDelIOThread(driver, vm, iothread.iothread= _id) < 0) @@ -5702,7 +5650,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, if (persistentDef) { switch (action) { case VIR_DOMAIN_IOTHREAD_ACTION_ADD: - if (qemuDomainAddIOThreadCheck(persistentDef, iothread.iothrea= d_id) < 0) + if (virDomainAddIOThreadCheck(persistentDef, iothread.iothread= _id) < 0) goto endjob; =20 if (!virDomainIOThreadIDAdd(persistentDef, iothread.iothread_i= d)) @@ -5711,7 +5659,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, break; =20 case VIR_DOMAIN_IOTHREAD_ACTION_DEL: - if (qemuDomainDelIOThreadCheck(persistentDef, iothread.iothrea= d_id) < 0) + if (virDomainDelIOThreadCheck(persistentDef, iothread.iothread= _id) < 0) goto endjob; =20 virDomainIOThreadIDDel(persistentDef, iothread.iothread_id); --=20 2.32.0 From nobody Mon Apr 29 11:27:07 2024 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 1625567572376441.9492558987446; Tue, 6 Jul 2021 03:32:52 -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-101-H2dlO6oRMGWUKeBYqtYOwA-1; Tue, 06 Jul 2021 06:32:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E3E91084F57; Tue, 6 Jul 2021 10:32:44 +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 20A24608BA; Tue, 6 Jul 2021 10:32:44 +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 DFD724EA39; Tue, 6 Jul 2021 10:32:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 166AWE1c022125 for ; Tue, 6 Jul 2021 06:32:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id B6DDF202F2FC; Tue, 6 Jul 2021 10:32:14 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2850202F2FB for ; Tue, 6 Jul 2021 10:32:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 62871866DF1 for ; Tue, 6 Jul 2021 10:32:11 +0000 (UTC) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-CwxN2apSOFSVGkJvG4op2A-1; Tue, 06 Jul 2021 06:32:09 -0400 Received: by mail-pj1-f50.google.com with SMTP id ie21so11531175pjb.0 for ; Tue, 06 Jul 2021 03:32:09 -0700 (PDT) Received: from localhost ([38.94.109.10]) by smtp.gmail.com with ESMTPSA id j16sm18139975pgh.69.2021.07.06.03.32.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 03:32:07 -0700 (PDT) X-MC-Unique: H2dlO6oRMGWUKeBYqtYOwA-1 X-MC-Unique: CwxN2apSOFSVGkJvG4op2A-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=BIFsUFKZ5y4MfcMPVuR/aincFWmTkb+QrwM+9fJYoKA=; b=U4Ovr34AivHkFQxiTMgKLmpHqv/nEO/p3pW+MJ7vAqatlTc59ZVn9m19+eUrpf2fuV NtcZ2s+zRPKWSpWeg9zVmwKTImvZDV9UVKRNQ1MRrni8Fvg08ehD/nncis0C498d5bZI sj9P7AGj8rmqm75/54AVawCgcwCG3LCzuC0qWIfAYgDYr3Gdd4KStwIfFjjbHaRxxn4f czfxTLmBgjAM6LIzqTJLAE0BV1mJdnGhENZ3Ad6cjw2tuKqml/eP7geik28wu0IHcgV4 hp5FuzDfMa8Oq93QwxV9ocNWkqCsaYJrzkYf8NdP8gRKMlcowZ1gD1rxGn3rLnWpoEV1 RIFA== X-Gm-Message-State: AOAM533YYfBV8eitAysXqHMaRZFliEyn0cIX5mgkoNwoTQH8kU3VQY9R O1rV2dWdXsjQ2vJ/nUI1X7OBmatGpWYyyPBR X-Google-Smtp-Source: ABdhPJzTRJm3wzVX/4rcxGJNrJeSo6tBjEo/pgz5nEW4SaV6Q6hju0fUNQnPxuvEbkQhgVdOUSx50g== X-Received: by 2002:a17:902:7045:b029:129:8507:baf8 with SMTP id h5-20020a1709027045b02901298507baf8mr9522225plt.35.1625567528192; Tue, 06 Jul 2021 03:32:08 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH 2/5] test_driver: Implement virDomainAddIOThread and virDomainDelIOThread Date: Tue, 6 Jul 2021 18:31:55 +0800 Message-Id: <20210706103158.294765-3-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.78 on 10.11.54.4 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.13 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: 1625567577448100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 160 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ef0ddab54d..6573ee3d61 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -182,6 +182,19 @@ struct _testDomainNamespaceDef { xmlNodePtr *snap_nodes; }; =20 +typedef struct _testMonitorIOThreadInfo testMonitorIOThreadInfo; +struct _testMonitorIOThreadInfo { + unsigned int iothread_id; + int thread_id; + bool poll_valid; + unsigned long long poll_max_ns; + unsigned int poll_grow; + unsigned int poll_shrink; + bool set_poll_max_ns; + bool set_poll_grow; + bool set_poll_shrink; +}; + static void testDomainDefNamespaceFree(void *data) { @@ -9291,6 +9304,151 @@ testDomainCheckpointDelete(virDomainCheckpointPtr c= heckpoint, return ret; } =20 +typedef enum { + VIR_DOMAIN_IOTHREAD_ACTION_ADD, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, + VIR_DOMAIN_IOTHREAD_ACTION_MOD, +} virDomainIOThreadAction; + +static int +testDomainChgIOThread(virDomainObj *vm, + testMonitorIOThreadInfo iothread, + virDomainIOThreadAction action, + unsigned int flags) +{ + virDomainDef *def; + virDomainDef *persistentDef; + int ret =3D -1; + + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + return ret; + + if (def) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: + if (virDomainAddIOThreadCheck(def, iothread.iothread_id) < 0) + return ret; + + if (!virDomainIOThreadIDAdd(def, iothread.iothread_id)) + return ret; + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: + if (virDomainDelIOThreadCheck(def, iothread.iothread_id) < 0) + return ret; + + virDomainIOThreadIDDel(def, iothread.iothread_id); + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_MOD: + if (!(virDomainIOThreadIDFind(def, iothread.iothread_id))) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot find IOThread '%u' in iothreadids= "), + iothread.iothread_id); + return ret; + } + + break; + } + } + + if (persistentDef) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: + if (virDomainAddIOThreadCheck(persistentDef, iothread.iothread= _id) < 0) + return ret; + + if (!virDomainIOThreadIDAdd(persistentDef, iothread.iothread_i= d)) + return ret; + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: + if (virDomainDelIOThreadCheck(persistentDef, iothread.iothread= _id) < 0) + return ret; + + virDomainIOThreadIDDel(persistentDef, iothread.iothread_id); + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_MOD: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("configuring persistent polling values is " + "not supported")); + return ret; + + break; + } + } + + ret =3D 0; + + return ret; +} + +static int +testDomainAddIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + testMonitorIOThreadInfo iothread =3D {0}; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (iothread_id =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + return -1; + } + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + iothread.iothread_id =3D iothread_id; + ret =3D testDomainChgIOThread(vm, iothread, + VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + +static int +testDomainDelIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + testMonitorIOThreadInfo iothread =3D {0}; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (iothread_id =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + return -1; + } + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + iothread.iothread_id =3D iothread_id; + ret =3D testDomainChgIOThread(vm, iothread, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + /* * Test driver */ @@ -9356,6 +9514,8 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetVcpus =3D testDomainGetVcpus, /* 0.7.3 */ .domainGetVcpuPinInfo =3D testDomainGetVcpuPinInfo, /* 1.2.18 */ .domainGetMaxVcpus =3D testDomainGetMaxVcpus, /* 0.7.3 */ + .domainAddIOThread =3D testDomainAddIOThread, /* 7.6.0 */ + .domainDelIOThread =3D testDomainDelIOThread, /* 7.6.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ .nodeGetSecurityModel =3D testNodeGetSecurityModel, /* 7.5.0 */ .domainGetXMLDesc =3D testDomainGetXMLDesc, /* 0.1.4 */ --=20 2.32.0 From nobody Mon Apr 29 11:27:07 2024 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 From nobody Mon Apr 29 11:27:07 2024 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 1625567577170347.4537516325081; Tue, 6 Jul 2021 03:32:57 -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-259-VmVwiYoMOIWOSDJtfpUXZA-1; Tue, 06 Jul 2021 06:32:52 -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 01E951084F4C; Tue, 6 Jul 2021 10:32:47 +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 D67005D9DC; Tue, 6 Jul 2021 10:32:46 +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 A1E481809CB3; Tue, 6 Jul 2021 10:32:46 +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 166AWJZg022160 for ; Tue, 6 Jul 2021 06:32:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id C43CC1002941; Tue, 6 Jul 2021 10:32:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BED611003215 for ; Tue, 6 Jul 2021 10:32:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 1CE9180158D for ; Tue, 6 Jul 2021 10:32:17 +0000 (UTC) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-9j4e_6azPSmLMCW3RVC-mA-1; Tue, 06 Jul 2021 06:32:14 -0400 Received: by mail-pj1-f50.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso1398038pjx.1 for ; Tue, 06 Jul 2021 03:32:14 -0700 (PDT) Received: from localhost ([38.94.109.10]) by smtp.gmail.com with ESMTPSA id h9sm8880129pgi.43.2021.07.06.03.32.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 03:32:13 -0700 (PDT) X-MC-Unique: VmVwiYoMOIWOSDJtfpUXZA-1 X-MC-Unique: 9j4e_6azPSmLMCW3RVC-mA-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=XlLCTWGSEdfQyJnbszWtoz1h0t90E2qTlSdmaIQdwmo=; b=WTW4/UigFAuN6jMsW/pVZDe+R6Ix0RlYbLAL0SUksLDyhHa14GrR10e4LNP5Usfu09 1AFHEUc5Rb2gRvJlKV0zHoc6DODvqHh5qNfjvRlkLPndM+eZgokX9zXkROrayTEt+wqL H7HjEbheOKCggKZdjQRvd1U2ulvElqDpDi5HWwxM7FQkh+GTvmKSBy9ouJMWur46bTdg NBY5tOIbJ8OZS0gqsrS3hpVQiOO5OjT8Tj1DBp45Yrx085S3dQKsJtcdHafGG4zT6KGx FODNhrvY66+91UDJMgUwALRR9ulUh2tvPJQKJwRMNWyFiiuOENSIjWSnZsZSl2sp8YOi kj2g== X-Gm-Message-State: AOAM532TQ1JofX2FQC5i0DidqZBCW4tN2a3hcNYPTXgRXn8qLU6IM4nX /bNB4nvUAmDYsQTpfy26RmfCtRm5F+auJf7o X-Google-Smtp-Source: ABdhPJyAUP21rjcYiazVhPUlgFtu16iKuI+P9X5GK4qU/tXHioG9Xxe/xhsQDW414bdyzj+bKvh36A== X-Received: by 2002:a17:90a:3fcd:: with SMTP id u13mr19616538pjm.182.1625567533302; Tue, 06 Jul 2021 03:32:13 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH 4/5] test_driver: Implement virDomainGetIOThreadInfo Date: Tue, 6 Jul 2021 18:31:57 +0800 Message-Id: <20210706103158.294765-5-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.78 on 10.11.54.3 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-ZM-MESSAGEID: 1625567582050100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6573ee3d61..20aee59f98 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9304,6 +9304,31 @@ testDomainCheckpointDelete(virDomainCheckpointPtr ch= eckpoint, return ret; } =20 +static int +testDomainGetIOThreadInfo(virDomainPtr dom, + virDomainIOThreadInfoPtr **info, + unsigned int flags) +{ + virDomainObj *vm; + virDomainDef *targetDef =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + targetDef =3D vm->def; + + if (targetDef) + ret =3D virDomainGetIOThreadsConfig(targetDef, info); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, VIR_DOMAIN_IOTHREAD_ACTION_DEL, @@ -9514,6 +9539,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetVcpus =3D testDomainGetVcpus, /* 0.7.3 */ .domainGetVcpuPinInfo =3D testDomainGetVcpuPinInfo, /* 1.2.18 */ .domainGetMaxVcpus =3D testDomainGetMaxVcpus, /* 0.7.3 */ + .domainGetIOThreadInfo =3D testDomainGetIOThreadInfo, /* 7.6.0 */ .domainAddIOThread =3D testDomainAddIOThread, /* 7.6.0 */ .domainDelIOThread =3D testDomainDelIOThread, /* 7.6.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ --=20 2.32.0 From nobody Mon Apr 29 11:27:07 2024 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 1625567565766504.122781313897; 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-501-3XSaZo2EPje8n6zsF6LztA-1; Tue, 06 Jul 2021 06:32:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 009A2804140; Tue, 6 Jul 2021 10:32:38 +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 A1935608BA; Tue, 6 Jul 2021 10:32:37 +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 67F9D1809CAC; Tue, 6 Jul 2021 10:32:37 +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 166AWJk8022159 for ; Tue, 6 Jul 2021 06:32:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id C1089100321E; Tue, 6 Jul 2021 10:32:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBB5A1005B69 for ; Tue, 6 Jul 2021 10:32:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 400B680D08E for ; Tue, 6 Jul 2021 10:32:19 +0000 (UTC) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-sGnSVaZ6MGyGQFHvu87gsw-1; Tue, 06 Jul 2021 06:32:17 -0400 Received: by mail-pf1-f182.google.com with SMTP id f20so11166426pfa.1 for ; Tue, 06 Jul 2021 03:32:16 -0700 (PDT) Received: from localhost ([38.94.109.10]) by smtp.gmail.com with ESMTPSA id f68sm16199192pfa.46.2021.07.06.03.32.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 03:32:15 -0700 (PDT) X-MC-Unique: 3XSaZo2EPje8n6zsF6LztA-1 X-MC-Unique: sGnSVaZ6MGyGQFHvu87gsw-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=jWK9uZFM9acYSkbx/ggwZIl3FU44IP8GFZxS6JWsPDg=; b=AlBVTzM00uL5cVKH9rtdtZ9lKBfWQBZIquQBr1BJQxec/zcInqJINxlgCjJVImQvgm ocG58h7p6TBg3rr1B70/rVQXbI4Il4CBoTYK5Bgpbwd0Eym/G4a3o2Jlq6CgEZgaWOHV 8hh3qSdx58orRE+tDSop6oimLh7MddFJdhzfg4HCdec2fNRFQgsFpgGNI3roeXIU6PkV mUeIh2cbTSOJfif0sTYdBNFui7aDKvl24RQC0ztP9I1pwUT1g8C9yjnXYQUtBmLCZkN3 UJQWQyXkARJUHNA81sBHAFCG1V1JGcDwqsRgvjPynKwrHXGZ7oSDyNquqbBpJqMt6kiY K8BQ== X-Gm-Message-State: AOAM5327RUKA4kD89+gHQvWZlsrO1i9RGKO2+facAsUK9SB/yr+Cp8uX qszGGEGm75hIa3BKLWRRGqKExPzCUcRHfBUW X-Google-Smtp-Source: ABdhPJwRZVJ5blHf3YhJyrM3Un6qQx5WFWBs9fPHvJ3e3wRXoXIguJo2Dg1EWYhIAfobjN+Uoyn9Eg== X-Received: by 2002:a63:dd51:: with SMTP id g17mr20560368pgj.238.1625567535852; Tue, 06 Jul 2021 03:32:15 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH 5/5] tests: Test IOThread related functions for test driver Date: Tue, 6 Jul 2021 18:31:58 +0800 Message-Id: <20210706103158.294765-6-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.78 on 10.11.54.3 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.13 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: 1625568478362100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- examples/xml/test/testdomfc4.xml | 4 ++++ tests/virshtest.c | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/examples/xml/test/testdomfc4.xml b/examples/xml/test/testdomfc= 4.xml index 26b7f25a06..25ad45365a 100644 --- a/examples/xml/test/testdomfc4.xml +++ b/examples/xml/test/testdomfc4.xml @@ -11,6 +11,10 @@ 261072 131072 1 + 1 + + + diff --git a/tests/virshtest.c b/tests/virshtest.c index c1974c46cb..10ff5a4b78 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -250,6 +250,34 @@ static int testCompareDomstateByName(const void *data = G_GNUC_UNUSED) return testCompareOutputLit(exp, NULL, argv); } =20 +static int testIOThreadAdd(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadadd", "--domain"= , "fc4", "--id", "1", NULL}; + const char *exp =3D "\n"; + + return testCompareOutputLit(exp, NULL, argv); +} + +static int testIOThreadDel(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "iothreaddel", "--domain"= , "fc4", "--id", "2", NULL}; + const char *exp =3D "\n"; + + return testCompareOutputLit(exp, NULL, argv); +} + +static int testIOThreadInfo(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadinfo", "--domain= ", "fc4", NULL}; + const char *exp =3D "\ + IOThread ID CPU Affinity\n\ +-----------------------------\n\ + 2 0-7\n\ +\n"; + + return testCompareOutputLit(exp, NULL, argv); +} + struct testInfo { const char *const *argv; const char *result; @@ -334,6 +362,18 @@ mymain(void) testCompareDomstateByName, NULL) !=3D 0) ret =3D -1; =20 + if (virTestRun("virsh iothreadadd", + testIOThreadAdd, NULL) !=3D 0) + ret =3D -1; + + if (virTestRun("virsh iothreaddel", + testIOThreadDel, NULL) !=3D 0) + ret =3D -1; + + if (virTestRun("virsh iothreadinfo", + testIOThreadInfo, NULL) !=3D 0) + ret =3D -1; + /* It's a bit awkward listing result before argument, but that's a * limitation of C99 vararg macros. */ # define DO_TEST(i, result, ...) \ --=20 2.32.0