]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: pass elementName to virDomainThreadSchedParseHelper
authorJán Tomko <jtomko@redhat.com>
Sat, 25 Jul 2020 07:42:14 +0000 (09:42 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 3 Aug 2020 05:23:45 +0000 (07:23 +0200)
Pass the scheduler element name instead of trying to reconstructing
it from the attribute name.

This has the benefit of not mixing '%s' with regular text in
translatable strings as well as preventing the confusion when
the 's' marking the plural in the element name ('vcpus') is taken
as a first letter of the 'sched' suffix.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 7ea55a481dd45f09b54425005362533ecc800cd2
Fixes: 99c5fe0e7c26c08103415248ffef1f5acb81ddc7
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/domain_conf.c

index fd968635fe2adcc585f43ace21e44283f4e869b1..0f12b5457502520d107ae531f1597a7e6c3e01d0 100644 (file)
@@ -19965,6 +19965,7 @@ virDomainEmulatorSchedParse(xmlNodePtr node,
 
 static virBitmapPtr
 virDomainSchedulerParse(xmlNodePtr node,
+                        const char *elementName,
                         const char *attributeName,
                         virProcessSchedPolicy *policy,
                         int *priority)
@@ -19974,8 +19975,8 @@ virDomainSchedulerParse(xmlNodePtr node,
 
     if (!(tmp = virXMLPropString(node, attributeName))) {
         virReportError(VIR_ERR_XML_ERROR,
-                       _("Missing attribute '%s' in element '%sched'"),
-                       attributeName, attributeName);
+                       _("Missing attribute '%s' in element '%s'"),
+                       attributeName, elementName);
         goto error;
     }
 
@@ -20002,6 +20003,7 @@ virDomainSchedulerParse(xmlNodePtr node,
 
 static int
 virDomainThreadSchedParseHelper(xmlNodePtr node,
+                                const char *elementName,
                                 const char *attributeName,
                                 virDomainThreadSchedParamPtr (*func)(virDomainDefPtr, unsigned int),
                                 virDomainDefPtr def)
@@ -20012,7 +20014,8 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
     int priority = 0;
     g_autoptr(virBitmap) map = NULL;
 
-    if (!(map = virDomainSchedulerParse(node, attributeName, &policy, &priority)))
+    if (!(map = virDomainSchedulerParse(node, elementName, attributeName,
+                                        &policy, &priority)))
         return -1;
 
     while ((next = virBitmapNextSetBit(map, next)) > -1) {
@@ -20021,8 +20024,8 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
 
         if (sched->policy != VIR_PROC_POLICY_NONE) {
             virReportError(VIR_ERR_XML_DETAIL,
-                           _("%ssched attributes 'vcpus' must not overlap"),
-                           STREQ(attributeName, "vcpus") ? "vcpu" : attributeName);
+                           _("'%s' attributes 'vcpus' must not overlap"),
+                           elementName);
             return -1;
         }
 
@@ -20038,7 +20041,9 @@ static int
 virDomainVcpuThreadSchedParse(xmlNodePtr node,
                               virDomainDefPtr def)
 {
-    return virDomainThreadSchedParseHelper(node, "vcpus",
+    return virDomainThreadSchedParseHelper(node,
+                                           "vcpusched",
+                                           "vcpus",
                                            virDomainDefGetVcpuSched,
                                            def);
 }
@@ -20065,7 +20070,9 @@ static int
 virDomainIOThreadSchedParse(xmlNodePtr node,
                             virDomainDefPtr def)
 {
-    return virDomainThreadSchedParseHelper(node, "iothreads",
+    return virDomainThreadSchedParseHelper(node,
+                                           "iothreadsched",
+                                           "iothreads",
                                            virDomainDefGetIOThreadSched,
                                            def);
 }