From nobody Wed Apr 24 09:21:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1566069058; cv=none; d=zoho.com; s=zohoarc; b=n54myUby+GT4UXIhCIzPJWv7rp3toIn4SE3fNQ6uxFBmaYOYaVE28/n2uujC2YBq9IY+oChY9WbDpa+UHuf4GIUstFQDXsM0vbPZKeF1EC98UIGuCRR2J84IM+XbJncd7J7L9t/c4PemgVR7vMvmr9dEv+ZLjRyF0h/EDVuuOEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566069058; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=Hj0bsFEpHGJZhOSqO83Nv7RANJvaMS+t0CgTq8UBu3I=; b=aXtKB5w3F9JFt50UoG/qBJfGP4h0l5oA9WqwxWrizKwwT+Pt952y2M+uOy7gL3RLD3snr+Dkg1oYnvpmZXsCWutLJ7zB6TNIpI+Y/gVSCZLflJVhxOrdc8D5Sz5WL8/zqVdQ57iJCv+yySkDUYOz7Kd5EArYQvLGnNMUVZ4EjBI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1566069058561445.17239873694257; Sat, 17 Aug 2019 12:10:58 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 733A93061421; Sat, 17 Aug 2019 19:10:56 +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 41783BA43; Sat, 17 Aug 2019 19:10:43 +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 28C0C4A486; Sat, 17 Aug 2019 19:10:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7HJAa9J007817 for ; Sat, 17 Aug 2019 15:10:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55323BA43; Sat, 17 Aug 2019 19:10:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E23560C18 for ; Sat, 17 Aug 2019 19:10:33 +0000 (UTC) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA51B12BD for ; Sat, 17 Aug 2019 19:10:31 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id i63so6668560wmg.4 for ; Sat, 17 Aug 2019 12:10:31 -0700 (PDT) Received: from archlap.localdomain ([185.32.231.210]) by smtp.gmail.com with ESMTPSA id v12sm9480992wrr.87.2019.08.17.12.10.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2019 12:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=L6z+ghLzEbH/6l3RjWf2heBgxlNx7KOnhrupg3Z9rxU=; b=U4K4d54cKHhNKYK/cs0Z4xXAuI37LnjFOPzyOrxalcQBIE+92Aq1dhFC9ZL/IvEwM8 YhbvcZIk7QeMbGAQ5xz5DLWzJU9ZTg122R6jNUKr4TtfKkqNJeLRJ7fMpkFtOE9o/H9A yrZi/wLr6Mscf33sXaZmpqdwjNO2vP1yX12m0IDEsvm5TzInUcXUAWYPsfmzfc4HBEK/ XRnDPG6tpKdTYBw88q0IMqSDK/0ShYvQFvkgjjDZVA03yGFX6W7PTTG4CY3lAx1r7v05 VcwGirJuRJiWBGvu8oUBnvESVu+l3wNT7kxmxSZX3xVQIR0gyqcH3gfRKK3y4vYYsReS phew== 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:mime-version :content-transfer-encoding; bh=L6z+ghLzEbH/6l3RjWf2heBgxlNx7KOnhrupg3Z9rxU=; b=UmrnnlGjBz/MrCSJbdzg5cioIh3XRIXQOvq1/GOiOX0nOaVF402EZxO2RpQMgRPAiO H3MRyJNaUW9NlzTQje5/xw2n5IepX3Ra4HEB8CDX9R95iZmP7PDP6yi794wlVJ3VKSa4 df2y90VHWLyQdwiPUQgeh5LhTbShVckgTzN54gemjmT2+z56oMy4bIxUKZUATXNYm2HN +M4vZ0eTk9NeMQXuTMNkafB4i9hIQjtm2oVbP7dj6JLl7BJB868O/MKLIfraQ/q6U1aH ch+VJJmv+DXrB08z21WDSbqP+uUo0HxLGUipwklFSRK0o2z/szuJnl+IhjV/G7jzkR1a tF3Q== X-Gm-Message-State: APjAAAUYVZNN72gpe6G9PDCwCIzVOxa34F9DSysYjZtnPzNFwuiOjkaV Hx4ZQYzaJNosP54P1Fjhvozf8aqXgn8= X-Google-Smtp-Source: APXvYqzQdJSNkbuJLuspLiWIttUGfuDdria31+I6nBLLvPPLTxxqrKDK+p/WUOJAs9WTQcWS3qBQRw== X-Received: by 2002:a1c:a008:: with SMTP id j8mr12532289wme.57.1566069029878; Sat, 17 Aug 2019 12:10:29 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Sat, 17 Aug 2019 22:10:21 +0300 Message-Id: <20190817191021.1663-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 17 Aug 2019 19:10:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 17 Aug 2019 19:10:32 +0000 (UTC) for IP:'209.85.128.65' DOMAIN:'mail-wm1-f65.google.com' HELO:'mail-wm1-f65.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.099 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.128.65 mail-wm1-f65.google.com 209.85.128.65 mail-wm1-f65.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] test_driver: implement virDomainSetBlockThreshold 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 17 Aug 2019 19:10:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Store disk name - threshold pairs in vm-private data so they can be retrieved by virConnectGetAllDomainStats later. Signed-off-by: Ilias Stamatis --- src/test/test_driver.c | 91 +++++++++++++++++++++++++++++++++++++++++- src/test/test_driver.h | 9 +++++ 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 9bf3728654..0b4646b0bb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -396,6 +396,10 @@ struct _testDomainObjPrivate { /* used by get/set time APIs */ long long seconds; unsigned int nseconds; + + /* used by domainSetBlockThreshold */ + size_t num_thresholds; + testBlockThresholdPtr *thresholds; }; @@ -413,6 +417,9 @@ testDomainObjPrivateAlloc(void *opaque) priv->seconds =3D 627319920; priv->nseconds =3D 0; + priv->num_thresholds =3D 0; + priv->thresholds =3D NULL; + return priv; } @@ -3974,6 +3981,71 @@ testDomainGetBlockIoTune(virDomainPtr dom, #undef TEST_SET_PARAM +static int +testDomainSetBlockThreshold(virDomainPtr dom, + const char *dev, + unsigned long long threshold, + unsigned int flags) +{ + virDomainObjPtr vm =3D NULL; + virDomainDiskDefPtr disk; + testDomainObjPrivatePtr priv; + testBlockThresholdPtr blockthreshold =3D NULL; + size_t i; + int ret =3D -1; + + virCheckFlags(0, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + if (virDomainObjCheckActive(vm) < 0) + goto cleanup; + + if (!(disk =3D virDomainDiskByName(vm->def, dev, true))) { + virReportError(VIR_ERR_INVALID_ARG, + _("failed to find disk '%s'"), + dev); + goto cleanup; + } + + priv =3D vm->privateData; + + for (i =3D 0; i < priv->num_thresholds; i++) { + if (STREQ(dev, priv->thresholds[i]->name)) { + blockthreshold =3D priv->thresholds[i]; + break; + } + } + + if (blockthreshold !=3D NULL) { + blockthreshold->threshold =3D threshold; + } else { + /* disk not found. add it to the list */ + if (VIR_ALLOC(blockthreshold) < 0) + goto cleanup; + if (VIR_STRDUP(blockthreshold->name, dev) < 0) + goto cleanup; + + blockthreshold->threshold =3D threshold; + + if (VIR_APPEND_ELEMENT(priv->thresholds, priv->num_thresholds, + blockthreshold) < 0) + goto cleanup; + } + + ret =3D 0; + + cleanup: + if (ret < 0 && blockthreshold !=3D NULL) { + VIR_FREE(blockthreshold->name); + VIR_FREE(blockthreshold); + } + virDomainObjEndAPI(&vm); + return ret; +} + + static int testConnectNumOfDefinedDomains(virConnectPtr conn) { testDriverPtr privconn =3D conn->privateData; @@ -5070,10 +5142,12 @@ testDomainDeviceOperation(testDriverPtr driver, virTestDeviceOperation operation, const char *xml, const char *alias, + virDomainObjPtr vm, virDomainDefPtr def) { virDomainDeviceDefPtr dev =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; + size_t i; int ret =3D -1; if (operation =3D=3D TEST_DEVICE_DETACH) @@ -5097,6 +5171,17 @@ testDomainDeviceOperation(testDriverPtr driver, case TEST_DEVICE_DETACH: if (testDomainDetachDeviceLiveAndConfig(def, dev) < 0) goto cleanup; + + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) { + testDomainObjPrivatePtr priv =3D vm->privateData; + + for (i =3D 0; i < priv->num_thresholds; i++) { + if (STREQ(dev->data.disk->dst, priv->thresholds[i]->name))= { + VIR_DELETE_ELEMENT(priv->thresholds[i], i, priv->num_t= hresholds); + break; + } + } + } break; case TEST_DEVICE_UPDATE: if (testDomainUpdateDeviceLiveAndConfig(def, dev) < 0) @@ -5137,12 +5222,13 @@ testDomainAttachDetachUpdateDevice(virDomainPtr dom, goto cleanup; if (persistentDef) { - if (testDomainDeviceOperation(driver, operation, xml, alias, persi= stentDef) < 0) + if (testDomainDeviceOperation(driver, operation, xml, alias, vm, + persistentDef) < 0) goto cleanup; } if (def) { - if (testDomainDeviceOperation(driver, operation, xml, alias, def) = < 0) + if (testDomainDeviceOperation(driver, operation, xml, alias, vm, d= ef) < 0) goto cleanup; } @@ -10001,6 +10087,7 @@ static virHypervisorDriver testHypervisorDriver =3D= { .domainGetInterfaceParameters =3D testDomainGetInterfaceParameters, /*= 5.6.0 */ .domainSetBlockIoTune =3D testDomainSetBlockIoTune, /* 5.7.0 */ .domainGetBlockIoTune =3D testDomainGetBlockIoTune, /* 5.7.0 */ + .domainSetBlockThreshold =3D testDomainSetBlockThreshold, /* 5.7.0 */ .connectListDefinedDomains =3D testConnectListDefinedDomains, /* 0.1.1= 1 */ .connectNumOfDefinedDomains =3D testConnectNumOfDefinedDomains, /* 0.1= .11 */ .domainCreate =3D testDomainCreate, /* 0.1.11 */ diff --git a/src/test/test_driver.h b/src/test/test_driver.h index 8c8a462db7..bcb5ffd7a4 100644 --- a/src/test/test_driver.h +++ b/src/test/test_driver.h @@ -23,4 +23,13 @@ #include "internal.h" + +typedef struct _testBlockThreshold testBlockThreshold; +typedef testBlockThreshold *testBlockThresholdPtr; + +struct _testBlockThreshold { + char *name; + unsigned long long threshold; +}; + int testRegister(void); -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list