[libvirt] [PATCH v2 3/3] qemu/qemu_migration_params: use virStringParseYesNo helper

Mao Zhongyi maozhongyi at cmss.chinamobile.com
Thu Oct 17 03:19:33 UTC 2019


A function virStringParseYesNo was added to convert
string 'yes' to true and 'no' to false, so use this
helper to replace 'STREQ(.*, \"yes\")' and
'STREQ(.*, \"no\")' as it allows us to drop several
repetitive if-then-else string->bool conversion blocks.

Signed-off-by: Mao Zhongyi <maozhongyi at cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju at cmss.chinamobile.com>
---
 src/qemu/qemu_migration_params.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 85fa8f8de5..f5bc8596f4 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -1326,12 +1326,7 @@ qemuMigrationParamsParse(xmlXPathContextPtr ctxt,
             break;
 
         case QEMU_MIGRATION_PARAM_TYPE_BOOL:
-            if (STREQ(value, "yes"))
-                pv->value.b = true;
-            else if (STREQ(value, "no"))
-                pv->value.b = false;
-            else
-                rc = -1;
+            rc = virStringParseYesNo(value, &pv->value.b);
             break;
 
         case QEMU_MIGRATION_PARAM_TYPE_STRING:
-- 
2.17.1






More information about the libvir-list mailing list