]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Generalize macro for getting VIR_MIGRATE_* typed params
authorJiri Denemark <jdenemar@redhat.com>
Fri, 9 Mar 2018 16:17:01 +0000 (17:17 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 17 Apr 2018 08:46:23 +0000 (10:46 +0200)
So far it's used only for CPU throttling parameters which are all ints,
but we'll soon want to use it for more parameters with different types.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_migration_params.c

index 369e560990fd38149323e5b107128ced7df51453..e0cbdb1a38043c94a161f866f92dd8d286000c79 100644 (file)
@@ -112,6 +112,17 @@ qemuMigrationParamsFree(qemuMigrationParamsPtr migParams)
 }
 
 
+#define GET(API, PARAM, VAR) \
+    do { \
+        int rc; \
+        if ((rc = API(params, nparams, VIR_MIGRATE_PARAM_ ## PARAM, \
+                      &migParams->params.VAR)) < 0) \
+            goto error; \
+ \
+        if (rc == 1) \
+            migParams->params.VAR ## _set = true; \
+    } while (0)
+
 qemuMigrationParamsPtr
 qemuMigrationParamsFromFlags(virTypedParameterPtr params,
                              int nparams,
@@ -135,27 +146,13 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
         }
     }
 
-#define GET(PARAM, VAR) \
-    do { \
-        int rc; \
-        if ((rc = virTypedParamsGetInt(params, nparams, \
-                                       VIR_MIGRATE_PARAM_ ## PARAM, \
-                                       &migParams->params.VAR)) < 0) \
-            goto error; \
- \
-        if (rc == 1) \
-            migParams->params.VAR ## _set = true; \
-    } while (0)
-
     if (params) {
         if (party == QEMU_MIGRATION_SOURCE) {
-            GET(AUTO_CONVERGE_INITIAL, cpuThrottleInitial);
-            GET(AUTO_CONVERGE_INCREMENT, cpuThrottleIncrement);
+            GET(virTypedParamsGetInt, AUTO_CONVERGE_INITIAL, cpuThrottleInitial);
+            GET(virTypedParamsGetInt, AUTO_CONVERGE_INCREMENT, cpuThrottleIncrement);
         }
     }
 
-#undef GET
-
     if ((migParams->params.cpuThrottleInitial_set ||
          migParams->params.cpuThrottleIncrement_set) &&
         !(flags & VIR_MIGRATE_AUTO_CONVERGE)) {
@@ -171,6 +168,8 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
     return NULL;
 }
 
+#undef GET
+
 
 /**
  * qemuMigrationParamsApply