[PATCH 6/6] conf: Move *AddressParseXML() to device_conf

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

 



The corresponding structs are declared there.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/conf/device_conf.c   | 267 ++++++++++++++++++++++++++++++++++++++
 src/conf/device_conf.h   |  17 +++
 src/conf/domain_conf.c   | 270 ---------------------------------------
 src/libvirt_private.syms |   6 +
 4 files changed, 290 insertions(+), 270 deletions(-)

diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 48788540d3..18592bbc1d 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -343,6 +343,273 @@ virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr)
            addr->devno <= VIR_DOMAIN_DEVICE_CCW_MAX_DEVNO;
 }
 
+int
+virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
+                                  virDomainDeviceCCWAddressPtr addr)
+{
+    int   ret = -1;
+    char *cssid;
+    char *ssid;
+    char *devno;
+
+    memset(addr, 0, sizeof(*addr));
+
+    cssid = virXMLPropString(node, "cssid");
+    ssid = virXMLPropString(node, "ssid");
+    devno = virXMLPropString(node, "devno");
+
+    if (cssid && ssid && devno) {
+        if (cssid &&
+            virStrToLong_uip(cssid, NULL, 0, &addr->cssid) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Cannot parse <address> 'cssid' attribute"));
+            goto cleanup;
+        }
+        if (ssid &&
+            virStrToLong_uip(ssid, NULL, 0, &addr->ssid) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Cannot parse <address> 'ssid' attribute"));
+            goto cleanup;
+        }
+        if (devno &&
+            virStrToLong_uip(devno, NULL, 0, &addr->devno) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Cannot parse <address> 'devno' attribute"));
+            goto cleanup;
+        }
+        if (!virDomainDeviceCCWAddressIsValid(addr)) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Invalid specification for virtio ccw"
+                             " address: cssid='%s' ssid='%s' devno='%s'"),
+                           cssid, ssid, devno);
+            goto cleanup;
+        }
+        addr->assigned = true;
+    } else if (cssid || ssid || devno) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Invalid partial specification for virtio ccw"
+                         " address"));
+        goto cleanup;
+    }
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(cssid);
+    VIR_FREE(ssid);
+    VIR_FREE(devno);
+    return ret;
+}
+
+int
+virDomainDeviceDriveAddressParseXML(xmlNodePtr node,
+                                    virDomainDeviceDriveAddressPtr addr)
+{
+    char *bus, *unit, *controller, *target;
+    int ret = -1;
+
+    memset(addr, 0, sizeof(*addr));
+
+    controller = virXMLPropString(node, "controller");
+    bus = virXMLPropString(node, "bus");
+    target = virXMLPropString(node, "target");
+    unit = virXMLPropString(node, "unit");
+
+    if (controller &&
+        virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'controller' attribute"));
+        goto cleanup;
+    }
+
+    if (bus &&
+        virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'bus' attribute"));
+        goto cleanup;
+    }
+
+    if (target &&
+        virStrToLong_uip(target, NULL, 10, &addr->target) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'target' attribute"));
+        goto cleanup;
+    }
+
+    if (unit &&
+        virStrToLong_uip(unit, NULL, 10, &addr->unit) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'unit' attribute"));
+        goto cleanup;
+    }
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(controller);
+    VIR_FREE(bus);
+    VIR_FREE(target);
+    VIR_FREE(unit);
+    return ret;
+}
+
+int
+virDomainDeviceVirtioSerialAddressParseXML(xmlNodePtr node,
+                                           virDomainDeviceVirtioSerialAddressPtr addr)
+{
+    char *controller, *bus, *port;
+    int ret = -1;
+
+    memset(addr, 0, sizeof(*addr));
+
+    controller = virXMLPropString(node, "controller");
+    bus = virXMLPropString(node, "bus");
+    port = virXMLPropString(node, "port");
+
+    if (controller &&
+        virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'controller' attribute"));
+        goto cleanup;
+    }
+
+    if (bus &&
+        virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'bus' attribute"));
+        goto cleanup;
+    }
+
+    if (port &&
+        virStrToLong_uip(port, NULL, 10, &addr->port) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'port' attribute"));
+        goto cleanup;
+    }
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(controller);
+    VIR_FREE(bus);
+    VIR_FREE(port);
+    return ret;
+}
+
+int
+virDomainDeviceCcidAddressParseXML(xmlNodePtr node,
+                                   virDomainDeviceCcidAddressPtr addr)
+{
+    char *controller, *slot;
+    int ret = -1;
+
+    memset(addr, 0, sizeof(*addr));
+
+    controller = virXMLPropString(node, "controller");
+    slot = virXMLPropString(node, "slot");
+
+    if (controller &&
+        virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'controller' attribute"));
+        goto cleanup;
+    }
+
+    if (slot &&
+        virStrToLong_uip(slot, NULL, 10, &addr->slot) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'slot' attribute"));
+        goto cleanup;
+    }
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(controller);
+    VIR_FREE(slot);
+    return ret;
+}
+
+static int
+virDomainDeviceUSBAddressParsePort(virDomainDeviceUSBAddressPtr addr,
+                                   char *port)
+{
+    char *tmp = port;
+    size_t i;
+
+    for (i = 0; i < VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH; i++) {
+        if (virStrToLong_uip(tmp, &tmp, 10, &addr->port[i]) < 0)
+            break;
+
+        if (*tmp == '\0')
+            return 0;
+
+        if (*tmp == '.')
+            tmp++;
+    }
+
+    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                   _("Cannot parse <address> 'port' attribute"));
+    return -1;
+}
+
+int
+virDomainDeviceUSBAddressParseXML(xmlNodePtr node,
+                                  virDomainDeviceUSBAddressPtr addr)
+{
+    char *port, *bus;
+    int ret = -1;
+
+    memset(addr, 0, sizeof(*addr));
+
+    port = virXMLPropString(node, "port");
+    bus = virXMLPropString(node, "bus");
+
+    if (port && virDomainDeviceUSBAddressParsePort(addr, port) < 0)
+        goto cleanup;
+
+    if (bus &&
+        virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Cannot parse <address> 'bus' attribute"));
+        goto cleanup;
+    }
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(bus);
+    VIR_FREE(port);
+    return ret;
+}
+
+int
+virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node,
+                                      virDomainDeviceSpaprVioAddressPtr addr)
+{
+    char *reg;
+    int ret;
+
+    memset(addr, 0, sizeof(*addr));
+
+    reg = virXMLPropString(node, "reg");
+    if (reg) {
+        if (virStrToLong_ull(reg, NULL, 16, &addr->reg) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Cannot parse <address> 'reg' attribute"));
+            ret = -1;
+            goto cleanup;
+        }
+
+        addr->has_reg = true;
+    }
+
+    ret = 0;
+ cleanup:
+    VIR_FREE(reg);
+    return ret;
+}
+
 bool
 virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                               int type)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index c23a5918b3..33146f0caa 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -212,6 +212,23 @@ bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
                               virPCIDeviceAddress *addr2);
 
 bool virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr);
+int virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
+                                      virDomainDeviceCCWAddressPtr addr);
+
+int virDomainDeviceDriveAddressParseXML(xmlNodePtr node,
+                                        virDomainDeviceDriveAddressPtr addr);
+
+int virDomainDeviceVirtioSerialAddressParseXML(xmlNodePtr node,
+                                               virDomainDeviceVirtioSerialAddressPtr addr);
+
+int virDomainDeviceCcidAddressParseXML(xmlNodePtr node,
+                                       virDomainDeviceCcidAddressPtr addr);
+
+int virDomainDeviceUSBAddressParseXML(xmlNodePtr node,
+                                      virDomainDeviceUSBAddressPtr addr);
+
+int virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node,
+                                           virDomainDeviceSpaprVioAddressPtr addr);
 
 int virInterfaceLinkParseXML(xmlNodePtr node,
                              virNetDevIfLinkPtr lnk);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3cae6b2aeb..7a52fc1e81 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6538,276 +6538,6 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
     virBufferAddLit(buf, "/>\n");
 }
 
-static int
-virDomainDeviceDriveAddressParseXML(xmlNodePtr node,
-                                    virDomainDeviceDriveAddressPtr addr)
-{
-    char *bus, *unit, *controller, *target;
-    int ret = -1;
-
-    memset(addr, 0, sizeof(*addr));
-
-    controller = virXMLPropString(node, "controller");
-    bus = virXMLPropString(node, "bus");
-    target = virXMLPropString(node, "target");
-    unit = virXMLPropString(node, "unit");
-
-    if (controller &&
-        virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'controller' attribute"));
-        goto cleanup;
-    }
-
-    if (bus &&
-        virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'bus' attribute"));
-        goto cleanup;
-    }
-
-    if (target &&
-        virStrToLong_uip(target, NULL, 10, &addr->target) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'target' attribute"));
-        goto cleanup;
-    }
-
-    if (unit &&
-        virStrToLong_uip(unit, NULL, 10, &addr->unit) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'unit' attribute"));
-        goto cleanup;
-    }
-
-    ret = 0;
-
- cleanup:
-    VIR_FREE(controller);
-    VIR_FREE(bus);
-    VIR_FREE(target);
-    VIR_FREE(unit);
-    return ret;
-}
-
-
-static int
-virDomainDeviceVirtioSerialAddressParseXML(
-    xmlNodePtr node,
-    virDomainDeviceVirtioSerialAddressPtr addr
-)
-{
-    char *controller, *bus, *port;
-    int ret = -1;
-
-    memset(addr, 0, sizeof(*addr));
-
-    controller = virXMLPropString(node, "controller");
-    bus = virXMLPropString(node, "bus");
-    port = virXMLPropString(node, "port");
-
-    if (controller &&
-        virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'controller' attribute"));
-        goto cleanup;
-    }
-
-    if (bus &&
-        virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'bus' attribute"));
-        goto cleanup;
-    }
-
-    if (port &&
-        virStrToLong_uip(port, NULL, 10, &addr->port) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'port' attribute"));
-        goto cleanup;
-    }
-
-    ret = 0;
-
- cleanup:
-    VIR_FREE(controller);
-    VIR_FREE(bus);
-    VIR_FREE(port);
-    return ret;
-}
-
-static int
-virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
-                                  virDomainDeviceCCWAddressPtr addr)
-{
-    int   ret = -1;
-    char *cssid;
-    char *ssid;
-    char *devno;
-
-    memset(addr, 0, sizeof(*addr));
-
-    cssid = virXMLPropString(node, "cssid");
-    ssid = virXMLPropString(node, "ssid");
-    devno = virXMLPropString(node, "devno");
-
-    if (cssid && ssid && devno) {
-        if (cssid &&
-            virStrToLong_uip(cssid, NULL, 0, &addr->cssid) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Cannot parse <address> 'cssid' attribute"));
-            goto cleanup;
-        }
-        if (ssid &&
-            virStrToLong_uip(ssid, NULL, 0, &addr->ssid) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Cannot parse <address> 'ssid' attribute"));
-            goto cleanup;
-        }
-        if (devno &&
-            virStrToLong_uip(devno, NULL, 0, &addr->devno) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Cannot parse <address> 'devno' attribute"));
-            goto cleanup;
-        }
-        if (!virDomainDeviceCCWAddressIsValid(addr)) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Invalid specification for virtio ccw"
-                             " address: cssid='%s' ssid='%s' devno='%s'"),
-                           cssid, ssid, devno);
-            goto cleanup;
-        }
-        addr->assigned = true;
-    } else if (cssid || ssid || devno) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Invalid partial specification for virtio ccw"
-                         " address"));
-        goto cleanup;
-    }
-
-    ret = 0;
-
- cleanup:
-    VIR_FREE(cssid);
-    VIR_FREE(ssid);
-    VIR_FREE(devno);
-    return ret;
-}
-
-static int
-virDomainDeviceCcidAddressParseXML(xmlNodePtr node,
-                                   virDomainDeviceCcidAddressPtr addr)
-{
-    char *controller, *slot;
-    int ret = -1;
-
-    memset(addr, 0, sizeof(*addr));
-
-    controller = virXMLPropString(node, "controller");
-    slot = virXMLPropString(node, "slot");
-
-    if (controller &&
-        virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'controller' attribute"));
-        goto cleanup;
-    }
-
-    if (slot &&
-        virStrToLong_uip(slot, NULL, 10, &addr->slot) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'slot' attribute"));
-        goto cleanup;
-    }
-
-    ret = 0;
-
- cleanup:
-    VIR_FREE(controller);
-    VIR_FREE(slot);
-    return ret;
-}
-
-static int
-virDomainDeviceUSBAddressParsePort(virDomainDeviceUSBAddressPtr addr,
-                                   char *port)
-{
-    char *tmp = port;
-    size_t i;
-
-    for (i = 0; i < VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH; i++) {
-        if (virStrToLong_uip(tmp, &tmp, 10, &addr->port[i]) < 0)
-            break;
-
-        if (*tmp == '\0')
-            return 0;
-
-        if (*tmp == '.')
-            tmp++;
-    }
-
-    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                   _("Cannot parse <address> 'port' attribute"));
-    return -1;
-}
-
-static int
-virDomainDeviceUSBAddressParseXML(xmlNodePtr node,
-                                  virDomainDeviceUSBAddressPtr addr)
-{
-    char *port, *bus;
-    int ret = -1;
-
-    memset(addr, 0, sizeof(*addr));
-
-    port = virXMLPropString(node, "port");
-    bus = virXMLPropString(node, "bus");
-
-    if (port && virDomainDeviceUSBAddressParsePort(addr, port) < 0)
-        goto cleanup;
-
-    if (bus &&
-        virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'bus' attribute"));
-        goto cleanup;
-    }
-
-    ret = 0;
-
- cleanup:
-    VIR_FREE(bus);
-    VIR_FREE(port);
-    return ret;
-}
-
-static int
-virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node,
-                                      virDomainDeviceSpaprVioAddressPtr addr)
-{
-    char *reg;
-    int ret;
-
-    memset(addr, 0, sizeof(*addr));
-
-    reg = virXMLPropString(node, "reg");
-    if (reg) {
-        if (virStrToLong_ull(reg, NULL, 16, &addr->reg) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Cannot parse <address> 'reg' attribute"));
-            ret = -1;
-            goto cleanup;
-        }
-
-        addr->has_reg = true;
-    }
-
-    ret = 0;
- cleanup:
-    VIR_FREE(reg);
-    return ret;
-}
-
 static int
 virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
                                  virDomainDeviceUSBMasterPtr master)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 44bf54da81..6711cce02d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -97,9 +97,15 @@ virDeviceInfoPCIAddressIsPresent;
 virDeviceInfoPCIAddressIsWanted;
 virDomainDeviceAddressIsValid;
 virDomainDeviceAddressTypeToString;
+virDomainDeviceCcidAddressParseXML;
 virDomainDeviceCCWAddressIsValid;
+virDomainDeviceCCWAddressParseXML;
+virDomainDeviceDriveAddressParseXML;
 virDomainDeviceInfoAddressIsEqual;
 virDomainDeviceInfoCopy;
+virDomainDeviceSpaprVioAddressParseXML;
+virDomainDeviceUSBAddressParseXML;
+virDomainDeviceVirtioSerialAddressParseXML;
 virInterfaceLinkFormat;
 virInterfaceLinkParseXML;
 virPCIDeviceAddressAsString;
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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