1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

hyperv: implement domainSetMaxMemory

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Matt Coleman 2020-11-11 01:48:30 -05:00 committed by Michal Privoznik
parent 5b389613e6
commit 5f3915a334

View 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 */