[libvirt PATCH 38/38] storage_conf: Use virXMLProp(OnOff|YesNo) in virStoragePoolDefParseSource

Tim Wiederhake twiederh at redhat.com
Thu Mar 18 08:01:17 UTC 2021


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

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 2e07c81f8a..7dc528b103 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -605,7 +605,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
         goto cleanup;
 
     for (i = 0; i < nsource; i++) {
-        g_autofree char *partsep = NULL;
+        virTristateBool partsep = VIR_TRISTATE_BOOL_ABSENT;
         virStoragePoolSourceDevice dev = { .path = NULL };
         dev.path = virXMLPropString(nodeset[i], "path");
 
@@ -615,17 +615,11 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
             goto cleanup;
         }
 
-        partsep = virXMLPropString(nodeset[i], "part_separator");
-        if (partsep) {
-            dev.part_separator = virTristateBoolTypeFromString(partsep);
-            if (dev.part_separator <= 0) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                               _("invalid part_separator setting '%s'"),
-                               partsep);
-                virStoragePoolSourceDeviceClear(&dev);
-                goto cleanup;
-            }
+        if (virXMLPropYesNo(nodeset[i], "part_separator", &partsep) < 0) {
+            virStoragePoolSourceDeviceClear(&dev);
+            goto cleanup;
         }
+        dev.part_separator = partsep;
 
         if (VIR_APPEND_ELEMENT(source->devices, source->ndevice, dev) < 0) {
             virStoragePoolSourceDeviceClear(&dev);
-- 
2.26.2




More information about the libvir-list mailing list