From nobody Sun Apr 28 09:07:02 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 1628765718259349.4400551111787; Thu, 12 Aug 2021 03:55:18 -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-479-O9pDFF8LPi2wWRq_bwFhdA-1; Thu, 12 Aug 2021 06:55:15 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F3318015C7; Thu, 12 Aug 2021 10:55:10 +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 76BBC1002D71; Thu, 12 Aug 2021 10:55:10 +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 44A684BB7C; Thu, 12 Aug 2021 10:55:10 +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 17CAoMAN015140 for ; Thu, 12 Aug 2021 06:50:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4880111515F; Thu, 12 Aug 2021 10:50:22 +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 435B0114D10 for ; Thu, 12 Aug 2021 10:50:19 +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 9FDAC8309DD for ; Thu, 12 Aug 2021 10:50:19 +0000 (UTC) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-320-VY1ffLYsMpG2g_NiYiOc2g-1; Thu, 12 Aug 2021 06:50:14 -0400 Received: by mail-pj1-f41.google.com with SMTP id m24-20020a17090a7f98b0290178b1a81700so10058418pjl.4 for ; Thu, 12 Aug 2021 03:50:14 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id a187sm3101746pfd.43.2021.08.12.03.50.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:12 -0700 (PDT) X-MC-Unique: O9pDFF8LPi2wWRq_bwFhdA-1 X-MC-Unique: VY1ffLYsMpG2g_NiYiOc2g-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=vlsUYgzPTmCUS95WXhxdbNJKLWYKVY2qnkgZSJ82v9c=; b=X2orOvQ/MBHF3lEZhK2EdhSA6StxdCzq0xB9gFZ7KE+dAQjdJ6wUgTEbDZFu4K00Iq J61sb0zX2XIWe5ps50KvTOJjjJ4t+HlkzJWR59Rh8b+0etfqFdNbFomD1qi9xkNPpsfh 6gosaMK3fxpZ5aZeYYvFjKlN6wpt4eFPLkQvnWhrSTF2liSdJ4p0v/TW3pEQyt+Pv2hu KjnlnogyW7EfoOMrmzOkS/3K3cePHtTfakdRjQxcdqntuY/XifV67cuonmxW8M++O8qZ wgWd+k2i2rfykWXPfXv3M2W1LgU5p3KyeCaSz70kCM3aHYh3sxsBFd8r/sU7wHSZyM/O 1lYA== X-Gm-Message-State: AOAM530QVqSHMjuPG5PD5a8VC4Wwmvj9WI2a8fjxgQtVt1M36Cb4cZVg Ksj5yvxTrlfYeBPioBMIKNsb5IREoXJV4pIZUPQ= X-Google-Smtp-Source: ABdhPJz7ghaunUxOl8WGqMbHZ6cq9QKQLU3Y5yXy6kn8X4Nxlp8KPGgqlHwuDu+fSiIeASikREVUiQ== X-Received: by 2002:a05:6a00:1c5d:b029:3e0:6fb9:1de4 with SMTP id s29-20020a056a001c5db02903e06fb91de4mr3623300pfw.21.1628765413254; Thu, 12 Aug 2021 03:50:13 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 01/11] domain_driver.c: Introduce and use virDomainDriverAddIOThreadCheck() Date: Thu, 12 Aug 2021 18:49:52 +0800 Message-Id: <20210812105002.197134-2-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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.84 on 10.5.11.22 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: 1628765720158100001 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/hypervisor/domain_driver.c | 64 ++++++++++++++++++++++++++++++++++ src/hypervisor/domain_driver.h | 6 ++++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_driver.c | 60 +++---------------------------- 4 files changed, 76 insertions(+), 56 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 2969d55173..3eb2401053 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -512,3 +512,67 @@ virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr = dev, =20 return virHostdevPCINodeDeviceDetach(hostdevMgr, pci); } + +/** + * virDomainDriverAddIOThreadCheck: + * @def: domain definition + * @iothread_id: iothread id + * + * Returns -1 if an IOThread is already using the given iothread id + */ +int +virDomainDriverAddIOThreadCheck(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; +} + +/** + * virDomainDriverDelIOThreadCheck: + * @def: domain definition + * @iothread_id: iothread id + * + * Returns -1 if there is no IOThread using the given iothread id + */ +int +virDomainDriverDelIOThreadCheck(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/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index 5970eef082..d91d21bc91 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -60,3 +60,9 @@ int virDomainDriverNodeDeviceReAttach(virNodeDevicePtr de= v, int virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr dev, virHostdevManager *hostdevMgr, const char *driverName); + +int virDomainDriverAddIOThreadCheck(virDomainDef *def, + unsigned int iothread_id); + +int virDomainDriverDelIOThreadCheck(virDomainDef *def, + unsigned int iothread_id); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 51a400ba59..d74f43da73 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1533,6 +1533,8 @@ virDomainCgroupSetupMemtune; =20 =20 # hypervisor/domain_driver.h +virDomainDriverAddIOThreadCheck; +virDomainDriverDelIOThreadCheck; virDomainDriverGenerateMachineName; virDomainDriverGenerateRootHash; virDomainDriverMergeBlkioDevice; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a7d76dd00f..908ad61785 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5477,58 +5477,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 @@ -5662,7 +5610,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, =20 switch (action) { case VIR_DOMAIN_IOTHREAD_ACTION_ADD: - if (qemuDomainAddIOThreadCheck(def, iothread.iothread_id) < 0) + if (virDomainDriverAddIOThreadCheck(def, iothread.iothread_id)= < 0) goto endjob; =20 if (qemuDomainHotplugAddIOThread(driver, vm, iothread.iothread= _id) < 0) @@ -5671,7 +5619,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, break; =20 case VIR_DOMAIN_IOTHREAD_ACTION_DEL: - if (qemuDomainDelIOThreadCheck(def, iothread.iothread_id) < 0) + if (virDomainDriverDelIOThreadCheck(def, iothread.iothread_id)= < 0) goto endjob; =20 if (qemuDomainHotplugDelIOThread(driver, vm, iothread.iothread= _id) < 0) @@ -5701,7 +5649,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, if (persistentDef) { switch (action) { case VIR_DOMAIN_IOTHREAD_ACTION_ADD: - if (qemuDomainAddIOThreadCheck(persistentDef, iothread.iothrea= d_id) < 0) + if (virDomainDriverAddIOThreadCheck(persistentDef, iothread.io= thread_id) < 0) goto endjob; =20 if (!virDomainIOThreadIDAdd(persistentDef, iothread.iothread_i= d)) @@ -5710,7 +5658,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, break; =20 case VIR_DOMAIN_IOTHREAD_ACTION_DEL: - if (qemuDomainDelIOThreadCheck(persistentDef, iothread.iothrea= d_id) < 0) + if (virDomainDriverDelIOThreadCheck(persistentDef, iothread.io= thread_id) < 0) goto endjob; =20 virDomainIOThreadIDDel(persistentDef, iothread.iothread_id); --=20 2.32.0 From nobody Sun Apr 28 09:07:02 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 1628765713219241.83934939236724; Thu, 12 Aug 2021 03:55:13 -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-171-sk6FmVpmPJm-a3XqkPg_rw-1; Thu, 12 Aug 2021 06:55:10 -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 C92D31082922; Thu, 12 Aug 2021 10:55:04 +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 7438A60C05; Thu, 12 Aug 2021 10:55:04 +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 04D10181A2A5; Thu, 12 Aug 2021 10:55:04 +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 17CAoM8G015135 for ; Thu, 12 Aug 2021 06:50:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 13118202879A; Thu, 12 Aug 2021 10:50:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E7B6202879D for ; Thu, 12 Aug 2021 10:50:19 +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 5E050101A54C for ; Thu, 12 Aug 2021 10:50:19 +0000 (UTC) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-ayXnUMEjPMiCfh22oN1TSQ-1; Thu, 12 Aug 2021 06:50:17 -0400 Received: by mail-pj1-f52.google.com with SMTP id j1so8709375pjv.3 for ; Thu, 12 Aug 2021 03:50:17 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id u17sm2907054pfh.184.2021.08.12.03.50.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:15 -0700 (PDT) X-MC-Unique: sk6FmVpmPJm-a3XqkPg_rw-1 X-MC-Unique: ayXnUMEjPMiCfh22oN1TSQ-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=xfG5o7GFQXtlbEokOU5eqUe0nGJqWH7JkMjid+R1WfY=; b=eVsCdR6iqOuFxWqa3UDAud/jHdUQ9p1Ft6NV0OFBwnEjxj5f95Zt5rA4B/KB5xlZ9c vj/HdU8RnCHHxI8Gntl0KE0ySS6Z4BGvslitq0LR4Tu+umllOrzeV6tkxf/OReuXUgAe pE4mf7x/IW9sB0YGCb969SQiJO0DLqPgkf+X1+wLdSGZLTUrTTKQbD7fdeF2hJ0a732L JdXRQ41QYHnehJfPUJ4CtWkz5fOJ9QSilJPBSJy84uI335PBvqDZwQrR0i+IHP/3esd0 FqdM1pUxJsu9XA/Nk13XnD+cBdjtEnfzLnruUqjm/IOtJsLUOWDo48YIWQ0WVYA7F/Gc nrtA== X-Gm-Message-State: AOAM531eTLm1ANieJcAvZCMbNA5Z67k4YEGNC3d2dmDJ4KLbjat18dbq AzSTXb2bmsCRLgaqzq5efafaeAb4XYUM/p/LaSA= X-Google-Smtp-Source: ABdhPJxL7FAvvwc+uRS2N3Bpd/kFhbS5xTSHOTMYtxQz5+x1FWDtajhR067zRd4ITwPgaqEu6WFSjw== X-Received: by 2002:a17:902:ab06:b029:12d:4e2e:aadf with SMTP id ik6-20020a170902ab06b029012d4e2eaadfmr3238230plb.2.1628765416068; Thu, 12 Aug 2021 03:50:16 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 02/11] test_driver: Introduce testIOThreadInfo and generate IOThread infos Date: Thu, 12 Aug 2021 18:49:53 +0800 Message-Id: <20210812105002.197134-3-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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.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: 1628765713780100001 Content-Type: text/plain; charset="utf-8" Introduce testIOThreadInfo to store IOThread infos: iothread_id, poll_max_ns, poll_grow and poll_shrink for future usage. Add an example of IOThread configuration to testdomfc4.xml, we also want to generate default testIOThreadInfo for the IOThread configured in the xml, so introduce testDomainGenerateIOThreadInfos, the values are taken from QEMU. Signed-off-by: Luke Yue --- examples/xml/test/testdomfc4.xml | 5 +++++ src/test/test_driver.c | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/examples/xml/test/testdomfc4.xml b/examples/xml/test/testdomfc= 4.xml index 26b7f25a06..cb4dd0cf70 100644 --- a/examples/xml/test/testdomfc4.xml +++ b/examples/xml/test/testdomfc4.xml @@ -11,6 +11,11 @@ 261072 131072 1 + 2 + + + + diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7c3bb70be3..5c875ae7ee 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -182,6 +182,14 @@ struct _testDomainNamespaceDef { xmlNodePtr *snap_nodes; }; =20 +typedef struct _testIOThreadInfo testIOThreadInfo; +struct _testIOThreadInfo { + unsigned int iothread_id; + unsigned long long poll_max_ns; + unsigned int poll_grow; + unsigned int poll_shrink; +}; + static void testDomainDefNamespaceFree(void *data) { @@ -380,6 +388,9 @@ struct _testDomainObjPrivate { /* used by get/set time APIs */ long long seconds; unsigned int nseconds; + + /* used by IOThread APIs */ + GArray *iothreads; }; =20 =20 @@ -396,6 +407,8 @@ testDomainObjPrivateAlloc(void *opaque) priv->seconds =3D 627319920; priv->nseconds =3D 0; =20 + priv->iothreads =3D g_array_new(FALSE, FALSE, sizeof(testIOThreadInfo)= ); + return priv; } =20 @@ -426,6 +439,8 @@ static void testDomainObjPrivateFree(void *data) { testDomainObjPrivate *priv =3D data; + + g_array_free(priv->iothreads, TRUE); g_free(priv); } =20 @@ -695,6 +710,26 @@ testDomainGenerateIfnames(virDomainDef *domdef) return 0; } =20 +static void +testDomainGenerateIOThreadInfos(virDomainObj *obj) +{ + size_t i; + testDomainObjPrivate *priv; + + if (!obj->def->iothreadids || !obj->def->niothreadids) + return; + + priv =3D obj->privateData; + + for (i =3D 0; i < obj->def->niothreadids; i++) { + testIOThreadInfo iothread; + iothread.iothread_id =3D obj->def->iothreadids[i]->iothread_id; + iothread.poll_max_ns =3D 32768; + iothread.poll_grow =3D 0; + iothread.poll_shrink =3D 0; + g_array_append_val(priv->iothreads, iothread); + } +} =20 static void testDomainShutdownState(virDomainPtr domain, @@ -1045,6 +1080,8 @@ testParseDomains(testDriver *privconn, =20 testDomainObjCheckTaint(obj); =20 + testDomainGenerateIOThreadInfos(obj); + virDomainObjEndAPI(&obj); } =20 --=20 2.32.0 From nobody Sun Apr 28 09:07:02 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 1628765722062204.57598705951204; Thu, 12 Aug 2021 03:55:22 -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-231-h0ejGOh9PsqdKNFgCkuLNQ-1; Thu, 12 Aug 2021 06:55:19 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 675559250B; Thu, 12 Aug 2021 10:55:14 +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 3ED7766FFF; Thu, 12 Aug 2021 10:55:14 +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 093A84A700; Thu, 12 Aug 2021 10:55:14 +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 17CAoPM0015159 for ; Thu, 12 Aug 2021 06:50:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA0F4117C2D4; Thu, 12 Aug 2021 10:50:25 +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 A5D37117C2D2 for ; Thu, 12 Aug 2021 10:50:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 203E889B846 for ; Thu, 12 Aug 2021 10:50:22 +0000 (UTC) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-18WmKQcmMzuEyH60sCLghw-1; Thu, 12 Aug 2021 06:50:20 -0400 Received: by mail-pj1-f43.google.com with SMTP id w14so8687145pjh.5 for ; Thu, 12 Aug 2021 03:50:20 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id c136sm2978136pfc.53.2021.08.12.03.50.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:18 -0700 (PDT) X-MC-Unique: h0ejGOh9PsqdKNFgCkuLNQ-1 X-MC-Unique: 18WmKQcmMzuEyH60sCLghw-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=6isRr2nCrQ1ZlRcRQAux9oQD0a3UctYLnllyM8+GtRo=; b=p4pkz2wBsF5qlOgjzuoqZK1ZY1UNNg7TdXEDLmcQBVkgSfDN7VFVqvgFQhXSIL1StC Z0whNVhvZObrsC1xVKzk90A0SUI7wAwnybQxH6BEE1sAD+oiQdcCyLMrgeTKQRlXzIEj kZzCnbYZA5YUpdTvaBA9zjd6ePvBhyV4pULoXlxF7mjpD4JaK1l2QUehhcGWisiTQF/6 +8vMs5YYmrDni3UGtSZXaXRJssfw5gfeq97HVo+lgKCJwTi5JggmnggUXriBBYW84Sl+ kd9ITbz5aM7WP/XjF6Y+azjYkz0e238vIjWMwnfztgW1hmyrpSUIIS9Zb1zqaUR0gp+v CxjQ== X-Gm-Message-State: AOAM530jlsol5sx4+zJutIWHxjsrPCkfbz7Z6KoZPEDXHRZB4z6HUuIy 9VETYxRDutyvCBmde4VbyC53trJ6ejQ/mLUqAnc= X-Google-Smtp-Source: ABdhPJyGNDDQ1KmfDGOu1jlAobznU/8EyKOM2jBEq9CvT3rHwMTzwaZCn2sGxh7s/cTqwYhvEGGPVA== X-Received: by 2002:a17:902:c641:b029:12c:ef04:fa86 with SMTP id s1-20020a170902c641b029012cef04fa86mr3220669pls.40.1628765418826; Thu, 12 Aug 2021 03:50:18 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 03/11] test_driver: Implement virDomainAddIOThread Date: Thu, 12 Aug 2021 18:49:54 +0800 Message-Id: <20210812105002.197134-4-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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.15 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: 1628765722427100001 Content-Type: text/plain; charset="utf-8" Introduce testDomainChgIOThread at the same time Signed-off-by: Luke Yue --- src/test/meson.build | 1 + src/test/test_driver.c | 77 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/src/test/meson.build b/src/test/meson.build index f54585adfd..c0174ad856 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -17,6 +17,7 @@ if conf.has('WITH_TEST') ], include_directories: [ conf_inc_dir, + hypervisor_inc_dir, ], ) =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5c875ae7ee..f3e3745442 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -40,6 +40,7 @@ #include "interface_conf.h" #include "checkpoint_conf.h" #include "domain_conf.h" +#include "domain_driver.h" #include "domain_event.h" #include "network_event.h" #include "snapshot_conf.h" @@ -9489,6 +9490,81 @@ testDomainGetMessages(virDomainPtr dom, return rv; } =20 +typedef enum { + VIR_DOMAIN_IOTHREAD_ACTION_ADD, +} virDomainIOThreadAction; + +static int +testDomainChgIOThread(virDomainObj *vm, + unsigned int iothread_id, + virDomainIOThreadAction action, + unsigned int flags) +{ + virDomainDef *def; + int ret =3D -1; + + if (!(def =3D virDomainObjGetOneDef(vm, flags))) + return ret; + + if (def) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: + if (virDomainDriverAddIOThreadCheck(def, iothread_id) < 0) + return ret; + + if (!virDomainIOThreadIDAdd(def, iothread_id)) + return ret; + + break; + } + } + + ret =3D 0; + + return ret; +} + +static int +testDomainAddIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + testDomainObjPrivate *priv; + testIOThreadInfo iothread; + 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; + + if (testDomainChgIOThread(vm, iothread_id, + VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags) < 0) + goto cleanup; + + priv =3D vm->privateData; + + iothread.iothread_id =3D iothread_id; + iothread.poll_max_ns =3D 32768; + iothread.poll_grow =3D 0; + iothread.poll_shrink =3D 0; + + g_array_append_val(priv->iothreads, iothread); + + ret =3D 0; + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} /* * Test driver */ @@ -9555,6 +9631,7 @@ 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.7.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 Sun Apr 28 09:07:02 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 1628765543125395.6270291745791; Thu, 12 Aug 2021 03:52:23 -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-195-BG63Ku3aM7W9k3DBhyVvdw-1; Thu, 12 Aug 2021 06:52:20 -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 4E2321082924; Thu, 12 Aug 2021 10:52:15 +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 017F660C05; Thu, 12 Aug 2021 10:52:15 +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 83D1A181A0F2; Thu, 12 Aug 2021 10:52:14 +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 17CAoP98015148 for ; Thu, 12 Aug 2021 06:50:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 489F8202879D; Thu, 12 Aug 2021 10:50:25 +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 440D7202879A for ; Thu, 12 Aug 2021 10:50:25 +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 2D31E8CA940 for ; Thu, 12 Aug 2021 10:50:25 +0000 (UTC) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-159-1nCoWUABOWW5y_NGaTmEEw-1; Thu, 12 Aug 2021 06:50:23 -0400 Received: by mail-pj1-f49.google.com with SMTP id gz13-20020a17090b0ecdb0290178c0e0ce8bso8621423pjb.1 for ; Thu, 12 Aug 2021 03:50:22 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id x16sm2973421pfr.89.2021.08.12.03.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:21 -0700 (PDT) X-MC-Unique: BG63Ku3aM7W9k3DBhyVvdw-1 X-MC-Unique: 1nCoWUABOWW5y_NGaTmEEw-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=vJbw1OWpnMOo7b7cATdzG/N5d5LoMY0NqgqapQk0I3I=; b=L5bFB/K6c0OorpuNoayjoP9T4ySoYm8bMEEaYu4FwYwHkM+ksCG3VxQtfiNYwx+xvN tA/niWIz1ZXU/VQ6o7otzU6IeKXFKFTSEulHBN0ezNOhas8rd82c4ExYVQYPiMbqk4Xd BpvGWrEYrQGRED6IqRxQOlZtprjTUGjp4KHAy64OeJvkQS0bphaS3lYtLWXYqcJCTeAL rKg4jRZwE83n2F0CJuAC1TYNid4X4GHXZIprwatonl6/S51scTZ/PKza4Ljjz001ro8X fq1hBf62y2IsmxLaXHweF45Ho0WFmCnJfWiDjGTVactsdlvMdaAxJ0AVufvqW9xMNjpo 2ivg== X-Gm-Message-State: AOAM530+vyTAxPInTtd/z7Om+6AteoDv+WcMLl9uRl/x+k4JnZs9mLTJ +t4Mc7b80HuXgdVX4HhhprOpzrgQVzFY+bsAEu4= X-Google-Smtp-Source: ABdhPJzSLS0KSjDV4Sg/ohYZ4sa7IOqq2P3zc2NIZyzAu8/l2PzGyvg+Y7Sok9zCXBp3yxN9YOUOuQ== X-Received: by 2002:a17:902:70c2:b029:12d:4d0b:6f22 with SMTP id l2-20020a17090270c2b029012d4d0b6f22mr3195332plt.32.1628765421757; Thu, 12 Aug 2021 03:50:21 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 04/11] test_driver: Implement virDomainDelIOThread Date: Thu, 12 Aug 2021 18:49:55 +0800 Message-Id: <20210812105002.197134-5-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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.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: 1628765543500100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index f3e3745442..2813320939 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9492,6 +9492,7 @@ testDomainGetMessages(virDomainPtr dom, =20 typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, } virDomainIOThreadAction; =20 static int @@ -9516,6 +9517,14 @@ testDomainChgIOThread(virDomainObj *vm, return ret; =20 break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: + if (virDomainDriverDelIOThreadCheck(def, iothread_id) < 0) + return ret; + + virDomainIOThreadIDDel(def, iothread_id); + + break; } } =20 @@ -9565,6 +9574,51 @@ testDomainAddIOThread(virDomainPtr dom, virDomainObjEndAPI(&vm); return ret; } + +static int +testDomainDelIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + testDomainObjPrivate *priv; + size_t i; + 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; + + if (testDomainChgIOThread(vm, iothread_id, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags) < 0) + goto cleanup; + + priv =3D vm->privateData; + + for (i =3D 0; i < priv->iothreads->len; i++) { + testIOThreadInfo iothread =3D g_array_index(priv->iothreads, + testIOThreadInfo, i); + if (iothread.iothread_id =3D=3D iothread_id) { + g_array_remove_index(priv->iothreads, i); + break; + } + } + + ret =3D 0; + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + /* * Test driver */ @@ -9632,6 +9686,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetVcpuPinInfo =3D testDomainGetVcpuPinInfo, /* 1.2.18 */ .domainGetMaxVcpus =3D testDomainGetMaxVcpus, /* 0.7.3 */ .domainAddIOThread =3D testDomainAddIOThread, /* 7.7.0 */ + .domainDelIOThread =3D testDomainDelIOThread, /* 7.7.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 Sun Apr 28 09:07:02 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 1628765550448292.57798342585284; Thu, 12 Aug 2021 03:52:30 -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-304-eVfjwnY4NDK-qeevEzqpeA-1; Thu, 12 Aug 2021 06:52:28 -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 12F3E801B3D; Thu, 12 Aug 2021 10:52:23 +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 E2D8D60BF1; Thu, 12 Aug 2021 10:52:22 +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 B0D7E181A100; Thu, 12 Aug 2021 10:52:22 +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 17CAoS0b015178 for ; Thu, 12 Aug 2021 06:50:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D4AE1108E5; Thu, 12 Aug 2021 10:50:28 +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 490DD11514C for ; Thu, 12 Aug 2021 10:50:28 +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 315FB89B852 for ; Thu, 12 Aug 2021 10:50:28 +0000 (UTC) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-565-bjoJJNgzMy6IBCxlXFSOOQ-1; Thu, 12 Aug 2021 06:50:26 -0400 Received: by mail-pl1-f177.google.com with SMTP id l11so6760782plk.6 for ; Thu, 12 Aug 2021 03:50:25 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id c15sm2631285pjr.22.2021.08.12.03.50.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:24 -0700 (PDT) X-MC-Unique: eVfjwnY4NDK-qeevEzqpeA-1 X-MC-Unique: bjoJJNgzMy6IBCxlXFSOOQ-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=DyU2khZ4tJo5Wpca+zEErod84xIRydSJm4exIwOKhUI=; b=Pi5cesQaJhL7f2JNFe8vFumhioVqIUOtg7uN3hCnzMv/GdrjRzUwffWR9guaZs7BgK eumn0hDjWXOIxbAa/wlQO2RmHOnJHL+6S8FxaBJlxqxD+xV1A8L/01JgvIu97rz19vfY Kp/Eo/D4PccfefKYCJUqRpYVFMlmYg5xpbbEmi5qvvJxbbEXqoM1wk61Vo5sN7qw5DVM A9Qum+R+K/xyyBB0amtekza5bcgsMokPvnwZ1o0zvckD7gD/BaL+1yDx2Ca2xXmJxaw9 88Unxb6cv64g2spPzXb+3PZk6Xal8hsfM0n6xgOIr1zOYFWN+jyQgoUODb4meI233vtS Aoqw== X-Gm-Message-State: AOAM530Yh/ei1dGYrrJJfsMAZNvYbBX9JaW+rNZpVxeGkbL4iQzFbwUL im4hgegVMole87YbZRCBUE/42z8qKS4UUuO4Ibs= X-Google-Smtp-Source: ABdhPJzFTfVDGRk8hcSZ2XD9ql2Wp727bSqUpNE/9sAAHpx5L5W4WiKKXRORjEWK+/tn/CVvKUYZfw== X-Received: by 2002:a63:1359:: with SMTP id 25mr3341187pgt.79.1628765424616; Thu, 12 Aug 2021 03:50:24 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 05/11] domain_driver.c: Introduce and use virDomainDriverGetIOThreadsConfig() Date: Thu, 12 Aug 2021 18:49:56 +0800 Message-Id: <20210812105002.197134-6-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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: 1628765552407100001 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 | 68 ++++++++++++++++++++++++++++++++++ src/hypervisor/domain_driver.h | 4 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 53 +------------------------- 4 files changed, 74 insertions(+), 52 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 3eb2401053..31737b0f4a 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -576,3 +576,71 @@ virDomainDriverDelIOThreadCheck(virDomainDef *def, =20 return 0; } + +/** + * virDomainDriverGetIOThreadsConfig: + * @targetDef: domain definition + * @info: information about the IOThread in a domain + * @bitmap_size: generate bitmap with bitmap_size, 0 for getting the size + * from host + * + * Returns the number of IOThreads in the given domain or -1 in case of er= ror + */ +int +virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info, + unsigned int bitmap_size) +{ + 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_size) { + if (!(bitmap =3D virBitmapNew(bitmap_size))) + goto cleanup; + virBitmapSetAll(bitmap); + } 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..7b0fbae2fd 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -66,3 +66,7 @@ int virDomainDriverAddIOThreadCheck(virDomainDef *def, =20 int virDomainDriverDelIOThreadCheck(virDomainDef *def, unsigned int iothread_id); + +int virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info, + unsigned int bitmap_size); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d74f43da73..ea76b6bdc9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1537,6 +1537,7 @@ virDomainDriverAddIOThreadCheck; virDomainDriverDelIOThreadCheck; virDomainDriverGenerateMachineName; virDomainDriverGenerateRootHash; +virDomainDriverGetIOThreadsConfig; virDomainDriverMergeBlkioDevice; virDomainDriverNodeDeviceDetachFlags; virDomainDriverNodeDeviceGetPCIInfo; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 908ad61785..43c9e5cc56 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, 0); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.32.0 From nobody Sun Apr 28 09:07:02 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 162876555442395.34643505211818; Thu, 12 Aug 2021 03:52:34 -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-527-NSm5KWSKNJaiXZY7aAPZMQ-1; Thu, 12 Aug 2021 06:52:31 -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 0B5C11082922; Thu, 12 Aug 2021 10:52:26 +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 E297E779D0; Thu, 12 Aug 2021 10:52:25 +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 ABB49181A1CE; Thu, 12 Aug 2021 10:52:25 +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 17CAoUVx015188 for ; Thu, 12 Aug 2021 06:50:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id CB055208DDBF; Thu, 12 Aug 2021 10:50:30 +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 C5545208DDBA for ; Thu, 12 Aug 2021 10:50:30 +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 ADA8318A01A0 for ; Thu, 12 Aug 2021 10:50:30 +0000 (UTC) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-555-uhOazwv-MzqLkUF5NPYmbw-1; Thu, 12 Aug 2021 06:50:28 -0400 Received: by mail-pj1-f47.google.com with SMTP id w13-20020a17090aea0db029017897a5f7bcso10044059pjy.5 for ; Thu, 12 Aug 2021 03:50:28 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id y4sm10010238pjg.9.2021.08.12.03.50.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:27 -0700 (PDT) X-MC-Unique: NSm5KWSKNJaiXZY7aAPZMQ-1 X-MC-Unique: uhOazwv-MzqLkUF5NPYmbw-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=G8DKpb2KLIYlxjaZLEm1kQwRP1WSY3qjJABO/IldzfM=; b=iV0WFDvg1CtO8yBuUYmLqitOHaGDY98JvLtGdLuBhVgn+LFI7xTNIl6kdYyAgBH06w 8c6eNpMdMaBoAWROuPVl+BAtvYSl01I/GE5Kgkr094UgiWLyyZqHP6jUV70OVUBzYXQw fTK55UVCpWXoUQymSj73Da8JwPOlxZoz4qx/68yQH4nPGMlppTfHv2xCvT98zH4W2hEo UXSg4BU3ghcLFAwIJcujufaajFCQPT7njaVpoKuxBSjfR4LHTRRIXzzSlsreYE7GCmwc +N9eXZoylA1BGWJQfirC16crRaLPltWNGW17m+KdVVM3taTuHHEZ3BBGqTn5nKNtKV/j rZFA== X-Gm-Message-State: AOAM532XtYd1CwKEy0Leh7lVfgiW44/6q7lMvTyfNdM0i28j+EgOTUZH s32Nu/hKwpyICKRr17X2hlsa9E6jcZVOXKCMP1I= X-Google-Smtp-Source: ABdhPJxAdJHtiDwbiE/4Ktuz1gfjtieST0vXX5+0C79naWJamqRpjXX0PDDmT2rgQamsWHtsk8OyGA== X-Received: by 2002:a63:120e:: with SMTP id h14mr3233864pgl.215.1628765427392; Thu, 12 Aug 2021 03:50:27 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 06/11] test_driver: Implement virDomainGetIOThreadInfo Date: Thu, 12 Aug 2021 18:49:57 +0800 Message-Id: <20210812105002.197134-7-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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: 1628765556601100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2813320939..67337879ef 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9490,6 +9490,34 @@ testDomainGetMessages(virDomainPtr dom, return rv; } =20 +static int +testDomainGetIOThreadInfo(virDomainPtr dom, + virDomainIOThreadInfoPtr **info, + unsigned int flags) +{ + virDomainObj *vm; + virDomainDef *targetDef =3D NULL; + unsigned int bitmap_size =3D 0; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (!(targetDef =3D virDomainObjGetOneDef(vm, flags))) + goto cleanup; + + bitmap_size =3D virDomainDefGetVcpus(targetDef); + + ret =3D virDomainDriverGetIOThreadsConfig(targetDef, info, bitmap_size= ); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, VIR_DOMAIN_IOTHREAD_ACTION_DEL, @@ -9685,6 +9713,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.7.0 */ .domainAddIOThread =3D testDomainAddIOThread, /* 7.7.0 */ .domainDelIOThread =3D testDomainDelIOThread, /* 7.7.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ --=20 2.32.0 From nobody Sun Apr 28 09:07:02 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 1628765556428351.608524076393; Thu, 12 Aug 2021 03:52:36 -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-517-Ch0fmo3GNwu-Jjn9v38pzw-1; Thu, 12 Aug 2021 06:52:34 -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 BB9A31008065; Thu, 12 Aug 2021 10:52:28 +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 9B48A5D9DE; Thu, 12 Aug 2021 10:52:28 +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 688904A7C9; Thu, 12 Aug 2021 10:52:28 +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 17CAoYh2015198 for ; Thu, 12 Aug 2021 06:50:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 00A41117C2D4; Thu, 12 Aug 2021 10:50:34 +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 F06AE117C2D2 for ; Thu, 12 Aug 2021 10:50:33 +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 D88D496B05C for ; Thu, 12 Aug 2021 10:50:33 +0000 (UTC) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-457-paid294fNkqdAVnkKQn_cg-1; Thu, 12 Aug 2021 06:50:31 -0400 Received: by mail-pj1-f48.google.com with SMTP id mq2-20020a17090b3802b0290178911d298bso10091948pjb.1 for ; Thu, 12 Aug 2021 03:50:31 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id h16sm2834542pfn.215.2021.08.12.03.50.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:29 -0700 (PDT) X-MC-Unique: Ch0fmo3GNwu-Jjn9v38pzw-1 X-MC-Unique: paid294fNkqdAVnkKQn_cg-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=1EYGKGQKFt/JWX050GVWcZ+KKCG7W13BD4sTikONV28=; b=L/VfffcLH8+fUHMPIvFJQEVJQqq0L4O84gsANBd94gB20nDeTp9aGWAt9XqsGyw7nI 1aPm4Jmghfj2ZB9dXRIIckMjK50RqyMKXeH9XX+sESPM3QD5WczrMQncPidW6ZVxfPL/ XALYjSPzeYBE6iA021mPwg45aigcTcOICvuXLO7USMKWWlLOInleuBfwAgwIjMQOu0q8 UPU9wD6nOsfbMEyHS1YR0XpwEEvx0rgwIsjj3WKq3b3WL/OdTNh1lbtjhKosHTDtZe/O ahIXH19ZubmE9kmImur63KB49gMegYe/1cBLzTojJpY0f983uuPoHJP1vCXfDVzrW1zX q3Jg== X-Gm-Message-State: AOAM530ndRA3tGDBWpTKBPzRNMu/kY/VxqmWSGHY4ywuzJ6luI3bew9n ysgzCC0h5bOcFx2kUhV0rzJallhtc4rWXzS+r6g= X-Google-Smtp-Source: ABdhPJwdmfDbHtrbsGrwf9rJM+oxgu5LQ6vaBbcLy8EPoubNvIvDLAE1eElJVBjGHwSEKNplKiiEqA== X-Received: by 2002:a17:90b:33ce:: with SMTP id lk14mr15554767pjb.118.1628765430334; Thu, 12 Aug 2021 03:50:30 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 07/11] test_driver: Implement virDomainPinIOThread Date: Thu, 12 Aug 2021 18:49:58 +0800 Message-Id: <20210812105002.197134-8-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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: 1628765556848100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 67337879ef..385c8b3ad3 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9647,6 +9647,55 @@ testDomainDelIOThread(virDomainPtr dom, return ret; } =20 +static int +testDomainPinIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned char *cpumap, + int maplen, + unsigned int flags) +{ + int ret =3D -1; + virDomainObj *vm; + virDomainDef *def; + virDomainIOThreadIDDef *iothrid; + virBitmap *cpumask =3D NULL; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (!(def =3D virDomainObjGetOneDef(vm, flags))) + goto cleanup; + + if (!(cpumask =3D virBitmapNewData(cpumap, maplen))) + goto cleanup; + + if (virBitmapIsAllClear(cpumask)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Empty iothread cpumap list for pinning")); + goto cleanup; + } + + if (!(iothrid =3D virDomainIOThreadIDFind(def, iothread_id))) { + virReportError(VIR_ERR_INVALID_ARG, + _("iothreadid %d not found"), iothread_id); + goto cleanup; + } + + virBitmapFree(iothrid->cpumask); + iothrid->cpumask =3D g_steal_pointer(&cpumask); + iothrid->autofill =3D false; + + ret =3D 0; + + cleanup: + virBitmapFree(cpumask); + virDomainObjEndAPI(&vm); + return ret; +} + /* * Test driver */ @@ -9716,6 +9765,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetIOThreadInfo =3D testDomainGetIOThreadInfo, /* 7.7.0 */ .domainAddIOThread =3D testDomainAddIOThread, /* 7.7.0 */ .domainDelIOThread =3D testDomainDelIOThread, /* 7.7.0 */ + .domainPinIOThread =3D testDomainPinIOThread, /* 7.7.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 Sun Apr 28 09:07:02 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 1628765829781228.12700782867535; Thu, 12 Aug 2021 03:57:09 -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-507-jolFFhsgONGvno7FfddnGQ-1; Thu, 12 Aug 2021 06:57:07 -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 3F5CE1853025; Thu, 12 Aug 2021 10:57:02 +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 2411F620DE; Thu, 12 Aug 2021 10:57:02 +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 60AA6181A2A6; Thu, 12 Aug 2021 10:57:01 +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 17CAoa5K015209 for ; Thu, 12 Aug 2021 06:50:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5242D117C2D4; Thu, 12 Aug 2021 10:50:36 +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 4D33B117C2D2 for ; Thu, 12 Aug 2021 10:50:36 +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 35928800182 for ; Thu, 12 Aug 2021 10:50:36 +0000 (UTC) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-y9XXlhe-NZi_73s4TszVjg-1; Thu, 12 Aug 2021 06:50:34 -0400 Received: by mail-pl1-f179.google.com with SMTP id k2so6712115plk.13 for ; Thu, 12 Aug 2021 03:50:34 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id i5sm9825155pjk.47.2021.08.12.03.50.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:32 -0700 (PDT) X-MC-Unique: jolFFhsgONGvno7FfddnGQ-1 X-MC-Unique: y9XXlhe-NZi_73s4TszVjg-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=ltZXuSB9vRxIUqKbquzDwUL5o67rx0noi1e6g2b0dSA=; b=XdEfYimObRFInHUp8r6pomLlSrzBW7zRILIUzLI0jMZF0qyK5nH9zxQjVPPxsJJqnS C8mDklWqoOcekidK2YDM3xqabrkWcxus214WdT5FI548KmBwYTnQdpcX4Zy6drM1A1YW pC3U/PbuFzdA2bxThvAvJJ5VIfjtpTcBkogxd6+vTvMiZGMWeLyuwHXbgzQ1xMTjla9K wAOkHIg33VJoPPkCsIfe/3VBbJVjMNEv9DB2rAUA7M3dEUkOEpUrzQ96GU1PMGONX6iR ByZpm9ntjrUMKpSiuCi88YrDTV/kNQlkjPOMnqhN7NdCMQWdaXhkYw+YkGeEu2joxh2A ksnQ== X-Gm-Message-State: AOAM533xSk1Gg+pSXxY695d3w8WG0hAJWLa4s1HJp9kgpvR/TqnjyyLI hxguEzQAEZRbFKYF5+Ub7TpFTpx4MK1XHdoTYrU= X-Google-Smtp-Source: ABdhPJyGmSDVk0CxWMuQ5apgcN7Xh9b951n+D8YX9HpXZUfuc/kFCF7Sa6ZLja/HXNZNEwchL4rs1A== X-Received: by 2002:a17:90b:3805:: with SMTP id mq5mr3367652pjb.207.1628765433028; Thu, 12 Aug 2021 03:50:33 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 08/11] test_driver: Implement testDomainSetIOThreadParams Date: Thu, 12 Aug 2021 18:49:59 +0800 Message-Id: <20210812105002.197134-9-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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.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: 1628765831803100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 385c8b3ad3..1d439a89b6 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9521,6 +9521,7 @@ testDomainGetIOThreadInfo(virDomainPtr dom, typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, VIR_DOMAIN_IOTHREAD_ACTION_DEL, + VIR_DOMAIN_IOTHREAD_ACTION_MOD, } virDomainIOThreadAction; =20 static int @@ -9552,6 +9553,16 @@ testDomainChgIOThread(virDomainObj *vm, =20 virDomainIOThreadIDDel(def, iothread_id); =20 + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_MOD: + if (!(virDomainIOThreadIDFind(def, iothread_id))) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot find IOThread '%u' in iothreadids= "), + iothread_id); + return ret; + } + break; } } @@ -9696,6 +9707,84 @@ testDomainPinIOThread(virDomainPtr dom, return ret; } =20 +static int +testDomainIOThreadParseParams(virTypedParameterPtr params, + int nparams, + testIOThreadInfo *iothread) +{ + if (virTypedParamsValidate(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_IOTHREAD_POLL_GROW, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_IOTHREAD_POLL_SHRINK, + VIR_TYPED_PARAM_UINT, + NULL) < 0) + return -1; + + if (virTypedParamsGetULLong(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, + &iothread->poll_max_ns) < 0) + return -1; + + if (virTypedParamsGetUInt(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_GROW, + &iothread->poll_grow) < 0) + return -1; + + if (virTypedParamsGetUInt(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_SHRINK, + &iothread->poll_shrink) < 0) + return -1; + + return 0; +} + +static int +testDomainSetIOThreadParams(virDomainPtr dom, + unsigned int iothread_id, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + testDomainObjPrivate *priv; + size_t i; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE, -1); + + if (iothread_id =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + goto cleanup; + } + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (testDomainChgIOThread(vm, iothread_id, + VIR_DOMAIN_IOTHREAD_ACTION_MOD, flags) < 0) + goto cleanup; + + priv =3D vm->privateData; + + for (i =3D 0; i < priv->iothreads->len; i++) { + testIOThreadInfo *iothread =3D &g_array_index(priv->iothreads, + testIOThreadInfo, i); + if (iothread->iothread_id =3D=3D iothread_id) { + if (testDomainIOThreadParseParams(params, nparams, iothread) <= 0) + goto cleanup; + ret =3D 0; + break; + } + } + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + /* * Test driver */ @@ -9766,6 +9855,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainAddIOThread =3D testDomainAddIOThread, /* 7.7.0 */ .domainDelIOThread =3D testDomainDelIOThread, /* 7.7.0 */ .domainPinIOThread =3D testDomainPinIOThread, /* 7.7.0 */ + .domainSetIOThreadParams =3D testDomainSetIOThreadParams, /* 7.7.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 Sun Apr 28 09:07:02 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 1628765559781498.41304332497964; Thu, 12 Aug 2021 03:52:39 -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-585-NmLY7pPbNdSU381hl_kLkQ-1; Thu, 12 Aug 2021 06:52:37 -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 E6A9692500; Thu, 12 Aug 2021 10:52:31 +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 C3EEA12C82; Thu, 12 Aug 2021 10:52:31 +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 8F5DD4A7CA; Thu, 12 Aug 2021 10:52:31 +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 17CAofrW015224 for ; Thu, 12 Aug 2021 06:50:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 83A9C202879E; Thu, 12 Aug 2021 10:50:41 +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 7E33C202879D for ; Thu, 12 Aug 2021 10:50:38 +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 D5F31800182 for ; Thu, 12 Aug 2021 10:50:38 +0000 (UTC) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-QkcPQ8fmNHemcbXG2hlv6A-1; Thu, 12 Aug 2021 06:50:37 -0400 Received: by mail-pj1-f45.google.com with SMTP id g12-20020a17090a7d0cb0290178f80de3d8so9948580pjl.2 for ; Thu, 12 Aug 2021 03:50:36 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id s20sm1738833pfw.143.2021.08.12.03.50.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:35 -0700 (PDT) X-MC-Unique: NmLY7pPbNdSU381hl_kLkQ-1 X-MC-Unique: QkcPQ8fmNHemcbXG2hlv6A-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=uaCGAkk5hk3OxRNjHwBB7owMojQSbZSMh3CyPtDPsyQ=; b=CopXVtFbS+CX4D/l6yeKWyPmt2gMcJQVX1iET6ObAB6vjGSnAicZ/0jV4sH9c9KzWK 3+nWAXdniCuCBjYHA4C2BLa0nz4RKLSKIQHa7b7ASwdnyMhDOOoNNUDXqhEjIKFw21FZ lTrSH58DPPFGJTbl8+j0QGXq4Pb8IrHCaWYhsc8QU9d+esV8Ra2CjiURrol/pDIMEZT7 1/1XpskScboZVpfFNwKZQZvXdM6JGI4MlpxJFYx1NY+jVQMbW24WaAEBl6N/1XaKKVF1 wmB8UIlGhU/E59ZvoGnKIwBWgopo+LfdSVOw6UYRSxJ/mLYG0eAA7CeZwPmK/IPXRzir dlcA== X-Gm-Message-State: AOAM532pdYFtQ49svg5dqXDK5KT0JYsMBJtcHSx6qeJcTAb6NIgaJg96 oG8W5HOUQ9Irypk6rpKB9HWLWc+EhxZcO2uTph8= X-Google-Smtp-Source: ABdhPJx1mk/7VPPNT4Jap/+zG2uAjGUsPP9Eh+Lbwzq9nQh/diCYa5GJTQH53TaXjdTFbvgMd9kCDw== X-Received: by 2002:a17:90a:2e88:: with SMTP id r8mr6415210pjd.169.1628765435764; Thu, 12 Aug 2021 03:50:35 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 09/11] test_driver: Implement virConnectGetAllDomainStats Date: Thu, 12 Aug 2021 18:50:00 +0800 Message-Id: <20210812105002.197134-10-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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.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: 1628765561082100001 Content-Type: text/plain; charset="utf-8" Implement virConnectGetAllDomainStats in a modular way just like QEMU driver, though remove some params in GetStatsWorker that we don't need in test driver currently. Only add the worker to get state so far, more worker will be added in the future. Signed-off-by: Luke Yue --- src/test/test_driver.c | 135 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 1d439a89b6..6eebd85cf3 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9785,6 +9785,140 @@ testDomainSetIOThreadParams(virDomainPtr dom, return ret; } =20 +static int +testDomainGetStatsState(virDomainObj *dom, + virTypedParamList *params) +{ + if (virTypedParamListAddInt(params, dom->state.state, "state.state") <= 0) + return -1; + + if (virTypedParamListAddInt(params, dom->state.reason, "state.reason")= < 0) + return -1; + + return 0; +} + +typedef int +(*testDomainGetStatsFunc)(virDomainObj *dom, + virTypedParamList *list); + +struct testDomainGetStatsWorker { + testDomainGetStatsFunc func; + unsigned int stats; +}; + +static struct testDomainGetStatsWorker testDomainGetStatsWorkers[] =3D { + { testDomainGetStatsState, VIR_DOMAIN_STATS_STATE }, + { NULL, 0 } +}; + +static int +testDomainGetStats(virConnectPtr conn, + virDomainObj *dom, + unsigned int stats, + virDomainStatsRecordPtr *record) +{ + g_autofree virDomainStatsRecordPtr tmp =3D NULL; + g_autoptr(virTypedParamList) params =3D NULL; + size_t i; + + params =3D g_new0(virTypedParamList, 1); + + for (i =3D 0; testDomainGetStatsWorkers[i].func; i++) { + if (stats & testDomainGetStatsWorkers[i].stats) { + if (testDomainGetStatsWorkers[i].func(dom, params) < 0) + return -1; + } + } + + tmp =3D g_new0(virDomainStatsRecord, 1); + + if (!(tmp->dom =3D virGetDomain(conn, dom->def->name, + dom->def->uuid, dom->def->id))) + return -1; + + tmp->nparams =3D virTypedParamListStealParams(params, &tmp->params); + *record =3D g_steal_pointer(&tmp); + return 0; +} + +static int +testConnectGetAllDomainStats(virConnectPtr conn, + virDomainPtr *doms, + unsigned int ndoms, + unsigned int stats, + virDomainStatsRecordPtr **retStats, + unsigned int flags) +{ + testDriver *driver =3D conn->privateData; + unsigned int lflags =3D flags & (VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTI= VE | + VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSIS= TENT | + VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE); + + unsigned int supported =3D VIR_DOMAIN_STATS_STATE; + virDomainObj **vms =3D NULL; + size_t nvms; + virDomainStatsRecordPtr *tmpstats =3D NULL; + int nstats =3D 0; + int ret =3D -1; + size_t i; + + virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE | + VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT | + VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE | + VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT | + VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING | + VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, -1); + + if (!stats) { + stats =3D supported; + } else if ((flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS) && + (stats & ~supported)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("Stats types bits 0x%x are not supported by this = daemon"), + stats & ~supported); + return -1; + } + + if (ndoms) { + if (virDomainObjListConvert(driver->domains, conn, doms, ndoms, &v= ms, + &nvms, NULL, lflags, true) < 0) + return -1; + } else { + if (virDomainObjListCollect(driver->domains, conn, &vms, &nvms, + NULL, lflags) < 0) + return -1; + } + + tmpstats =3D g_new0(virDomainStatsRecordPtr, nvms + 1); + + for (i =3D 0; i < nvms; i++) { + virDomainStatsRecordPtr tmp =3D NULL; + virDomainObj *vm =3D vms[i]; + + virObjectLock(vm); + + if ((testDomainGetStats(conn, vm, stats, &tmp)) < 0) + goto cleanup; + + virObjectUnlock(vm); + + if (!tmp) + goto cleanup; + + tmpstats[nstats++] =3D tmp; + } + + *retStats =3D g_steal_pointer(&tmpstats); + ret =3D nstats; + + cleanup: + virDomainStatsRecordListFree(tmpstats); + virObjectListFreeCount(vms, nvms); + + return ret; +} + /* * Test driver */ @@ -9799,6 +9933,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .nodeGetCPUStats =3D testNodeGetCPUStats, /* 2.3.0 */ .nodeGetFreeMemory =3D testNodeGetFreeMemory, /* 2.3.0 */ .nodeGetFreePages =3D testNodeGetFreePages, /* 2.3.0 */ + .connectGetAllDomainStats =3D testConnectGetAllDomainStats, /* 7.7.0 */ .connectGetCapabilities =3D testConnectGetCapabilities, /* 0.2.1 */ .connectGetSysinfo =3D testConnectGetSysinfo, /* 2.3.0 */ .connectGetType =3D testConnectGetType, /* 2.3.0 */ --=20 2.32.0 From nobody Sun Apr 28 09:07:02 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 1628765837731331.63925649045837; Thu, 12 Aug 2021 03:57:17 -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-371-bTLCwDUbMD-YRoClLQ0jBg-1; Thu, 12 Aug 2021 06:57:15 -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 127861082924; Thu, 12 Aug 2021 10:57:09 +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 8D45518032; Thu, 12 Aug 2021 10:57:08 +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 6CA974BB7C; Thu, 12 Aug 2021 10:57:07 +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 17CAoisB015251 for ; Thu, 12 Aug 2021 06:50:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 57A44208DDB6; Thu, 12 Aug 2021 10:50:44 +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 52D61208DDA5 for ; Thu, 12 Aug 2021 10:50:41 +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 DA23D18A01A9 for ; Thu, 12 Aug 2021 10:50:41 +0000 (UTC) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-4gqs5JbdNQuGY9mULkkJJQ-1; Thu, 12 Aug 2021 06:50:40 -0400 Received: by mail-pl1-f170.google.com with SMTP id t3so6733840plg.9 for ; Thu, 12 Aug 2021 03:50:39 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id j5sm3198994pgg.41.2021.08.12.03.50.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:38 -0700 (PDT) X-MC-Unique: bTLCwDUbMD-YRoClLQ0jBg-1 X-MC-Unique: 4gqs5JbdNQuGY9mULkkJJQ-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=rTpDw2Pi84JmU5gklDy2GDJI9l/IXO3nY9Mwq+xbbpg=; b=S4+2WkhpLQPYydATmX9UZcs+gdPLJ7MWjwDZgwgUuP0O2J0yjcTiLHyTwy57Uye1xS SM2slK8d6cdBOfnchvO4FO/cbNs+TNkalnLXrsbyGQFS/YqR3+BpGm+GPVq+adfAceKe Y/1M6C/MjlFI2Y9/MOHTEWTTExdIHX1tS90di0Ig+tzuoCSL4U0a7R4oeGSmNTKoDbnF phsdDXI0FWldz5cgdwXORui/RC9+BMcMrpZCFCe3Yrk3vOx3lwICVvaP9079xa5pFhr3 Y9jFkLikGo9p+7brGFCzPnzpPGz6wLpXXjqGMb5IBoZQKDBXboTztMDQoL3cdRX4/F4X kBDw== X-Gm-Message-State: AOAM5313cy1yG/hAVEdocOYKuaCDfgH3rEDUDTJo3ntw0G36Ziuebt0V 2zn+5x2TRXRkOP6iBGsR2ExtJ9mWv0LkDD/hJ5g= X-Google-Smtp-Source: ABdhPJz5xUP2p4wqGikfzGpHRSQQkgZt7wD1Hc9NwW8rv+d3PJGc5Vphfy8wRfHFvxzvs6dAZcmCGA== X-Received: by 2002:a17:90a:7d11:: with SMTP id g17mr3736809pjl.150.1628765438634; Thu, 12 Aug 2021 03:50:38 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 10/11] test_driver: Introduce testDomainGetStatsIOThread Date: Thu, 12 Aug 2021 18:50:01 +0800 Message-Id: <20210812105002.197134-11-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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.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: 1628765838558100001 Content-Type: text/plain; charset="utf-8" Introduce testDomainGetStatsIOThread to add support for testConnectGetAllDomainStats to get IOThread infos. Signed-off-by: Luke Yue --- src/test/test_driver.c | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6eebd85cf3..3c4015a67d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9798,6 +9798,46 @@ testDomainGetStatsState(virDomainObj *dom, return 0; } =20 +static int +testDomainGetStatsIOThread(virDomainObj *dom, + virTypedParamList *params) +{ + testDomainObjPrivate *priv =3D dom->privateData; + size_t i; + int niothreads =3D 0; + + if (!virDomainObjIsActive(dom)) + return 0; + + niothreads =3D priv->iothreads->len; + + if (niothreads =3D=3D 0) { + return 0; + } + + if (virTypedParamListAddUInt(params, niothreads, "iothread.count") < 0) + return -1; + + for (i =3D 0; i < niothreads; i++) { + testIOThreadInfo iothread =3D g_array_index(priv->iothreads, + testIOThreadInfo, i); + if (virTypedParamListAddULLong(params, iothread.poll_max_ns, + "iothread.%u.poll-max-ns", + iothread.iothread_id) < 0) + return -1; + if (virTypedParamListAddUInt(params, iothread.poll_grow, + "iothread.%u.poll-grow", + iothread.iothread_id) < 0) + return -1; + if (virTypedParamListAddUInt(params, iothread.poll_shrink, + "iothread.%u.poll-shrink", + iothread.iothread_id) < 0) + return -1; + } + + return 0; +} + typedef int (*testDomainGetStatsFunc)(virDomainObj *dom, virTypedParamList *list); @@ -9809,6 +9849,7 @@ struct testDomainGetStatsWorker { =20 static struct testDomainGetStatsWorker testDomainGetStatsWorkers[] =3D { { testDomainGetStatsState, VIR_DOMAIN_STATS_STATE }, + { testDomainGetStatsIOThread, VIR_DOMAIN_STATS_IOTHREAD }, { NULL, 0 } }; =20 @@ -9855,7 +9896,8 @@ testConnectGetAllDomainStats(virConnectPtr conn, VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSIS= TENT | VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE); =20 - unsigned int supported =3D VIR_DOMAIN_STATS_STATE; + unsigned int supported =3D VIR_DOMAIN_STATS_STATE | + VIR_DOMAIN_STATS_IOTHREAD; virDomainObj **vms =3D NULL; size_t nvms; virDomainStatsRecordPtr *tmpstats =3D NULL; --=20 2.32.0 From nobody Sun Apr 28 09:07:02 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 1628765839991171.9565686872512; Thu, 12 Aug 2021 03:57:19 -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-493-NlpXXarTOlacgJmgwhwryg-1; Thu, 12 Aug 2021 06:57:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 242E71008065; Thu, 12 Aug 2021 10:57:12 +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 EE8C466FFF; Thu, 12 Aug 2021 10:57:11 +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 BCE46181A2A9; Thu, 12 Aug 2021 10:57:11 +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 17CAomtY015263 for ; Thu, 12 Aug 2021 06:50:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6ADDA117C2D4; Thu, 12 Aug 2021 10:50:48 +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 66542117C2D2 for ; Thu, 12 Aug 2021 10:50:45 +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 074658CA953 for ; Thu, 12 Aug 2021 10:50:45 +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-589-pVLgJNg4ObyUOIsS5s4Kmw-1; Thu, 12 Aug 2021 06:50:42 -0400 Received: by mail-pl1-f176.google.com with SMTP id t3so6733983plg.9 for ; Thu, 12 Aug 2021 03:50:42 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id f9sm6007623pjq.36.2021.08.12.03.50.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 03:50:41 -0700 (PDT) X-MC-Unique: NlpXXarTOlacgJmgwhwryg-1 X-MC-Unique: pVLgJNg4ObyUOIsS5s4Kmw-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=A0CP4ZQJfl5xDKjaQZGAs0+7lkKbrZjthwsb5/TYpwE=; b=kYWlBljHxI3FBAQYJNJllpxAtO94uqXcBE9tVJydAMOEccwXvOkw+78XFOzasL4Nf1 IfvoROqko4D5kyV9nrIqtGhl/xtrahkWt4guc+56cCpkpj/cWVkJLFEDTxD08fuRWeZR sbpEhwZHQloLJ89Y7hcwNgdVSxKDhvg25sL3VF31YQwG7YDM9xg//BBr7cYITraSGoNi Vq/gFTA6thBwypbs8gWOnWRJNBlrBESuqAilTQI4p6nezX4jd8nJcZvu4DNT4AM0F2sC SsSEz0Lwzq2rXT3Qw85kZg/cp6+69h4ynY82H4mP511vnZ0/FIqazmDNDkayGvw5yOPd 7U+Q== X-Gm-Message-State: AOAM530E4Z2JcNYdY6fa/R36nOiCR4vWA8pB2x0uvxuhKjTCK6CEdlnI aeQHwgrW9uLO4CuJViQNJxXSQInTvitoc36hjIU= X-Google-Smtp-Source: ABdhPJxet5QwBzchQLJvZMUDiNt8FbzUHRjkHVneJ1IV8E/OjeQxmiNY0dbLT/dqIW/r8UbZJXTz6A== X-Received: by 2002:a17:90a:2c05:: with SMTP id m5mr3891624pjd.32.1628765441507; Thu, 12 Aug 2021 03:50:41 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 11/11] tests: Test IOThread related functions for test driver Date: Thu, 12 Aug 2021 18:50:02 +0800 Message-Id: <20210812105002.197134-12-lukedyue@gmail.com> In-Reply-To: <20210812105002.197134-1-lukedyue@gmail.com> References: <20210812105002.197134-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.15 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: 1628765840688100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- tests/virshtest.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tests/virshtest.c b/tests/virshtest.c index 53db2aa19a..e2d6ddd72b 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -30,6 +30,7 @@ main(void) tainted: custom device tree blob used\n\ tainted: use of deprecated configuration settings\n\ deprecated configuration: CPU model Deprecated-Test" +# define EQUAL "=3D" =20 static const char *dominfo_fc4 =3D "\ Id: 2\n\ @@ -69,6 +70,17 @@ Security DOI: \n\ Security label: " SECURITY_LABEL "\n\ Messages: " FC5_MESSAGES "\n\ \n"; +static const char *domstats_fc4 =3D "\ +Domain: 'fc4'\n\ + state.state" EQUAL "1\n\ + state.reason" EQUAL "0\n\ + iothread.count" EQUAL "2\n\ + iothread.2.poll-max-ns" EQUAL "32768\n\ + iothread.2.poll-grow" EQUAL "0\n\ + iothread.2.poll-shrink" EQUAL "0\n\ + iothread.4.poll-max-ns" EQUAL "32768\n\ + iothread.4.poll-grow" EQUAL "0\n\ + iothread.4.poll-shrink" EQUAL "0\n\n"; =20 static int testFilterLine(char *buffer, const char *toRemove) @@ -291,6 +303,60 @@ static int testCompareDomControlInfoByName(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\n\ + 4 0\n\ +\n"; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testIOThreadSet(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadset", "--domain= ", + "fc4", "--id", "2", "--poll-max-ns", "100= ", + "--poll-shrink", "10", "--poll-grow", + "10", NULL}; + const char *exp =3D "\n"; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testIOThreadPin(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadpin", "fc4", + "--iothread", "2", "--cpulist", "0", NULL= }; + const char *exp =3D "\n"; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testDomStats(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "domstats", "fc4", NULL }; + const char *exp =3D domstats_fc4; + return testCompareOutputLit(exp, NULL, argv); +} + struct testInfo { const char *const *argv; const char *result; @@ -383,6 +449,30 @@ mymain(void) testCompareDomControlInfoByName, 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; + + if (virTestRun("virsh iothreadset", + testIOThreadSet, NULL) !=3D 0) + ret =3D -1; + + if (virTestRun("virsh iothreadpin", + testIOThreadPin, NULL) !=3D 0) + ret =3D -1; + + if (virTestRun("virsh domstats (by name)", + testDomStats, 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