From nobody Wed May 8 16:46:36 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 1627560684474707.0405003608429; Thu, 29 Jul 2021 05:11:24 -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-300-ftuEqzAPO2aj7wdXXY8H3g-1; Thu, 29 Jul 2021 08:11:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8E858799E0; Thu, 29 Jul 2021 12:11: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 176962657B; Thu, 29 Jul 2021 12:11: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 21E25180084A; Thu, 29 Jul 2021 12:11:13 +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 16TCBBjf014569 for ; Thu, 29 Jul 2021 08:11:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7F670113B5F; Thu, 29 Jul 2021 12:11:11 +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 7A007113B55 for ; Thu, 29 Jul 2021 12:11:08 +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 C8E74811E78 for ; Thu, 29 Jul 2021 12:11:08 +0000 (UTC) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-tXktSKkQPKipXZAZgRkXEQ-1; Thu, 29 Jul 2021 08:11:06 -0400 Received: by mail-pj1-f50.google.com with SMTP id m2-20020a17090a71c2b0290175cf22899cso9002916pjs.2 for ; Thu, 29 Jul 2021 05:11:06 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id j3sm3353871pfc.10.2021.07.29.05.11.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:04 -0700 (PDT) X-MC-Unique: ftuEqzAPO2aj7wdXXY8H3g-1 X-MC-Unique: tXktSKkQPKipXZAZgRkXEQ-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=lxnsSkF4SpZyquITdZQFLImJvfrmAXTfdGKhXI9Ywa4=; b=XWIDfY/nONf9ozX6klMDKJgisedh4oXUwmBpncgDjVrxNIr5nGR3tSISxR0K9KXHRQ PWqUgQlNXuA2qkIjw31AwvZlbz1DLihPOKJ5I8ZB8Mew3R3zOqNnMuwWnzdFk3JBhbIZ s8VMku4ZLsfP7hx7nrd5z45aqyQjK3P5hYoBvPmlWbqUMGPLByeVmbd+f3P2iy1m1ElD jG2xwQby8WmTQ+mn2S77KpvO7bhenXH76fAXJwCPE7X6ww6XQvS8G6Gq1AiVtWgTFEqf o0jCtY2FKy5l7WrZjb+aC0QXJV1zTcgHXlUKWtzzH4CRi+iqKOJq5VilkZJ5GWJiGdHK MqnA== X-Gm-Message-State: AOAM530CYig2pqJJUdlYp+KPIzNzseCz/HTG6rYRxeFV3ELgoeyviTed /9gtoKjaiHFcI/xupvOiFgeC20BmiBJMRBGJ2bws0g== X-Google-Smtp-Source: ABdhPJxyKT9UHfhftGu1FyiljSMC0WSDmjQNIjlkdyKSFLcmUhhZw8BqtEwf/M26RdpZbmym6iCNCA== X-Received: by 2002:a65:6a4c:: with SMTP id o12mr3625603pgu.108.1627560665282; Thu, 29 Jul 2021 05:11:05 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 01/11] domain_driver.c: Introduce and use virDomainDriverAddIOThreadCheck() Date: Thu, 29 Jul 2021 20:10:48 +0800 Message-Id: <20210729121058.454431-2-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.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.23 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: 1627560684944100003 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 29e11c0447..0d4d9ae5de 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -511,3 +511,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 43493ea76e..fa2412c0dc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1531,6 +1531,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 0b35bbc15c..b96ac985bf 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 Wed May 8 16:46:36 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 1627560697883739.045694966679; Thu, 29 Jul 2021 05:11:37 -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-140-B2yL2laBMWChQgzkqHJa8A-1; Thu, 29 Jul 2021 08:11:34 -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 31E3B8799E0; Thu, 29 Jul 2021 12:11:29 +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 13B3969FAD; Thu, 29 Jul 2021 12:11:29 +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 D1E884A7CD; Thu, 29 Jul 2021 12:11:28 +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 16TCBB42014571 for ; Thu, 29 Jul 2021 08:11:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id C1E60202BFB9; Thu, 29 Jul 2021 12:11:11 +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 BD5B2202C0EB for ; Thu, 29 Jul 2021 12:11:11 +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 A6903101A529 for ; Thu, 29 Jul 2021 12:11:11 +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-125-33lEujvLOhC13gGkPIoodQ-1; Thu, 29 Jul 2021 08:11:09 -0400 Received: by mail-pl1-f176.google.com with SMTP id d1so6765393pll.1 for ; Thu, 29 Jul 2021 05:11:09 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id f3sm3576104pfe.123.2021.07.29.05.11.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:07 -0700 (PDT) X-MC-Unique: B2yL2laBMWChQgzkqHJa8A-1 X-MC-Unique: 33lEujvLOhC13gGkPIoodQ-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=YCE44wp0Cs3IaRKLqHdPK0AVf+2u+4NxXKESwwPP0AY=; b=hzUSIpuKFNsCvGi71Bd6oqjIwuY1ubRI2zBSZqNKnw3rSINBgHNXBgd1rLFVbLsl9L PWrG9iqq4eR5Yf4F29cIGFHCVrPMuSTKlLqI9mbz9IiPaDL0Kc+LUleGF6Ci1/Xv+wXI ckK6VctqTnUthoaKH6tMWzN6wWNTIvYelJbhlfTG5vHhXbt//hL++1VcRQv8iTP066V3 2xWr/xU8pTEu5Ht3yiHCmGOqmuJKo1lGt2VtJ0tCwOEZR7UoH5/nzt35oQNNU1QCM1Dp 4kMeOHyaF8gFKpHVMJJ5F2R7mg66Gz7JaNAcWe2yyQzMUoe0e3SpLF50HF+OKfO+20zT oORg== X-Gm-Message-State: AOAM5308CuwV0q9zYLRg6wh8CIIZgutLmOkcKiWlPxSyvJp1qI3Vxcxi P7U4TDodqspXOY2H7Pjtli8vJx5XEUFvxDVRD7iBZA== X-Google-Smtp-Source: ABdhPJyg78H5/z8jAnQLDf+DbcfXV0pCN/AakHIgpHU1rQeeFtnNW2tXFVpOnsNolJYlKr68cMoExg== X-Received: by 2002:aa7:9a08:0:b029:331:ea96:691d with SMTP id w8-20020aa79a080000b0290331ea96691dmr4665074pfj.75.1627560668290; Thu, 29 Jul 2021 05:11:08 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 02/11] test_driver: Introduce testIOThreadInfo and generate IOThread infos Date: Thu, 29 Jul 2021 20:10:49 +0800 Message-Id: <20210729121058.454431-3-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1627560699061100004 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 892dc978f2..7d9a81de54 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, @@ -968,6 +1003,8 @@ testParseDomains(testDriver *privconn, } virDomainObjSetState(obj, nsdata->runstate, 0); =20 + testDomainGenerateIOThreadInfos(obj); + virDomainObjEndAPI(&obj); } =20 --=20 2.32.0 From nobody Wed May 8 16:46:36 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 1627560697478846.9175266566933; Thu, 29 Jul 2021 05:11:37 -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-99-m_guvt_HMQSSP12YxrS4cg-1; Thu, 29 Jul 2021 08:11:35 -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 4480580196C; Thu, 29 Jul 2021 12:11:29 +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 1EFAA5C225; Thu, 29 Jul 2021 12:11:29 +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 D8BC5180BABF; Thu, 29 Jul 2021 12:11:28 +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 16TCBFT9014595 for ; Thu, 29 Jul 2021 08:11:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 015B6202C0E5; Thu, 29 Jul 2021 12:11:15 +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 F0F1A202BFB9 for ; Thu, 29 Jul 2021 12:11:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9A78101A52C for ; Thu, 29 Jul 2021 12:11:14 +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-495-LSw8wdOsN4Ci97r4RbjbFA-1; Thu, 29 Jul 2021 08:11:12 -0400 Received: by mail-pj1-f52.google.com with SMTP id m2-20020a17090a71c2b0290175cf22899cso9003583pjs.2 for ; Thu, 29 Jul 2021 05:11:12 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id p4sm2239525pfw.90.2021.07.29.05.11.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:10 -0700 (PDT) X-MC-Unique: m_guvt_HMQSSP12YxrS4cg-1 X-MC-Unique: LSw8wdOsN4Ci97r4RbjbFA-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=HR22Wx7hmuyCqgry6eQRmBfQgDCNsxi4Q50x179fGrs=; b=TOC2x4hBYyQP0odEImsU4zJq5KKXh19pW2QVKfPncfiLjy+Ylm0O0OAdcjK0AiXUWe Ibg27I5oOCs2jVs2YR8OfrLSMZt7QnhTSVmU/7Pzv0pLncpfc/NSnaHM95VVzw+K9nau 8aIU7k5ZL/r7uTgDocLX8R+i56Cgn+KtZJI3mt+rIvViwLCLzXgxx/tclybreIEO1sdY tpbvVk4inhaCHCDghZpuXkW8MQCAoGppUAmNu5nkOY2RX90xuIxYu5APBV9mT19NafGa V2+BK7Xbeo8TYlBggStuzeGTsU+kOTlGyaq3tIw8wOwwTveBE4g3Ee4LJy82rxxZzWCV 5NyQ== X-Gm-Message-State: AOAM531/zT1ovYK492NFOy9iR3EJLcL6EOtM8JXbvhj00OlU+gviIUkL bzYsvjDvGdRLySzolWhikFfO0xnLuzSsQNT23WLczw== X-Google-Smtp-Source: ABdhPJw3G4GraBR5H/YMJdAG8rflWszQHWmMNqHBcTSuRphNRF0qHk5xn3K1CyHw0UdTCK7Wumzzcg== X-Received: by 2002:a17:902:e547:b029:12c:563c:4a03 with SMTP id n7-20020a170902e547b029012c563c4a03mr4439159plf.46.1627560671128; Thu, 29 Jul 2021 05:11:11 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 03/11] test_driver: Implement virDomainAddIOThread Date: Thu, 29 Jul 2021 20:10:50 +0800 Message-Id: <20210729121058.454431-4-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.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: 1627560698916100001 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 7d9a81de54..3cabd6dc46 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" @@ -9390,6 +9391,81 @@ testDomainCheckpointDelete(virDomainCheckpointPtr ch= eckpoint, return ret; } =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 */ @@ -9456,6 +9532,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 Wed May 8 16:46:36 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 1627560689262819.4810790055294; Thu, 29 Jul 2021 05:11:29 -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-356-QYdeRlsKOYWYyYxdFRl2HA-1; Thu, 29 Jul 2021 08:11:26 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DAF71006C8F; Thu, 29 Jul 2021 12:11:21 +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 5F87526DF2; Thu, 29 Jul 2021 12:11:21 +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 2B61D4BB7C; Thu, 29 Jul 2021 12:11:21 +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 16TCBKfu014615 for ; Thu, 29 Jul 2021 08:11:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 506C62094D1F; Thu, 29 Jul 2021 12:11:20 +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 4C2D52094D1A for ; Thu, 29 Jul 2021 12:11:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8D30F811E78 for ; Thu, 29 Jul 2021 12:11:17 +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-390-8Nu6rbVuOyysKh0eziqa2w-1; Thu, 29 Jul 2021 08:11:15 -0400 Received: by mail-pj1-f43.google.com with SMTP id q17-20020a17090a2e11b02901757deaf2c8so9112924pjd.0 for ; Thu, 29 Jul 2021 05:11:15 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id j5sm3743716pgg.41.2021.07.29.05.11.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:13 -0700 (PDT) X-MC-Unique: QYdeRlsKOYWYyYxdFRl2HA-1 X-MC-Unique: 8Nu6rbVuOyysKh0eziqa2w-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=mrX87H7LU2QYER2FSWqIs4PXidomj5JMklP8HnE+yjc=; b=CWZ/fHvQ4zvOum1Z8GPYhVG8bPlYN8H6BbdkV0oG9WItt918EaFgxpPvImv8PV63mk JhmhPgh3jgkfujTCUt6E/RHYwQnqrA/BZ2hQ9pM4KQbU+uCpHrA9aePMhSgFt0W6g8ES Ts2kDNfHAcCLtz7qXRUHLAggRvlttgGW4SoaOtqydZi1H1+TvPhXAQ665vc8RyzVldpp CC3vuxy9zHM0BGycOPjM46us+O4w9yhklsGpYOHLzf7lD3UYVbEvwSPmfhfFuU28UomQ oac0D1SvEuE6CM7ghYNFn5A3wnXbGXdCQXjrpfctteR1OX7G+uOslATLDKxDB0Gjei5r Bv9A== X-Gm-Message-State: AOAM531gB8KdUjCT9XJrrJBElEz+SQ8JZ5ViqXc/ovx/mURtnQJiRIcu yN3iihY/DjrdOJaRrLF+O3cINHbKusn3HtjsSXdotQ== X-Google-Smtp-Source: ABdhPJwZLZLFc9QInr1pg5/h2bqQAA6ilGsERVdQgRFhR2sOPPwn847d30PQjfeh0kb78n4bx/ZwQQ== X-Received: by 2002:a17:90a:6782:: with SMTP id o2mr14597807pjj.165.1627560673882; Thu, 29 Jul 2021 05:11:13 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 04/11] test_driver: Implement virDomainDelIOThread Date: Thu, 29 Jul 2021 20:10:51 +0800 Message-Id: <20210729121058.454431-5-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.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.84 on 10.5.11.23 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: 1627560690102100001 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 3cabd6dc46..99d5d5b67b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9393,6 +9393,7 @@ testDomainCheckpointDelete(virDomainCheckpointPtr che= ckpoint, =20 typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, } virDomainIOThreadAction; =20 static int @@ -9417,6 +9418,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 @@ -9466,6 +9475,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 */ @@ -9533,6 +9587,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 Wed May 8 16:46:36 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 1627560703315909.1393821350779; Thu, 29 Jul 2021 05:11:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-6ovQnq02OiCK9dEU6jcAhQ-1; Thu, 29 Jul 2021 08:11:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74D9B94DD0; Thu, 29 Jul 2021 12:11:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59E0469FAD; Thu, 29 Jul 2021 12:11:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2817D180BAB2; Thu, 29 Jul 2021 12:11:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16TCBLVL014620 for ; Thu, 29 Jul 2021 08:11:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 13232202C0E5; Thu, 29 Jul 2021 12:11:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E34C202BFB9 for ; Thu, 29 Jul 2021 12:11:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E938A800883 for ; Thu, 29 Jul 2021 12:11:20 +0000 (UTC) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-T41tw9CGNImFcYV-t699aQ-1; Thu, 29 Jul 2021 08:11:18 -0400 Received: by mail-pl1-f176.google.com with SMTP id a20so6797639plm.0 for ; Thu, 29 Jul 2021 05:11:18 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id 11sm3809266pgh.52.2021.07.29.05.11.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:17 -0700 (PDT) X-MC-Unique: 6ovQnq02OiCK9dEU6jcAhQ-1 X-MC-Unique: T41tw9CGNImFcYV-t699aQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/SjR1Jtn+gmtzR6x8qR0yh4el7VZe4N71g1+tpLldV0=; b=OUCiEXQ6g2cG+jOi53vOmAOYKVVmwHXcGbrJ7Ak+z9w1OpCdNjptIs/K+LSOsd6SbN SGwQlk1/3KqCdbZNfsUz8AUS2pzlItvy+mcPR8eOXEa45HmFABZF8yQt3zZg3irxMVvx DEJ7YhCo++ubTLxtIIfiOZPEeiUyjAf8yzEPMzkrxJaQ9kU3EXC2r1GTe5Ma+LHI+9e0 m1ThtCoLAW39LFI+kRb8FjTemaozBvbkgo/JVvdLtQAK1rhZyIXH3xTRUQ5og0DhRwXH HPY5ys6lOAMCv2X5Fr3p8i0ItlXiBE4ASyhHgD0YdxfMQgQcxT7Q3TLr//L2Y+A0pxCM RXMQ== X-Gm-Message-State: AOAM533LyArjuB+DfCuBgmwXXfrDmEEKB5zFzKZRbmTh+buPKfwsebTj OqoAGAb0JwkujuEbE6rqR/ahAObUkSMdv+7WRXE2Pg== X-Google-Smtp-Source: ABdhPJzaxhpwL98y57wkz0sY0SGrNOIEgSPL4QbFwY7z95mKVNhizCNT6OWZAX8/W+3iNAEBpzFaKw== X-Received: by 2002:a17:90a:4fa4:: with SMTP id q33mr5044595pjh.75.1627560677415; Thu, 29 Jul 2021 05:11:17 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 05/11] domain_driver.c: Introduce and use virDomainDriverGetIOThreadsConfig() Date: Thu, 29 Jul 2021 20:10:52 +0800 Message-Id: <20210729121058.454431-6-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1627560705623100002 Content-Type: text/plain; charset="utf-8" The test driver can share the same code with qemu driver when implement testDomainGetIOThreadsConfig, so extract it for test driver to use. Signed-off-by: Luke Yue --- src/hypervisor/domain_driver.c | 59 ++++++++++++++++++++++++++++++++++ src/hypervisor/domain_driver.h | 3 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 53 +----------------------------- 4 files changed, 64 insertions(+), 52 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 0d4d9ae5de..fd0665daaf 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -575,3 +575,62 @@ virDomainDriverDelIOThreadCheck(virDomainDef *def, =20 return 0; } + +/** + * virDomainDriverGetIOThreadsConfig: + * @targetDef: domain definition + * @info: information about the IOThread in a domain + * + * Returns the number of IOThreads in the given domain or -1 in case of er= ror + */ +int +virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info) +{ + virDomainIOThreadInfoPtr *info_ret =3D NULL; + virBitmap *bitmap =3D NULL; + virBitmap *cpumask =3D NULL; + size_t i; + int ret =3D -1; + + if (targetDef->niothreadids =3D=3D 0) + return 0; + + info_ret =3D g_new0(virDomainIOThreadInfoPtr, targetDef->niothreadids); + + for (i =3D 0; i < targetDef->niothreadids; i++) { + info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); + + /* IOThread ID's are taken from the iothreadids list */ + info_ret[i]->iothread_id =3D targetDef->iothreadids[i]->iothread_i= d; + + cpumask =3D targetDef->iothreadids[i]->cpumask; + if (!cpumask) { + if (targetDef->cpumask) { + cpumask =3D targetDef->cpumask; + } else { + if (!(bitmap =3D virHostCPUGetAvailableCPUsBitmap())) + goto cleanup; + cpumask =3D bitmap; + } + } + if (virBitmapToData(cpumask, &info_ret[i]->cpumap, + &info_ret[i]->cpumaplen) < 0) + goto cleanup; + virBitmapFree(bitmap); + bitmap =3D NULL; + } + + *info =3D g_steal_pointer(&info_ret); + ret =3D targetDef->niothreadids; + + cleanup: + if (info_ret) { + for (i =3D 0; i < targetDef->niothreadids; i++) + virDomainIOThreadInfoFree(info_ret[i]); + VIR_FREE(info_ret); + } + virBitmapFree(bitmap); + + return ret; +} diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index d91d21bc91..638f01274b 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -66,3 +66,6 @@ int virDomainDriverAddIOThreadCheck(virDomainDef *def, =20 int virDomainDriverDelIOThreadCheck(virDomainDef *def, unsigned int iothread_id); + +int virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fa2412c0dc..4db2c5362d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1535,6 +1535,7 @@ virDomainDriverAddIOThreadCheck; virDomainDriverDelIOThreadCheck; virDomainDriverGenerateMachineName; virDomainDriverGenerateRootHash; +virDomainDriverGetIOThreadsConfig; virDomainDriverMergeBlkioDevice; virDomainDriverNodeDeviceDetachFlags; virDomainDriverNodeDeviceGetPCIInfo; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b96ac985bf..81e3f94f8b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5079,57 +5079,6 @@ qemuDomainGetIOThreadsLive(virQEMUDriver *driver, return ret; } =20 -static int -qemuDomainGetIOThreadsConfig(virDomainDef *targetDef, - virDomainIOThreadInfoPtr **info) -{ - virDomainIOThreadInfoPtr *info_ret =3D NULL; - virBitmap *bitmap =3D NULL; - virBitmap *cpumask =3D NULL; - size_t i; - int ret =3D -1; - - if (targetDef->niothreadids =3D=3D 0) - return 0; - - info_ret =3D g_new0(virDomainIOThreadInfoPtr, targetDef->niothreadids); - - for (i =3D 0; i < targetDef->niothreadids; i++) { - info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); - - /* IOThread ID's are taken from the iothreadids list */ - info_ret[i]->iothread_id =3D targetDef->iothreadids[i]->iothread_i= d; - - cpumask =3D targetDef->iothreadids[i]->cpumask; - if (!cpumask) { - if (targetDef->cpumask) { - cpumask =3D targetDef->cpumask; - } else { - if (!(bitmap =3D virHostCPUGetAvailableCPUsBitmap())) - goto cleanup; - cpumask =3D bitmap; - } - } - if (virBitmapToData(cpumask, &info_ret[i]->cpumap, - &info_ret[i]->cpumaplen) < 0) - goto cleanup; - virBitmapFree(bitmap); - bitmap =3D NULL; - } - - *info =3D g_steal_pointer(&info_ret); - ret =3D targetDef->niothreadids; - - cleanup: - if (info_ret) { - for (i =3D 0; i < targetDef->niothreadids; i++) - virDomainIOThreadInfoFree(info_ret[i]); - VIR_FREE(info_ret); - } - virBitmapFree(bitmap); - - return ret; -} =20 static int qemuDomainGetIOThreadInfo(virDomainPtr dom, @@ -5156,7 +5105,7 @@ qemuDomainGetIOThreadInfo(virDomainPtr dom, if (!targetDef) ret =3D qemuDomainGetIOThreadsLive(driver, vm, info); else - ret =3D qemuDomainGetIOThreadsConfig(targetDef, info); + ret =3D virDomainDriverGetIOThreadsConfig(targetDef, info); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.32.0 From nobody Wed May 8 16:46:36 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 1627560697886593.3713852254175; Thu, 29 Jul 2021 05:11:37 -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-543-rLKycyPeNIiEFHEyYZgdGA-1; Thu, 29 Jul 2021 08:11:35 -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 8D1A01006C83; Thu, 29 Jul 2021 12:11:29 +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 3C3631036D05; Thu, 29 Jul 2021 12:11:29 +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 01049180BAD0; Thu, 29 Jul 2021 12:11:29 +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 16TCBOoh014632 for ; Thu, 29 Jul 2021 08:11:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 107A0113B5F; Thu, 29 Jul 2021 12:11:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0AD1A110E9F for ; Thu, 29 Jul 2021 12:11:24 +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 E67B28001EA for ; Thu, 29 Jul 2021 12:11:23 +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-172-joXGF-tJNtCk7IWorV5Ttg-1; Thu, 29 Jul 2021 08:11:21 -0400 Received: by mail-pj1-f47.google.com with SMTP id e2-20020a17090a4a02b029016f3020d867so8949873pjh.3 for ; Thu, 29 Jul 2021 05:11:21 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id d134sm39137pfd.60.2021.07.29.05.11.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:20 -0700 (PDT) X-MC-Unique: rLKycyPeNIiEFHEyYZgdGA-1 X-MC-Unique: joXGF-tJNtCk7IWorV5Ttg-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=Uvp1HkcRAyIe88xvpZpTCIZHBiAPoVGhIjpJH9Uiel8=; b=Q2vM0brhmG8G1ROAaKEbxDsEqMrZURL6f0l9pufCDbSBbnwF5A4PVHhZylbfoWMEeP 5F0w8hUSLHXSpyTM/Hs6EAZBgbLGdHm1UVPL5NpG4PBzvgRYIp6Hgm/El6rP9OiTuHsS blnDfTItk6ZYtWuW8n9GRNZH8K8jBxd4Thmn2XgAki9ld+Ci+MP2bMIhCfGoOP9brcN/ 1AIQ/tSoVvLl2HnqF8wwqPvRRqENWtNMtsToxf3C+czg1AD56aft9/qB5xD2zcrtOVti hleENCz/GyWL66d65asUcKGTgMhDTapD953mHc3hs0KBIIuOgtpOschvTDI1QNGFD/WI FLBw== X-Gm-Message-State: AOAM5335iU9inEWyOlfU9dckGQr7pfvy5FQp8XwI5d8osprNTRY36o2A usZQYK7uUZBL2XsSV7HwIRiGPaUlaZAAyQa+ZDdC4Q== X-Google-Smtp-Source: ABdhPJxQM8ZNQoTzZHCEuPXe7tsRiH0ZClJ3/hgWFnG9isKx0LJg6w86yop6T2nPUarydge8vujNOw== X-Received: by 2002:a17:902:bcc3:b029:12b:c539:c2fc with SMTP id o3-20020a170902bcc3b029012bc539c2fcmr4346585pls.19.1627560680385; Thu, 29 Jul 2021 05:11:20 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 06/11] test_driver: Implement virDomainGetIOThreadInfo Date: Thu, 29 Jul 2021 20:10:53 +0800 Message-Id: <20210729121058.454431-7-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.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: 1627560698970100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 99d5d5b67b..d4958e4818 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9391,6 +9391,31 @@ testDomainCheckpointDelete(virDomainCheckpointPtr ch= eckpoint, return ret; } =20 +static int +testDomainGetIOThreadInfo(virDomainPtr dom, + virDomainIOThreadInfoPtr **info, + unsigned int flags) +{ + virDomainObj *vm; + virDomainDef *targetDef =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (!(targetDef =3D virDomainObjGetOneDef(vm, flags))) + goto cleanup; + + ret =3D virDomainDriverGetIOThreadsConfig(targetDef, info); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, VIR_DOMAIN_IOTHREAD_ACTION_DEL, @@ -9586,6 +9611,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 Wed May 8 16:46:36 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 162756070328366.12861153884228; Thu, 29 Jul 2021 05:11:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-578-UQ3uV4ceOU20q2EzAkC8BA-1; Thu, 29 Jul 2021 08:11:40 -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 6D7CE180FCD3; Thu, 29 Jul 2021 12:11:35 +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 4ACF35D9DC; Thu, 29 Jul 2021 12:11:35 +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 0E829181A2A7; Thu, 29 Jul 2021 12:11:35 +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 16TCBRkc014656 for ; Thu, 29 Jul 2021 08:11:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 10C962094D1F; Thu, 29 Jul 2021 12:11:27 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0BF362094D1A for ; Thu, 29 Jul 2021 12:11:27 +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 E8E9A800882 for ; Thu, 29 Jul 2021 12:11:26 +0000 (UTC) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-aN_UUBWwOfClajT0SIxQdw-1; Thu, 29 Jul 2021 08:11:24 -0400 Received: by mail-pj1-f54.google.com with SMTP id m2-20020a17090a71c2b0290175cf22899cso9004793pjs.2 for ; Thu, 29 Jul 2021 05:11:24 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id 26sm3088674pjj.27.2021.07.29.05.11.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:23 -0700 (PDT) X-MC-Unique: UQ3uV4ceOU20q2EzAkC8BA-1 X-MC-Unique: aN_UUBWwOfClajT0SIxQdw-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=IeHI7HRMd0ek9O0P6hK0O/OcB+Vno51CY8WwI10Hf0I=; b=Bg/Bqm6ucOtIa+dsGUggKyBjnQGgeI80TdjeJF/r5eJ+Y5YuuS6QP2R1zJX3p7dHvN 6m+CUemNo4fKvLi1WHiUBczky/bfNE2Po5WTyZ3+QcCBpdnjx/eUeC8Mn/aa728wWnfD f449bgsOPmKEzCv/XWAOyYauCQ2alWZapkNUDXXsUI3b0jE/vsRpHEO61bEnOS6e5RPC jqNxWuaUpNhSHn5r86V/qkMm95PjknGXSJBKldKzLgMbuquDk/H9qUCQG4NvU1EGGNNL UTi/WANucXGFusgdeki/JwfzumUvg2zOsDYONI49yrgBkeGzkBT9Z72VuCCzY9fzH0em XNeA== X-Gm-Message-State: AOAM530r/CJiQl81AwPzHJoL0bUhN9VSdyCtt+eU8tedKiT+DcILMy2x OlHK7tNa9DprPmDYgMxmpIAz1bP2PrrW9blmCyL6rw== X-Google-Smtp-Source: ABdhPJwSymJFJ51zD+n7NhtBIN1R2aY7NVHSGdCplXd58qujcnvbz5mIK/o2aa7NScWa8lKuJMCW3g== X-Received: by 2002:a17:902:e80a:b029:12c:58eb:1c8f with SMTP id u10-20020a170902e80ab029012c58eb1c8fmr4486519plg.59.1627560683526; Thu, 29 Jul 2021 05:11:23 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 07/11] test_driver: Implement virDomainPinIOThread Date: Thu, 29 Jul 2021 20:10:54 +0800 Message-Id: <20210729121058.454431-8-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.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.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: 1627560705589100001 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 d4958e4818..f192e800bf 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9545,6 +9545,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 */ @@ -9614,6 +9663,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 Wed May 8 16:46:36 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 1627560709015308.2440049466991; Thu, 29 Jul 2021 05:11:49 -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-283-YzPkfdrzOTuaIcSpoiZfbg-1; Thu, 29 Jul 2021 08:11:46 -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 DEE5D1006C83; Thu, 29 Jul 2021 12:11:39 +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 B72E6100EB3E; Thu, 29 Jul 2021 12:11:39 +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 827994A70B; Thu, 29 Jul 2021 12:11:39 +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 16TCBZUg014751 for ; Thu, 29 Jul 2021 08:11:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 82CC220BC8D1; Thu, 29 Jul 2021 12:11:35 +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 7E7A620287D4 for ; Thu, 29 Jul 2021 12:11:32 +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 2F9AA18A01A9 for ; Thu, 29 Jul 2021 12:11:32 +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-507-A-73FkdoOTqIsmKoeVqXFg-1; Thu, 29 Jul 2021 08:11:27 -0400 Received: by mail-pl1-f170.google.com with SMTP id d17so6709156plh.10 for ; Thu, 29 Jul 2021 05:11:27 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id j16sm3762337pfi.165.2021.07.29.05.11.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:26 -0700 (PDT) X-MC-Unique: YzPkfdrzOTuaIcSpoiZfbg-1 X-MC-Unique: A-73FkdoOTqIsmKoeVqXFg-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=wnSajLfVCNAnFlvcbebQMR/xxu9YazXA2VIvvwiL8Jc=; b=O8W1zsFxgbGUqx/ME8rXTFl7u1z9613TzMxkbzy0UFX7KGEAdf5uDPHBr9bp7cVt49 TtfBosqULehpmO7xFxx6Azi94AEpkczclYZv8oTwahQWiUpGc32F46V2ujVJu1Hw5Vil qJhoTHCdi0lxZH5l8w/6Y/Ob33A3emA+fFi4O0l+CZ4cYCKtfRfYC/uHhszPK0/Gmeh6 7r055PsF45LHv3zN8zivlAXqtPf2n0yzkDtSb8ATFk0AUVHuYvu2pHxHWkoF0Oe1YQha SiicDgvyxyDnai/X9PJJFxTKF2e8hHE8YAbsee2Swc78OZY4wS6S9Eun+hwHOI8IwVZa bX3g== X-Gm-Message-State: AOAM530LqWoqQtbDyi3pv6geU4MDs3j6DY+TpcNebcL8mcWuUy9+ulM7 9guX20UzjftskpM6wUnEZbx5EVRViuM6NiD0ToWL1g== X-Google-Smtp-Source: ABdhPJy0c9dzHIjnP7TPtXVw+MpPFztnew4V4c7rLOK32oRAOoSWs3Hit1AdQYFPnj5zutsR1vc4GQ== X-Received: by 2002:aa7:9a4a:0:b029:328:abeb:a339 with SMTP id x10-20020aa79a4a0000b0290328abeba339mr4868915pfj.29.1627560686381; Thu, 29 Jul 2021 05:11:26 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 08/11] test_driver: Implement testDomainSetIOThreadParams Date: Thu, 29 Jul 2021 20:10:55 +0800 Message-Id: <20210729121058.454431-9-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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: 1627560710497100002 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 f192e800bf..ca36e655f4 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9419,6 +9419,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 @@ -9450,6 +9451,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; } } @@ -9594,6 +9605,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 */ @@ -9664,6 +9753,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 Wed May 8 16:46:36 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 1627560724959295.4222872760324; Thu, 29 Jul 2021 05:12:04 -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-584-NEBv-u-fPCiMZuXpVyCSLg-1; Thu, 29 Jul 2021 08:11:43 -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 F141B1006C91; Thu, 29 Jul 2021 12:11:36 +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 C6ABA5D6B1; Thu, 29 Jul 2021 12:11:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 92CD04A705; Thu, 29 Jul 2021 12:11:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16TCBZRL014742 for ; Thu, 29 Jul 2021 08:11:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 076E1110E9F; Thu, 29 Jul 2021 12:11:35 +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 026C1113B63 for ; Thu, 29 Jul 2021 12:11:32 +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 8BD661066684 for ; Thu, 29 Jul 2021 12:11:32 +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-283-DaF_EcPjOwyWrupRvqsyGw-1; Thu, 29 Jul 2021 08:11:30 -0400 Received: by mail-pl1-f176.google.com with SMTP id t3so4625064plg.9 for ; Thu, 29 Jul 2021 05:11:30 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id p3sm3655581pfw.171.2021.07.29.05.11.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:28 -0700 (PDT) X-MC-Unique: NEBv-u-fPCiMZuXpVyCSLg-1 X-MC-Unique: DaF_EcPjOwyWrupRvqsyGw-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=FjFCN5ahkUlWO+zdCESivWaZQCi1PIwqt4PZ6OX7F1M=; b=UhifR9RQCCqdRWC7Z1rReyI/K8gSy4saHz0xfxlgCbKajH5I6nuS8egRMatM2dz+3S h8++TDOKunTVEe7hiTEgHJ37IY+f60NZ/EFrI8S2jDxKYODkFGr5gbt9ewBhuGJcn/jX 3kKNBngc3H9NZ4l+70jKbsu/bLRPt1WxHtvXPTyIADEISOdOdRgU97uw9bnCsbu/HUVO Xzpc0vSQWSWF75v8LoHdI1WDr1JBI7YFej1B+x0bBaSTov4mOg7LX3w3Nm6xGnKi8gHz VNg3pBQxvI3D3uPNpTFXncGxtgVp8eIfYpczpaZTkLq/mRZ67WYZEtVFp9fVfBRMhCT3 SJxw== X-Gm-Message-State: AOAM5331jOase+TiaEIn7GyMwl5jxRTh9JnH/ixEmwYfJ0K4udCqlet5 BXnrwqO5xvjLKn72rVfs54e1Ra1e7U/G42VCK0brHA== X-Google-Smtp-Source: ABdhPJwd/5ysqYVMoumvcLvqeEnP0bJFmTEUR258XqgBRqbcsc+YzlwIvHlNMqYrCNHpe0Ss93M6Kg== X-Received: by 2002:a17:902:db0f:b029:12b:32c8:c097 with SMTP id m15-20020a170902db0fb029012b32c8c097mr4366525plx.25.1627560689095; Thu, 29 Jul 2021 05:11:29 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 09/11] test_driver: Implement virConnectGetAllDomainStats Date: Thu, 29 Jul 2021 20:10:56 +0800 Message-Id: <20210729121058.454431-10-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.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.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: 1627560726625100001 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 | 132 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ca36e655f4..5da7f23a9b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9683,6 +9683,137 @@ 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; + virDomainObj *vm =3D vms[i]; + + virObjectLock(vm); + testDomainGetStats(conn, vm, stats, &tmp); + 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 */ @@ -9697,6 +9828,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 Wed May 8 16:46:36 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 1627560710163898.4539187092358; Thu, 29 Jul 2021 05:11:50 -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-424-gl-D0eRvNK27kaKj8NcShQ-1; Thu, 29 Jul 2021 08:11:47 -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 73B8B1084F4B; Thu, 29 Jul 2021 12:11:42 +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 58FC860843; Thu, 29 Jul 2021 12:11:42 +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 23528181A2AC; Thu, 29 Jul 2021 12:11:42 +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 16TCBZXK014756 for ; Thu, 29 Jul 2021 08:11:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC798113B5F; Thu, 29 Jul 2021 12:11:35 +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 D7A5C10FADA for ; Thu, 29 Jul 2021 12:11:35 +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 C0AEB1066682 for ; Thu, 29 Jul 2021 12:11:35 +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-472-Ugaiheo_OE-YFJspGq5MNA-1; Thu, 29 Jul 2021 08:11:33 -0400 Received: by mail-pj1-f49.google.com with SMTP id ds11-20020a17090b08cbb0290172f971883bso15337398pjb.1 for ; Thu, 29 Jul 2021 05:11:32 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id b6sm9724786pjl.17.2021.07.29.05.11.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:31 -0700 (PDT) X-MC-Unique: gl-D0eRvNK27kaKj8NcShQ-1 X-MC-Unique: Ugaiheo_OE-YFJspGq5MNA-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=bS5D99Z03SQXwEW+xgomOFBFhm6+deEJn9aIBUfPrO8=; b=N+XrCxILCdMHIWNR2Jf7l2mrfleWdTELckE7efFJG86vDhtN4mwVxAmbhtWLgNz7We SSuGeA4k7PYCfuXSFbcYoY6RxC0tQcxm9hLnxbGJZyTbIM3Nx1NbfBCBj2XRw3y1hjzz gzzkxQ8JZ0OPP3PnwEG+Tg0Nr+/crDdTpwa7BSUEC2iCshbvV9lpzxVPXfeNWDG/a0F0 8Y9lXdRFbAOe/zSwnAsWofCc7u6+e1/obCFWb2HEicyEhzQd4cd+mdTa9QXjKiwyVydK FjRfOkamu+fdru0P028NfKgmctWny8Ci4s3q64HrjNoBxnTZ66DRrJFzsTWbleXGwkqr 7/Hw== X-Gm-Message-State: AOAM530Gx+3kFGIOVLjfMPdbYZoI/B/F8jXRGnWKjoo8UsT9HPWLbTBz szA6+KAz7E+7+8QXWO4OInpT4GzJuID0KohwwshAtA== X-Google-Smtp-Source: ABdhPJxsIbEfFT7b2QVOjSkp18lTJ8RdqiDazLq5UDezXW6mYH6g8DRgkO3WDGYSTQBYtIuQEFmUYA== X-Received: by 2002:a62:7b86:0:b029:32b:364a:e7e4 with SMTP id w128-20020a627b860000b029032b364ae7e4mr4802013pfc.49.1627560691892; Thu, 29 Jul 2021 05:11:31 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 10/11] test_driver: Introduce testDomainGetStatsIOThread Date: Thu, 29 Jul 2021 20:10:57 +0800 Message-Id: <20210729121058.454431-11-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.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.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: 1627560710532100003 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 5da7f23a9b..24f6062b42 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9696,6 +9696,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); @@ -9707,6 +9747,7 @@ struct testDomainGetStatsWorker { =20 static struct testDomainGetStatsWorker testDomainGetStatsWorkers[] =3D { { testDomainGetStatsState, VIR_DOMAIN_STATS_STATE }, + { testDomainGetStatsIOThread, VIR_DOMAIN_STATS_IOTHREAD }, { NULL, 0 } }; =20 @@ -9753,7 +9794,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 Wed May 8 16:46:36 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 1627560709287639.1111494324399; Thu, 29 Jul 2021 05:11:49 -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-317-5MJNQ-qQOKSXfoLlTYGucw-1; Thu, 29 Jul 2021 08:11:46 -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 6ADA61084F5F; Thu, 29 Jul 2021 12:11:40 +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 4A4CD5C1D1; Thu, 29 Jul 2021 12:11:40 +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 15765181A2A9; Thu, 29 Jul 2021 12:11:40 +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 16TCBcZe014782 for ; Thu, 29 Jul 2021 08:11:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 02807110E9F; Thu, 29 Jul 2021 12:11:38 +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 F210210FADA for ; Thu, 29 Jul 2021 12:11:37 +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 DB25418A01A5 for ; Thu, 29 Jul 2021 12:11:37 +0000 (UTC) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-527-nhcDIIwfPYyz3fOhQ0IDEg-1; Thu, 29 Jul 2021 08:11:35 -0400 Received: by mail-pl1-f171.google.com with SMTP id k1so6701151plt.12 for ; Thu, 29 Jul 2021 05:11:35 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id j13sm3677113pgp.29.2021.07.29.05.11.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 05:11:34 -0700 (PDT) X-MC-Unique: 5MJNQ-qQOKSXfoLlTYGucw-1 X-MC-Unique: nhcDIIwfPYyz3fOhQ0IDEg-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=2YSKnMTsG9b/6NEX9mzs4lQHluTiXLTP8Db3rc9wyis=; b=Pw+6twbdXtcRThUgNcVx3bb6KWwBxENHsZwyzYek+xq+q2JSMHNTg25obORUP4ugrl 5bDhOjHP6JizihxjGBXvEYeDupjDQ+wSHgxIIkZKlAvtJ5fNQFKgFoFWoDz9QlYncP/l j29iJdB3gM5LvTThJZtA3MECbD01mAQgyo9JhQ3RshfDslVVEIbDnIKKyCSiZwAAEvVV nmAI97oObKoXWZnrct7BtfoV0nxyRq7GmHSugXHAXZ6GapXmUxjYVq90yxf3+Kn5iOHf 7NxKm4dnGAbDke5xd/01mf0WW+7zpiWTgzOavV283+19dOtc9kH22se5p3KchU7+9+wE C45A== X-Gm-Message-State: AOAM533V3Ejv7Td/11M1ySpqyEyykPqKdc6Hc1iLcFMo9DCAzXAF0FR4 t1Asy9cCj5dqmDFuumI8a0hDVo8ysaD1bPLaPU3QLw== X-Google-Smtp-Source: ABdhPJymhhXQhivYgREmg1YaIrDIIP8ZTeiXw8+Azzzw2j/jVGS2+f6vndb801bnguxJnDBIeI0mnw== X-Received: by 2002:a17:902:e547:b029:12c:563c:4a03 with SMTP id n7-20020a170902e547b029012c563c4a03mr4440554plf.46.1627560694435; Thu, 29 Jul 2021 05:11:34 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 11/11] tests: Test IOThread related functions for test driver Date: Thu, 29 Jul 2021 20:10:58 +0800 Message-Id: <20210729121058.454431-12-lukedyue@gmail.com> In-Reply-To: <20210729121058.454431-1-lukedyue@gmail.com> References: <20210729121058.454431-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.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.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: 1627560710479100001 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 fe0c420958..4b10be9c0c 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -22,6 +22,7 @@ main(void) =20 # define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493" # define SECURITY_LABEL "libvirt-test (enforcing)" +# define EQUAL "=3D" =20 static const char *dominfo_fc4 =3D "\ Id: 2\n\ @@ -43,6 +44,17 @@ static const char *domuuid_fc4 =3D DOM_UUID "\n\n"; static const char *domid_fc4 =3D "2\n\n"; static const char *domname_fc4 =3D "fc4\n\n"; static const char *domstate_fc4 =3D "running\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) @@ -257,6 +269,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-7\n\ + 4 0-7\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; @@ -345,6 +411,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