From nobody Sat May 11 08:18:58 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1698679237399195.13620429774699; Mon, 30 Oct 2023 08:20:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4D9F016F2; Mon, 30 Oct 2023 11:20:36 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 63BB71717; Mon, 30 Oct 2023 11:18:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5B152171D; Mon, 30 Oct 2023 11:18:09 -0400 (EDT) Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) (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 86FDC179A for ; Mon, 30 Oct 2023 11:16:55 -0400 (EDT) Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39UEAGr0000930 for ; Mon, 30 Oct 2023 08:16:55 -0700 Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3u1n3pt2aj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 30 Oct 2023 08:16:54 -0700 (PDT) Received: from DM8PR02MB8005.namprd02.prod.outlook.com (2603:10b6:8:16::16) by SA3PR02MB9278.namprd02.prod.outlook.com (2603:10b6:806:314::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Mon, 30 Oct 2023 15:16:52 +0000 Received: from DM8PR02MB8005.namprd02.prod.outlook.com ([fe80::78ae:6068:aacd:c855]) by DM8PR02MB8005.namprd02.prod.outlook.com ([fe80::78ae:6068:aacd:c855%4]) with mapi id 15.20.6933.019; Mon, 30 Oct 2023 15:16:52 +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.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lm87ZUK+2QuKnaMyCnFHVpUW8z3hMwm0ZqYBNQXRvfKWTyVAiaHTFExU8mWql+wIhyWysL3QPoHpgvmaHwGLsri36B/w6EDeoVUz8AE8EzPcboxNSjDHPlRyzI9Y8GmucsLpXSmj4LX0TZal9WfuAoVGb3D9sH4A/jjbpTgJB/miFBA+A6mT2tgD+bUdaQTydl4AGaDEVyoQxNE/fuppCdK4xAvBvcX+tM8GG7v/qv8fPy6CkLN9/vgDwdWkUQ851bGzp9NxJZaYCx5CvRML+VdcSPaUuGdu9Fsi34ZyzrPLQWR3V4KXCRGnZMP8Jq5QNVSO8ijjo4Gk8iFXzSuffg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=djXwwOylFRrfjdWI/IsSDO2gfuxHHRqhLsKMPnX5DM4=; b=XgAn4b3ug0f2mS6d4D5M/jIyM4ocmtrPLzCln1Dyi3fNbjlI8Y4HIcqjfBCMA+sJ2XiKJ1dpDZ3B8eKgpcVilUHOdk6ImllknrLKz55m+06k+0/RXttGG6MJsCAS/ZYOJcE5AF8jvuvqJ9ywBKVlS2tXEeDdMZ1DqwyzN+bI3HKEShjZTL/I+mx0qMB+GcLAACx6GQxpM5urZzaLACyIkfFyqgQ1sQ0kJbqkbAN7GNstqAqk2difBGItsbI9aUy0/xpXnyeIyv1AQKi6omoJX15EsZPCxjROwb2M6xmqdNCH8z6LMSHgnXKRkmHLo5u9kM0BIuoYySv1zNguvrycuw== 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 From: Thanos Makatos To: devel@lists.libvirt.org Subject: [PATCH V2] support for hotplug/hotunplug in test hypervisor Date: Mon, 30 Oct 2023 15:16:49 +0000 Message-Id: <20231030151649.176043-1-thanos.makatos@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: BYAPR07CA0006.namprd07.prod.outlook.com (2603:10b6:a02:bc::19) To DM8PR02MB8005.namprd02.prod.outlook.com (2603:10b6:8:16::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM8PR02MB8005:EE_|SA3PR02MB9278:EE_ X-MS-Office365-Filtering-Correlation-Id: 90c39434-e236-4d4f-6a41-08dbd95b3eea x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0s28BlaNYIMRh2czcrTs/moRdAboaF/NBANGJvtCI+UlriVt53bQHeK5SrLYDviqxEbSz1xPc7HsoVfzo9ydBVQdX9iaw0Z5UsHgU78YFqwqAQ3h2Qh+P+vGwArE8mSTNIfM74UIQIg1X29gjEHYB8SejOICmAxFCvzl58teQZcpdXAtpDQ4QUGxPh9Ix46x4bBwfvZrKoyKv8khDf8Oe+JyAyN+9+gIMHk82Ho8M7Vho2ybBPRDA+ePspOXOLWbR43g11Xao7BE6YwEoEVY7lL1wwdtnwfKaHwqSyNx1kFmtc+mxdyxsSWjk6JXpLm8NCTviEFoOi1No3qxsHmjEaN2TNtd3uY0vujRW47zAQfC+RamddJQ/sw+RNY/vS/sXKkL5NfurKoulrYUvsBNy9pWgI+F31ukNSQnrrGtclzAb1rhhq7KPA9HNYkXrq08DskQijWVi5X/YBZ/pJ1ytZGt4C/AjQDxXpKN+M7x5LtPeA4uR0JKgsbp/Uvs+QIZLX8DJL9SPz1n2JCg2mjfHFM7pjKc5xuaYbcli/cAti1TVriBDM+LzcdX8A4FLp25PRHTmZpLCWYtL9cotfw0qmNxkLmQTTja+87YcSKCBkjkJDS31Mr2+v3FduGJU397 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR02MB8005.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(376002)(346002)(136003)(39860400002)(396003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2906002)(38350700005)(2616005)(6512007)(52116002)(6506007)(6486002)(38100700002)(86362001)(36756003)(478600001)(1076003)(66476007)(66946007)(83380400001)(44832011)(107886003)(4326008)(8676002)(41300700001)(6666004)(8936002)(6916009)(66556008)(5660300002)(26005)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8uv3k8JbdkSbPfN/n4wyAubu9phA05JJBggwamDbK2Tf47yaEryxPZFaC0i9?= =?us-ascii?Q?5Be4a5fiE3MLaSc71Mrdd+CaVFa28poJbVXOxcBFDNX5x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nRtlYffxJhTsweUVpE+YMmemaWfpfnV8PlMIUf8aQz/t?= =?us-ascii?Q?h31ZibyYKYM89Dj+D2sVfpW3Vj98twMB5Jlbvmas65fVY0yoqCYjAguqzRe7?= =?us-ascii?Q?gHLwl8Pw2u6JRlCdIIkLR576IuYtXg3dgY0gCC6aQ5ogc9yXbDXforqlFY28?= =?us-ascii?Q?2znzeULhZehlFFSrF/ttgtQgZAnOkvZ+OXVt6cokSiNnzm9JKRTE0cCMamkm?= =?us-ascii?Q?NtJD/L+SK3c/xskGcPnUus2JCqpihiaDN32/B4aSFa4xKtnvG0wyvc6DEf0e?= =?us-ascii?Q?/9v5PUOaFxvzLQ7xjQ93+49EBbRxH9j4tyQ202oJINEeWa5ieI2Pk2IqHpvr?= =?us-ascii?Q?YHk7FscmxZxZhxbVZR4Ax/f2Xp6fr/YjJbTx155i6WVcnEW0vfRpsmwzQZ02?= =?us-ascii?Q?9lb78oDSdc362KifVNbMi8ll4a0s0WNHSgyRPCImpBrhZjTPp5ZPkxNgc/dG?= =?us-ascii?Q?vs2HGA8VrvK9ExdzcwHjyK7YjUhSRw7Hc6iuM08mHNc/EQr9xnmJYqH+H0aV?= =?us-ascii?Q?yJDKijUs/LEgW1xQTVWSEF8VX32PlGEuVUlCG8wK41uyun8FWxMkwBfh57fE?= =?us-ascii?Q?zZiMDninoZPipjbqKJzcqtrY0cCl1zXtloCywu0gooolXrjyUuWSyUiaQTA1?= =?us-ascii?Q?tQ=3D=3D?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90c39434-e236-4d4f-6a41-08dbd95b3eea X-MS-Exchange-CrossTenant-AuthSource: DM8PR02MB8005.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 15:16:52.5526 (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: RUhBWJV2JEbW31zBjWvU87se+LLJqkE83/cUlpO2kNVHohi+2UItc25bJ5gIHNMZv0ioA1LQnE5W3U4FnhxrFCe4tY3hWf9Oh9Y0dYapAwE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR02MB9278 X-Proofpoint-GUID: 4sQVhmO0Jp9yP32sA0Hxre8whe46p7TU X-Proofpoint-ORIG-GUID: 4sQVhmO0Jp9yP32sA0Hxre8whe46p7TU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-30_10,2023-10-27_01,2023-05-22_02 X-Proofpoint-Spam-Reason: safe Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 52AWLYD4WT2J7ZIVGJAB6SKT532BH7OM X-Message-ID-Hash: 52AWLYD4WT2J7ZIVGJAB6SKT532BH7OM X-MailFrom: thanos.makatos@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: Thanos Makatos 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-ZM-MESSAGEID: 1698679237793100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Thanos Makatos --- src/test/test_driver.c | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e87d7cfd44..80ef1b3cbb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -10035,6 +10035,62 @@ testConnectGetDomainCapabilities(virConnectPtr con= n G_GNUC_UNUSED, return virDomainCapsFormat(domCaps); } =20 +static int +testVirDomainAttachDeviceFlags(virDomainPtr domain, + const char *xml, + unsigned int flags G_GNUC_UNUSED) { + + int ret =3D -1; + virDomainObj *vm; + testDriver *driver; + virDomainDeviceDef *devConf; + + if (!(vm =3D testDomObjFromDomain(domain))) + return -1; + + driver =3D domain->conn->privateData; + + if (!(devConf =3D virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, + NULL, 0))) + goto out; + + VIR_APPEND_ELEMENT(vm->def->hostdevs, vm->def->nhostdevs, + devConf->data.hostdev); + virDomainDeviceDefFree(devConf); + ret =3D 0; +out: + virDomainObjEndAPI(&vm); + return ret; +} + +static int +testVirDomainAttachDevice(virDomainPtr domain, const char *xml) +{ + return testVirDomainAttachDeviceFlags(domain, xml, 0); +} + +static int +testVirDomainDetachDeviceAlias(virDomainPtr domain, + const char *alias, + unsigned int flags G_GNUC_UNUSED) +{ + virDomainObj *vm; + int size_t; + bool found =3D false; + + if (!(vm =3D testDomObjFromDomain(domain))) + return -1; + + for (i =3D 0; i < vm->def->nhostdevs && !found; i++) { + if (!strcmp(vm->def->hostdevs[i]->info->alias, alias)) { + virDomainHostdevDefFree(vm->def->hostdevs[i]); + VIR_DELETE_ELEMENT(vm->def->hostdevs, i, vm->def->nhostdevs); + found =3D true; + } + } + virDomainObjEndAPI(&vm); + return found ? 0 : -1; +} =20 /* * Test driver @@ -10058,6 +10114,9 @@ static virHypervisorDriver testHypervisorDriver =3D= { .connectListDomains =3D testConnectListDomains, /* 0.1.1 */ .connectNumOfDomains =3D testConnectNumOfDomains, /* 0.1.1 */ .connectListAllDomains =3D testConnectListAllDomains, /* 0.9.13 */ + .domainAttachDevice =3D testVirDomainAttachDevice, /* 9.9.0 */ + .domainAttachDeviceFlags =3D testVirDomainAttachDeviceFlags, /* 9.9.0 = */ + .domainDetachDeviceAlias =3D testVirDomainDetachDeviceAlias, /* 9.9.0 = */ .domainCreateXML =3D testDomainCreateXML, /* 0.1.4 */ .domainCreateXMLWithFiles =3D testDomainCreateXMLWithFiles, /* 5.7.0 */ .domainLookupByID =3D testDomainLookupByID, /* 0.1.1 */ --=20 2.27.0