From c215b5ec79516111456dfc2a63fa0facf5946ab0 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 18 Dec 2012 12:06:15 +0000 Subject: Add support for configuring SPICE graphics with libvirt Add support to the libvirt driver to configure SPICE graphics and the SPICE guest agent. It allows for enablement of both VNC and SPICE at the same time, since some recent libvirt/KVM versions support this concurrent mode. The USB tablet will now only be enabled if VNC is requested, or SPICE is requested without the agent Blueprint: libvirt-spice Change-Id: Ic7fbfd636455aba5bf881b6a1925fd4561edfd15 Signed-off-by: Daniel P. Berrange --- nova/virt/libvirt/driver.py | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 4312086a8..557818a99 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -196,6 +196,7 @@ CONF.import_opt('default_ephemeral_format', 'nova.virt.driver') CONF.import_opt('use_cow_images', 'nova.virt.driver') CONF.import_opt('live_migration_retry_count', 'nova.compute.manager') CONF.import_opt('vncserver_proxyclient_address', 'nova.vnc') +CONF.import_opt('server_proxyclient_address', 'nova.spice', group='spice') DEFAULT_FIREWALL_DRIVER = "%s.%s" % ( libvirt_firewall.__name__, @@ -1786,19 +1787,49 @@ class LibvirtDriver(driver.ComputeDriver): consolepty.type = "pty" guest.add_device(consolepty) - if CONF.vnc_enabled and CONF.libvirt_type not in ('lxc', 'uml'): - if CONF.use_usb_tablet and guest.os_type == vm_mode.HVM: - tablet = vconfig.LibvirtConfigGuestInput() - tablet.type = "tablet" - tablet.bus = "usb" - guest.add_device(tablet) + # We want a tablet if VNC is enabled, + # or SPICE is enabled and the SPICE agent is disabled + # NB: this implies that if both SPICE + VNC are enabled + # at the same time, we'll get the tablet whether the + # SPICE agent is used or not. + need_usb_tablet = False + if CONF.vnc_enabled: + need_usb_tablet = CONF.use_usb_tablet + elif CONF.spice.enabled and not CONF.spice.agent_enabled: + need_usb_tablet = CONF.use_usb_tablet + + if need_usb_tablet and guest.os_type == vm_mode.HVM: + tablet = vconfig.LibvirtConfigGuestInput() + tablet.type = "tablet" + tablet.bus = "usb" + guest.add_device(tablet) + + if CONF.spice.enabled and CONF.spice.agent_enabled and \ + CONF.libvirt_type not in ('lxc', 'uml', 'xen'): + channel = vconfig.LibvirtConfigGuestChannel() + channel.target_name = "com.redhat.spice.0" + guest.add_device(channel) + + # NB some versions of libvirt support both SPICE and VNC + # at the same time. We're not trying to second guess which + # those versions are. We'll just let libvirt report the + # errors appropriately if the user enables both. + if CONF.vnc_enabled and CONF.libvirt_type not in ('lxc', 'uml'): graphics = vconfig.LibvirtConfigGuestGraphics() graphics.type = "vnc" graphics.keymap = CONF.vnc_keymap graphics.listen = CONF.vncserver_listen guest.add_device(graphics) + if CONF.spice.enabled and \ + CONF.libvirt_type not in ('lxc', 'uml', 'xen'): + graphics = vconfig.LibvirtConfigGuestGraphics() + graphics.type = "spice" + graphics.keymap = CONF.spice.keymap + graphics.listen = CONF.spice.server_listen + guest.add_device(graphics) + return guest def to_xml(self, instance, network_info, image_meta=None, rescue=None, -- cgit