From nobody Thu Oct 31 00:20:42 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?+gkDlzXcCyuaOu71ibSQZab0I3cua2nz2WOxfZGugtE9LVEdDUqqreyjmx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z8wqAx80Ri0lQutTVdzv0JcO?= =?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+ZUsTmHO8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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