[RFC virt-manager v2] virtmanager: list active node devices only
Shalini Chellathurai Saroja
shalini at linux.ibm.com
Tue Jan 18 09:33:13 UTC 2022
With virt-manager application, it is possible to add inactive node
devices(eg: mediated devices) in host system to guest system. But it
is impossible to start a guest system with inactive node devices.
Also, it is not yet possible to start a node device with virt-manager
application. So, the user cannot use the inactive node device.
This patch filters out all inactive node devices and lists only active
node devices in virt-manager application, so that it is only possible
to add active node devices to the guest system.
Signed-off-by: Shalini Chellathurai Saroja <shalini at linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
virtManager/connection.py | 2 +-
virtinst/pollhelpers.py | 15 +++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/virtManager/connection.py b/virtManager/connection.py
index 68a37ea6..8462108b 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -1113,7 +1113,7 @@ class vmmConnection(vmmGObject):
dopoll = pollnodedev
objs = self.list_nodedevs()
cls = vmmNodeDevice
- pollcb = pollhelpers.fetch_nodedevs
+ pollcb = pollhelpers.fetch_active_nodedevs
else:
dopoll = pollvm
objs = self.list_vms()
diff --git a/virtinst/pollhelpers.py b/virtinst/pollhelpers.py
index ef695914..ca12d165 100644
--- a/virtinst/pollhelpers.py
+++ b/virtinst/pollhelpers.py
@@ -5,10 +5,11 @@
# See the COPYING file in the top-level directory.
#
+import libvirt
from .logger import log
-def _new_poll_helper(origmap, typename, list_cb, build_cb, support_cb):
+def _new_poll_helper(origmap, typename, list_cb, build_cb, support_cb, flags=0):
"""
Helper for new style listAll* APIs
"""
@@ -17,8 +18,10 @@ def _new_poll_helper(origmap, typename, list_cb, build_cb, support_cb):
objs = []
try:
- if support_cb():
+ if support_cb() and not(flags):
objs = list_cb()
+ else:
+ objs = list_cb(flags)
except Exception as e: # pragma: no cover
log.debug("Unable to list all %ss: %s", typename, e)
@@ -65,6 +68,14 @@ def fetch_nodedevs(backend, origmap, build_cb):
return _new_poll_helper(origmap, typename, list_cb, build_cb, support_cb)
+def fetch_active_nodedevs(backend, origmap, build_cb):
+ typename = "nodedev"
+ flags = libvirt.VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE
+ list_cb = backend.listAllDevices
+ support_cb = backend.support.conn_nodedev
+ return _new_poll_helper(origmap, typename, list_cb, build_cb, support_cb, flags)
+
+
def fetch_vms(backend, origmap, build_cb):
typename = "domain"
list_cb = backend.listAllDomains
--
2.34.1
More information about the virt-tools-list
mailing list