From nobody Tue Mar 3 04:54:29 2026 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; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1771536837; cv=none; d=zohomail.com; s=zohoarc; b=LHuFKqYJngATh90ub2PpOtoaZpoN4x4JTYBK+cRz3K3NMtx61KFzh64AYI2KTvea+Ry/cYcHeeCneXe02plcsVuhGGw+W6uUADaQStyaZYxif6QmdyN5XOZdWoOLu8g5LHEI96f8gzwHUb30N+T5AAxGfc+LoI2HBIJwfpT5ofA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771536837; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=rU/gtr5Rqx3n588RWCyB1ZrCT4cQCnzvY/eZzDfx5dU=; b=EPusqtM1z+TxUXku/jdEHBRFSzqjzCWQQ+wQ5CyVSLJKY3PkKCCp92vN5Av9Bh5YPZ4attDfQzQwjRUVlXD7c2BZadHa4LO0vJF6NaZnai2iUx5/P4gds34IACJqf8UtTUwU1YhFDFwfz0lYEoFAEMn+AEYqhnXhwY3vLv7mgAc= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1771536837170657.4723965480747; Thu, 19 Feb 2026 13:33:57 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 395954197E; Thu, 19 Feb 2026 16:33:56 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id D863E41AC1; Thu, 19 Feb 2026 16:31:42 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id ECE743FA5C; Thu, 19 Feb 2026 16:31:34 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 630E53F359 for ; Thu, 19 Feb 2026 16:31:34 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-622-TAn9ETRpMMGmr-R1sgKRUw-1; Thu, 19 Feb 2026 16:31:31 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 87AE81956095 for ; Thu, 19 Feb 2026 21:31:30 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.90.32]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 05DF83000C26; Thu, 19 Feb 2026 21:31:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771536692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rU/gtr5Rqx3n588RWCyB1ZrCT4cQCnzvY/eZzDfx5dU=; b=DZlM26tr3IHors2wRTv8A0NsDWgwq8kbpA/F2r7jTgH2bjA4nALJr9mim9qRTw3mgB/bqC G2Y7LOVP64XCBR3T6Gn0gou3ImXi8DPJIzZgObtaqrhIHFe/wUm7C8dU/n1tnJAB2aRlCa 1kDUu4Yig1l5kqXStle4RtN55aZzRR8= X-MC-Unique: TAn9ETRpMMGmr-R1sgKRUw-1 X-Mimecast-MFC-AGG-ID: TAn9ETRpMMGmr-R1sgKRUw_1771536690 To: devel@lists.libvirt.org Subject: [PATCH 2/3] hyperv: Add resource subtype definitions Date: Thu, 19 Feb 2026 15:31:25 -0600 Message-ID: <20260219213126.3387319-3-jjongsma@redhat.com> In-Reply-To: <20260219213126.3387319-1-jjongsma@redhat.com> References: <20260219213126.3387319-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 8QOPmN7P4nvJLEYrATzKXrBaQnMpVu1uBlpCJaTFybQ_1771536690 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7WMVHLHIE3CI6NT7QGRUKP4DM2B44KUE X-Message-ID-Hash: 7WMVHLHIE3CI6NT7QGRUKP4DM2B44KUE X-MailFrom: jjongsma@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: ehazan@redhat.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jonathon Jongsma via Devel Reply-To: Jonathon Jongsma X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771536838964158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Rather than using raw strings, create definitions for each subtype string so that they can be re-used without needing to know the exact string format. Signed-off-by: Jonathon Jongsma --- Note: I originally intended to use these constants in the next patch, but later changed my approach and didn't actually use these in the blockinfo implementation. Nevertheless it seems like a useful change. src/hyperv/hyperv_driver.c | 29 +++++++++++++++-------------- src/hyperv/hyperv_driver.h | 11 +++++++++++ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index eb28093028..3cebab305b 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -447,7 +447,7 @@ hypervDomainCreateSCSIController(virDomainPtr domain, v= irDomainControllerDef *de return -1; =20 if (hypervSetEmbeddedProperty(scsiResource, "ResourceSubType", - "Microsoft:Hyper-V:Synthetic SCSI Contro= ller") < 0) + HYPERV_RESOURCE_SUBTYPE_SCSI_CONTROLLER)= < 0) return -1; =20 /* perform the settings change */ @@ -493,7 +493,7 @@ hypervDomainAddVirtualDiskParent(virDomainPtr domain, return -1; =20 if (hypervSetEmbeddedProperty(controllerResource, "ResourceSubType", - "Microsoft:Hyper-V:Synthetic Disk Drive"= ) < 0) + HYPERV_RESOURCE_SUBTYPE_DISK_DRIVE) < 0) return -1; =20 if (hypervMsvmVSMSAddResourceSettings(domain, &controllerResource, @@ -537,7 +537,7 @@ hypervDomainAddVirtualHardDisk(virDomainPtr domain, return -1; =20 if (hypervSetEmbeddedProperty(volumeResource, "ResourceSubType", - "Microsoft:Hyper-V:Virtual Hard Disk") <= 0) + HYPERV_RESOURCE_SUBTYPE_VIRTUAL_HARD_DIS= K) < 0) return -1; =20 if (hypervMsvmVSMSAddResourceSettings(domain, &volumeResource, @@ -615,10 +615,11 @@ hypervDomainAttachPhysicalDisk(virDomainPtr domain, /* prepare HostResource */ =20 /* get Msvm_DiskDrive root device ID */ - virBufferAddLit(&query, - MSVM_RESOURCEALLOCATIONSETTINGDATA_WQL_SELECT - "WHERE ResourceSubType =3D 'Microsoft:Hyper-V:Physical= Disk Drive' " - "AND InstanceID LIKE '%%Default%%'"); + virBufferEscapeSQL(&query, + MSVM_RESOURCEALLOCATIONSETTINGDATA_WQL_SELECT + "WHERE ResourceSubType =3D '%s' " + "AND InstanceID LIKE '%%Default%%'", + HYPERV_RESOURCE_SUBTYPE_PHYSICAL_DISK_DRIVE); =20 if (hypervGetWmiClass(Msvm_ResourceAllocationSettingData, &diskdefault= ) < 0) return -1; @@ -666,7 +667,7 @@ hypervDomainAttachPhysicalDisk(virDomainPtr domain, return -1; =20 if (hypervSetEmbeddedProperty(diskResource, "ResourceSubType", - "Microsoft:Hyper-V:Physical Disk Drive")= < 0) + HYPERV_RESOURCE_SUBTYPE_PHYSICAL_DISK_DR= IVE) < 0) return -1; =20 if (hypervSetEmbeddedProperty(diskResource, "HostResource", hostResour= ce) < 0) @@ -715,7 +716,7 @@ hypervDomainAddOpticalDrive(virDomainPtr domain, return -1; =20 if (hypervSetEmbeddedProperty(driveResource, "ResourceSubType", - "Microsoft:Hyper-V:Synthetic DVD Drive")= < 0) + HYPERV_RESOURCE_SUBTYPE_DVD_DRIVE) < 0) return -1; =20 if (hypervMsvmVSMSAddResourceSettings(domain, &driveResource, @@ -758,7 +759,7 @@ hypervDomainAddOpticalDisk(virDomainPtr domain, return -1; =20 if (hypervSetEmbeddedProperty(volumeResource, "ResourceSubType", - "Microsoft:Hyper-V:Virtual CD/DVD Disk")= < 0) + HYPERV_RESOURCE_SUBTYPE_VIRTUAL_DVD_DISK= ) < 0) return -1; =20 if (hypervMsvmVSMSAddResourceSettings(domain, &volumeResource, @@ -828,7 +829,7 @@ hypervDomainAttachFloppy(virDomainPtr domain, return -1; =20 if (hypervSetEmbeddedProperty(volumeResource, "ResourceSubType", - "Microsoft:Hyper-V:Virtual Floppy Disk")= < 0) + HYPERV_RESOURCE_SUBTYPE_VIRTUAL_FLOPPY_D= ISK) < 0) return -1; =20 if (hypervMsvmVSMSAddResourceSettings(domain, &volumeResource, @@ -1087,7 +1088,7 @@ hypervDomainAttachSyntheticEthernetAdapter(virDomainP= tr domain, return -1; =20 if (hypervSetEmbeddedProperty(portResource, "ResourceSubType", - "Microsoft:Hyper-V:Synthetic Ethernet Po= rt") < 0) + HYPERV_RESOURCE_SUBTYPE_ETHERNET_PORT) <= 0) return -1; =20 if (hypervSetEmbeddedProperty(portResource, @@ -1156,7 +1157,7 @@ hypervDomainAttachSyntheticEthernetAdapter(virDomainP= tr domain, return -1; =20 if (hypervSetEmbeddedProperty(connectionResource, - "ResourceSubType", "Microsoft:Hyper-V:Et= hernet Connection") < 0) + "ResourceSubType", HYPERV_RESOURCE_SUBTY= PE_ETHERNET_CONNECTION) < 0) return -1; =20 if (hypervMsvmVSMSAddResourceSettings(domain, &connectionResource, @@ -1294,7 +1295,7 @@ hypervDomainDefParseVirtualExtent(hypervPrivate *priv, disk->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; =20 /* note if it's a CDROM disk */ - if (STREQ(disk_entry->data->ResourceSubType, "Microsoft:Hyper-V:Virtua= l CD/DVD Disk")) + if (STREQ(disk_entry->data->ResourceSubType, HYPERV_RESOURCE_SUBTYPE_V= IRTUAL_DVD_DISK)) disk->device =3D VIR_DOMAIN_DISK_DEVICE_CDROM; else disk->device =3D VIR_DOMAIN_DISK_DEVICE_DISK; diff --git a/src/hyperv/hyperv_driver.h b/src/hyperv/hyperv_driver.h index 3764844494..27be81ea1c 100644 --- a/src/hyperv/hyperv_driver.h +++ b/src/hyperv/hyperv_driver.h @@ -27,4 +27,15 @@ #define HYPERV_MAX_IDE_CHANNELS 2 #define HYPERV_MAX_DRIVES_PER_IDE_CHANNEL 2 =20 +/* ResourceSubType values for Msvm_*AllocationSettingData */ +#define HYPERV_RESOURCE_SUBTYPE_SCSI_CONTROLLER "Microsoft:Hyper-V:Synthet= ic SCSI Controller" +#define HYPERV_RESOURCE_SUBTYPE_DISK_DRIVE "Microsoft:Hyper-V:Synthetic Di= sk Drive" +#define HYPERV_RESOURCE_SUBTYPE_VIRTUAL_HARD_DISK "Microsoft:Hyper-V:Virtu= al Hard Disk" +#define HYPERV_RESOURCE_SUBTYPE_PHYSICAL_DISK_DRIVE "Microsoft:Hyper-V:Phy= sical Disk Drive" +#define HYPERV_RESOURCE_SUBTYPE_DVD_DRIVE "Microsoft:Hyper-V:Synthetic DVD= Drive" +#define HYPERV_RESOURCE_SUBTYPE_VIRTUAL_DVD_DISK "Microsoft:Hyper-V:Virtua= l CD/DVD Disk" +#define HYPERV_RESOURCE_SUBTYPE_VIRTUAL_FLOPPY_DISK "Microsoft:Hyper-V:Vir= tual Floppy Disk" +#define HYPERV_RESOURCE_SUBTYPE_ETHERNET_PORT "Microsoft:Hyper-V:Synthetic= Ethernet Port" +#define HYPERV_RESOURCE_SUBTYPE_ETHERNET_CONNECTION "Microsoft:Hyper-V:Eth= ernet Connection" + int hypervRegister(void); --=20 2.53.0