From nobody Sun May 12 07:39:43 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 1698681852235491.85714040776566; Mon, 30 Oct 2023 09:04:12 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 25FB41727; Mon, 30 Oct 2023 12:04:11 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EFD7A1711; Mon, 30 Oct 2023 12:02:53 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 10066170C; Mon, 30 Oct 2023 12:02:51 -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 63A0B1708 for ; Mon, 30 Oct 2023 12:02:50 -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 39UE3sY6025223 for ; Mon, 30 Oct 2023 09:02:49 -0700 Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3u1n3pt58j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 30 Oct 2023 09:02:49 -0700 (PDT) Received: from DM8PR02MB8005.namprd02.prod.outlook.com (2603:10b6:8:16::16) by SA3PR02MB10081.namprd02.prod.outlook.com (2603:10b6:806:39a::11) 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 16:02:47 +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 16:02:47 +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=H9aDg50J13TCVo3QTBRygdy3NqvWcQrtzgrkUVNtPXx4N1605P0pAd5J46Sv44njtMcMIvxk/al+79Vgd6AUut60BEDpRhU+79tl7isvblJB32RvZ4up0wcWtHbdmmBniAIG5Dq7U440kE/tSZcRli62x41NzVtYKLTUhVTwmkt+7w6gxKtjYkG6XI0fKgACJiAYhG9/uN6XVjBXglcp9Bil2P3vW6vgB3e2WEXDX322e/BFU4VnvoCM9lAIJGCwE27p0EiEBqgzv/cYwtPhbg0a1Y1a143GkSu5HXtx2LZzaWONsDvKrNiq6QTCvTfi63fhKSH58AMM0qqru6pTfA== 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=EoO6mcNhucCc+DGNm6S4ANKM7mXbYn35Okk5IFlAX84=; b=j966/0OqSkk4euC4+0uY+Hs7EJoWf4Y14nihaJuBCHXvgWFDgDS0YORUXSM5+7i8kvJ7qvGsjDuflYOpddOFIBsvV9ang3iCzT/+EYDZuxWSJDFdiS5ndkXoWNyw+h2eVOely5/KtId3HdKerKuqnW0tILRAQ/KHcyJFJjDNhu9IewEKxb0R9egK8JXV+R7+8BgwKVYgzPeckBKH0W5L8RR8369ZOPEirL6ormJZUt9cRR4sUw0Rhgt43SiQ9jhiLJGl/duFZ9GJvpvchyUH/V8vAxdaWi7ky17BHISwQsNYWLPA14DaCDUcFSzpflUKK9i9OKvYj4BqQ6i3pJ3yBw== 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 V3] support for hotplug/hotunplug in test hypervisor Date: Mon, 30 Oct 2023 16:02:43 +0000 Message-Id: <20231030160243.185180-1-thanos.makatos@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: PH7PR10CA0012.namprd10.prod.outlook.com (2603:10b6:510:23d::26) To DM8PR02MB8005.namprd02.prod.outlook.com (2603:10b6:8:16::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM8PR02MB8005:EE_|SA3PR02MB10081:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ab1268f-4e8a-4bab-e2f0-08dbd961a8b4 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: j8NeDDunF0Jevcgx3q99gtuLSDHzGM1FAX4FtxVkjGbhhqIsEbEOXbMcSgZGeOQsWvFkCEi+CJoI3NJ8XfLqwaLy6M4zSSPaTdsV6taX7lQMuKHxm3EMDM44iy3O6ZmfxkptW2oKP2rDfhzLY9h6ouJLyL0ugzBHckOrrC/0uwryaA6VYQikhmlQLiQSo/YprUiRJpkBfmbiR9b+N9KSrelbgGeh5n1STjfQXyIBuno3byRHkmLQMFQI+SmLVXM1EMLECNrMf5sckzmwPa3a59gavsjGblSVGm5NJsSvk333KPjM7Q2wEFgltt3oqZATVDRoAZAK2xkphIVy3f9CnWEu58Ct8nhxy5I5M0Zs6tdhlX2huSDou6iE+OWXaLs3e24SAg+yQLzYkfCG2s1LWUraZpAOhnalnDf1/ljLG65nS0cXExki/7iODwvFsMnNKSOMzRTcAIabJ8UAzS2jXzKqVaPRw42HEyDyQ2YhP7ydW88VgrduphKoef6OYnKpPQlCOFwjNKb64OqxL4u+uqMqpU+gfGYo78y7Pxw2EvDLWX5UsbAlwdQO9yL43OmLE90eBh1fn/CAFLiwPidp025Yy79+Bu9Myoz5sDO+v5ZkY4X4PiQO5iunwaa6+Or2 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)(396003)(39860400002)(376002)(366004)(346002)(136003)(230922051799003)(64100799003)(186009)(1800799009)(451199024)(38350700005)(86362001)(6916009)(6506007)(4326008)(52116002)(1076003)(38100700002)(6512007)(8936002)(44832011)(8676002)(36756003)(2906002)(107886003)(2616005)(6666004)(83380400001)(6486002)(66946007)(26005)(5660300002)(66476007)(478600001)(66556008)(41300700001)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?61sixpzzVKSQoUIc+o1um3h5RQimbE0fXIkCW//Jby9TQEkaR/sGi0vjiFr8?= =?us-ascii?Q?aJd3UoRyj5RJ4oEEl5dKb1ZmlQaQOKfV7t9NA91ec8R7IB4eUiRb+00wJ51f?= =?us-ascii?Q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BhSBE?= =?us-ascii?Q?bfdSxeeTETH1J4kLp256a1nJieJha5NmNd6lnP78+nJ2ViSlIgqe8t09PbO+?= =?us-ascii?Q?YWkKHD7fkRw8E0/8REMCZ9agSdLRdSwBTvOKLIptIdDPnrtx2TE0PH0O9ZjC?= =?us-ascii?Q?k0HFgebm72pCTqL8TMmVaIhleDqBDZF5RBUkyEiukfQS0ubiJejF1meG0/Dw?= =?us-ascii?Q?UNHQ0CQ/nc/BR+YZH3Azn8n9vTnXR+j9rskcNnMoz3sOsi2YM9/Tv3kMATL4?= =?us-ascii?Q?BnHuOO9na8HBt1QbqtFnPwBNlHvQeLJ52PN/gPaibnXT49EJJIJGhzG4uzKG?= =?us-ascii?Q?NJ7qcMdkJCI4QI5sqJ1kg5RAFFgWLU87DzMc+5OeLWs9EzyZkbsLdCXio+et?= =?us-ascii?Q?RuanJF+hvfAl+O/dkfffGPggqRDvPt++DHvhELt6Sthmc6a7p8UZZBkscvvL?= =?us-ascii?Q?CNUYOnlNgxwJDETabuipdva4m5U0/vbauf47+CCUcuJiiIvi7Zb0l7F36o3s?= =?us-ascii?Q?9S7jXBBPrK3lFw7b7QIsMV072YfAFjrzxoVdqYy7RDwK2HFpOrXiWbgAU0yj?= =?us-ascii?Q?VHPsFP5+nF3gxDzNUWsCLzzuIcHL7nQhTxUAEYV4C1Z1wDhJirXnyWcSivh4?= =?us-ascii?Q?0g=3D=3D?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ab1268f-4e8a-4bab-e2f0-08dbd961a8b4 X-MS-Exchange-CrossTenant-AuthSource: DM8PR02MB8005.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 16:02:47.7737 (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: HMgSzehzH3DGJX7/TAR8PDlkFrWgYoE1qUraEptA/ALMyS1L0di/jm7Us4XtK76z9w2Ll3tXlUWpd3XOYr8deAI56bhZg6FgiEXCUBF97v4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR02MB10081 X-Proofpoint-GUID: lNG4Iu7CE8DurEeDjXybO40A4NpF8Po8 X-Proofpoint-ORIG-GUID: lNG4Iu7CE8DurEeDjXybO40A4NpF8Po8 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: 766S4PL2CSK5H6UZ6PIFJGDLCRMOLZWO X-Message-ID-Hash: 766S4PL2CSK5H6UZ6PIFJGDLCRMOLZWO 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: 1698681854517100001 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..d605649262 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; + size_t i; + 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