]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Convert virCPUDefParseXML() to virXMLProp*()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 20 Jan 2022 20:57:35 +0000 (21:57 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 21 Jan 2022 15:42:14 +0000 (16:42 +0100)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/cpu_conf.c
src/conf/cpu_conf.h

index 8e61a1691978ffc24aaf6dc49336fee6d3be371a..da83e99371b0e1ed055c0bcbf0a04f6d484fc7c5 100644 (file)
@@ -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,
index b0a81895be1f998a0bc26e4c613bedefe38150fe..2cda4ee1f4512d9002bfed6231c15b053892d351 100644 (file)
@@ -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;