[libvirt PATCH v3 47/51] device_conf: Use virXMLPropTristateXXX in virPCIDeviceAddressParseXML

Tim Wiederhake twiederh at redhat.com
Fri Mar 19 15:57:44 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/conf/device_conf.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 0dd60985e9..8d0540bb02 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -214,7 +214,6 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
     g_autofree char *bus      = virXMLPropString(node, "bus");
     g_autofree char *slot     = virXMLPropString(node, "slot");
     g_autofree char *function = virXMLPropString(node, "function");
-    g_autofree char *multi    = virXMLPropString(node, "multifunction");
 
     memset(addr, 0, sizeof(*addr));
 
@@ -246,16 +245,9 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
         return -1;
     }
 
-    if (multi) {
-        int value;
-        if ((value = virTristateSwitchTypeFromString(multi)) <= 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("Unknown value '%s' for <address> 'multifunction' attribute"),
-                           multi);
-            return -1;
-        }
-        addr->multi = value;
-    }
+    if (virXMLPropTristateSwitch(node, "multifunction", false, &addr->multi) < 0)
+        return -1;
+
     if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(addr, true))
         return -1;
 
-- 
2.26.2




More information about the libvir-list mailing list