[libvirt PATCH v3 44/51] domain_conf: Use virXMLPropTristateXXX in virDomainVcpuParse

Tim Wiederhake twiederh at redhat.com
Fri Mar 19 15:57:41 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/conf/domain_conf.c | 28 +++++-----------------------
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 55405d129b..97c7a3ec28 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18998,7 +18998,7 @@ virDomainVcpuParse(virDomainDefPtr def,
 
         for (i = 0; i < n; i++) {
             virDomainVcpuDefPtr vcpu;
-            int state;
+            virTristateBool state;
             unsigned int id;
             unsigned int order;
 
@@ -19020,31 +19020,13 @@ virDomainVcpuParse(virDomainDefPtr def,
 
             vcpu = virDomainDefGetVcpu(def, id);
 
-            if (!(tmp = virXMLPropString(nodes[i], "enabled"))) {
-                virReportError(VIR_ERR_XML_ERROR, "%s",
-                               _("missing vcpu enabled state"));
+            if (virXMLPropTristateBool(nodes[i], "enabled", true, &state) < 0)
                 return -1;
-            }
-
-            if ((state = virTristateBoolTypeFromString(tmp)) < 0) {
-                virReportError(VIR_ERR_XML_ERROR,
-                               _("invalid vcpu 'enabled' value '%s'"), tmp);
-                return -1;
-            }
-            VIR_FREE(tmp);
-
             vcpu->online = state == VIR_TRISTATE_BOOL_YES;
 
-            if ((tmp = virXMLPropString(nodes[i], "hotpluggable"))) {
-                int hotpluggable;
-                if ((hotpluggable = virTristateBoolTypeFromString(tmp)) < 0) {
-                    virReportError(VIR_ERR_XML_ERROR,
-                                   _("invalid vcpu 'hotpluggable' value '%s'"), tmp);
-                    return -1;
-                }
-                vcpu->hotpluggable = hotpluggable;
-                VIR_FREE(tmp);
-            }
+            if (virXMLPropTristateBool(nodes[i], "hotpluggable", false,
+                                       &vcpu->hotpluggable) < 0)
+                return -1;
 
             if ((tmp = virXMLPropString(nodes[i], "order"))) {
                 if (virStrToLong_uip(tmp, NULL, 10, &order) < 0) {
-- 
2.26.2




More information about the libvir-list mailing list