[PATCHv2 2/6] conf: put all host-related (source) HostdevDef data into one object

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

 



When <interface> is expanded to allow passthrough with extra
dev-dependent network interface info, the host-side address of the
device will need to be added to virDomainNetDef. It will be much
simpler if this is done with a common typedefed struct rather than
inlining the same struct stuff.

In the end, the virDomainHostdevDef really has two kinds of data -
data about the device as it exists on the host side (source), and data
about the device that is presented to the guest. All of the
guest-related data is already in the virDomainDeviceInfo info member
of the HostdevDef; this patch moves everything host-related into a new
virDomainDeviceSourceInfo source struct.

Much of this data was already in a union called source - that union
was moved into the newly define struct and made an anonymous union, so
that all references to its data can remain unchanged. That left only
the following items which needed to have "source." added to the
beginning of their references:

   origstates - this contains the original state of the device on the host,
                prior to attaching it to the guest.
   mode - "capabilities" or "subsystem". Only subsystem is ever used.
   managed - whether or not the device is managed (i.e. if it should
             be re-attached to the host after detaching from guest).
             (note that I changed this from a 1-bit bitfield to a bool
             while rearranging)

The entire virDomainHostdevDef now contains two structs and nothing
else. This will make it much easier to transplant PCI passthrough
functionality into virDomainNetDef (for example).
---

Change from V1: almost all of the patch! V1 of this patch just moved
the subsys data into its own struct. Although this isn't directly
related to adding romfile support (the declared purpose of the patch
series), this patch first so well with PATCH 1/6 that it makes sense
to push them together.

NB: in my local tree I re-ordered 1/6 and 2/6 while re-basing, so this
patch is now 1/6 and the other (which relocated with no conflicts) is
2/6.

 src/conf/domain_conf.c           |   42 ++++++++--------
 src/conf/domain_conf.h           |  102 +++++++++++++++++++++----------------
 src/qemu/qemu_cgroup.c           |    2 +-
 src/qemu/qemu_command.c          |   16 +++---
 src/qemu/qemu_hostdev.c          |   26 +++++-----
 src/qemu/qemu_hotplug.c          |   12 ++--
 src/security/security_apparmor.c |    2 +-
 src/security/security_dac.c      |    4 +-
 src/security/security_selinux.c  |    4 +-
 src/util/pci.c                   |    4 +-
 src/util/pci.h                   |    4 +-
 src/vbox/vbox_tmpl.c             |   10 ++--
 src/xen/xend_internal.c          |    6 +-
 src/xenxs/xen_sxpr.c             |   12 ++--
 src/xenxs/xen_xm.c               |    6 +-
 15 files changed, 133 insertions(+), 119 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8a35e6e..bb803d0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6146,7 +6146,7 @@ virDomainHostdevSubsysPciDefParseXML(const xmlNodePtr node,
                 def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
             } else if ((flags & VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES) &&
                        xmlStrEqual(cur->name, BAD_CAST "origstates")) {
-                virDomainHostdevOrigStatesPtr states = &def->origstates;
+                virDomainHostdevOrigStatesPtr states = &def->source.origstates;
                 if (virDomainHostdevSubsysPciOrigStatesDefParseXML(cur, states) < 0)
                     goto out;
             } else {
@@ -6181,13 +6181,13 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
 
     mode = virXMLPropString(node, "mode");
     if (mode) {
-        if ((def->mode=virDomainHostdevModeTypeFromString(mode)) < 0) {
+        if ((def->source.mode=virDomainHostdevModeTypeFromString(mode)) < 0) {
              virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                   _("unknown hostdev mode '%s'"), mode);
             goto error;
         }
     } else {
-        def->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
+        def->source.mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
     }
 
     type = virXMLPropString(node, "type");
@@ -6206,7 +6206,7 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
     managed = virXMLPropString(node, "managed");
     if (managed != NULL) {
         if (STREQ(managed, "yes"))
-            def->managed = 1;
+            def->source.managed = true;
         VIR_FREE(managed);
     }
 
@@ -6214,12 +6214,12 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
             if (xmlStrEqual(cur->name, BAD_CAST "source")) {
-                if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+                if (def->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
                     def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
                     if (virDomainHostdevSubsysUsbDefParseXML(cur, def) < 0)
                         goto error;
                 }
-                if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+                if (def->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
                     def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
                         if (virDomainHostdevSubsysPciDefParseXML(cur, def, flags) < 0)
                             goto error;
@@ -6259,7 +6259,7 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
             goto error;
     }
 
-    if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+    if (def->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
         switch (def->source.subsys.type) {
         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
             if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
@@ -8739,15 +8739,15 @@ static bool virDomainHostdevDefCheckABIStability(virDomainHostdevDefPtr src,
 {
     bool identical = false;
 
-    if (src->mode != dst->mode) {
+    if (src->source.mode != dst->source.mode) {
         virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                              _("Target host device mode %s does not match source %s"),
-                             virDomainHostdevModeTypeToString(dst->mode),
-                             virDomainHostdevModeTypeToString(src->mode));
+                             virDomainHostdevModeTypeToString(dst->source.mode),
+                             virDomainHostdevModeTypeToString(src->source.mode));
         goto cleanup;
     }
 
-    if (src->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+    if (src->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
         if (src->source.subsys.type != dst->source.subsys.type) {
             virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                  _("Target host device subsystem %s does not match source %s"),
@@ -11244,12 +11244,12 @@ virDomainHostdevDefFormat(virBufferPtr buf,
                           virDomainHostdevDefPtr def,
                           unsigned int flags)
 {
-    const char *mode = virDomainHostdevModeTypeToString(def->mode);
+    const char *mode = virDomainHostdevModeTypeToString(def->source.mode);
     const char *type;
 
-    if (!mode || def->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+    if (!mode || def->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
         virDomainReportError(VIR_ERR_INTERNAL_ERROR,
-                             _("unexpected hostdev mode %d"), def->mode);
+                             _("unexpected hostdev mode %d"), def->source.mode);
         return -1;
     }
 
@@ -11264,7 +11264,7 @@ virDomainHostdevDefFormat(virBufferPtr buf,
     }
 
     virBufferAsprintf(buf, "    <hostdev mode='%s' type='%s' managed='%s'>\n",
-                      mode, type, def->managed ? "yes" : "no");
+                      mode, type, def->source.managed ? "yes" : "no");
     virBufferAddLit(buf, "      <source>\n");
 
     if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
@@ -11288,15 +11288,15 @@ virDomainHostdevDefFormat(virBufferPtr buf,
                           def->source.subsys.u.pci.function);
 
         if ((flags & VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES) &&
-            (def->origstates.states.pci.unbind_from_stub ||
-             def->origstates.states.pci.remove_slot ||
-             def->origstates.states.pci.reprobe)) {
+            (def->source.origstates.states.pci.unbind_from_stub ||
+             def->source.origstates.states.pci.remove_slot ||
+             def->source.origstates.states.pci.reprobe)) {
             virBufferAddLit(buf, "        <origstates>\n");
-            if (def->origstates.states.pci.unbind_from_stub)
+            if (def->source.origstates.states.pci.unbind_from_stub)
                 virBufferAddLit(buf, "          <unbind/>\n");
-            if (def->origstates.states.pci.remove_slot)
+            if (def->source.origstates.states.pci.remove_slot)
                 virBufferAddLit(buf, "          <removeslot/>\n");
-            if (def->origstates.states.pci.reprobe)
+            if (def->source.origstates.states.pci.reprobe)
                 virBufferAddLit(buf, "          <reprobe/>\n");
             virBufferAddLit(buf, "        </origstates>\n");
         }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a2fffd1..2b66469 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -100,6 +100,16 @@ struct _virDomainDevicePCIAddress {
     int          multi;  /* enum virDomainDeviceAddressPciMulti */
 };
 
+typedef struct _virDomainDeviceSubsysUSBAddress virDomainDeviceSubsysUSBAddress;
+typedef virDomainDeviceSubsysUSBAddress *virDomainDeviceSubsysUSBAddressPtr;
+struct _virDomainDeviceSubsysUSBAddress {
+    unsigned bus;
+    unsigned device;
+
+    unsigned vendor;
+    unsigned product;
+};
+
 typedef struct _virDomainDeviceDriveAddress virDomainDeviceDriveAddress;
 typedef virDomainDeviceDriveAddress *virDomainDeviceDriveAddressPtr;
 struct _virDomainDeviceDriveAddress {
@@ -217,6 +227,54 @@ struct _virDomainHostdevOrigStates {
     } states;
 };
 
+enum virDomainHostdevSubsysType {
+    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
+    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
+
+    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
+};
+
+typedef struct _virDomainDeviceSubsysAddress virDomainDeviceSubsysAddress;
+typedef virDomainDeviceSubsysAddress *virDomainDeviceSubsysAddressPtr;
+struct _virDomainDeviceSubsysAddress {
+    int type; /* enum virDomainHostdevSubsysType */
+    union {
+        virDomainDeviceSubsysUSBAddress usb;
+        virDomainDevicePCIAddress pci; /* host address */
+    } u;
+};
+
+enum virDomainHostdevMode {
+    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
+    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
+
+    VIR_DOMAIN_HOSTDEV_MODE_LAST,
+};
+
+typedef struct _virDomainDeviceSourceInfo virDomainDeviceSourceInfo;
+typedef virDomainDeviceSourceInfo *virDomainDeviceSourceInfoPtr;
+struct _virDomainDeviceSourceInfo {
+    int mode; /* enum virDomainHostdevMode */
+    bool managed;
+    union {
+        virDomainDeviceSubsysAddress subsys; /* USB or PCI */
+        struct {
+            /* TBD: struct capabilities see:
+             * https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
+             */
+            int dummy;
+        } caps;
+    };
+    virDomainHostdevOrigStates origstates;
+};
+
+typedef struct _virDomainHostdevDef virDomainHostdevDef;
+typedef virDomainHostdevDef *virDomainHostdevDefPtr;
+struct _virDomainHostdevDef {
+    virDomainDeviceSourceInfo source; /* host address info */
+    virDomainDeviceInfo       info;   /* guest address info */
+};
+
 typedef struct _virDomainLeaseDef virDomainLeaseDef;
 typedef virDomainLeaseDef *virDomainLeaseDefPtr;
 struct _virDomainLeaseDef {
@@ -1070,50 +1128,6 @@ struct _virDomainGraphicsDef {
     virDomainGraphicsListenDefPtr listens;
 };
 
-enum virDomainHostdevMode {
-    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
-    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
-
-    VIR_DOMAIN_HOSTDEV_MODE_LAST,
-};
-
-enum virDomainHostdevSubsysType {
-    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
-    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
-
-    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
-};
-
-typedef struct _virDomainHostdevDef virDomainHostdevDef;
-typedef virDomainHostdevDef *virDomainHostdevDefPtr;
-struct _virDomainHostdevDef {
-    int mode; /* enum virDomainHostdevMode */
-    unsigned int managed : 1;
-    union {
-        struct {
-            int type; /* enum virDomainHostdevBusType */
-            union {
-                struct {
-                    unsigned bus;
-                    unsigned device;
-
-                    unsigned vendor;
-                    unsigned product;
-                } usb;
-                virDomainDevicePCIAddress pci; /* host address */
-            } u;
-        } subsys;
-        struct {
-            /* TBD: struct capabilities see:
-             * https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
-             */
-            int dummy;
-        } caps;
-    } source;
-    virDomainDeviceInfo info; /* Guest address */
-    virDomainHostdevOrigStates origstates;
-};
-
 enum virDomainRedirdevBus {
     VIR_DOMAIN_REDIRDEV_BUS_USB,
 
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 2d970d6..e384df2 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -282,7 +282,7 @@ int qemuSetupCgroup(struct qemud_driver *driver,
             virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
             usbDevice *usb;
 
-            if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+            if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
                 continue;
             if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)
                 continue;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fd170bf..54ccce1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1385,7 +1385,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
     for (i = 0; i < def->nhostdevs ; i++) {
         if (def->hostdevs[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
             continue;
-        if (def->hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+        if (def->hostdevs[i]->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
             def->hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
 
@@ -5548,7 +5548,7 @@ qemuBuildCommandLine(virConnectPtr conn,
         char *devstr;
 
         if (hostdev->info.bootIndex) {
-            if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+            if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
                 hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
                 qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                 _("booting from assigned devices is only"
@@ -5563,7 +5563,7 @@ qemuBuildCommandLine(virConnectPtr conn,
         }
 
         /* USB */
-        if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+        if (hostdev->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
 
             if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
@@ -5582,7 +5582,7 @@ qemuBuildCommandLine(virConnectPtr conn,
         }
 
         /* PCI */
-        if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+        if (hostdev->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
             if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
                 char *configfd_name = NULL;
@@ -6538,8 +6538,8 @@ qemuParseCommandLinePCI(const char *val)
         goto cleanup;
     }
 
-    def->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
-    def->managed = 1;
+    def->source.mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
+    def->source.managed = true;
     def->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
     def->source.subsys.u.pci.bus = bus;
     def->source.subsys.u.pci.slot = slot;
@@ -6604,8 +6604,8 @@ qemuParseCommandLineUSB(const char *val)
         goto cleanup;
     }
 
-    def->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
-    def->managed = 0;
+    def->source.mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
+    def->source.managed = false;
     def->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB;
     if (*end == '.') {
         def->source.subsys.u.usb.bus = first;
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index b3cad8e..99fd4bc 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -43,7 +43,7 @@ qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
         virDomainHostdevDefPtr hostdev = hostdevs[i];
         pciDevice *dev;
 
-        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+        if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
             continue;
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
@@ -63,7 +63,7 @@ qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
             return NULL;
         }
 
-        pciDeviceSetManaged(dev, hostdev->managed);
+        pciDeviceSetManaged(dev, hostdev->source.managed);
     }
 
     return list;
@@ -85,7 +85,7 @@ qemuGetActivePciHostDeviceList(struct qemud_driver *driver,
         pciDevice *dev;
         pciDevice *activeDev;
 
-        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+        if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
             continue;
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
@@ -126,7 +126,7 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
         pciDevice *dev = NULL;
         hostdev = def->hostdevs[i];
 
-        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+        if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
             continue;
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
@@ -139,13 +139,13 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
         if (!dev)
             return -1;
 
-        pciDeviceSetManaged(dev, hostdev->managed);
+        pciDeviceSetManaged(dev, hostdev->source.managed);
         pciDeviceSetUsedBy(dev, def->name);
 
         /* Setup the original states for the PCI device */
-        pciDeviceSetUnbindFromStub(dev, hostdev->origstates.states.pci.unbind_from_stub);
-        pciDeviceSetRemoveSlot(dev, hostdev->origstates.states.pci.remove_slot);
-        pciDeviceSetReprobe(dev, hostdev->origstates.states.pci.reprobe);
+        pciDeviceSetUnbindFromStub(dev, hostdev->source.origstates.states.pci.unbind_from_stub);
+        pciDeviceSetRemoveSlot(dev, hostdev->source.origstates.states.pci.remove_slot);
+        pciDeviceSetReprobe(dev, hostdev->source.origstates.states.pci.reprobe);
 
         if (pciDeviceListAdd(driver->activePciHostdevs, dev) < 0) {
             pciFreeDevice(dev);
@@ -258,7 +258,7 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
         pciDevice *pcidev;
         virDomainHostdevDefPtr hostdev = hostdevs[i];
 
-        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+        if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
             continue;
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
@@ -273,11 +273,11 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
          * loop 2.
          */
         if ((pcidev = pciDeviceListFind(pcidevs, dev))) {
-            hostdev->origstates.states.pci.unbind_from_stub =
+            hostdev->source.origstates.states.pci.unbind_from_stub =
                 pciDeviceGetUnbindFromStub(pcidev);
-            hostdev->origstates.states.pci.remove_slot =
+            hostdev->source.origstates.states.pci.remove_slot =
                 pciDeviceGetRemoveSlot(pcidev);
-            hostdev->origstates.states.pci.reprobe =
+            hostdev->source.origstates.states.pci.reprobe =
                 pciDeviceGetReprobe(pcidev);
         }
 
@@ -346,7 +346,7 @@ qemuPrepareHostdevUSBDevices(struct qemud_driver *driver,
     for (i = 0 ; i < nhostdevs ; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
 
-        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+        if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
             continue;
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)
             continue;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4b60839..9eb4ee1 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1089,10 +1089,10 @@ int qemuDomainAttachHostDevice(struct qemud_driver *driver,
                                virDomainObjPtr vm,
                                virDomainHostdevDefPtr hostdev)
 {
-    if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+    if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
         qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("hostdev mode '%s' not supported"),
-                        virDomainHostdevModeTypeToString(hostdev->mode));
+                        virDomainHostdevModeTypeToString(hostdev->source.mode));
         return -1;
     }
 
@@ -1970,7 +1970,7 @@ qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
     pciDevice *activePci;
 
     for (i = 0 ; i < vm->def->nhostdevs ; i++) {
-        if (vm->def->hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+        if (vm->def->hostdevs[i]->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
             vm->def->hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
 
@@ -2078,7 +2078,7 @@ qemuDomainDetachHostUsbDevice(struct qemud_driver *driver,
     int i, ret;
 
     for (i = 0 ; i < vm->def->nhostdevs ; i++) {
-        if (vm->def->hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+        if (vm->def->hostdevs[i]->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
             vm->def->hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)
             continue;
 
@@ -2170,10 +2170,10 @@ int qemuDomainDetachHostDevice(struct qemud_driver *driver,
     virDomainHostdevDefPtr detach = NULL;
     int ret;
 
-    if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+    if (hostdev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
         qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("hostdev mode '%s' not supported"),
-                        virDomainHostdevModeTypeToString(hostdev->mode));
+                        virDomainHostdevModeTypeToString(hostdev->source.mode));
         return -1;
     }
 
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index 8f8b200..4a76920 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -698,7 +698,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
     if (secdef->norelabel)
         return 0;
 
-    if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+    if (dev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
         return 0;
 
     if (profile_loaded(secdef->imagelabel) < 0)
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 2fb4a14..fbee0ff 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -283,7 +283,7 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
     if (!priv->dynamicOwnership)
         return 0;
 
-    if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+    if (dev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
         return 0;
 
     switch (dev->source.subsys.type) {
@@ -354,7 +354,7 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
     if (!priv->dynamicOwnership)
         return 0;
 
-    if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+    if (dev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
         return 0;
 
     switch (dev->source.subsys.type) {
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index c2dceca..252bde5 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -710,7 +710,7 @@ SELinuxSetSecurityHostdevLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
     if (secdef->norelabel)
         return 0;
 
-    if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+    if (dev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
         return 0;
 
     switch (dev->source.subsys.type) {
@@ -779,7 +779,7 @@ SELinuxRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
     if (secdef->norelabel)
         return 0;
 
-    if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+    if (dev->source.mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
         return 0;
 
     switch (dev->source.subsys.type) {
diff --git a/src/util/pci.c b/src/util/pci.c
index 633dcd8..c413669 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -1428,12 +1428,12 @@ pciDeviceGetName(pciDevice *dev)
     return dev->name;
 }
 
-void pciDeviceSetManaged(pciDevice *dev, unsigned managed)
+void pciDeviceSetManaged(pciDevice *dev, bool managed)
 {
     dev->managed = !!managed;
 }
 
-unsigned pciDeviceGetManaged(pciDevice *dev)
+bool pciDeviceGetManaged(pciDevice *dev)
 {
     return dev->managed;
 }
diff --git a/src/util/pci.h b/src/util/pci.h
index 25b5b66..2183b06 100644
--- a/src/util/pci.h
+++ b/src/util/pci.h
@@ -50,8 +50,8 @@ int        pciResetDevice    (pciDevice     *dev,
                               pciDeviceList *activeDevs,
                               pciDeviceList *inactiveDevs);
 void      pciDeviceSetManaged(pciDevice     *dev,
-                              unsigned       managed);
-unsigned  pciDeviceGetManaged(pciDevice     *dev);
+                              bool           managed);
+bool      pciDeviceGetManaged(pciDevice     *dev);
 void      pciDeviceSetUsedBy(pciDevice     *dev,
                              const char *used_by);
 const char *pciDeviceGetUsedBy(pciDevice   *dev);
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index d720432..22136f7 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -3345,7 +3345,7 @@ sharedFoldersCleanup:
                                             unsigned productId        = 0;
                                             char *endptr              = NULL;
 
-                                            def->hostdevs[USBFilterCount]->mode =
+                                            def->hostdevs[USBFilterCount]->source.mode =
                                                 VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
                                             def->hostdevs[USBFilterCount]->source.subsys.type =
                                                 VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB;
@@ -4874,7 +4874,7 @@ vboxAttachUSB(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
      * usual
      */
     for (i = 0; i < def->nhostdevs; i++) {
-        if (def->hostdevs[i]->mode ==
+        if (def->hostdevs[i]->source.mode ==
             VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
             if (def->hostdevs[i]->source.subsys.type ==
                 VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
@@ -4900,7 +4900,7 @@ vboxAttachUSB(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
             USBController->vtbl->SetEnabledEhci(USBController, 1);
 
             for (i = 0; i < def->nhostdevs; i++) {
-                if (def->hostdevs[i]->mode ==
+                if (def->hostdevs[i]->source.mode ==
                     VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
                     if (def->hostdevs[i]->source.subsys.type ==
                         VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
@@ -5483,7 +5483,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
 #endif /* VBOX_API_VERSION >= 3001 */
                 } else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
                 } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
-                    if (dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+                    if (dev->data.hostdev->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
                         if (dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
                         }
                     }
@@ -5669,7 +5669,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
 #endif /* VBOX_API_VERSION >= 3001 */
                 } else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
                 } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
-                    if (dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+                    if (dev->data.hostdev->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
                         if (dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
                         }
                     }
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 1d8e035..e0aff1e 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2722,7 +2722,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
         break;
 
     case VIR_DOMAIN_DEVICE_HOSTDEV:
-        if (dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+        if (dev->data.hostdev->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
             if (xenFormatSxprOnePCI(dev->data.hostdev, &buf, 0) < 0)
                 goto cleanup;
@@ -2972,7 +2972,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
         goto cleanup;
 
     if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
-        if (dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+        if (dev->data.hostdev->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
             if (xenFormatSxprOnePCI(dev->data.hostdev, &buf, 1) < 0)
                 goto cleanup;
@@ -3969,7 +3969,7 @@ virDomainXMLDevID(virDomainPtr domain,
         if (tmp == NULL)
             return -1;
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
-               dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+               dev->data.hostdev->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
                dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
         char *bdf;
         virDomainHostdevDefPtr def = dev->data.hostdev;
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 04ba5aa..5101915 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -1016,8 +1016,8 @@ xenParseSxprPCI(virDomainDefPtr def,
         if (VIR_ALLOC(dev) < 0)
             goto no_memory;
 
-        dev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
-        dev->managed = 0;
+        dev->source.mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
+        dev->source.managed = false;
         dev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
         dev->source.subsys.u.pci.domain = domainID;
         dev->source.subsys.u.pci.bus = busID;
@@ -1909,7 +1909,7 @@ xenFormatSxprOnePCI(virDomainHostdevDefPtr def,
                     virBufferPtr buf,
                     int detach)
 {
-    if (def->managed) {
+    if (def->source.managed) {
         XENXS_ERROR(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                      _("managed PCI devices not supported with XenD"));
         return -1;
@@ -1934,7 +1934,7 @@ xenFormatSxprAllPCI(virDomainDefPtr def,
     int i;
 
     for (i = 0 ; i < def->nhostdevs ; i++)
-        if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+        if (def->hostdevs[i]->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             hasPCI = 1;
 
@@ -1957,9 +1957,9 @@ xenFormatSxprAllPCI(virDomainDefPtr def,
 
     virBufferAddLit(buf, "(device (pci ");
     for (i = 0 ; i < def->nhostdevs ; i++) {
-        if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+        if (def->hostdevs[i]->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
-            if (def->hostdevs[i]->managed) {
+            if (def->hostdevs[i]->source.managed) {
                 XENXS_ERROR(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                              _("managed PCI devices not supported with XenD"));
                 return -1;
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 0aa04f3..d2dbb51 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -818,7 +818,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
             if (VIR_ALLOC(hostdev) < 0)
                 goto no_memory;
 
-            hostdev->managed = 0;
+            hostdev->source.managed = false;
             hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
             hostdev->source.subsys.u.pci.domain = domainID;
             hostdev->source.subsys.u.pci.bus = busID;
@@ -1379,7 +1379,7 @@ xenFormatXMPCI(virConfPtr conf,
     int i;
 
     for (i = 0 ; i < def->nhostdevs ; i++)
-        if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+        if (def->hostdevs[i]->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             hasPCI = 1;
 
@@ -1395,7 +1395,7 @@ xenFormatXMPCI(virConfPtr conf,
     pciVal->list = NULL;
 
     for (i = 0 ; i < def->nhostdevs ; i++) {
-        if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+        if (def->hostdevs[i]->source.mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
             virConfValuePtr val, tmp;
             char *buf;
-- 
1.7.7.5

--
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]