From nobody Wed Feb 11 02:06:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1625567572376441.9492558987446; Tue, 6 Jul 2021 03:32:52 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-H2dlO6oRMGWUKeBYqtYOwA-1; Tue, 06 Jul 2021 06:32:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E3E91084F57; Tue, 6 Jul 2021 10:32:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20A24608BA; Tue, 6 Jul 2021 10:32:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DFD724EA39; Tue, 6 Jul 2021 10:32:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 166AWE1c022125 for ; Tue, 6 Jul 2021 06:32:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id B6DDF202F2FC; Tue, 6 Jul 2021 10:32:14 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2850202F2FB for ; Tue, 6 Jul 2021 10:32:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 62871866DF1 for ; Tue, 6 Jul 2021 10:32:11 +0000 (UTC) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-CwxN2apSOFSVGkJvG4op2A-1; Tue, 06 Jul 2021 06:32:09 -0400 Received: by mail-pj1-f50.google.com with SMTP id ie21so11531175pjb.0 for ; Tue, 06 Jul 2021 03:32:09 -0700 (PDT) Received: from localhost ([38.94.109.10]) by smtp.gmail.com with ESMTPSA id j16sm18139975pgh.69.2021.07.06.03.32.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 03:32:07 -0700 (PDT) X-MC-Unique: H2dlO6oRMGWUKeBYqtYOwA-1 X-MC-Unique: CwxN2apSOFSVGkJvG4op2A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BIFsUFKZ5y4MfcMPVuR/aincFWmTkb+QrwM+9fJYoKA=; b=U4Ovr34AivHkFQxiTMgKLmpHqv/nEO/p3pW+MJ7vAqatlTc59ZVn9m19+eUrpf2fuV NtcZ2s+zRPKWSpWeg9zVmwKTImvZDV9UVKRNQ1MRrni8Fvg08ehD/nncis0C498d5bZI sj9P7AGj8rmqm75/54AVawCgcwCG3LCzuC0qWIfAYgDYr3Gdd4KStwIfFjjbHaRxxn4f czfxTLmBgjAM6LIzqTJLAE0BV1mJdnGhENZ3Ad6cjw2tuKqml/eP7geik28wu0IHcgV4 hp5FuzDfMa8Oq93QwxV9ocNWkqCsaYJrzkYf8NdP8gRKMlcowZ1gD1rxGn3rLnWpoEV1 RIFA== X-Gm-Message-State: AOAM533YYfBV8eitAysXqHMaRZFliEyn0cIX5mgkoNwoTQH8kU3VQY9R O1rV2dWdXsjQ2vJ/nUI1X7OBmatGpWYyyPBR X-Google-Smtp-Source: ABdhPJzTRJm3wzVX/4rcxGJNrJeSo6tBjEo/pgz5nEW4SaV6Q6hju0fUNQnPxuvEbkQhgVdOUSx50g== X-Received: by 2002:a17:902:7045:b029:129:8507:baf8 with SMTP id h5-20020a1709027045b02901298507baf8mr9522225plt.35.1625567528192; Tue, 06 Jul 2021 03:32:08 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH 2/5] test_driver: Implement virDomainAddIOThread and virDomainDelIOThread Date: Tue, 6 Jul 2021 18:31:55 +0800 Message-Id: <20210706103158.294765-3-lukedyue@gmail.com> In-Reply-To: <20210706103158.294765-1-lukedyue@gmail.com> References: <20210706103158.294765-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1625567577448100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 160 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ef0ddab54d..6573ee3d61 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -182,6 +182,19 @@ struct _testDomainNamespaceDef { xmlNodePtr *snap_nodes; }; =20 +typedef struct _testMonitorIOThreadInfo testMonitorIOThreadInfo; +struct _testMonitorIOThreadInfo { + unsigned int iothread_id; + int thread_id; + bool poll_valid; + unsigned long long poll_max_ns; + unsigned int poll_grow; + unsigned int poll_shrink; + bool set_poll_max_ns; + bool set_poll_grow; + bool set_poll_shrink; +}; + static void testDomainDefNamespaceFree(void *data) { @@ -9291,6 +9304,151 @@ testDomainCheckpointDelete(virDomainCheckpointPtr c= heckpoint, return ret; } =20 +typedef enum { + VIR_DOMAIN_IOTHREAD_ACTION_ADD, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, + VIR_DOMAIN_IOTHREAD_ACTION_MOD, +} virDomainIOThreadAction; + +static int +testDomainChgIOThread(virDomainObj *vm, + testMonitorIOThreadInfo iothread, + virDomainIOThreadAction action, + unsigned int flags) +{ + virDomainDef *def; + virDomainDef *persistentDef; + int ret =3D -1; + + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + return ret; + + if (def) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: + if (virDomainAddIOThreadCheck(def, iothread.iothread_id) < 0) + return ret; + + if (!virDomainIOThreadIDAdd(def, iothread.iothread_id)) + return ret; + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: + if (virDomainDelIOThreadCheck(def, iothread.iothread_id) < 0) + return ret; + + virDomainIOThreadIDDel(def, iothread.iothread_id); + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_MOD: + if (!(virDomainIOThreadIDFind(def, iothread.iothread_id))) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot find IOThread '%u' in iothreadids= "), + iothread.iothread_id); + return ret; + } + + break; + } + } + + if (persistentDef) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: + if (virDomainAddIOThreadCheck(persistentDef, iothread.iothread= _id) < 0) + return ret; + + if (!virDomainIOThreadIDAdd(persistentDef, iothread.iothread_i= d)) + return ret; + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: + if (virDomainDelIOThreadCheck(persistentDef, iothread.iothread= _id) < 0) + return ret; + + virDomainIOThreadIDDel(persistentDef, iothread.iothread_id); + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_MOD: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("configuring persistent polling values is " + "not supported")); + return ret; + + break; + } + } + + ret =3D 0; + + return ret; +} + +static int +testDomainAddIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + testMonitorIOThreadInfo iothread =3D {0}; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (iothread_id =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + return -1; + } + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + iothread.iothread_id =3D iothread_id; + ret =3D testDomainChgIOThread(vm, iothread, + VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + +static int +testDomainDelIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + testMonitorIOThreadInfo iothread =3D {0}; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (iothread_id =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + return -1; + } + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + iothread.iothread_id =3D iothread_id; + ret =3D testDomainChgIOThread(vm, iothread, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + /* * Test driver */ @@ -9356,6 +9514,8 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetVcpus =3D testDomainGetVcpus, /* 0.7.3 */ .domainGetVcpuPinInfo =3D testDomainGetVcpuPinInfo, /* 1.2.18 */ .domainGetMaxVcpus =3D testDomainGetMaxVcpus, /* 0.7.3 */ + .domainAddIOThread =3D testDomainAddIOThread, /* 7.6.0 */ + .domainDelIOThread =3D testDomainDelIOThread, /* 7.6.0 */ .domainGetSecurityLabel =3D testDomainGetSecurityLabel, /* 7.5.0 */ .nodeGetSecurityModel =3D testNodeGetSecurityModel, /* 7.5.0 */ .domainGetXMLDesc =3D testDomainGetXMLDesc, /* 0.1.4 */ --=20 2.32.0