[gnome-boxes] Add USB support in new VMs if supported
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Add USB support in new VMs if supported
- Date: Wed, 14 Nov 2012 16:26:50 +0000 (UTC)
commit 5803906dcdc8960ae18efc2464290c5a58ed6051
Author: Alexander Larsson <alexl redhat com>
Date: Mon Nov 5 17:09:47 2012 +0100
Add USB support in new VMs if supported
If qemu is new enough to fully support usb redirection, add support
for it (i.e. 4 redirection channels and usb2 controllers) to all new
VMs.
https://bugzilla.gnome.org/show_bug.cgi?id=672268
src/vm-configurator.vala | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index b7ddc92..952462e 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -74,6 +74,10 @@ private class Boxes.VMConfigurator {
channel.set_source (vmc);
domain.add_device (channel);
+ // Only add usb support if we'er 100% sure it works, as it breaks migration (i.e. save) on older qemu
+ if (Config.HAVE_USBREDIR)
+ add_usb_support (domain);
+
set_video_config (domain, install_media);
set_sound_config (domain, install_media);
set_tablet_config (domain, install_media);
@@ -291,6 +295,40 @@ private class Boxes.VMConfigurator {
return null;
}
+ public static void add_usb_support (Domain domain) {
+ // 4 USB redirection channels
+ for (int i = 0; i < 4; i++) {
+ var usb_redir = new DomainRedirdev ();
+ usb_redir.set_bus (DomainRedirdevBus.USB);
+ var vmc = new DomainChardevSourceSpiceVmc ();
+ usb_redir.set_source (vmc);
+ domain.add_device (usb_redir);
+ }
+
+ // USB controllers
+ var master_controller = create_usb_controller (DomainControllerUsbModel.ICH9_EHCI1);
+ domain.add_device (master_controller);
+ var controller = create_usb_controller (DomainControllerUsbModel.ICH9_UHCI1, master_controller, 0, 0);
+ domain.add_device (controller);
+ controller = create_usb_controller (DomainControllerUsbModel.ICH9_UHCI2, master_controller, 0, 2);
+ domain.add_device (controller);
+ controller = create_usb_controller (DomainControllerUsbModel.ICH9_UHCI3, master_controller, 0, 4);
+ domain.add_device (controller);
+ }
+
+ private static DomainControllerUsb create_usb_controller (DomainControllerUsbModel model,
+ DomainControllerUsb? master = null,
+ uint index = 0,
+ uint start_port = 0) {
+ var controller = new DomainControllerUsb ();
+ controller.set_model (model);
+ controller.set_index (index);
+ if (master != null)
+ controller.set_master (master, start_port);
+
+ return controller;
+ }
+
private static CapabilitiesGuest get_best_guest_caps (Capabilities caps, InstallerMedia install_media)
throws VMConfiguratorError {
var guests_caps = caps.get_guests ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]