[PATCH 0/7] drop support for Windows versions prior to 2012R2

Microsoft no longer supports Windows 2008R2 at all. Windows 2012 and 2012 R2 are still within extended support until October 9, 2023. Hyper-V's WMI API has two versions. V1 is supported by 2008R2 and 2012. 2012 also offered initial support for V2, but it's incomplete. 2012R2 was the first version to offer full support for the V2 API. This patchset drops support for the V1 WMI API. Here's a GitLab merge request, if you'd prefer to review it there: https://gitlab.com/iammattcoleman/libvirt/-/merge_requests/7 Matt Coleman (7): hyperv: remove V1 classes from the WMI generator input hyperv: remove hypervPrivate->wmiVersion hyperv: remove support for multiple API versions from the WMI generator hyperv: remove hypervWmiClassInfoList, hypervWmiClassInfoListPtr, and _hypervWmiClassInfoList hyperv: do not generate *_CLASSNAME constants docs: drop support for Windows versions prior to 2012R2 news: drop support for Windows versions prior to 2012R2 NEWS.rst | 6 + docs/drvhyperv.html.in | 17 +- docs/platforms.rst | 3 +- scripts/hyperv_wmi_generator.py | 275 ++++------------- src/hyperv/hyperv_driver.c | 299 +++++------------- src/hyperv/hyperv_private.h | 7 - src/hyperv/hyperv_wmi.c | 108 ++----- src/hyperv/hyperv_wmi.h | 39 +-- src/hyperv/hyperv_wmi_classes.h | 13 - src/hyperv/hyperv_wmi_generator.input | 422 +------------------------- 10 files changed, 180 insertions(+), 1009 deletions(-) -- 2.27.0

Signed-off-by: Matt Coleman <matt@datto.com> --- src/hyperv/hyperv_wmi_generator.input | 424 +------------------------- 1 file changed, 12 insertions(+), 412 deletions(-) diff --git a/src/hyperv/hyperv_wmi_generator.input b/src/hyperv/hyperv_wmi_generator.input index 1377138a12..e6b53bc021 100644 --- a/src/hyperv/hyperv_wmi_generator.input +++ b/src/hyperv/hyperv_wmi_generator.input @@ -23,39 +23,6 @@ # -class Msvm_ComputerSystem - string Caption - string Description - string ElementName - datetime InstallDate - uint16 OperationalStatus[] - string StatusDescriptions[] - string Status - uint16 HealthState - uint16 EnabledState - string OtherEnabledState - uint16 RequestedState - uint16 EnabledDefault - datetime TimeOfLastStateChange - string CreationClassName - string Name - string PrimaryOwnerName - string PrimaryOwnerContact - string Roles[] - string NameFormat - string OtherIdentifyingInfo[] - string IdentifyingDescriptions[] - uint16 Dedicated[] - string OtherDedicatedDescriptions[] - uint16 ResetCapability - uint16 PowerManagementCapabilities[] - uint64 OnTimeInMilliseconds - datetime TimeOfLastConfigurationChange - uint32 ProcessID - uint16 AssignedNumaNodeList[] -end - - class v2/Msvm_ComputerSystem string InstanceID string Caption @@ -105,46 +72,6 @@ class v2/Msvm_ComputerSystem end -class Msvm_ConcreteJob - string Caption - string Description - string ElementName - datetime InstallDate - uint16 OperationalStatus[] - string StatusDescriptions[] - string Status - uint16 HealthState - string JobStatus - datetime TimeSubmitted - datetime ScheduledStartTime - datetime StartTime - datetime ElapsedTime - uint32 JobRunTimes - uint8 RunMonth - int8 RunDay - int8 RunDayOfWeek - datetime RunStartInterval - uint16 LocalOrUtcTime - datetime UntilTime - string Notify - string Owner - uint32 Priority - uint16 PercentComplete - boolean DeleteOnCompletion - uint16 ErrorCode - string ErrorDescription - string ErrorSummaryDescription - uint16 RecoveryAction - string OtherRecoveryAction - string InstanceID - string Name - uint16 JobState - datetime TimeOfLastStateChange - datetime TimeBeforeRemoval - boolean Cancellable -end - - class v2/Msvm_ConcreteJob string InstanceID string Caption @@ -190,36 +117,6 @@ class v2/Msvm_ConcreteJob end -class Msvm_MemorySettingData - string Caption - string Description - string InstanceID - string ElementName - uint16 ResourceType - string OtherResourceType - string ResourceSubType - string PoolID - uint16 ConsumerVisibility - string HostResource[] - string AllocationUnits - uint64 VirtualQuantity - uint64 Reservation - uint64 Limit - uint32 Weight - boolean AutomaticAllocation - boolean AutomaticDeallocation - string Parent - string Connection[] - string Address - uint16 MappingBehavior - boolean IsVirtualized - string DeviceID - string DeviceIDFormat - boolean DynamicMemoryEnabled -# uint32 TargetMemoryBuffer # Available only on Windows Server 2008 R2 SP1 -end - - class v2/Msvm_MemorySettingData string InstanceID string Caption @@ -252,39 +149,6 @@ class v2/Msvm_MemorySettingData end -class Msvm_ProcessorSettingData - string Caption - string Description - string InstanceID - string ElementName - uint16 ResourceType - string OtherResourceType - string ResourceSubType - string PoolID - uint16 ConsumerVisibility - string HostResource[] - string AllocationUnits - uint64 VirtualQuantity - uint64 Reservation - uint64 Limit - uint32 Weight - boolean AutomaticAllocation - boolean AutomaticDeallocation - string Parent - string Connection[] - string Address - uint16 MappingBehavior - boolean IsVirtualized - string DeviceID - string DeviceIDFormat - uint16 ProcessorsPerSocket - uint16 SocketCount - boolean ThreadsEnabled - boolean LimitCPUID - boolean LimitProcessorFeatures -end - - class v2/Msvm_ProcessorSettingData string InstanceID string Caption @@ -316,31 +180,6 @@ class v2/Msvm_ProcessorSettingData end -class Msvm_VirtualSystemSettingData - string Caption - string Description - string ElementName - string InstanceID - string SystemName - uint16 SettingType - uint16 VirtualSystemType - string OtherVirtualSystemType - boolean AutoActivate - datetime CreationTime - string Notes - string BIOSGUID - string BIOSSerialNumber - string BaseBoardSerialNumber - string ChassisSerialNumber - string ChassisAssetTag - boolean BIOSNumLock - uint16 BootOrder[] - string Parent - uint16 NumaNodeList[] - boolean NumaNodesAreRequired -end - - class v2/Msvm_VirtualSystemSettingData string InstanceID string Caption @@ -730,63 +569,6 @@ class Win32_OperatingSystem end -class Msvm_VirtualSwitch - string Caption - string Description - string ElementName - datetime InstallDate - uint16 OperationalStatus[] - string StatusDescriptions[] - string Status - uint16 HealthState - uint16 EnabledState - string OtherEnabledState - uint16 RequestedState - uint16 EnabledDefault - datetime TimeOfLastStateChange - string CreationClassName - string Name - string PrimaryOwnerContact - string PrimaryOwnerName - string Roles[] - string NameFormat - string OtherIdentifyingInfo[] - string IdentifyingDescriptions[] - uint16 Dedicated[] - string OtherDedicatedDescriptions[] - uint16 ResetCapability - uint16 PowerManagementCapabilities[] - string ScopeOfResidence - uint32 NumLearnableAddresses - uint32 MaxVMQOffloads - uint32 MaxChimneyOffloads -end - - -class Msvm_VirtualSystemManagementService - string Caption - string Description - string ElementName - datetime InstallDate - uint16 OperationalStatus - string StatusDescriptions - string Status - uint16 HealthState - uint16 EnabledState - string OtherEnabledState - uint16 RequestedState - uint16 EnabledDefault - datetime TimeOfLastStateChange - string SystemCreationClassName - string SystemName - string CreationClassName - string Name - string PrimaryOwnerName - string PrimaryOwnerContact - string StartMode - boolean Started -end - class v2/Msvm_VirtualSystemManagementService string InstanceID string Caption @@ -818,35 +600,11 @@ class v2/Msvm_VirtualSystemManagementService boolean Started end -class Msvm_VirtualSystemGlobalSettingData - string Caption - string Description - string ElementName - string InstanceID - string SystemName - uint16 SettingType - uint16 VirtualSystemType - string OtherVirtualSystemType - boolean AutoActivate - datetime CreationTime - string ExternalDataRoot - string SnapshotDataRoot - uint16 AutomaticStartupAction - datetime AutomaticStartupActionDelay - uint16 AutomaticShutdownAction - uint16 AutomaticRecoveryAction - string AdditionalRecoveryInformation - string ScopeOfResidence - uint32 DebugChannelId - boolean AllowFullSCSICommandSet - string Version -end - -class Msvm_ResourceAllocationSettingData +class v2/Msvm_ResourceAllocationSettingData + string InstanceID string Caption string Description - string InstanceID string ElementName uint16 ResourceType string OtherResourceType @@ -865,64 +623,16 @@ class Msvm_ResourceAllocationSettingData string Connection[] string Address uint16 MappingBehavior + string AddressOnParent + string VirtualQuantityUnits string VirtualSystemIdentifiers[] end -class Msvm_AllocationCapabilities - string Caption - string Description - string ElementName +class v2/Msvm_SyntheticEthernetPortSettingData string InstanceID - string OtherResourceType - uint16 RequestTypesSupported - string ResourceSubType - uint16 ResourceType - uint16 SharingMode - uint16 SupportedAddStates[] - uint16 SupportedRemoveStates[] -end - - -class Msvm_SwitchPort - string Caption - string ElementName - datetime InstallDate - string StatusDescriptions[] - string Status - uint16 HealthState - string OtherEnabledState - uint16 RequestedState - uint16 EnabledDefault - string SystemCreationClassName - string SystemName - string CreationClassName - string Description - uint16 OperationalStatus[] - uint16 EnabledState - datetime TimeOfLastStateChange - string Name - string NameFormat - uint16 ProtocolType - uint16 ProtocolIFType - string OtherTypeDescription - boolean BroadcastResetSupported - uint16 PortNumber - string ScopeOfResidence - uint32 VMQOffloadWeight - uint32 ChimneyOffloadWeight - uint32 VMQOffloadUsage - uint32 ChimneyOffloadUsage - uint32 VMQOffloadLimit - uint32 ChimneyOffloadLimit - boolean AllowMacSpoofing -end - - -class Msvm_SyntheticEthernetPortSettingData string Caption string Description - string InstanceID string ElementName uint16 ResourceType string OtherResourceType @@ -941,89 +651,15 @@ class Msvm_SyntheticEthernetPortSettingData string Connection[] string Address uint16 MappingBehavior + string AddressOnParent + string VirtualQuantityUnits + uint16 DesiredVLANEndpointMode + string OtherEndpointMode string VirtualSystemIdentifiers[] + boolean DeviceNamingEnabled + boolean AllowPacketDirect boolean StaticMacAddress -end - - -class Msvm_VirtualSwitchManagementService - string Caption - string Description - string ElementName - datetime InstallDate - uint16 OperationalStatus[] - string StatusDescriptions[] - string Status - uint16 HealthState - uint16 EnabledState - string OtherEnabledState - uint16 RequestedState - uint16 EnabledDefault - datetime TimeOfLastStateChange - string SystemCreationClassName - string SystemName - string CreationClassName - string Name - string PrimaryOwnerName - string PrimaryOwnerContact - string StartMode - boolean Started -end - - -class Msvm_VirtualHardDiskSettingData - string InstanceID - string Caption - string Description - string ElementName - uint16 Type - uint16 Format - string Path - string ParentPath - uint64 MaxInternalSize - uint32 BlockSize - uint32 LogicalSectorSize - uint32 PhysicalSectorSize - string VirtualDiskId -end - -class Msvm_Keyboard - string Caption - string Description - string ElementName - datetime InstallDate - string Name - uint16 OperationalStatus[] - string StatusDescriptions[] - string Status - uint16 HealthState - uint16 EnabledState - string OtherEnabledState - uint16 RequestedState - uint16 EnabledDefault - datetime TimeOfLastStateChange - string SystemCreationClassName - string SystemName - string CreationClassName - string DeviceID - boolean PowerManagementSupported - uint16 PowerManagementCapabilities[] - uint16 Availability - uint16 StatusInfo - uint32 LastErrorCode - string ErrorDescription - boolean ErrorCleared - string OtherIdentifyingInfo[] - uint64 PowerOnHours - uint64 TotalPowerOnHours - string IdentifyingDescriptions[] - uint16 AdditionalAvailability[] - uint64 MaxQuiesceTime - uint16 LocationIndicator - boolean IsLocked - string Layout - uint16 NumberOfFunctionKeys - uint16 Password + boolean ClusterMonitored end @@ -1074,42 +710,6 @@ class v2/Msvm_Keyboard end -class Msvm_ShutdownComponent - string Caption - string Description - string ElementName - datetime InstallDate - string Name - uint16 OperationalStatus[] - string StatusDescriptions[] - string Status - uint16 HealthState - uint16 EnabledState - string OtherEnabledState - uint16 RequestedState - uint16 EnabledDefault - datetime TimeOfLastStateChange - string SystemCreationClassName - string SystemName - string CreationClassName - string DeviceID - boolean PowerManagementSupported - uint16 PowerManagementCapabilities[] - uint16 Availability - uint16 StatusInfo - uint32 LastErrorCode - string ErrorDescription - boolean ErrorCleared - string OtherIdentifyingInfo[] - uint64 PowerOnHours - uint64 TotalPowerOnHours - string IdentifyingDescriptions[] - uint16 AdditionalAvailability[] - uint64 MaxQuiesceTime - uint16 LocationIndicator -end - - class v2/Msvm_ShutdownComponent string InstanceID string Caption -- 2.27.0

On Mon, Nov 09, 2020 at 03:43:07AM -0500, Matt Coleman wrote:
Signed-off-by: Matt Coleman <matt@datto.com> --- src/hyperv/hyperv_wmi_generator.input | 424 +------------------------- 1 file changed, 12 insertions(+), 412 deletions(-)
This patch has to be moved after the 2nd patch, otherwise the build breaks temporarily which impacts git bisect. I can fix that when pushing. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Mon, Nov 09, 2020 at 03:43:07AM -0500, Matt Coleman wrote:
Signed-off-by: Matt Coleman <matt@datto.com> --- src/hyperv/hyperv_wmi_generator.input | 424 +------------------------- 1 file changed, 12 insertions(+), 412 deletions(-)
diff --git a/src/hyperv/hyperv_wmi_generator.input b/src/hyperv/hyperv_wmi_generator.input index 1377138a12..e6b53bc021 100644 --- a/src/hyperv/hyperv_wmi_generator.input +++ b/src/hyperv/hyperv_wmi_generator.input
- -class Msvm_ResourceAllocationSettingData +class v2/Msvm_ResourceAllocationSettingData + string InstanceID string Caption string Description - string InstanceID string ElementName uint16 ResourceType string OtherResourceType @@ -865,64 +623,16 @@ class Msvm_ResourceAllocationSettingData string Connection[] string Address uint16 MappingBehavior + string AddressOnParent + string VirtualQuantityUnits string VirtualSystemIdentifiers[] end
I was expecting to see that this patch only dropped code, but this is introducing a new v2 class. I think that ought to be down as a separate patch. Likewise for similar changes below. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Nov 9, 2020, at 9:28 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
I was expecting to see that this patch only dropped code, but this is introducing a new v2 class. I think that ought to be down as a separate patch. Likewise for similar changes below.
This is not actually adding a new class: current code accesses it via data.common. So, this change is necessary in order to remove the v1 version while leaving the v2 functionality intact. -- Matt

On Mon, Nov 09, 2020 at 09:31:09AM -0500, Matt Coleman wrote:
On Nov 9, 2020, at 9:28 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
I was expecting to see that this patch only dropped code, but this is introducing a new v2 class. I think that ought to be down as a separate patch. Likewise for similar changes below.
This is not actually adding a new class: current code accesses it via data.common. So, this change is necessary in order to remove the v1 version while leaving the v2 functionality intact.
That doesn't seem to be the case. If I modify this patch so that it only removes the Msvm_XXXX classes for v1, everything still compiles. What's leftover is addition of 2 extra classes whcih don't seem to impact the build +class v2/Msvm_ResourceAllocationSettingData + string InstanceID + string Caption + string Description + string ElementName + uint16 ResourceType + string OtherResourceType + string ResourceSubType + string PoolID + uint16 ConsumerVisibility + string HostResource[] + string AllocationUnits + uint64 VirtualQuantity + uint64 Reservation + uint64 Limit + uint32 Weight + boolean AutomaticAllocation + boolean AutomaticDeallocation + string Parent + string Connection[] + string Address + uint16 MappingBehavior + string AddressOnParent + string VirtualQuantityUnits + string VirtualSystemIdentifiers[] +end + + +class v2/Msvm_SyntheticEthernet + string InstanceID + string Caption + string Description + string ElementName + uint16 ResourceType + string OtherResourceType + string ResourceSubType + string PoolID + uint16 ConsumerVisibility + string HostResource[] + string AllocationUnits + uint64 VirtualQuantity + uint64 Reservation + uint64 Limit + uint32 Weight + boolean AutomaticAllocation + boolean AutomaticDeallocation + string Parent + string Connection[] + string Address + uint16 MappingBehavior + string AddressOnParent + string VirtualQuantityUnits + uint16 DesiredVLANEndpointMode + string OtherEndpointMode + string VirtualSystemIdentifiers[] + boolean DeviceNamingEnabled + boolean AllowPacketDirect + boolean StaticMacAddress + boolean ClusterMonitored +end Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Nov 9, 2020, at 9:55 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
That doesn't seem to be the case. If I modify this patch so that it only removes the Msvm_XXXX classes for v1, everything still compiles.
Sorry, I'm juggling several branches and have many commits ahead of this. I thought I had tested removing those and found them to be necessary, but I see you're right. Feel free to remove them, or I can prepare a new version of this patch. I'll be adding them back in soon, with the new APIs that I've implemented. -- Matt

Signed-off-by: Matt Coleman <matt@datto.com> --- src/hyperv/hyperv_driver.c | 199 ++++++------------------------------ src/hyperv/hyperv_private.h | 7 -- src/hyperv/hyperv_wmi.c | 46 +++------ src/hyperv/hyperv_wmi.h | 12 +-- 4 files changed, 51 insertions(+), 213 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4e24cd37aa..11f177ae30 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -318,11 +318,6 @@ static int hypervInitConnection(virConnectPtr conn, hypervPrivate *priv, char *username, char *password) { - g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER; - hypervWqlQuery wqlQuery = HYPERV_WQL_QUERY_INITIALIZER; - hypervObject *computerSystem = NULL; - int ret = -1; - /* Initialize the openwsman connection */ priv->client = wsmc_create(conn->uri->server, conn->uri->port, "/wsman", priv->parsedUri->transport, username, password); @@ -330,47 +325,19 @@ hypervInitConnection(virConnectPtr conn, hypervPrivate *priv, if (priv->client == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not create openwsman client")); - goto cleanup; + return -1; } if (wsmc_transport_init(priv->client, NULL) != 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not initialize openwsman transport")); - goto cleanup; + return -1; } /* FIXME: Currently only basic authentication is supported */ wsman_transport_set_auth_method(priv->client, "basic"); - wqlQuery.info = Msvm_ComputerSystem_WmiInfo; - wqlQuery.query = &query; - - virBufferAddLit(&query, - MSVM_COMPUTERSYSTEM_WQL_SELECT - "WHERE " MSVM_COMPUTERSYSTEM_WQL_PHYSICAL); - - /* try query using V2 namespace (for Hyper-V 2012+) */ - priv->wmiVersion = HYPERV_WMI_VERSION_V2; - - if (hypervEnumAndPull(priv, &wqlQuery, &computerSystem) < 0) { - /* rebuild query because hypervEnumAndPull consumes it */ - virBufferAddLit(&query, - MSVM_COMPUTERSYSTEM_WQL_SELECT - "WHERE " MSVM_COMPUTERSYSTEM_WQL_PHYSICAL); - - /* fall back to V1 namespace (for Hyper-V 2008) */ - priv->wmiVersion = HYPERV_WMI_VERSION_V1; - - if (hypervEnumAndPull(priv, &wqlQuery, &computerSystem) < 0) - goto cleanup; - } - - ret = 0; - - cleanup: - hypervFreeObject(priv, computerSystem); - - return ret; + return 0; } @@ -774,19 +741,7 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name) static int hypervDomainSuspend(virDomainPtr domain) { - hypervPrivate *priv = domain->conn->privateData; - int requestedState = -1; - - switch (priv->wmiVersion) { - case HYPERV_WMI_VERSION_V1: - requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED; - break; - case HYPERV_WMI_VERSION_V2: - requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE; - break; - } - - return hypervRequestStateChange(domain, requestedState); + return hypervRequestStateChange(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE); } @@ -796,21 +751,11 @@ hypervDomainResume(virDomainPtr domain) int result = -1; hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; - int expectedState = -1; - - switch (priv->wmiVersion) { - case HYPERV_WMI_VERSION_V1: - expectedState = MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED; - break; - case HYPERV_WMI_VERSION_V2: - expectedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE; - break; - } if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) return -1; - if (computerSystem->data.common->EnabledState != expectedState) { + if (computerSystem->data.common->EnabledState != MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not paused")); goto cleanup; @@ -867,7 +812,7 @@ hypervDomainShutdownFlags(virDomainPtr domain, unsigned int flags) "SystemCreationClassName=\"Msvm_ComputerSystem\"&SystemName=\"%s\"", shutdown->data.common->DeviceID, uuid); - params = hypervCreateInvokeParamsList(priv, "InitiateShutdown", selector, + params = hypervCreateInvokeParamsList("InitiateShutdown", selector, Msvm_ShutdownComponent_WmiInfo); if (!params) goto cleanup; @@ -1096,10 +1041,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) def->name = g_strdup(computerSystem->data.common->ElementName); - if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) { - def->description = g_strdup(virtualSystemSettingData->data.v1->Notes); - } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2 && - virtualSystemSettingData->data.v2->Notes.data != NULL) { + if (virtualSystemSettingData->data.v2->Notes.data) { char **notes = (char **)virtualSystemSettingData->data.v2->Notes.data; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; size_t i = 0; @@ -1259,32 +1201,17 @@ hypervDomainGetAutostart(virDomainPtr domain, int *autostart) int result = -1; char uuid_string[VIR_UUID_STRING_BUFLEN]; hypervPrivate *priv = domain->conn->privateData; - g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER; - Msvm_VirtualSystemGlobalSettingData *vsgsd = NULL; Msvm_VirtualSystemSettingData *vssd = NULL; virUUIDFormat(domain->uuid, uuid_string); - if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) { - virBufferEscapeSQL(&query, - MSVM_VIRTUALSYSTEMGLOBALSETTINGDATA_WQL_SELECT - "WHERE SystemName = '%s'", uuid_string); - - if (hypervGetWmiClass(Msvm_VirtualSystemGlobalSettingData, &vsgsd) < 0) - goto cleanup; - - *autostart = vsgsd->data.common->AutomaticStartupAction == 2; - result = 0; - } else { - if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) - goto cleanup; + if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) + goto cleanup; - *autostart = vssd->data.v2->AutomaticStartupAction == 4; - result = 0; - } + *autostart = vssd->data.v2->AutomaticStartupAction == 4; + result = 0; cleanup: - hypervFreeObject(priv, (hypervObject *)vsgsd); hypervFreeObject(priv, (hypervObject *)vssd); return result; @@ -1299,64 +1226,32 @@ hypervDomainSetAutostart(virDomainPtr domain, int autostart) hypervPrivate *priv = domain->conn->privateData; Msvm_VirtualSystemSettingData *vssd = NULL; g_autoptr(hypervInvokeParamsList) params = NULL; - g_auto(virBuffer) eprQuery = VIR_BUFFER_INITIALIZER; g_autoptr(GHashTable) autostartParam = NULL; - const char *methodName = NULL; - hypervWmiClassInfoListPtr embeddedParamClass = NULL; - const char *enabledValue = NULL, *disabledValue = NULL; - const char *embeddedParamName = NULL; - - switch (priv->wmiVersion) { - case HYPERV_WMI_VERSION_V1: - methodName = "ModifyVirtualSystem"; - embeddedParamClass = Msvm_VirtualSystemGlobalSettingData_WmiInfo; - enabledValue = "2"; - disabledValue = "0"; - embeddedParamName = "SystemSettingData"; - break; - case HYPERV_WMI_VERSION_V2: - methodName = "ModifySystemSettings"; - embeddedParamClass = Msvm_VirtualSystemSettingData_WmiInfo; - enabledValue = "4"; - disabledValue = "2"; - embeddedParamName = "SystemSettings"; - break; - } virUUIDFormat(domain->uuid, uuid_string); if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) goto cleanup; - params = hypervCreateInvokeParamsList(priv, methodName, + params = hypervCreateInvokeParamsList("ModifySystemSettings", MSVM_VIRTUALSYSTEMMANAGEMENTSERVICE_SELECTOR, Msvm_VirtualSystemManagementService_WmiInfo); if (!params) goto cleanup; - if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) { - virBufferEscapeSQL(&eprQuery, - MSVM_COMPUTERSYSTEM_WQL_SELECT "WHERE Name = '%s'", - uuid_string); - - if (hypervAddEprParam(params, "ComputerSystem", priv, &eprQuery, - Msvm_ComputerSystem_WmiInfo) < 0) - goto cleanup; - } - - autostartParam = hypervCreateEmbeddedParam(priv, embeddedParamClass); + autostartParam = hypervCreateEmbeddedParam(Msvm_VirtualSystemSettingData_WmiInfo); if (hypervSetEmbeddedProperty(autostartParam, "AutomaticStartupAction", - autostart ? enabledValue : disabledValue) < 0) + autostart ? "4" : "2") < 0) goto cleanup; if (hypervSetEmbeddedProperty(autostartParam, "InstanceID", vssd->data.common->InstanceID) < 0) goto cleanup; - if (hypervAddEmbeddedParam(params, priv, embeddedParamName, - &autostartParam, embeddedParamClass) < 0) + if (hypervAddEmbeddedParam(params, "SystemSettings", + &autostartParam, Msvm_VirtualSystemSettingData_WmiInfo) < 0) goto cleanup; if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) @@ -1480,19 +1375,9 @@ hypervDomainManagedSave(virDomainPtr domain, unsigned int flags) hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; bool in_transition = false; - int requestedState = -1; virCheckFlags(0, -1); - switch (priv->wmiVersion) { - case HYPERV_WMI_VERSION_V1: - requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_SUSPENDED; - break; - case HYPERV_WMI_VERSION_V2: - requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_OFFLINE; - break; - } - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; @@ -1503,7 +1388,7 @@ hypervDomainManagedSave(virDomainPtr domain, unsigned int flags) goto cleanup; } - result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, requestedState); + result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_OFFLINE); cleanup: hypervFreeObject(priv, (hypervObject *)computerSystem); @@ -1749,7 +1634,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset, for (i = 0; i < nkeycodes; i++) { g_snprintf(keycodeStr, sizeof(keycodeStr), "%d", translatedKeycodes[i]); - params = hypervCreateInvokeParamsList(priv, "PressKey", selector, + params = hypervCreateInvokeParamsList("PressKey", selector, Msvm_Keyboard_WmiInfo); if (!params) @@ -1769,7 +1654,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset, /* release the keys */ for (i = 0; i < nkeycodes; i++) { g_snprintf(keycodeStr, sizeof(keycodeStr), "%d", translatedKeycodes[i]); - params = hypervCreateInvokeParamsList(priv, "ReleaseKey", selector, + params = hypervCreateInvokeParamsList("ReleaseKey", selector, Msvm_Keyboard_WmiInfo); if (!params) @@ -1805,7 +1690,6 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, unsigned long memory_mb = VIR_ROUND_UP(VIR_DIV_UP(memory, 1024), 2); Msvm_VirtualSystemSettingData *vssd = NULL; Msvm_MemorySettingData *memsd = NULL; - g_auto(virBuffer) eprQuery = VIR_BUFFER_INITIALIZER; g_autoptr(GHashTable) memResource = NULL; virCheckFlags(0, -1); @@ -1820,31 +1704,14 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, if (hypervGetMemorySD(priv, vssd->data.common->InstanceID, &memsd) < 0) goto cleanup; - if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) { - params = hypervCreateInvokeParamsList(priv, "ModifyVirtualSystemResources", - MSVM_VIRTUALSYSTEMMANAGEMENTSERVICE_SELECTOR, - Msvm_VirtualSystemManagementService_WmiInfo); - - if (!params) - goto cleanup; - - virBufferEscapeSQL(&eprQuery, - MSVM_COMPUTERSYSTEM_WQL_SELECT - "WHERE Name = '%s'", uuid_string); - - if (hypervAddEprParam(params, "ComputerSystem", priv, &eprQuery, - Msvm_ComputerSystem_WmiInfo) < 0) - goto cleanup; - } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) { - params = hypervCreateInvokeParamsList(priv, "ModifyResourceSettings", - MSVM_VIRTUALSYSTEMMANAGEMENTSERVICE_SELECTOR, - Msvm_VirtualSystemManagementService_WmiInfo); + params = hypervCreateInvokeParamsList("ModifyResourceSettings", + MSVM_VIRTUALSYSTEMMANAGEMENTSERVICE_SELECTOR, + Msvm_VirtualSystemManagementService_WmiInfo); - if (!params) - goto cleanup; - } + if (!params) + goto cleanup; - memResource = hypervCreateEmbeddedParam(priv, Msvm_MemorySettingData_WmiInfo); + memResource = hypervCreateEmbeddedParam(Msvm_MemorySettingData_WmiInfo); if (!memResource) goto cleanup; @@ -1856,18 +1723,10 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, goto cleanup; } - if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) { - if (hypervAddEmbeddedParam(params, priv, "ResourceSettingData", - &memResource, Msvm_MemorySettingData_WmiInfo) < 0) { - goto cleanup; - } - - } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) { - if (hypervAddEmbeddedParam(params, priv, "ResourceSettings", - &memResource, Msvm_MemorySettingData_WmiInfo) < 0) { - hypervFreeEmbeddedParam(memResource); - goto cleanup; - } + if (hypervAddEmbeddedParam(params, "ResourceSettings", + &memResource, Msvm_MemorySettingData_WmiInfo) < 0) { + hypervFreeEmbeddedParam(memResource); + goto cleanup; } if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) diff --git a/src/hyperv/hyperv_private.h b/src/hyperv/hyperv_private.h index b31cb616af..f400f58c3a 100644 --- a/src/hyperv/hyperv_private.h +++ b/src/hyperv/hyperv_private.h @@ -29,16 +29,9 @@ #include "hyperv_util.h" #include "capabilities.h" -typedef enum _hypervWmiVersion hypervWmiVersion; -enum _hypervWmiVersion { - HYPERV_WMI_VERSION_V1, - HYPERV_WMI_VERSION_V2, -}; - typedef struct _hypervPrivate hypervPrivate; struct _hypervPrivate { hypervParsedUri *parsedUri; WsManClient *client; - hypervWmiVersion wmiVersion; virCapsPtr caps; }; diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 509a66da74..adb68425f9 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -48,10 +48,8 @@ VIR_LOG_INIT("hyperv.hyperv_wmi"); static int -hypervGetWmiClassInfo(hypervPrivate *priv, hypervWmiClassInfoListPtr list, - hypervWmiClassInfoPtr *info) +hypervGetWmiClassInfo(hypervWmiClassInfoListPtr list, hypervWmiClassInfoPtr *info) { - const char *version = "v2"; size_t i; if (list->count == 0) { @@ -66,19 +64,15 @@ hypervGetWmiClassInfo(hypervPrivate *priv, hypervWmiClassInfoListPtr list, return 0; } - if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) - version = "v1"; - for (i = 0; i < list->count; i++) { - if (STRCASEEQ(list->objs[i]->version, version)) { + if (STRCASEEQ(list->objs[i]->version, "v2")) { *info = list->objs[i]; return 0; } } - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not match WMI class info for version %s"), - version); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not match WMI class info for version v2")); return -1; } @@ -158,7 +152,6 @@ hypervVerifyResponse(WsManClient *client, WsXmlDocH response, /* * hypervCreateInvokeParamsList: - * @priv: hypervPrivate object associated with the connection. * @method: The name of the method you are calling * @selector: The selector for the object you are invoking the method on * @obj: The WmiInfo of the object class you are invoking the method on. @@ -169,13 +162,14 @@ hypervVerifyResponse(WsManClient *client, WsXmlDocH response, * be freed by hypervInvokeMethod. Otherwise returns NULL. */ hypervInvokeParamsListPtr -hypervCreateInvokeParamsList(hypervPrivate *priv, const char *method, - const char *selector, hypervWmiClassInfoListPtr obj) +hypervCreateInvokeParamsList(const char *method, + const char *selector, + hypervWmiClassInfoListPtr obj) { hypervInvokeParamsListPtr params = NULL; hypervWmiClassInfoPtr info = NULL; - if (hypervGetWmiClassInfo(priv, obj, &info) < 0) + if (hypervGetWmiClassInfo(obj, &info) < 0) return NULL; params = g_new0(hypervInvokeParamsList, 1); @@ -285,14 +279,15 @@ hypervAddSimpleParam(hypervInvokeParamsListPtr params, const char *name, * Adds an EPR param to the params list. Returns -1 on failure, 0 on success. */ int -hypervAddEprParam(hypervInvokeParamsListPtr params, const char *name, - hypervPrivate *priv, virBufferPtr query, +hypervAddEprParam(hypervInvokeParamsListPtr params, + const char *name, + virBufferPtr query, hypervWmiClassInfoListPtr eprInfo) { hypervParamPtr p = NULL; hypervWmiClassInfoPtr classInfo = NULL; - if (hypervGetWmiClassInfo(priv, eprInfo, &classInfo) < 0 || + if (hypervGetWmiClassInfo(eprInfo, &classInfo) < 0 || hypervCheckParams(params) < 0) return -1; @@ -309,7 +304,6 @@ hypervAddEprParam(hypervInvokeParamsListPtr params, const char *name, /* * hypervCreateEmbeddedParam: - * @priv: hypervPrivate object associated with the connection * @info: WmiInfo of the object type to serialize * * Instantiates a GHashTable pre-filled with all the properties pre-added @@ -319,7 +313,7 @@ hypervAddEprParam(hypervInvokeParamsListPtr params, const char *name, * Returns a pointer to the GHashTable on success, otherwise NULL. */ GHashTable * -hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWmiClassInfoListPtr info) +hypervCreateEmbeddedParam(hypervWmiClassInfoListPtr info) { size_t i; size_t count; @@ -328,7 +322,7 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWmiClassInfoListPtr info) hypervWmiClassInfoPtr classInfo = NULL; /* Get the typeinfo out of the class info list */ - if (hypervGetWmiClassInfo(priv, info, &classInfo) < 0) + if (hypervGetWmiClassInfo(info, &classInfo) < 0) return NULL; typeinfo = classInfo->serializerInfo; @@ -377,7 +371,6 @@ hypervSetEmbeddedProperty(GHashTable *table, /* * hypervAddEmbeddedParam: * @params: Params list to add to - * @priv: hypervPrivate object associated with the connection * @name: Name of the parameter * @table: pointer to table of properties to add * @info: WmiInfo of the object to serialize @@ -391,7 +384,6 @@ hypervSetEmbeddedProperty(GHashTable *table, */ int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, - hypervPrivate *priv, const char *name, GHashTable **table, hypervWmiClassInfoListPtr info) @@ -403,7 +395,7 @@ hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, return -1; /* Get the typeinfo out of the class info list */ - if (hypervGetWmiClassInfo(priv, info, &classInfo) < 0) + if (hypervGetWmiClassInfo(info, &classInfo) < 0) return -1; p = ¶ms->params[params->nbParams]; @@ -1008,7 +1000,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery, return -1; } - if (hypervGetWmiClassInfo(priv, wqlQuery->info, &wmiInfo) < 0) + if (hypervGetWmiClassInfo(wqlQuery->info, &wmiInfo) < 0) goto cleanup; serializerContext = wsmc_get_serialization_context(priv->client); @@ -1260,16 +1252,12 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER; Msvm_ConcreteJob *concreteJob = NULL; bool completed = false; - const char *resourceUri = MSVM_COMPUTERSYSTEM_V2_RESOURCE_URI; virUUIDFormat(domain->uuid, uuid_string); selector = g_strdup_printf("Name=%s&CreationClassName=Msvm_ComputerSystem", uuid_string); properties = g_strdup_printf("RequestedState=%d", requestedState); - if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) - resourceUri = MSVM_COMPUTERSYSTEM_V1_RESOURCE_URI; - options = wsmc_options_init(); if (options == NULL) { @@ -1282,7 +1270,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, wsmc_add_prop_from_str(options, properties); /* Invoke method */ - response = wsmc_action_invoke(priv->client, resourceUri, + response = wsmc_action_invoke(priv->client, MSVM_COMPUTERSYSTEM_V2_RESOURCE_URI, options, "RequestStateChange", NULL); if (hypervVerifyResponse(priv->client, response, "invocation") < 0) diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 08b6e2c4af..2f8d5b2fce 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -131,8 +131,7 @@ typedef struct _hypervInvokeParamsList hypervInvokeParamsList; typedef hypervInvokeParamsList *hypervInvokeParamsListPtr; -hypervInvokeParamsListPtr hypervCreateInvokeParamsList(hypervPrivate *priv, - const char *method, +hypervInvokeParamsListPtr hypervCreateInvokeParamsList(const char *method, const char *selector, hypervWmiClassInfoListPtr obj); @@ -142,19 +141,18 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervInvokeParamsList, hypervFreeInvokeParams); int hypervAddSimpleParam(hypervInvokeParamsListPtr params, const char *name, const char *value); -int hypervAddEprParam(hypervInvokeParamsListPtr params, const char *name, - hypervPrivate *priv, virBufferPtr query, +int hypervAddEprParam(hypervInvokeParamsListPtr params, + const char *name, + virBufferPtr query, hypervWmiClassInfoListPtr eprInfo); -GHashTable *hypervCreateEmbeddedParam(hypervPrivate *priv, - hypervWmiClassInfoListPtr info); +GHashTable *hypervCreateEmbeddedParam(hypervWmiClassInfoListPtr info); int hypervSetEmbeddedProperty(GHashTable *table, const char *name, const char *value); int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, - hypervPrivate *priv, const char *name, GHashTable **table, hypervWmiClassInfoListPtr info); -- 2.27.0

On Mon, Nov 09, 2020 at 03:43:08AM -0500, Matt Coleman wrote:
Signed-off-by: Matt Coleman <matt@datto.com> --- src/hyperv/hyperv_driver.c | 199 ++++++------------------------------ src/hyperv/hyperv_private.h | 7 -- src/hyperv/hyperv_wmi.c | 46 +++------ src/hyperv/hyperv_wmi.h | 12 +-- 4 files changed, 51 insertions(+), 213 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

All Msvm_* classes are assumed to be V2, now. Signed-off-by: Matt Coleman <matt@datto.com> --- scripts/hyperv_wmi_generator.py | 267 +++++--------------------- src/hyperv/hyperv_driver.c | 106 +++++----- src/hyperv/hyperv_wmi.c | 49 ++--- src/hyperv/hyperv_wmi.h | 16 +- src/hyperv/hyperv_wmi_classes.h | 5 - src/hyperv/hyperv_wmi_generator.input | 20 +- 6 files changed, 125 insertions(+), 338 deletions(-) diff --git a/scripts/hyperv_wmi_generator.py b/scripts/hyperv_wmi_generator.py index ac03cf526f..03cac2992e 100755 --- a/scripts/hyperv_wmi_generator.py +++ b/scripts/hyperv_wmi_generator.py @@ -25,57 +25,22 @@ import os import os.path separator = "/*" + ("*" * 50) + "*\n" -wmi_version_separator = "/" wmi_classes_by_name = {} class WmiClass: - """Represents WMI class and provides methods to generate C code. - - This class holds one or more instances of WmiClassVersion because with the - Windows 2012 release, Microsoft introduced "v2" version of Msvm_* family of - classes that need different URI for making wsman requests and also have - some additional/changed properties (though many of the properties are the - same as in "v1". Therefore, this class makes sure that C code is generated - for each of them while avoiding name conflicts, identifies common members, - and defined *_WmiInfo structs holding info about each version so the driver - code can make the right choices based on which Hyper-V host it's connected - to. - """ - - def __init__(self, name, versions=None): - self.name = name - self.versions = versions if versions else list() - self.common = None - - def prepare(self): - """Prepares the class for code generation + """Represents WMI class and provides methods to generate C code.""" - Makes sure that "versioned" classes are sorted by version, identifies - common properties and ensures that they are aligned by name and - type in each version - """ - # sort versioned classes by version in case input file did not have them - # in order - self.versions = sorted(self.versions, key=lambda cls: cls.version or "") - - # if there's more than one version make sure first one has name suffixed - # because we'll generate "common" member and will be the "base" name - if len(self.versions) > 1: - first = self.versions[0] - if first.version is None: - first.version = "v1" - first.name = "%s_%s" % (first.name, first.version) - - # finally, identify common members in all versions and make sure they - # are in the same order - to ensure C struct member alignment - self._align_property_members() + def __init__(self, name, properties, uri_info): + self.name = name + self.properties = properties + self.uri_info = uri_info def generate_classes_header(self): """Generate C header code and return it as string Declares: - <class_name>_Data - used as one of hypervObject->data members + <class_name>_Data - used as hypervObject->data <class_name>_TypeInfo - used as wsman XmlSerializerInfo <class_name> - "inherits" hypervObject struct """ @@ -103,30 +68,28 @@ class WmiClass: """Returns a C code string defining wsman data structs Defines: - <class_name>_Data structs - <class_name>_WmiInfo - list holding metadata (e.g. request URIs) for - each known version of WMI class. + <class_name>_Data struct + <class_name>_WmiInfo - list holding metadata (e.g. request URIs) for the WMI class """ source = separator source += " * %s\n" % self.name source += " */\n" - for cls in self.versions: - source += "SER_START_ITEMS(%s_Data)\n" % cls.name + source += "SER_START_ITEMS(%s_Data)\n" % self.name - for property in cls.properties: - source += property.generate_classes_source(cls.name) + for property in self.properties: + source += property.generate_classes_source(self.name) - source += "SER_END_ITEMS(%s_Data);\n\n" % cls.name + source += "SER_END_ITEMS(%s_Data);\n\n" % self.name - # also generate typemap data while we're here - source += "hypervCimType %s_Typemap[] = {\n" % cls.name + # also generate typemap data while we're here + source += "hypervCimType %s_Typemap[] = {\n" % self.name - for property in cls.properties: - source += property.generate_typemap() - source += ' { "", "", 0 },\n' # null terminated - source += '};\n\n' + for property in self.properties: + source += property.generate_typemap() + source += ' { "", "", 0 },\n' # null terminated + source += '};\n\n' source += self._define_WmiInfo_struct() source += "\n\n" @@ -134,45 +97,29 @@ class WmiClass: return source def generate_classes_typedef(self): - """Returns C string for typdefs""" + """Returns C string for typedefs""" typedef = "typedef struct _%s %s;\n" % (self.name, self.name) - - if self.common is not None: - typedef += "typedef struct _%s_Data %s_Data;\n" % (self.name, self.name) - - for cls in self.versions: - typedef += "typedef struct _%s_Data %s_Data;\n" % (cls.name, cls.name) + typedef += "typedef struct _%s_Data %s_Data;\n" % (self.name, self.name) return typedef def _declare_data_structs(self): """Returns string C code declaring data structs. - The *_Data structs are members of hypervObject data union. Each one has + The *_Data structs are used as hypervObject->data. Each one has corresponding *_TypeInfo that is used for wsman unserialization of - response XML into the *_Data structs. If there's a "common" member, it - won't have corresponding *_TypeInfo because this is a special case only - used to provide a common "view" of v1, v2 etc members + response XML into the *_Data structs. """ - header = "" - if self.common is not None: - header += "struct _%s_Data {\n" % self.name - for property in self.common: - header += property.generate_classes_header() - header += "};\n\n" - - # Declare actual data struct for each versions - for cls in self.versions: - header += "#define %s_RESOURCE_URI \\\n" % cls.name.upper() - header += " \"%s\"\n" % cls.uri_info.resourceUri - header += "\n" - header += "struct _%s_Data {\n" % cls.name - for property in cls.properties: - header += property.generate_classes_header() - header += "};\n\n" - header += "SER_DECLARE_TYPE(%s_Data);\n" % cls.name + header = "#define %s_RESOURCE_URI \\\n" % self.name.upper() + header += " \"%s\"\n" % self.uri_info.resourceUri + header += "\n" + header += "struct _%s_Data {\n" % self.name + for property in self.properties: + header += property.generate_classes_header() + header += "};\n\n" + header += "SER_DECLARE_TYPE(%s_Data);\n" % self.name return header @@ -181,19 +128,7 @@ class WmiClass: header = "\n/* must match hypervObject */\n" header += "struct _%s {\n" % self.name - header += " union {\n" - - # if there's common use it as "common" else first and only version is - # the "common" member - if self.common is not None: - header += " %s_Data *common;\n" % self.name - else: - header += " %s_Data *common;\n" % self.versions[0].name - - for cls in self.versions: - header += " %s_Data *%s;\n" % (cls.name, cls.version) - - header += " } data;\n" + header += " %s_Data *data;\n" % self.name header += " hypervWmiClassInfoPtr info;\n" header += " %s *next;\n" % self.name header += "};\n" @@ -205,127 +140,41 @@ class WmiClass: def _define_WmiInfo_struct(self): """Return string for C code defining *_WmiInfo struct - Those structs hold info with meta-data needed to make wsman requests for - each version of WMI class + This struct holds info with meta-data needed to make wsman requests for the WMI class. """ source = "hypervWmiClassInfoListPtr %s_WmiInfo = &(hypervWmiClassInfoList) {\n" % self.name - source += " .count = %d,\n" % len(self.versions) + source += " .count = 1,\n" source += " .objs = (hypervWmiClassInfoPtr []) {\n" - for cls in self.versions: - source += " &(hypervWmiClassInfo) {\n" - source += " .name = %s_CLASSNAME,\n" % self.name.upper() - if cls.version is not None: - source += " .version = \"%s\",\n" % cls.version - else: - source += " .version = NULL,\n" - source += " .rootUri = %s,\n" % cls.uri_info.rootUri - source += " .resourceUri = %s_RESOURCE_URI,\n" % cls.name.upper() - source += " .serializerInfo = %s_Data_TypeInfo,\n" % cls.name - source += " .propertyInfo = %s_Typemap\n" % cls.name - source += " },\n" + source += " &(hypervWmiClassInfo) {\n" + source += " .name = %s_CLASSNAME,\n" % self.name.upper() + source += " .rootUri = %s,\n" % self.uri_info.rootUri + source += " .resourceUri = %s_RESOURCE_URI,\n" % self.name.upper() + source += " .serializerInfo = %s_Data_TypeInfo,\n" % self.name + source += " .propertyInfo = %s_Typemap\n" % self.name + source += " },\n" source += " }\n" source += "};\n" return source - def _align_property_members(self): - """Identifies common properties in all class versions. - - Makes sure that properties in all versions are ordered with common - members first and that they are in the same order. This makes the - generated C structs memory aligned and safe to access via the "common" - struct that "shares" members with v1, v2 etc. - """ - - num_classes = len(self.versions) - common = {} - property_info = {} - - if num_classes < 2: - return - - # count property occurrences in all class versions - for cls in self.versions: - for prop in cls.properties: - # consdered same if matches by name AND type - key = "%s_%s_%s" % (prop.name, prop.type, prop.is_array) - - if key in property_info: - property_info[key][1] += 1 - else: - property_info[key] = [prop, 1] - - # isolate those that are common for all and keep track of their positions - pos = 0 - for key in sorted(property_info): - info = property_info[key] - # exists in all class versions - if info[1] == num_classes: - common[info[0].name] = [info[0], pos] - pos += 1 - - # alter each version's property list so that common members are first - # and in the same order as in the common dictionary - for cls in self.versions: - index = 0 - count = len(cls.properties) - - while index < count: - prop = cls.properties[index] - - # it's a "common" property - if prop.name in common: - pos = common[prop.name][1] - - # move to the same position as in "common" dictionary - if index != pos: - tmp = cls.properties[pos] - cls.properties[pos] = prop - cls.properties[index] = tmp - else: - index += 1 - else: - index += 1 - - # finally, get common properties as list sorted by position in dictionary - tmp = sorted(common.values(), key=lambda x: x[1]) - self.common = [] - for x in tmp: - self.common.append(x[0]) - class ClassUriInfo: """Prepares URI information needed for wsman requests.""" - def __init__(self, wmi_name, version): - self.rootUri = "ROOT_CIMV2" - self.resourceUri = None - baseUri = "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2" - + def __init__(self, wmi_name): if wmi_name.startswith("Msvm_"): - baseUri = "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/virtualization" - self.rootUri = "ROOT_VIRTUALIZATION" - - if version == "v2": - baseUri += "/v2" - self.rootUri = "ROOT_VIRTUALIZATION_V2" + self.rootUri = "ROOT_VIRTUALIZATION_V2" + baseUri = "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/virtualization/v2" + else: + self.rootUri = "ROOT_CIMV2" + baseUri = "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2" self.resourceUri = "%s/%s" % (baseUri, wmi_name) -class WmiClassVersion: - """Represents specific version of WMI class.""" - - def __init__(self, name, version, properties, uri_info): - self.name = name - self.version = version - self.properties = properties - self.uri_info = uri_info - - class Property: typemap = { "boolean": "BOOL", @@ -391,15 +240,11 @@ def parse_class(block, number): assert header_items[0] == "class" name = header_items[1] - properties = [] - version = None - wmi_name = name - ns_separator = name.find(wmi_version_separator) - if ns_separator != -1: - version = name[:ns_separator] - wmi_name = name[ns_separator + 1:] - name = "%s_%s" % (wmi_name, version) + if name in wmi_classes_by_name: + report_error("class '%s' has already been defined" % name) + + properties = [] for line in block[1:]: # expected format: <type> <name> @@ -414,16 +259,9 @@ def parse_class(block, number): else: is_array = False - properties.append(Property(type=items[0], name=items[1], - is_array=is_array)) - - cls = WmiClassVersion(name=name, version=version, properties=properties, - uri_info=ClassUriInfo(wmi_name, version)) + properties.append(Property(type=items[0], name=items[1], is_array=is_array)) - if wmi_name in wmi_classes_by_name: - wmi_classes_by_name[wmi_name].versions.append(cls) - else: - wmi_classes_by_name[wmi_name] = WmiClass(wmi_name, [cls]) + wmi_classes_by_name[name] = WmiClass(name, properties, ClassUriInfo(name)) def main(): @@ -478,7 +316,6 @@ def main(): for name in names: cls = wmi_classes_by_name[name] - cls.prepare() classes_typedef.write(cls.generate_classes_typedef()) classes_header.write(cls.generate_classes_header()) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 11f177ae30..b789ef58e8 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -192,7 +192,7 @@ hypervRequestStateChange(virDomainPtr domain, int state) if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - if (computerSystem->data.common->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) { + if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active")); goto cleanup; } @@ -239,10 +239,10 @@ hypervLookupHostSystemBiosUuid(hypervPrivate *priv, unsigned char *uuid) if (hypervGetWmiClass(Win32_ComputerSystemProduct, &computerSystem) < 0) goto cleanup; - if (virUUIDParse(computerSystem->data.common->UUID, uuid) < 0) { + if (virUUIDParse(computerSystem->data->UUID, uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse UUID from string '%s'"), - computerSystem->data.common->UUID); + computerSystem->data->UUID); goto cleanup; } result = 0; @@ -443,11 +443,10 @@ hypervConnectGetVersion(virConnectPtr conn, unsigned long *version) goto cleanup; } - if (hypervParseVersionString(os->data.common->Version, - &major, &minor, µ) < 0) { + if (hypervParseVersionString(os->data->Version, &major, &minor, µ) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse version from '%s'"), - os->data.common->Version); + os->data->Version); goto cleanup; } @@ -471,7 +470,7 @@ hypervConnectGetVersion(virConnectPtr conn, unsigned long *version) if (major > 99 || minor > 99 || micro > 999999) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not produce packed version number from '%s'"), - os->data.common->Version); + os->data->Version); goto cleanup; } @@ -496,7 +495,7 @@ hypervConnectGetHostname(virConnectPtr conn) if (hypervGetPhysicalSystemList(priv, &computerSystem) < 0) goto cleanup; - hostname = g_strdup(computerSystem->data.common->DNSHostName); + hostname = g_strdup(computerSystem->data->DNSHostName); cleanup: hypervFreeObject(priv, (hypervObject *)computerSystem); @@ -537,7 +536,7 @@ hypervConnectGetMaxVcpus(virConnectPtr conn, const char *type G_GNUC_UNUSED) goto cleanup; } - result = processorSettingData->data.common->VirtualQuantity; + result = processorSettingData->data->VirtualQuantity; cleanup: hypervFreeObject(priv, (hypervObject *)processorSettingData); @@ -561,13 +560,12 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) if (hypervGetPhysicalSystemList(priv, &computerSystem) < 0) goto cleanup; - if (hypervGetProcessorsByName(priv, computerSystem->data.common->Name, - &processorList) < 0) { + if (hypervGetProcessorsByName(priv, computerSystem->data->Name, &processorList) < 0) { goto cleanup; } /* Strip the string to fit more relevant information in 32 chars */ - tmp = processorList->data.common->Name; + tmp = processorList->data->Name; while (*tmp != '\0') { if (STRPREFIX(tmp, " ")) { @@ -589,15 +587,15 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) } /* Fill struct */ - if (virStrcpyStatic(info->model, processorList->data.common->Name) < 0) { + if (virStrcpyStatic(info->model, processorList->data->Name) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("CPU model %s too long for destination"), - processorList->data.common->Name); + processorList->data->Name); goto cleanup; } - info->memory = computerSystem->data.common->TotalPhysicalMemory / 1024; /* byte to kilobyte */ - info->mhz = processorList->data.common->MaxClockSpeed; + info->memory = computerSystem->data->TotalPhysicalMemory / 1024; /* byte to kilobyte */ + info->mhz = processorList->data->MaxClockSpeed; info->nodes = 1; info->sockets = 0; @@ -606,8 +604,8 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) ++info->sockets; } - info->cores = processorList->data.common->NumberOfCores; - info->threads = processorList->data.common->NumberOfLogicalProcessors / info->cores; + info->cores = processorList->data->NumberOfCores; + info->threads = processorList->data->NumberOfLogicalProcessors / info->cores; info->cpus = info->sockets * info->cores; result = 0; @@ -637,7 +635,7 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, int maxids) for (computerSystem = computerSystemList; computerSystem != NULL; computerSystem = computerSystem->next) { - ids[count++] = computerSystem->data.common->ProcessID; + ids[count++] = computerSystem->data->ProcessID; if (count >= maxids) break; @@ -755,7 +753,7 @@ hypervDomainResume(virDomainPtr domain) if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) return -1; - if (computerSystem->data.common->EnabledState != MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE) { + if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not paused")); goto cleanup; @@ -810,7 +808,7 @@ hypervDomainShutdownFlags(virDomainPtr domain, unsigned int flags) selector = g_strdup_printf("CreationClassName=\"Msvm_ShutdownComponent\"&DeviceID=\"%s\"&" "SystemCreationClassName=\"Msvm_ComputerSystem\"&SystemName=\"%s\"", - shutdown->data.common->DeviceID, uuid); + shutdown->data->DeviceID, uuid); params = hypervCreateInvokeParamsList("InitiateShutdown", selector, Msvm_ShutdownComponent_WmiInfo); @@ -931,20 +929,20 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) goto cleanup; if (hypervGetProcessorSD(priv, - virtualSystemSettingData->data.common->InstanceID, + virtualSystemSettingData->data->InstanceID, &processorSettingData) < 0) goto cleanup; if (hypervGetMemorySD(priv, - virtualSystemSettingData->data.common->InstanceID, + virtualSystemSettingData->data->InstanceID, &memorySettingData) < 0) goto cleanup; /* Fill struct */ info->state = hypervMsvmComputerSystemEnabledStateToDomainState(computerSystem); - info->maxMem = memorySettingData->data.common->Limit * 1024; /* megabyte to kilobyte */ - info->memory = memorySettingData->data.common->VirtualQuantity * 1024; /* megabyte to kilobyte */ - info->nrVirtCpu = processorSettingData->data.common->VirtualQuantity; + info->maxMem = memorySettingData->data->Limit * 1024; /* megabyte to kilobyte */ + info->memory = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */ + info->nrVirtCpu = processorSettingData->data->VirtualQuantity; info->cpuTime = 0; result = 0; @@ -1014,12 +1012,12 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) goto cleanup; if (hypervGetProcessorSD(priv, - virtualSystemSettingData->data.common->InstanceID, + virtualSystemSettingData->data->InstanceID, &processorSettingData) < 0) goto cleanup; if (hypervGetMemorySD(priv, - virtualSystemSettingData->data.common->InstanceID, + virtualSystemSettingData->data->InstanceID, &memorySettingData) < 0) goto cleanup; @@ -1027,27 +1025,27 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) def->virtType = VIR_DOMAIN_VIRT_HYPERV; if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) { - def->id = computerSystem->data.common->ProcessID; + def->id = computerSystem->data->ProcessID; } else { def->id = -1; } - if (virUUIDParse(computerSystem->data.common->Name, def->uuid) < 0) { + if (virUUIDParse(computerSystem->data->Name, def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse UUID from string '%s'"), - computerSystem->data.common->Name); + computerSystem->data->Name); return NULL; } - def->name = g_strdup(computerSystem->data.common->ElementName); + def->name = g_strdup(computerSystem->data->ElementName); - if (virtualSystemSettingData->data.v2->Notes.data) { - char **notes = (char **)virtualSystemSettingData->data.v2->Notes.data; + if (virtualSystemSettingData->data->Notes.data) { + char **notes = (char **)virtualSystemSettingData->data->Notes.data; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; size_t i = 0; /* in practice Notes has 1 element */ - for (i = 0; i < virtualSystemSettingData->data.v2->Notes.count; i++) { + for (i = 0; i < virtualSystemSettingData->data->Notes.count; i++) { /* but if there's more than 1, separate by double new line */ if (virBufferUse(&buf) > 0) virBufferAddLit(&buf, "\n\n"); @@ -1060,17 +1058,14 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) } /* mebibytes to kibibytes */ - def->mem.max_memory = memorySettingData->data.common->Limit * 1024; - def->mem.cur_balloon = memorySettingData->data.common->VirtualQuantity * 1024; - virDomainDefSetMemoryTotal(def, memorySettingData->data.common->VirtualQuantity * 1024); + def->mem.max_memory = memorySettingData->data->Limit * 1024; + def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; + virDomainDefSetMemoryTotal(def, memorySettingData->data->VirtualQuantity * 1024); - if (virDomainDefSetVcpusMax(def, - processorSettingData->data.common->VirtualQuantity, - NULL) < 0) + if (virDomainDefSetVcpusMax(def, processorSettingData->data->VirtualQuantity, NULL) < 0) goto cleanup; - if (virDomainDefSetVcpus(def, - processorSettingData->data.common->VirtualQuantity) < 0) + if (virDomainDefSetVcpus(def, processorSettingData->data->VirtualQuantity) < 0) goto cleanup; def->os.type = VIR_DOMAIN_OSTYPE_HVM; @@ -1110,7 +1105,7 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn for (computerSystem = computerSystemList; computerSystem != NULL; computerSystem = computerSystem->next) { - names[count] = g_strdup(computerSystem->data.common->ElementName); + names[count] = g_strdup(computerSystem->data->ElementName); ++count; @@ -1208,7 +1203,7 @@ hypervDomainGetAutostart(virDomainPtr domain, int *autostart) if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) goto cleanup; - *autostart = vssd->data.v2->AutomaticStartupAction == 4; + *autostart = vssd->data->AutomaticStartupAction == 4; result = 0; cleanup: @@ -1246,8 +1241,7 @@ hypervDomainSetAutostart(virDomainPtr domain, int autostart) autostart ? "4" : "2") < 0) goto cleanup; - if (hypervSetEmbeddedProperty(autostartParam, "InstanceID", - vssd->data.common->InstanceID) < 0) + if (hypervSetEmbeddedProperty(autostartParam, "InstanceID", vssd->data->InstanceID) < 0) goto cleanup; if (hypervAddEmbeddedParam(params, "SystemSettings", @@ -1284,7 +1278,7 @@ hypervNodeGetFreeMemory(virConnectPtr conn) return 0; } - freeMemoryBytes = operatingSystem->data.common->FreePhysicalMemory * 1024; + freeMemoryBytes = operatingSystem->data->FreePhysicalMemory * 1024; hypervFreeObject(priv, (hypervObject *)operatingSystem); @@ -1409,8 +1403,7 @@ hypervDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags) if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - result = computerSystem->data.common->EnabledState == - MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED ? 1 : 0; + result = computerSystem->data->EnabledState == MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED ? 1 : 0; cleanup: hypervFreeObject(priv, (hypervObject *)computerSystem); @@ -1431,8 +1424,7 @@ hypervDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags) if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - if (computerSystem->data.common->EnabledState != - MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) { + if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain has no managed save image")); goto cleanup; @@ -1530,7 +1522,7 @@ hypervConnectListAllDomains(virConnectPtr conn, /* managed save filter */ if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE)) { - bool mansave = computerSystem->data.common->EnabledState == + bool mansave = computerSystem->data->EnabledState == MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED; if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) && mansave) || @@ -1628,7 +1620,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset, selector = g_strdup_printf("CreationClassName=Msvm_Keyboard&DeviceID=%s&" "SystemCreationClassName=Msvm_ComputerSystem&" - "SystemName=%s", keyboard->data.common->DeviceID, uuid_string); + "SystemName=%s", keyboard->data->DeviceID, uuid_string); /* press the keys */ for (i = 0; i < nkeycodes; i++) { @@ -1701,7 +1693,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) goto cleanup; - if (hypervGetMemorySD(priv, vssd->data.common->InstanceID, &memsd) < 0) + if (hypervGetMemorySD(priv, vssd->data->InstanceID, &memsd) < 0) goto cleanup; params = hypervCreateInvokeParamsList("ModifyResourceSettings", @@ -1718,10 +1710,8 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, if (hypervSetEmbeddedProperty(memResource, "VirtualQuantity", memory_str) < 0) goto cleanup; - if (hypervSetEmbeddedProperty(memResource, "InstanceID", - memsd->data.common->InstanceID) < 0) { + if (hypervSetEmbeddedProperty(memResource, "InstanceID", memsd->data->InstanceID) < 0) goto cleanup; - } if (hypervAddEmbeddedParam(params, "ResourceSettings", &memResource, Msvm_MemorySettingData_WmiInfo) < 0) { diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index adb68425f9..2a3d6abc0b 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -50,31 +50,8 @@ VIR_LOG_INIT("hyperv.hyperv_wmi"); static int hypervGetWmiClassInfo(hypervWmiClassInfoListPtr list, hypervWmiClassInfoPtr *info) { - size_t i; - - if (list->count == 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("The WMI class info list is empty")); - return -1; - } - - /* if there's just one WMI class and isn't versioned, assume "shared" */ - if (list->count == 1 && list->objs[0]->version == NULL) { - *info = list->objs[0]; - return 0; - } - - for (i = 0; i < list->count; i++) { - if (STRCASEEQ(list->objs[i]->version, "v2")) { - *info = list->objs[i]; - return 0; - } - } - - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not match WMI class info for version v2")); - - return -1; + *info = list->objs[0]; + return 0; } @@ -911,7 +888,7 @@ hypervInvokeMethod(hypervPrivate *priv, if (hypervGetWmiClass(Msvm_ConcreteJob, &job) < 0 || !job) goto cleanup; - jobState = job->data.common->JobState; + jobState = job->data->JobState; switch (jobState) { case MSVM_CONCRETEJOB_JOBSTATE_NEW: case MSVM_CONCRETEJOB_JOBSTATE_STARTING: @@ -1078,7 +1055,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery, object = g_new0(hypervObject, 1); object->info = wmiInfo; - object->data.common = data; + object->data = data; data = NULL; @@ -1139,7 +1116,7 @@ hypervFreeObject(hypervPrivate *priv G_GNUC_UNUSED, hypervObject *object) while (object != NULL) { next = object->next; - if (ws_serializer_free_mem(serializerContext, object->data.common, + if (ws_serializer_free_mem(serializerContext, object->data, object->info->serializerInfo) < 0) { VIR_ERROR(_("Could not free deserialized data")); } @@ -1270,7 +1247,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, wsmc_add_prop_from_str(options, properties); /* Invoke method */ - response = wsmc_action_invoke(priv->client, MSVM_COMPUTERSYSTEM_V2_RESOURCE_URI, + response = wsmc_action_invoke(priv->client, MSVM_COMPUTERSYSTEM_RESOURCE_URI, options, "RequestStateChange", NULL); if (hypervVerifyResponse(priv->client, response, "invocation") < 0) @@ -1320,7 +1297,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, goto cleanup; } - switch (concreteJob->data.common->JobState) { + switch (concreteJob->data->JobState) { case MSVM_CONCRETEJOB_JOBSTATE_NEW: case MSVM_CONCRETEJOB_JOBSTATE_STARTING: case MSVM_CONCRETEJOB_JOBSTATE_RUNNING: @@ -1380,7 +1357,7 @@ int hypervMsvmComputerSystemEnabledStateToDomainState (Msvm_ComputerSystem *computerSystem) { - switch (computerSystem->data.common->EnabledState) { + switch (computerSystem->data->EnabledState) { case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_UNKNOWN: return VIR_DOMAIN_NOSTATE; @@ -1421,7 +1398,7 @@ hypervIsMsvmComputerSystemActive(Msvm_ComputerSystem *computerSystem, if (in_transition != NULL) *in_transition = false; - switch (computerSystem->data.common->EnabledState) { + switch (computerSystem->data->EnabledState) { case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_UNKNOWN: return false; @@ -1467,17 +1444,17 @@ hypervMsvmComputerSystemToDomain(virConnectPtr conn, return -1; } - if (virUUIDParse(computerSystem->data.common->Name, uuid) < 0) { + if (virUUIDParse(computerSystem->data->Name, uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse UUID from string '%s'"), - computerSystem->data.common->Name); + computerSystem->data->Name); return -1; } if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) - id = computerSystem->data.common->ProcessID; + id = computerSystem->data->ProcessID; - *domain = virGetDomain(conn, computerSystem->data.common->ElementName, uuid, id); + *domain = virGetDomain(conn, computerSystem->data->ElementName, uuid, id); return *domain ? 0 : -1; } diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 2f8d5b2fce..a9fe5318e6 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -47,20 +47,8 @@ int hypervVerifyResponse(WsManClient *client, WsXmlDocH response, typedef struct _hypervObject hypervObject; struct _hypervObject { - /* Unserialized data from wsman response. The member called "common" has - * properties that are the same type and name for all "versions" of given - * WMI class. This means that calling code does not have to make any - * conditional checks based on which version was returned as long as it - * only needs to read common values. The alignment of structs is ensured - * by the generator. - */ - union { - XML_TYPE_PTR common; - XML_TYPE_PTR v1; - XML_TYPE_PTR v2; - } data; - /* The info used to make wsman request */ - hypervWmiClassInfoPtr info; + XML_TYPE_PTR data; /* Unserialized data from wsman response */ + hypervWmiClassInfoPtr info; /* The info used to make wsman request */ hypervObject *next; }; diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h index b9d8dfcf38..a00751013d 100644 --- a/src/hyperv/hyperv_wmi_classes.h +++ b/src/hyperv/hyperv_wmi_classes.h @@ -32,9 +32,6 @@ #define ROOT_CIMV2 \ "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*" -#define ROOT_VIRTUALIZATION \ - "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/virtualization/*" - #define ROOT_VIRTUALIZATION_V2 \ "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/virtualization/v2/*" @@ -121,8 +118,6 @@ typedef hypervWmiClassInfo *hypervWmiClassInfoPtr; struct _hypervWmiClassInfo { /* The WMI class name */ const char *name; - /* The version of the WMI class as in "v1" or "v2" */ - const char *version; /* The URI for wsman enumerate request */ const char *rootUri; /* The namespace URI for XML serialization */ diff --git a/src/hyperv/hyperv_wmi_generator.input b/src/hyperv/hyperv_wmi_generator.input index e6b53bc021..74c9495372 100644 --- a/src/hyperv/hyperv_wmi_generator.input +++ b/src/hyperv/hyperv_wmi_generator.input @@ -23,7 +23,7 @@ # -class v2/Msvm_ComputerSystem +class Msvm_ComputerSystem string InstanceID string Caption string Description @@ -72,7 +72,7 @@ class v2/Msvm_ComputerSystem end -class v2/Msvm_ConcreteJob +class Msvm_ConcreteJob string InstanceID string Caption string Description @@ -117,7 +117,7 @@ class v2/Msvm_ConcreteJob end -class v2/Msvm_MemorySettingData +class Msvm_MemorySettingData string InstanceID string Caption string Description @@ -149,7 +149,7 @@ class v2/Msvm_MemorySettingData end -class v2/Msvm_ProcessorSettingData +class Msvm_ProcessorSettingData string InstanceID string Caption string Description @@ -180,7 +180,7 @@ class v2/Msvm_ProcessorSettingData end -class v2/Msvm_VirtualSystemSettingData +class Msvm_VirtualSystemSettingData string InstanceID string Caption string Description @@ -569,7 +569,7 @@ class Win32_OperatingSystem end -class v2/Msvm_VirtualSystemManagementService +class Msvm_VirtualSystemManagementService string InstanceID string Caption string Description @@ -601,7 +601,7 @@ class v2/Msvm_VirtualSystemManagementService end -class v2/Msvm_ResourceAllocationSettingData +class Msvm_ResourceAllocationSettingData string InstanceID string Caption string Description @@ -629,7 +629,7 @@ class v2/Msvm_ResourceAllocationSettingData end -class v2/Msvm_SyntheticEthernetPortSettingData +class Msvm_SyntheticEthernetPortSettingData string InstanceID string Caption string Description @@ -663,7 +663,7 @@ class v2/Msvm_SyntheticEthernetPortSettingData end -class v2/Msvm_Keyboard +class Msvm_Keyboard string InstanceID string Caption string Description @@ -710,7 +710,7 @@ class v2/Msvm_Keyboard end -class v2/Msvm_ShutdownComponent +class Msvm_ShutdownComponent string InstanceID string Caption string Description -- 2.27.0

On Mon, Nov 09, 2020 at 03:43:09AM -0500, Matt Coleman wrote:
All Msvm_* classes are assumed to be V2, now.
Signed-off-by: Matt Coleman <matt@datto.com> --- scripts/hyperv_wmi_generator.py | 267 +++++--------------------- src/hyperv/hyperv_driver.c | 106 +++++----- src/hyperv/hyperv_wmi.c | 49 ++--- src/hyperv/hyperv_wmi.h | 16 +- src/hyperv/hyperv_wmi_classes.h | 5 - src/hyperv/hyperv_wmi_generator.input | 20 +- 6 files changed, 125 insertions(+), 338 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Matt Coleman <matt@datto.com> --- scripts/hyperv_wmi_generator.py | 21 ++++++----------- src/hyperv/hyperv_wmi.c | 41 ++++++--------------------------- src/hyperv/hyperv_wmi.h | 13 ++++++----- src/hyperv/hyperv_wmi_classes.h | 8 ------- 4 files changed, 21 insertions(+), 62 deletions(-) diff --git a/scripts/hyperv_wmi_generator.py b/scripts/hyperv_wmi_generator.py index 03cac2992e..a6f5c6aeab 100755 --- a/scripts/hyperv_wmi_generator.py +++ b/scripts/hyperv_wmi_generator.py @@ -57,7 +57,7 @@ class WmiClass: header += "#define %s_WQL_SELECT \\\n" % name_upper header += " \"SELECT * FROM %s \"\n" % self.name header += "\n" - header += "extern hypervWmiClassInfoListPtr %s_WmiInfo;\n\n" % self.name + header += "extern hypervWmiClassInfoPtr %s_WmiInfo;\n\n" % self.name header += self._declare_data_structs() header += self._declare_hypervObject_struct() @@ -143,19 +143,12 @@ class WmiClass: This struct holds info with meta-data needed to make wsman requests for the WMI class. """ - source = "hypervWmiClassInfoListPtr %s_WmiInfo = &(hypervWmiClassInfoList) {\n" % self.name - source += " .count = 1,\n" - source += " .objs = (hypervWmiClassInfoPtr []) {\n" - - source += " &(hypervWmiClassInfo) {\n" - source += " .name = %s_CLASSNAME,\n" % self.name.upper() - source += " .rootUri = %s,\n" % self.uri_info.rootUri - source += " .resourceUri = %s_RESOURCE_URI,\n" % self.name.upper() - source += " .serializerInfo = %s_Data_TypeInfo,\n" % self.name - source += " .propertyInfo = %s_Typemap\n" % self.name - source += " },\n" - - source += " }\n" + source = "hypervWmiClassInfoPtr %s_WmiInfo = &(hypervWmiClassInfo) {\n" % self.name + source += " .name = %s_CLASSNAME,\n" % self.name.upper() + source += " .rootUri = %s,\n" % self.uri_info.rootUri + source += " .resourceUri = %s_RESOURCE_URI,\n" % self.name.upper() + source += " .serializerInfo = %s_Data_TypeInfo,\n" % self.name + source += " .propertyInfo = %s_Typemap\n" % self.name source += "};\n" return source diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 2a3d6abc0b..72a68c0591 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -47,16 +47,8 @@ VIR_LOG_INIT("hyperv.hyperv_wmi"); -static int -hypervGetWmiClassInfo(hypervWmiClassInfoListPtr list, hypervWmiClassInfoPtr *info) -{ - *info = list->objs[0]; - return 0; -} - - int -hypervGetWmiClassList(hypervPrivate *priv, hypervWmiClassInfoListPtr wmiInfo, +hypervGetWmiClassList(hypervPrivate *priv, hypervWmiClassInfoPtr wmiInfo, virBufferPtr query, hypervObject **wmiClass) { hypervWqlQuery wqlQuery = HYPERV_WQL_QUERY_INITIALIZER; @@ -141,13 +133,9 @@ hypervVerifyResponse(WsManClient *client, WsXmlDocH response, hypervInvokeParamsListPtr hypervCreateInvokeParamsList(const char *method, const char *selector, - hypervWmiClassInfoListPtr obj) + hypervWmiClassInfoPtr info) { hypervInvokeParamsListPtr params = NULL; - hypervWmiClassInfoPtr info = NULL; - - if (hypervGetWmiClassInfo(obj, &info) < 0) - return NULL; params = g_new0(hypervInvokeParamsList, 1); @@ -259,13 +247,11 @@ int hypervAddEprParam(hypervInvokeParamsListPtr params, const char *name, virBufferPtr query, - hypervWmiClassInfoListPtr eprInfo) + hypervWmiClassInfoPtr classInfo) { hypervParamPtr p = NULL; - hypervWmiClassInfoPtr classInfo = NULL; - if (hypervGetWmiClassInfo(eprInfo, &classInfo) < 0 || - hypervCheckParams(params) < 0) + if (hypervCheckParams(params) < 0) return -1; p = ¶ms->params[params->nbParams]; @@ -290,17 +276,12 @@ hypervAddEprParam(hypervInvokeParamsListPtr params, * Returns a pointer to the GHashTable on success, otherwise NULL. */ GHashTable * -hypervCreateEmbeddedParam(hypervWmiClassInfoListPtr info) +hypervCreateEmbeddedParam(hypervWmiClassInfoPtr classInfo) { size_t i; size_t count; g_autoptr(GHashTable) table = NULL; XmlSerializerInfo *typeinfo = NULL; - hypervWmiClassInfoPtr classInfo = NULL; - - /* Get the typeinfo out of the class info list */ - if (hypervGetWmiClassInfo(info, &classInfo) < 0) - return NULL; typeinfo = classInfo->serializerInfo; @@ -363,18 +344,13 @@ int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, const char *name, GHashTable **table, - hypervWmiClassInfoListPtr info) + hypervWmiClassInfoPtr classInfo) { hypervParamPtr p = NULL; - hypervWmiClassInfoPtr classInfo = NULL; if (hypervCheckParams(params) < 0) return -1; - /* Get the typeinfo out of the class info list */ - if (hypervGetWmiClassInfo(info, &classInfo) < 0) - return -1; - p = ¶ms->params[params->nbParams]; p->type = HYPERV_EMBEDDED_PARAM; p->embedded.name = name; @@ -959,7 +935,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery, WsSerializerContextH serializerContext; client_opt_t *options = NULL; char *query_string = NULL; - hypervWmiClassInfoPtr wmiInfo = NULL; + hypervWmiClassInfoPtr wmiInfo = wqlQuery->info; filter_t *filter = NULL; WsXmlDocH response = NULL; char *enumContext = NULL; @@ -977,9 +953,6 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery, return -1; } - if (hypervGetWmiClassInfo(wqlQuery->info, &wmiInfo) < 0) - goto cleanup; - serializerContext = wsmc_get_serialization_context(priv->client); options = wsmc_options_init(); diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index a9fe5318e6..eb273ba7cf 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -56,7 +56,7 @@ typedef struct _hypervWqlQuery hypervWqlQuery; typedef hypervWqlQuery *hypervWqlQueryPtr; struct _hypervWqlQuery { virBufferPtr query; - hypervWmiClassInfoListPtr info; + hypervWmiClassInfoPtr info; }; int hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery, @@ -121,7 +121,7 @@ typedef hypervInvokeParamsList *hypervInvokeParamsListPtr; hypervInvokeParamsListPtr hypervCreateInvokeParamsList(const char *method, const char *selector, - hypervWmiClassInfoListPtr obj); + hypervWmiClassInfoPtr obj); void hypervFreeInvokeParams(hypervInvokeParamsListPtr params); G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervInvokeParamsList, hypervFreeInvokeParams); @@ -132,9 +132,9 @@ int hypervAddSimpleParam(hypervInvokeParamsListPtr params, const char *name, int hypervAddEprParam(hypervInvokeParamsListPtr params, const char *name, virBufferPtr query, - hypervWmiClassInfoListPtr eprInfo); + hypervWmiClassInfoPtr eprInfo); -GHashTable *hypervCreateEmbeddedParam(hypervWmiClassInfoListPtr info); +GHashTable *hypervCreateEmbeddedParam(hypervWmiClassInfoPtr info); int hypervSetEmbeddedProperty(GHashTable *table, const char *name, @@ -143,7 +143,7 @@ int hypervSetEmbeddedProperty(GHashTable *table, int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, const char *name, GHashTable **table, - hypervWmiClassInfoListPtr info); + hypervWmiClassInfoPtr info); void hypervFreeEmbeddedParam(GHashTable *p); @@ -188,7 +188,8 @@ const char *hypervReturnCodeToString(int returnCode); int hypervGetWmiClassList(hypervPrivate *priv, - hypervWmiClassInfoListPtr wmiInfo, virBufferPtr query, + hypervWmiClassInfoPtr wmiInfo, + virBufferPtr query, hypervObject **wmiClass); /** diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h index a00751013d..161e9be131 100644 --- a/src/hyperv/hyperv_wmi_classes.h +++ b/src/hyperv/hyperv_wmi_classes.h @@ -128,12 +128,4 @@ struct _hypervWmiClassInfo { hypervCimTypePtr propertyInfo; }; - -typedef struct _hypervWmiClassInfoList hypervWmiClassInfoList; -typedef hypervWmiClassInfoList *hypervWmiClassInfoListPtr; -struct _hypervWmiClassInfoList { - size_t count; - hypervWmiClassInfoPtr *objs; -}; - #include "hyperv_wmi_classes.generated.h" -- 2.27.0

On Mon, Nov 09, 2020 at 03:43:10AM -0500, Matt Coleman wrote:
Signed-off-by: Matt Coleman <matt@datto.com> --- scripts/hyperv_wmi_generator.py | 21 ++++++----------- src/hyperv/hyperv_wmi.c | 41 ++++++--------------------------- src/hyperv/hyperv_wmi.h | 13 ++++++----- src/hyperv/hyperv_wmi_classes.h | 8 ------- 4 files changed, 21 insertions(+), 62 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> NB, this illustrates a flaw in our meson.build rules. ALl the custom_target() using python are missing dependancies, so won't trigger a code rebuild. I'll be sending a patch for this flaw... Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Matt Coleman <matt@datto.com> --- scripts/hyperv_wmi_generator.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/hyperv_wmi_generator.py b/scripts/hyperv_wmi_generator.py index a6f5c6aeab..d72e5d8ca1 100755 --- a/scripts/hyperv_wmi_generator.py +++ b/scripts/hyperv_wmi_generator.py @@ -51,9 +51,6 @@ class WmiClass: header += " * %s\n" % self.name header += " */\n" header += "\n" - header += "#define %s_CLASSNAME \\\n" % name_upper - header += " \"%s\"\n" % self.name - header += "\n" header += "#define %s_WQL_SELECT \\\n" % name_upper header += " \"SELECT * FROM %s \"\n" % self.name header += "\n" @@ -144,7 +141,7 @@ class WmiClass: """ source = "hypervWmiClassInfoPtr %s_WmiInfo = &(hypervWmiClassInfo) {\n" % self.name - source += " .name = %s_CLASSNAME,\n" % self.name.upper() + source += " .name = \"%s\",\n" % self.name source += " .rootUri = %s,\n" % self.uri_info.rootUri source += " .resourceUri = %s_RESOURCE_URI,\n" % self.name.upper() source += " .serializerInfo = %s_Data_TypeInfo,\n" % self.name -- 2.27.0

Signed-off-by: Matt Coleman <matt@datto.com> --- docs/drvhyperv.html.in | 17 +---------------- docs/platforms.rst | 3 +-- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/docs/drvhyperv.html.in b/docs/drvhyperv.html.in index e8e2113f70..bce4e4128b 100644 --- a/docs/drvhyperv.html.in +++ b/docs/drvhyperv.html.in @@ -5,7 +5,7 @@ <h1>Microsoft Hyper-V hypervisor driver</h1> <ul id="toc"></ul> <p> - The libvirt Microsoft Hyper-V driver can manage Hyper-V 2008 R2 and newer. + The libvirt Microsoft Hyper-V driver can manage Hyper-V 2012 R2 and newer. </p> @@ -129,21 +129,6 @@ winrm set winrm/config/service @{AllowUnencrypted="true"} <th>Kernel Version</th> <th>libvirt Representation</th> </thead> - <tr> - <td>Windows Server 2008</td> - <td>6.0.6001</td> - <td>600.6.1</td> - </tr> - <tr> - <td>Windows Server 2008 R2</td> - <td>6.1.7600</td> - <td>601.7.600</td> - </tr> - <tr> - <td>Windows Server 2012</td> - <td>6.2.9200</td> - <td>602.9.200</td> - </tr> <tr> <td>Windows Server 2012 R2</td> <td>6.3.9600</td> diff --git a/docs/platforms.rst b/docs/platforms.rst index b0ce0c3737..e181be247f 100644 --- a/docs/platforms.rst +++ b/docs/platforms.rst @@ -59,8 +59,7 @@ Windows The project supports building with current versions of the MinGW toolchain, hosted on Linux. -The version of the Windows API that's currently targeted is Vista / Server -2008. +The version of the Windows API that's currently targeted is Server 2012R2. Virtualization platforms -- 2.27.0

On Mon, Nov 09, 2020 at 03:43:12AM -0500, Matt Coleman wrote:
Signed-off-by: Matt Coleman <matt@datto.com> --- docs/drvhyperv.html.in | 17 +---------------- docs/platforms.rst | 3 +-- 2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/docs/platforms.rst b/docs/platforms.rst index b0ce0c3737..e181be247f 100644 --- a/docs/platforms.rst +++ b/docs/platforms.rst @@ -59,8 +59,7 @@ Windows The project supports building with current versions of the MinGW toolchain, hosted on Linux.
-The version of the Windows API that's currently targeted is Vista / Server -2008. +The version of the Windows API that's currently targeted is Server 2012R2.
This isn't right, as it is referring to Windows builds in general, not the HyperV driver. More specifically it is referring to this code in meson.build if host_machine.system() == 'windows' # For AI_ADDRCONFIG conf.set('_WIN32_WINNT', '0x0600') # Win Vista / Server 2008 conf.set('WINVER', '0x0600') # Win Vista / Server 2008 endif Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Nov 9, 2020, at 8:21 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
On Mon, Nov 09, 2020 at 03:43:12AM -0500, Matt Coleman wrote:
Signed-off-by: Matt Coleman <matt@datto.com> --- docs/drvhyperv.html.in | 17 +---------------- docs/platforms.rst | 3 +-- 2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/docs/platforms.rst b/docs/platforms.rst index b0ce0c3737..e181be247f 100644 --- a/docs/platforms.rst +++ b/docs/platforms.rst @@ -59,8 +59,7 @@ Windows The project supports building with current versions of the MinGW toolchain, hosted on Linux.
-The version of the Windows API that's currently targeted is Vista / Server -2008. +The version of the Windows API that's currently targeted is Server 2012R2.
This isn't right, as it is referring to Windows builds in general, not the HyperV driver. More specifically it is referring to this code in meson.build
Thanks for pointing that out. No changes should be made to platforms.rst. Please replace PATCH 6/7 with the following patch. Signed-off-by: Matt Coleman <matt@datto.com> --- docs/drvhyperv.html.in | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/docs/drvhyperv.html.in b/docs/drvhyperv.html.in index e8e2113f70..bce4e4128b 100644 --- a/docs/drvhyperv.html.in +++ b/docs/drvhyperv.html.in @@ -5,7 +5,7 @@ <h1>Microsoft Hyper-V hypervisor driver</h1> <ul id="toc"></ul> <p> - The libvirt Microsoft Hyper-V driver can manage Hyper-V 2008 R2 and newer. + The libvirt Microsoft Hyper-V driver can manage Hyper-V 2012 R2 and newer. </p> @@ -129,21 +129,6 @@ winrm set winrm/config/service @{AllowUnencrypted="true"} <th>Kernel Version</th> <th>libvirt Representation</th> </thead> - <tr> - <td>Windows Server 2008</td> - <td>6.0.6001</td> - <td>600.6.1</td> - </tr> - <tr> - <td>Windows Server 2008 R2</td> - <td>6.1.7600</td> - <td>601.7.600</td> - </tr> - <tr> - <td>Windows Server 2012</td> - <td>6.2.9200</td> - <td>602.9.200</td> - </tr> <tr> <td>Windows Server 2012 R2</td> <td>6.3.9600</td> -- 2.27.0

Signed-off-by: Matt Coleman <matt@datto.com> --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 905deba5a8..0e56f5dbca 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -17,6 +17,12 @@ v6.10.0 (unreleased) * **Bug fixes** +* **Removed features** + + * hyperv: removed support for the Hyper-V V1 WMI API + + This drops support for Windows Server 2008R2 and 2012. + The earliest supported version is now Windows 2012R2. v6.9.0 (2020-11-02) =================== -- 2.27.0

On Mon, Nov 09, 2020 at 03:43:06AM -0500, Matt Coleman wrote:
Microsoft no longer supports Windows 2008R2 at all. Windows 2012 and 2012 R2 are still within extended support until October 9, 2023.
Hyper-V's WMI API has two versions. V1 is supported by 2008R2 and 2012. 2012 also offered initial support for V2, but it's incomplete. 2012R2 was the first version to offer full support for the V2 API.
This patchset drops support for the V1 WMI API.
Here's a GitLab merge request, if you'd prefer to review it there: https://gitlab.com/iammattcoleman/libvirt/-/merge_requests/7
I've pushed with the discussed changed. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Daniel P. Berrangé
-
Matt Coleman