From f04dd04342705c8dc745308662b698bb54debf69 Mon Sep 17 00:00:00 2001 From: Sahid Orentino Ferdjaoui Date: Fri, 9 Sep 2016 05:55:39 -0400 Subject: [PATCH] libvirt: add ps2mouse in choice for pointer_model This commit adds option ps2mouse to pointer_model, and set the default value of pointer_model to usbtablet to do not break upgrade regarding the default behavior of use_usb_tablet. WHY: use_usb_tablet is by default set to True and during the deprecation phase of use_usb_tablet, operators which have set that option to false can't have the same behavior by using pointer_model since use_usb_tablet takes precedence. Now operators can use pointer_model=ps2mouse. Change-Id: Id18b5503799922e4096bde296a9e7bb4f2a994aa Closes-Bug: #1621582 --- nova/conf/virt.py | 7 +++-- nova/tests/unit/virt/libvirt/test_driver.py | 30 +++++++++++-------- ...-value-pointer-model-cb3d9a3e9c51e503.yaml | 4 +++ 3 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 releasenotes/notes/default-value-pointer-model-cb3d9a3e9c51e503.yaml diff --git a/nova/conf/virt.py b/nova/conf/virt.py index ccda61e03a7a..c9c4c6219194 100644 --- a/nova/conf/virt.py +++ b/nova/conf/virt.py @@ -272,7 +272,8 @@ Unused unresized base images younger than this will not be removed cfg.StrOpt( 'pointer_model', - choices=[None, 'usbtablet'], + default='usbtablet', + choices=[None, 'ps2mouse', 'usbtablet'], help=""" Generic property to specify the pointer type. @@ -284,7 +285,9 @@ this configuration option. Possible values: -* None: Uses relative movement. Mouse connected by PS2 +* None: Uses default behavior provided by drivers (mouse on PS2 for + libvirt x86) +* ps2mouse: Uses relative movement. Mouse connected by PS2 * usbtablet: Uses absolute movement. Tablet connect by USB Interdependencies to other options: diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 2e9b43dd326d..966bbe9e2ff7 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -3419,9 +3419,8 @@ class LibvirtConnTestCase(test.NoDBTestCase): def test_get_guest_config_with_vnc(self): self.flags(enabled=True, group='vnc') - self.flags(virt_type='kvm', - use_usb_tablet=False, - group='libvirt') + self.flags(virt_type='kvm', group='libvirt') + self.flags(pointer_model='ps2mouse') self.flags(enabled=False, group='spice') drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) @@ -4144,6 +4143,12 @@ class LibvirtConnTestCase(test.NoDBTestCase): image_meta = objects.ImageMeta.from_dict(image_meta) return drvr._get_guest_pointer_model(os_type, image_meta) + def test_use_ps2_mouse(self): + self.flags(pointer_model='ps2mouse') + + tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM) + self.assertIsNone(tablet) + def test_get_guest_usb_tablet_wipe(self): self.flags(use_usb_tablet=True, group='libvirt') @@ -4206,12 +4211,14 @@ class LibvirtConnTestCase(test.NoDBTestCase): def test_get_guest_no_pointer_model_usb_tablet_set(self): self.flags(use_usb_tablet=True, group='libvirt') + self.flags(pointer_model=None) 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') + self.flags(pointer_model=None) tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM) self.assertIsNone(tablet) @@ -4567,9 +4574,8 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.assertEqual(cfg.devices[5].type, "vnc") def test_get_guest_config_with_rng_device(self): - self.flags(virt_type='kvm', - use_usb_tablet=False, - group='libvirt') + self.flags(virt_type='kvm', group='libvirt') + self.flags(pointer_model='ps2mouse') drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) instance_ref = objects.Instance(**self.test_instance) @@ -4608,9 +4614,8 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.assertIsNone(cfg.devices[6].rate_period) def test_get_guest_config_with_rng_not_allowed(self): - self.flags(virt_type='kvm', - use_usb_tablet=False, - group='libvirt') + self.flags(virt_type='kvm', group='libvirt') + self.flags(pointer_model='ps2mouse') drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) instance_ref = objects.Instance(**self.test_instance) @@ -4641,9 +4646,8 @@ class LibvirtConnTestCase(test.NoDBTestCase): vconfig.LibvirtConfigMemoryBalloon) def test_get_guest_config_with_rng_limits(self): - self.flags(virt_type='kvm', - use_usb_tablet=False, - group='libvirt') + self.flags(virt_type='kvm', group='libvirt') + self.flags(pointer_model='ps2mouse') drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) instance_ref = objects.Instance(**self.test_instance) @@ -4686,9 +4690,9 @@ class LibvirtConnTestCase(test.NoDBTestCase): @mock.patch('nova.virt.libvirt.driver.os.path.exists') def test_get_guest_config_with_rng_backend(self, mock_path): self.flags(virt_type='kvm', - use_usb_tablet=False, rng_dev_path='/dev/hw_rng', group='libvirt') + self.flags(pointer_model='ps2mouse') mock_path.return_value = True drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) diff --git a/releasenotes/notes/default-value-pointer-model-cb3d9a3e9c51e503.yaml b/releasenotes/notes/default-value-pointer-model-cb3d9a3e9c51e503.yaml new file mode 100644 index 000000000000..cdb147a120c6 --- /dev/null +++ b/releasenotes/notes/default-value-pointer-model-cb3d9a3e9c51e503.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - The default value of the ``pointer_model`` configuration option + has been set to 'usbtablet'. \ No newline at end of file