From nobody Mon May 6 12:08:25 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 163171990822349.45321732525997; Wed, 15 Sep 2021 08:31:48 -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-534-ZcIfr9EhO2Sj_SeX0jb-7Q-1; Wed, 15 Sep 2021 11:31:04 -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 10349802CB5; Wed, 15 Sep 2021 15:30:58 +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 761B07BE45; Wed, 15 Sep 2021 15:30:56 +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 B37ED4EA2F; Wed, 15 Sep 2021 15:30:54 +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 18FFUsla028833 for ; Wed, 15 Sep 2021 11:30:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 072F320287C7; Wed, 15 Sep 2021 15:30:54 +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 F00E020287D3 for ; Wed, 15 Sep 2021 15:30:51 +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 08FE0800B36 for ; Wed, 15 Sep 2021 15:30:51 +0000 (UTC) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-597-oo4rakDXNASUM46fGX5yDw-1; Wed, 15 Sep 2021 11:30:49 -0400 Received: by mail-pf1-f171.google.com with SMTP id j6so3011831pfa.4 for ; Wed, 15 Sep 2021 08:30:49 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id u24sm373497pfm.27.2021.09.15.08.30.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:30:47 -0700 (PDT) X-MC-Unique: ZcIfr9EhO2Sj_SeX0jb-7Q-1 X-MC-Unique: oo4rakDXNASUM46fGX5yDw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=moNg1/zMQw9XIUIMeojuxzpbnkVHvScF3e2MfR0PP50=; b=ybPXcyctRouc6GIESwXbxy4/jjVeAkPa8rDRLee6XQwlJKZ1OHSfHE/Q3iX4T8tYeg SZEcfxaEFAVmXPmdhJvqj/Xf3ELlWYgyHE4OgKOc53x1N+EAnNB6jgN7/Z0qmVu4v5Vy BGDzcrUSjIF6HN6EZ1W0vwmNgvpWKvU6rlA5hWIcyeUvzsY7wtYuKWjVJORKRh/jBDte Nm0z2SH/1Vg5bW7T62OUEbbZRQ+Xv/pj7iNOrDOS2bKuv/Tnbv/5qDr5WyDJtZl2t8HM hSerK/+cGYA4pK/0Lxb/7TfQK48k2a7F/A0VTBjqzPBXSy6pgMGkECvOHKfjy50d/nIB fIOA== X-Gm-Message-State: AOAM5327Uz/FUhk04FZm27UN1oXgtaKZ1yTNCZXyAUBeDOS6oq+q25Ct 46uYrJXY3uPD6BBLO0IGpho5X7a+gK2iRJCpyXw= X-Google-Smtp-Source: ABdhPJz66H5CR0lEAAy0/E9gXjlmOMgA+WWfqJHHmIp5wH+bOc/iZqRrlOvJAiz89M87cxlg+huoTQ== X-Received: by 2002:a05:6a00:8c2:b0:438:7f68:2438 with SMTP id s2-20020a056a0008c200b004387f682438mr115365pfu.33.1631719847741; Wed, 15 Sep 2021 08:30:47 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 01/11] domain_driver.c: Introduce and use virDomainDriverAddIOThreadCheck() Date: Wed, 15 Sep 2021 23:30:22 +0800 Message-Id: <20210915153032.121221-2-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-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.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: 1631719909422000001 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 Reviewed-by: Michal Privoznik --- src/hypervisor/domain_driver.c | 64 ++++++++++++++++++++++++++++++++++ src/hypervisor/domain_driver.h | 6 ++++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_driver.c | 60 +++---------------------------- 4 files changed, 76 insertions(+), 56 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 2969d55173..3eb2401053 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -512,3 +512,67 @@ virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr = dev, =20 return virHostdevPCINodeDeviceDetach(hostdevMgr, pci); } + +/** + * virDomainDriverAddIOThreadCheck: + * @def: domain definition + * @iothread_id: iothread id + * + * Returns -1 if an IOThread is already using the given iothread id + */ +int +virDomainDriverAddIOThreadCheck(virDomainDef *def, + unsigned int iothread_id) +{ + if (virDomainIOThreadIDFind(def, iothread_id)) { + virReportError(VIR_ERR_INVALID_ARG, + _("an IOThread is already using iothread_id '%u'"), + iothread_id); + return -1; + } + + return 0; +} + +/** + * virDomainDriverDelIOThreadCheck: + * @def: domain definition + * @iothread_id: iothread id + * + * Returns -1 if there is no IOThread using the given iothread id + */ +int +virDomainDriverDelIOThreadCheck(virDomainDef *def, + unsigned int iothread_id) +{ + size_t i; + + if (!virDomainIOThreadIDFind(def, iothread_id)) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot find IOThread '%u' in iothreadids list"), + iothread_id); + return -1; + } + + for (i =3D 0; i < def->ndisks; i++) { + if (def->disks[i]->iothread =3D=3D iothread_id) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot remove IOThread %u since it " + "is being used by disk '%s'"), + iothread_id, def->disks[i]->dst); + return -1; + } + } + + for (i =3D 0; i < def->ncontrollers; i++) { + if (def->controllers[i]->iothread =3D=3D iothread_id) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot remove IOThread '%u' since it " + "is being used by controller"), + iothread_id); + return -1; + } + } + + return 0; +} diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index 5970eef082..d91d21bc91 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -60,3 +60,9 @@ int virDomainDriverNodeDeviceReAttach(virNodeDevicePtr de= v, int virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr dev, virHostdevManager *hostdevMgr, const char *driverName); + +int virDomainDriverAddIOThreadCheck(virDomainDef *def, + unsigned int iothread_id); + +int virDomainDriverDelIOThreadCheck(virDomainDef *def, + unsigned int iothread_id); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ace35d709f..d45b644caf 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1537,6 +1537,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 6ae678b165..f2acb37c76 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5445,58 +5445,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 @@ -5630,7 +5578,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) @@ -5639,7 +5587,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) @@ -5668,7 +5616,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)) @@ -5677,7 +5625,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.33.0 From nobody Mon May 6 12:08:25 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 163171994893095.24272842043547; Wed, 15 Sep 2021 08:32:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-p4kN_PISNPqxnyw6_QFTew-1; Wed, 15 Sep 2021 11:31:03 -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 64F961006B1D; Wed, 15 Sep 2021 15:30:58 +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 196007D9C6; Wed, 15 Sep 2021 15:30:58 +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 B56C3180598A; Wed, 15 Sep 2021 15:30:56 +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 18FFUsKV028840 for ; Wed, 15 Sep 2021 11:30:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id D267EE2A61; Wed, 15 Sep 2021 15:30:54 +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 CCF39DEECD for ; Wed, 15 Sep 2021 15:30:54 +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 B4A418038E3 for ; Wed, 15 Sep 2021 15:30:54 +0000 (UTC) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-528-YV-X7JsHMKur0_xbyFYMLA-1; Wed, 15 Sep 2021 11:30:52 -0400 Received: by mail-pg1-f169.google.com with SMTP id k24so3071585pgh.8 for ; Wed, 15 Sep 2021 08:30:52 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id k29sm304285pfp.200.2021.09.15.08.30.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:30:50 -0700 (PDT) X-MC-Unique: p4kN_PISNPqxnyw6_QFTew-1 X-MC-Unique: YV-X7JsHMKur0_xbyFYMLA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f05S+K1UfXIJ7RYK2t6+vUSHcGsSGE0NKpgG6hLEbHo=; b=l5KjkXUGUt5kqlsuz027LtqWGdHNIQgQOUjgVAjuUsQ8YBhAuDUN6MKQjnsV9PCK9h rX1ydB7cfcJAUuGWvUekZVs08L/uEYEg3c3uzIFdrlptPTmQ3x9ZKuv7Qo6+NjSbvEIV xz90TKtRduD7cv+N0su4Cvy1ItvfGtSF0ATac/aMQDvj2n/8dbaS9+FdUppLdD8PjEw/ Og95l9EviVPzUDKZDuxHtKtc8uN58d1t0qfw49WznMWiaAvXjrwpGr7UYBS1HftVGwF8 vUv0B30YVmelcoW+Raap31CDz1qf+cLxI5dmg0wcNSSqyX6c45i5zRgBzrv9h7UTRV7O 4Low== X-Gm-Message-State: AOAM533905PXJ1BMCpXbO0Sy4T+D1Xm67RZR15LTe+MqoyLrZCLFSeP9 9M8MYoBoJNnOONajv8xSHVBSMjOHetf+KlqnX04= X-Google-Smtp-Source: ABdhPJzRzLFjoIPRWUkVyGV3fbkbZJEdKXMFXNpKtY6Mtp3McScX0h6IVrG9oHJrKthij3Tj5rGAeg== X-Received: by 2002:a63:b50d:: with SMTP id y13mr341091pge.286.1631719850849; Wed, 15 Sep 2021 08:30:50 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 02/11] test_driver: Introduce testIOThreadInfo and generate IOThread infos Date: Wed, 15 Sep 2021 23:30:23 +0800 Message-Id: <20210915153032.121221-3-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-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: 1631719949965000001 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 Reviewed-by: Michal Privoznik --- 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 2c2c6f52d1..8de8779c7f 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -183,6 +183,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) { @@ -381,6 +389,9 @@ struct _testDomainObjPrivate { /* used by get/set time APIs */ long long seconds; unsigned int nseconds; + + /* used by IOThread APIs */ + GArray *iothreads; }; =20 =20 @@ -397,6 +408,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 @@ -427,6 +440,8 @@ static void testDomainObjPrivateFree(void *data) { testDomainObjPrivate *priv =3D data; + + g_array_free(priv->iothreads, TRUE); g_free(priv); } =20 @@ -696,6 +711,26 @@ testDomainGenerateIfnames(virDomainDef *domdef) return 0; } =20 +static void +testDomainGenerateIOThreadInfos(virDomainObj *obj) +{ + size_t i; + testDomainObjPrivate *priv; + + if (!obj->def->iothreadids || !obj->def->niothreadids) + return; + + priv =3D obj->privateData; + + for (i =3D 0; i < obj->def->niothreadids; i++) { + testIOThreadInfo iothread; + iothread.iothread_id =3D obj->def->iothreadids[i]->iothread_id; + iothread.poll_max_ns =3D 32768; + iothread.poll_grow =3D 0; + iothread.poll_shrink =3D 0; + g_array_append_val(priv->iothreads, iothread); + } +} =20 static void testDomainShutdownState(virDomainPtr domain, @@ -1045,6 +1080,8 @@ testParseDomains(testDriver *privconn, =20 testDomainObjCheckTaint(obj); =20 + testDomainGenerateIOThreadInfos(obj); + virDomainObjEndAPI(&obj); } =20 --=20 2.33.0 From nobody Mon May 6 12:08:25 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 1631719881153519.8791414099273; Wed, 15 Sep 2021 08:31:21 -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-320-oVMlANbcOvC3GJ2GUulykw-1; Wed, 15 Sep 2021 11:31:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41915802DF1; Wed, 15 Sep 2021 15:31:11 +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 1B4B36C8D4; Wed, 15 Sep 2021 15:31:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CFAD3180598A; Wed, 15 Sep 2021 15:31:10 +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 18FFV152028863 for ; Wed, 15 Sep 2021 11:31:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 20D6D2121C38; Wed, 15 Sep 2021 15:31:01 +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 1B42E2121C34 for ; Wed, 15 Sep 2021 15:31:01 +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 03F8718A01A0 for ; Wed, 15 Sep 2021 15:31:01 +0000 (UTC) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-e4npUQNaO2KAKOU6u1gxNg-1; Wed, 15 Sep 2021 11:30:58 -0400 Received: by mail-pg1-f178.google.com with SMTP id n18so3044761pgm.12 for ; Wed, 15 Sep 2021 08:30:58 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id n14sm347732pgd.48.2021.09.15.08.30.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:30:53 -0700 (PDT) X-MC-Unique: oVMlANbcOvC3GJ2GUulykw-1 X-MC-Unique: e4npUQNaO2KAKOU6u1gxNg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iCvYtjXx37MhxPMbLf5Tx2aOwW/86NBCvbiP1mirx+Y=; b=LoYZFnKOugDh7h/rC4VKxp8OV+T8Afskzf19HthUTsDVWF4FvDQckMJHNe3BnQjTBb VWv5R0e04QXRlp1FQhKwLio7H8xmGB8t+unmkg6HYJop2C/3oZI3Yi84CdfF9t4M8/5n VVmo+jJAy6JFcBVQCvZMczd2L9TfXyrhY3y/fiUpoL8/VTQ1jjgrOfBgXyMA1a8d1+pJ nvfW/EeWY2MwcPCz3OX/7Xcy0oHcEbBuNzSBVQ56JPo29NRruO/1ybJXZUn9sqjbN9Id lVgRAQ+jh4NEv49rHlahCj0qPR8Pfx4DoYmYhxwaRW/mdo4W1vLU9adyIaXidKHzCXSH 9h7Q== X-Gm-Message-State: AOAM530CE7HP8b4HHXiszMi+Bemndjs8l7pbJuUUagJr2a5I5pO4MX+p z/WLT00wg3sLDA2V05FjiW1qbun09ib06MVBHG0= X-Google-Smtp-Source: ABdhPJwgbj1HLuPNUohvMK3RpI3c36NsOyuT3YudvrfDTRRCNhgvQ8SLoeR8vi2b4is5zarB8QbYPw== X-Received: by 2002:a63:b40a:: with SMTP id s10mr323477pgf.454.1631719854746; Wed, 15 Sep 2021 08:30:54 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 03/11] test_driver: Implement virDomainAddIOThread Date: Wed, 15 Sep 2021 23:30:24 +0800 Message-Id: <20210915153032.121221-4-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-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.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: 1631719886118100001 Content-Type: text/plain; charset="utf-8" Introduce testDomainChgIOThread at the same time, could be used for virDomainDelIOThread etc. Signed-off-by: Luke Yue Reviewed-by: Michal Privoznik --- src/test/test_driver.c | 76 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 8de8779c7f..e0b7ace4ed 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9586,6 +9586,81 @@ testDomainGetMessages(virDomainPtr dom, return rv; } =20 +typedef enum { + VIR_DOMAIN_IOTHREAD_ACTION_ADD, +} virDomainIOThreadAction; + +static int +testDomainChgIOThread(virDomainObj *vm, + unsigned int iothread_id, + virDomainIOThreadAction action, + unsigned int flags) +{ + virDomainDef *def; + int ret =3D -1; + + if (!(def =3D virDomainObjGetOneDef(vm, flags))) + return ret; + + if (def) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: + if (virDomainDriverAddIOThreadCheck(def, iothread_id) < 0) + return ret; + + if (!virDomainIOThreadIDAdd(def, iothread_id)) + return ret; + + break; + } + } + + ret =3D 0; + + return ret; +} + +static int +testDomainAddIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + testDomainObjPrivate *priv; + testIOThreadInfo iothread; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (iothread_id =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + return -1; + } + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (testDomainChgIOThread(vm, iothread_id, + VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags) < 0) + goto cleanup; + + priv =3D vm->privateData; + + iothread.iothread_id =3D iothread_id; + iothread.poll_max_ns =3D 32768; + iothread.poll_grow =3D 0; + iothread.poll_shrink =3D 0; + + g_array_append_val(priv->iothreads, iothread); + + ret =3D 0; + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} /* * Test driver */ @@ -9652,6 +9727,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.8.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ .nodeGetSecurityModel =3D testNodeGetSecurityModel, /* 7.5.0 */ .domainGetXMLDesc =3D testDomainGetXMLDesc, /* 0.1.4 */ --=20 2.33.0 From nobody Mon May 6 12:08:25 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 1631719883572942.7114612204097; Wed, 15 Sep 2021 08:31:23 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-409--O2k9YGRO3y8lFwMQW12iw-1; Wed, 15 Sep 2021 11:31:21 -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 5FB4D802C99; Wed, 15 Sep 2021 15:31:14 +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 3DFCB6A902; Wed, 15 Sep 2021 15:31:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0827C1806D03; Wed, 15 Sep 2021 15:31:14 +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 18FFV23F028871 for ; Wed, 15 Sep 2021 11:31:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB0D4E2A81; Wed, 15 Sep 2021 15:31:02 +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 A5FDEDEED7 for ; Wed, 15 Sep 2021 15:31:02 +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 8F5221066681 for ; Wed, 15 Sep 2021 15:31:02 +0000 (UTC) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-7CbnGsrbOISqNol18Fwy3g-1; Wed, 15 Sep 2021 11:31:00 -0400 Received: by mail-pj1-f41.google.com with SMTP id dw14so2411253pjb.1 for ; Wed, 15 Sep 2021 08:31:00 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id i2sm326717pfa.82.2021.09.15.08.30.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:30:58 -0700 (PDT) X-MC-Unique: -O2k9YGRO3y8lFwMQW12iw-1 X-MC-Unique: 7CbnGsrbOISqNol18Fwy3g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n2BRLZyFD1C8BlVf4+lLEbbnn6cdRvDbjNEkRNX4t4E=; b=2jlafGUDqU7BNAQCmMu7CIuRI3ZFQ+Hfy9mmcDtdChyDQpFKRNdwi5xQaTZATIztQA IsDqTHO5/ZSlQ8GuchSoyuE6sySGzmdFEYXI16/uBzfe8o6E0OmxIZp2HDm7JGmDvgIt J7s63dlUzD2lWTEbMhfRhQFsqoEYwAqOUefCF9Ph7vsCL74Cw0embkP6v7eswgTtFp95 rPU/0XSf4iYhH020TlndIQ2+1nYUsudXilm9DlVJDaH7cdr17X2YUzRQjl83NRRKpVbf ZInEA9lM9LvbyFmh6V03VoZpjrl1H3i3kLYAclxLsF7aG+7K4sDuzJaK9mOVUVt1ZJAx z8Bw== X-Gm-Message-State: AOAM533HzgXaNa8IyazEb+K7KQ36mwtjLN+DLK8+srIcdi9otGYICNkT HMZf2pSsgWOP8WZr1ItUKdOnhevrYv8BbFhR+aw= X-Google-Smtp-Source: ABdhPJzrBA9GL1vK/0Z3Un7bnMsM0Vo4jnez1HITeaEEEYcirJQ1QOZAINUKd+4t7OaiWMSHcRixTA== X-Received: by 2002:a17:90a:e386:: with SMTP id b6mr379464pjz.97.1631719858944; Wed, 15 Sep 2021 08:30:58 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 04/11] test_driver: Implement virDomainDelIOThread Date: Wed, 15 Sep 2021 23:30:25 +0800 Message-Id: <20210915153032.121221-5-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-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: 1631719887408100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue Reviewed-by: Michal Privoznik --- 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 e0b7ace4ed..b588bbc32e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9588,6 +9588,7 @@ testDomainGetMessages(virDomainPtr dom, =20 typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, } virDomainIOThreadAction; =20 static int @@ -9612,6 +9613,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 @@ -9661,6 +9670,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 */ @@ -9728,6 +9782,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetVcpuPinInfo =3D testDomainGetVcpuPinInfo, /* 1.2.18 */ .domainGetMaxVcpus =3D testDomainGetMaxVcpus, /* 0.7.3 */ .domainAddIOThread =3D testDomainAddIOThread, /* 7.8.0 */ + .domainDelIOThread =3D testDomainDelIOThread, /* 7.8.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ .nodeGetSecurityModel =3D testNodeGetSecurityModel, /* 7.5.0 */ .domainGetXMLDesc =3D testDomainGetXMLDesc, /* 0.1.4 */ --=20 2.33.0 From nobody Mon May 6 12:08:25 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 1631719981852627.0224552834925; Wed, 15 Sep 2021 08:33:01 -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-542-m8S59PR6M5eyjmmQHFMpjg-1; Wed, 15 Sep 2021 11:32:55 -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 A02D9108469A; Wed, 15 Sep 2021 15:32:48 +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 562D58400E; Wed, 15 Sep 2021 15:32:48 +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 1C850180142F; Wed, 15 Sep 2021 15:32:48 +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 18FFVBH2028890 for ; Wed, 15 Sep 2021 11:31:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id E70A4208747E; Wed, 15 Sep 2021 15:31:10 +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 E3047208747A for ; Wed, 15 Sep 2021 15:31:05 +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 28745185A79C for ; Wed, 15 Sep 2021 15:31:05 +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-579-hU7bTGfAOlSeMso4YTU-pA-1; Wed, 15 Sep 2021 11:31:03 -0400 Received: by mail-pj1-f50.google.com with SMTP id on12-20020a17090b1d0c00b001997c60aa29so4349741pjb.1 for ; Wed, 15 Sep 2021 08:31:02 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id g24sm317743pfk.52.2021.09.15.08.31.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:31:01 -0700 (PDT) X-MC-Unique: m8S59PR6M5eyjmmQHFMpjg-1 X-MC-Unique: hU7bTGfAOlSeMso4YTU-pA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P2zBR2/6V/3NqkFT0i1DeZjVZJlaRNUhG/zXPZCAyPU=; b=h4PGM8ps4BkMAn0AQfi/GkRiDrAiB/UbBrzuI98+SNOPDS/4QNHLLxQPranIe1L6zc g1vwSoCF+TG0xGUg1eskS4LBpcAOEU3ErITdToYrql43c6n9uA71aMRrWvF7lsF7ixji JQkaFBHwcYYenIJdbfgMQsKud36pEmEtCwomn5/uPk3Qi+aRFgWZOI9+tm+eTLCUVLKZ k7mgMqoWdtobzIWhIb/rfiykx5Fbh6XOOuNriYfDhwIcz/g1BXz8/S5seUUoH7VxuDpF d2hHXNfoSR0U0ZYzC3lxx16yn3KSt9PMZOkFY+p8OqGT2ul/QZo3ZrVPGHGWRud7oO59 ibDw== X-Gm-Message-State: AOAM5307mbJMb89vRul9jHGWMmTgoYQsmVvKioWdWOwb5Wnf5LGQS0Bm lzdABqF5F+qhXnr4eW/f/IZVj9ZxJLdf2z+exmY= X-Google-Smtp-Source: ABdhPJzElXPI40x27c7mCHdsfxxAZsDRgcOYgUjVbxK0Ui6cb6jCIRv0wL7Of9Oo5Cr1F+bMOcaMmQ== X-Received: by 2002:a17:90a:af86:: with SMTP id w6mr454729pjq.8.1631719861545; Wed, 15 Sep 2021 08:31:01 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 05/11] domain_driver.c: Introduce and use virDomainDriverGetIOThreadsConfig() Date: Wed, 15 Sep 2021 23:30:26 +0800 Message-Id: <20210915153032.121221-6-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631719982268100001 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. Also add a new parameter `bitmap_size` to the function, it's used for specifying the bitmap size of the bitmap to generate, it would be helpful for test driver or some special situation. Signed-off-by: Luke Yue Reviewed-by: Michal Privoznik --- src/hypervisor/domain_driver.c | 68 ++++++++++++++++++++++++++++++++++ src/hypervisor/domain_driver.h | 4 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 53 +------------------------- 4 files changed, 74 insertions(+), 52 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 3eb2401053..31737b0f4a 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -576,3 +576,71 @@ virDomainDriverDelIOThreadCheck(virDomainDef *def, =20 return 0; } + +/** + * virDomainDriverGetIOThreadsConfig: + * @targetDef: domain definition + * @info: information about the IOThread in a domain + * @bitmap_size: generate bitmap with bitmap_size, 0 for getting the size + * from host + * + * Returns the number of IOThreads in the given domain or -1 in case of er= ror + */ +int +virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info, + unsigned int bitmap_size) +{ + virDomainIOThreadInfoPtr *info_ret =3D NULL; + virBitmap *bitmap =3D NULL; + virBitmap *cpumask =3D NULL; + size_t i; + int ret =3D -1; + + if (targetDef->niothreadids =3D=3D 0) + return 0; + + info_ret =3D g_new0(virDomainIOThreadInfoPtr, targetDef->niothreadids); + + for (i =3D 0; i < targetDef->niothreadids; i++) { + info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); + + /* IOThread ID's are taken from the iothreadids list */ + info_ret[i]->iothread_id =3D targetDef->iothreadids[i]->iothread_i= d; + + cpumask =3D targetDef->iothreadids[i]->cpumask; + if (!cpumask) { + if (targetDef->cpumask) { + cpumask =3D targetDef->cpumask; + } else { + if (bitmap_size) { + if (!(bitmap =3D virBitmapNew(bitmap_size))) + goto cleanup; + virBitmapSetAll(bitmap); + } else { + if (!(bitmap =3D virHostCPUGetAvailableCPUsBitmap())) + goto cleanup; + } + cpumask =3D bitmap; + } + } + if (virBitmapToData(cpumask, &info_ret[i]->cpumap, + &info_ret[i]->cpumaplen) < 0) + goto cleanup; + virBitmapFree(bitmap); + bitmap =3D NULL; + } + + *info =3D g_steal_pointer(&info_ret); + ret =3D targetDef->niothreadids; + + cleanup: + if (info_ret) { + for (i =3D 0; i < targetDef->niothreadids; i++) + virDomainIOThreadInfoFree(info_ret[i]); + VIR_FREE(info_ret); + } + virBitmapFree(bitmap); + + return ret; +} diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index d91d21bc91..7b0fbae2fd 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -66,3 +66,7 @@ int virDomainDriverAddIOThreadCheck(virDomainDef *def, =20 int virDomainDriverDelIOThreadCheck(virDomainDef *def, unsigned int iothread_id); + +int virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, + virDomainIOThreadInfoPtr **info, + unsigned int bitmap_size); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d45b644caf..bcc413be02 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1541,6 +1541,7 @@ virDomainDriverAddIOThreadCheck; virDomainDriverDelIOThreadCheck; virDomainDriverGenerateMachineName; virDomainDriverGenerateRootHash; +virDomainDriverGetIOThreadsConfig; virDomainDriverMergeBlkioDevice; virDomainDriverNodeDeviceDetachFlags; virDomainDriverNodeDeviceGetPCIInfo; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f2acb37c76..54b8529d88 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5032,57 +5032,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, @@ -5109,7 +5058,7 @@ qemuDomainGetIOThreadInfo(virDomainPtr dom, if (!targetDef) ret =3D qemuDomainGetIOThreadsLive(driver, vm, info); else - ret =3D qemuDomainGetIOThreadsConfig(targetDef, info); + ret =3D virDomainDriverGetIOThreadsConfig(targetDef, info, 0); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.33.0 From nobody Mon May 6 12:08:25 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 1631719887285570.9002974784839; Wed, 15 Sep 2021 08:31:27 -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-290-r8qt5MLdNDi-0Ta3j1ThCA-1; Wed, 15 Sep 2021 11:31:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B38AD84A5E8; Wed, 15 Sep 2021 15:31:17 +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 9256E60C81; Wed, 15 Sep 2021 15:31:17 +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 540C54EA2F; Wed, 15 Sep 2021 15:31:17 +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 18FFV9bl028884 for ; Wed, 15 Sep 2021 11:31:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8682F2087A21; Wed, 15 Sep 2021 15:31:09 +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 820BB208747A for ; Wed, 15 Sep 2021 15:31:09 +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 61A0318A01A5 for ; Wed, 15 Sep 2021 15:31:09 +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-223-Ov5qI9vxNlWAN0YmTQ29ug-1; Wed, 15 Sep 2021 11:31:06 -0400 Received: by mail-pj1-f43.google.com with SMTP id g13-20020a17090a3c8d00b00196286963b9so5209028pjc.3 for ; Wed, 15 Sep 2021 08:31:05 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id d16sm124077pjd.54.2021.09.15.08.31.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:31:04 -0700 (PDT) X-MC-Unique: r8qt5MLdNDi-0Ta3j1ThCA-1 X-MC-Unique: Ov5qI9vxNlWAN0YmTQ29ug-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4H6bPpyZKElbDEYalROcqeKjXgiT+jGarnAOeUbTA/I=; b=hVsoKuf/V5XWEiU5OVLCbrlABmom5nR3yx55jUTOUg8LHUaWD7cWlocaRs3x0pIUx4 1NOUQ53l2EOebdvKxBFbYk5GDnuhmwKMey3H1fz+5d/lBP4xZNa0+WIfOuGpwgsp6Ols kRQfU7W2EbCdv4cqLuamqvyUPCboa8uXvI3yljiuEZhGRuK66757EGdhBEBTgMNHmPrx uR+IsMDwG59MlCJeyRzRYTCizN2fzaZunicjBRc3CIJUM5FYQwSZOj2pA0ckiZx0ISvI tTgzsbH3iVsr+2OD4+PAw6Cdv2O2haOLof7YcaFdkF95XZB09tF/THeVUWtOwCi0UGct rNwg== X-Gm-Message-State: AOAM532fjocfxA1usqqMMSOI/248asZsvYhbsmKTCidC/FZhBG+Oxksy PdbyyqXLxvYbuyorvmuESIrzUxQFI5JfKq8qfXw= X-Google-Smtp-Source: ABdhPJwsccf8B+upAHymyNmXQtdBj9RDxUyYD6St5UMYcH6gMzZ87prf5CsvcQc7SGOtgff8YRLDRQ== X-Received: by 2002:a17:90a:44:: with SMTP id 4mr428913pjb.130.1631719864537; Wed, 15 Sep 2021 08:31:04 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 06/11] test_driver: Implement virDomainGetIOThreadInfo Date: Wed, 15 Sep 2021 23:30:27 +0800 Message-Id: <20210915153032.121221-7-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-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.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631719890154100001 Content-Type: text/plain; charset="utf-8" If we use test driver on different machines, and use 0 as bitmap_size for virDomainDriverGetIOThreadsConfig(), we would get different results for the `CPU Affinity`, because it's depending on the host CPU's bitmap. In order to get a stable result for testing, use result of virDomainDefGetVcpus() as bitmap_size instead. Signed-off-by: Luke Yue Reviewed-by: Michal Privoznik --- src/test/test_driver.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b588bbc32e..0971661c89 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9586,6 +9586,34 @@ testDomainGetMessages(virDomainPtr dom, return rv; } =20 +static int +testDomainGetIOThreadInfo(virDomainPtr dom, + virDomainIOThreadInfoPtr **info, + unsigned int flags) +{ + virDomainObj *vm; + virDomainDef *targetDef =3D NULL; + unsigned int bitmap_size =3D 0; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (!(targetDef =3D virDomainObjGetOneDef(vm, flags))) + goto cleanup; + + bitmap_size =3D virDomainDefGetVcpus(targetDef); + + ret =3D virDomainDriverGetIOThreadsConfig(targetDef, info, bitmap_size= ); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, VIR_DOMAIN_IOTHREAD_ACTION_DEL, @@ -9781,6 +9809,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.8.0 */ .domainAddIOThread =3D testDomainAddIOThread, /* 7.8.0 */ .domainDelIOThread =3D testDomainDelIOThread, /* 7.8.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ --=20 2.33.0 From nobody Mon May 6 12:08:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 1631719926188481.0867328110088; Wed, 15 Sep 2021 08:32:06 -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-6-A-fIy32QNRCHE4XGpcG2jg-1; Wed, 15 Sep 2021 11:31:29 -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 0BD5A100CCC4; Wed, 15 Sep 2021 15:31:23 +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 C4E706D987; Wed, 15 Sep 2021 15:31:20 +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 777274EA3A; Wed, 15 Sep 2021 15:31:20 +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 18FFVB4g028891 for ; Wed, 15 Sep 2021 11:31:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1AA70208747B; Wed, 15 Sep 2021 15:31:11 +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 16A172087A23 for ; Wed, 15 Sep 2021 15:31:11 +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 F370A91C7D3 for ; Wed, 15 Sep 2021 15:31:10 +0000 (UTC) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-56--LRV_XAsNNaIRn781IUf5Q-1; Wed, 15 Sep 2021 11:31:09 -0400 Received: by mail-pg1-f177.google.com with SMTP id e7so3090946pgk.2 for ; Wed, 15 Sep 2021 08:31:08 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id g11sm332141pgn.41.2021.09.15.08.31.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:31:07 -0700 (PDT) X-MC-Unique: A-fIy32QNRCHE4XGpcG2jg-1 X-MC-Unique: -LRV_XAsNNaIRn781IUf5Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AYfQu4KYTAhgGcquOrISnJieYS2D53+Hl/gd7FzwRic=; b=rX3s8CBJl7rBfh/YhOrqdHENah8JP1c8sMyW2LmZy4F2UERxjy5SETxwz3dff7E6Lz o8PkxywYzlAmUcd+gjp9H4WejT4B22izJD8G7dL6jsw+n0dvRID6zDX64yEby/z/JmPU bbyJ3YFIG0GGJV9Gda5H+d7Inr98jmxgOedI+LmVuUHMDLBdt/0xWdL60vWV9Oa/WTnY Eq09eSTum7cqz4uMVo7bZbhz7ezCJzyxoVxOAE3HjYkH0cCV+x8qMzl1nRkDZ7hO/odX bGuD/K7NGhKn3FWckM+G30NYNzAkftPa/ZtA6yCV4ac/EWkzVTfoZSJhzFL74vU20XGD DMrA== X-Gm-Message-State: AOAM5312DUqcCs0peAa/31g0Gv/onwm8eD2LPWplBPc/+2OHs+3WBUoG CQAK/xh4dOQde8kFjBl8TcsRcPJ6j8yybms8 X-Google-Smtp-Source: ABdhPJyRxKe2lxz0VGY6e684En8AmY9WNX+Ay77gNRStiYiOKWmaIp7xyp7vU/wo4bqMVJzAAmxGuA== X-Received: by 2002:a62:ddd8:0:b0:435:4de8:2652 with SMTP id w207-20020a62ddd8000000b004354de82652mr104411pff.53.1631719867699; Wed, 15 Sep 2021 08:31:07 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 07/11] test_driver: Implement virDomainPinIOThread Date: Wed, 15 Sep 2021 23:30:28 +0800 Message-Id: <20210915153032.121221-8-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-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.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: 1631719927748100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue Reviewed-by: Michal Privoznik --- 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 0971661c89..43c0822c87 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9743,6 +9743,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 */ @@ -9812,6 +9861,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetIOThreadInfo =3D testDomainGetIOThreadInfo, /* 7.8.0 */ .domainAddIOThread =3D testDomainAddIOThread, /* 7.8.0 */ .domainDelIOThread =3D testDomainDelIOThread, /* 7.8.0 */ + .domainPinIOThread =3D testDomainPinIOThread, /* 7.8.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ .nodeGetSecurityModel =3D testNodeGetSecurityModel, /* 7.5.0 */ .domainGetXMLDesc =3D testDomainGetXMLDesc, /* 0.1.4 */ --=20 2.33.0 From nobody Mon May 6 12:08:25 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 163171988860428.274383016274555; Wed, 15 Sep 2021 08:31:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-137-Abf6ZQqXNImb54_vZiJQJA-1; Wed, 15 Sep 2021 11:31:26 -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 2A88BA0CD2; Wed, 15 Sep 2021 15:31:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 095545C3DF; Wed, 15 Sep 2021 15:31:19 +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 C78A14EA38; Wed, 15 Sep 2021 15:31:18 +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 18FFVH39028950 for ; Wed, 15 Sep 2021 11:31:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 381CCDEE85; Wed, 15 Sep 2021 15:31:17 +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 32AC3DEED7 for ; Wed, 15 Sep 2021 15:31: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 0F4FB101A529 for ; Wed, 15 Sep 2021 15:31:14 +0000 (UTC) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-eyQxZecXNRuar_t_mI4MBw-1; Wed, 15 Sep 2021 11:31:12 -0400 Received: by mail-pj1-f53.google.com with SMTP id j1so2390977pjv.3 for ; Wed, 15 Sep 2021 08:31:12 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id i8sm309879pfo.117.2021.09.15.08.31.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:31:09 -0700 (PDT) X-MC-Unique: Abf6ZQqXNImb54_vZiJQJA-1 X-MC-Unique: eyQxZecXNRuar_t_mI4MBw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wL5SXtWr/pBo+ikOFqeJ8AsLglmSorrYOXecUO5m0Tg=; b=4EJ0WUuP9FKc8TVCXoqS5cPMQxxp1z60+uDtf5cFQmKClOOtpPpaC4myO2jMJvP9cu tI7y5kEAQPmf23p4nPeKJ4Yrx9hWLlmLIsVP33JuRWM0nNGePrzCtYinitEkZ5xi0KWx 65qiyfsWbCAFQogL+WcAHV+yZDQUxj5SHXOF+OzByNYxNf5MUHZqoqkGtEvWqs3PI0E9 edrO/MeYMcXRHG/qFUrLWZwMyMuaxXPiVRbv24N5C2bB10FfeWtl0HzXMu0CXyC/aJAS oK3oQOzIPp0t3+gbS4sPac5NoX1wR6Cwxp7qw357QemLUqZcFgAWrgiKDavFuYoRPWg4 Qaxg== X-Gm-Message-State: AOAM533K0+0VxuHeJYDBEB+EQqzgt3mWnpn+KyeimLR2ipwKdB9weuih dwwufpMH2nnXPDBXNwHNuZW+eMDshbwBZ8tGPTk= X-Google-Smtp-Source: ABdhPJyvkG0mZDmdQeyzhvnxMLLRkfOdamR7TcIwa+L/gs/+ZrEgDcaSutyWeEp1C/AlbRhWMW4qOw== X-Received: by 2002:a17:90a:29a4:: with SMTP id h33mr436863pjd.88.1631719870282; Wed, 15 Sep 2021 08:31:10 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 08/11] test_driver: Implement testDomainSetIOThreadParams Date: Wed, 15 Sep 2021 23:30:29 +0800 Message-Id: <20210915153032.121221-9-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-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: 1631719891970100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue Reviewed-by: Michal Privoznik --- 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 43c0822c87..7cff26776a 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9617,6 +9617,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 @@ -9648,6 +9649,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; } } @@ -9792,6 +9803,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 */ @@ -9862,6 +9951,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainAddIOThread =3D testDomainAddIOThread, /* 7.8.0 */ .domainDelIOThread =3D testDomainDelIOThread, /* 7.8.0 */ .domainPinIOThread =3D testDomainPinIOThread, /* 7.8.0 */ + .domainSetIOThreadParams =3D testDomainSetIOThreadParams, /* 7.8.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ .nodeGetSecurityModel =3D testNodeGetSecurityModel, /* 7.5.0 */ .domainGetXMLDesc =3D testDomainGetXMLDesc, /* 0.1.4 */ --=20 2.33.0 From nobody Mon May 6 12:08:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 1631719891972697.2571722929746; Wed, 15 Sep 2021 08:31:31 -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-43-kXski1R4OtyRYSVwxsfnmA-1; Wed, 15 Sep 2021 11:31:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F74E100CCC9; Wed, 15 Sep 2021 15:31:24 +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 E09BF60C81; Wed, 15 Sep 2021 15:31:23 +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 AB4C1181A1CF; Wed, 15 Sep 2021 15:31:23 +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 18FFVLrd028996 for ; Wed, 15 Sep 2021 11:31:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 091BB2121C37; Wed, 15 Sep 2021 15:31:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 029032121C39 for ; Wed, 15 Sep 2021 15:31:18 +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 2103A8934E1 for ; Wed, 15 Sep 2021 15:31:18 +0000 (UTC) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-iS5eHfOjPVemfggvloZ_6g-1; Wed, 15 Sep 2021 11:31:14 -0400 Received: by mail-pf1-f174.google.com with SMTP id y17so2935269pfl.13 for ; Wed, 15 Sep 2021 08:31:14 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id b20sm298910pfl.9.2021.09.15.08.31.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:31:12 -0700 (PDT) X-MC-Unique: kXski1R4OtyRYSVwxsfnmA-1 X-MC-Unique: iS5eHfOjPVemfggvloZ_6g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ezW5zRfspp1V/4FmiQQS+v9DncJeA+0XL2quRzc1iFU=; b=DIp+rIi+8V1gpVEyBIaJbC7q08ZfqNNqg7cuCZwIKZLVHkBkPhi9w+51HfQgQgtVU7 lZezoCY6lc7hKO6CXWPk3+Bmx6WU5IVVec5yEkzJaohYCFh6E1F/uLK2fI5EGBfl8Dyf +UA5GxlJK143dLdx37sfBcea8Q8APTsPrJUiDngKN8STs9w4gx1V2eMe0z48KSjWO8Km iiSHGuECk6TtexPo2j5wxY6QyR8DGrBSU3qkHZATWsY70HpHg5ObqEuyqsPO9HKBmxx4 dpNvUP7LuPRUnW0cj/J3f27en5UfxS3RyG8y0eKUPQEJ9L3H75EPgI8toyRvPcm7IHp0 15tw== X-Gm-Message-State: AOAM533GPBUnodkipnMzGRbr0DOZmR9YUKwSEVBG3wloqVVBn/734D6r Nykfmyue6USjVrYpvlSC7S0GrnDN4OangN61atw= X-Google-Smtp-Source: ABdhPJz6r95rWkC+7Kvfb8Rz7aX23/rJkMipFarBr4idA3tb/0mSE6cffVblfDCKX9dtUSNNn097CQ== X-Received: by 2002:a63:3587:: with SMTP id c129mr318105pga.127.1631719873291; Wed, 15 Sep 2021 08:31:13 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 09/11] test_driver: Implement virConnectGetAllDomainStats Date: Wed, 15 Sep 2021 23:30:30 +0800 Message-Id: <20210915153032.121221-10-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631719894394100001 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 Reviewed-by: Michal Privoznik --- src/test/test_driver.c | 137 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7cff26776a..a6f7de2ccd 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9881,6 +9881,142 @@ testDomainSetIOThreadParams(virDomainPtr dom, return ret; } =20 +static int +testDomainGetStatsState(virDomainObj *dom, + virTypedParamList *params) +{ + if (virTypedParamListAddInt(params, dom->state.state, "state.state") <= 0) + return -1; + + if (virTypedParamListAddInt(params, dom->state.reason, "state.reason")= < 0) + return -1; + + return 0; +} + +typedef int +(*testDomainGetStatsFunc)(virDomainObj *dom, + virTypedParamList *list); + +struct testDomainGetStatsWorker { + testDomainGetStatsFunc func; + unsigned int stats; +}; + +static struct testDomainGetStatsWorker testDomainGetStatsWorkers[] =3D { + { testDomainGetStatsState, VIR_DOMAIN_STATS_STATE }, + { NULL, 0 } +}; + +static int +testDomainGetStats(virConnectPtr conn, + virDomainObj *dom, + unsigned int stats, + virDomainStatsRecordPtr *record) +{ + g_autofree virDomainStatsRecordPtr tmp =3D NULL; + g_autoptr(virTypedParamList) params =3D NULL; + size_t i; + + params =3D g_new0(virTypedParamList, 1); + + for (i =3D 0; testDomainGetStatsWorkers[i].func; i++) { + if (stats & testDomainGetStatsWorkers[i].stats) { + if (testDomainGetStatsWorkers[i].func(dom, params) < 0) + return -1; + } + } + + tmp =3D g_new0(virDomainStatsRecord, 1); + + if (!(tmp->dom =3D virGetDomain(conn, dom->def->name, + dom->def->uuid, dom->def->id))) + return -1; + + tmp->nparams =3D virTypedParamListStealParams(params, &tmp->params); + *record =3D g_steal_pointer(&tmp); + return 0; +} + +static int +testConnectGetAllDomainStats(virConnectPtr conn, + virDomainPtr *doms, + unsigned int ndoms, + unsigned int stats, + virDomainStatsRecordPtr **retStats, + unsigned int flags) +{ + testDriver *driver =3D conn->privateData; + unsigned int lflags =3D flags & (VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTI= VE | + VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSIS= TENT | + VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE); + + unsigned int supported =3D VIR_DOMAIN_STATS_STATE; + virDomainObj **vms =3D NULL; + size_t nvms; + virDomainStatsRecordPtr *tmpstats =3D NULL; + int nstats =3D 0; + int ret =3D -1; + size_t i; + + virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE | + VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT | + VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE | + VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT | + VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING | + VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, -1); + + if (!stats) { + stats =3D supported; + } else if ((flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS) && + (stats & ~supported)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("Stats types bits 0x%x are not supported by this = daemon"), + stats & ~supported); + return -1; + } + + if (ndoms) { + if (virDomainObjListConvert(driver->domains, conn, doms, ndoms, &v= ms, + &nvms, NULL, lflags, true) < 0) + return -1; + } else { + if (virDomainObjListCollect(driver->domains, conn, &vms, &nvms, + NULL, lflags) < 0) + return -1; + } + + tmpstats =3D g_new0(virDomainStatsRecordPtr, nvms + 1); + + for (i =3D 0; i < nvms; i++) { + virDomainStatsRecordPtr tmp =3D NULL; + virDomainObj *vm =3D vms[i]; + + virObjectLock(vm); + + if ((testDomainGetStats(conn, vm, stats, &tmp)) < 0) { + virObjectUnlock(vm); + goto cleanup; + } + + virObjectUnlock(vm); + + if (!tmp) + goto cleanup; + + tmpstats[nstats++] =3D tmp; + } + + *retStats =3D g_steal_pointer(&tmpstats); + ret =3D nstats; + + cleanup: + virDomainStatsRecordListFree(tmpstats); + virObjectListFreeCount(vms, nvms); + + return ret; +} + /* * Test driver */ @@ -9895,6 +10031,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.8.0 */ .connectGetCapabilities =3D testConnectGetCapabilities, /* 0.2.1 */ .connectGetSysinfo =3D testConnectGetSysinfo, /* 2.3.0 */ .connectGetType =3D testConnectGetType, /* 2.3.0 */ --=20 2.33.0 From nobody Mon May 6 12:08:25 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 16317199852711005.9743698601884; Wed, 15 Sep 2021 08:33:05 -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-83-29YYjoptPciHG39kkNAZzQ-1; Wed, 15 Sep 2021 11:33:02 -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 57D0B802C80; Wed, 15 Sep 2021 15:32:57 +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 E61AC18B5E; Wed, 15 Sep 2021 15:32:56 +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 A31041803B30; Wed, 15 Sep 2021 15:32:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18FFVPjw029060 for ; Wed, 15 Sep 2021 11:31:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 82DA5114C936; Wed, 15 Sep 2021 15:31:25 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7E1A91010BA6 for ; Wed, 15 Sep 2021 15:31:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C29ED8934E7 for ; Wed, 15 Sep 2021 15:31:19 +0000 (UTC) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-195-beR1N4wcPsupITDgOC9gMw-1; Wed, 15 Sep 2021 11:31:18 -0400 Received: by mail-pj1-f44.google.com with SMTP id m21-20020a17090a859500b00197688449c4so2537098pjn.0 for ; Wed, 15 Sep 2021 08:31:17 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id h4sm148752pjc.28.2021.09.15.08.31.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:31:15 -0700 (PDT) X-MC-Unique: 29YYjoptPciHG39kkNAZzQ-1 X-MC-Unique: beR1N4wcPsupITDgOC9gMw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ii3AnbsQCxYq07v8bLfHB/oHpWVLzAfqkT/txcl8tLE=; b=Nr0di2tgbrVEMNJnqn3qN+L143a0W2AQM80FErCl4d1Git5/TWWarUfapWlLPZD0v0 ADAtN6+UU1AfxZ4PGpZFxQUtk21/vksWQvJtSUafrnEL3ccOCMnyhuh8NoKz1ItpcYgu b2XmSlx1lfIzn9xRqLVPPIrZ8809kNwvkK9O1+uzRwhO02ny7i/P+kdLKxT3WV3nPZ+M 27EDIO/HJc6ywWUqPQPPr3ui5SyPlbwfu3t8IfJaqpz5ZotUb5TTS+vOwWxV6FXF4HRw 2228/x8O/Ep1oS/wLQGf+OlrzdXn2RxsASRBKmpWGpMFtQ24ERxoZsAeHFz8JJrrsiav S8SA== X-Gm-Message-State: AOAM533oFYbFlVQ+GGbUtQd9C65tRspYBlxI4fuZSoStbkwU5BgBDpVd GtuqP58Wnj/CBaMBabPUqWWAMi57t7BF0wm70io= X-Google-Smtp-Source: ABdhPJy16IYXjd/DDkDDeDPewMUdMRIrXGcAHKvoBHGjU13derV9PBJz3Lx4mlBTmRO24iRyd73YOQ== X-Received: by 2002:a17:90a:1d4c:: with SMTP id u12mr376554pju.95.1631719876259; Wed, 15 Sep 2021 08:31:16 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 10/11] test_driver: Introduce testDomainGetStatsIOThread Date: Wed, 15 Sep 2021 23:30:31 +0800 Message-Id: <20210915153032.121221-11-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631719986770100001 Content-Type: text/plain; charset="utf-8" Introduce testDomainGetStatsIOThread to add support for testConnectGetAllDomainStats to get IOThread infos. Signed-off-by: Luke Yue Reviewed-by: Michal Privoznik --- 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 a6f7de2ccd..d9b0578e13 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9894,6 +9894,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); @@ -9905,6 +9945,7 @@ struct testDomainGetStatsWorker { =20 static struct testDomainGetStatsWorker testDomainGetStatsWorkers[] =3D { { testDomainGetStatsState, VIR_DOMAIN_STATS_STATE }, + { testDomainGetStatsIOThread, VIR_DOMAIN_STATS_IOTHREAD }, { NULL, 0 } }; =20 @@ -9951,7 +9992,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.33.0 From nobody Mon May 6 12:08:25 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 1631719988551137.45404075383692; Wed, 15 Sep 2021 08:33:08 -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-154-4QQK_nWtNE2s0dCGW_ZR4A-1; Wed, 15 Sep 2021 11:33:05 -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 5011EA40C0; Wed, 15 Sep 2021 15:32:55 +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 75ACE6B555; Wed, 15 Sep 2021 15:32:52 +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 430714EA3E; Wed, 15 Sep 2021 15:32:52 +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 18FFVNgj029031 for ; Wed, 15 Sep 2021 11:31:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F6BE208747C; Wed, 15 Sep 2021 15:31:23 +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 4B6B5208747B for ; Wed, 15 Sep 2021 15:31:23 +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 3103C91C7C7 for ; Wed, 15 Sep 2021 15:31:23 +0000 (UTC) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-36GJQDwAMOemvRhnvxYqsA-1; Wed, 15 Sep 2021 11:31:20 -0400 Received: by mail-pg1-f173.google.com with SMTP id k24so3073003pgh.8 for ; Wed, 15 Sep 2021 08:31:20 -0700 (PDT) Received: from localhost ([103.149.249.103]) by smtp.gmail.com with ESMTPSA id z14sm313121pfr.154.2021.09.15.08.31.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 08:31:18 -0700 (PDT) X-MC-Unique: 4QQK_nWtNE2s0dCGW_ZR4A-1 X-MC-Unique: 36GJQDwAMOemvRhnvxYqsA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NhvD24HWrza6PS/mB19gwNFD7aH4uD6Y5zCd7wbx83I=; b=Zu5hTv0vqNq0CMrYxOYJK/78Y1OVNMcxNhBsoxT176QneMJamSHjh2ouZFs3ui1cW2 GOmnGyyejadorIcrOFkEx209AWpVFesUd4wj7eYD5ktzs6eeI7yrMKC+Ue5OsZvkO8cn 7xQtakhxCJO4wyy9Z5m3TQGmsLJBUH/d4EhfEoOYHUkHFbbu2sMtpKdvpsrnP5M8QIqW NddX4r9ucLocCWXIgcjJHT2bKD6qsDOs9JL24RlQaOk6/K43GVk1uYB7OY51iJP83fbm aq7PP6VIlFRKo8Yw/ERNwUTww6ddM4mXbZhH9M+u0lRUSHlBc9nynuA9h/FNG+EODsTW 9xNQ== X-Gm-Message-State: AOAM5317jysy4O2RRsvfkt5J3BhMcqdf0HLdTvbsv7avHP09yEcmoeHY RNhuFzB5ruJegEzdVcHvShSeejpq9nRcwh06 X-Google-Smtp-Source: ABdhPJzmzc1HkFeiVwwwodMXK6Ns+1ZjehWw/2CfxaGfNvWvStDBqDc2uxZNo5QnS1B6Ahoiy3dkeA== X-Received: by 2002:a62:8801:0:b0:43e:390:295f with SMTP id l1-20020a628801000000b0043e0390295fmr63811pfd.57.1631719879062; Wed, 15 Sep 2021 08:31:19 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v4 11/11] tests: Test IOThread related functions for test driver Date: Wed, 15 Sep 2021 23:30:32 +0800 Message-Id: <20210915153032.121221-12-lukedyue@gmail.com> In-Reply-To: <20210915153032.121221-1-lukedyue@gmail.com> References: <20210915153032.121221-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.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: 1631719989470100001 Content-Type: text/plain; charset="utf-8" testIOThreadAdd tests iothreadinfo and iothreadadd testIOThreadDel tests iothreadinfo and iothreaddel testIOThreadSet tests domstats and iothreadset testIOThreadPin tests iothreadadd, iothreadinfo and iothreadpin Above tests should cover the IOThreads related APIs for test driver Signed-off-by: Luke Yue Reviewed-by: Michal Privoznik --- tests/virshtest.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/tests/virshtest.c b/tests/virshtest.c index 87da1f5889..c2c892c60d 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -32,6 +32,7 @@ main(void) deprecated configuration: CPU model Deprecated-Test" # define GET_BLKIO_PARAMETER "/dev/hda,700" # define SET_BLKIO_PARAMETER "/dev/hda,1000" +# define EQUAL "=3D" =20 static const char *dominfo_fc4 =3D "\ Id: 2\n\ @@ -338,6 +339,99 @@ static int testCompareSetBlkioParameters(const void *d= ata 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, "iothreadinfo --domain fc= 4;\ + iothreadadd --domain fc4 --id 6;\ + iothreadinfo --domain fc4", NULL}; + const char *exp =3D "\ + IOThread ID CPU Affinity\n\ +-----------------------------\n\ + 2 0\n\ + 4 0\n\ +\n\ +\n\ + IOThread ID CPU Affinity\n\ +-----------------------------\n\ + 2 0\n\ + 4 0\n\ + 6 0\n\ +\n"; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testIOThreadDel(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadinfo --domain fc= 4;\ + iothreaddel --domain fc4 --id 2;\ + iothreadinfo --domain fc4", NULL}; + const char *exp =3D "\ + IOThread ID CPU Affinity\n\ +-----------------------------\n\ + 2 0\n\ + 4 0\n\ +\n\ +\n\ + IOThread ID CPU Affinity\n\ +-----------------------------\n\ + 4 0\n\ +\n"; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testIOThreadSet(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "domstats --domain fc4;\ + iothreadset --domain fc4\ + --id 2 --poll-max-ns 100\ + --poll-shrink 10 --poll-grow 10;\ + domstats --domain fc4", NULL}; + const char *exp =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\ +\n\ +Domain: 'fc4'\n\ + state.state" EQUAL "1\n\ + state.reason" EQUAL "0\n\ + iothread.count" EQUAL "2\n\ + iothread.2.poll-max-ns" EQUAL "100\n\ + iothread.2.poll-grow" EQUAL "10\n\ + iothread.2.poll-shrink" EQUAL "10\n\ + iothread.4.poll-max-ns" EQUAL "32768\n\ + iothread.4.poll-grow" EQUAL "0\n\ + iothread.4.poll-shrink" EQUAL "0\n\n"; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testIOThreadPin(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, + "iothreadadd --domain fc5 --id 2;\ + iothreadinfo --domain fc5;\ + iothreadpin --domain fc5 --iothread 2\ + --cpulist 0;\ + iothreadinfo --domain fc5", NULL}; + const char *exp =3D "\n\ + IOThread ID CPU Affinity\n\ +-----------------------------\n\ + 2 0-3\n\ +\n\ +\n\ + IOThread ID CPU Affinity\n\ +-----------------------------\n\ + 2 0\n\ +\n"; + return testCompareOutputLit(exp, NULL, argv); +} + struct testInfo { const char *const *argv; const char *result; @@ -438,6 +532,22 @@ mymain(void) testCompareSetBlkioParameters, 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 iothreadset", + testIOThreadSet, NULL) !=3D 0) + ret =3D -1; + + if (virTestRun("virsh iothreadpin", + testIOThreadPin, 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.33.0