From nobody Sun May 5 13:55:55 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 1629463834744632.0845185203361; Fri, 20 Aug 2021 05:50:34 -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-232-NYrJBV9IMKyxt8p3k__gDg-1; Fri, 20 Aug 2021 08:50:32 -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 339C387D545; Fri, 20 Aug 2021 12:50:27 +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 135C361096; Fri, 20 Aug 2021 12:50:27 +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 D7FB9181A60D; Fri, 20 Aug 2021 12:50:26 +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 17KCir44013568 for ; Fri, 20 Aug 2021 08:44:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84AA120B665E; Fri, 20 Aug 2021 12:44:53 +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 8035D20BEAB8 for ; Fri, 20 Aug 2021 12:44:50 +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 7A96C967612 for ; Fri, 20 Aug 2021 12:44:50 +0000 (UTC) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-386-WThZPxtIPZKyPQnEeA1wdA-1; Fri, 20 Aug 2021 08:44:48 -0400 Received: by mail-pl1-f182.google.com with SMTP id l11so5904833plk.6 for ; Fri, 20 Aug 2021 05:44:48 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id r17sm8475726pgu.8.2021.08.20.05.44.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:44:46 -0700 (PDT) X-MC-Unique: NYrJBV9IMKyxt8p3k__gDg-1 X-MC-Unique: WThZPxtIPZKyPQnEeA1wdA-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=1CKYOYeN5ja6e1iT2TIpPFpHNOhEN6tfyKSTNHkt45M=; b=shfVEbo/IP/D3LHXzqcmrBFNX8CobmyDsTW8wDABnGpXGaSMiheIgPW73MK5q2/K9/ p/fbRRB589b9Qnf/fwLL6EXwUMTVz/UbslP0nm5kLFzn9WDyVE5AVNUpPxnmuN6A92QQ yFQu+eXNW/M5w2gccO5Otzun6dyUnepbXl/3A20FyG2olw/9ySu+wJay0tKPe6vjeFLP D99E8L6/ab0fPTa0G8I+yVo90hrsSyiC7xpBKVrEJ9w802bth7u2ZZ30O7T7XwkxLsr/ kLvYkblputn+PiB8zAYwUYpz74ODKeeeGyl5cVGSicCzYqEHV+l97eCGMq0CFz8oSxVE aL3A== X-Gm-Message-State: AOAM532z2ah3B7cnU+T80+8oX/dAQHlwidNDu10bbvSCWMW81dmMCAwg ykqQCjhfOSH+zTXVTEmnhw8bVab4UiujgVi7EAc= X-Google-Smtp-Source: ABdhPJxRSbMjJbQwH/qGMK5jXB30q8qhg7zQ5YPUCky5n18K25epCcT/KKPBeii8QjlsQnkkQH82xA== X-Received: by 2002:a17:902:c10a:b0:12d:97e1:f035 with SMTP id 10-20020a170902c10a00b0012d97e1f035mr16403507pli.52.1629463486808; Fri, 20 Aug 2021 05:44:46 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 01/12] conf: Introduce virDomainInputDefRemove and fix memory leak Date: Fri, 20 Aug 2021 20:44:28 +0800 Message-Id: <20210820124439.535276-2-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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: 1629463836200100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/conf/domain_conf.c | 12 ++++++++++++ src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 3 ++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 10effdce69..6667426b9a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16760,6 +16760,18 @@ virDomainInputDefFind(const virDomainDef *def, } =20 =20 +virDomainInputDef * +virDomainInputDefRemove(virDomainDef *def, + size_t idx) +{ + virDomainInputDef *ret =3D def->inputs[idx]; + + VIR_DELETE_ELEMENT(def->inputs, idx, def->ninputs); + + return ret; +} + + bool virDomainVsockDefEquals(const virDomainVsockDef *a, const virDomainVsockDef *b) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c7e6df7981..3e4701176d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3815,6 +3815,8 @@ virDomainShmemDef *virDomainShmemDefRemove(virDomainD= ef *def, size_t idx) ssize_t virDomainInputDefFind(const virDomainDef *def, const virDomainInputDef *input) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; +virDomainInputDef *virDomainInputDefRemove(virDomainDef *def, size_t idx) + ATTRIBUTE_NONNULL(1); bool virDomainVsockDefEquals(const virDomainVsockDef *a, const virDomainVsockDef *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 090ac80691..f74291cb06 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -476,6 +476,7 @@ virDomainInputBusTypeToString; virDomainInputDefFind; virDomainInputDefFree; virDomainInputDefGetPath; +virDomainInputDefRemove; virDomainInputSourceGrabToggleTypeFromString; virDomainInputSourceGrabToggleTypeToString; virDomainInputSourceGrabTypeFromString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f31e13889e..c008921582 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7569,7 +7569,8 @@ qemuDomainDetachDeviceConfig(virDomainDef *vmdef, _("matching input device not found")); return -1; } - VIR_DELETE_ELEMENT(vmdef->inputs, idx, vmdef->ninputs); + + virDomainInputDefFree(virDomainInputDefRemove(vmdef, idx)); break; =20 case VIR_DOMAIN_DEVICE_VSOCK: --=20 2.33.0 From nobody Sun May 5 13:55:55 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 1629463572915117.06572704343375; Fri, 20 Aug 2021 05:46:12 -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-406-02_Yp18qMyyRTyQo5CT1Iw-1; Fri, 20 Aug 2021 08:46:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5FF001018F64; Fri, 20 Aug 2021 12:46:05 +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 A33F65D9D5; Fri, 20 Aug 2021 12:46:04 +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 C05CC181A2A6; Fri, 20 Aug 2021 12:46:02 +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 17KCj3CW013617 for ; Fri, 20 Aug 2021 08:45:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4227C10BC294; Fri, 20 Aug 2021 12:45:03 +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 3D6C410BC28D for ; Fri, 20 Aug 2021 12:44:55 +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 BE03A18A01AC for ; Fri, 20 Aug 2021 12:44:55 +0000 (UTC) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-YNTCBBSVOrq1PmBfCN_cPA-1; Fri, 20 Aug 2021 08:44:53 -0400 Received: by mail-pl1-f181.google.com with SMTP id c4so5883920plh.7 for ; Fri, 20 Aug 2021 05:44:53 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id x19sm7915294pgk.37.2021.08.20.05.44.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:44:49 -0700 (PDT) X-MC-Unique: 02_Yp18qMyyRTyQo5CT1Iw-1 X-MC-Unique: YNTCBBSVOrq1PmBfCN_cPA-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=ickuZ1SFnwW7GE4GUsASQM3yo90JBNPQnhGHiShtZd4=; b=gYBE0HHhaA3Svb9JXsvQB2di8j72ZB+5ZRA5sPusZ/4gVfINF+WcojdnHyk6SpiUX5 sCbpyGRBOt8/Coa9bDIqjGzti28gIRN/X7S79ME6JMMxzel4rSJ4kZWXgsAQcKqX4LOI TtJCWul0QvTLmFPSgNEKsT1ETedA1C05PFr4OGDLIKIQ90fyZuqVHfvJjxJmz2I/Njm1 S+SdbuAtOK8L4aZEAMKABPxwZ3tzZ/IIZJe5cgJw4clfn3xetYlm4zCh4v1A5WVq0xvR l9RXmlCtHKaqxlW6PbzpxYv71I5AW0BIJoy9wCm7OQC242Im5KMbrSWBnhcWVkAswq4Y fZ/Q== X-Gm-Message-State: AOAM532xKE79DA1liyrpuAMk0bZkJnRduAvKPrJABRRUWTv4E69oqJQO P54Q/WYfdXkKimieb6Sua5eJMWU3QrIsXpZsBoc= X-Google-Smtp-Source: ABdhPJxjQmouUP3RufpeMrQgAndA6zhD62r0pcoz7sMZW5vDjeZZSHKR73RSfXC7a/uCZxsXMtRKsw== X-Received: by 2002:a17:90a:17cc:: with SMTP id q70mr4475925pja.1.1629463490068; Fri, 20 Aug 2021 05:44:50 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 02/12] domain_driver: extract DetachXXXDeviceConfig related functions and use them Date: Fri, 20 Aug 2021 20:44:29 +0800 Message-Id: <20210820124439.535276-3-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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.14 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: 1629463574058100001 Content-Type: text/plain; charset="utf-8" libxl / lxc / qemu drivers share some common codes in their DomainDetachDeviceConfig functions, so extract them to domain_driver and reuse them. Signed-off-by: Luke Yue --- src/hypervisor/domain_driver.c | 267 +++++++++++++++++++++++++++++++++ src/hypervisor/domain_driver.h | 41 +++++ src/libvirt_private.syms | 14 ++ src/libxl/libxl_driver.c | 41 +---- src/lxc/lxc_driver.c | 37 +---- src/qemu/qemu_driver.c | 123 +++------------ 6 files changed, 357 insertions(+), 166 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 2969d55173..04c12dff5b 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -512,3 +512,270 @@ virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr= dev, =20 return virHostdevPCINodeDeviceDetach(hostdevMgr, pci); } + + +int +virDomainDriverDetachDiskDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainDiskDef *disk; + virDomainDiskDef *det_disk; + + disk =3D dev->data.disk; + if (!(det_disk =3D virDomainDiskRemoveByName(vmdef, disk->dst))) { + virReportError(VIR_ERR_DEVICE_MISSING, + _("no target device %s"), disk->dst); + return -1; + } + virDomainDiskDefFree(det_disk); + + return 0; +} + + +int +virDomainDriverDetachNetDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainNetDef *net; + int idx; + + net =3D dev->data.net; + if ((idx =3D virDomainNetFindIdx(vmdef, net)) < 0) + return -1; + + /* this is guaranteed to succeed */ + virDomainNetDefFree(virDomainNetRemove(vmdef, idx)); + + return 0; +} + + +int +virDomainDriverDetachSoundDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainSoundDef *sound; + int idx; + + sound =3D dev->data.sound; + if ((idx =3D virDomainSoundDefFind(vmdef, sound)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("device not present in domain configuration")); + return -1; + } + virDomainSoundDefFree(virDomainSoundDefRemove(vmdef, idx)); + + return 0; +} + + +int +virDomainDriverDetachHostdevDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainHostdevDef *hostdev; + virDomainHostdevDef *det_hostdev; + int idx; + + hostdev =3D dev->data.hostdev; + if ((idx =3D virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("device not present in domain configuration")); + return -1; + } + virDomainHostdevRemove(vmdef, idx); + virDomainHostdevDefFree(det_hostdev); + + return 0; +} + + +int +virDomainDriverDetachLeaseDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainLeaseDef *lease; + virDomainLeaseDef *det_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); + + return 0; +} + + +int +virDomainDriverDetachControllerDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainControllerDef *cont; + virDomainControllerDef *det_cont; + int idx; + + cont =3D dev->data.controller; + if ((idx =3D virDomainControllerFind(vmdef, cont->type, + cont->idx)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("device not present in domain configuration")); + return -1; + } + det_cont =3D virDomainControllerRemove(vmdef, idx); + virDomainControllerDefFree(det_cont); + + return 0; +} + + +int +virDomainDriverDetachFSDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainFSDef *fs; + int idx; + + 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); + + return 0; +} + + +int +virDomainDriverDetachRNGDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + int idx; + + 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)); + + return 0; +} + + +int +virDomainDriverDetachMemoryDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainMemoryDef *mem; + int idx; + + 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); + + return 0; +} + + +int +virDomainDriverDetachRedirdevDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + int idx; + + 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)); + + return 0; +} + + +int +virDomainDriverDetachShmemDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + int idx; + + 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)); + + return 0; +} + + +int +virDomainDriverDetachWatchdogDeviceConfig(virDomainDef *vmdef) +{ + if (!vmdef->watchdog) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("domain has no watchdog")); + return -1; + } + virDomainWatchdogDefFree(vmdef->watchdog); + vmdef->watchdog =3D NULL; + + return 0; +} + + +int +virDomainDriverDetachInputDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + int idx; + + if ((idx =3D virDomainInputDefFind(vmdef, dev->data.input)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("matching input device not found")); + return -1; + } + + virDomainInputDefFree(virDomainInputDefRemove(vmdef, idx)); + + return 0; +} + + +int +virDomainDriverDetachVsockDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + 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; + + return 0; +} diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index 5970eef082..9c089f17cc 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -60,3 +60,44 @@ int virDomainDriverNodeDeviceReAttach(virNodeDevicePtr d= ev, int virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr dev, virHostdevManager *hostdevMgr, const char *driverName); + +int virDomainDriverDetachDiskDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachNetDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachSoundDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachHostdevDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachLeaseDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachControllerDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachFSDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachRNGDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachMemoryDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachRedirdevDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachShmemDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachWatchdogDeviceConfig(virDomainDef *vmdef); + +int virDomainDriverDetachInputDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); + +int virDomainDriverDetachVsockDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f74291cb06..9cf12779bf 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1534,6 +1534,20 @@ virDomainCgroupSetupMemtune; =20 =20 # hypervisor/domain_driver.h +virDomainDriverDetachControllerDeviceConfig; +virDomainDriverDetachDiskDeviceConfig; +virDomainDriverDetachFSDeviceConfig; +virDomainDriverDetachHostdevDeviceConfig; +virDomainDriverDetachInputDeviceConfig; +virDomainDriverDetachLeaseDeviceConfig; +virDomainDriverDetachMemoryDeviceConfig; +virDomainDriverDetachNetDeviceConfig; +virDomainDriverDetachRedirdevDeviceConfig; +virDomainDriverDetachRNGDeviceConfig; +virDomainDriverDetachShmemDeviceConfig; +virDomainDriverDetachSoundDeviceConfig; +virDomainDriverDetachVsockDeviceConfig; +virDomainDriverDetachWatchdogDeviceConfig; virDomainDriverGenerateMachineName; virDomainDriverGenerateRootHash; virDomainDriverMergeBlkioDevice; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 6a3938ead4..a794fe8f14 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3916,56 +3916,29 @@ libxlDomainDetachDeviceLive(libxlDriverPrivate *dri= ver, static int libxlDomainDetachDeviceConfig(virDomainDef *vmdef, virDomainDeviceDef *dev) { - virDomainDiskDef *disk; - virDomainDiskDef *detach; - virDomainHostdevDef *hostdev; - virDomainHostdevDef *det_hostdev; - virDomainControllerDef *cont; - virDomainControllerDef *det_cont; - virDomainNetDef *net; - 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); + if (virDomainDriverDetachDiskDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainDiskDefFree(detach); + break; =20 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")); + if (virDomainDriverDetachControllerDeviceConfig(vmdef, dev) < = 0) return -1; - } - det_cont =3D virDomainControllerRemove(vmdef, idx); - virDomainControllerDefFree(det_cont); + break; =20 case VIR_DOMAIN_DEVICE_NET: - net =3D dev->data.net; - if ((idx =3D virDomainNetFindIdx(vmdef, net)) < 0) + if (virDomainDriverDetachNetDeviceConfig(vmdef, dev) < 0) return -1; =20 - /* this is guaranteed to succeed */ - virDomainNetDefFree(virDomainNetRemove(vmdef, idx)); break; =20 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")); + if (virDomainDriverDetachHostdevDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainHostdevRemove(vmdef, idx); - virDomainHostdevDefFree(det_hostdev); + break; } =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 8f2ca19f44..b8958eb6c1 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3129,56 +3129,33 @@ static int lxcDomainDetachDeviceConfig(virDomainDef *vmdef, virDomainDeviceDef *dev) { - int ret =3D -1; - virDomainDiskDef *disk; - virDomainDiskDef *det_disk; - virDomainNetDef *net; - virDomainHostdevDef *hostdev; - virDomainHostdevDef *det_hostdev; - int idx; - switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: - disk =3D dev->data.disk; - if (!(det_disk =3D virDomainDiskRemoveByName(vmdef, disk->dst))) { - virReportError(VIR_ERR_INVALID_ARG, - _("no target device %s"), disk->dst); + if (virDomainDriverDetachDiskDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainDiskDefFree(det_disk); - ret =3D 0; + break; =20 case VIR_DOMAIN_DEVICE_NET: - net =3D dev->data.net; - if ((idx =3D virDomainNetFindIdx(vmdef, net)) < 0) + if (virDomainDriverDetachNetDeviceConfig(vmdef, dev) < 0) return -1; =20 - /* this is guaranteed to succeed */ - virDomainNetDefFree(virDomainNetRemove(vmdef, idx)); - ret =3D 0; break; =20 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 configuration")= ); + if (virDomainDriverDetachHostdevDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainHostdevRemove(vmdef, idx); - virDomainHostdevDefFree(det_hostdev); - ret =3D 0; + break; } =20 default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("persistent detach of device is not supported")); - break; + return -1; } =20 - return ret; + return 0; } =20 =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c008921582..727d663bad 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7408,84 +7408,43 @@ qemuDomainDetachDeviceConfig(virDomainDef *vmdef, unsigned int parse_flags, virDomainXMLOption *xmlopt) { - virDomainDiskDef *disk; - virDomainDiskDef *det_disk; - virDomainNetDef *net; - virDomainSoundDef *sound; - virDomainHostdevDef *hostdev; - virDomainHostdevDef *det_hostdev; - virDomainLeaseDef *lease; - virDomainLeaseDef *det_lease; - virDomainControllerDef *cont; - virDomainControllerDef *det_cont; virDomainChrDef *chr; - virDomainFSDef *fs; - virDomainMemoryDef *mem; - int idx; =20 switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_DISK: - disk =3D dev->data.disk; - if (!(det_disk =3D virDomainDiskRemoveByName(vmdef, disk->dst))) { - virReportError(VIR_ERR_DEVICE_MISSING, - _("no target device %s"), disk->dst); + if (virDomainDriverDetachDiskDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainDiskDefFree(det_disk); + break; =20 case VIR_DOMAIN_DEVICE_NET: - net =3D dev->data.net; - if ((idx =3D virDomainNetFindIdx(vmdef, net)) < 0) + if (virDomainDriverDetachNetDeviceConfig(vmdef, dev) < 0) return -1; =20 - /* this is guaranteed to succeed */ - virDomainNetDefFree(virDomainNetRemove(vmdef, idx)); break; =20 case VIR_DOMAIN_DEVICE_SOUND: - sound =3D dev->data.sound; - if ((idx =3D virDomainSoundDefFind(vmdef, sound)) < 0) { - virReportError(VIR_ERR_DEVICE_MISSING, "%s", - _("device not present in domain configuration")= ); + if (virDomainDriverDetachSoundDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainSoundDefFree(virDomainSoundDefRemove(vmdef, idx)); + break; =20 case VIR_DOMAIN_DEVICE_HOSTDEV: { - hostdev =3D dev->data.hostdev; - if ((idx =3D virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) <= 0) { - virReportError(VIR_ERR_DEVICE_MISSING, "%s", - _("device not present in domain configuration")= ); + if (virDomainDriverDetachHostdevDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainHostdevRemove(vmdef, idx); - virDomainHostdevDefFree(det_hostdev); + break; } =20 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)); + if (virDomainDriverDetachLeaseDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainLeaseDefFree(det_lease); + break; =20 case VIR_DOMAIN_DEVICE_CONTROLLER: - cont =3D dev->data.controller; - if ((idx =3D virDomainControllerFind(vmdef, cont->type, - cont->idx)) < 0) { - virReportError(VIR_ERR_DEVICE_MISSING, "%s", - _("device not present in domain configuration")= ); + if (virDomainDriverDetachControllerDeviceConfig(vmdef, dev) < 0) return -1; - } - det_cont =3D virDomainControllerRemove(vmdef, idx); - virDomainControllerDefFree(det_cont); =20 break; =20 @@ -7497,91 +7456,51 @@ qemuDomainDetachDeviceConfig(virDomainDef *vmdef, break; =20 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")); + if (virDomainDriverDetachFSDeviceConfig(vmdef, dev) < 0) return -1; - } =20 - fs =3D virDomainFSRemove(vmdef, idx); - virDomainFSDefFree(fs); break; =20 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")); + if (virDomainDriverDetachRNGDeviceConfig(vmdef, dev) < 0) return -1; - } =20 - virDomainRNGDefFree(virDomainRNGRemove(vmdef, idx)); break; =20 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")); + if (virDomainDriverDetachMemoryDeviceConfig(vmdef, dev) < 0) return -1; - } - mem =3D virDomainMemoryRemove(vmdef, idx); - vmdef->mem.cur_balloon -=3D mem->size; - virDomainMemoryDefFree(mem); + break; =20 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")); + if (virDomainDriverDetachRedirdevDeviceConfig(vmdef, dev) < 0) return -1; - } =20 - virDomainRedirdevDefFree(virDomainRedirdevDefRemove(vmdef, idx)); break; =20 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")); + if (virDomainDriverDetachShmemDeviceConfig(vmdef, dev) < 0) return -1; - } =20 - virDomainShmemDefFree(virDomainShmemDefRemove(vmdef, idx)); break; =20 - case VIR_DOMAIN_DEVICE_WATCHDOG: - if (!vmdef->watchdog) { - virReportError(VIR_ERR_DEVICE_MISSING, "%s", - _("domain has no watchdog")); + if (virDomainDriverDetachWatchdogDeviceConfig(vmdef) < 0) return -1; - } - virDomainWatchdogDefFree(vmdef->watchdog); - vmdef->watchdog =3D NULL; + break; =20 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")); + if (virDomainDriverDetachInputDeviceConfig(vmdef, dev) < 0) return -1; - } =20 - virDomainInputDefFree(virDomainInputDefRemove(vmdef, idx)); break; =20 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")); + if (virDomainDriverDetachVsockDeviceConfig(vmdef, dev) < 0) return -1; - } - virDomainVsockDefFree(vmdef->vsock); - vmdef->vsock =3D NULL; + break; =20 case VIR_DOMAIN_DEVICE_VIDEO: --=20 2.33.0 From nobody Sun May 5 13:55:55 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 162946366175785.50077840064046; Fri, 20 Aug 2021 05:47:41 -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-380-jSLEBxS2NSC7AUKsR9_x5Q-1; Fri, 20 Aug 2021 08:47:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4DC9B8799EE; Fri, 20 Aug 2021 12:47:34 +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 304B05D9FC; Fri, 20 Aug 2021 12:47:34 +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 F074B181A3F0; Fri, 20 Aug 2021 12:47:33 +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 17KCj5tG013623 for ; Fri, 20 Aug 2021 08:45:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 208A8202BFCE; Fri, 20 Aug 2021 12:45:05 +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 0E6D420389F2 for ; Fri, 20 Aug 2021 12:44:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 9FF0889B841 for ; Fri, 20 Aug 2021 12:44:57 +0000 (UTC) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-581-WzFcp9GDMOq0Q6qd0IVtGQ-1; Fri, 20 Aug 2021 08:44:55 -0400 Received: by mail-pj1-f45.google.com with SMTP id qe12-20020a17090b4f8c00b00179321cbae7so7160342pjb.2 for ; Fri, 20 Aug 2021 05:44:55 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id v63sm7815099pgv.59.2021.08.20.05.44.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:44:53 -0700 (PDT) X-MC-Unique: jSLEBxS2NSC7AUKsR9_x5Q-1 X-MC-Unique: WzFcp9GDMOq0Q6qd0IVtGQ-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=uobVLryVWX0H0ICus1UnqqAFLO04ROmlDymC+bniyBU=; b=CeRWVXKOas5VGoF60qzFVHwPX14for9/ssVyeBWSipwA15S2qLQaKUcaEY1UaLUm7F napSmN7u4NHts3VN/lEmEnh1FYoS9vLnMY/ETx0a8SvZ+HhEXcpmblq0Oz7jGQDkGxoz imLLbYDtJkSBhstwikS6y2CUvxEULYWorFmV3D4KH0LNSErj0UpINkdMcYfhsCsnpOV8 pi6vEzOi5qAPoXr5wAGZ2Q1Zjb3vBopSDf83GO45KH7cpFUhKq5WCkbKQlRkxr0CzMfM 6KcASzGKda2EJgbO0fHORWyDOqd4t39IY+2M9XI5U/ssuqyRKTV5pCLEnu2h9pGVA7o2 2pbw== X-Gm-Message-State: AOAM5336YI4vynIe0PEYDO0sPl25AbMOMUdXD4ApROYxre0af+FqF3sJ B8laBVmwHmMirRfGSeV+furb3ArcCCHo5TQfL+o= X-Google-Smtp-Source: ABdhPJy+xS/6NpOVfV9k4H8h9e0n0lf1DkE9Ejm/4xxXwLkRpp8KQFRobXeTKjtD4gWVCfs+qBTUBA== X-Received: by 2002:a17:90a:c88:: with SMTP id v8mr4492397pja.197.1629463493988; Fri, 20 Aug 2021 05:44:53 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 03/12] test_driver: Implement virDomainDetachDeviceFlags Date: Fri, 20 Aug 2021 20:44:30 +0800 Message-Id: <20210820124439.535276-4-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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.14 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: 1629463662644100001 Content-Type: text/plain; charset="utf-8" Introduce testDomainChgDevice for further development (just like what we did for IOThread). And introduce testDomainDetachDeviceLiveAndConfig for detaching devices. Signed-off-by: Luke Yue --- src/test/test_driver.c | 201 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 10a1767542..5e4d6d37ef 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9537,6 +9537,206 @@ testDomainGetMessages(virDomainPtr dom, return rv; } =20 +static int +testDomainDetachDeviceLiveAndConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + virDomainChrDef *chr; + + switch (dev->type) { + case VIR_DOMAIN_DEVICE_DISK: + if (virDomainDriverDetachDiskDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_NET: + if (virDomainDriverDetachNetDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_SOUND: + if (virDomainDriverDetachSoundDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_HOSTDEV: + if (virDomainDriverDetachHostdevDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_LEASE: + if (virDomainDriverDetachLeaseDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_CONTROLLER: + if (virDomainDriverDetachControllerDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_FS: + if (virDomainDriverDetachFSDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_RNG: + if (virDomainDriverDetachRNGDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_MEMORY: + if (virDomainDriverDetachMemoryDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_REDIRDEV: + if (virDomainDriverDetachRedirdevDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_SHMEM: + if (virDomainDriverDetachShmemDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_WATCHDOG: + if (virDomainDriverDetachWatchdogDeviceConfig(vmdef) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_INPUT: + if (virDomainDriverDetachInputDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_VSOCK: + if (virDomainDriverDetachVsockDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + + case VIR_DOMAIN_DEVICE_CHR: + if (!(chr =3D virDomainChrRemove(vmdef, dev->data.chr))) + return -1; + + virDomainChrDefFree(chr); + break; + + case VIR_DOMAIN_DEVICE_VIDEO: + case VIR_DOMAIN_DEVICE_GRAPHICS: + case VIR_DOMAIN_DEVICE_HUB: + case VIR_DOMAIN_DEVICE_SMARTCARD: + case VIR_DOMAIN_DEVICE_MEMBALLOON: + case VIR_DOMAIN_DEVICE_NVRAM: + case VIR_DOMAIN_DEVICE_NONE: + case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: + case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_AUDIO: + case VIR_DOMAIN_DEVICE_LAST: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("detach of device '%s' is not supported"), + virDomainDeviceTypeToString(dev->type)); + return -1; + } + + return 0; +} + +static int +testDomainChgDevice(virDomainPtr dom, + virDomainDeviceAction action, + const char *xml, + const char *alias, + unsigned int flags) +{ + testDriver *driver =3D dom->conn->privateData; + virDomainObj *vm =3D NULL; + virDomainDef *def; + virDomainDeviceDef *dev =3D NULL; + unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) + goto cleanup; + + if (!(def =3D virDomainObjGetOneDef(vm, flags))) + goto cleanup; + + if (action =3D=3D VIR_DOMAIN_DEVICE_ACTION_DETACH) + parse_flags |=3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; + + if (xml) { + if (!(dev =3D virDomainDeviceDefParse(xml, def, driver->xmlopt, + driver->caps, parse_flags))) + goto cleanup; + } else if (alias) { + dev =3D g_new0(virDomainDeviceDef, 1); + if (virDomainDefFindDevice(def, alias, dev, true) < 0) + goto cleanup; + } + + if (dev =3D=3D NULL) + goto cleanup; + + switch (action) { + case VIR_DOMAIN_DEVICE_ACTION_ATTACH: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("attaching devices is not supported")); + goto cleanup; + break; + + case VIR_DOMAIN_DEVICE_ACTION_DETACH: + if (testDomainDetachDeviceLiveAndConfig(def, dev) < 0) + goto cleanup; + break; + + case VIR_DOMAIN_DEVICE_ACTION_UPDATE: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("updating devices is not supported")); + goto cleanup; + break; + } + + ret =3D 0; + + cleanup: + if (xml) { + virDomainDeviceDefFree(dev); + } else { + g_free(dev); + } + virDomainObjEndAPI(&vm); + return ret; +} + +static int +testDomainDetachDeviceFlags(virDomainPtr dom, + const char *xml, + unsigned int flags) +{ + return testDomainChgDevice(dom, VIR_DOMAIN_DEVICE_ACTION_DETACH, + xml, NULL, flags); +} /* * Test driver */ @@ -9628,6 +9828,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainFSFreeze =3D testDomainFSFreeze, /* 5.7.0 */ .domainFSThaw =3D testDomainFSThaw, /* 5.7.0 */ .domainFSTrim =3D testDomainFSTrim, /* 5.7.0 */ + .domainDetachDeviceFlags =3D testDomainDetachDeviceFlags, /* 7.7.0 */ .domainGetAutostart =3D testDomainGetAutostart, /* 0.3.2 */ .domainSetAutostart =3D testDomainSetAutostart, /* 0.3.2 */ .domainGetDiskErrors =3D testDomainGetDiskErrors, /* 5.4.0 */ --=20 2.33.0 From nobody Sun May 5 13:55:55 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 1629463839995682.9065237669612; Fri, 20 Aug 2021 05:50:39 -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-235-jDegrUvGP9WaqJI8ohRzbQ-1; Fri, 20 Aug 2021 08:50:37 -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 F0DBA107ACF5; Fri, 20 Aug 2021 12:50:31 +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 D531D7BE5B; Fri, 20 Aug 2021 12:50:31 +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 A2F56181A6E3; Fri, 20 Aug 2021 12:50:31 +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 17KCj0Lw013579 for ; Fri, 20 Aug 2021 08:45:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3105C113B7F; Fri, 20 Aug 2021 12:45:00 +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 2C22C1140EC for ; Fri, 20 Aug 2021 12:45:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 1505680234F for ; Fri, 20 Aug 2021 12:45:00 +0000 (UTC) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-498-OHOOZAyAPs6RSjPznGmPmw-1; Fri, 20 Aug 2021 08:44:58 -0400 Received: by mail-pf1-f178.google.com with SMTP id j187so8487103pfg.4 for ; Fri, 20 Aug 2021 05:44:57 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id nn3sm5562353pjb.9.2021.08.20.05.44.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:44:56 -0700 (PDT) X-MC-Unique: jDegrUvGP9WaqJI8ohRzbQ-1 X-MC-Unique: OHOOZAyAPs6RSjPznGmPmw-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=914spF7Wqfx1abHYiuDExF1rU9O8xzeCQdIWpSAGr+w=; b=MwEH4jzgHAjTB0HJUlx7PA/jq0jRHT1qqttmimpHUhagK06zYB0RqBsV7td3yRFyqd /CLzoySOrL8I1WilRy3C/vwBhISyRkjry2WzFYNuOdJVU3njfJu1QPkXy5Qik2hBgGue 2NjifMRn09X7QJ6m4NzF/VXMw5fk/2AINbGjm+MOI/YqeliECLoYWwYqDMju/O36Kc+R AmyQQMqVFhUBN6k2c3asADIl6+F9kWPV1Vu/dl/C4/ENZJXGs4sQeKbRXUp2SF3DIXZJ ggdUQaiPIXbSxTNcVg92VgOTJ1/HsMerszeqcjnWWnN2h1sUTVUHo69pEMDy/KT7hlBD bkZg== X-Gm-Message-State: AOAM5321lkmbCtia5qK8WzeDxcBhj6rB0+ElzW9uQpXaNfFtVoh6X2GV Bm4e3tgrQNxsKtjm/8+TgrnjrDG0yJ9mBP1mO04= X-Google-Smtp-Source: ABdhPJyBSeJR2wxPLKQEeVc4lAnBXd4SKfSP8Y1BwaXr6GeMuGtHcuRhkGWcVRR6Ef3h5HwJjzosjQ== X-Received: by 2002:a65:6919:: with SMTP id s25mr18683725pgq.2.1629463496904; Fri, 20 Aug 2021 05:44:56 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 04/12] test_driver: Implement virDomainDetachDeviceAlias Date: Fri, 20 Aug 2021 20:44:31 +0800 Message-Id: <20210820124439.535276-5-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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: 1629463841098100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5e4d6d37ef..6cabf78e7c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9737,6 +9737,16 @@ testDomainDetachDeviceFlags(virDomainPtr dom, return testDomainChgDevice(dom, VIR_DOMAIN_DEVICE_ACTION_DETACH, xml, NULL, flags); } + +static int +testDomainDetachDeviceAlias(virDomainPtr dom, + const char *alias, + unsigned int flags) +{ + return testDomainChgDevice(dom, VIR_DOMAIN_DEVICE_ACTION_DETACH, + NULL, alias, flags); +} + /* * Test driver */ @@ -9828,6 +9838,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainFSFreeze =3D testDomainFSFreeze, /* 5.7.0 */ .domainFSThaw =3D testDomainFSThaw, /* 5.7.0 */ .domainFSTrim =3D testDomainFSTrim, /* 5.7.0 */ + .domainDetachDeviceAlias =3D testDomainDetachDeviceAlias, /* 7.7.0 */ .domainDetachDeviceFlags =3D testDomainDetachDeviceFlags, /* 7.7.0 */ .domainGetAutostart =3D testDomainGetAutostart, /* 0.3.2 */ .domainSetAutostart =3D testDomainSetAutostart, /* 0.3.2 */ --=20 2.33.0 From nobody Sun May 5 13:55:55 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 1629463580104693.5941507157985; Fri, 20 Aug 2021 05:46:20 -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-44-utUWMoj0OTaHyHTMkELQdg-1; Fri, 20 Aug 2021 08:46:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B4C98799EF; Fri, 20 Aug 2021 12:46:12 +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 473505D9FC; Fri, 20 Aug 2021 12:46:12 +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 11BC7181A2A9; Fri, 20 Aug 2021 12:46:12 +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 17KCj5hO013625 for ; Fri, 20 Aug 2021 08:45:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 41B95114CEA; Fri, 20 Aug 2021 12:45:05 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 342C9115D87 for ; Fri, 20 Aug 2021 12:45:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 14E3B858914 for ; Fri, 20 Aug 2021 12:45:03 +0000 (UTC) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564-V2Vy08eiMpyVKzn_wQAiyw-1; Fri, 20 Aug 2021 08:45:01 -0400 Received: by mail-pf1-f169.google.com with SMTP id j187so8487212pfg.4 for ; Fri, 20 Aug 2021 05:45:01 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id n41sm7048351pfv.43.2021.08.20.05.44.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:44:59 -0700 (PDT) X-MC-Unique: utUWMoj0OTaHyHTMkELQdg-1 X-MC-Unique: V2Vy08eiMpyVKzn_wQAiyw-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=uY9T1SHsHxqZTXCtx80RR1ov6TH2Uo3Ix3SrAXCACtY=; b=RF/KkAp/T4qJfWaq4qGq5O8UWZX+Ov6R+VXByqL8QiHa1xgDaXDJwoq6FGPMbAJKm3 Sy1w97MIhj/rrb3b+524OEIwHcbZrp0EMqp8BbknPCvzyFu9NVIzrJ/4YwuRvkTBdVJu ziBS2fMxfNqhct0O4mlkdll+NmOVENwqXIoycgQFdYnKMioIoICqt2GAXpUQVOGPiqPU Nh/CRSle4S49IyoFC3KCkFpIWl8Sfu9MkNYoDTiQzlUFJOMScRgRZ8T4wTVaFxYvJNU/ 8hzHOEnMj3MV2KNMhqVvQ4VPR+YFKM2V5eIbf2szgaqCDjGcFrhIydGMr3aGZ78BWYt+ 8c/Q== X-Gm-Message-State: AOAM5327qIqdSccQgVNKZG7nmLUACfPxxtoVWBMFo4+WwAop2gohob3g t7wRmMLtYNhybex2qhhAiYnZRqn8isun0/uYOfU= X-Google-Smtp-Source: ABdhPJwg5YTv7Cx7DkfNtKhbRJ8Gf2dF7TErGinZwnUP/PaD7NlAWCtBl41DK1DyO9qGrZndtiCY2w== X-Received: by 2002:a65:689a:: with SMTP id e26mr18906631pgt.193.1629463499805; Fri, 20 Aug 2021 05:44:59 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 05/12] test_driver: Implement virDomainDetachDevice Date: Fri, 20 Aug 2021 20:44:32 +0800 Message-Id: <20210820124439.535276-6-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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.14 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: 1629463580902100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6cabf78e7c..c6aead09c9 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9747,6 +9747,14 @@ testDomainDetachDeviceAlias(virDomainPtr dom, NULL, alias, flags); } =20 +static int +testDomainDetachDevice(virDomainPtr dom, + const char *xml) +{ + return testDomainDetachDeviceFlags(dom, xml, + VIR_DOMAIN_AFFECT_LIVE); +} + /* * Test driver */ @@ -9838,6 +9846,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainFSFreeze =3D testDomainFSFreeze, /* 5.7.0 */ .domainFSThaw =3D testDomainFSThaw, /* 5.7.0 */ .domainFSTrim =3D testDomainFSTrim, /* 5.7.0 */ + .domainDetachDevice =3D testDomainDetachDevice, /* 7.7.0 */ .domainDetachDeviceAlias =3D testDomainDetachDeviceAlias, /* 7.7.0 */ .domainDetachDeviceFlags =3D testDomainDetachDeviceFlags, /* 7.7.0 */ .domainGetAutostart =3D testDomainGetAutostart, /* 0.3.2 */ --=20 2.33.0 From nobody Sun May 5 13:55:55 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 1629463583895911.3883785218758; Fri, 20 Aug 2021 05:46: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-478-yeZpoO1ZPuegwJ7FptC3SQ-1; Fri, 20 Aug 2021 08:46: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 165051B2C984; Fri, 20 Aug 2021 12:46:16 +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 E02231ABD8; Fri, 20 Aug 2021 12:46:15 +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 9D7984BB7C; Fri, 20 Aug 2021 12:46:15 +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 17KCj6BQ013638 for ; Fri, 20 Aug 2021 08:45:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id A5A4D105458D; Fri, 20 Aug 2021 12:45:06 +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 9755A1050199 for ; Fri, 20 Aug 2021 12:45:06 +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 13D5410666A3 for ; Fri, 20 Aug 2021 12:45:06 +0000 (UTC) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-Prdu6E5jOaGX-1PAXlcrWg-1; Fri, 20 Aug 2021 08:45:04 -0400 Received: by mail-pf1-f173.google.com with SMTP id j187so8487339pfg.4 for ; Fri, 20 Aug 2021 05:45:03 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id nv11sm11533572pjb.48.2021.08.20.05.45.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:45:02 -0700 (PDT) X-MC-Unique: yeZpoO1ZPuegwJ7FptC3SQ-1 X-MC-Unique: Prdu6E5jOaGX-1PAXlcrWg-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=iNhtx1xv+yrIbyanbn6l8y1/Y3Q+UPSQrlToEom0SKs=; b=XgSHWHUB6nMRUPauLCrht24ZCAK+q70g6tEaT6V76L832S1WWVd0h6uZD+oViPAesB jO5/AKMOOp2+EeODE5rNzSVnSOv5F6KfPkJLRM1Zo7rqPJBD5ufqYLI3xcJW6Tt2n0bY 9ej9PJ+WknhHmytyPb7BUayNLvqQpwUblv+xFg+S42Q3+5S/m5C98S72ks7nT1dLRUVl mU0vx5mBNHT4y+W0qnIzdSKg1wvZl0+ZZcLl1KOPfzYc+E4goMkYLjOsgQlTsh7NLM39 Pf5tbrAohC4diJjfGaWZ20U0qj/e4xxqMMGk/zfQvRzs0q4/emYUcFk+N2Z2UGftC4y0 hLRA== X-Gm-Message-State: AOAM530Tfg+MGpFd4v9aGMcUZj54c3fgVsf8FKxHNt8EaFjEpUwR012D 0+kY8p90K/MuErKBNP8xAlUb3pu2OBsWvlaQkg4= X-Google-Smtp-Source: ABdhPJzS6agkzG87+vHeGX14V6Ef01HGMgjFttTVYloBPm+HLWYcUZLNHXdqIcs5WKubOK5z9Fon+A== X-Received: by 2002:a63:134e:: with SMTP id 14mr18243122pgt.312.1629463502612; Fri, 20 Aug 2021 05:45:02 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 06/12] conf: Add tpm helpers for future use Date: Fri, 20 Aug 2021 20:44:33 +0800 Message-Id: <20210820124439.535276-7-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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.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: 1629463585251100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/conf/domain_conf.c | 67 ++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 6 ++++ src/libvirt_private.syms | 2 ++ 3 files changed, 75 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6667426b9a..7f3d207a3e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16790,6 +16790,73 @@ virDomainVsockDefEquals(const virDomainVsockDef *a, } =20 =20 +static bool +virDomainTPMDefEquals(const virDomainTPMDef *a, + const virDomainTPMDef *b) +{ + if (a->type !=3D b->type) + return false; + + if (a->model !=3D b->model) + return false; + + if (a->version !=3D b->version) + return false; + + if (a->type =3D=3D VIR_DOMAIN_TPM_TYPE_PASSTHROUGH) { + if (STRNEQ_NULLABLE(a->data.passthrough.source.data.file.path, + b->data.passthrough.source.data.file.path)) + return false; + } else { + if (a->data.emulator.hassecretuuid !=3D b->data.emulator.hassecret= uuid) + return false; + + if (a->data.emulator.hassecretuuid =3D=3D true && + memcmp(a->data.emulator.secretuuid, + b->data.emulator.secretuuid, + VIR_UUID_BUFLEN)) + return false; + + if (a->data.emulator.persistent_state !=3D + b->data.emulator.persistent_state) + return false; + } + + if (a->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + !virDomainDeviceInfoAddressIsEqual(&a->info, &b->info)) + return false; + + return true; +} + + +ssize_t +virDomainTPMDefFind(const virDomainDef *def, + const virDomainTPMDef *tpm) +{ + size_t i; + + for (i =3D 0; i < def->ntpms; i++) { + if (virDomainTPMDefEquals(tpm, def->tpms[i])) + return i; + } + + return -1; +} + + +virDomainTPMDef * +virDomainTPMDefRemove(virDomainDef *def, + size_t idx) +{ + virDomainTPMDef *ret =3D def->tpms[idx]; + + VIR_DELETE_ELEMENT(def->tpms, idx, def->ntpms); + + return ret; +} + + char * virDomainDefGetDefaultEmulator(virDomainDef *def, virCaps *caps) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3e4701176d..b8a1e1d2d2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3821,6 +3821,12 @@ bool virDomainVsockDefEquals(const virDomainVsockDef= *a, const virDomainVsockDef *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; =20 +ssize_t virDomainTPMDefFind(const virDomainDef *def, + const virDomainTPMDef *tpm) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; +virDomainTPMDef *virDomainTPMDefRemove(virDomainDef *def, size_t idx) + ATTRIBUTE_NONNULL(1); + VIR_ENUM_DECL(virDomainTaint); VIR_ENUM_DECL(virDomainTaintMessage); VIR_ENUM_DECL(virDomainVirt); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9cf12779bf..f7f3726443 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -661,7 +661,9 @@ virDomainTimerTrackTypeFromString; virDomainTimerTrackTypeToString; virDomainTPMBackendTypeFromString; virDomainTPMBackendTypeToString; +virDomainTPMDefFind; virDomainTPMDefFree; +virDomainTPMDefRemove; virDomainTPMModelTypeFromString; virDomainTPMModelTypeToString; virDomainUSBDeviceDefForeach; --=20 2.33.0 From nobody Sun May 5 13:55:55 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 1629463587354678.5262416930401; Fri, 20 Aug 2021 05:46: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-17-xdtqwiXYNw-SHza3jzmJww-1; Fri, 20 Aug 2021 08:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE3D7101C8A8; Fri, 20 Aug 2021 12:46:19 +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 AA35E5E26A; Fri, 20 Aug 2021 12:46: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 43A86181A2AA; Fri, 20 Aug 2021 12:46:19 +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 17KCj9eW013665 for ; Fri, 20 Aug 2021 08:45:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id E5DFF10BC28D; Fri, 20 Aug 2021 12:45:08 +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 E071A10BC295 for ; Fri, 20 Aug 2021 12:45:08 +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 C9DB91066691 for ; Fri, 20 Aug 2021 12:45:08 +0000 (UTC) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-rYop3k_tMeG78ciQMSbhEw-1; Fri, 20 Aug 2021 08:45:06 -0400 Received: by mail-pf1-f181.google.com with SMTP id k19so8508392pfc.11 for ; Fri, 20 Aug 2021 05:45:06 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id c15sm6651251pfl.181.2021.08.20.05.45.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:45:05 -0700 (PDT) X-MC-Unique: xdtqwiXYNw-SHza3jzmJww-1 X-MC-Unique: rYop3k_tMeG78ciQMSbhEw-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=IRj1+0genTL35cRdvyZYcor7Q3HEz3N333s3pao067w=; b=iEPxuNRk5+q1e106VJBUsiSg9Jzt1EmSKN4S7lR1bJ+RjJA4suSxh1WpstN3q8GB1n 64gVw70oljaoopzWd3YCLwqt86wlP0w23Ih2o6KpI/+zZlSlf8/IwY7GpdSuqSPQgvo0 6dZNTUBf/hp/jDTgySTcZlYTxEM+BKfqQNaJtdq2tooeFyVkWTfLuK1tTi+i3yEpj6F6 SK/33splzkOR5XfPGvTbnUzlIB6jpCxUr6/mvYTlg9GN1oDKSYRtDq8SmcOdyoQz6hrA Lf/OYSLsvQkEPz3iUyIm5qN0TCFdVG80F9iarIPhN8Wixo3wuIaIa5CQiFXRAWrU61C2 f3dg== X-Gm-Message-State: AOAM531e5K5y1zMs7eVdNy5NIaqnmgT7HuRI28GrtILPMtga2Aa2sb13 LENll3fQGahQgxnDZxw2OiKRr4fgi97XOLaBRRk= X-Google-Smtp-Source: ABdhPJyu30/gMA/Y9xJ9Y7QXfKwJYck6d1NE5tL1iqIfWKukmvR68tf85uw7mx1GdJDVG3vfUk30vw== X-Received: by 2002:a63:5901:: with SMTP id n1mr18302223pgb.378.1629463505353; Fri, 20 Aug 2021 05:45:05 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 07/12] test_driver: add TPM support for testDomainDetachDeviceLiveAndConfig Date: Fri, 20 Aug 2021 20:44:34 +0800 Message-Id: <20210820124439.535276-8-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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.14 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: 1629463589573100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/hypervisor/domain_driver.c | 18 ++++++++++++++++++ src/hypervisor/domain_driver.h | 3 +++ src/libvirt_private.syms | 1 + src/test/test_driver.c | 7 ++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 04c12dff5b..93754ae08a 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -779,3 +779,21 @@ virDomainDriverDetachVsockDeviceConfig(virDomainDef *v= mdef, =20 return 0; } + + +int +virDomainDriverDetachTPMDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + int idx; + + if ((idx =3D virDomainTPMDefFind(vmdef, dev->data.tpm)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("matching tpm device not found")); + return -1; + } + + virDomainTPMDefFree(virDomainTPMDefRemove(vmdef, idx)); + + return 0; +} diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index 9c089f17cc..6cb9defb58 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -101,3 +101,6 @@ int virDomainDriverDetachInputDeviceConfig(virDomainDef= *vmdef, =20 int virDomainDriverDetachVsockDeviceConfig(virDomainDef *vmdef, virDomainDeviceDef *dev); + +int virDomainDriverDetachTPMDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f7f3726443..349cce2f00 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1548,6 +1548,7 @@ virDomainDriverDetachRedirdevDeviceConfig; virDomainDriverDetachRNGDeviceConfig; virDomainDriverDetachShmemDeviceConfig; virDomainDriverDetachSoundDeviceConfig; +virDomainDriverDetachTPMDeviceConfig; virDomainDriverDetachVsockDeviceConfig; virDomainDriverDetachWatchdogDeviceConfig; virDomainDriverGenerateMachineName; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c6aead09c9..c12a76749c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9635,6 +9635,12 @@ testDomainDetachDeviceLiveAndConfig(virDomainDef *vm= def, virDomainChrDefFree(chr); break; =20 + case VIR_DOMAIN_DEVICE_TPM: + if (virDomainDriverDetachTPMDeviceConfig(vmdef, dev) < 0) + return -1; + + break; + case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: @@ -9642,7 +9648,6 @@ testDomainDetachDeviceLiveAndConfig(virDomainDef *vmd= ef, case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_AUDIO: --=20 2.33.0 From nobody Sun May 5 13:55:55 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 1629463666338730.8328844920669; Fri, 20 Aug 2021 05:47:46 -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-51-MR132JPvPZ-bQStsYJ323A-1; Fri, 20 Aug 2021 08:47:43 -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 B84311B2C98C; Fri, 20 Aug 2021 12:47:37 +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 9D005369A; Fri, 20 Aug 2021 12:47:37 +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 6E5B24A7CB; Fri, 20 Aug 2021 12:47:37 +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 17KCjEUO013690 for ; Fri, 20 Aug 2021 08:45:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id D8BC2105019F; Fri, 20 Aug 2021 12:45:14 +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 CC15210BC2B9 for ; Fri, 20 Aug 2021 12:45:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 61BC280B907 for ; Fri, 20 Aug 2021 12:45:11 +0000 (UTC) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-IolM3UBvO_WeWxszjcULlw-1; Fri, 20 Aug 2021 08:45:09 -0400 Received: by mail-pl1-f171.google.com with SMTP id f3so5916979plg.3 for ; Fri, 20 Aug 2021 05:45:09 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id y1sm8028889pga.50.2021.08.20.05.45.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:45:07 -0700 (PDT) X-MC-Unique: MR132JPvPZ-bQStsYJ323A-1 X-MC-Unique: IolM3UBvO_WeWxszjcULlw-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=Nnu11hvUXR8e7mwQZWKO8dnODvw/D0+ra5MEprpVfxo=; b=am72XNKGCezvBFZZnSVy5QwnHEvJ+8EiUeHSRAiz/Pt2RuWcRwApgb+iJFPZ4yQKmF 7NCxwslayF77z+Nl5rZMe4N/zUjoIjqfaAqm96PptsD2d0LGbi/ieCqiNiFJjNDq7/yt dW4lCWKoTnEvmGmiWII1lpp5btOLtZ21Ien4pzEiPVXhaE3fbACvJJBOQS37nG/BqlrC nWhoTNeonqBwAe4gOvtpzfBB4o+e/iXjmZKfqnumpf8xQ+VCcIgltp+NevXiYizssrSw 99ydBvYk/sYoZ3BVOKXv+33afMeuf3cgLTr5m37J8k3Y8TPLjJC0rricp0lFT1fSuawW j0ug== X-Gm-Message-State: AOAM533ip/Bl31z+zhS3t4cVbeiv+osJN5bJ44nTo27D1REImt/yf92q M1h+1cVZpUBwplSZqQIfQeVKzv3/7tNV925f0rg= X-Google-Smtp-Source: ABdhPJzxOrMNuRw4+icTo+T5oGC+DPVUtBzuWsciyRNDYKD4Abtn37J2Rcx50oy+w9IB6SCwFaf1xw== X-Received: by 2002:a17:90b:1209:: with SMTP id gl9mr4366574pjb.148.1629463508097; Fri, 20 Aug 2021 05:45:08 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 08/12] conf: Add a memballoon helper for future use Date: Fri, 20 Aug 2021 20:44:35 +0800 Message-Id: <20210820124439.535276-9-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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: 1629463667077100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/conf/domain_conf.c | 24 ++++++++++++++++++++++++ src/conf/domain_conf.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 29 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7f3d207a3e..62bb6669e8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16857,6 +16857,30 @@ virDomainTPMDefRemove(virDomainDef *def, } =20 =20 +bool +virDomainMemballoonDefEquals(const virDomainMemballoonDef *a, + const virDomainMemballoonDef *b) +{ + if (a->model !=3D b->model) + return false; + + if (a->period !=3D b->period) + return false; + + if (a->autodeflate !=3D b->autodeflate) + return false; + + if (a->free_page_reporting !=3D b->free_page_reporting) + return false; + + if (a->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + !virDomainDeviceInfoAddressIsEqual(&a->info, &b->info)) + return false; + + return true; +} + + char * virDomainDefGetDefaultEmulator(virDomainDef *def, virCaps *caps) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b8a1e1d2d2..a18992677b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3827,6 +3827,10 @@ ssize_t virDomainTPMDefFind(const virDomainDef *def, virDomainTPMDef *virDomainTPMDefRemove(virDomainDef *def, size_t idx) ATTRIBUTE_NONNULL(1); =20 +bool virDomainMemballoonDefEquals(const virDomainMemballoonDef *a, + const virDomainMemballoonDef *b) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; + VIR_ENUM_DECL(virDomainTaint); VIR_ENUM_DECL(virDomainTaintMessage); VIR_ENUM_DECL(virDomainVirt); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 349cce2f00..57f0d24c36 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -504,6 +504,7 @@ virDomainLoaderTypeFromString; virDomainLoaderTypeToString; virDomainLockFailureTypeFromString; virDomainLockFailureTypeToString; +virDomainMemballoonDefEquals; virDomainMemballoonModelTypeFromString; virDomainMemballoonModelTypeToString; virDomainMemoryDefFree; --=20 2.33.0 From nobody Sun May 5 13:55:55 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 1629463668054992.0711115323387; Fri, 20 Aug 2021 05:47: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-123-EuoJCW0UO82J5L6AdeFpdg-1; Fri, 20 Aug 2021 08:47:45 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D6E7802935; Fri, 20 Aug 2021 12:47:40 +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 7524D10013C1; Fri, 20 Aug 2021 12:47:40 +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 3B7A4181A3F4; Fri, 20 Aug 2021 12:47:40 +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 17KCjHg3013700 for ; Fri, 20 Aug 2021 08:45:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D6CD20BEAB6; Fri, 20 Aug 2021 12:45: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 7895920B665E for ; Fri, 20 Aug 2021 12:45:14 +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 5CA0C106668A for ; Fri, 20 Aug 2021 12:45:14 +0000 (UTC) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-0MWx8h5zMJKxVaOImgrzQQ-1; Fri, 20 Aug 2021 08:45:12 -0400 Received: by mail-pj1-f47.google.com with SMTP id oc2-20020a17090b1c0200b00179e56772d6so3817988pjb.4 for ; Fri, 20 Aug 2021 05:45:12 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id c16sm6945183pfb.196.2021.08.20.05.45.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:45:10 -0700 (PDT) X-MC-Unique: EuoJCW0UO82J5L6AdeFpdg-1 X-MC-Unique: 0MWx8h5zMJKxVaOImgrzQQ-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=+Ipafn15jeyql9YBYl7Z1Omy+R6Om0k84Zzrw5obRWE=; b=DMO/ZqTicIFAk2x/U+eOVFArQqAcAruQbox9Xtld5riXmljG1NNAmCrcaGncu4W+yp hla4rH/VhD2VdAkgKEu5n+nAhIbc/LjtEFJi1QTe63GnUMBA/B4CduXLxfWMbf7Vvaf7 jNFFTUmmCtZykBcLkIbOJxKc1YMUaCwIp8k9xik/ZFuuWk8a3BpJMOCJTTQII7r2feOP JVaKmqTQh1AvU04Tih4ArcCvoOya3Lg4HchpdZNrGYfeUlD594+pFniigrmfdPEaEZzg CaPNNW0AUYrgX6o3WutuXRWMLUxIziAe304LiQ+5u7rrFCbO4sCeyJOPzgC1PFds28xT itNg== X-Gm-Message-State: AOAM5338Jptk+v2oWt3SB8rjkDdh/Qrwbgb9oqjv20uZFgOPoESAyi6j dkzhrcru7iGuXg7IjylQF/ER4Zs4O2p+RM8fAl8= X-Google-Smtp-Source: ABdhPJx55ibDrwxwT5d16n3/iHtEZd7QFBT15v0PB8t4KXLCg+4/rgEL38J82CYcHUtDlN9mjYi0BA== X-Received: by 2002:a17:90a:ba93:: with SMTP id t19mr4658238pjr.4.1629463511051; Fri, 20 Aug 2021 05:45:11 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 09/12] test_driver: add memballoon support for testDomainDetachDeviceLiveAndConfig Date: Fri, 20 Aug 2021 20:44:36 +0800 Message-Id: <20210820124439.535276-10-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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.84 on 10.5.11.22 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: 1629463669293100001 Content-Type: text/plain; charset="utf-8" As the memballoon device shouldn't be hot-(un)pluggable, so error if try to remove it on a running domain, for removing from config, it's fine. Signed-off-by: Luke Yue --- src/hypervisor/domain_driver.c | 18 ++++++++++++++++++ src/hypervisor/domain_driver.h | 3 +++ src/libvirt_private.syms | 1 + src/test/test_driver.c | 19 ++++++++++++++++--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 93754ae08a..34e225dd2d 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -797,3 +797,21 @@ virDomainDriverDetachTPMDeviceConfig(virDomainDef *vmd= ef, =20 return 0; } + + +int +virDomainDriverDetachMemballoonDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev) +{ + if (!vmdef->memballoon || + !virDomainMemballoonDefEquals(dev->data.memballoon, + vmdef->memballoon)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("matching memballoon device not found")); + return -1; + } + virDomainMemballoonDefFree(vmdef->memballoon); + vmdef->memballoon =3D NULL; + + return 0; +} diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index 6cb9defb58..4d8b1f7b36 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -104,3 +104,6 @@ int virDomainDriverDetachVsockDeviceConfig(virDomainDef= *vmdef, =20 int virDomainDriverDetachTPMDeviceConfig(virDomainDef *vmdef, virDomainDeviceDef *dev); + +int virDomainDriverDetachMemballoonDeviceConfig(virDomainDef *vmdef, + virDomainDeviceDef *dev); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 57f0d24c36..fc4e8736b0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1543,6 +1543,7 @@ virDomainDriverDetachFSDeviceConfig; virDomainDriverDetachHostdevDeviceConfig; virDomainDriverDetachInputDeviceConfig; virDomainDriverDetachLeaseDeviceConfig; +virDomainDriverDetachMemballoonDeviceConfig; virDomainDriverDetachMemoryDeviceConfig; virDomainDriverDetachNetDeviceConfig; virDomainDriverDetachRedirdevDeviceConfig; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c12a76749c..bf26df0d18 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9539,7 +9539,8 @@ testDomainGetMessages(virDomainPtr dom, =20 static int testDomainDetachDeviceLiveAndConfig(virDomainDef *vmdef, - virDomainDeviceDef *dev) + virDomainDeviceDef *dev, + unsigned int flags) { virDomainChrDef *chr; =20 @@ -9641,11 +9642,23 @@ testDomainDetachDeviceLiveAndConfig(virDomainDef *v= mdef, =20 break; =20 + case VIR_DOMAIN_DEVICE_MEMBALLOON: + if (flags & VIR_DOMAIN_AFFECT_LIVE) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("detach of device '%s' on running domain " + "is not supported"), + virDomainDeviceTypeToString(dev->type)); + return -1; + } else { + if (virDomainDriverDetachMemballoonDeviceConfig(vmdef, dev) < = 0) + return -1; + } + break; + case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_PANIC: @@ -9711,7 +9724,7 @@ testDomainChgDevice(virDomainPtr dom, break; =20 case VIR_DOMAIN_DEVICE_ACTION_DETACH: - if (testDomainDetachDeviceLiveAndConfig(def, dev) < 0) + if (testDomainDetachDeviceLiveAndConfig(def, dev, flags) < 0) goto cleanup; break; =20 --=20 2.33.0 From nobody Sun May 5 13:55:55 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 1629463592285983.2613785147033; Fri, 20 Aug 2021 05:46:32 -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-31-ZoQ5xO6jO36N8hbQ9CF5Lg-1; Fri, 20 Aug 2021 08:46:29 -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 1491D94EE5; Fri, 20 Aug 2021 12:46: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 EDF32687D5; Fri, 20 Aug 2021 12:46: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 BAF6E181A2E4; Fri, 20 Aug 2021 12:46:23 +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 17KCjH3G013701 for ; Fri, 20 Aug 2021 08:45:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id B069820B665E; Fri, 20 Aug 2021 12:45:17 +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 ABBF720BEAB7 for ; Fri, 20 Aug 2021 12:45:17 +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 9167B18A6534 for ; Fri, 20 Aug 2021 12:45:17 +0000 (UTC) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-534-W9ay7VfFOE6zjB_pq4xR9Q-1; Fri, 20 Aug 2021 08:45:15 -0400 Received: by mail-pl1-f182.google.com with SMTP id c4so5884475plh.7 for ; Fri, 20 Aug 2021 05:45:15 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id 20sm8401827pgg.36.2021.08.20.05.45.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:45:13 -0700 (PDT) X-MC-Unique: ZoQ5xO6jO36N8hbQ9CF5Lg-1 X-MC-Unique: W9ay7VfFOE6zjB_pq4xR9Q-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=u5aJdIlxwzdO5+BR51wuODccRZnsvmqQV+pFjk1OaDY=; b=TWlsRKtQVKk/WKbdYCxjhM42cwdLdeqewpIBlwfN0recN/qDylyi1B3JQt2u49qNbQ Q4BU95P2jBaUKIGgpw32ybqMRwLju2YtaNxAjNzN/VMXDwCHGnBQkfXeRs1mzggT0aat T4/P6KpOGNHQOYmjwo+UvtXcirfa9t/HVSaO0RLcIh+4mCD2scE7K9hz+WliyI8Fx4Q3 YRlX5mwJb8eb1BTzIe9XAf57YYBWzB/j9d9wd5zrVyCDgUbwTNdZFlM76OI9Yhc9BcnT uBeZt/wdoiJM/0FzIvuev25h4xBPzVetIBHmcKnMst2TWYhi0lqilXcnoq6fvGfSEyLZ Y1Kg== X-Gm-Message-State: AOAM533P9D5s9zu9TP/dfemawMLx73EPmmV8Mx7QklZEuQ+bEgcBgPux QX7OQDDLf69tXMflLp9OTuQlO6xBXYMscWcYjoA= X-Google-Smtp-Source: ABdhPJws3aQr4zW7zgL1JiDVQJEmU4kBVAZDsQUo3WXbkaS1GV7gOvQA1MQ8MOj4VxvX2Z/tHkxoFA== X-Received: by 2002:a17:90b:3718:: with SMTP id mg24mr4609591pjb.158.1629463514014; Fri, 20 Aug 2021 05:45:14 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 10/12] examples: xml: test: add xml for testing devices related APIs Date: Fri, 20 Aug 2021 20:44:37 +0800 Message-Id: <20210820124439.535276-11-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-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: 1629463594295100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- examples/xml/test/testdevcontroller.xml | 1 + examples/xml/test/testdevdiskcdrom.xml | 5 +++ examples/xml/test/testdevfs.xml | 6 +++ examples/xml/test/testdevhostdev.xml | 5 +++ examples/xml/test/testdevif.xml | 6 +++ examples/xml/test/testdevinput.xml | 1 + examples/xml/test/testdevlease.xml | 5 +++ examples/xml/test/testdevmem.xml | 6 +++ examples/xml/test/testdevmemballoon.xml | 3 ++ examples/xml/test/testdevrng.xml | 4 ++ examples/xml/test/testdevshmem.xml | 4 ++ examples/xml/test/testdevsound.xml | 3 ++ examples/xml/test/testdevtpm.xml | 5 +++ examples/xml/test/testdevvsock.xml | 3 ++ examples/xml/test/testdevwatchdog.xml | 1 + examples/xml/test/testdomfc5.xml | 54 +++++++++++++++++++++++++ examples/xml/test/testnodeinline.xml | 54 +++++++++++++++++++++++++ 17 files changed, 166 insertions(+) create mode 100644 examples/xml/test/testdevcontroller.xml create mode 100644 examples/xml/test/testdevdiskcdrom.xml create mode 100644 examples/xml/test/testdevfs.xml create mode 100644 examples/xml/test/testdevhostdev.xml create mode 100644 examples/xml/test/testdevif.xml create mode 100644 examples/xml/test/testdevinput.xml create mode 100644 examples/xml/test/testdevlease.xml create mode 100644 examples/xml/test/testdevmem.xml create mode 100644 examples/xml/test/testdevmemballoon.xml create mode 100644 examples/xml/test/testdevrng.xml create mode 100644 examples/xml/test/testdevshmem.xml create mode 100644 examples/xml/test/testdevsound.xml create mode 100644 examples/xml/test/testdevtpm.xml create mode 100644 examples/xml/test/testdevvsock.xml create mode 100644 examples/xml/test/testdevwatchdog.xml diff --git a/examples/xml/test/testdevcontroller.xml b/examples/xml/test/te= stdevcontroller.xml new file mode 100644 index 0000000000..d855bfa17f --- /dev/null +++ b/examples/xml/test/testdevcontroller.xml @@ -0,0 +1 @@ + diff --git a/examples/xml/test/testdevdiskcdrom.xml b/examples/xml/test/tes= tdevdiskcdrom.xml new file mode 100644 index 0000000000..edc90556bb --- /dev/null +++ b/examples/xml/test/testdevdiskcdrom.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/xml/test/testdevfs.xml b/examples/xml/test/testdevfs.= xml new file mode 100644 index 0000000000..cee5ed4ed9 --- /dev/null +++ b/examples/xml/test/testdevfs.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/xml/test/testdevhostdev.xml b/examples/xml/test/testd= evhostdev.xml new file mode 100644 index 0000000000..e364b50f36 --- /dev/null +++ b/examples/xml/test/testdevhostdev.xml @@ -0,0 +1,5 @@ + + + /dev/sdf1s + + diff --git a/examples/xml/test/testdevif.xml b/examples/xml/test/testdevif.= xml new file mode 100644 index 0000000000..7e0be80050 --- /dev/null +++ b/examples/xml/test/testdevif.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/xml/test/testdevinput.xml b/examples/xml/test/testdev= input.xml new file mode 100644 index 0000000000..d958f5b931 --- /dev/null +++ b/examples/xml/test/testdevinput.xml @@ -0,0 +1 @@ + diff --git a/examples/xml/test/testdevlease.xml b/examples/xml/test/testdev= lease.xml new file mode 100644 index 0000000000..c53c0c7e7d --- /dev/null +++ b/examples/xml/test/testdevlease.xml @@ -0,0 +1,5 @@ + + testarea + testkey + + diff --git a/examples/xml/test/testdevmem.xml b/examples/xml/test/testdevme= m.xml new file mode 100644 index 0000000000..49efd4af55 --- /dev/null +++ b/examples/xml/test/testdevmem.xml @@ -0,0 +1,6 @@ + + + 524287 + 0 + + diff --git a/examples/xml/test/testdevmemballoon.xml b/examples/xml/test/te= stdevmemballoon.xml new file mode 100644 index 0000000000..fde18a9db6 --- /dev/null +++ b/examples/xml/test/testdevmemballoon.xml @@ -0,0 +1,3 @@ + + + diff --git a/examples/xml/test/testdevrng.xml b/examples/xml/test/testdevrn= g.xml new file mode 100644 index 0000000000..369f423740 --- /dev/null +++ b/examples/xml/test/testdevrng.xml @@ -0,0 +1,4 @@ + + + + diff --git a/examples/xml/test/testdevshmem.xml b/examples/xml/test/testdev= shmem.xml new file mode 100644 index 0000000000..04bf3d9a53 --- /dev/null +++ b/examples/xml/test/testdevshmem.xml @@ -0,0 +1,4 @@ + + + 4 + diff --git a/examples/xml/test/testdevsound.xml b/examples/xml/test/testdev= sound.xml new file mode 100644 index 0000000000..cf7323077f --- /dev/null +++ b/examples/xml/test/testdevsound.xml @@ -0,0 +1,3 @@ + + + diff --git a/examples/xml/test/testdevtpm.xml b/examples/xml/test/testdevtp= m.xml new file mode 100644 index 0000000000..cc08b7bf6d --- /dev/null +++ b/examples/xml/test/testdevtpm.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/xml/test/testdevvsock.xml b/examples/xml/test/testdev= vsock.xml new file mode 100644 index 0000000000..dda45780c4 --- /dev/null +++ b/examples/xml/test/testdevvsock.xml @@ -0,0 +1,3 @@ + + + diff --git a/examples/xml/test/testdevwatchdog.xml b/examples/xml/test/test= devwatchdog.xml new file mode 100644 index 0000000000..a02086f296 --- /dev/null +++ b/examples/xml/test/testdevwatchdog.xml @@ -0,0 +1 @@ + diff --git a/examples/xml/test/testdomfc5.xml b/examples/xml/test/testdomfc= 5.xml index a8afc211f6..3b9edb9da9 100644 --- a/examples/xml/test/testdomfc5.xml +++ b/examples/xml/test/testdomfc5.xml @@ -29,6 +29,12 @@