]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: implement domainSetMaxMemory
authorMatt Coleman <mcoleman@datto.com>
Wed, 11 Nov 2020 06:48:30 +0000 (01:48 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 12 Nov 2020 08:43:42 +0000 (09:43 +0100)
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/hyperv/hyperv_driver.c

index e779b67d002dacfc38711b36930504dc04522e85..6d7bc4b80f86d267965cc5f235c62b2cc8138d38 100644 (file)
@@ -933,8 +933,8 @@ hypervDomainGetMaxMemory(virDomainPtr domain)
 
 
 static int
-hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
-                           unsigned int flags)
+hypervDomainSetMemoryProperty(virDomainPtr domain, unsigned long memory,
+                              const char* propertyName)
 {
     int result = -1;
     char uuid_string[VIR_UUID_STRING_BUFLEN];
@@ -946,8 +946,6 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
     Msvm_MemorySettingData *memsd = NULL;
     g_autoptr(GHashTable) memResource = NULL;
 
-    virCheckFlags(0, -1);
-
     memory_str = g_strdup_printf("%lu", memory_mb);
 
     virUUIDFormat(domain->uuid, uuid_string);
@@ -969,7 +967,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
     if (!memResource)
         goto cleanup;
 
-    if (hypervSetEmbeddedProperty(memResource, "VirtualQuantity", memory_str) < 0)
+    if (hypervSetEmbeddedProperty(memResource, propertyName, memory_str) < 0)
         goto cleanup;
 
     if (hypervSetEmbeddedProperty(memResource, "InstanceID", memsd->data->InstanceID) < 0)
@@ -995,6 +993,21 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
 }
 
 
+static int
+hypervDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
+{
+    return hypervDomainSetMemoryProperty(domain, memory, "Limit");
+}
+
+
+static int
+hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, unsigned int flags)
+{
+    virCheckFlags(0, -1);
+    return hypervDomainSetMemoryProperty(domain, memory, "VirtualQuantity");
+}
+
+
 static int
 hypervDomainSetMemory(virDomainPtr domain, unsigned long memory)
 {
@@ -1793,6 +1806,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
     .domainDestroyFlags = hypervDomainDestroyFlags, /* 0.9.5 */
     .domainGetOSType = hypervDomainGetOSType, /* 0.9.5 */
     .domainGetMaxMemory = hypervDomainGetMaxMemory, /* 6.10.0 */
+    .domainSetMaxMemory = hypervDomainSetMaxMemory, /* 6.10.0 */
     .domainSetMemory = hypervDomainSetMemory, /* 3.6.0 */
     .domainSetMemoryFlags = hypervDomainSetMemoryFlags, /* 3.6.0 */
     .domainGetInfo = hypervDomainGetInfo, /* 0.9.5 */