virt-manager: Add hidden options --test-old-poll and --test-no-events

For easy testing of fallback codepaths
This commit is contained in:
Cole Robinson 2015-09-17 15:18:22 -04:00
parent b15c44923c
commit 053cda8de7
3 changed files with 25 additions and 11 deletions

View File

@ -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"

View File

@ -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(

View File

@ -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: