]> xenbits.xensource.com Git - libvirt.git/commitdiff
vz: make output arguments in prlsdkGetDomainIds as optional
authorMikhail Feoktistov <mfeoktistov@virtuozzo.com>
Wed, 10 Feb 2016 09:39:11 +0000 (12:39 +0300)
committerMaxim Nestratov <mnestratov@virtuozzo.com>
Fri, 12 Feb 2016 10:31:56 +0000 (13:31 +0300)
prlsdkGetDomainIds() returns name and uuid for specified instance.
Now output arguments can be NULL.
It allows to get only necessary info(name or uuid).

src/vz/vz_sdk.c

index 30ea5453cc025913c2b029ea0bdfe74fdee86a5c..a47c5d68756e6203190fc04ddbff5b7ed2208bf3 100644 (file)
@@ -346,31 +346,37 @@ prlsdkGetDomainIds(PRL_HANDLE sdkdom,
     PRL_UINT32 len;
     PRL_RESULT pret;
 
-    len = 0;
-    /* get name length */
-    pret = PrlVmCfg_GetName(sdkdom, NULL, &len);
-    prlsdkCheckRetGoto(pret, error);
+    if (name) {
+        len = 0;
+        *name = NULL;
+        /* get name length */
+        pret = PrlVmCfg_GetName(sdkdom, NULL, &len);
+        prlsdkCheckRetGoto(pret, error);
 
-    if (VIR_ALLOC_N(*name, len) < 0)
-        goto error;
+        if (VIR_ALLOC_N(*name, len) < 0)
+            goto error;
 
-    PrlVmCfg_GetName(sdkdom, *name, &len);
-    prlsdkCheckRetGoto(pret, error);
+        pret = PrlVmCfg_GetName(sdkdom, *name, &len);
+        prlsdkCheckRetGoto(pret, error);
+    }
 
-    len = sizeof(uuidstr);
-    PrlVmCfg_GetUuid(sdkdom, uuidstr, &len);
-    prlsdkCheckRetGoto(pret, error);
+    if (uuid) {
+        len = sizeof(uuidstr);
+        pret = PrlVmCfg_GetUuid(sdkdom, uuidstr, &len);
+        prlsdkCheckRetGoto(pret, error);
 
-    if (prlsdkUUIDParse(uuidstr, uuid) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Domain UUID is malformed or empty"));
-        goto error;
+        if (prlsdkUUIDParse(uuidstr, uuid) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Domain UUID is malformed or empty"));
+            goto error;
+        }
     }
 
     return 0;
 
  error:
-    VIR_FREE(*name);
+    if (name)
+        VIR_FREE(*name);
     return -1;
 }