On 11/12/20 12:51 PM, Matt Coleman wrote:
Co-authored-by: Sri Ramanujam <sramanujam(a)datto.com>
Signed-off-by: Matt Coleman <matt(a)datto.com>
---
src/hyperv/hyperv_driver.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 3c436d9465..0e35f18430 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -42,6 +42,11 @@
VIR_LOG_INIT("hyperv.hyperv_driver");
+/*
+ * Forward declarations
+ */
+static int hypervDomainIsActive(virDomainPtr domain);
+
I'm not a big fan of these declarations, because changing one place
requires changing the other. Although in this case it doesn't matter
really, because this declaration won't change as it's derived from
public API. Anyway, might be worth shifting things around ..
/*
* WMI utility functions
*
@@ -1184,6 +1189,16 @@ hypervDomainGetVcpus(virDomainPtr domain,
}
+static int
+hypervDomainGetMaxVcpus(virDomainPtr dom)
+{
+ if (hypervDomainIsActive(dom))
+ return hypervDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
VIR_DOMAIN_VCPU_MAXIMUM));
+ else
+ return hypervConnectGetMaxVcpus(dom->conn, NULL);
+}
.. eg push this a bit further - after the hypervDomainIsActive() is
implemented.
+
+
static char *
hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
{
@@ -1983,6 +1998,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
.domainGetState = hypervDomainGetState, /* 0.9.5 */
.domainGetVcpusFlags = hypervDomainGetVcpusFlags, /* 6.10.0 */
.domainGetVcpus = hypervDomainGetVcpus, /* 6.10.0 */
+ .domainGetMaxVcpus = hypervDomainGetMaxVcpus, /* 6.10.0 */
.domainGetXMLDesc = hypervDomainGetXMLDesc, /* 0.9.5 */
.connectListDefinedDomains = hypervConnectListDefinedDomains, /* 0.9.5 */
.connectNumOfDefinedDomains = hypervConnectNumOfDefinedDomains, /* 0.9.5 */
Michal