[PATCH 07/12] conf: Convert virCPUDefParseXML() to virXMLProp*()

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

 



After previous cleanups, the virCPUDefParseXML() function uses a
mixture of virXMLProp*() and the old virXMLPropString() +
virXXXTypeFromString() patterns. Rework it so that virXMLProp*()
is used.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/cpu_conf.c | 24 ++++++++----------------
 src/conf/cpu_conf.h |  2 +-
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 8e61a16919..da83e99371 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -407,17 +407,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
     }
 
     if (def->type == VIR_CPU_TYPE_GUEST) {
-        g_autofree char *match = virXMLPropString(ctxt->node, "match");
-
-        if (match) {
-            def->match = virCPUMatchTypeFromString(match);
-            if (def->match < 0) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("Invalid match attribute for CPU "
-                                 "specification"));
-                return -1;
-            }
-        }
+        if (virXMLPropEnum(ctxt->node, "match",
+                           virCPUMatchTypeFromString,
+                           VIR_XML_PROP_NONE,
+                           &def->match) < 0)
+            return -1;
 
         if (virXMLPropEnum(ctxt->node, "check", virCPUCheckTypeFromString,
                            VIR_XML_PROP_NONE, &def->check) < 0)
@@ -450,12 +444,10 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
         if ((counter_node = virXPathNode("./counter[@name='tsc'])", ctxt))) {
             tsc = g_new0(virHostCPUTscInfo, 1);
 
-            if (virXPathULongLong("string(./counter[@name='tsc']/@frequency)",
-                                  ctxt, &tsc->frequency) < 0) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("Invalid TSC frequency"));
+            if (virXMLPropULongLong(counter_node, "frequency", 10,
+                                    VIR_XML_PROP_REQUIRED,
+                                    &tsc->frequency) < 0)
                 return -1;
-            }
 
             if (virXMLPropTristateBool(counter_node, "scaling",
                                        VIR_XML_PROP_NONE,
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index b0a81895be..2cda4ee1f4 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -122,7 +122,7 @@ struct _virCPUDef {
     int refs;
     int type;           /* enum virCPUType */
     int mode;           /* enum virCPUMode */
-    int match;          /* enum virCPUMatch */
+    virCPUMatch match;
     virCPUCheck check;
     virArch arch;
     char *model;
-- 
2.34.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