From nobody Sun Nov 24 02:09:58 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?ESd1s3ojaKp1u19BPvRveXskCpXbvDEf2XxNPZrbPRIjCZzgm9X0/sLsUVVw?= =?us-ascii?Q?XuGco97jL4xCE3nzVjoKySwXFFCvL6tRVG5cV/EXpJl3yqa3fpXBcNVZFbhT?= =?us-ascii?Q?WF0lO3NdRzLSzljmjHrSs+5eyr/6I05ASJz5QrOkOQB8PZWWIEdyRYRXXiRt?= =?us-ascii?Q?dhhqXhrtQCNNepryjtj3ToVQrodSzuKuq3pQPirFyH3pHksP7gA0jSwJwMlW?= =?us-ascii?Q?1BPoMVQ7c8kUOn3xkIqeZSmLvPUrMkBIuLdoq+K4tQtLoB/bzXz/1Y8mJNXp?= =?us-ascii?Q?0glbpqxOGuLqqVBFjo6/by8N/ca6nsZGqFkASTgK7YwZ83LVGHIk0jur8AZZ?= =?us-ascii?Q?BND6f70dFkAzLpLzLMypuWrEOfLGRs5POqN1T26RgqimVcFkYmNinfVxOo6N?= =?us-ascii?Q?P537FzDhxWQDx84lFiTz1VG39V+gC+it3QVoCMtwool66VcllU1mbtrKnWC3?= =?us-ascii?Q?iqIzvrx+IZi9UsXrIes81UdcUdSpt1hRKd10GX8OOyJb8MZrVtksf9qqbepH?= =?us-ascii?Q?akDEB/cs6RwBEpgNvwe9FcBM59v+osMRYEuTmrbxOLXb63kPZ9zP1haLk8iO?= =?us-ascii?Q?kZr+txlNiUuGf0fM5oar+VXmxA2L5J2dG6qkBf8O6MA5EcQ25VHGTpmGyRfJ?= =?us-ascii?Q?9UPum5wNKR1Q0NptYHry51xuvHZmXZwgQrYs4EHE1Eiu3W8iEU6PbsIJbO5X?= =?us-ascii?Q?7BYBmkr11ScbJG+wlR3XbSkm5wx0Gx0Rf058E/xz0Gb1ma9gHWbkUJKW1h56?= =?us-ascii?Q?SmFB+NZt1zJiifathN2KEEUmLH4mjSS+WqGRyOODGtIcQfTPebrQkqRwPjrR?= =?us-ascii?Q?UfujcI/dx/b2O4SnqYI9fD3y92qD2TN4ZFm9zgRdnNL8fGF4bWJ0e+gH3Hiv?= =?us-ascii?Q?8j1lYX04I78y32HSodQXv63zj2ZyQvAtQvJuhZJRvI+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 --- 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