core-admin/test-packages/libvirt.py
Marek Marczykowski-Górecki 466bf89aae
Fix starting VM with kernel=None
When dom0 do not provide the kernel, it should also not set kernel
command line in libvirt config. Otherwise qemu in stubdom fails to start
because it get -append option without -kernel, which is illegal
configuration.

Fixes QubesOS/qubes-issues#3339
2017-12-14 23:26:52 +01:00

36 lines
788 B
Python

"""mock libvirt module
WARNING: you did not import real libvirt module
This is needed, because we don't currently ship libvirt-python for templates.
The module contains libvirtError and openReadOnly() function, which
does nothing and raises the aforementioned exception. More functions can be
added as needed.
"""
class libvirtError(Exception):
def get_error_code(self):
return VIR_ERR_NO_DOMAIN
class virConnect:
pass
class virDomain:
pass
def openReadOnly(*args, **kwargs):
raise libvirtError('mock module, always raises')
def registerErrorHandler(f, ctx):
pass
VIR_DOMAIN_BLOCKED = 2
VIR_DOMAIN_RUNNING = 1
VIR_DOMAIN_PAUSED = 3
VIR_DOMAIN_SHUTDOWN = 4
VIR_DOMAIN_SHUTOFF = 5
VIR_DOMAIN_CRASHED = 6
VIR_DOMAIN_PMSUSPENDED = 7
VIR_ERR_NO_DOMAIN = 0