From: Matt Coleman <matt(a)datto.com>
Co-authored-by: Sri Ramanujam <sramanujam(a)datto.com>
Signed-off-by: Matt Coleman <matt(a)datto.com>
---
NEWS.rst | 6 +++---
src/hyperv/hyperv_driver.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/NEWS.rst b/NEWS.rst
index 65fa616a03..c52dddde74 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -13,10 +13,10 @@ v6.9.0 (unreleased)
* **New features**
- * hyperv: implement ``virConnectGetCapabilities()``
+ * hyperv: implement new APIs
- The ``virConnectGetCapabilities()`` API has been implemented in the Hyper-V
- driver.
+ The ``virConnectGetCapabilities()`` and ``virConnectGetMaxVcpus()`` APIs
+ have been implemented in the Hyper-V driver.
* **Improvements**
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index b1f84c568f..faeb826601 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -522,6 +522,39 @@ hypervConnectGetCapabilities(virConnectPtr conn)
+static int
+hypervConnectGetMaxVcpus(virConnectPtr conn, const char *type G_GNUC_UNUSED)
+{
+ int result = -1;
+ hypervPrivate *priv = conn->privateData;
+ g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER;
+ Msvm_ProcessorSettingData *processorSettingData = NULL;
+
+ /* Get max processors definition */
+ virBufferAddLit(&query,
+ MSVM_PROCESSORSETTINGDATA_WQL_SELECT
+ "WHERE InstanceID LIKE
'Microsoft:Definition%Maximum'");
+
+ if (hypervGetWmiClass(Msvm_ProcessorSettingData, &processorSettingData) < 0)
+ goto cleanup;
+
+ if (!processorSettingData) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not get maximum definition of
Msvm_ProcessorSettingData for host %s"),
+ conn->uri->server);
+ goto cleanup;
+ }
+
+ result = processorSettingData->data.common->VirtualQuantity;
+
+ cleanup:
+ hypervFreeObject(priv, (hypervObject *) processorSettingData);
+
+ return result;
+}
+
+
+
static int
hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
{
@@ -1690,6 +1723,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
.connectClose = hypervConnectClose, /* 0.9.5 */
.connectGetType = hypervConnectGetType, /* 0.9.5 */
.connectGetHostname = hypervConnectGetHostname, /* 0.9.5 */
+ .connectGetMaxVcpus = hypervConnectGetMaxVcpus, /* 6.9.0 */
.nodeGetInfo = hypervNodeGetInfo, /* 0.9.5 */
.connectGetCapabilities = hypervConnectGetCapabilities, /* 6.9.0 */
.connectListDomains = hypervConnectListDomains, /* 0.9.5 */
--
2.27.0