From nobody Sun Feb 8 18:30:16 2026 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=1565801343; cv=none; d=zoho.com; s=zohoarc; b=H3zXIya8mmMHFO5zRF4DWYMfACh0o78m9yjiwrgMPWx6IkvIm6wFKy8PtzRzEDw37pFZN0UL64rUq5Li3c/OesPgfdRbQ5uoIB+98kUPJpwcnGYNGEhrOvEZpjBIGkCJU6t2ylj2wh4udMsGB6cUEsoWhpbEgpGHFwmq6tXFy5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565801343; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ThVKwRbiN9RXJbvMtlpZDVSv27E0N7Y73S1/zjVHw/4=; b=JcvYQdRqTFLxL7VCmiZGoyRrNuRPtbdESwVICUeSb95ZAM57kumjOu0AIUspFJjajlz5ewhsg8WkLZp+VYETA5gMZWKw9pihwXZ2Wmy9Dbok/OmxW1P0ekAF0Y7xCbhNALwjg1IQCxdQOPR5HaXZyUhwr7TNkOLbK9P83p5LOnM= 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 1565801343156967.36553229646; Wed, 14 Aug 2019 09:49:03 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D8CB152136; Wed, 14 Aug 2019 16:49:01 +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 B4E2883090; Wed, 14 Aug 2019 16:49:01 +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 7EB3218005A4; Wed, 14 Aug 2019 16:49:01 +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 x7EGn0QH028151 for ; Wed, 14 Aug 2019 12:49:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 313D9909EA; Wed, 14 Aug 2019 16:49:00 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A932909E5 for ; Wed, 14 Aug 2019 16:48:57 +0000 (UTC) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 9A84030BE7D9 for ; Wed, 14 Aug 2019 16:48:56 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id j16so9486435wrr.8 for ; Wed, 14 Aug 2019 09:48:56 -0700 (PDT) Received: from archlap.localdomain ([185.32.231.210]) by smtp.gmail.com with ESMTPSA id d20sm129372wmb.24.2019.08.14.09.48.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 09:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=x4fDwx2ochry1O9uhe4IXNuYAS/NTUTAYlYuQOziDiA=; b=BXmaqmuejdyZY8UVJkNV/W9Pj25c9mlVCAXUGmnGlPTY0Xf81dzTOyWAGaJyAr4JC1 XuCwNYCY7jBaPz3s8BL16asGNQAigk8ERXyjIdRHenKrgO3cApoqCv/f4UWwaOloPsQM IhMeF3iy/apLzW3X0iRtGyfh9NNLnfXmrwa+r5iNYrZ7E1q/X0MtQBJMDkg26pexjReS Rw/dAUeTioQ9FsyY2I4OX5yudLBGgKyjV2ng874sUDd/OVfg1nKBorrffV8TDV+Y8ZW3 vhHSl3iXy+/PL2bYGGt947GTzVfpczWXMCd0oxCV1MJhLvBKh7S2E26AGDZUgGVMyGUT 7tLA== 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=x4fDwx2ochry1O9uhe4IXNuYAS/NTUTAYlYuQOziDiA=; b=pd8yTiRwX5+TRabx5B53d2E2MqMD+dcdhnxYDdR0C2+ybwhF6SX0YM91n275QuMZIV QKhcOZW/PlrPZx2W+agJMUm2UUiP88Sxzq17iJ+ub8dXmTP8kh7332RXtHMq+6VL2vM0 ECZ/Onp7G/kILlZLKGBWgdkHHj2SU1tCXUvJ8kXRQxjyotvfq0MXPh0rte53sW2/pnbP kPXoUjUtkFdE0788k5Wdy6gIAvWyAfwoVNHgtEfX7Q9powJOlT0BLC9L/S0aEuY1uFuL wnlyS4QMnY0ec+n/x4WcxF7pshbybVmFPhmY2FOL2/X6uMXZ3FgEjHyy4G12GL3pOf43 7F8g== X-Gm-Message-State: APjAAAWTO31h/QjWgTRPNrpf8bIbkfkRjACJE2CLZJIgoiDiEHmtp3Zf RwPi+cUGISWntWzlt2f3bRrmSXU8d5o= X-Google-Smtp-Source: APXvYqz1QfewjQUIf1TaGsiXmBWDw5h72DcNaGkZspRu4Q0xwWqruBFoVk1TrDmGBrJHx8+Vri41cw== X-Received: by 2002:adf:e5c4:: with SMTP id a4mr720606wrn.87.1565801334907; Wed, 14 Aug 2019 09:48:54 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 14 Aug 2019 19:47:07 +0300 Message-Id: <20190814164709.5418-4-stamatis.iliass@gmail.com> In-Reply-To: <20190814164709.5418-1-stamatis.iliass@gmail.com> References: <20190814164709.5418-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.44]); Wed, 14 Aug 2019 16:48:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 14 Aug 2019 16:48:56 +0000 (UTC) for IP:'209.85.221.47' DOMAIN:'mail-wr1-f47.google.com' HELO:'mail-wr1-f47.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.221.47 mail-wr1-f47.google.com 209.85.221.47 mail-wr1-f47.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/6] test_driver: implement virDomainDetachDeviceFlags 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Aug 2019 16:49:02 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 178 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index abf80b97cf..ff9693ccb7 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4834,6 +4834,171 @@ testDomainAttachDeviceLiveAndConfig(virDomainDefPtr= vmdef, } +static int +testDomainDetachDeviceLiveAndConfig(virDomainDefPtr vmdef, + virDomainDeviceDefPtr dev) +{ + virDomainDiskDefPtr disk, detach; + virDomainHostdevDefPtr hostdev, det_hostdev; + virDomainControllerDefPtr cont, det_cont; + virDomainNetDefPtr net; + virDomainLeaseDefPtr lease, det_lease; + virDomainFSDefPtr fs; + virDomainMemoryDefPtr mem; + int idx; + + switch (dev->type) { + case VIR_DOMAIN_DEVICE_DISK: + disk =3D dev->data.disk; + if (!(detach =3D virDomainDiskRemoveByName(vmdef, disk->dst)))= { + virReportError(VIR_ERR_INVALID_ARG, + _("no target device %s"), disk->dst); + return -1; + } + virDomainDiskDefFree(detach); + break; + + case VIR_DOMAIN_DEVICE_CONTROLLER: + cont =3D dev->data.controller; + if ((idx =3D virDomainControllerFind(vmdef, cont->type, + cont->idx)) < 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("device not present in domain configurati= on")); + return -1; + } + det_cont =3D virDomainControllerRemove(vmdef, idx); + virDomainControllerDefFree(det_cont); + break; + + case VIR_DOMAIN_DEVICE_NET: + net =3D dev->data.net; + if ((idx =3D virDomainNetFindIdx(vmdef, net)) < 0) + return -1; + + /* this is guaranteed to succeed */ + virDomainNetDefFree(virDomainNetRemove(vmdef, idx)); + break; + + case VIR_DOMAIN_DEVICE_HOSTDEV: { + hostdev =3D dev->data.hostdev; + if ((idx =3D virDomainHostdevFind(vmdef, hostdev, &det_hostdev= )) < 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("device not present in domain configurati= on")); + return -1; + } + virDomainHostdevRemove(vmdef, idx); + virDomainHostdevDefFree(det_hostdev); + break; + } + + case VIR_DOMAIN_DEVICE_LEASE: + lease =3D dev->data.lease; + if (!(det_lease =3D virDomainLeaseRemove(vmdef, lease))) { + virReportError(VIR_ERR_DEVICE_MISSING, + _("Lease %s in lockspace %s does not exist"= ), + lease->key, NULLSTR(lease->lockspace)); + return -1; + } + virDomainLeaseDefFree(det_lease); + break; + + case VIR_DOMAIN_DEVICE_FS: + fs =3D dev->data.fs; + idx =3D virDomainFSIndexByName(vmdef, fs->dst); + if (idx < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("no matching filesystem device was found"= )); + return -1; + } + + fs =3D virDomainFSRemove(vmdef, idx); + virDomainFSDefFree(fs); + break; + + case VIR_DOMAIN_DEVICE_RNG: + if ((idx =3D virDomainRNGFind(vmdef, dev->data.rng)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("no matching RNG device was found")); + return -1; + } + + virDomainRNGDefFree(virDomainRNGRemove(vmdef, idx)); + break; + + case VIR_DOMAIN_DEVICE_MEMORY: + if ((idx =3D virDomainMemoryFindInactiveByDef(vmdef, + dev->data.memory))= < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("matching memory device was not found")); + return -1; + } + mem =3D virDomainMemoryRemove(vmdef, idx); + vmdef->mem.cur_balloon -=3D mem->size; + virDomainMemoryDefFree(mem); + break; + + case VIR_DOMAIN_DEVICE_REDIRDEV: + if ((idx =3D virDomainRedirdevDefFind(vmdef, + dev->data.redirdev)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("no matching redirdev was not found")); + return -1; + } + + virDomainRedirdevDefFree(virDomainRedirdevDefRemove(vmdef, idx= )); + break; + + case VIR_DOMAIN_DEVICE_SHMEM: + if ((idx =3D virDomainShmemDefFind(vmdef, dev->data.shmem)) < = 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("matching shmem device was not found")); + return -1; + } + + virDomainShmemDefFree(virDomainShmemDefRemove(vmdef, idx)); + break; + + + case VIR_DOMAIN_DEVICE_WATCHDOG: + if (!vmdef->watchdog) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("domain has no watchdog")); + return -1; + } + virDomainWatchdogDefFree(vmdef->watchdog); + vmdef->watchdog =3D NULL; + break; + + case VIR_DOMAIN_DEVICE_INPUT: + if ((idx =3D virDomainInputDefFind(vmdef, dev->data.input)) < = 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("matching input device not found")); + return -1; + } + VIR_DELETE_ELEMENT(vmdef->inputs, idx, vmdef->ninputs); + break; + + case VIR_DOMAIN_DEVICE_VSOCK: + if (!vmdef->vsock || + !virDomainVsockDefEquals(dev->data.vsock, vmdef->vsock)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("matching vsock device not found")); + return -1; + } + virDomainVsockDefFree(vmdef->vsock); + vmdef->vsock =3D NULL; + break; + + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("persistent detach of device is not supported= ")); + return -1; + } + + return 0; +} + + typedef enum { TEST_DEVICE_ATTACH =3D 0, TEST_DEVICE_DETACH, @@ -4871,6 +5036,8 @@ testDomainDeviceOperation(testDriverPtr driver, goto cleanup; break; case TEST_DEVICE_DETACH: + if (testDomainDetachDeviceLiveAndConfig(def, dev) < 0) + goto cleanup; break; case TEST_DEVICE_UPDATE: break; @@ -4943,6 +5110,16 @@ testDomainAttachDevice(virDomainPtr dom, } +static int +testDomainDetachDeviceFlags(virDomainPtr dom, + const char *xml, + unsigned int flags) +{ + return testDomainAttachDetachUpdateDevice(dom, TEST_DEVICE_DETACH, + xml, NULL, flags); +} + + static int testDomainGetAutostart(virDomainPtr domain, int *autostart) { @@ -9749,6 +9926,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainFSTrim =3D testDomainFSTrim, /* 5.7.0 */ .domainAttachDevice =3D testDomainAttachDevice, /* 5.7.0 */ .domainAttachDeviceFlags =3D testDomainAttachDeviceFlags, /* 5.7.0 */ + .domainDetachDeviceFlags =3D testDomainDetachDeviceFlags, /* 5.7.0 */ .domainGetAutostart =3D testDomainGetAutostart, /* 0.3.2 */ .domainSetAutostart =3D testDomainSetAutostart, /* 0.3.2 */ .domainGetDiskErrors =3D testDomainGetDiskErrors, /* 5.4.0 */ -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list