On 03/06/2013 03:58 PM, Lucas Meneghel Rodrigues wrote:
On 03/06/2013 05:34 PM, Chris Evich wrote:
On 03/05/2013 11:17 AM, Lucas Meneghel Rodrigues wrote:
Maybe even have a dedicated VMCrashError exception that tests could
catch in case it's what they're looking for (i.e. error testing)?
There is one. see qemu_vm.py
class QemuSegFaultError(virt_vm.VMError):
def __init__(self, crash_message):
virt_vm.VMError.__init__(self, crash_message)
self.crash_message = crash_message
def __str__(self):
return ("Qemu crashed: %s" % self.crash_message)
Ohh, maybe I'm mistaken. What kind of "crash" are we talking about
detecting here? I understood from "VM userspace crashes" that this was
guest kernel-panics, OOPS's, and other such nasties. Is it something
else, or all-of-the-above?
VM userpace - emulator, userspace programs that allow a vm to exist -
for QEMU, that is, well, QEMU. For libvirt, it is libvirt and whatever
is the driver (may be also QEMU). Nothing to do with guest kernel panics
OOPS's and similar.
Ahh, okay, my mistake then. So if it were in vm.destroy() then we would
need to check twice. Once at the beginning, to make sure
qemu/libvirtd/etc. didn't die prior to the call. Then again at the end
to make sure whatever destroy did, wasn't the cause of a
qemu/libvirtd/etc. failure.
Maybe this could be avoided by sticking the check into one of the
is_alive() type status calls? It sounds like a legitimate reason for it
to fail. The down-side being a possibly large performance penalty. The
up-side is we'd be very through and fast at detecting failures in
qemu/libvirt/etc.
Here's an idea: Stick a callable instance onto BaseVM which simply calls
each of it's methods as long as they return True. e.g.
class ChecksOut(object):
def __init__(self, vm):
self.vm = vm
def __call_them__(self):
for name, mthd in self.__dict__.items():
if not name.startswith("__") and callable(mthd):
yield mthd(self.vm)
def __call__(self):
# Use generator/iterator for speed (first False stops checking)
return not False in self.__call_them__()
Then is_alive (and friends) would simply call vm.checksout() to see if
an exception should be raised. e.g.
>>> def foobar(vm):
... return bool(vm.count("qemu"))
...
>>>
>>> def baz(vm):
... return not bool(vm.count("dead"))
...
>>> co = ChecksOut("qemu alive")
>>> co.check1 = foobar
>>> co.check2 = baz
>>> if not co():
... raise Exception()
...
>>> co = ChecksOut("dead qemu")
>>> co.something = foobar
>>> co.thing = baz
>>> if not co():
... raise Exception()
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
Exception
vm.__init__ would have to create the instance (passing self in as vm
parameter) and attach basic checks. Other areas of the code (including
test modules) would be free to tack-on (or delete) specialized checks as
needed, so this would be very flexible.
Anyway, hopefully you get the idea.
--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel