From nobody Thu Oct 31 00:23:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=nutanix.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1722512960314120.44281066218252; Thu, 1 Aug 2024 04:49:20 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1586913BC; Thu, 1 Aug 2024 07:49:19 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 23FB913B2; Thu, 1 Aug 2024 07:48:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 367D71424; Thu, 1 Aug 2024 07:48:10 -0400 (EDT) Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id EDD871424 for ; Thu, 1 Aug 2024 07:48:01 -0400 (EDT) Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4718HpC4022096 for ; Thu, 1 Aug 2024 04:48:01 -0700 Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azlp17010002.outbound.protection.outlook.com [40.93.12.2]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 40q9ch45e9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 01 Aug 2024 04:48:00 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by MN6PR02MB10632.namprd02.prod.outlook.com (2603:10b6:208:4ef::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.29; Thu, 1 Aug 2024 11:47:58 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%4]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 11:47:58 +0000 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=uT61jtJw2hTm8xquGRxQ+lMJq2h5f65y0vehqDqeQ 7A=; b=btwMtGzaFca4Vn6G7QNLzbzf8ybdO3TCNDh86vpQKRwGcBFIxNoWiyyUh IosFF/8Cm6XmTqheDXYYeJ01KgDyra7xIY8NhHQses8PIeTOVLLjHYWquEwu0mDa 1XOHJ6lcfvB8TMbEeg5XMkH5KYziRA2ii+6scc8s5deKRRY60nojM5ftaP4ijtZI BqJFAHDil9Cm6pdz5u/WW27dHJJupQVYW+WfWG7P5buzX7lK1WcMM7i9wu/uhn3N Qx9fgMimIo/qvYyoFkMh3YbIMPUae+0jM9jC3hUCa2TXgvj/tTI2zkkMUux6B6bv wmBm2XISp6q3zwSPvXT6XaGBql/pA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CzrAhtLN5C3tVDG55L8FFVMAa3VG+09cSRnSI7ZnyGcPOJXNIJDa6TbWQVdnWO4YWrzuvEv2gFCG/rH8FG4EUuBi9KLhahYOoLrnVGyL56Bi/PeBWFz828aH+V/MCec6rM+NQnpPjOPG8I5/KD3neF1SOTUyoiWId4fx8kXh5WMijVz8J3kDB/dP6ZHkq2rL8iRi+vWniuYfTNZPRaMUQ0IceCOUAlMxye2Rn0xj3JqFtb0y1LE/NnlRWeDY+9r6rg2Yj7cdUB8tqNtti8yX0KnNt6Fv9+wrltr/KNVQu0CsE3/y42FUeZYz7rsLIzU4ne7OJV5e77UwG7Wu1HKUJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uT61jtJw2hTm8xquGRxQ+lMJq2h5f65y0vehqDqeQ7A=; b=hpEhF235kBnA9TdwGJwrDHlZw7kSIg7Rkk3OwCI0Zo2fOGD1P4fBwN1v7H5YD8mavBp3X1RiI2IKqEc8LszLVx3ZOx1Q0oG21K8a6ZU6m6vr6sfdnI2Ieynnkpj29kidZlAz/BeyNSvTii3eroHKLT8uz8ro0VUN8UFEo5gSB2Ln+5aTpYq+63muIu0qeBZ7rLmEWINKkoxCsunxbg8kvt0kB4jcU8q0uvRTfXSCXao2cYxBHqeBE+GniUt44JqGDYIivPm4Q7qlVXRtUUivWRh7/f6VMN35TDzuFBSES9Rw53Fj6M32GSX4xPfmGGvocQOf7EvyJvJeR9DTUr9vwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uT61jtJw2hTm8xquGRxQ+lMJq2h5f65y0vehqDqeQ7A=; b=KOxGssF4E5Gb6mYG24VeTCKDObQmEsIy9jSLzmvE3vTGRx9NSk7tskhYEPmnyKR4WGrZXuKXP9ofgwr8THiHb/4m25e26bV41l/YW7GGACENTddov3TS5yGaO9BsJ1nN/I2V5V4IWif2cwfINEHjn2MT/5kw/FwUX72F7MPcUPbbuno9cBhylQmPcJ1pWrcRwVx2OgmQulL/sYKKfrUWjZyDo+QciLZFwPdwpboBhYyNyaLce9thYK3qqS5WUx6fmI23rZvnJzMDzdZiNM4+dUGD03Db5dS6jgbz0OFINoqZnXifD2atZ/9SStcMBdWB61zmRfwNn4A0EYYF9eZrcQ== From: John Levon To: devel@lists.libvirt.org Subject: [PATCH 2/2] test_driver: provide basic NIC hotunplug support Date: Thu, 1 Aug 2024 12:47:41 +0100 Message-Id: <20240801114741.224919-3-john.levon@nutanix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240801114741.224919-1-john.levon@nutanix.com> References: <20240801114741.224919-1-john.levon@nutanix.com> X-ClientProxiedBy: AM0PR10CA0020.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::30) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|MN6PR02MB10632:EE_ X-MS-Office365-Filtering-Correlation-Id: b00577dc-838b-401f-13fe-08dcb21fca27 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HBIqctgxiAPN5zjiXIIOv9ZnS9/aK3hx9ng6Ju+AtOCdc6ubWPS7XS+DADYy?= =?us-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tdzK+GNrorlA/flr9k8fSmtjFDsKls9xspE9?= =?us-ascii?Q?6E9e9Jsqst34etsRK1vuJEfHknG825V36awMfk5pmL14Z0fjEHF8A0jils6x?= =?us-ascii?Q?xp/Mr5I1SibJg4k0I8Q33Voms1kXw9G0hSa0e8vHlLKLAVXpvG31xBoBZ8j/?= =?us-ascii?Q?v5UF2Hv6rGYEmWfXqBLTWZEdTBz92BL/LrCvbeLBT3O0Zxcu8+NhqHQnQ7v2?= =?us-ascii?Q?At2Y4luepxatnJZMVOCXC6hzLC3ZhZ1YjbLvznlVrk3uhAaGT6nsMjDnhlcR?= =?us-ascii?Q?eSBHUKLvFoIPvj3wOzhyQRi44+a05k3ZgX7QnuQLq81ZUmEp/UpIRfNdyFOy?= =?us-ascii?Q?kQtNQIkXf4I0GFPgmdaj3CaDjyvTxrOgy201Kwg9fJbWb1xV/diaCr4IvUs9?= =?us-ascii?Q?gUSW1mdicmJMJIoq5Z5+3yN9KMuOh+R7lZVzMOWoG39oEw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR02MB6760.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jGNtM26CgrNsPUEArc4IvI2w447SJxpUXtfN2uHXMhpXUE/x9VmQ6O3Ily85?= =?us-ascii?Q?CaAfE+6mLVS3gZkg5w1uRfy+t6+V3TetSUmgX41AmTBfrXWBD92J63ajnYRh?= =?us-ascii?Q?CPAPsuxwWKqC/JE9dL5Ov0lK3oDFqhThva8l9ftKoydQxVW2aUy0ww3SzdlN?= =?us-ascii?Q?nE5O/N20LkGMmDQ5FLwX4E+s+2aqrB+xg+9RYjaHUkyYFC4+poV6EHQZEOG9?= =?us-ascii?Q?Mr2aH/q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j78AchP?= =?us-ascii?Q?MC+W6+uZIJAqpQemC0+LmfH5499VOeNb63HN0HSLOh4+QCxVDxBbC88kyke4?= =?us-ascii?Q?9rp8YdVWNYaUGG5MFjklZ64rGZUd2ZmxHwqWfM2Wu1X4f7BB3JYpUvAnhkgn?= =?us-ascii?Q?zmBLRXkCA/bNa1JXlE/suo5CXiTUJ0FqHtpzIJwqfEVWSYtv7vnHi+qrJfz2?= =?us-ascii?Q?7n2pUncrmIdzTfDSbVhPxgDX89bpUuB0ZGUZf3jSUaywFNcseIEJtgHxR9qY?= =?us-ascii?Q?+2gkGm12lWXaCKNE80WyWW7ZkzmXYC0drrrWGgKrZEIE8r+xMZlOMrkBA9xP?= =?us-ascii?Q?MDxo2+FYj2hpAKOjMlxlysV039D77O0tJhRmee1FfTdGQfqV90HRNLL8YkWy?= =?us-ascii?Q?wQHU9Ok1evMbyw+ke4yVl1VPe8zXp4p7oVZY3TfRxMO4QA6eA6aZyfgr7f7w?= =?us-ascii?Q?4IG1souZ2IpS6dYK4/RiaXr7LGN4ZRfvVD8oNeA2?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b00577dc-838b-401f-13fe-08dcb21fca27 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 11:47:58.6339 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QU4NkyY3N1dojn0ezUD0mQeKvD5/g7OWpFaIrlHrt07JugGY/miVoQvr72RltuCXQu85KZkEjgxYJgJJn9hzlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR02MB10632 X-Proofpoint-GUID: KZsj9kDHxkBZfM7cslrMzpQeEczJLR6c X-Proofpoint-ORIG-GUID: KZsj9kDHxkBZfM7cslrMzpQeEczJLR6c X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-01_08,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Reason: safe Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YWN5H447HO27QMGSEEWK2YIML6HASCUC X-Message-ID-Hash: YWN5H447HO27QMGSEEWK2YIML6HASCUC X-MailFrom: john.levon@nutanix.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: John Levon X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1722512961140116600 Content-Type: text/plain; charset="utf-8" Provide minimal support for hotunplugging ETHERNET or BRIDGE type NICs in the test driver. Signed-off-by: John Levon Reviewed-by: Martin Kletzander --- src/test/test_driver.c | 159 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 146 insertions(+), 13 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4915c13a25..9a25e9548c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10568,6 +10568,22 @@ testDomainDetachPrepHostdev(virDomainObj *vm, } =20 =20 +static int +testDomainDetachPrepNet(virDomainObj *vm, + virDomainNetDef *match, + virDomainNetDef **detach) +{ + int detachidx; + + if ((detachidx =3D virDomainNetFindIdx(vm->def, match)) < 0) + return -1; + + *detach =3D vm->def->nets[detachidx]; + + return 0; +} + + static int testDomainRemoveHostDevice(testDriver *driver G_GNUC_UNUSED, virDomainObj *vm, @@ -10590,6 +10606,55 @@ testDomainRemoveHostDevice(testDriver *driver G_GN= UC_UNUSED, } =20 =20 +static int +testDomainRemoveNetDevice(testDriver *driver G_GNUC_UNUSED, + virDomainObj *vm, + virDomainNetDef *net) +{ + size_t i; + int actualType =3D virDomainNetGetActualType(net); + + switch (actualType) { + case VIR_DOMAIN_NET_TYPE_ETHERNET: + case VIR_DOMAIN_NET_TYPE_BRIDGE: + break; + + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_NETWORK: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_VDPA: + case VIR_DOMAIN_NET_TYPE_NULL: + case VIR_DOMAIN_NET_TYPE_VDS: + case VIR_DOMAIN_NET_TYPE_LAST: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("live detach of interface type %1$s is not implem= ented yet"), + virDomainNetTypeToString(actualType)); + return -1; + } + + VIR_DEBUG("Removing network interface %s from domain %p %s", + net->info.alias, vm, vm->def->name); + + virDomainAuditNet(vm, net, NULL, "detach", true); + + for (i =3D 0; i < vm->def->nnets; i++) { + if (vm->def->nets[i] =3D=3D net) { + virDomainNetRemove(vm->def, i); + break; + } + } + + virDomainNetDefFree(net); + return 0; +} + static int testDomainRemoveDevice(testDriver *driver, virDomainObj *vm, @@ -10598,13 +10663,6 @@ testDomainRemoveDevice(testDriver *driver, virDomainDeviceInfo *info =3D NULL; g_autofree char *alias =3D NULL; =20 - if (dev->type !=3D VIR_DOMAIN_DEVICE_HOSTDEV) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("don't know how to remove a %1$s device"), - virDomainDeviceTypeToString(dev->type)); - return -1; - } - /* * save the alias to use when sending a DEVICE_REMOVED event after * all other teardown is complete @@ -10613,8 +10671,47 @@ testDomainRemoveDevice(testDriver *driver, alias =3D g_strdup(info->alias); } =20 - if (testDomainRemoveHostDevice(driver, vm, dev->data.hostdev) < 0) + switch (dev->type) { + case VIR_DOMAIN_DEVICE_NET: + if (testDomainRemoveNetDevice(driver, vm, dev->data.net) < 0) + return -1; + break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + if (testDomainRemoveHostDevice(driver, vm, dev->data.hostdev) < 0) + return -1; + break; + case VIR_DOMAIN_DEVICE_NONE: + case VIR_DOMAIN_DEVICE_DISK: + case VIR_DOMAIN_DEVICE_LEASE: + case VIR_DOMAIN_DEVICE_FS: + case VIR_DOMAIN_DEVICE_INPUT: + case VIR_DOMAIN_DEVICE_SOUND: + case VIR_DOMAIN_DEVICE_VIDEO: + case VIR_DOMAIN_DEVICE_WATCHDOG: + case VIR_DOMAIN_DEVICE_CONTROLLER: + case VIR_DOMAIN_DEVICE_GRAPHICS: + case VIR_DOMAIN_DEVICE_HUB: + case VIR_DOMAIN_DEVICE_REDIRDEV: + case VIR_DOMAIN_DEVICE_SMARTCARD: + case VIR_DOMAIN_DEVICE_CHR: + case VIR_DOMAIN_DEVICE_MEMBALLOON: + case VIR_DOMAIN_DEVICE_NVRAM: + case VIR_DOMAIN_DEVICE_RNG: + case VIR_DOMAIN_DEVICE_SHMEM: + case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: + case VIR_DOMAIN_DEVICE_MEMORY: + case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: + case VIR_DOMAIN_DEVICE_AUDIO: + case VIR_DOMAIN_DEVICE_CRYPTO: + case VIR_DOMAIN_DEVICE_PSTORE: + case VIR_DOMAIN_DEVICE_LAST: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("live detach of device '%1$s' is not supported"), + virDomainDeviceTypeToString(dev->type)); return -1; + } =20 if (alias) { virObjectEvent *event; @@ -10634,17 +10731,53 @@ testDomainDetachDeviceLive(testDriver *driver, virDomainDeviceDef detach =3D { .type =3D match->type }; virDomainDeviceInfo *info =3D NULL; =20 - if (match->type !=3D VIR_DOMAIN_DEVICE_HOSTDEV) { + switch (match->type) { + case VIR_DOMAIN_DEVICE_NET: + if (testDomainDetachPrepNet(vm, match->data.net, + &detach.data.net) < 0) { + return -1; + } + break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + if (testDomainDetachPrepHostdev(vm, match->data.hostdev, + &detach.data.hostdev) < 0) { + return -1; + } + break; + + case VIR_DOMAIN_DEVICE_NONE: + case VIR_DOMAIN_DEVICE_DISK: + case VIR_DOMAIN_DEVICE_LEASE: + case VIR_DOMAIN_DEVICE_FS: + case VIR_DOMAIN_DEVICE_INPUT: + case VIR_DOMAIN_DEVICE_SOUND: + case VIR_DOMAIN_DEVICE_VIDEO: + case VIR_DOMAIN_DEVICE_WATCHDOG: + case VIR_DOMAIN_DEVICE_CONTROLLER: + case VIR_DOMAIN_DEVICE_GRAPHICS: + case VIR_DOMAIN_DEVICE_HUB: + case VIR_DOMAIN_DEVICE_REDIRDEV: + case VIR_DOMAIN_DEVICE_SMARTCARD: + case VIR_DOMAIN_DEVICE_CHR: + case VIR_DOMAIN_DEVICE_MEMBALLOON: + case VIR_DOMAIN_DEVICE_NVRAM: + case VIR_DOMAIN_DEVICE_RNG: + case VIR_DOMAIN_DEVICE_SHMEM: + case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: + case VIR_DOMAIN_DEVICE_MEMORY: + case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: + case VIR_DOMAIN_DEVICE_AUDIO: + case VIR_DOMAIN_DEVICE_CRYPTO: + case VIR_DOMAIN_DEVICE_PSTORE: + case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("live detach of device '%1$s' is not supported"), virDomainDeviceTypeToString(match->type)); return -1; } =20 - if (testDomainDetachPrepHostdev(vm, match->data.hostdev, - &detach.data.hostdev) < 0) - return -1; - /* "detach" now points to the actual device we want to detach */ =20 if (!(info =3D virDomainDeviceGetInfo(&detach))) { --=20 2.34.1