From nobody Mon Feb 9 00:31:07 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=1564664228; cv=none; d=zoho.com; s=zohoarc; b=neGz4/LH38UmyCk0vK0hywoilnP05zoqGJiVLMNT9cxCfvACUaNvb492u8g7ght1C25DWX+kFyTPmjGnyYOU5Og3tSfQNT1xJQKkKerlBJ57h47QZlsdI2YOPjGdbumw/NCTVNiBE2y5zVb2YR6upBEdOR5M+IOIGzSH7QvsZHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564664228; 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=XoxrhD++H9ySaplMOCHxmxpN6nl4qlpeVNykoXZEzPc=; b=eQTnAQjtLDqOPRSlBqTPF1EIpdU5ZFN/Dgswcg87UQEMgCx8usZgNaOwSLnCdpSyxvpYKlqZbQo5jM2FivG04oWGzvSyV38757KnUS+FDMPwz8ha8ZwGrOnzYO8LItVt9RJNk0XDpvSPE3vFIH8Cf8dy2jEY9ZdCldHJzkt3lUA= 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 1564664228892817.6138652802563; Thu, 1 Aug 2019 05:57:08 -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 AA744C04959E; Thu, 1 Aug 2019 12:57:07 +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 84EF760BF4; Thu, 1 Aug 2019 12:57:07 +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 4C590180B7B0; Thu, 1 Aug 2019 12:57:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x71Cv5J3006286 for ; Thu, 1 Aug 2019 08:57:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id B73926012C; Thu, 1 Aug 2019 12:57:05 +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 B0B6B600F8 for ; Thu, 1 Aug 2019 12:57:03 +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 E5C872CE905 for ; Thu, 1 Aug 2019 12:57:01 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id p17so73466783wrf.11 for ; Thu, 01 Aug 2019 05:57:01 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id h14sm71248878wrs.66.2019.08.01.05.56.59 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 05:56:59 -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=mdF06v1cAfkWOB6ahEJPwAKKuAI/2MCdtOlwB/vvp88=; b=LkrzAuNg/Qia4VWbE0ZkE84HncxHqqJL61rTTDOI5Dp43ea9247VSMlInAgpJ1ylej 256Y+MaJooLFvWddl2WZUjMEgrL1dK3l2oxftZsw+/CNnowQJmgMSEo6ge20FXi+Q24E NHS6XaWhD8tIVc+QG1HCugoKuXexbLpfDUl3WR7WjiNeKJVbLwKeldQu+EctaVFOq8YF dY9dNzDs6lirc9EU9dlViuN5/g5Fxt24cJU3zjDQnPmRgNQslI/fdYMapz9RZR7vvlGM pYps7uT774GITWScllddDrWvrn6b0l+Xai/lTO3Eys1H0DRtrVW2tep+KMX5ONhk4txy /pcw== 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=mdF06v1cAfkWOB6ahEJPwAKKuAI/2MCdtOlwB/vvp88=; b=Jb7x/RVD9fGnC8dqU1DfEiKkWjGFVV8HJnO6UvjkE0BLjHbu7tY7K2lxeGPiaiXtqZ RC+OxuQ3txhi0QhD8rSTRy5ZK1gmrqUOaRz8ufhlhKW2JlsVJBM7TgEi/14T/roEE56P p7Tw3hk1NRJzvnz4A+YQXUc3DeoO0W8sjYwsOaryn+yQ8ylgv0h/j22UazoSQg8W5QPJ 035wRoupRr0Xx/CAhUSrnwo9S1+X+I6siUwpfUU7tck7dK/DhJjeYglZZKdML9d1EDCo AC0z2zsCEZEVal1XzWRIjaVTlGdpJfVgl0Vqlr86wD7CdmaZgyR4ztIjkd9kF8+3vFLq 8qRQ== X-Gm-Message-State: APjAAAWXPpsXCDDB22GpNDd3+RUaWJdLgHRtWR0/9yW5QJ6iXQ3ObhRO B3AgBw2UDbPNFAc8ytX/LSvld4J0m67Ziw== X-Google-Smtp-Source: APXvYqz/Zrx76BXfxO2alVaI5VXqLxXhTdGq9ngKLpT70spkPpJdBr3k4mBKKBb7VBryiHBHtDKZ6w== X-Received: by 2002:adf:e552:: with SMTP id z18mr144459693wrm.45.1564664220176; Thu, 01 Aug 2019 05:57:00 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Thu, 1 Aug 2019 14:54:50 +0200 Message-Id: <20190801125453.27030-4-stamatis.iliass@gmail.com> In-Reply-To: <20190801125453.27030-1-stamatis.iliass@gmail.com> References: <20190801125453.27030-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]); Thu, 01 Aug 2019 12:57:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 01 Aug 2019 12:57:02 +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.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 01 Aug 2019 12:57:08 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis --- 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 784622985c..1d371a5832 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4202,6 +4202,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, @@ -4239,6 +4404,8 @@ testDomainDeviceOperation(testDriverPtr driver, goto cleanup; break; case TEST_DEVICE_DETACH: + if (testDomainDetachDeviceLiveAndConfig(def, dev) < 0) + goto cleanup; break; case TEST_DEVICE_UPDATE: break; @@ -4311,6 +4478,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) { @@ -8959,6 +9136,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainUndefineFlags =3D testDomainUndefineFlags, /* 0.9.4 */ .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