Re: [PATCH 1/7] hyperv: implement domainSetAutostart

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

 



> On Oct 9, 2020, at 4:58 AM, Pino Toscano <ptoscano@xxxxxxxxxx> wrote:
> 
> On Friday, 9 October 2020 10:31:50 CEST Matt Coleman wrote:
>> +static int
>> +hypervDomainSetAutostart(virDomainPtr domain, int autostart)
>> +{
>> +    int result = -1;
>> +    char uuid_string[VIR_UUID_STRING_BUFLEN];
>> +    hypervPrivate *priv = domain->conn->privateData;
>> +    Msvm_VirtualSystemSettingData *vssd = NULL;
>> +    hypervInvokeParamsListPtr params = NULL;
>> +    g_auto(virBuffer) eprQuery = VIR_BUFFER_INITIALIZER;
>> +    virHashTablePtr autostartParam = NULL;
>> +    hypervWmiClassInfoListPtr embeddedParamClass = NULL;
>> +    const char *methodName = NULL, *embeddedParamName = NULL;
>> +    g_autofree char *enabledValue = NULL, *disabledValue = NULL;
>> +
>> +    if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
>> +        methodName = "ModifyVirtualSystem";
>> +        embeddedParamName = "SystemSettingData";
>> +        embeddedParamClass = Msvm_VirtualSystemGlobalSettingData_WmiInfo;
>> +        enabledValue = g_strdup("2");
>> +        disabledValue = g_strdup("0");
>> +    } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) {
>> +        methodName = "ModifySystemSettings";
>> +        embeddedParamName = "SystemSettings";
>> +        embeddedParamClass = Msvm_VirtualSystemSettingData_WmiInfo;
>> +        enabledValue = g_strdup("4");
>> +        disabledValue = g_strdup("2");
>> +    }
> 
> It looks like 'enabledValue' and 'disabledValue' can be static strings
> (like 'methodName' and 'embeddedParamName').

I removed g_autofree and g_strdup() with the following patch applied on 
top of my initial changes. Can it be squashed into this commit, or do I 
have to submit a [PATCH v2]?

Signed-off-by: Matt Coleman <matt@xxxxxxxxx>
---
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index c91bc58488..baaace041b 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1450,20 +1450,18 @@ hypervDomainSetAutostart(virDomainPtr domain, int autostart)
     virHashTablePtr autostartParam = NULL;
     hypervWmiClassInfoListPtr embeddedParamClass = NULL;
     const char *methodName = NULL, *embeddedParamName = NULL;
-    g_autofree char *enabledValue = NULL, *disabledValue = NULL;
+    char enabledValue[] = "2", disabledValue[] = "0";
 
     if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
         methodName = "ModifyVirtualSystem";
         embeddedParamName = "SystemSettingData";
         embeddedParamClass = Msvm_VirtualSystemGlobalSettingData_WmiInfo;
-        enabledValue = g_strdup("2");
-        disabledValue = g_strdup("0");
     } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) {
         methodName = "ModifySystemSettings";
         embeddedParamName = "SystemSettings";
         embeddedParamClass = Msvm_VirtualSystemSettingData_WmiInfo;
-        enabledValue = g_strdup("4");
-        disabledValue = g_strdup("2");
+        enabledValue[0] = '4';
+        disabledValue[0] = '2';
     }
 
     virUUIDFormat(domain->uuid, uuid_string);





[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