You need to sign in or sign up before continuing.
提交 82c142b3 编写于 作者: J Ján Tomko

Introduce virDomainUSBAddressSet

A new type to track USB addresses.

Every <controller type='usb' index='i'/> is represented by an
object of type virDomainUSBAddressHub located at buses[i].

Each of these hubs has up to 'nports' ports.
If a port is occupied, it has the corresponding bit set in
the 'ports' bitmap, e.g. port 1 would have the 0th bit set.
If there is a hub on this port, then hubs[i] will point
to this hub.
上级 b999ce97
...@@ -1284,3 +1284,45 @@ virDomainUSBAddressPortFormat(unsigned int *port) ...@@ -1284,3 +1284,45 @@ virDomainUSBAddressPortFormat(unsigned int *port)
return NULL; return NULL;
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
} }
virDomainUSBAddressSetPtr
virDomainUSBAddressSetCreate(void)
{
virDomainUSBAddressSetPtr addrs;
if (VIR_ALLOC(addrs) < 0)
return NULL;
return addrs;
}
static void
virDomainUSBAddressHubFree(virDomainUSBAddressHubPtr hub)
{
size_t i;
if (!hub)
return;
for (i = 0; i < hub->nports; i++)
virDomainUSBAddressHubFree(hub->ports[i]);
virBitmapFree(hub->portmap);
VIR_FREE(hub);
}
void
virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs)
{
size_t i;
if (!addrs)
return;
for (i = 0; i < addrs->nbuses; i++)
virDomainUSBAddressHubFree(addrs->buses[i]);
VIR_FREE(addrs->buses);
VIR_FREE(addrs);
}
...@@ -249,4 +249,26 @@ char * ...@@ -249,4 +249,26 @@ char *
virDomainUSBAddressPortFormat(unsigned int *port) virDomainUSBAddressPortFormat(unsigned int *port)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
typedef struct _virDomainUSBAddressHub virDomainUSBAddressHub;
typedef virDomainUSBAddressHub *virDomainUSBAddressHubPtr;
struct _virDomainUSBAddressHub {
/* indexes are shifted by one:
* ports[0] represents port 1, because ports are numbered from 1 */
virBitmapPtr portmap;
size_t nports;
virDomainUSBAddressHubPtr *ports;
};
struct _virDomainUSBAddressSet {
/* every <controller type='usb' index='i'> is represented
* as a hub at buses[i] */
virDomainUSBAddressHubPtr *buses;
size_t nbuses;
};
typedef struct _virDomainUSBAddressSet virDomainUSBAddressSet;
typedef virDomainUSBAddressSet *virDomainUSBAddressSetPtr;
virDomainUSBAddressSetPtr virDomainUSBAddressSetCreate(void);
void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs);
#endif /* __DOMAIN_ADDR_H__ */ #endif /* __DOMAIN_ADDR_H__ */
...@@ -110,6 +110,8 @@ virDomainPCIControllerModelToConnectType; ...@@ -110,6 +110,8 @@ virDomainPCIControllerModelToConnectType;
virDomainUSBAddressPortFormat; virDomainUSBAddressPortFormat;
virDomainUSBAddressPortFormatBuf; virDomainUSBAddressPortFormatBuf;
virDomainUSBAddressPortIsValid; virDomainUSBAddressPortIsValid;
virDomainUSBAddressSetCreate;
virDomainUSBAddressSetFree;
virDomainVirtioSerialAddrAssign; virDomainVirtioSerialAddrAssign;
virDomainVirtioSerialAddrAutoAssign; virDomainVirtioSerialAddrAutoAssign;
virDomainVirtioSerialAddrIsComplete; virDomainVirtioSerialAddrIsComplete;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册