From nobody Thu Nov 21 12:53:28 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 1730500376179900.1219618373085; Fri, 1 Nov 2024 15:32:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 26A301239; Fri, 1 Nov 2024 18:32:55 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 15DDD1300; Fri, 1 Nov 2024 18:32:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8E95E1219; Fri, 1 Nov 2024 18:32: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 DDC491215 for ; Fri, 1 Nov 2024 18:32:09 -0400 (EDT) Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A1Es2Lf019529 for ; Fri, 1 Nov 2024 15:32:09 -0700 Received: from bn8pr05cu002.outbound.protection.outlook.com (mail-eastus2azlp17011028.outbound.protection.outlook.com [40.93.12.28]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 42gygf8n3s-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Nov 2024 15:32:08 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by IA0PR02MB9485.namprd02.prod.outlook.com (2603:10b6:208:400::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Fri, 1 Nov 2024 22:32:06 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%5]) with mapi id 15.20.8114.023; Fri, 1 Nov 2024 22:32:06 +0000 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,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=QfRKhZhUeWjt/QZ5/ZBXqDkC5w4kts/eZTtCbohuY nU=; b=jTVY1GWj1e/jhnVkhMmZXBfBA2ZogpGyf2nHJmsp3jErOt1ZdBbWDq2qY yy2dAsVpUWs+X8Dilik82loEGaVMe+PKUggc3sRxAbB/dPXXBxxzpo0xhv+z5fMp 7RZZ4OKWIwe/I5VaGdADuPk8THXoLCrweNE6KZXjNtrldVNrz62QZkwpQcWInivY BK7pq5H0v4wA5YPQC55ROZdXpqxfSym0k/WAuviHkW7DD+nzfRw04UDWbhfp9Zp8 HpWw84t4zEr23snoATqCdYjTV9/pYHE9lckHisl0dCs+AjOgPTEj2kv+Oivr++VA uZr6MdS7f+Jq7b0eaiCIIcGQLRdTg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X79lwDtl7N8uIqCynK6pjhD8f43LSDskQNW5zEd9h6gNYZby+yyJr6ONnG0oU7ttwgEEkY/Wvp7EM0IMdJlA3KifSZyPhUPpbqw5VCGONQXKeURBUQdCXKv2fhgN2CkA4ME15syYsw0QW03pEwzbnQClnggT5EQg6Eafw5rE7zriLLrBCLw8irFvY0jS4tciCfjvFFQK48F3ObHDxX9DbtvD0OwIsOwlmqwz1wU6S8CJOwpEAQxEj2d49bjrl5vhYJotm1u2ivsi8zKrs1xGrzf+7xVM4NzXQqGu0oBtuRNS2MncL4FjBmPv1qzXk1aK0MF+MPl/D8+cXB5EuoFk1g== 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=QfRKhZhUeWjt/QZ5/ZBXqDkC5w4kts/eZTtCbohuYnU=; b=ITB1ui3BqqK6wTWLEVg8YTmjQ7bopHLpUXFptLIAgI6ChXbeKBsqrQLBS/MVLEO8fewAiMiDbWNAWTr93HeVFuY17Fy0jIe0dhK0K1AHMuYjOuZNj4PwBpzJvC8XS66CzyLSiRCVYSA0Lla1RH21HDbIn8+G6fZIcajHk6MXu3a/aSarq0UW5Er+5Fjzs71m6VUwX8ORf/A/Oqx1zwtWUUUATXTTbVa2xDSN0zgm1AIXgENf/N7Qo1EG5S4WmrNkHkWbTvOjGc68vkwjLa6MhUHIMvvLeINo1MtUe4qOkkBWoqBI5ykj325aOXZxTddrBRDAr6TJ4LAygujF8aqAbg== 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=QfRKhZhUeWjt/QZ5/ZBXqDkC5w4kts/eZTtCbohuYnU=; b=yasF8JgxRblsYjJwntLvKcAcJfeIMIY9wyDoImjC/ZIIJMfHFarW3ZmMBim/ChzTi3aGz6mRSCKYp2OuhwsoS0EwAGlCxbcHAxV19MPbFM+6rV/ZJ5ZL3+4/dUYNfngwtFa1t37pGNa7owllJ0yph54r03QltcLo7iiKVtnHq7Dx46wbjXGwIWSSrDWkjSC57kZpu9EcqGzauBaCCNQ3qxCDlSMOjGc8d/xc8Lrb1MFG+rlRnhr+oAxzNiACar4UhVZ7cZL6rHDAiHQMnmNlcJJ8lt4uqOSLRjiOZwprZi5XfZ+UGPVek2CJ/3haIx94cS5rl3pxdJmo7ONzO2Y+nA== From: John Levon To: devel@lists.libvirt.org Subject: [PATCH 1/2] test_driver: provide basic disk hotplug support Date: Fri, 1 Nov 2024 22:31:56 +0000 Message-Id: <20241101223157.1678743-2-john.levon@nutanix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241101223157.1678743-1-john.levon@nutanix.com> References: <20241101223157.1678743-1-john.levon@nutanix.com> X-ClientProxiedBy: AM4PR07CA0036.eurprd07.prod.outlook.com (2603:10a6:205:1::49) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|IA0PR02MB9485:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e6f2279-65e5-4acd-1a9c-08dcfac503f2 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iYV+Df618U08VAA4CQXbeMuTYXgYje75ZI2on17xLThyYq1M06boSukHFHNl?= =?us-ascii?Q?4N3uBWzjnuiyGcOtoLOk2rouTKDH2eVuTzu9HGsi+1GA9+EjZc7nHVFsxHTN?= =?us-ascii?Q?0/q+fwqrqhJynWcxTWTODTxP1GmBwdSbkvjLBGGuw9yhsZWFTjyqUaIpE4Fl?= =?us-ascii?Q?FiCNb0ycoReHtTGwwibpu/D1ZKJA8pWgGR3VHX9Xle1gGGykIFmOnQXIVzVh?= =?us-ascii?Q?GDnqqwEYwjlKcH2hg9t5zztuB2J46wLjvK/P8WwRaxdDi8q26eAUV0utduNf?= =?us-ascii?Q?5PqbC796vt8aqjdGCUz3ky2HAqaramG6Po7rvG80EF8wHrxTqikrRN6HJ2Hj?= =?us-ascii?Q?ubYhnb7GHFbqnZvj4h7AiyoDih7ed+I1q1yDZR8nSohtbjWNQ4NttVPnNCt/?= =?us-ascii?Q?AziEvzNWCYLt4BlP44aBLOEBuUdDl67wnaW5Fj8pEFeOI7LhKh7van6YznXD?= =?us-ascii?Q?DrZdVK4nStIBWAGmlDdBLGWdoBwshXJpCG1ZyEnvVdBkdxCdhga2wA31P/+C?= =?us-ascii?Q?6EhNyCqMprb2mMJg5er0dDiwQGW+JWSYbYtMm5lgw0E4+2+u6+7EjYo9iQfd?= =?us-ascii?Q?hmEHAGHoEKSbcu77bxVu31W7Y3H73mEgP/gPzgmF3cTias6hY817Ttmew1xD?= =?us-ascii?Q?MQuNgd27Kl/lSArtHk4sHnsgRRum5EHsDCnQV0/br/3caxnjMAnSlvG89qs3?= =?us-ascii?Q?/GKs+JQl0RiggPkAI9UC+d8mfrdob3F2j6/9g/1t1AsAxPxI0Km4xiB6tlDR?= =?us-ascii?Q?l2Z2S8dLQIk2vVq0FybOqyMSvf/zBw1x0lBn60Cl10UgVfnT0Yjg6IX9C8SO?= =?us-ascii?Q?jLT3fwjh4aS1IfoOd6fO7oDBSxcP+pxnHr8FoqgPk73ajHtqNXBZFuDsOuuu?= =?us-ascii?Q?80R8L6tjcFCVVpOxOB2CRG1fX7j1KvkGuuOGhRzTDNPaVE+CmRNPYDak7BrW?= =?us-ascii?Q?bysKzlBGZGQngt16ClQTR+kNvz6o0iFcN3O3Has3xsKgGtoAJgGppK0c7eIJ?= =?us-ascii?Q?VstKeAMq+RJWmqBscfnJaoGdfutuk0z69QmcClScv8t2UGTtWDTGzR2PCXLD?= =?us-ascii?Q?/tiMIiwjk+T9AyHBU8UJ/GEDZofT1j7usabu3kM0RI156pQrGUpWwfkah/Aj?= =?us-ascii?Q?9k/CD9GCcTuhznvugZVkKNjBF7Tyrzbv650lZYdLVkN081oHwKMRiOl8xm2U?= =?us-ascii?Q?p0ZJ+Y9Z5QKOO5RxjrQrweIZI1X2NGBIYC6pJe/y012MIa+PBYpyHlqrUo5A?= =?us-ascii?Q?hK5iS5gVQNMqkxZ21XLhG2Ayw9xxiWifsgv4G0QXcjG9XCYVl6hX6imKP1qd?= =?us-ascii?Q?J+IvNGo3yptldxjUB+2h4ito?= 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?xWEICCll2EPlM7eJ/qFQCiQCOrxB6Hcv8ju5wYP0xFZxxPcsoXGmWawRz0fx?= =?us-ascii?Q?3a0KOFeo+i4Ow/6EgcyOpiYru+H096gTj3uBZaavrobPIfBma+9BGb42wfQS?= =?us-ascii?Q?IYVkSYmbhr4Yy1f/lnXkyNNRT32CWq/urItnOamRmuBVj3KwPLH90WxPj4NK?= =?us-ascii?Q?ESd1s3ojaKp1u19BPvRveXskCpXbvDEf2XxNPZrbP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QXv63zj2ZyQvAtQvJuhZJRvI+I3r+z8z7i50TpkjPZ?= =?us-ascii?Q?MSlVOWcIrHw+6pWaqkLnr631ifVF1qTeuqYYukAAack445u1afg5IUHowhvu?= =?us-ascii?Q?231wOhYLOMoecsy+vjtLyL/+nKXScqLTCLQ73lFDKhTc5KyKwrLur67Tlwkx?= =?us-ascii?Q?Q7qj4b6ISSoh2P29cLQ4gtkOS3ac/Ldz/4n0V7d2DVaI9tvvIAizSGR7+1pF?= =?us-ascii?Q?Tyfe3O+r4+/BjbJEWRD43o6VpkOdjviIdh6VXHe251m1m0A02hh1I+rr0xYb?= =?us-ascii?Q?gXslavOrcl5S/U8/Vf/j7C6YYhkbcfUZrS8bv645QH3y5z2kaTqw6GhVyUWa?= =?us-ascii?Q?PJ3LhKErwl0BZAensGlBQ64rAVvij/+4kZ22tFOkVj7ld79c7W6VEcSIetjM?= =?us-ascii?Q?pb5cxPiF+sEXsZvaxpWu9kesZyq1lkTopDRHOpoVHh6vIPeouhQqKXuHbqvw?= =?us-ascii?Q?W8920UHotsUz1DpC8biwHtcRvasCBUVP3Cck5862?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e6f2279-65e5-4acd-1a9c-08dcfac503f2 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 22:32:06.3606 (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: GwWUo3Dzmp+CEy2puw8mx50QRNz07WKCyWHkJTSPciEC+cEk4IXeN5SMUHeRLMH7MWhPyXqwU8EfdK1B43Suxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR02MB9485 X-Authority-Analysis: v=2.4 cv=bYg5U/PB c=1 sm=1 tr=0 ts=672556e8 cx=c_pps a=WlqDjRht0D+wB3AL0MAriA==:117 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=VlfZXiiP6vEA:10 a=0034W8JfsZAA:10 a=0kUYKlekyDsA:10 a=64Cc0HZtAAAA:8 a=Xf1eM__cp05pPCFU7fAA:9 a=14NRyaPF5x3gF6G45PvQ:22 X-Proofpoint-GUID: VoJiF0c_BpkEodzBzuooMxFIuBBKUWhN X-Proofpoint-ORIG-GUID: VoJiF0c_BpkEodzBzuooMxFIuBBKUWhN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-01_17,2024-11-01_01,2024-09-30_01 X-Proofpoint-Spam-Reason: safe Content-Transfer-Encoding: quoted-printable Message-ID-Hash: I3A7DGSNDFOOG76ADMXG4UQTYQSP6VLH X-Message-ID-Hash: I3A7DGSNDFOOG76ADMXG4UQTYQSP6VLH 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: 1730500376514116600 Content-Type: text/plain; charset="utf-8" Add some basic plumbing, based on the qemu driver. Signed-off-by: John Levon Reviewed-by: Michal Privoznik --- src/test/test_driver.c | 162 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 03afe8af8d..b7e36e8451 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10223,6 +10223,158 @@ testDomainAttachHostDevice(testDriver *driver, } =20 =20 +/** + * @def: Domain definition + * @info: Domain device info + * + * Using the device info, find the controller related to the + * device by index and use that controller to return the model. + * + * Returns the model if found, -1 if not with an error message set + */ +static int +testDomainFindSCSIControllerModel(const virDomainDef *def, + virDomainDeviceInfo *info) +{ + virDomainControllerDef *cont; + + if (!(cont =3D virDomainDeviceFindSCSIController(def, &info->addr.driv= e))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to find a SCSI controller for idx=3D%1$d"= ), + info->addr.drive.controller); + return -1; + } + + return cont->model; +} + + +static int +testAssignDeviceDiskAlias(virDomainDef *def, + virDomainDiskDef *disk) +{ + const char *prefix =3D virDomainDiskBusTypeToString(disk->bus); + int controllerModel =3D -1; + + if (!disk->info.alias) { + if (disk->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { + if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI) { + controllerModel =3D testDomainFindSCSIControllerModel(def, + &disk-= >info); + if (controllerModel < 0) + return -1; + } + + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI || + controllerModel =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LS= ILOGIC) { + disk->info.alias =3D g_strdup_printf("%s%d-%d-%d", prefix, + disk->info.addr.drive.c= ontroller, + disk->info.addr.drive.b= us, + disk->info.addr.drive.u= nit); + } else { + disk->info.alias =3D g_strdup_printf("%s%d-%d-%d-%d", pref= ix, + disk->info.addr.drive.c= ontroller, + disk->info.addr.drive.b= us, + disk->info.addr.drive.t= arget, + disk->info.addr.drive.u= nit); + } + } else { + int idx =3D virDiskNameToIndex(disk->dst); + disk->info.alias =3D g_strdup_printf("%s-disk%d", prefix, idx); + } + } + + return 0; +} + + +static int +testDomainAttachDeviceDiskLiveInternal(testDriver *driver G_GNUC_UNUSED, + virDomainObj *vm, + virDomainDeviceDef *dev) +{ + size_t i; + virDomainDiskDef *disk =3D dev->data.disk; + int ret =3D -1; + + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("floppy device hotplug isn't supported")); + return -1; + } + + if (virDomainDiskTranslateSourcePool(disk) < 0) + goto cleanup; + + for (i =3D 0; i < vm->def->ndisks; i++) { + if (virDomainDiskDefCheckDuplicateInfo(vm->def->disks[i], disk) < = 0) + goto cleanup; + } + + switch (disk->bus) { + case VIR_DOMAIN_DISK_BUS_USB: + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("disk device=3D'lun' is not supported for usb= bus")); + goto cleanup; + } + + break; + + case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cdrom device with virtio bus isn't supported= ")); + goto cleanup; + } + break; + + case VIR_DOMAIN_DISK_BUS_SCSI: + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_LAST: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("disk bus '%1$s' cannot be hotplugged."), + virDomainDiskBusTypeToString(disk->bus)); + goto cleanup; + } + + if (testAssignDeviceDiskAlias(vm->def, disk) < 0) + goto cleanup; + + virDomainDiskInsert(vm->def, disk); + + ret =3D 0; + + cleanup: + return ret; +} + + +/** + * testDomainAttachDeviceDiskLive: + * @driver: test driver struct + * @vm: domain object + * @dev: device to attach (expected type is DISK) + * + * Attach a new disk or in case of cdroms/floppies change the media in the= drive. + * This function handles all the necessary steps to attach a new storage s= ource + * to the VM. + */ +static int +testDomainAttachDeviceDiskLive(testDriver *driver, + virDomainObj *vm, + virDomainDeviceDef *dev) +{ + return testDomainAttachDeviceDiskLiveInternal(driver, vm, dev); +} + + static int testDomainAttachDeviceLive(virDomainObj *vm, virDomainDeviceDef *dev, @@ -10251,8 +10403,16 @@ testDomainAttachDeviceLive(virDomainObj *vm, } break; =20 - case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_DISK: + testDomainObjCheckDiskTaint(vm, dev->data.disk); + ret =3D testDomainAttachDeviceDiskLive(driver, vm, dev); + if (!ret) { + alias =3D dev->data.disk->info.alias; + dev->data.disk =3D NULL; + } + break; + + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: --=20 2.34.1 From nobody Thu Nov 21 12:53:28 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 1730500405053351.2553760320625; Fri, 1 Nov 2024 15:33:25 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 06B39121F; Fri, 1 Nov 2024 18:33:24 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2E26C1293; Fri, 1 Nov 2024 18:32:16 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3391D1218; Fri, 1 Nov 2024 18:32:11 -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 8DF0311C3 for ; Fri, 1 Nov 2024 18:32:10 -0400 (EDT) Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A1Es2Lg019529 for ; Fri, 1 Nov 2024 15:32:09 -0700 Received: from bn8pr05cu002.outbound.protection.outlook.com (mail-eastus2azlp17011028.outbound.protection.outlook.com [40.93.12.28]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 42gygf8n3s-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Nov 2024 15:32:09 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by IA0PR02MB9485.namprd02.prod.outlook.com (2603:10b6:208:400::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Fri, 1 Nov 2024 22:32:07 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%5]) with mapi id 15.20.8114.023; Fri, 1 Nov 2024 22:32:07 +0000 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,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=dWGpARmYAuL7DW+tudeoG5Zrf9vd0dadn0UFFLGsy XA=; b=cEcEE8+ETCOC4ebfzNqGiF/aFgAK8tGuk8iBx87LXO42bd8q8a2nnLiNC gpwBcyk9iv69myOsZmLg9m8xCitjryolHE6dfCTuiX4tML8yDm13MYXfgnb+IzPq eEeHCc6lA6loBOMtguGK8BEGot3i5oUep2IZfagoqJuHpYBPAx8Dwlaj/UoD+O88 AhPyI6xI3qXGKdgluZDotjT8iuWh+sE92ztNRDxd7ZhBlsrB+WhuWoS5zkRy+f2S EoqYn6mB9HCYF0NdIAV/CJKbNT4edccrLtsqRdhHcNHkteQ0dmndutOAbOt6Z0KI G4fK+SR/J+gzKu+DVAfLJc9Nusq1Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m61kawN7dLq0j7Z3XpbXe+9Ian0pkMjQV8dqO1wmWQwNAtSB+BgrF20IFMsELbGZI1m+Wp8Av/MqjGoXylXJeQsUZB9CdDLgzgH5Zq4bnvBfN42koUeGswV8QzkRXgHMqy+LtkWpOpP5kriq0sv11pEkVkLLLK800cM8BrJqd7OAPtDC+ZMw/knURbrzfzzMw8n7e9zQqPyg/y3aoVnE790UcW2yqupBHHnwuUWT0Smv/OZ88ornIC6XJ1CQSMsEzvkwu86FjPc+9BT1ssQQkQ5+nuu7e4CnVM2QUjFMJ7U0oJebj2vJNxZqQoqh8ia8IRyH1Eatl6f3enQUn1Vnhg== 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=dWGpARmYAuL7DW+tudeoG5Zrf9vd0dadn0UFFLGsyXA=; b=m8aO2dUOWYmyl3egkGp9Jmt5hOW7Tr81ISQiKIifzLz3amcOJ59oq0Q0b94B++PhpfbR/Pr/raRM3vgaqJwho0ya4nlr53uunjfMRV8QzfPSjLtCWm/nAatoYf2GNS4tXlFqW2rt1ZrrL0H15NHWrecmpoQaK7zGp6xfZME3xPFs2r13973RbmhKqKkjzMSQcNMZDiywK7rWDsHcaJkrLgerStgcLiXCGAOXZe+x2QOY8C6FoFz90s3X+8Cnz7rrLWNPa2ZQkUmne04KBjUglN97lcfVafJ9/urZmT5ZxI/AnHCjN14T9i+Q1KuAQ6MQLAttd0K3dGoatoSKhbhgSA== 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=dWGpARmYAuL7DW+tudeoG5Zrf9vd0dadn0UFFLGsyXA=; b=w54ttbCJylZ7LurRb0O6TCuYzfuuAaEO2DQQyfhmq6SPlmiipS9RW/nnIj/DQIy4zvdMwDSsyBjx0bAM1OClu9wnFvGI1ibItYHCCHUUVOb1ELwE5H/B3NQQ3iRFxZQGlkTCWWtNxLTTFjpBYNUk0Xd3TyMGMXGP31HJFp1im9xEYETY+dkGGunw6EwrakahTAx0RCwsJU8J6/fKxDHgaA4XaMigql2AfRw2/pnXo/T/NM858z6lfAJE3QXcOCB6MhAY6Bc6cJPlKANRd4+6x7JfajwfjqCfLF7V9cxHaACELw242/lOM6e3c4LprWN7AmeSRSg+jy1npanPTa5O8A== From: John Levon To: devel@lists.libvirt.org Subject: [PATCH 2/2] test_driver: provide basic disk hotunplug support Date: Fri, 1 Nov 2024 22:31:57 +0000 Message-Id: <20241101223157.1678743-3-john.levon@nutanix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241101223157.1678743-1-john.levon@nutanix.com> References: <20241101223157.1678743-1-john.levon@nutanix.com> X-ClientProxiedBy: AM4PR07CA0036.eurprd07.prod.outlook.com (2603:10a6:205:1::49) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|IA0PR02MB9485:EE_ X-MS-Office365-Filtering-Correlation-Id: ac2ab306-f195-4499-8488-08dcfac5047a x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?30K4E04+Oi7ogM/LHQJ8m02Pn+HYs6gU/F+Wd7nkO8FBYbvhB68/bUrpZaOx?= =?us-ascii?Q?tb5P4iqb9vko6Olqls5+ufuBjj35xZndmvSyY0i0+e0NvUKbs2tnfogw7DwE?= =?us-ascii?Q?oOppVNfL/JkiOtYCRKBptjQeR2khNmMKRmd/EWAZlmflpOSHhGe19UUiCj/+?= =?us-ascii?Q?P8tRkjwq3Rkui90PXPEA67P7R9Hbs+Rok8uevcPQAfoQdnuXpHGQ259tjKBw?= =?us-ascii?Q?AdFja+9DbkRqVqVF061PfeiAkOs6iG2VVkASfrpydAkEsg0LBlEzX8vXupSI?= =?us-ascii?Q?hVcXKNZ9B2BFJQe1TMEdvN5mj70bORctcEkJm/2NqjGazuHG9fN+bXEdturP?= =?us-ascii?Q?y0KHXnVQEkCds/YsY0hh5dX+iwuY9XqYS5i74f17inBb3Ja6clbVmXlJUWGw?= =?us-ascii?Q?Veiiz6LowHBDVYHIWRzR6/5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ascii?Q?ooJ3NLyPIcQecM6tdmxcUyYI?= 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?WzTOtKbaGSILb5znvudZRv72wN9kTCcDp7l+ydrCbE1UWJLHKp+y1fBTEMTw?= =?us-ascii?Q?8gXM0R90T6kZfefBA3tXm8qDBQ5QX1JNc4057rzTi6EpPYjJikZp67tkJECr?= =?us-ascii?Q?FHbBE02JZnBAD+il6rm64BfKrUUF+fJi3lBuwtV4aD6nDikfLqcacYq6lnyi?= =?us-ascii?Q?zBBDZToXOvI3CGdmfp3y6w1VdP0iSIuPmkceEKN07Y6in8CF+UmfW62jOslv?= =?us-ascii?Q?sudmRmmsTfmZIZMGT0FrSyWRMv8BXgy8B3IbXvTtBsBnQdu3OEvc0tfz5A0O?= =?us-ascii?Q?DSIw7Xv1+gqYlbqlrOwlu771l+btTflpLdHskqm+1TrSMeq7xfpIve+73ihk?= =?us-ascii?Q?eQL18Hokt2Rke9zwlBHM998sOG42RsWmh4ZSeSibjWYqqVbCoQrTknq4wf/j?= =?us-ascii?Q?4n3EBYkpW/kTX0JshdBJUyXW61nRzdNXPYP1c7WHe0yTKcKzBAvnc/QLJf8e?= =?us-ascii?Q?m7CdYMCKyR6Fqu2k19dA6Jpb9iuk8U9uu3HBl61GdRmfI7l5qYET1J+LyOBy?= =?us-ascii?Q?pLl5NrzBl6/dmJLC/wwrerRF0aal45y1RftLvDx3N46h/Nug58dFVNDwy+08?= =?us-ascii?Q?0nptYRDROFyh5jXjYBBnfQFPDeXAUp+z5ZPqd2mrBMjTG76CwEaKwchhru2l?= =?us-ascii?Q?kjzceGLklIWnRhmPHvQ1CuST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?Q?fNmpsoD6St1lx3ZSR8uLXyPoELM/T+DQjIwKBNKx?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac2ab306-f195-4499-8488-08dcfac5047a X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 22:32:07.1840 (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: qzbhiL8d4XTbfTr/KRNis2dpEUuWz2ZMYkhV/rAa8C+kSmsE7VwwWzLqIQmfgBDoEpafoJEcAj984/fd1nPEEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR02MB9485 X-Authority-Analysis: v=2.4 cv=bYg5U/PB c=1 sm=1 tr=0 ts=672556e9 cx=c_pps a=WlqDjRht0D+wB3AL0MAriA==:117 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=VlfZXiiP6vEA:10 a=0034W8JfsZAA:10 a=0kUYKlekyDsA:10 a=64Cc0HZtAAAA:8 a=rtD7whcn2g4kf6IR_CUA:9 a=14NRyaPF5x3gF6G45PvQ:22 X-Proofpoint-GUID: 0WgylqBaVWNJd1F3AtQxTI1ZVyL3gHpR X-Proofpoint-ORIG-GUID: 0WgylqBaVWNJd1F3AtQxTI1ZVyL3gHpR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-01_17,2024-11-01_01,2024-09-30_01 X-Proofpoint-Spam-Reason: safe Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WQ5CRQW2W4UY3X6ONO6Y4S7XXREPEMQA X-Message-ID-Hash: WQ5CRQW2W4UY3X6ONO6Y4S7XXREPEMQA 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: 1730500406695116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Levon Reviewed-by: Michal Privoznik --- src/test/test_driver.c | 114 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b7e36e8451..789b1a2222 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10741,6 +10741,85 @@ testDomainDetachPrepNet(virDomainObj *vm, } =20 =20 +static int +testFindDisk(virDomainDef *def, const char *dst) +{ + size_t i; + + for (i =3D 0; i < def->ndisks; i++) { + if (STREQ(def->disks[i]->dst, dst)) + return i; + } + + return -1; +} + +static int +testDomainDetachPrepDisk(virDomainObj *vm, + virDomainDiskDef *match, + virDomainDiskDef **detach) +{ + virDomainDiskDef *disk; + int idx; + + if ((idx =3D testFindDisk(vm->def, match->dst)) < 0) { + virReportError(VIR_ERR_DEVICE_MISSING, + _("disk %1$s not found"), match->dst); + return -1; + } + *detach =3D disk =3D vm->def->disks[idx]; + + switch ((virDomainDiskDevice) disk->device) { + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_LUN: + + switch (disk->bus) { + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_SCSI: + break; + + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_SD: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("This type of disk cannot be hot unplugged")); + return -1; + + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_LAST: + default: + virReportEnumRangeError(virDomainDiskBus, disk->bus); + return -1; + } + break; + + case VIR_DOMAIN_DISK_DEVICE_CDROM: + if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_USB || + disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI) { + break; + } + G_GNUC_FALLTHROUGH; + + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("disk device type '%1$s' cannot be detached"), + virDomainDiskDeviceTypeToString(disk->device)); + return -1; + + case VIR_DOMAIN_DISK_DEVICE_LAST: + default: + virReportEnumRangeError(virDomainDiskDevice, disk->device); + return -1; + } + + return 0; +} + + static int testDomainRemoveHostDevice(testDriver *driver G_GNUC_UNUSED, virDomainObj *vm, @@ -10810,6 +10889,28 @@ testDomainRemoveNetDevice(testDriver *driver G_GNU= C_UNUSED, return 0; } =20 + +static int +testDomainRemoveDiskDevice(testDriver *driver G_GNUC_UNUSED, + virDomainObj *vm, + virDomainDiskDef *disk) +{ + size_t i; + + VIR_DEBUG("Removing disk %s from domain %p %s", + disk->info.alias, vm, vm->def->name); + + for (i =3D 0; i < vm->def->ndisks; i++) { + if (vm->def->disks[i] =3D=3D disk) { + virDomainDiskRemove(vm->def, i); + break; + } + } + + virDomainDiskDefFree(disk); + return 0; +} + static int testDomainRemoveDevice(testDriver *driver, virDomainObj *vm, @@ -10835,8 +10936,11 @@ testDomainRemoveDevice(testDriver *driver, if (testDomainRemoveHostDevice(driver, vm, dev->data.hostdev) < 0) return -1; break; - case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_DISK: + if (testDomainRemoveDiskDevice(driver, vm, dev->data.disk) < 0) + return -1; + break; + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -10900,8 +11004,14 @@ testDomainDetachDeviceLive(testDriver *driver, } break; =20 - case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_DISK: + if (testDomainDetachPrepDisk(vm, match->data.disk, + &detach.data.disk) < 0) { + return -1; + } + break; + + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: --=20 2.34.1