From 053cda8de76c269420fe7c026b4a1f87de3377dd Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 17 Sep 2015 15:18:22 -0400 Subject: [PATCH] virt-manager: Add hidden options --test-old-poll and --test-no-events For easy testing of fallback codepaths --- virt-manager | 12 ++++++++++++ virtManager/connection.py | 11 ++++++----- virtinst/pollhelpers.py | 13 +++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/virt-manager b/virt-manager index 0a9d4b4b2..b27248c08 100755 --- a/virt-manager +++ b/virt-manager @@ -101,6 +101,12 @@ def parse_commandline(): # PackageKit integration parser.add_argument("--test-first-run", dest="testfirstrun", help=argparse.SUPPRESS, action="store_true") + # Force use of old style libvirt polling APIs + parser.add_argument("--test-old-poll", dest="testoldpoll", + help=argparse.SUPPRESS, action="store_true") + # Force disable use of libvirt object events + parser.add_argument("--test-no-events", dest="testnoevents", + help=argparse.SUPPRESS, action="store_true") parser.add_argument("-c", "--connect", dest="uri", help="Connect to hypervisor at URI", metavar="URI") @@ -234,6 +240,12 @@ def main(): Gtk.Window.set_default_icon_name("virt-manager") + import virtManager.connection + virtManager.connection.FORCE_DISABLE_EVENTS = bool(options.testnoevents) + + import virtinst.pollhelpers + virtinst.pollhelpers.FORCE_OLD_POLL = bool(options.testoldpoll) + show = None if options.show_domain_creator: show = "creator" diff --git a/virtManager/connection.py b/virtManager/connection.py index 48eb4356d..9219f9b71 100644 --- a/virtManager/connection.py +++ b/virtManager/connection.py @@ -42,7 +42,8 @@ from .storagepool import vmmStoragePool # debugging helper to turn off events -_disable_libvirt_events = False +# Can be enabled with virt-manager --test-no-events +FORCE_DISABLE_EVENTS = False class _ObjectList(vmmGObject): @@ -748,8 +749,8 @@ class vmmConnection(vmmGObject): return try: - if _disable_libvirt_events: - raise RuntimeError("_disable_libvirt_events = True") + if FORCE_DISABLE_EVENTS: + raise RuntimeError("FORCE_DISABLE_EVENTS = True") self._domain_cb_ids.append( self.get_backend().domainEventRegisterAny( @@ -785,8 +786,8 @@ class vmmConnection(vmmGObject): "device added") try: - if _disable_libvirt_events: - raise RuntimeError("_disable_libvirt_events = True") + if FORCE_DISABLE_EVENTS: + raise RuntimeError("FORCE_DISABLE_EVENTS = True") eventid = getattr(libvirt, "VIR_NETWORK_EVENT_ID_LIFECYCLE", 0) self._network_cb_ids.append( diff --git a/virtinst/pollhelpers.py b/virtinst/pollhelpers.py index d4acc3032..2090b8c84 100644 --- a/virtinst/pollhelpers.py +++ b/virtinst/pollhelpers.py @@ -21,7 +21,8 @@ import logging # Debugging helper to force old style polling -_force_old_poll = False +# Can be enabled with virt-manager --test-old-poll +FORCE_OLD_POLL = False def _new_poll_helper(origmap, typename, listfunc, buildfunc): @@ -114,7 +115,7 @@ def fetch_nets(backend, origmap, build_func): name = "network" if backend.check_support( - backend.SUPPORT_CONN_LISTALLNETWORKS) and not _force_old_poll: + backend.SUPPORT_CONN_LISTALLNETWORKS) and not FORCE_OLD_POLL: return _new_poll_helper(origmap, name, backend.listAllNetworks, build_func) else: @@ -131,7 +132,7 @@ def fetch_pools(backend, origmap, build_func): name = "pool" if backend.check_support( - backend.SUPPORT_CONN_LISTALLSTORAGEPOOLS) and not _force_old_poll: + backend.SUPPORT_CONN_LISTALLSTORAGEPOOLS) and not FORCE_OLD_POLL: return _new_poll_helper(origmap, name, backend.listAllStoragePools, build_func) else: @@ -148,7 +149,7 @@ def fetch_volumes(backend, pool, origmap, build_func): name = "volume" if backend.check_support( - backend.SUPPORT_POOL_LISTALLVOLUMES, pool) and not _force_old_poll: + backend.SUPPORT_POOL_LISTALLVOLUMES, pool) and not FORCE_OLD_POLL: return _new_poll_helper(origmap, name, pool.listAllVolumes, build_func) else: @@ -165,7 +166,7 @@ def fetch_interfaces(backend, origmap, build_func): name = "interface" if backend.check_support( - backend.SUPPORT_CONN_LISTALLINTERFACES) and not _force_old_poll: + backend.SUPPORT_CONN_LISTALLINTERFACES) and not FORCE_OLD_POLL: return _new_poll_helper(origmap, name, backend.listAllInterfaces, build_func) else: @@ -181,7 +182,7 @@ def fetch_interfaces(backend, origmap, build_func): def fetch_nodedevs(backend, origmap, build_func): name = "nodedev" if backend.check_support( - backend.SUPPORT_CONN_LISTALLDEVICES) and not _force_old_poll: + backend.SUPPORT_CONN_LISTALLDEVICES) and not FORCE_OLD_POLL: return _new_poll_helper(origmap, name, backend.listAllDevices, build_func) else: