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

[libvirt] [PATCH 01/15] Prerequisite Patch. virDomainDevicePCIAddress and respective functions moved to a new file called conf/device_conf.ch



Refactoring existing code without causing any functional changes to prepare for new code.
This patch makes the code reusable.

Signed-off-by: Shradha Shah <sshah solarflare com>
---
 include/libvirt/virterror.h  |    1 +
 src/Makefile.am              |    6 ++-
 src/conf/device_conf.c       |  135 ++++++++++++++++++++++++++++++++++++++++++
 src/conf/device_conf.h       |   65 ++++++++++++++++++++
 src/conf/domain_conf.c       |  114 ++++-------------------------------
 src/conf/domain_conf.h       |   25 +-------
 src/libvirt_private.syms     |   10 ++-
 src/qemu/qemu_command.c      |   13 ++--
 src/qemu/qemu_hotplug.c      |    7 +-
 src/qemu/qemu_monitor.c      |   14 ++--
 src/qemu/qemu_monitor.h      |   17 +++---
 src/qemu/qemu_monitor_json.c |   14 ++--
 src/qemu/qemu_monitor_json.h |   14 ++--
 src/qemu/qemu_monitor_text.c |   16 +++---
 src/qemu/qemu_monitor_text.h |   14 ++--
 src/util/virterror.c         |    3 +-
 src/xen/xend_internal.c      |    3 +-
 17 files changed, 290 insertions(+), 181 deletions(-)

diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index ad8e101..a3516f6 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -110,6 +110,7 @@ typedef enum {
     VIR_FROM_AUTH = 46,         /* Error from auth handling */
     VIR_FROM_DBUS = 47,         /* Error from DBus */
     VIR_FROM_PARALLELS = 48,    /* Error from Parallels */
+    VIR_FROM_DEVICE = 49,       /* Error from Device */
 
 # ifdef VIR_ENUM_SENTINELS
     VIR_ERR_DOMAIN_LAST
diff --git a/src/Makefile.am b/src/Makefile.am
index 6ed4a41..d6ebfdf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -200,6 +200,9 @@ CONSOLE_CONF_SOURCES =						\
 DOMAIN_LIST_SOURCES =						\
 		conf/virdomainlist.c conf/virdomainlist.h
 
+DEVICE_CONF_SOURCES =                                           \
+		conf/device_conf.c conf/device_conf.h
+
 CONF_SOURCES =							\
 		$(NETDEV_CONF_SOURCES)				\
 		$(DOMAIN_CONF_SOURCES)				\
@@ -213,7 +216,8 @@ CONF_SOURCES =							\
 		$(SECRET_CONF_SOURCES)				\
 		$(CPU_CONF_SOURCES)				\
 		$(CONSOLE_CONF_SOURCES)				\
-		$(DOMAIN_LIST_SOURCES)
+		$(DOMAIN_LIST_SOURCES)				\
+		$(DEVICE_CONF_SOURCES)
 
 # The remote RPC driver, covering domains, storage, networks, etc
 REMOTE_DRIVER_GENERATED = \
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
new file mode 100644
index 0000000..d4eb764
--- /dev/null
+++ b/src/conf/device_conf.c
@@ -0,0 +1,135 @@
+/*
+ * device_conf.h: device XML handling
+ *
+ * Copyright (C) 2006-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Shradha Shah <sshah solarflare com>
+ */
+
+#include <config.h>
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "memory.h"
+#include "xml.h"
+#include "uuid.h"
+#include "util.h"
+#include "buf.h"
+#include "conf/device_conf.h"
+
+#define VIR_FROM_THIS VIR_FROM_DEVICE
+
+#define virDeviceReportError(code, ...)                              \
+    virReportErrorHelper(VIR_FROM_DEVICE, code, __FILE__,            \
+                         __FUNCTION__, __LINE__, __VA_ARGS__)
+
+VIR_ENUM_IMPL(virDeviceAddressPciMulti,
+              VIR_DEVICE_ADDRESS_PCI_MULTI_LAST,
+              "default",
+              "on",
+              "off")
+
+int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr)
+{
+    /* PCI bus has 32 slots and 8 functions per slot */
+    if (addr->slot >= 32 || addr->function >= 8)
+        return 0;
+    return addr->domain || addr->bus || addr->slot;
+}
+
+
+int
+virDevicePCIAddressParseXML(xmlNodePtr node,
+                            virDevicePCIAddressPtr addr)
+{
+    char *domain, *slot, *bus, *function, *multi;
+    int ret = -1;
+
+    memset(addr, 0, sizeof(*addr));
+
+    domain   = virXMLPropString(node, "domain");
+    bus      = virXMLPropString(node, "bus");
+    slot     = virXMLPropString(node, "slot");
+    function = virXMLPropString(node, "function");
+    multi    = virXMLPropString(node, "multifunction");
+
+    if (domain &&
+        virStrToLong_ui(domain, NULL, 0, &addr->domain) < 0) {
+        virDeviceReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                             _("Cannot parse <address> 'domain' attribute"));
+        goto cleanup;
+    }
+
+    if (bus &&
+        virStrToLong_ui(bus, NULL, 0, &addr->bus) < 0) {
+        virDeviceReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                             _("Cannot parse <address> 'bus' attribute"));
+        goto cleanup;
+    }
+
+    if (slot &&
+        virStrToLong_ui(slot, NULL, 0, &addr->slot) < 0) {
+        virDeviceReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                             _("Cannot parse <address> 'slot' attribute"));
+        goto cleanup;
+    }
+
+    if (function &&
+        virStrToLong_ui(function, NULL, 0, &addr->function) < 0) {
+        virDeviceReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                             _("Cannot parse <address> 'function' attribute"));
+        goto cleanup;
+    }
+
+    if (multi &&
+        ((addr->multi = virDeviceAddressPciMultiTypeFromString(multi)) <= 0)) {
+        virDeviceReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                             _("Unknown value '%s' for <address> 'multifunction' attribute"),
+                             multi);
+        goto cleanup;
+
+    }
+    if (!virDevicePCIAddressIsValid(addr)) {
+        virDeviceReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                             _("Insufficient specification for PCI address"));
+        goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    VIR_FREE(domain);
+    VIR_FREE(bus);
+    VIR_FREE(slot);
+    VIR_FREE(function);
+    VIR_FREE(multi);
+    return ret;
+}
+
+int
+virDevicePCIAddressFormat(virBufferPtr buf,
+                          virDevicePCIAddress addr,
+                          bool includeTypeInAddr)
+{
+    virBufferAsprintf(buf, "    <address %sdomain='0x%.4x' bus='0x%.2x' "
+                      "slot='0x%.2x' function='0x%.1x'/>\n",
+                      includeTypeInAddr ? "type='pci' " : "",
+                      addr.domain,
+                      addr.bus,
+                      addr.slot,
+                      addr.function);
+    return 0;
+}
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
new file mode 100644
index 0000000..b060798
--- /dev/null
+++ b/src/conf/device_conf.h
@@ -0,0 +1,65 @@
+/*
+ * device_conf.h: device XML handling entry points
+ *
+ * Copyright (C) 2006-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Shradha Shah <sshah solarflare com>
+ */
+
+#ifndef __DEVICE_CONF_H__
+# define __DEVICE_CONF_H__
+
+# include <libxml/parser.h>
+# include <libxml/tree.h>
+# include <libxml/xpath.h>
+
+# include "internal.h"
+# include "util.h"
+# include "threads.h"
+# include "buf.h" 
+
+enum virDeviceAddressPciMulti {
+    VIR_DEVICE_ADDRESS_PCI_MULTI_DEFAULT = 0,
+    VIR_DEVICE_ADDRESS_PCI_MULTI_ON,
+    VIR_DEVICE_ADDRESS_PCI_MULTI_OFF,
+
+    VIR_DEVICE_ADDRESS_PCI_MULTI_LAST
+};
+
+typedef struct _virDevicePCIAddress virDevicePCIAddress;
+typedef virDevicePCIAddress *virDevicePCIAddressPtr;
+struct _virDevicePCIAddress {
+    unsigned int domain;
+    unsigned int bus;
+    unsigned int slot;
+    unsigned int function;
+    int          multi;  /* enum virDomainDeviceAddressPciMulti */
+};
+
+int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr);
+
+int virDevicePCIAddressParseXML(xmlNodePtr node,
+                                virDevicePCIAddressPtr addr);
+
+int virDevicePCIAddressFormat(virBufferPtr buf,
+                              virDevicePCIAddress addr,
+                              bool includeTypeInAddr);
+
+
+VIR_ENUM_DECL(virDeviceAddressPciMulti)
+
+#endif /* __DEVICE_CONF_H__ */
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d8c0969..ecad6cc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -52,6 +52,7 @@
 #include "netdev_vport_profile_conf.h"
 #include "netdev_bandwidth_conf.h"
 #include "virdomainlist.h"
+#include "device_conf.h"
 
 #define VIR_FROM_THIS VIR_FROM_DOMAIN
 
@@ -153,12 +154,6 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
               "spapr-vio",
               "virtio-s390")
 
-VIR_ENUM_IMPL(virDomainDeviceAddressPciMulti,
-              VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_LAST,
-              "default",
-              "on",
-              "off")
-
 VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST,
               "block",
               "file",
@@ -1897,7 +1892,7 @@ int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
 
     switch (info->type) {
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
-        return virDomainDevicePCIAddressIsValid(&info->addr.pci);
+        return virDevicePCIAddressIsValid(&info->addr.pci);
 
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
         return 1;
@@ -1909,16 +1904,6 @@ int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
     return 0;
 }
 
-
-int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr)
-{
-    /* PCI bus has 32 slots and 8 functions per slot */
-    if (addr->slot >= 32 || addr->function >= 8)
-        return 0;
-    return addr->domain || addr->bus || addr->slot;
-}
-
-
 static bool
 virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info, unsigned int flags)
 {
@@ -2143,7 +2128,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
                           info->addr.pci.function);
         if (info->addr.pci.multi) {
            virBufferAsprintf(buf, " multifunction='%s'",
-                             virDomainDeviceAddressPciMultiTypeToString(info->addr.pci.multi));
+                             virDeviceAddressPciMultiTypeToString(info->addr.pci.multi));
         }
         break;
 
@@ -2191,75 +2176,6 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
 }
 
 static int
-virDomainDevicePCIAddressParseXML(xmlNodePtr node,
-                                  virDomainDevicePCIAddressPtr addr)
-{
-    char *domain, *slot, *bus, *function, *multi;
-    int ret = -1;
-
-    memset(addr, 0, sizeof(*addr));
-
-    domain   = virXMLPropString(node, "domain");
-    bus      = virXMLPropString(node, "bus");
-    slot     = virXMLPropString(node, "slot");
-    function = virXMLPropString(node, "function");
-    multi    = virXMLPropString(node, "multifunction");
-
-    if (domain &&
-        virStrToLong_ui(domain, NULL, 0, &addr->domain) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'domain' attribute"));
-        goto cleanup;
-    }
-
-    if (bus &&
-        virStrToLong_ui(bus, NULL, 0, &addr->bus) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'bus' attribute"));
-        goto cleanup;
-    }
-
-    if (slot &&
-        virStrToLong_ui(slot, NULL, 0, &addr->slot) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'slot' attribute"));
-        goto cleanup;
-    }
-
-    if (function &&
-        virStrToLong_ui(function, NULL, 0, &addr->function) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot parse <address> 'function' attribute"));
-        goto cleanup;
-    }
-
-    if (multi &&
-        ((addr->multi = virDomainDeviceAddressPciMultiTypeFromString(multi)) <= 0)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Unknown value '%s' for <address> 'multifunction' attribute"),
-                       multi);
-        goto cleanup;
-
-    }
-    if (!virDomainDevicePCIAddressIsValid(addr)) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Insufficient specification for PCI address"));
-        goto cleanup;
-    }
-
-    ret = 0;
-
-cleanup:
-    VIR_FREE(domain);
-    VIR_FREE(bus);
-    VIR_FREE(slot);
-    VIR_FREE(function);
-    VIR_FREE(multi);
-    return ret;
-}
-
-
-static int
 virDomainDeviceDriveAddressParseXML(xmlNodePtr node,
                                     virDomainDeviceDriveAddressPtr addr)
 {
@@ -2620,7 +2536,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
 
     switch (info->type) {
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
-        if (virDomainDevicePCIAddressParseXML(address, &info->addr.pci) < 0)
+        if (virDevicePCIAddressParseXML(address, &info->addr.pci) < 0)
             goto cleanup;
         break;
 
@@ -2668,7 +2584,7 @@ cleanup:
 
 static int
 virDomainParseLegacyDeviceAddress(char *devaddr,
-                                  virDomainDevicePCIAddressPtr pci)
+                                  virDevicePCIAddressPtr pci)
 {
     char *tmp;
 
@@ -2853,10 +2769,10 @@ virDomainHostdevSubsysPciDefParseXML(const xmlNodePtr node,
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
             if (xmlStrEqual(cur->name, BAD_CAST "address")) {
-                virDomainDevicePCIAddressPtr addr =
+                virDevicePCIAddressPtr addr =
                     &def->source.subsys.u.pci;
 
-                if (virDomainDevicePCIAddressParseXML(cur, addr) < 0)
+                if (virDevicePCIAddressParseXML(cur, addr) < 0)
                     goto out;
             } else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) &&
                        xmlStrEqual(cur->name, BAD_CAST "state")) {
@@ -11519,14 +11435,12 @@ virDomainHostdevSourceFormat(virBufferPtr buf,
         }
         break;
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
-        virBufferAsprintf(buf, "  <address %sdomain='0x%.4x' bus='0x%.2x' "
-                          "slot='0x%.2x' function='0x%.1x'/>\n",
-                          includeTypeInAddr ? "type='pci' " : "",
-                          def->source.subsys.u.pci.domain,
-                          def->source.subsys.u.pci.bus,
-                          def->source.subsys.u.pci.slot,
-                          def->source.subsys.u.pci.function);
-
+        if (virDevicePCIAddressFormat(buf, 
+                                      def->source.subsys.u.pci,
+                                      includeTypeInAddr) != 0)
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("PCI address Formatting failed"));
+        
         if ((flags & VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES) &&
             (def->origstates.states.pci.unbind_from_stub ||
              def->origstates.states.pci.remove_slot ||
@@ -11539,7 +11453,7 @@ virDomainHostdevSourceFormat(virBufferPtr buf,
             if (def->origstates.states.pci.reprobe)
                 virBufferAddLit(buf, "    <reprobe/>\n");
             virBufferAddLit(buf, "  </origstates>\n");
-        }
+        } 
         break;
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3f25ad2..a2e4816 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -44,6 +44,7 @@
 # include "virnetdevopenvswitch.h"
 # include "virnetdevbandwidth.h"
 # include "virobject.h"
+# include "device_conf.h"
 
 /* forward declarations of all device types, required by
  * virDomainDeviceDef
@@ -179,14 +180,6 @@ enum virDomainDeviceAddressType {
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
 };
 
-enum virDomainDeviceAddressPciMulti {
-    VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_DEFAULT = 0,
-    VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_ON,
-    VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_OFF,
-
-    VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_LAST
-};
-
 enum virDomainPciRombarMode {
     VIR_DOMAIN_PCI_ROMBAR_DEFAULT = 0,
     VIR_DOMAIN_PCI_ROMBAR_ON,
@@ -195,16 +188,6 @@ enum virDomainPciRombarMode {
     VIR_DOMAIN_PCI_ROMBAR_LAST
 };
 
-typedef struct _virDomainDevicePCIAddress virDomainDevicePCIAddress;
-typedef virDomainDevicePCIAddress *virDomainDevicePCIAddressPtr;
-struct _virDomainDevicePCIAddress {
-    unsigned int domain;
-    unsigned int bus;
-    unsigned int slot;
-    unsigned int function;
-    int          multi;  /* enum virDomainDeviceAddressPciMulti */
-};
-
 typedef struct _virDomainDeviceDriveAddress virDomainDeviceDriveAddress;
 typedef virDomainDeviceDriveAddress *virDomainDeviceDriveAddressPtr;
 struct _virDomainDeviceDriveAddress {
@@ -266,7 +249,7 @@ struct _virDomainDeviceInfo {
     char *alias;
     int type;
     union {
-        virDomainDevicePCIAddress pci;
+        virDevicePCIAddress pci;
         virDomainDeviceDriveAddress drive;
         virDomainDeviceVirtioSerialAddress vioserial;
         virDomainDeviceCcidAddress ccid;
@@ -377,7 +360,7 @@ struct _virDomainHostdevSubsys {
             unsigned vendor;
             unsigned product;
         } usb;
-        virDomainDevicePCIAddress pci; /* host address */
+        virDevicePCIAddress pci; /* host address */
     } u;
 };
 
@@ -1897,7 +1880,6 @@ virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps,
                                              virDomainDeviceDefPtr src);
 int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                   int type);
-int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
 void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
 void virDomainDefClearPCIAddresses(virDomainDefPtr def);
 void virDomainDefClearDeviceAliases(virDomainDefPtr def);
@@ -2168,7 +2150,6 @@ VIR_ENUM_DECL(virDomainLifecycle)
 VIR_ENUM_DECL(virDomainLifecycleCrash)
 VIR_ENUM_DECL(virDomainDevice)
 VIR_ENUM_DECL(virDomainDeviceAddress)
-VIR_ENUM_DECL(virDomainDeviceAddressPciMulti)
 VIR_ENUM_DECL(virDomainDisk)
 VIR_ENUM_DECL(virDomainDiskDevice)
 VIR_ENUM_DECL(virDomainDiskBus)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c023dbf..f752f49 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -218,6 +218,13 @@ virStorageVolClass;
 virStreamClass;
 
 
+# device_conf.h
+virDeviceAddressPciMultiTypeFromString;
+virDeviceAddressPciMultiTypeToString;
+virDevicePCIAddressIsValid;
+virDevicePCIAddressParseXML;
+virDevicePCIAddressFormat;
+
 # dnsmasq.h
 dnsmasqAddDhcpHost;
 dnsmasqAddHost;
@@ -297,14 +304,11 @@ virDomainDefParseNode;
 virDomainDefParseString;
 virDomainDeleteConfig;
 virDomainDeviceAddressIsValid;
-virDomainDeviceAddressPciMultiTypeFromString;
-virDomainDeviceAddressPciMultiTypeToString;
 virDomainDeviceAddressTypeToString;
 virDomainDeviceDefCopy;
 virDomainDeviceDefFree;
 virDomainDeviceDefParse;
 virDomainDeviceInfoIterate;
-virDomainDevicePCIAddressIsValid;
 virDomainDeviceTypeToString;
 virDomainDiskBusTypeToString;
 virDomainDiskCacheTypeFromString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9383530..6f6c6cd 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -40,6 +40,7 @@
 #include "network/bridge_driver.h"
 #include "virnetdevtap.h"
 #include "base64.h"
+#include "device_conf.h"
 
 #include <sys/utsname.h>
 #include <sys/stat.h>
@@ -1027,7 +1028,7 @@ static int qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
     addr = NULL;
 
     if ((info->addr.pci.function == 0) &&
-        (info->addr.pci.multi != VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_ON)) {
+        (info->addr.pci.multi != VIR_DEVICE_ADDRESS_PCI_MULTI_ON)) {
         /* a function 0 w/o multifunction=on must reserve the entire slot */
         int function;
         virDomainDeviceInfo temp_info = *info;
@@ -1610,7 +1611,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
 
         /* USB2 needs special handling to put all companions in the same slot */
         if (IS_USB2_CONTROLLER(def->controllers[i])) {
-            virDomainDevicePCIAddress addr = { 0, 0, 0, 0, false };
+            virDevicePCIAddress addr = { 0, 0, 0, 0, false };
             for (j = 0 ; j < i ; j++) {
                 if (IS_USB2_CONTROLLER(def->controllers[j]) &&
                     def->controllers[j]->idx == def->controllers[i]->idx) {
@@ -1625,7 +1626,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
                 break;
             case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1:
                 addr.function = 0;
-                addr.multi = VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_ON;
+                addr.multi = VIR_DEVICE_ADDRESS_PCI_MULTI_ON;
                 break;
             case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2:
                 addr.function = 1;
@@ -1779,7 +1780,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
                                  "are supported with this QEMU binary"));
                 return -1;
             }
-            if (info->addr.pci.multi == VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_ON) {
+            if (info->addr.pci.multi == VIR_DEVICE_ADDRESS_PCI_MULTI_ON) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("'multifunction=on' is not supported with "
                                  "this QEMU binary"));
@@ -1797,9 +1798,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
             virBufferAsprintf(buf, ",bus=pci.0");
         else
             virBufferAsprintf(buf, ",bus=pci");
-        if (info->addr.pci.multi == VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_ON)
+        if (info->addr.pci.multi == VIR_DEVICE_ADDRESS_PCI_MULTI_ON)
             virBufferAddLit(buf, ",multifunction=on");
-        else if (info->addr.pci.multi == VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_OFF)
+        else if (info->addr.pci.multi == VIR_DEVICE_ADDRESS_PCI_MULTI_OFF)
             virBufferAddLit(buf, ",multifunction=off");
         virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot);
         if (info->addr.pci.function != 0)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index e128e58..3eeeb29 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -43,6 +43,7 @@
 #include "virnetdev.h"
 #include "virnetdevbridge.h"
 #include "virnetdevtap.h"
+#include "device_conf.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -258,7 +259,7 @@ int qemuDomainAttachPciDiskDevice(virConnectPtr conn,
             }
         }
     } else {
-        virDomainDevicePCIAddress guestAddr = disk->info.addr.pci;
+        virDevicePCIAddress guestAddr = disk->info.addr.pci;
         ret = qemuMonitorAddPCIDisk(priv->mon,
                                     disk->src,
                                     type,
@@ -655,7 +656,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
     char *netstr = NULL;
     virNetDevVPortProfilePtr vport = NULL;
     int ret = -1;
-    virDomainDevicePCIAddress guestAddr;
+    virDevicePCIAddress guestAddr;
     int vlan;
     bool releaseaddr = false;
     bool iface_connected = false;
@@ -974,7 +975,7 @@ int qemuDomainAttachHostPciDevice(struct qemud_driver *driver,
                                          configfd, configfd_name);
         qemuDomainObjExitMonitorWithDriver(driver, vm);
     } else {
-        virDomainDevicePCIAddress guestAddr = hostdev->info->addr.pci;
+        virDevicePCIAddress guestAddr = hostdev->info->addr.pci;
 
         qemuDomainObjEnterMonitorWithDriver(driver, vm);
         ret = qemuMonitorAddPCIHostDevice(priv->mon,
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index b0f3bb6..6ce1839 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2151,8 +2151,8 @@ int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon,
 
 
 int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
-                                virDomainDevicePCIAddress *hostAddr,
-                                virDomainDevicePCIAddress *guestAddr)
+                                virDevicePCIAddress *hostAddr,
+                                virDevicePCIAddress *guestAddr)
 {
     int ret;
     VIR_DEBUG("mon=%p domain=%d bus=%d slot=%d function=%d",
@@ -2176,7 +2176,7 @@ int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
 int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
                           const char *path,
                           const char *bus,
-                          virDomainDevicePCIAddress *guestAddr)
+                          virDevicePCIAddress *guestAddr)
 {
     int ret;
     VIR_DEBUG("mon=%p path=%s bus=%s",
@@ -2198,7 +2198,7 @@ int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
 
 int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
                              const char *nicstr,
-                             virDomainDevicePCIAddress *guestAddr)
+                             virDevicePCIAddress *guestAddr)
 {
     int ret;
     VIR_DEBUG("mon=%p nicstr=%s", mon, nicstr);
@@ -2218,7 +2218,7 @@ int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
 
 
 int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
-                               virDomainDevicePCIAddress *guestAddr)
+                               virDevicePCIAddress *guestAddr)
 {
     int ret;
     VIR_DEBUG("mon=%p domain=%d bus=%d slot=%d function=%d",
@@ -2454,7 +2454,7 @@ int qemuMonitorGetPtyPaths(qemuMonitorPtr mon,
 
 int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
                                        const char *bus,
-                                       virDomainDevicePCIAddress *guestAddr)
+                                       virDevicePCIAddress *guestAddr)
 {
     VIR_DEBUG("mon=%p type=%s", mon, bus);
     int ret;
@@ -2476,7 +2476,7 @@ int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
 
 int qemuMonitorAttachDrive(qemuMonitorPtr mon,
                            const char *drivestr,
-                           virDomainDevicePCIAddress *controllerAddr,
+                           virDevicePCIAddress *controllerAddr,
                            virDomainDeviceDriveAddress *driveAddr)
 {
     VIR_DEBUG("mon=%p drivestr=%s domain=%d bus=%d slot=%d function=%d",
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 42f33d1..ad8d2f1 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -32,6 +32,7 @@
 # include "bitmap.h"
 # include "virhash.h"
 # include "json.h"
+# include "device_conf.h"
 
 typedef struct _qemuMonitor qemuMonitor;
 typedef qemuMonitor *qemuMonitorPtr;
@@ -415,8 +416,8 @@ int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon,
 
 
 int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
-                                virDomainDevicePCIAddress *hostAddr,
-                                virDomainDevicePCIAddress *guestAddr);
+                                virDevicePCIAddress *hostAddr,
+                                virDevicePCIAddress *guestAddr);
 
 /* XXX disk driver type eg,  qcow/etc.
  * XXX cache mode
@@ -424,17 +425,17 @@ int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
 int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
                           const char *path,
                           const char *bus,
-                          virDomainDevicePCIAddress *guestAddr);
+                          virDevicePCIAddress *guestAddr);
 
 /* XXX do we really want to hardcode 'nicstr' as the
  * sendable item here
  */
 int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
                              const char *nicstr,
-                             virDomainDevicePCIAddress *guestAddr);
+                             virDevicePCIAddress *guestAddr);
 
 int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
-                               virDomainDevicePCIAddress *guestAddr);
+                               virDevicePCIAddress *guestAddr);
 
 
 int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
@@ -473,11 +474,11 @@ int qemuMonitorGetPtyPaths(qemuMonitorPtr mon,
 
 int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
                                        const char *bus,
-                                       virDomainDevicePCIAddress *guestAddr);
+                                       virDevicePCIAddress *guestAddr);
 
 int qemuMonitorAttachDrive(qemuMonitorPtr mon,
                            const char *drivestr,
-                           virDomainDevicePCIAddress *controllerAddr,
+                           virDevicePCIAddress *controllerAddr,
                            virDomainDeviceDriveAddress *driveAddr);
 
 
@@ -485,7 +486,7 @@ typedef struct _qemuMonitorPCIAddress qemuMonitorPCIAddress;
 struct _qemuMonitorPCIAddress {
     unsigned int vendor;
     unsigned int product;
-    virDomainDevicePCIAddress addr;
+    virDevicePCIAddress addr;
 };
 
 int qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 3ede88d..7d577b9 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2628,8 +2628,8 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 
 
 int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
-                                    virDomainDevicePCIAddress *hostAddr ATTRIBUTE_UNUSED,
-                                    virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
+                                    virDevicePCIAddress *hostAddr ATTRIBUTE_UNUSED,
+                                    virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
 {
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                    _("pci_add not supported in JSON mode"));
@@ -2640,7 +2640,7 @@ int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                               const char *path ATTRIBUTE_UNUSED,
                               const char *bus ATTRIBUTE_UNUSED,
-                              virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
+                              virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
 {
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                    _("pci_add not supported in JSON mode"));
@@ -2650,7 +2650,7 @@ int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 
 int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                                  const char *nicstr ATTRIBUTE_UNUSED,
-                                 virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
+                                 virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
 {
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                    _("pci_add not supported in JSON mode"));
@@ -2659,7 +2659,7 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 
 
 int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
-                                   virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
+                                   virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
 {
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                    _("pci_del not supported in JSON mode"));
@@ -2916,7 +2916,7 @@ int qemuMonitorJSONGetPtyPaths(qemuMonitorPtr mon,
 
 int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                                            const char *bus ATTRIBUTE_UNUSED,
-                                           virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
+                                           virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
 {
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                    _("pci_add not supported in JSON mode"));
@@ -2955,7 +2955,7 @@ qemuMonitorJSONGetGuestDriveAddress(virJSONValuePtr reply,
 
 int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon,
                                const char *drivestr,
-                               virDomainDevicePCIAddress* controllerAddr,
+                               virDevicePCIAddress* controllerAddr,
                                virDomainDeviceDriveAddress* driveAddr)
 {
     int ret;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index e732178..3255007 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -163,20 +163,20 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon,
 
 
 int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
-                                    virDomainDevicePCIAddress *hostAddr,
-                                    virDomainDevicePCIAddress *guestAddr);
+                                    virDevicePCIAddress *hostAddr,
+                                    virDevicePCIAddress *guestAddr);
 
 int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
                               const char *path,
                               const char *bus,
-                              virDomainDevicePCIAddress *guestAddr);
+                              virDevicePCIAddress *guestAddr);
 
 int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
                                  const char *nicstr,
-                                 virDomainDevicePCIAddress *guestAddr);
+                                 virDevicePCIAddress *guestAddr);
 
 int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
-                                   virDomainDevicePCIAddress *guestAddr);
+                                   virDevicePCIAddress *guestAddr);
 
 int qemuMonitorJSONSendFileHandle(qemuMonitorPtr mon,
                                   const char *fdname,
@@ -203,11 +203,11 @@ int qemuMonitorJSONGetPtyPaths(qemuMonitorPtr mon,
 
 int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon,
                                            const char *bus,
-                                           virDomainDevicePCIAddress *guestAddr);
+                                           virDevicePCIAddress *guestAddr);
 
 int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon,
                                const char *drivestr,
-                               virDomainDevicePCIAddress *controllerAddr,
+                               virDevicePCIAddress *controllerAddr,
                                virDomainDeviceDriveAddress *driveAddr);
 
 int qemuMonitorJSONGetAllPCIAddresses(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index fa17927..a575e30 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1898,7 +1898,7 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon,
 static int
 qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                                 const char *reply,
-                                virDomainDevicePCIAddress *addr)
+                                virDevicePCIAddress *addr)
 {
     char *s, *e;
 
@@ -1960,8 +1960,8 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 
 
 int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
-                                    virDomainDevicePCIAddress *hostAddr,
-                                    virDomainDevicePCIAddress *guestAddr)
+                                    virDevicePCIAddress *hostAddr,
+                                    virDevicePCIAddress *guestAddr)
 {
     char *cmd;
     char *reply = NULL;
@@ -2006,7 +2006,7 @@ cleanup:
 int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
                               const char *path,
                               const char *bus,
-                              virDomainDevicePCIAddress *guestAddr)
+                              virDevicePCIAddress *guestAddr)
 {
     char *cmd = NULL;
     char *reply = NULL;
@@ -2058,7 +2058,7 @@ cleanup:
 
 int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
                                  const char *nicstr,
-                                 virDomainDevicePCIAddress *guestAddr)
+                                 virDevicePCIAddress *guestAddr)
 {
     char *cmd;
     char *reply = NULL;
@@ -2091,7 +2091,7 @@ cleanup:
 
 
 int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
-                                   virDomainDevicePCIAddress *guestAddr)
+                                   virDevicePCIAddress *guestAddr)
 {
     char *cmd = NULL;
     char *reply = NULL;
@@ -2439,7 +2439,7 @@ cleanup:
 
 int qemuMonitorTextAttachPCIDiskController(qemuMonitorPtr mon,
                                            const char *bus,
-                                           virDomainDevicePCIAddress *guestAddr)
+                                           virDevicePCIAddress *guestAddr)
 {
     char *cmd = NULL;
     char *reply = NULL;
@@ -2528,7 +2528,7 @@ qemudParseDriveAddReply(const char *reply,
 
 int qemuMonitorTextAttachDrive(qemuMonitorPtr mon,
                                const char *drivestr,
-                               virDomainDevicePCIAddress *controllerAddr,
+                               virDevicePCIAddress *controllerAddr,
                                virDomainDeviceDriveAddress *driveAddr)
 {
     char *cmd = NULL;
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index c6fd464..aca32a0 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -147,20 +147,20 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon,
 
 
 int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
-                                    virDomainDevicePCIAddress *hostAddr,
-                                    virDomainDevicePCIAddress *guestAddr);
+                                    virDevicePCIAddress *hostAddr,
+                                    virDevicePCIAddress *guestAddr);
 
 int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
                               const char *path,
                               const char *bus,
-                              virDomainDevicePCIAddress *guestAddr);
+                              virDevicePCIAddress *guestAddr);
 
 int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
                                  const char *nicstr,
-                                 virDomainDevicePCIAddress *guestAddr);
+                                 virDevicePCIAddress *guestAddr);
 
 int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
-                                   virDomainDevicePCIAddress *guestAddr);
+                                   virDevicePCIAddress *guestAddr);
 
 int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
                                   const char *fdname,
@@ -187,11 +187,11 @@ int qemuMonitorTextGetPtyPaths(qemuMonitorPtr mon,
 
 int qemuMonitorTextAttachPCIDiskController(qemuMonitorPtr mon,
                                            const char *bus,
-                                           virDomainDevicePCIAddress *guestAddr);
+                                           virDevicePCIAddress *guestAddr);
 
 int qemuMonitorTextAttachDrive(qemuMonitorPtr mon,
                                const char *drivestr,
-                               virDomainDevicePCIAddress *controllerAddr,
+                               virDevicePCIAddress *controllerAddr,
                                virDomainDeviceDriveAddress *driveAddr);
 
 int qemuMonitorTextGetAllPCIAddresses(qemuMonitorPtr mon,
diff --git a/src/util/virterror.c b/src/util/virterror.c
index a40cfe0..d630db8 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -112,7 +112,8 @@ VIR_ENUM_IMPL(virErrorDomain, VIR_ERR_DOMAIN_LAST,
               "URI Utils", /* 45 */
               "Authentication Utils",
               "DBus Utils",
-              "Parallels Cloud Server"
+              "Parallels Cloud Server",
+              "Device Config"
     )
 
 
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 892d0e5..f93b249 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -46,6 +46,7 @@
 #include "count-one-bits.h"
 #include "virfile.h"
 #include "viruri.h"
+#include "device_conf.h"
 
 /* required for cpumap_t */
 #include <xen/dom0_ops.h>
@@ -2725,7 +2726,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
             if (xenFormatSxprOnePCI(dev->data.hostdev, &buf, 0) < 0)
                 goto cleanup;
 
-            virDomainDevicePCIAddress PCIAddr;
+            virDevicePCIAddress PCIAddr;
 
             PCIAddr = dev->data.hostdev->source.subsys.u.pci;
             virAsprintf(&target, "PCI device: %.4x:%.2x:%.2x", PCIAddr.domain,
-- 
1.7.4.4



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