From nobody Sat Nov 23 12:35:55 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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OkVeSWXWw6YMp6KqcbORUbMEG?= =?us-ascii?Q?yYO3gnHEFZpzMnNIPRoax/3Cm0cOmW34aOsdoHnYo4Jw1GmynN5KrQqJgQlg?= =?us-ascii?Q?K1XP+DDMfFlS8lP2u92rzG5ujrmbegwRegzVQleFA6n4m3uQhV9lzxKBGFF6?= =?us-ascii?Q?fD4oTvCtGu3E9GIYnhkRECF7oKeAvpxaFt0+L0TKcjujtPQP6W5ldW6kcPEO?= =?us-ascii?Q?Im1qXBHTfq5ljQFGbE/lPbZsM61kcsvb9c3RjPf+sReTUkAKKfURxWhuIGYh?= =?us-ascii?Q?vLZMBlclMZEC73dpdmJrvb1BYsH9rYcKa3Kp06UxkFShQET7IJbocfvAk9nC?= =?us-ascii?Q?zsvQQotSSZGVHY8Kzn6wH6pJCmL4NLiVlkTqT8qG4kU59twauS0uJmTNDeEm?= =?us-ascii?Q?z+DIL93bRfko69wApnX7+GZCSFosSt1QA4pNlJmLolZlQ6njjPlSMfes6jd1?= =?us-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?= =?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1nMDRYXDnDtNV1KMWY2IoWl?= =?us-ascii?Q?luAYjDov+RXNoAqUR6tzstwesoZGoS3ebUxkPdeFc6AjjZ6YqhUaRAq2d2/f?= =?us-ascii?Q?aMjyF/xqfgfUXXi136VcChRiJwrJ3LvRVXxvKwCzbOsFvVPBZFJvIvlS7gC0?= =?us-ascii?Q?XNx591Y77j2cOfMR4i6qIApF4rIr3tolJJS+IlKJLM/HiJlP83gyJYo3swjV?= =?us-ascii?Q?ZlI/lrIAzCbSYS7cnm7y8LU2CQoXoW7cS464K1mNkuSIsxeQjTXsrJavAL8N?= =?us-ascii?Q?n2nVHEoYL640mOWjye7oF2WKI+zj+LUtaGdi4FYZGHW+/w49zrxKDGa/AF5H?= =?us-ascii?Q?0SO5OoeIfTugzVItG6ZCCUNBOoMknqndwlqQoRw1YLsfoCF0ABbogR/m47mw?= =?us-ascii?Q?rrTeawON13IogUaLlM8Sf8DYfIJmyJQs5SVPle4iq4HuSP3eMzhdmfYOTeEe?= =?us-ascii?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 --- 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