mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
nodedev: Fold DRMDevice into NodeDevice
This commit is contained in:
parent
87b2ea4672
commit
ab0c99057b
@ -138,17 +138,14 @@ class TestNodeDev(unittest.TestCase):
|
|||||||
|
|
||||||
def testDRMDevice(self):
|
def testDRMDevice(self):
|
||||||
devname = "drm_renderD129"
|
devname = "drm_renderD129"
|
||||||
vals = {"name": "drm_renderD129",
|
dev = self._nodeDevFromName(devname)
|
||||||
"parent": "pci_0000_00_02_0",
|
self.assertEqual(dev.devnodes[0].path, "/dev/dri/renderD129")
|
||||||
"devnodes": [
|
self.assertEqual(dev.devnodes[0].node_type, "dev")
|
||||||
{"path": "/dev/dri/renderD129", "node_type": "dev"},
|
self.assertEqual(dev.devnodes[1].path,
|
||||||
{"path": "/dev/dri/by-path/pci-0000:00:02.0-render", "node_type": "link"},
|
"/dev/dri/by-path/pci-0000:00:02.0-render")
|
||||||
{"path": "/dev/dri/by-id/foo-render", "node_type": "link"}
|
self.assertEqual(dev.devnodes[1].node_type, "link")
|
||||||
],
|
self.assertEqual(dev.is_drm_render(), True)
|
||||||
"device_type": NodeDevice.CAPABILITY_TYPE_DRM,
|
self.assertEqual(dev.pretty_name(),
|
||||||
"drm_type": "render"}
|
|
||||||
dev = self._testCompare(devname, vals)
|
|
||||||
self.assertEqual(dev.drm_pretty_name(self.conn),
|
|
||||||
"0000:00:02:0 Intel Corporation HD Graphics 530 (render)")
|
"0000:00:02:0 Intel Corporation HD Graphics 530 (render)")
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,12 +106,10 @@ class vmmGraphicsDetails(vmmGObjectUI):
|
|||||||
devs = self.conn.filter_nodedevs("drm")
|
devs = self.conn.filter_nodedevs("drm")
|
||||||
for i in devs:
|
for i in devs:
|
||||||
drm = i.xmlobj
|
drm = i.xmlobj
|
||||||
if drm.drm_type != 'render':
|
if not drm.is_drm_render():
|
||||||
continue
|
continue
|
||||||
rendernode = drm.get_devnode().path
|
rendernode = drm.get_devnode().path
|
||||||
|
model.append([rendernode, i.xmlobj.pretty_name()])
|
||||||
model.append([rendernode,
|
|
||||||
i.xmlobj.drm_pretty_name(self.conn.get_backend())])
|
|
||||||
|
|
||||||
def _get_config_graphics_ports(self):
|
def _get_config_graphics_ports(self):
|
||||||
port = uiutil.spin_get_helper(self.widget("graphics-port"))
|
port = uiutil.spin_get_helper(self.widget("graphics-port"))
|
||||||
|
@ -259,8 +259,7 @@ class DeviceGraphics(Device):
|
|||||||
if not self.rendernode and self.conn.check_support(
|
if not self.rendernode and self.conn.check_support(
|
||||||
self.conn.SUPPORT_CONN_SPICE_RENDERNODE):
|
self.conn.SUPPORT_CONN_SPICE_RENDERNODE):
|
||||||
for nodedev in self.conn.fetch_all_nodedevs():
|
for nodedev in self.conn.fetch_all_nodedevs():
|
||||||
if (nodedev.device_type != 'drm' or
|
if not nodedev.is_drm_render():
|
||||||
nodedev.drm_type != 'render'):
|
|
||||||
continue
|
continue
|
||||||
self.rendernode = nodedev.get_devnode().path
|
self.rendernode = nodedev.get_devnode().path
|
||||||
break
|
break
|
||||||
|
@ -97,16 +97,6 @@ class NodeDevice(XMLBuilder):
|
|||||||
name = XMLProperty("./name")
|
name = XMLProperty("./name")
|
||||||
parent = XMLProperty("./parent")
|
parent = XMLProperty("./parent")
|
||||||
device_type = XMLProperty("./capability/@type")
|
device_type = XMLProperty("./capability/@type")
|
||||||
devnodes = XMLChildProperty(DevNode)
|
|
||||||
|
|
||||||
def get_devnode(self, parent="by-path"):
|
|
||||||
for d in self.devnodes:
|
|
||||||
paths = d.path.split(os.sep)
|
|
||||||
if len(paths) > 2 and paths[-2] == parent:
|
|
||||||
return d
|
|
||||||
if len(self.devnodes) > 0:
|
|
||||||
return self.devnodes[0]
|
|
||||||
return None
|
|
||||||
|
|
||||||
def compare_to_hostdev(self, hostdev):
|
def compare_to_hostdev(self, hostdev):
|
||||||
if self.device_type == "pci":
|
if self.device_type == "pci":
|
||||||
@ -184,6 +174,11 @@ class NodeDevice(XMLBuilder):
|
|||||||
if self.device_type == "usb_device":
|
if self.device_type == "usb_device":
|
||||||
return self._usb_pretty_name()
|
return self._usb_pretty_name()
|
||||||
|
|
||||||
|
if self.device_type == "drm":
|
||||||
|
parent = NodeDevice.lookupNodedevFromString(
|
||||||
|
self.conn, self.parent)
|
||||||
|
return "%s (%s)" % (parent.pretty_name(), self._drm_type)
|
||||||
|
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
@ -200,6 +195,9 @@ class NodeDevice(XMLBuilder):
|
|||||||
return (self.vendor_id == "0x1d6b" and
|
return (self.vendor_id == "0x1d6b" and
|
||||||
self.product_id in ["0x0001", "0x0002", "0x0003"])
|
self.product_id in ["0x0001", "0x0002", "0x0003"])
|
||||||
|
|
||||||
|
def is_drm_render(self):
|
||||||
|
return self.device_type == "drm" and self._drm_type == "render"
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# XML properties #
|
# XML properties #
|
||||||
@ -237,14 +235,18 @@ class NodeDevice(XMLBuilder):
|
|||||||
"./capability/capability[@type='removable']/media_available",
|
"./capability/capability[@type='removable']/media_available",
|
||||||
is_int=True)
|
is_int=True)
|
||||||
|
|
||||||
|
# type='drm' options
|
||||||
|
_drm_type = XMLProperty("./capability/type")
|
||||||
|
devnodes = XMLChildProperty(DevNode)
|
||||||
|
|
||||||
class DRMDevice(NodeDevice):
|
def get_devnode(self, parent="by-path"):
|
||||||
drm_type = XMLProperty("./capability/type")
|
for d in self.devnodes:
|
||||||
|
paths = d.path.split(os.sep)
|
||||||
def drm_pretty_name(self, conn):
|
if len(paths) > 2 and paths[-2] == parent:
|
||||||
parent = NodeDevice.lookupNodedevFromString(conn, self.parent)
|
return d
|
||||||
|
if len(self.devnodes) > 0:
|
||||||
return "%s (%s)" % (parent.pretty_name(), self.drm_type)
|
return self.devnodes[0]
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _AddressStringToHostdev(conn, addrstr):
|
def _AddressStringToHostdev(conn, addrstr):
|
||||||
@ -313,7 +315,4 @@ def _AddressStringToNodedev(conn, addrstr):
|
|||||||
|
|
||||||
|
|
||||||
def _typeToDeviceClass(t):
|
def _typeToDeviceClass(t):
|
||||||
if t == NodeDevice.CAPABILITY_TYPE_DRM:
|
|
||||||
return DRMDevice
|
|
||||||
else:
|
|
||||||
return NodeDevice
|
return NodeDevice
|
||||||
|
Loading…
Reference in New Issue
Block a user