[libvirt] [PATCH v2 41/73] qemu: Generalize macro for getting VIR_MIGRATE_* typed params

Jiri Denemark posted 73 patches 7 years, 1 month ago
[libvirt] [PATCH v2 41/73] qemu: Generalize macro for getting VIR_MIGRATE_* typed params
Posted by Jiri Denemark 7 years, 1 month ago
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>
---
 src/qemu/qemu_migration_params.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 369e560990..e0cbdb1a38 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -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
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 41/73] qemu: Generalize macro for getting VIR_MIGRATE_* typed params
Posted by Ján Tomko 7 years, 1 month ago
On Wed, Apr 11, 2018 at 04:41:31PM +0200, Jiri Denemark wrote:
>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>
>---
> src/qemu/qemu_migration_params.c | 31 +++++++++++++++----------------
> 1 file changed, 15 insertions(+), 16 deletions(-)
>
>diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
>index 369e560990..e0cbdb1a38 100644
>--- a/src/qemu/qemu_migration_params.c
>+++ b/src/qemu/qemu_migration_params.c
>@@ -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);

If all the getter APIs start with virTypedParamsGet, you can hide the
prefix inside the macro definition to save columns.

Regardless:

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 41/73] qemu: Generalize macro for getting VIR_MIGRATE_* typed params
Posted by Jiri Denemark 7 years, 1 month ago
On Fri, Apr 13, 2018 at 16:22:00 +0200, Ján Tomko wrote:
> On Wed, Apr 11, 2018 at 04:41:31PM +0200, Jiri Denemark wrote:
> >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>
> >---
> > src/qemu/qemu_migration_params.c | 31 +++++++++++++++----------------
> > 1 file changed, 15 insertions(+), 16 deletions(-)
> >
> >diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
> >index 369e560990..e0cbdb1a38 100644
> >--- a/src/qemu/qemu_migration_params.c
> >+++ b/src/qemu/qemu_migration_params.c
> >@@ -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);
> 
> If all the getter APIs start with virTypedParamsGet, you can hide the
> prefix inside the macro definition to save columns.

The macro will go away completely later in this series anyway.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list