|
|
6ae9ed |
From da353cc1db4b13c50c3d79d5053d47a389a86148 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <da353cc1db4b13c50c3d79d5053d47a389a86148@dist-git>
|
|
|
6ae9ed |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
6ae9ed |
Date: Thu, 21 Jul 2016 15:57:50 +0200
|
|
|
6ae9ed |
Subject: [PATCH] Introduce virDomainUSBAddressSet
|
|
|
6ae9ed |
MIME-Version: 1.0
|
|
|
6ae9ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
6ae9ed |
Content-Transfer-Encoding: 8bit
|
|
|
6ae9ed |
|
|
|
6ae9ed |
A new type to track USB addresses.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Every <controller type='usb' index='i'/> is represented by an
|
|
|
6ae9ed |
object of type virDomainUSBAddressHub located at buses[i].
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Each of these hubs has up to 'nports' ports.
|
|
|
6ae9ed |
If a port is occupied, it has the corresponding bit set in
|
|
|
6ae9ed |
the 'ports' bitmap, e.g. port 1 would have the 0th bit set.
|
|
|
6ae9ed |
If there is a hub on this port, then hubs[i] will point
|
|
|
6ae9ed |
to this hub.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit 82c142b321a10c62aa0a10e3ae9ba603b2d7d155)
|
|
|
6ae9ed |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1215968
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
src/conf/domain_addr.c | 42 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
6ae9ed |
src/conf/domain_addr.h | 22 ++++++++++++++++++++++
|
|
|
6ae9ed |
src/libvirt_private.syms | 2 ++
|
|
|
6ae9ed |
3 files changed, 66 insertions(+)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
|
|
|
6ae9ed |
index 741d045..658aad5 100644
|
|
|
6ae9ed |
--- a/src/conf/domain_addr.c
|
|
|
6ae9ed |
+++ b/src/conf/domain_addr.c
|
|
|
6ae9ed |
@@ -1284,3 +1284,45 @@ virDomainUSBAddressPortFormat(unsigned int *port)
|
|
|
6ae9ed |
return NULL;
|
|
|
6ae9ed |
return virBufferContentAndReset(&buf;;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+virDomainUSBAddressSetPtr
|
|
|
6ae9ed |
+virDomainUSBAddressSetCreate(void)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ virDomainUSBAddressSetPtr addrs;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (VIR_ALLOC(addrs) < 0)
|
|
|
6ae9ed |
+ return NULL;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ return addrs;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+static void
|
|
|
6ae9ed |
+virDomainUSBAddressHubFree(virDomainUSBAddressHubPtr hub)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ size_t i;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (!hub)
|
|
|
6ae9ed |
+ return;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ for (i = 0; i < hub->nports; i++)
|
|
|
6ae9ed |
+ virDomainUSBAddressHubFree(hub->ports[i]);
|
|
|
6ae9ed |
+ virBitmapFree(hub->portmap);
|
|
|
6ae9ed |
+ VIR_FREE(hub);
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+void
|
|
|
6ae9ed |
+virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ size_t i;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (!addrs)
|
|
|
6ae9ed |
+ return;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ for (i = 0; i < addrs->nbuses; i++)
|
|
|
6ae9ed |
+ virDomainUSBAddressHubFree(addrs->buses[i]);
|
|
|
6ae9ed |
+ VIR_FREE(addrs->buses);
|
|
|
6ae9ed |
+ VIR_FREE(addrs);
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
|
|
|
6ae9ed |
index cfc74d5..168d3ed 100644
|
|
|
6ae9ed |
--- a/src/conf/domain_addr.h
|
|
|
6ae9ed |
+++ b/src/conf/domain_addr.h
|
|
|
6ae9ed |
@@ -249,4 +249,26 @@ char *
|
|
|
6ae9ed |
virDomainUSBAddressPortFormat(unsigned int *port)
|
|
|
6ae9ed |
ATTRIBUTE_NONNULL(1);
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+typedef struct _virDomainUSBAddressHub virDomainUSBAddressHub;
|
|
|
6ae9ed |
+typedef virDomainUSBAddressHub *virDomainUSBAddressHubPtr;
|
|
|
6ae9ed |
+struct _virDomainUSBAddressHub {
|
|
|
6ae9ed |
+ /* indexes are shifted by one:
|
|
|
6ae9ed |
+ * ports[0] represents port 1, because ports are numbered from 1 */
|
|
|
6ae9ed |
+ virBitmapPtr portmap;
|
|
|
6ae9ed |
+ size_t nports;
|
|
|
6ae9ed |
+ virDomainUSBAddressHubPtr *ports;
|
|
|
6ae9ed |
+};
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+struct _virDomainUSBAddressSet {
|
|
|
6ae9ed |
+ /* every <controller type='usb' index='i'> is represented
|
|
|
6ae9ed |
+ * as a hub at buses[i] */
|
|
|
6ae9ed |
+ virDomainUSBAddressHubPtr *buses;
|
|
|
6ae9ed |
+ size_t nbuses;
|
|
|
6ae9ed |
+};
|
|
|
6ae9ed |
+typedef struct _virDomainUSBAddressSet virDomainUSBAddressSet;
|
|
|
6ae9ed |
+typedef virDomainUSBAddressSet *virDomainUSBAddressSetPtr;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+virDomainUSBAddressSetPtr virDomainUSBAddressSetCreate(void);
|
|
|
6ae9ed |
+void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
#endif /* __DOMAIN_ADDR_H__ */
|
|
|
6ae9ed |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
6ae9ed |
index 44b78e0..49f8d6c 100644
|
|
|
6ae9ed |
--- a/src/libvirt_private.syms
|
|
|
6ae9ed |
+++ b/src/libvirt_private.syms
|
|
|
6ae9ed |
@@ -110,6 +110,8 @@ virDomainPCIControllerModelToConnectType;
|
|
|
6ae9ed |
virDomainUSBAddressPortFormat;
|
|
|
6ae9ed |
virDomainUSBAddressPortFormatBuf;
|
|
|
6ae9ed |
virDomainUSBAddressPortIsValid;
|
|
|
6ae9ed |
+virDomainUSBAddressSetCreate;
|
|
|
6ae9ed |
+virDomainUSBAddressSetFree;
|
|
|
6ae9ed |
virDomainVirtioSerialAddrAssign;
|
|
|
6ae9ed |
virDomainVirtioSerialAddrAutoAssign;
|
|
|
6ae9ed |
virDomainVirtioSerialAddrIsComplete;
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.9.2
|
|
|
6ae9ed |
|