Re: [PATCH 11/17] virDomainDiskDefParseSourceXML: Switch to virXMLPropEnumDefault()

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

 



On 5/23/22 3:08 PM, Michal Privoznik wrote:
The virDomainDiskDefParseSourceXML() function uses old style of
parsing XML (virXMLPropString + str2enum conversion). Use
virXMLPropEnumDefault() which encapsulates those steps.

strtoul and virXMLPropUInt (also subject)


Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
  src/conf/domain_conf.c | 14 +++++---------
  1 file changed, 5 insertions(+), 9 deletions(-)

Besides above
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>


diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c42ac9c0c9..44b507b74d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9039,15 +9039,11 @@ virDomainDiskDefParseSourceXML(virDomainXMLOption *xmlopt,
          if (virDomainStorageSourceParse(tmp, ctxt, src, flags, xmlopt) < 0)
              return NULL;
- if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) {
-            g_autofree char *sourceindex = NULL;
-
-            if ((sourceindex = virXMLPropString(tmp, "index")) &&
-                virStrToLong_uip(sourceindex, NULL, 10, &src->id) < 0) {
-                virReportError(VIR_ERR_XML_ERROR,
-                               _("invalid disk index '%s'"), sourceindex);
-                return NULL;
-            }
+        if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
+            virXMLPropUInt(tmp, "index", 10,
+                           VIR_XML_PROP_NONE,
+                           &src->id) < 0) {
+            return NULL;
          }
      } else {
          /* Reset src->type in case when 'source' was not present */



--
Mit freundlichen Grüßen/Kind regards
   Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294





[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