osdict: Fix incorrect usage of virtio input

Regression reported with latest libosinfo, when the OS reports
virtio-input support:

http://www.redhat.com/archives/virt-tools-list/2016-July/msg00109.html

Really our code presently only cares about the USB tablet, so adjust
our libosinfo lookup to explicitly check for it
This commit is contained in:
Cole Robinson 2016-07-29 13:17:36 -04:00
parent 9cdf78e94c
commit 1d2cd30677
2 changed files with 17 additions and 22 deletions

View File

@ -1031,15 +1031,14 @@ class Guest(XMLBuilder):
return False return False
return all([c.model == "none" for c in controllers]) return all([c.model == "none" for c in controllers])
input_type = self._os_object.default_inputtype() input_type = "mouse"
input_bus = self._os_object.default_inputbus() input_bus = "ps2"
if self.os.is_xenpv(): if self.os.is_xenpv():
input_type = VirtualInputDevice.TYPE_MOUSE input_type = VirtualInputDevice.TYPE_MOUSE
input_bus = VirtualInputDevice.BUS_XEN input_bus = VirtualInputDevice.BUS_XEN
elif _usb_disabled() and input_bus == "usb": elif self._os_object.supports_usbtablet() and not _usb_disabled():
input_bus = "ps2" input_type = "tablet"
if input_type == "tablet": input_bus = "usb"
input_type = "mouse"
for inp in self.get_devices("input"): for inp in self.get_devices("input"):
if (inp.type == inp.TYPE_DEFAULT and if (inp.type == inp.TYPE_DEFAULT and

View File

@ -457,23 +457,19 @@ class _OsVariant(object):
return devname return devname
return None return None
def default_inputtype(self): def supports_usbtablet(self):
if self._os: if not self._os:
fltr = libosinfo.Filter() return False
fltr.add_constraint("class", "input")
devs = self._os.get_all_devices(fltr)
if devs.get_length():
return devs.get_nth(0).get_name()
return "mouse"
def default_inputbus(self):
if self._os:
fltr = libosinfo.Filter() fltr = libosinfo.Filter()
fltr.add_constraint("class", "input") fltr.add_constraint("class", "input")
fltr.add_constraint("name", "tablet")
devs = self._os.get_all_devices(fltr) devs = self._os.get_all_devices(fltr)
if devs.get_length(): for idx in range(devs.get_length()):
return devs.get_nth(0).get_bus_type() dev = devs.get_nth(idx)
return "ps2" if devs.get_nth(idx).get_bus_type() == "usb":
return True
return False
def supports_virtiodisk(self): def supports_virtiodisk(self):
if self._os: if self._os: