libvirt: deprecate use_usb_tablet in favor of pointer_model

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
This commit is contained in:
Sahid Orentino Ferdjaoui 2015-04-22 05:17:25 -04:00 committed by Michael Still
parent 105195b0c1
commit 73d5d1f461
4 changed files with 99 additions and 21 deletions

View File

@ -324,6 +324,31 @@ remove_unused_original_minimum_age_seconds = cfg.IntOpt(
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,
@ -341,7 +366,8 @@ ALL_OPTS = [vcpu_pin_set,
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):

View File

@ -3834,7 +3834,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
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')
@ -3858,6 +3858,24 @@ class LibvirtConnTestCase(test.NoDBTestCase):
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')

View File

@ -156,7 +156,9 @@ libvirt_opts = [
'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, '
@ -4608,9 +4610,9 @@ class LibvirtDriver(driver.ComputeDriver):
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')):
@ -4691,26 +4693,50 @@ class LibvirtDriver(driver.ComputeDriver):
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,

View File

@ -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'.