Skip to content

Commit

Permalink
libvirt: deprecate use_usb_tablet in favor of pointer_model
Browse files Browse the repository at this point in the history
A new global option to handle input devices has
been introduced. The specifc option use_usb_tablet in the
group libvirt has been depecreated for Newton and should be
removed for O*

Related-To: blueprint virt-configure-usb-tablet-from-image
Change-Id: I51186530a94d86c8ed14783c7d42d0a3bd601f59
  • Loading branch information
sahid authored and mikalstill committed Apr 21, 2016
1 parent 105195b commit 73d5d1f
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 21 deletions.
28 changes: 27 additions & 1 deletion nova/conf/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,31 @@
help='Unused unresized base images younger than this will not '
'be removed')

pointer_model = cfg.StrOpt(
'pointer_model',
default=None, choices=[None, 'usbtablet'],
help="""Generic property to specify the pointer type.
Input devices allow interaction with a graphical framebuffer. For
example to provide a graphic tablet for absolute cursor movement.
Possible values:
* None: Uses relative movement. Mouse connected by PS2
* usbtablet: Uses absolute movement. Tablet connect by USB
Services which consume this:
* nova-compute
Interdependencies to other options:
* usbtablet must be configured with VNC enabled or SPICE enabled and SPICE
agent disabled. When used with libvirt the instance mode should be
configured as HVM.
""")


ALL_OPTS = [vcpu_pin_set,
compute_driver,
default_ephemeral_format,
Expand All @@ -341,7 +366,8 @@
image_cache_manager_interval,
image_cache_subdirectory_name,
remove_unused_base_images,
remove_unused_original_minimum_age_seconds]
remove_unused_original_minimum_age_seconds,
pointer_model]


def register_opts(conf):
Expand Down
20 changes: 19 additions & 1 deletion nova/tests/unit/virt/libvirt/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,7 @@ def _test_get_guest_usb_tablet(self, vnc_enabled, spice_enabled, os_type,
self.flags(enabled=spice_enabled,
agent_enabled=agent_enabled, group='spice')
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
return drvr._get_guest_usb_tablet(os_type)
return drvr._get_guest_pointer_model(os_type)

def test_get_guest_usb_tablet_wipe(self):
self.flags(use_usb_tablet=True, group='libvirt')
Expand All @@ -3858,6 +3858,24 @@ def test_get_guest_usb_tablet_wipe(self):
False, True, vm_mode.HVM, True)
self.assertIsNone(tablet)

def test_get_guest_no_pointer_model_usb_tablet_set(self):
self.flags(use_usb_tablet=True, group='libvirt')

tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM)
self.assertIsNotNone(tablet)

def test_get_guest_no_pointer_model_usb_tablet_not_set(self):
self.flags(use_usb_tablet=False, group='libvirt')

tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM)
self.assertIsNone(tablet)

def test_get_guest_pointer_model_usb_tablet(self):
self.flags(use_usb_tablet=False, group='libvirt')
self.flags(pointer_model='usbtablet')
tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM)
self.assertIsNotNone(tablet)

def _test_get_guest_config_with_watchdog_action_flavor(self,
hw_watchdog_action="hw:watchdog_action"):
self.flags(virt_type='kvm', group='libvirt')
Expand Down
64 changes: 45 additions & 19 deletions nova/virt/libvirt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@
'0 => not partitioned, >0 => partition number'),
cfg.BoolOpt('use_usb_tablet',
default=True,
help='Sync virtual and real mouse cursors in Windows VMs'),
deprecated_for_removal=True,
help='(Deprecated, please see pointer_model) Sync virtual and '
'real mouse cursors in Windows VMs'),
cfg.StrOpt('live_migration_inbound_addr',
help='Live migration target ip or hostname '
'(if this option is set to None, which is the default, '
Expand Down Expand Up @@ -4608,9 +4610,9 @@ def _get_guest_config(self, instance, network_info, image_meta,
consolepty.type = "pty"
guest.add_device(consolepty)

tablet = self._get_guest_usb_tablet(guest.os_type)
if tablet:
guest.add_device(tablet)
pointer = self._get_guest_pointer_model(guest.os_type)
if pointer:
guest.add_device(pointer)

if (CONF.spice.enabled and CONF.spice.agent_enabled and
virt_type not in ('lxc', 'uml', 'xen')):
Expand Down Expand Up @@ -4691,26 +4693,50 @@ def _get_guest_config(self, instance, network_info, image_meta,

return guest

def _get_guest_usb_tablet(self, os_type):
# We want a tablet if VNC is enabled, or SPICE is enabled and
# the SPICE agent is disabled. If the SPICE agent is enabled
# it provides a paravirt mouse which drastically reduces
# overhead (by eliminating USB polling).
#
# 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.libvirt.use_usb_tablet
elif CONF.spice.enabled and not CONF.spice.agent_enabled:
need_usb_tablet = CONF.libvirt.use_usb_tablet
def _get_guest_pointer_model(self, os_type):
pointer_model = CONF.pointer_model
if pointer_model is None and CONF.libvirt.use_usb_tablet:
# TODO(sahid): We set pointer_model to keep compatibility
# until the next release O*. It means operators can continue
# to use the depecrated option "use_usb_tablet" or set a
# specific device to use
pointer_model = "usbtablet"
LOG.warning(_LW('The option "use_usb_tablet" has been '
'deprecated for Newton in favor of the more '
'generic "pointer_model". Please update '
'nova.conf to address this change.'))

if pointer_model == "usbtablet":
# We want a tablet if VNC is enabled, or SPICE is enabled and
# the SPICE agent is disabled. If the SPICE agent is enabled
# it provides a paravirt mouse which drastically reduces
# overhead (by eliminating USB polling).
if CONF.vnc.enabled or (
CONF.spice.enabled and not CONF.spice.agent_enabled):
return self._get_guest_usb_tablet(os_type)
else:
# For backward compatibility We don't want to break
# process of booting an instance if host is configured
# to use USB tablet without VNC or SPICE and SPICE
# agent disable.
LOG.warning(_LW('USB tablet requested for guests by host '
'configuration. In order to accept this '
'request VNC should be enabled or SPICE '
'and SPICE agent disabled on host.'))

def _get_guest_usb_tablet(self, os_type):
tablet = None
if need_usb_tablet and os_type == vm_mode.HVM:
if os_type == vm_mode.HVM:
tablet = vconfig.LibvirtConfigGuestInput()
tablet.type = "tablet"
tablet.bus = "usb"
else:
# For backward compatibility We don't want to break
# process of booting an instance if virtual machine mode
# is not configured as HVM.
LOG.warning(_LW('USB tablet requested for guests by host '
'configuration. In order to accept this request '
'the machine mode should be configured as HVM.'))
return tablet

def _get_guest_xml(self, context, instance, network_info, disk_info,
Expand Down
8 changes: 8 additions & 0 deletions releasenotes/notes/pointer-model-b4a1828c43e8d523.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
features:
- The pointer_model configuration option was added to specify
different pointer models for input devices. This replaces
the now deprecated use_usb_tablet option.
deprecations:
- Nova option 'use_usb_tablet' will be deprecated in favor of
the global 'pointer_model'.

0 comments on commit 73d5d1f

Please sign in to comment.