From nobody Wed Oct 30 22:14:29 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 172251292724787.5879015991485; Thu, 1 Aug 2024 04:48:47 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2C4211436; Thu, 1 Aug 2024 07:48:46 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 11DFF1471; Thu, 1 Aug 2024 07:48:12 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4212213E2; Thu, 1 Aug 2024 07:48:07 -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 F2E08139B for ; Thu, 1 Aug 2024 07:48:00 -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 4718HpC3022096 for ; Thu, 1 Aug 2024 04:48:00 -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-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 01 Aug 2024 04:47:59 -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:56 +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:56 +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=yRfBfy5lleUdMQL03bXjYgbzg5vbuTrgkR+V5Sf9Y EY=; b=rClHh9JXcwdwspQ6z2xYv/xV8jKub5/tR1QCEuutU/HaP3tMEk/xsEeUi sE1FZZdZgxQMKJmBjimoilDfX22MQDpKJIV6y/cUsVy3LUIrU5UQbZ8260ShiplB q7G2/vGHj4c4czQZnClb3PYq1PFeqV/A7hzM/NaN7Z5zBL32X6l0C1n0BeOvdKh9 dsxX2+fpwgBwX3sDM3EeCX4Piyus2Iwu6hxOHokBXt4tV96M2bDGVwH7MLsIfKAu f+azwFSfPcwxmv4K/k8KrrF0347ZGLA7S5XtSmJY6TTbSbopt+e4XcUOhonGQrO2 DOcZhuaOLeVtmwy0I3sVhe3QqKIaA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PbfeCGZuWigLAMkQvFc0DW3w3K6bzaL4VNbZI44oMQRiuQMB1qrtAK6fpgzbavGqddiYuzTaXUSCIX3VM1L62Y0AZHqMCBuZ3AiCdtFKtryzamPGQ/uZ8gbnjPN8yCkNxplywxB6z3+sVVmb2mu9EH4XfV48QzVkZnexUgT9qrRKp4Vl5eaYA745Iueid/NRQq8N5u4vgw87HvEpqgEyGPTmL/Ohz5RMNucBitl5jP7FqX+vY6J0HUsd+HyrnmeSjrHSHHNckwVzx2tJaezmdpKIiWcjWbHiztgpdliNOmTRap9aIFgTlTpURUuUnn8SvYlQloHxF8dGam6ZuAOXvg== 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=yRfBfy5lleUdMQL03bXjYgbzg5vbuTrgkR+V5Sf9YEY=; b=St2fYR7BmLbCy5niZwMmNL47I749lpc4QbPGbDbb9Rd/zzZJhvc8ODT5UdBBSRDXFkmBRBuGekh8W2zUpZx9gTlFacFefSCcVxNzoGKr5JhC06JH6uSPvE6N/RaXP+06uedpDkgYCjMjFaB0Z9zIE1ePFHz4Ln4EOcKPWUQUl0joUStKoiD4Db3wx2fFEnAz1/TdI9jToFBhOzfdOw5rr+vBlA2WNWKrWVRT6dNzGdD+Fo2nllyPmqE3WB99azQ14/HsyzlPpka/1hyXrE3FoHbV4L8+E+Iyl+yPjnr89tEDvg0b5mqjcTpgJFAzGM2dDCqUuiXdt3ky8z5AE6f/Mw== 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=yRfBfy5lleUdMQL03bXjYgbzg5vbuTrgkR+V5Sf9YEY=; b=Yoi3iELYS7SMqKOOpQqO0yPsM2rgI4WPBwxQ/XFh7ZChvMXMpbJl6X3F5aj+PqTohEsxQwLy4zExt1VD4uMJj4piLvd2JIB7ZmAylEhpfD5jaiZaI8q+y/cXPHRfhxZo+Q1mwf5FEqFEKn62O8mlUqndt6ZcdVgLHGtiHJ5VD7lWh6wW2pC5HLc0s+LIDxswlJ3S61+DGaHCPUpwHWuCQ0+GqlXk4lfU5JMBSW/vVRrzLhKFElADcBanCVttFJVNTijgrMzMpneNPMDpDRzVwb4eD1QwjIrjKJVsXXXBLZxoCGq+SfYsq8hSVUlIVN2v5VjXtY3xfkJ9CSzwq04UaA== From: John Levon To: devel@lists.libvirt.org Subject: [PATCH 1/2] test_driver: provide basic NIC hotplug support Date: Thu, 1 Aug 2024 12:47:40 +0100 Message-Id: <20240801114741.224919-2-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: 0fc9d427-f433-4343-af3f-08dcb21fc905 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?+gkDlzXcCyuaOu71ibSQZab0I3cua2nz2WOxfZGugtE9LVEdDUqqreyjmxXK?= =?us-ascii?Q?d1thB5ZCh37R0SrMkY8fzo5nyzvtLfnLeBObk5feQHzugL4ZTF71YchGpsx2?= =?us-ascii?Q?aXdU0FrcQUIcTTLVl4L39mJLm3Cs8bT4LKlX+lH7ogaMgMPxQ+wcvz4w79ji?= =?us-ascii?Q?S0HSLgpROPqHEQG2wyYHez/xy0G3AhRAa31wrFDABh0aTU7pTHBqcECsO0Zo?= =?us-ascii?Q?v5qayknm73IZYiSVo5bSA3qzEQKXRVO0DssJifM1cwGYQDIcU86s9qo0SUvH?= =?us-ascii?Q?+5TF7Brw8FeltIEtOw0BXZDxKnEsErRmP4yihOmlM0sutxS+LuRjVfxSdBGX?= =?us-ascii?Q?N3ftBZqeYPBucmY1TgrSfceJXDdeFEBBRyQX4DD0ZrXzDbr69sO4RfQqs/Tv?= =?us-ascii?Q?c5JKnxd/enW4jhaBFO8yiAMsRkpshGml+GzlfIpk6gaHLqQe98SxIFUUty/F?= =?us-ascii?Q?Mu++kq57D/EpZZg5R2eUwA8VROEy+l7QC3YfMWJe16u5R4l22a6OyFSTuLUR?= =?us-ascii?Q?9OW1O/imAJzZ7TkIacqdxlk6hQRCv0LVAjhdm1KmJKven2902//DTopdHO9K?= =?us-ascii?Q?Mm6Y/R2Mv159m0ws7/K6ReZbPBoOoj4lqwo6Qldx1YvlgB+ML7uxQrux/Mda?= =?us-ascii?Q?DTdkDspYtdYYp8FNYCGH7Y4fWcBeH6+ccpjovAnQQh0evnpIFSNcol5oVwqX?= =?us-ascii?Q?3C63dilrxHTQlI4vv4I+BvJFmzUm5T1CTskUwwxqodOU6V2P6ahlobpO1XmZ?= =?us-ascii?Q?PtP9ajwt7a/RLqaCAgcZjXxu3nyDkYGvpqmAlp1zSnHnNsl4W8rrzQBuqsUl?= =?us-ascii?Q?Iagr+OUm3/q/dTIuPNh0KQbnE9RpFqEyR+Pxdvfn/l1/1BLq8pyvqJqtHheT?= =?us-ascii?Q?togShmDQkcgtMb1q5O6235iulXKuwH2u4+c3z8wqAx80Ri0lQutTVdzv0JcO?= =?us-ascii?Q?cWVzanPR9q3RIuF+AEh73g4YrX6QSDRsp1tJT46IJ47DQWNBqScM4vveF7Nl?= =?us-ascii?Q?grn5ezbtDbxTzVHO8Bxuikn6mofMVYxSfVAxS59nfLJUUT4wFqESeuJ+t7JV?= =?us-ascii?Q?qAQ6ULViluQVPuuSLDrsBd2QgMfSdiZMzrJSh8jeiUkqMStjGOQfrPyT2CTo?= =?us-ascii?Q?yMC/X3tnaCZG67EMO7OImxbSid0a+XME6aGdeffbr5O3fFicdNwwiZiEZmTi?= =?us-ascii?Q?zM4NHwt7JtZ2lOd+AhHbZdai/RjfB/Xfv60WGnV0tMjToUSKgOQFXjb2i0e+?= =?us-ascii?Q?5FstTdl2rsOLnA9s2Xs7EX7S33aAlkhSwNWmRCW8wDFv1Z0h1rlvSZjpD0ny?= =?us-ascii?Q?8sLTNLeM+KbQhFmFJp7wXLV2QucZf5Qtc8leWav5IElkYg=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?2F4HgK+b4x/YcHzA6b8OHT/fqnhLqk/Uo1aiWDAbJ+mjLWGkkaMXuwVsFgqZ?= =?us-ascii?Q?0UnYjHxniWHxf734EnSYj8FM3FOls8xgi+cm3lObqowqux3Uftn9ZtzFqGKr?= =?us-ascii?Q?5rq70naWsbD2isXOI6m/ok1MTgAO5L9dTTifgmLA8kFHIYeHs3wBWoL4Qp5q?= =?us-ascii?Q?fgikbxuyGYQwfU9gdYrQWjWZ9AQZkj7ICWYuuHjKdBUbhfAZSz7CZocNcUMh?= =?us-ascii?Q?rNyBNevlos+ZUsTmHO8nu+49VkLeHLfBi1VbRfXK6Anx1Iizn6JgvnSQtl2v?= =?us-ascii?Q?+691q6kjZ6KIFWnY21AimeuXwSol39YSdmdcRPDvApeT/Mt5PoQN5IHP01TW?= =?us-ascii?Q?maEyL+nfHLU4ZIO5F/7XyQ2Q1ePrZxKo+kNZcb+It0XgidmAH0B7Yj3KWg86?= =?us-ascii?Q?JloxkTYhXBb00E44qU9v0xViYP1eZY0Y8vu6NKF0UQKCgui8Bu7is6iJA6zC?= =?us-ascii?Q?RKSMhjM7QJvTVSE80GYlAAzpQrGZgeHFk2dHL8+/83a6yQiUhRFY+pNNEDoZ?= =?us-ascii?Q?4M8BSxRGj+jZ0rKdn/SB82GAeZWjXD4pIOtQq2ZOo70sTn5VLt0oFMpNOAyW?= =?us-ascii?Q?afGxH9tOjSa8rYLBSM8zq7FS3TegUn8hypjtmQjkRPPjE4sQjgdDSXIAge5t?= =?us-ascii?Q?O91W7Z9uu38Er0Gpn0yTlvlpbFbpDQfEoqUlttMXBYBoULpxtSmKQX4SRT46?= =?us-ascii?Q?myGByfPkuktAiar2a332RLiaaV9vfcGX2cvJWVv8cl15NDWSdLAAxhnggIpO?= =?us-ascii?Q?FH447yOX7Vl1gDCQNHhL5FMorjy4d54gIpdeLwzYg6PpaYCT02Nz1VQDVObw?= =?us-ascii?Q?GkKWyMM0u9RJ3K0bVgB24QgXJTyLNt3iZTQ7wXdKw1JhAy3t/JEpC0aN9L2x?= =?us-ascii?Q?BVDK8VuQUqGK1a4W6XUDuZc5S3hRA55I6WJUyUGTVbuPgmHCWBMKXTErK5NK?= =?us-ascii?Q?CPRapOUiyGrENM6gS8IMQQqLwemSJLVv/hUk1t27/OX5h0aSVxj20iNT263R?= =?us-ascii?Q?w0vK3HA3DN9mSuI/UkwgD09pOYs+LX1FsGRVJWLC3gzONQB/KMpJGwkZ7xDD?= =?us-ascii?Q?/+ri0IKwGynTs+vGmx1eh8BwocqLwgRy9FE1p5woH5UkTmHNUZ5+paKXkHgP?= =?us-ascii?Q?FvJPq6SwosCr9SqkukGQUfytWJ35Y62FcEB26/TfKL9LGwJeO5QJzDifJ348?= =?us-ascii?Q?4syRP0De0G33hrN/wKxHVR4+yBgg6z7lkVaWsR49xxOyuMKOdXRYd9Q8Y4ON?= =?us-ascii?Q?Oy1XBrytg5rwPuqB6iqdGft/W0Dmbr/oHhuQ4yPHJ9hySc4S2myv+Ovod4HE?= =?us-ascii?Q?B1ko6u2CTPKmcPUXj46s/2E4R5SQk0MAmMvgRl992uRR/06kuzD/JgoIgO8K?= =?us-ascii?Q?iZraCGa+xl+SOXC5diKRKLCpv1IQybHTT69rB/hW04Amnz1rZ9MsYqZHDqV6?= =?us-ascii?Q?q/ECiUxNpKHBT+poaAgwBk1kOIOcv/gENdiSgu7GpnMCpM1fyuXTf68ntC5h?= =?us-ascii?Q?rWzVe47LwLMbOUvGXoSsMgIq8aQJy7ah3oHCICA98IlWa+HZyDzVv7PAutDo?= =?us-ascii?Q?eGs9PSOTdqkJFKa+f7nP05qO9wMVdU9j9xWjtIZB?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0fc9d427-f433-4343-af3f-08dcb21fc905 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:56.7018 (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: BzZJpmrdXAjQIdqPQYUOaOmL2ljq1dI2FlR8RnVpYxY7ISJtd1rue/QPznIVsz1CWdX7vQf7wXiFMnYA5mULYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR02MB10632 X-Proofpoint-GUID: Mk2FUszfLnWBDc96zaAM0M0Et7bFnIub X-Proofpoint-ORIG-GUID: Mk2FUszfLnWBDc96zaAM0M0Et7bFnIub 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: 7DGXABJLBVEU36IBN3JM4KPUGQUXE6VY X-Message-ID-Hash: 7DGXABJLBVEU36IBN3JM4KPUGQUXE6VY 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: 1722512929087116600 Content-Type: text/plain; charset="utf-8" Provide minimal support for hotplugging ETHERNET or BRIDGE type NICs in the test driver. Signed-off-by: John Levon --- src/test/test_driver.c | 146 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 137 insertions(+), 9 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7cb77f044d..4915c13a25 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -38,6 +38,7 @@ #include "virnetworkobj.h" #include "interface_conf.h" #include "checkpoint_conf.h" +#include "domain_audit.h" #include "domain_conf.h" #include "domain_driver.h" #include "domain_event.h" @@ -10115,6 +10116,93 @@ testDomainAttachHostPCIDevice(testDriver *driver G= _GNUC_UNUSED, } =20 =20 +static int +testDomainDeviceAliasIndex(const virDomainDeviceInfo *info, + const char *prefix) +{ + int idx; + + if (!info->alias) + return -1; + if (!STRPREFIX(info->alias, prefix)) + return -1; + + if (virStrToLong_i(info->alias + strlen(prefix), NULL, 10, &idx) < 0) + return -1; + + return idx; +} + + +static void +testAssignDeviceNetAlias(virDomainDef *def, + virDomainNetDef *net, + int idx) +{ + if (net->info.alias) + return; + + if (idx =3D=3D -1) { + size_t i; + + idx =3D 0; + for (i =3D 0; i < def->nnets; i++) { + int thisidx; + + if ((thisidx =3D testDomainDeviceAliasIndex(&def->nets[i]->inf= o, "net")) < 0) + continue; /* failure could be due to "hostdevN" */ + if (thisidx >=3D idx) + idx =3D thisidx + 1; + } + } + + net->info.alias =3D g_strdup_printf("net%d", idx); +} + + +static int +testDomainAttachNetDevice(testDriver *driver G_GNUC_UNUSED, + virDomainObj *vm, + virDomainNetDef *net) +{ + virDomainNetType actualType; + + actualType =3D virDomainNetGetActualType(net); + + testAssignDeviceNetAlias(vm->def, net, -1); + + 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, + _("hotplug of interface type of %1$s is not impleme= nted yet"), + virDomainNetTypeToString(actualType)); + return -1; + } + + VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net); + + virDomainAuditNet(vm, NULL, net, "attach", true); + + return 0; +} + static int testDomainAttachHostDevice(testDriver *driver, virDomainObj *vm, @@ -10144,28 +10232,68 @@ testDomainAttachDeviceLive(virDomainObj *vm, testDriver *driver) { const char *alias =3D NULL; + int ret =3D -1; =20 - if (dev->type !=3D VIR_DOMAIN_DEVICE_HOSTDEV) { + switch (dev->type) { + case VIR_DOMAIN_DEVICE_NET: + testDomainObjCheckNetTaint(vm, dev->data.net); + ret =3D testDomainAttachNetDevice(driver, vm, dev->data.net); + if (!ret) { + alias =3D dev->data.net->info.alias; + dev->data.net =3D NULL; + } + break; + + case VIR_DOMAIN_DEVICE_HOSTDEV: + testDomainObjCheckHostdevTaint(vm, dev->data.hostdev); + ret =3D testDomainAttachHostDevice(driver, vm, + dev->data.hostdev); + if (!ret) { + alias =3D dev->data.hostdev->info->alias; + dev->data.hostdev =3D NULL; + } + 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 attach of device '%1$s' is not supported"), virDomainDeviceTypeToString(dev->type)); return -1; } =20 - testDomainObjCheckHostdevTaint(vm, dev->data.hostdev); - if (testDomainAttachHostDevice(driver, vm, dev->data.hostdev) < 0) - return -1; - - alias =3D dev->data.hostdev->info->alias; - dev->data.hostdev =3D NULL; - if (alias) { virObjectEvent *event; event =3D virDomainEventDeviceAddedNewFromObj(vm, alias); virObjectEventStateQueue(driver->eventState, event); } =20 - return 0; + return ret; } =20 =20 --=20 2.34.1 From nobody Wed Oct 30 22:14:29 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-ascii?Q?TWSaW3gmUAUvz4p9G2UoywatzuV/cv1Hz8U9YgzQqIc/lAVLOjU32j3jdMcY?= =?us-ascii?Q?Bu0W4vajiJLXVL61Er+3Zyp0akKBhV5RlOLAh6p0P+tBXKUDUaS4c+JV3eDr?= =?us-ascii?Q?X84uRqWuXaf/Yuh804BcfhBWLG+3Vc/6dEoh+dGucbZzCAcxP9IDIfhhP1mj?= =?us-ascii?Q?yNP08byT+VyKsGQzDxfVvsrpP4owc2oFBGmqEgl0WY1M1lwGcTxTG5PP9a7y?= =?us-ascii?Q?lyeUB5WTK0wpPs5AQjB3wYCpuxYtt2c/fPrgHgDEmDC4y6XwkhW1WrHeh2tU?= =?us-ascii?Q?jis7ZlJy3Kyq0mZ7gp8+jPQQ9AVFY4ij4E2009Dh0DkSFQEcrAJrMBuGZnJA?= =?us-ascii?Q?1z+CVMO669xbTx6ZapJK3k7PjJjXJ4XgIM5hXVGFWpBPeUoJ6/6e3kNxWStU?= =?us-ascii?Q?I7B6XWwDvM9RU+OsuyetVecVOTSq2hud5eYBRYC8zDeQlEuJmOCKIhyP5w9T?= =?us-ascii?Q?eW2kilrp+QJO7f1v7obwiBm7S9f/RsUHoNW3Kce9mcJtuB1oXxcCG600yltC?= =?us-ascii?Q?CNuPfQcggAExGJLDyhLQSe6IpSCB0BeAhZp+ehDAVJmlcSXyISuuDcKpUIJu?= =?us-ascii?Q?zQ9/noyKtZzQnN7NCeg+76RRUWLrYoYS1LbhjIaBu7ynaM2BAh8cROzyTQSh?= =?us-ascii?Q?BLXB0qPbfFrZlgG0AA6umFaAw4glxuSy1dG6WAXfim8P+EazcTWD2vdR0lqs?= =?us-ascii?Q?0KeFF5mv+HdOHZKT+CWTY3nflbfivQIGP3MyGfnPpKWGJMuCB3AEaS/pr4OH?= =?us-ascii?Q?0VK7mwfD8HvfUfMbeHqVNQO7ky6zJWnxq8MayE1zNvSonIZ2I4ztmS2KCcp+?= =?us-ascii?Q?VRwtTnK+T6AXJcr4bqjloJUvtdzK+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/qEJ0K+UQFysjU6XBvjax+3NxvyAHOwXm3f7K0bhtV3P8cI7iM1h8yD?= =?us-ascii?Q?Opq8Wv1q99YCYjSJOnzbJ2NITP1xkPbrFzbqoiY8hUCPx0AxBfDIPSmCcFUC?= =?us-ascii?Q?LoCQqSu18taFufRnbqlnC1LZwTu0VOHHhCIllZu8pgVjqHeL+zoqku8MQ0HL?= =?us-ascii?Q?MYrAiIF9Ap/WKuI50GGP2izr0kdvt8E3y+cjg2Z5Y9XvUHAc/HsSRZJDZuxG?= =?us-ascii?Q?Ui3S2lreInFAXIQUOhaCwOq19YlPJN7pPIC+/++tXfaoIa2JMfWnzvV04uO8?= =?us-ascii?Q?EhyWTNEiCeqaDZ0pKd4QQqbC84doPdphgs+GjQmxgJS6ReBHkL1uFTlCbS/Y?= =?us-ascii?Q?hP4BM/SPq5WMfiGyqJtHwq7xse+ZLg7F7nKy8HRTVkiJankOuwXDyOwnly0b?= =?us-ascii?Q?gs8786iNi16X0amGg980ess/BllnyZ64IUmaqZWVpHxLTBQajn7C2hdzZ84y?= =?us-ascii?Q?aXoQLoxS2LSc0QIQoj54T+IrlR2zgdWsOFSl2lUU9DQLatlW7vwD6cQPtXi6?= =?us-ascii?Q?7hudyV/9CsE0XSc+EGpAo3UbnLYJDscgDuzr1WfnmDyLQHEU9s9D2dpBx3jK?= =?us-ascii?Q?pshgciQW4hYmBzZ3uYKMdWEqwO3stePQEClDH/LMLlhFMwKcQqMVimUMd0Bx?= =?us-ascii?Q?S8nS3dc1iVVf/V7ubVhluHHaxsUY4DZlu+er1Ue4Ig62at80+YmwesD/MP3p?= =?us-ascii?Q?BIXDBU9T4w0EIF8ds/azjNFxLIXCselZTfZveqGOUYfg/3Uc3QTMuQkp86/g?= =?us-ascii?Q?vuL5R+6iMtKq9PAQMFwqjihtgPBXjHw1MC+d4V0IaqayDTBqAGklq1quHlE5?= =?us-ascii?Q?ajFaBf8onQwDDh/pajPZPJOyJ75iRynlAK+EkeyUBB/fki2n3ZG5xj78AchP?= =?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