[PATCH 14/17] virDomainPanicDefParseXML: Switch to virXMLPropEnumDefault()

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

 



The virDomainPanicDefParseXML() function uses old style of
parsing XML (virXMLPropString + str2enum conversion). Use
virXMLPropEnumDefault() which encapsulates those steps.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 11 ++++-------
 src/conf/domain_conf.h   |  2 +-
 src/qemu/qemu_command.c  |  2 +-
 src/qemu/qemu_validate.c |  2 +-
 4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1f18bab332..678b9265c7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11755,7 +11755,6 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlopt,
                           unsigned int flags)
 {
     virDomainPanicDef *panic;
-    g_autofree char *model = NULL;
 
     panic = g_new0(virDomainPanicDef, 1);
 
@@ -11763,13 +11762,11 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlopt,
                                     &panic->info, flags) < 0)
         goto error;
 
-    model = virXMLPropString(node, "model");
-    if (model != NULL &&
-        (panic->model = virDomainPanicModelTypeFromString(model)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown panic model '%s'"), model);
+    if (virXMLPropEnum(node, "model",
+                       virDomainPanicModelTypeFromString,
+                       VIR_XML_PROP_NONE,
+                       &panic->model) < 0)
         goto error;
-    }
 
     return panic;
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9891a5e276..9a0b962ec8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2596,7 +2596,7 @@ typedef enum {
 } virDomainPanicModel;
 
 struct _virDomainPanicDef {
-    int model; /* virDomainPanicModel */
+    virDomainPanicModel model;
     virDomainDeviceInfo info;
 };
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4dd803642a..72bca45dc4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9976,7 +9976,7 @@ qemuBuildPanicCommandLine(virCommand *cmd,
     size_t i;
 
     for (i = 0; i < def->npanics; i++) {
-        switch ((virDomainPanicModel) def->panics[i]->model) {
+        switch (def->panics[i]->model) {
         case VIR_DOMAIN_PANIC_MODEL_ISA: {
             g_autoptr(virJSONValue) props = NULL;
 
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index d30ffeb3ea..d4f0ea03e8 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -935,7 +935,7 @@ qemuValidateDomainDefPanic(const virDomainDef *def,
     size_t i;
 
     for (i = 0; i < def->npanics; i++) {
-        switch ((virDomainPanicModel) def->panics[i]->model) {
+        switch (def->panics[i]->model) {
         case VIR_DOMAIN_PANIC_MODEL_S390:
             /* For s390 guests, the hardware provides the same
              * functionality as the pvpanic device. The address
-- 
2.35.1




[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