[PATCH 3/7] hyperv: implement domainSetMaxMemory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Co-authored-by: Sri Ramanujam <sramanujam@xxxxxxxxx>
Signed-off-by: Matt Coleman <matt@xxxxxxxxx>
---
 src/hyperv/hyperv_driver.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index e779b67d00..6d7bc4b80f 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -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 */
-- 
2.27.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux