From nobody Fri May 3 20:27:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 163655431138428.513592445720178; Wed, 10 Nov 2021 06:25:11 -0800 (PST) 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-183-YQ4ecdBXMwWXzOZbLQ2i6Q-1; Wed, 10 Nov 2021 09:25:08 -0500 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 3CCCE824F88; Wed, 10 Nov 2021 14:25:03 +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 142F160936; Wed, 10 Nov 2021 14:25:03 +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 CC14F4EA2A; Wed, 10 Nov 2021 14:25:01 +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 1AAEOmgf020109 for ; Wed, 10 Nov 2021 09:24:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E3AB2166B25; Wed, 10 Nov 2021 14:24:48 +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 76F7A2166B26 for ; Wed, 10 Nov 2021 14:24:45 +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 7F9711066684 for ; Wed, 10 Nov 2021 14:24:45 +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-574--1PIpSQoMJ-SqhTcW8mdyg-1; Wed, 10 Nov 2021 09:24:43 -0500 Received: by mail-pf1-f178.google.com with SMTP id n85so2769607pfd.10 for ; Wed, 10 Nov 2021 06:24:43 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id y9sm6053627pjt.27.2021.11.10.06.24.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:24:42 -0800 (PST) X-MC-Unique: YQ4ecdBXMwWXzOZbLQ2i6Q-1 X-MC-Unique: -1PIpSQoMJ-SqhTcW8mdyg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nBA30yNefJevgYBwapC9s4PGqS6V7+3cVDJeJ+jGiZA=; b=YIKETsmItxrGz6plyb1unL11TeEks/nV7UaizWlS28bY/IcxuoMxVagM/szun80Rey uUe8xCcI9eqFR5NNTCGmDDYSExN7WCO5otFhz93KOyH8eQ114o6VMVrpM/k1My9fsyuJ oU1z8DFDX62egHkcQTYceDcuu62mF9qxgkotfDO0o+TjOCn0rEGa9gvRGfue8ai713rz /XZ7m9i5ACcmt0JGnb7LXRqyqxyca8kMaLh2iSNOeJnTO0Go6+v9RkMLLmXXBlIBi3Di xOr9tKShA5PVvFyecDGaLzYXKax8sUyDVesLi1o+4m35XdzB12BX6CPexPox9IAedMQM dkEQ== X-Gm-Message-State: AOAM532tH2h38u51lmUoLNc8/5k6l2cgdl+t49T/sNyrrh0V8s134fcR PfmwqDxEq3kT/95tj4JGMUIZGAqis2YXal8f X-Google-Smtp-Source: ABdhPJy2L+J4jvXOL2vC3LhAMeRbKYJrypZ8TFX1Sq18WhzZ5dv9yEhUpWXvNfGUSfiZP+rnVUZH9A== X-Received: by 2002:a05:6a00:84c:b0:494:6d40:ed76 with SMTP id q12-20020a056a00084c00b004946d40ed76mr48459pfk.65.1636554282385; Wed, 10 Nov 2021 06:24:42 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 01/12] conf: Introduce virDomainInputDefRemove and fix memory leak Date: Wed, 10 Nov 2021 22:24:20 +0800 Message-Id: <20211110142431.10622-2-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.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: 1636554312602100001 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 da0c64b460..3193120b79 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16901,6 +16901,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 ab9a7d66f8..a089b0b3de 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3851,6 +3851,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 9ee8fda25f..000c9893f0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -478,6 +478,7 @@ virDomainInputBusTypeToString; virDomainInputDefFind; virDomainInputDefFree; virDomainInputDefGetPath; +virDomainInputDefRemove; virDomainInputSourceGrabToggleTypeFromString; virDomainInputSourceGrabToggleTypeToString; virDomainInputSourceGrabTypeFromString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6a77d9f513..cf9407c358 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7678,7 +7678,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.1 From nobody Fri May 3 20:27:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 1636554319939532.1640898983674; Wed, 10 Nov 2021 06:25:19 -0800 (PST) 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-133-IeU4XoLEMRWGYQu2mqbANw-1; Wed, 10 Nov 2021 09:25:17 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CBF2824F89; Wed, 10 Nov 2021 14:25:12 +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 19FE079451; Wed, 10 Nov 2021 14:25: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 967C24EA38; Wed, 10 Nov 2021 14:25:11 +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 1AAEOsdB020125 for ; Wed, 10 Nov 2021 09:24:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1CB791121321; Wed, 10 Nov 2021 14:24:54 +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 1706E112131B for ; Wed, 10 Nov 2021 14:24:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 A7DA885A5B9 for ; Wed, 10 Nov 2021 14:24:50 +0000 (UTC) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-H4mLy5fxOcyRRHsAHhf0nw-1; Wed, 10 Nov 2021 09:24:47 -0500 Received: by mail-pf1-f175.google.com with SMTP id z6so2790310pfe.7 for ; Wed, 10 Nov 2021 06:24:47 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id f130sm23260693pfa.81.2021.11.10.06.24.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:24:45 -0800 (PST) X-MC-Unique: IeU4XoLEMRWGYQu2mqbANw-1 X-MC-Unique: H4mLy5fxOcyRRHsAHhf0nw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IykieOzRhMNmRyv9MpYwiK5tsP3E/hqYY3PLtVkOAKA=; b=M+fi1RYqbbO9tih7m/Rtj2wXJjVNdbitQoQQ45USjDcqPydDFHOEk44dhCGZe0x9yu fsjRQ/o+wzUvZkmPJmWudH8UQvz5jzeWr7QX6hYijbWTqTKylvkzs3LKdgKOM+XjvaGs pobIY4D60gWnxKlhJne25UWfrfcPG+PjwDUwIxdiCQ8WtC7q4WTeroI4uuqKrHEQHZtE 41UJxkkc4YYifLKVjvroBmPhsKa74UyDiUMJEJWwx0OpPE4x4lvJMjfd7x0gK1qd3J/s WNH3bBG4jmCj87AiahSmuotELZ0fpW59VpiLlyaXC1ik6kGbR4my1vp0xpdyjLiVVAVM nIQQ== X-Gm-Message-State: AOAM530zje4lowHOJFe/n5jq5wU7g8Y4F7oTcO3hkJVblb4cVMHA7f7t +FP77o0WGPdFuuIewKTWfUqOVV2p3Yo+LKVW X-Google-Smtp-Source: ABdhPJzUQaDrLqQ7l+Ji+qyMZzeo1eDxyXVy9FHCPXGaCp4wE3TyZ2VmISGtP9Gb9notwEJHJF+RVg== X-Received: by 2002:aa7:8d09:0:b0:44b:fd25:dd8a with SMTP id j9-20020aa78d09000000b0044bfd25dd8amr99733507pfe.41.1636554286005; Wed, 10 Nov 2021 06:24:46 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 02/12] domain_driver: extract DetachXXXDeviceConfig related functions and use them Date: Wed, 10 Nov 2021 22:24:21 +0800 Message-Id: <20211110142431.10622-3-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.16 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: 1636554321044100001 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. At the same time, this will enable test driver to test these functions with virshtest in the future. Signed-off-by: Luke Yue --- Not pretty sure whether this is a proper way to make these functions reusable, maybe there is a more elegant choice. --- src/hypervisor/domain_driver.c | 266 +++++++++++++++++++++++++++++++++ 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, 356 insertions(+), 166 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 31737b0f4a..01ecb4e30e 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -644,3 +644,269 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targe= tDef, =20 return ret; } + + +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 7b0fbae2fd..e7fbd70d7b 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -70,3 +70,44 @@ int virDomainDriverDelIOThreadCheck(virDomainDef *def, int virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef, virDomainIOThreadInfoPtr **info, unsigned int bitmap_size); + +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 000c9893f0..0252f7c9d6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1551,6 +1551,20 @@ virDomainCgroupSetupMemtune; # hypervisor/domain_driver.h virDomainDriverAddIOThreadCheck; virDomainDriverDelIOThreadCheck; +virDomainDriverDetachControllerDeviceConfig; +virDomainDriverDetachDiskDeviceConfig; +virDomainDriverDetachFSDeviceConfig; +virDomainDriverDetachHostdevDeviceConfig; +virDomainDriverDetachInputDeviceConfig; +virDomainDriverDetachLeaseDeviceConfig; +virDomainDriverDetachMemoryDeviceConfig; +virDomainDriverDetachNetDeviceConfig; +virDomainDriverDetachRedirdevDeviceConfig; +virDomainDriverDetachRNGDeviceConfig; +virDomainDriverDetachShmemDeviceConfig; +virDomainDriverDetachSoundDeviceConfig; +virDomainDriverDetachVsockDeviceConfig; +virDomainDriverDetachWatchdogDeviceConfig; virDomainDriverGenerateMachineName; virDomainDriverGenerateRootHash; virDomainDriverGetIOThreadsConfig; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 7ea157f9c4..1e3d40f448 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3912,56 +3912,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 e2720a6f89..485683fe3a 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 cf9407c358..d149cd22b2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7517,84 +7517,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 @@ -7606,91 +7565,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.1 From nobody Fri May 3 20:27:32 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 1636554316660996.0158717882505; Wed, 10 Nov 2021 06:25:16 -0800 (PST) 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-592-LMf8XnS7O_mwT24Z4XM80A-1; Wed, 10 Nov 2021 09:25:13 -0500 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 17F286A7; Wed, 10 Nov 2021 14:25:08 +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 EE52E60936; Wed, 10 Nov 2021 14:25:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B35244EA31; Wed, 10 Nov 2021 14:25:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AAEOrTF020120 for ; Wed, 10 Nov 2021 09:24:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1B667404727C; Wed, 10 Nov 2021 14:24:53 +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 17B774047279 for ; Wed, 10 Nov 2021 14:24:53 +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 F1E5480015A for ; Wed, 10 Nov 2021 14:24:52 +0000 (UTC) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-483-WlLGW1l4MwOjr4cstZ0dGg-1; Wed, 10 Nov 2021 09:24:51 -0500 Received: by mail-pf1-f182.google.com with SMTP id c4so2815827pfj.2 for ; Wed, 10 Nov 2021 06:24:51 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id w192sm17607261pfd.21.2021.11.10.06.24.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:24:49 -0800 (PST) X-MC-Unique: LMf8XnS7O_mwT24Z4XM80A-1 X-MC-Unique: WlLGW1l4MwOjr4cstZ0dGg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yhMwmsowKpnmkqqo7u/gaj4Ild4o0KtYuCey7eh1ugw=; b=wWsIvPLpObQVczUX8OyxhCEIh8YkSNa+pFPCcG1wEIBxphOAJABOPD9TqRWmD+E3Q4 1vcDaXAvDmolQ6W9S0o3Od0zPb2PugJnrdQLrLWbLcg3oACeACSnrrrhYlLjwyYYcsSI QrTyLKMPjlnEhE5KaLQz+X1FjNsaDBHXSYcN+4vca2hvEJOI55tDM9e2kulCAQKPQ3ZD w2ie2fUU917iwFNMpKYg3Bc58v4CBCnzL8wQNtCjyhDYQwjUV4HhrNP1M3YsSmAvPBc6 7dtxeED++ILMlUoLKvNk/JG9IQUGSlN2atznxk8iwxgHthTfGqSAOuJ+IG2SL7tawD/7 orpw== X-Gm-Message-State: AOAM532MZagNuiphSmfzyosqrfLl/va8sJ5iwh9Ied2RHe2pg3qr8CmJ gSEN1CluwItA8WiWiBLLjTVk1DzlWMk6JJnN X-Google-Smtp-Source: ABdhPJyfOHXFRgaT4+F46vytyee8idJLYAJzuZR6CMdDxb+QTrmWN567RXEQD6UROfUQfAIg4Cem1g== X-Received: by 2002:aa7:8151:0:b0:480:9d40:8e38 with SMTP id d17-20020aa78151000000b004809d408e38mr16167158pfn.72.1636554289768; Wed, 10 Nov 2021 06:24:49 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 03/12] test_driver: Implement virDomainDetachDeviceFlags Date: Wed, 10 Nov 2021 22:24:22 +0800 Message-Id: <20211110142431.10622-4-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.84 on 10.11.54.2 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: 1636554318582100001 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 | 202 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ea474d55ac..6a7eb12f77 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10051,6 +10051,207 @@ testConnectGetAllDomainStats(virConnectPtr conn, return ret; } =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 */ @@ -10148,6 +10349,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.10.0 */ .domainGetAutostart =3D testDomainGetAutostart, /* 0.3.2 */ .domainSetAutostart =3D testDomainSetAutostart, /* 0.3.2 */ .domainGetDiskErrors =3D testDomainGetDiskErrors, /* 5.4.0 */ --=20 2.33.1 From nobody Fri May 3 20:27:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 1636555186241292.1163982185128; Wed, 10 Nov 2021 06:39:46 -0800 (PST) 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-323-_Ltje8CfM1GekWnhatt__A-1; Wed, 10 Nov 2021 09:39:43 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B7D98B428F; Wed, 10 Nov 2021 14:39:14 +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 BF6521700F; Wed, 10 Nov 2021 14:39: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 4F7725533F; Wed, 10 Nov 2021 14:39:11 +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 1AAEOuZL020146 for ; Wed, 10 Nov 2021 09:24:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 737212026D48; Wed, 10 Nov 2021 14:24:56 +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 6DA512026D65 for ; Wed, 10 Nov 2021 14:24:56 +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 10006185A7B2 for ; Wed, 10 Nov 2021 14:24:56 +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-32-2Ifk7l3rMWCcAYO5UuZPKg-1; Wed, 10 Nov 2021 09:24:54 -0500 Received: by mail-pf1-f178.google.com with SMTP id c126so2855995pfb.0 for ; Wed, 10 Nov 2021 06:24:54 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id p25sm22990935pfh.86.2021.11.10.06.24.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:24:52 -0800 (PST) X-MC-Unique: _Ltje8CfM1GekWnhatt__A-1 X-MC-Unique: 2Ifk7l3rMWCcAYO5UuZPKg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TE4EUMHchfU7MrbIDSoBZs3NrEqTAg+OlO1shhtgri0=; b=x137ND3K1X2Jmyl/2evusnKreIQGTroEH7UekokBzj9mQp9YaApxqSlDgdJmoU+ASY 0eGfjoHiu++lxCtAggNfEwmrnx2OcPeNgi/CJJH6ekLmdl1ZxJb1mBT5lk+vz2vC5kCb SM25MUhquOaGQmD8vZwBtGQ+zqxwGkfUfmuSXtjaslywO567CImZjW5qrvRIuxKf2VlE Vn/zbizVl/RvOir13+1JO4DvRlOwLcpV3WVJ0aLpJnnGVrSAUpYE6KvRj7x5ToEBYe1S X8aw20Ze6ZH6ZyigR7yiFzIgYqQ8gNkCGU6Q1IqbqqUqC6DhTVe1N6GK95HV19C3ZjAz pWGA== X-Gm-Message-State: AOAM531BwBtrFrCvAjfRerK1EhET8aSc85LAaaWq6YC7IozsJwkFYngA jWKOUMXuFd/hlnqhI1QfWLbcet6GJRfoXrQR X-Google-Smtp-Source: ABdhPJxzqho1UIT2auV4WEsFX5nGeOoO98zJmiPOaQ8c5m8Vv/uwqHmEKhtn+qw/JOxNyLLr/MdfuQ== X-Received: by 2002:a63:8f02:: with SMTP id n2mr170304pgd.270.1636554292954; Wed, 10 Nov 2021 06:24:52 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 04/12] test_driver: Implement virDomainDetachDeviceAlias Date: Wed, 10 Nov 2021 22:24:23 +0800 Message-Id: <20211110142431.10622-5-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.23 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: 1636555187687100001 Content-Type: text/plain; charset="utf-8" As we already implement testDomainChgDevice for both DetachDeviceFlags and DetachDeviceAlias, so it's simple to implement this API by changing the parameter. Signed-off-by: Luke Yue --- src/test/test_driver.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6a7eb12f77..9843340fec 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10252,6 +10252,15 @@ testDomainDetachDeviceFlags(virDomainPtr dom, xml, NULL, flags); } =20 +static int +testDomainDetachDeviceAlias(virDomainPtr dom, + const char *alias, + unsigned int flags) +{ + return testDomainChgDevice(dom, VIR_DOMAIN_DEVICE_ACTION_DETACH, + NULL, alias, flags); +} + /* * Test driver */ @@ -10349,6 +10358,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.10.0 */ .domainDetachDeviceFlags =3D testDomainDetachDeviceFlags, /* 7.10.0 */ .domainGetAutostart =3D testDomainGetAutostart, /* 0.3.2 */ .domainSetAutostart =3D testDomainSetAutostart, /* 0.3.2 */ --=20 2.33.1 From nobody Fri May 3 20:27:32 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 1636554329682238.71241016082342; Wed, 10 Nov 2021 06:25:29 -0800 (PST) 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-126-bF_rnStdNe2wioaAHiOLgQ-1; Wed, 10 Nov 2021 09:25:25 -0500 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 E47BF1023F50; Wed, 10 Nov 2021 14:25:19 +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 BDAD660E1C; Wed, 10 Nov 2021 14:25: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 850094EA3E; Wed, 10 Nov 2021 14:25:19 +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 1AAEP0TP020164 for ; Wed, 10 Nov 2021 09:25:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 232CD2026D5D; Wed, 10 Nov 2021 14:25:00 +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 1DEDB2026D48 for ; Wed, 10 Nov 2021 14:25:00 +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 03F36811E7F for ; Wed, 10 Nov 2021 14:25:00 +0000 (UTC) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-H_b6mYTPMti60Kcy1uITUw-1; Wed, 10 Nov 2021 09:24:57 -0500 Received: by mail-pf1-f175.google.com with SMTP id o4so2759597pfp.13 for ; Wed, 10 Nov 2021 06:24:57 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id g5sm5898716pjt.15.2021.11.10.06.24.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:24:56 -0800 (PST) X-MC-Unique: bF_rnStdNe2wioaAHiOLgQ-1 X-MC-Unique: H_b6mYTPMti60Kcy1uITUw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eXtEF8MHXDpI7dfaONRkUh4tzaAZwBe/wsRMCcHDotI=; b=ipDfVN1H4FrWBE+v5lP9Yh1eaOOvu/iP+1mcinzVK6ACGwVJ4CoFwnpWvQ63CTolpb 12zX/pnfDlAUbtO8EYhxyS+NtV14MFG5rnYEJN6F+k0J3Py6lLi+HNABSkaxT6AdZDyV pijB/LSpkNMrKdfrthezm9UNlC6z4YbVjiw+Envv+/y8lqlTuWb6nUA14PrdqWkcgn2T g3XKkY/56mOa8R4Ng6kodG3itHXlYmzslk6MlVm2/aRmuJ7hD5UAE/Ar2+pu3QNMWD96 UidbhmllcAz26CGBVzxQFlpQ/AmGGGvS/uCIGDKoK7HiqZ10EDf5+CvlEF4kx2l7dj4X EQFA== X-Gm-Message-State: AOAM532lxEL4M1qRyWDs7uaCy/Y9OKangXxEWv/tv13egtgNFvod2zx6 i6HQNVaaH4rFs0odDKZ6kzSskWY4RpRF6OwN X-Google-Smtp-Source: ABdhPJyqIGw9rCJpq9TsgNLtojl0qmh22nW2XYL9+Rf0Y0m/q4mchMgzwyqR0/CWsKMTc3DPRAFguQ== X-Received: by 2002:a63:ea4e:: with SMTP id l14mr160835pgk.406.1636554296597; Wed, 10 Nov 2021 06:24:56 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 05/12] test_driver: Implement virDomainDetachDevice Date: Wed, 10 Nov 2021 22:24:24 +0800 Message-Id: <20211110142431.10622-6-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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: 1636554330649100001 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 9843340fec..b1ca6a7b97 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10261,6 +10261,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 */ @@ -10358,6 +10366,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.10.0 */ .domainDetachDeviceAlias =3D testDomainDetachDeviceAlias, /* 7.10.0 */ .domainDetachDeviceFlags =3D testDomainDetachDeviceFlags, /* 7.10.0 */ .domainGetAutostart =3D testDomainGetAutostart, /* 0.3.2 */ --=20 2.33.1 From nobody Fri May 3 20:27:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 1636555727493211.8129465081946; Wed, 10 Nov 2021 06:48:47 -0800 (PST) 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-277-vm1Qb3XNOiWGEuhmojf8dQ-1; Wed, 10 Nov 2021 09:48:45 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AAB5B8799F1; Wed, 10 Nov 2021 14:48:39 +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 228EB794A4; Wed, 10 Nov 2021 14:48:39 +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 7072C1832DF4; Wed, 10 Nov 2021 14:48:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AAEP6kE020201 for ; Wed, 10 Nov 2021 09:25:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id A34E9404727D; Wed, 10 Nov 2021 14:25:06 +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 9EAD9404727E for ; Wed, 10 Nov 2021 14:25:06 +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 86AD7811E78 for ; Wed, 10 Nov 2021 14:25:06 +0000 (UTC) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-384-vnKokFA6OQmWfrlHwYOjxA-1; Wed, 10 Nov 2021 09:25:01 -0500 Received: by mail-pf1-f172.google.com with SMTP id m14so2777274pfc.9 for ; Wed, 10 Nov 2021 06:25:01 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id 145sm22506359pfx.87.2021.11.10.06.24.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:24:59 -0800 (PST) X-MC-Unique: vm1Qb3XNOiWGEuhmojf8dQ-1 X-MC-Unique: vnKokFA6OQmWfrlHwYOjxA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2AxA5nlO5abkkf381woSUODTbduubibgFXrQF8Rb+Lg=; b=FBn9gC5KSlLVjGCqJRSQlyaMCvd1tre3WAOPiI0mmaUMkptO74M/dNPhwBgH2r9hzY Kv0mpzoIW1DUT9hdeWOi+5PZRbBu5+ElBBoP8UTWDctyVh5tnePkto4JCodYmRq2a+KW jRUnglhBlx2goi0FQmGSwW018zBxsrGqWrDA28P4AFihKar2UdSa+2EwHzTgShQufbxQ vm7a8jXGQOPv1SYpgdlhu96wHJ4fh5gD6PmHuwv+9+5/cQBHxtB+7aEuPTKLYPjCUU1/ n+wOCi8uk2+fK19KhnXqI9lBC0w4k/PF8rnl/7u/fc4vSx4+piayGtpoEm8wW3sOTlv+ 1zmA== X-Gm-Message-State: AOAM5316A9kJqvL3xXXpL92vjxFXUrzp2MRZylsExUgBMu+WY88gqwxl 92YbC2kIpQ7NKf1tdPlw3LrQWpKptmGnY2Pt X-Google-Smtp-Source: ABdhPJzpzpTJUaPvufUvk0XRGp5fKm9/pP9IByY2k9EPDsqPUh0icAheqHp4PEI+1HyuAk9A0W/q2Q== X-Received: by 2002:a63:68c9:: with SMTP id d192mr135969pgc.335.1636554299908; Wed, 10 Nov 2021 06:24:59 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 06/12] conf: Add tpm helpers for future use Date: Wed, 10 Nov 2021 22:24:25 +0800 Message-Id: <20211110142431.10622-7-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.84 on 10.11.54.2 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.16 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: 1636555727977100001 Content-Type: text/plain; charset="utf-8" Currently it will only be used in the test driver. 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 3193120b79..512bfab9e9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16931,6 +16931,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 a089b0b3de..715c8fbd16 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3857,6 +3857,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 0252f7c9d6..68cc9c51cb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -665,7 +665,9 @@ virDomainTimerTrackTypeFromString; virDomainTimerTrackTypeToString; virDomainTPMBackendTypeFromString; virDomainTPMBackendTypeToString; +virDomainTPMDefFind; virDomainTPMDefFree; +virDomainTPMDefRemove; virDomainTPMModelTypeFromString; virDomainTPMModelTypeToString; virDomainTPMPcrBankTypeFromString; --=20 2.33.1 From nobody Fri May 3 20:27:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 16365551982297.334429495071959; Wed, 10 Nov 2021 06:39:58 -0800 (PST) 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-135-T6TjGtgcNEuj0929xXnE0Q-1; Wed, 10 Nov 2021 09:39:54 -0500 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 78490A7185; Wed, 10 Nov 2021 14:39:23 +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 59E3267840; Wed, 10 Nov 2021 14:39: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 E1A5518199EE; Wed, 10 Nov 2021 14:39:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AAEP6AV020200 for ; Wed, 10 Nov 2021 09:25:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7CEBE404727C; Wed, 10 Nov 2021 14:25:06 +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 790E64047279 for ; Wed, 10 Nov 2021 14:25:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6057A811E78 for ; Wed, 10 Nov 2021 14:25:06 +0000 (UTC) Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-biBsmm50OWOYD2ArLgKxhw-1; Wed, 10 Nov 2021 09:25:04 -0500 Received: by mail-pg1-f181.google.com with SMTP id f5so2377613pgc.12 for ; Wed, 10 Nov 2021 06:25:04 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id g9sm8831044pfc.182.2021.11.10.06.25.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:25:02 -0800 (PST) X-MC-Unique: T6TjGtgcNEuj0929xXnE0Q-1 X-MC-Unique: biBsmm50OWOYD2ArLgKxhw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yF8QIn3JbC2dR9qHpeNWW3hPM5y7FP42D1OMIocQsVM=; b=ei5lGil0QvWDVF3MYgiDrUcJ4CXxcO+4YClDCeZiA/XtRnde29+27+ImS3lG0iA6NF CywkLmylQIoGp7tIPOsJYnGthq9m74YBt2wSL0XyeKniZxbikk4S4/grHpzOtOOCQHn/ R//g8z/gxG3JVqs/01Ch/ewwdpddW9mRVGz/3+kXBOO9wmINX9DnflMG6Xhv+3tydkkK 8pk2Yk+aogmSYGw08tcT0kp8+Brmn1QdlS3dWfllTPcPcFTJRhjW6wydwdJkWPaFj88Y JUfhfGDj5BjM/df9gUwZpjWqJ/bNIkP4c216Zugw4gBhZVdYPCOT2dwvOAksBRLWEmQV UBmQ== X-Gm-Message-State: AOAM530cT+oKyqstiHz8vSZO/O3VShdjN7DbojwzCqWVZGDYIKGyTAch 7u9qymdOy6mCwFbpILQz6Q5TBMMJWcC/3Heq X-Google-Smtp-Source: ABdhPJwUdTZYhZgdGwableufblJgNkqUjLNEXtzBZjy4JSoPfLJFzgMYnc2MOya0G77O0otnNmKt+A== X-Received: by 2002:a65:5bc8:: with SMTP id o8mr186685pgr.92.1636554303106; Wed, 10 Nov 2021 06:25:03 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 07/12] test_driver: add TPM support for testDomainDetachDeviceLiveAndConfig Date: Wed, 10 Nov 2021 22:24:26 +0800 Message-Id: <20211110142431.10622-8-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.84 on 10.11.54.2 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: 1636555198866100001 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 01ecb4e30e..2461d977a3 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -910,3 +910,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 e7fbd70d7b..51dc109c38 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -111,3 +111,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 68cc9c51cb..cfda58320a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1565,6 +1565,7 @@ virDomainDriverDetachRedirdevDeviceConfig; virDomainDriverDetachRNGDeviceConfig; virDomainDriverDetachShmemDeviceConfig; virDomainDriverDetachSoundDeviceConfig; +virDomainDriverDetachTPMDeviceConfig; virDomainDriverDetachVsockDeviceConfig; virDomainDriverDetachWatchdogDeviceConfig; virDomainDriverGenerateMachineName; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b1ca6a7b97..15b4332769 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10149,6 +10149,12 @@ testDomainDetachDeviceLiveAndConfig(virDomainDef *= vmdef, 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: @@ -10156,7 +10162,6 @@ testDomainDetachDeviceLiveAndConfig(virDomainDef *v= mdef, 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.1 From nobody Fri May 3 20:27:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 1636554346043303.8141198583004; Wed, 10 Nov 2021 06:25:46 -0800 (PST) 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-197-uxsbpptlNj-ha0L03mA12g-1; Wed, 10 Nov 2021 09:25:43 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7404F5203; Wed, 10 Nov 2021 14:25:35 +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 5006F1970E; Wed, 10 Nov 2021 14:25:35 +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 617231832DD2; Wed, 10 Nov 2021 14:25: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 1AAEPFub020261 for ; Wed, 10 Nov 2021 09:25:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0A95D2026D48; Wed, 10 Nov 2021 14:25:15 +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 026A12026D65 for ; Wed, 10 Nov 2021 14:25:09 +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 773DE181B7A5 for ; Wed, 10 Nov 2021 14:25:09 +0000 (UTC) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-jLG8gkPBOb6oHUpLqzc7sQ-1; Wed, 10 Nov 2021 09:25:07 -0500 Received: by mail-pf1-f177.google.com with SMTP id x64so2800164pfd.6 for ; Wed, 10 Nov 2021 06:25:07 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id b4sm24268241pfl.60.2021.11.10.06.25.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:25:06 -0800 (PST) X-MC-Unique: uxsbpptlNj-ha0L03mA12g-1 X-MC-Unique: jLG8gkPBOb6oHUpLqzc7sQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=50g5NT1J0zqaE8GTuuYsj23bfnifY7jvDP31+Y7vdQI=; b=OmR9XkdX7dGU7lqIaBfXdsu9HEypPyvu5oH48WMAs42ADiDoVt9p0yHJ8Uq+b4u3bU BGmdvkff1JZNxcsO21d+AX4T5I7EaIJEx2GCPSh0HZGwS/1th73ThEf016Bc4KyUrjkF +s70FHnO7ruEwJuWAbM7sMyWyeQNErfCFD2xPuq7WroAZdf0lXVTIxXPo9dmqGJQRsVv /M/tB5NWGBm/udxf4d2YaJGGzITd/VK5Vq4PqM7OD6GQfRby/+yvfF2EovbxzsLdU3+k Sv/xEX2gyWbn560/unb3g7qwo0t4uCIoCJFOFP+e70NHxYImrLNkTThxhPcO0w4WpnwS fbLw== X-Gm-Message-State: AOAM5321QXnZP5aPLzdbAP4anDJdqvqI22DJY9XpJiiBIa76/izrWAtm d2I0udFlAt+MuOwJT+yPgcxQMYt053ZxPl0f X-Google-Smtp-Source: ABdhPJzLA97iZB8A08bFNW7lUw+RhgewmgUnoQBc7avnWGD0peu8Kqd1KChetESnPQzSRR5SiYcI/g== X-Received: by 2002:a62:1b86:0:b0:47b:d112:96d4 with SMTP id b128-20020a621b86000000b0047bd11296d4mr244917pfb.52.1636554306382; Wed, 10 Nov 2021 06:25:06 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 08/12] conf: Add a memballoon helper for future use Date: Wed, 10 Nov 2021 22:24:27 +0800 Message-Id: <20211110142431.10622-9-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.23 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: 1636554346986100001 Content-Type: text/plain; charset="utf-8" Currently it will only be used in test driver. 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 512bfab9e9..92a8bd63f3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16998,6 +16998,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 715c8fbd16..f60ba37d19 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3863,6 +3863,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 cfda58320a..b143537bb4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -506,6 +506,7 @@ virDomainLoaderTypeFromString; virDomainLoaderTypeToString; virDomainLockFailureTypeFromString; virDomainLockFailureTypeToString; +virDomainMemballoonDefEquals; virDomainMemballoonModelTypeFromString; virDomainMemballoonModelTypeToString; virDomainMemoryDefFree; --=20 2.33.1 From nobody Fri May 3 20:27:32 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 1636555742210294.3040081720593; Wed, 10 Nov 2021 06:49:02 -0800 (PST) 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-368-elA-tr-VO2-YFnyfX_B1bw-1; Wed, 10 Nov 2021 09:48:56 -0500 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 E757B100CCE4; Wed, 10 Nov 2021 14:48:50 +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 EDFC867C73; Wed, 10 Nov 2021 14:48:49 +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 C0BCA4EA30; Wed, 10 Nov 2021 14:48:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AAEPDJQ020243 for ; Wed, 10 Nov 2021 09:25:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3847B400DB2F; Wed, 10 Nov 2021 14:25:13 +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 3379F40CFD0B for ; Wed, 10 Nov 2021 14:25:13 +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 1A957106668B for ; Wed, 10 Nov 2021 14:25:13 +0000 (UTC) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-LVkb3PJIMP62iv72LQ6peQ-1; Wed, 10 Nov 2021 09:25:11 -0500 Received: by mail-pf1-f170.google.com with SMTP id c4so2816644pfj.2 for ; Wed, 10 Nov 2021 06:25:11 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id na13sm6912964pjb.11.2021.11.10.06.25.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:25:09 -0800 (PST) X-MC-Unique: elA-tr-VO2-YFnyfX_B1bw-1 X-MC-Unique: LVkb3PJIMP62iv72LQ6peQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6flf84F2RaATciJTYvsnWBDtUyawqlidUM/GBzQKWXs=; b=OfFsuOO1HMkE4W+w1/BuEabDWydU601wnJVBQafWwUpnNi3DjkwsQIl/DdcoWtq8kh UkN07MQJ/I4yGjUU+dAkJFT2fca4yHfZ7d+jQCgSf2tb+tsLqN/Oz8PuuTVKGKg1wQ9t g19L8UmH7WcRPT6zj6x8jPJxFlSDaW6PEQQR2Hwzlr9iEmtFGjPA3ZF7I6dlNUVNmvX3 vMTbmGYSoewriS+c3oNYyfxL2YaMdAIZ4n1/pVWgQLUX/Iy47mfp1XIGQqVuhJlPDkHT wIPqQvujrIB+GiaUNXKSavvQwDb4b/OL960NtAQ88jHo+WakvROHYaZZ3qDzo2QHNc/+ mrQA== X-Gm-Message-State: AOAM530bLZxph639ttLAw/nzACqEqgACHy4spmm5XaYSk9sio7WhS1j2 eJRiA4k9WBnXFbJuPS6Y/sB3DuZvPP3UUvb/ X-Google-Smtp-Source: ABdhPJwyiyROnorGRLFUwn9yQuecFXLzjU75OO76STqzWyujI8Q7ztlKBo5JxkR9rfG/koUiZQNALQ== X-Received: by 2002:a63:f960:: with SMTP id q32mr154583pgk.61.1636554309977; Wed, 10 Nov 2021 06:25:09 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 09/12] test_driver: add memballoon support for testDomainDetachDeviceLiveAndConfig Date: Wed, 10 Nov 2021 22:24:28 +0800 Message-Id: <20211110142431.10622-10-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.84 on 10.11.54.1 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: 1636555744273100001 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 2461d977a3..0a0ff7b361 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -928,3 +928,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 51dc109c38..5920854b13 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -114,3 +114,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 b143537bb4..19cc301a20 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1560,6 +1560,7 @@ virDomainDriverDetachFSDeviceConfig; virDomainDriverDetachHostdevDeviceConfig; virDomainDriverDetachInputDeviceConfig; virDomainDriverDetachLeaseDeviceConfig; +virDomainDriverDetachMemballoonDeviceConfig; virDomainDriverDetachMemoryDeviceConfig; virDomainDriverDetachNetDeviceConfig; virDomainDriverDetachRedirdevDeviceConfig; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 15b4332769..317aa0181b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10053,7 +10053,8 @@ testConnectGetAllDomainStats(virConnectPtr conn, =20 static int testDomainDetachDeviceLiveAndConfig(virDomainDef *vmdef, - virDomainDeviceDef *dev) + virDomainDeviceDef *dev, + unsigned int flags) { virDomainChrDef *chr; =20 @@ -10155,11 +10156,23 @@ testDomainDetachDeviceLiveAndConfig(virDomainDef = *vmdef, =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: @@ -10225,7 +10238,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.1 From nobody Fri May 3 20:27:32 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 16365557442971016.4730915237374; Wed, 10 Nov 2021 06:49:04 -0800 (PST) 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-519-luLmxsuzPJCaSoo2JQtCZw-1; Wed, 10 Nov 2021 09:48:58 -0500 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 427AE100CCC2; Wed, 10 Nov 2021 14:48:53 +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 23EBD6786E; Wed, 10 Nov 2021 14:48:53 +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 E4E204EA3C; Wed, 10 Nov 2021 14:48:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AAEPHYK020293 for ; Wed, 10 Nov 2021 09:25:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4BD47404727C; Wed, 10 Nov 2021 14:25:17 +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 47AB04047279 for ; Wed, 10 Nov 2021 14:25:17 +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 2913685A5B5 for ; Wed, 10 Nov 2021 14:25:17 +0000 (UTC) Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-XOXBqEdiNP68fVR0h7kthA-1; Wed, 10 Nov 2021 09:25:15 -0500 Received: by mail-pg1-f182.google.com with SMTP id r28so2457772pga.0 for ; Wed, 10 Nov 2021 06:25:15 -0800 (PST) Received: from localhost ([2400:ddc0:1000::b373:390c]) by smtp.gmail.com with ESMTPSA id e15sm3200386pfv.131.2021.11.10.06.25.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 06:25:13 -0800 (PST) X-MC-Unique: luLmxsuzPJCaSoo2JQtCZw-1 X-MC-Unique: XOXBqEdiNP68fVR0h7kthA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bqYNrviUFRQrNboZMH6KJu+K8DPm4EEGQxfdQHK90b4=; b=ZjH9NzZzIy2+sLbxn/UZMNj+IMAj8aS+lh9Pxgj9hPHOx2GTo19qYOH+ZfO5D0xKcY ctaMY91nfF85THfkOheyfqe6y6Y23XPDLDbxTSCDcNpiEAujf1LcjzDC8b0GrxFshENW UL/jVS+5vdEf/AroKQEBh+l4PTtBl0SAylBfXPobgT9tDlRjC64Ri3wSVKeRcCvGAFbQ NrUnWlIeRQQppjLDWAz4IKcuowkeqKvtka8Ik5TdHG2SA9IHg1vZytoHjrhVPBi3gwXo Zaz0noodWMrV6OyTLaKZ/bcFrohMvBLUX1CVDaV8B0wiM1KbJIRNIJNbR+uGmhf2pfYg T/Fw== X-Gm-Message-State: AOAM532Sw3sDSQxIOL24jWDgn79jyfkOIG+X5+7zMwPXApTFjxiOAtr9 XiUuYSCQrJhvYY07NRqHuziJX6B6O1TxjAiB X-Google-Smtp-Source: ABdhPJzZSPGvf3l/alTKMAxRp4O3AojqDujO92nuG1C31xoc6YSamXTAK58IBvsR13cHEbb0XEC8vQ== X-Received: by 2002:a63:5308:: with SMTP id h8mr137694pgb.287.1636554313847; Wed, 10 Nov 2021 06:25:13 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 10/12] examples: xml: test: add xml for testing devices related APIs Date: Wed, 10 Nov 2021 22:24:29 +0800 Message-Id: <20211110142431.10622-11-lukedyue@gmail.com> In-Reply-To: <20211110142431.10622-1-lukedyue@gmail.com> References: <20211110142431.10622-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.84 on 10.11.54.2 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: 1636555746445100001 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 @@