|
|
6ae9ed |
From ad806164d0df731d6ce8b24109abb360584ea64b Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <ad806164d0df731d6ce8b24109abb360584ea64b@dist-git>
|
|
|
6ae9ed |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
6ae9ed |
Date: Thu, 21 Jul 2016 15:57:47 +0200
|
|
|
6ae9ed |
Subject: [PATCH] Introduce virDomainUSBDeviceDefForeach
|
|
|
6ae9ed |
MIME-Version: 1.0
|
|
|
6ae9ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
6ae9ed |
Content-Transfer-Encoding: 8bit
|
|
|
6ae9ed |
|
|
|
6ae9ed |
A helper that will execute a callback on every USB device
|
|
|
6ae9ed |
in the domain definition.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
With an ability to skip USB hubs, since we will want to treat
|
|
|
6ae9ed |
them differently in some cases.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit 492b3bfda175a846bdbff898607197b0b306d58c)
|
|
|
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_conf.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
6ae9ed |
src/conf/domain_conf.h | 7 ++++
|
|
|
6ae9ed |
src/libvirt_private.syms | 1 +
|
|
|
6ae9ed |
3 files changed, 97 insertions(+)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
6ae9ed |
index bb297f6..e6dc23d 100644
|
|
|
6ae9ed |
--- a/src/conf/domain_conf.c
|
|
|
6ae9ed |
+++ b/src/conf/domain_conf.c
|
|
|
6ae9ed |
@@ -24022,6 +24022,95 @@ virDomainSmartcardDefForeach(virDomainDefPtr def,
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+int
|
|
|
6ae9ed |
+virDomainUSBDeviceDefForeach(virDomainDefPtr def,
|
|
|
6ae9ed |
+ virDomainUSBDeviceDefIterator iter,
|
|
|
6ae9ed |
+ void *opaque,
|
|
|
6ae9ed |
+ bool skipHubs)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ size_t i;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* usb-hub */
|
|
|
6ae9ed |
+ if (!skipHubs) {
|
|
|
6ae9ed |
+ for (i = 0; i < def->nhubs; i++) {
|
|
|
6ae9ed |
+ virDomainHubDefPtr hub = def->hubs[i];
|
|
|
6ae9ed |
+ if (hub->type == VIR_DOMAIN_HUB_TYPE_USB) {
|
|
|
6ae9ed |
+ if (iter(&hub->info, opaque) < 0)
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* usb-host */
|
|
|
6ae9ed |
+ for (i = 0; i < def->nhostdevs; i++) {
|
|
|
6ae9ed |
+ virDomainHostdevDefPtr hostdev = def->hostdevs[i];
|
|
|
6ae9ed |
+ if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
|
|
|
6ae9ed |
+ if (iter(hostdev->info, opaque) < 0)
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* usb-storage */
|
|
|
6ae9ed |
+ for (i = 0; i < def->ndisks; i++) {
|
|
|
6ae9ed |
+ virDomainDiskDefPtr disk = def->disks[i];
|
|
|
6ae9ed |
+ if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) {
|
|
|
6ae9ed |
+ if (iter(&disk->info, opaque) < 0)
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* TODO: add def->nets here when libvirt starts supporting usb-net */
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* usb-ccid */
|
|
|
6ae9ed |
+ for (i = 0; i < def->ncontrollers; i++) {
|
|
|
6ae9ed |
+ virDomainControllerDefPtr cont = def->controllers[i];
|
|
|
6ae9ed |
+ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_CCID) {
|
|
|
6ae9ed |
+ if (iter(&cont->info, opaque) < 0)
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* usb-kbd, usb-mouse, usb-tablet */
|
|
|
6ae9ed |
+ for (i = 0; i < def->ninputs; i++) {
|
|
|
6ae9ed |
+ virDomainInputDefPtr input = def->inputs[i];
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) {
|
|
|
6ae9ed |
+ if (iter(&input->info, opaque) < 0)
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* usb-serial */
|
|
|
6ae9ed |
+ for (i = 0; i < def->nserials; i++) {
|
|
|
6ae9ed |
+ virDomainChrDefPtr serial = def->serials[i];
|
|
|
6ae9ed |
+ if (serial->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) {
|
|
|
6ae9ed |
+ if (iter(&serial->info, opaque) < 0)
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* usb-audio model=usb */
|
|
|
6ae9ed |
+ for (i = 0; i < def->nsounds; i++) {
|
|
|
6ae9ed |
+ virDomainSoundDefPtr sound = def->sounds[i];
|
|
|
6ae9ed |
+ if (sound->model == VIR_DOMAIN_SOUND_MODEL_USB) {
|
|
|
6ae9ed |
+ if (iter(&sound->info, opaque) < 0)
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* usb-redir */
|
|
|
6ae9ed |
+ for (i = 0; i < def->nredirdevs; i++) {
|
|
|
6ae9ed |
+ virDomainRedirdevDefPtr redirdev = def->redirdevs[i];
|
|
|
6ae9ed |
+ if (redirdev->bus == VIR_DOMAIN_REDIRDEV_BUS_USB) {
|
|
|
6ae9ed |
+ if (iter(&redirdev->info, opaque) < 0)
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ return 0;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
/* Call iter(disk, name, depth, opaque) for each element of disk and
|
|
|
6ae9ed |
* its backing chain in the pre-populated disk->src.backingStore.
|
|
|
6ae9ed |
* ignoreOpenFailure determines whether to warn about a chain that
|
|
|
6ae9ed |
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
|
|
6ae9ed |
index e1990dc..f29c4bd 100644
|
|
|
6ae9ed |
--- a/src/conf/domain_conf.h
|
|
|
6ae9ed |
+++ b/src/conf/domain_conf.h
|
|
|
6ae9ed |
@@ -2884,6 +2884,13 @@ typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
|
|
|
6ae9ed |
size_t depth,
|
|
|
6ae9ed |
void *opaque);
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
|
|
|
6ae9ed |
+ void *opaque);
|
|
|
6ae9ed |
+int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
|
|
|
6ae9ed |
+ virDomainUSBDeviceDefIterator iter,
|
|
|
6ae9ed |
+ void *opaque,
|
|
|
6ae9ed |
+ bool skipHubs);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
|
|
|
6ae9ed |
bool ignoreOpenFailure,
|
|
|
6ae9ed |
virDomainDiskDefPathIterator iter,
|
|
|
6ae9ed |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
6ae9ed |
index 4617f5d..de620a8 100644
|
|
|
6ae9ed |
--- a/src/libvirt_private.syms
|
|
|
6ae9ed |
+++ b/src/libvirt_private.syms
|
|
|
6ae9ed |
@@ -473,6 +473,7 @@ virDomainTPMBackendTypeToString;
|
|
|
6ae9ed |
virDomainTPMDefFree;
|
|
|
6ae9ed |
virDomainTPMModelTypeFromString;
|
|
|
6ae9ed |
virDomainTPMModelTypeToString;
|
|
|
6ae9ed |
+virDomainUSBDeviceDefForeach;
|
|
|
6ae9ed |
virDomainVideoDefaultRAM;
|
|
|
6ae9ed |
virDomainVideoDefaultType;
|
|
|
6ae9ed |
virDomainVideoDefFree;
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.9.2
|
|
|
6ae9ed |
|