[PATCH 1/7] virStorageSourcePoolDef: Turn 'mode' member into proper enum type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use proper enum type and refactor the formatter accordingly.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c         | 12 ++++--------
 src/conf/storage_source_conf.h |  2 +-
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4435ee2ad4..d7f167a469 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7011,7 +7011,6 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node,
 {
     virStorageSourcePoolDef *source;
     int ret = -1;
-    g_autofree char *mode = NULL;

     *srcpool = NULL;

@@ -7019,7 +7018,6 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node,

     source->pool = virXMLPropString(node, "pool");
     source->volume = virXMLPropString(node, "volume");
-    mode = virXMLPropString(node, "mode");

     /* CD-ROM and Floppy allows no source */
     if (!source->pool && !source->volume) {
@@ -7033,13 +7031,11 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node,
         goto cleanup;
     }

-    if (mode &&
-        (source->mode = virStorageSourcePoolModeTypeFromString(mode)) <= 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown source mode '%1$s' for volume type disk"),
-                       mode);
+    if (virXMLPropEnum(node, "mode",
+                       virStorageSourcePoolModeTypeFromString,
+                       VIR_XML_PROP_NONZERO,
+                       &source->mode) < 0)
         goto cleanup;
-    }

     *srcpool = g_steal_pointer(&source);
     ret = 0;
diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h
index fc6c67f426..bfa8d625e5 100644
--- a/src/conf/storage_source_conf.h
+++ b/src/conf/storage_source_conf.h
@@ -201,7 +201,7 @@ struct _virStorageSourcePoolDef {
     int voltype; /* virStorageVolType, internal only */
     int pooltype; /* virStoragePoolType from storage_conf.h, internal only */
     virStorageType actualtype; /* internal only */
-    int mode; /* virStorageSourcePoolMode, currently makes sense only for iscsi pool */
+    virStorageSourcePoolMode mode; /* currently makes sense only for iscsi pool */
 };


-- 
2.41.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux