Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions etc/boot
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ for vm_ in vmrunner.vms:
if vm_._config.has_key("image") and vm_._config["image"].startswith(image_name):
vm = vm_

# Don't listen to events needed by testrunner
vm.on_success(lambda: None, do_exit = False)

if (args.clean):
print INFO, "Cleaning build"
vm.clean()
Expand Down
63 changes: 37 additions & 26 deletions vmrunner/vmrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,36 +109,39 @@ def abstract():
# (It seems to be recommended for "new style classes" to inherit object)
class hypervisor(object):

def __init__(self, config):
self._config = config;
def __init__(self, config):
self._config = config;

# Boot a VM, returning a hypervisor handle for reuse
def boot(self):
abstract()
# Boot a VM, returning a hypervisor handle for reuse
def boot(self):
abstract()

# Stop the VM booted by boot
def stop(self):
abstract()
# Stop the VM booted by boot
def stop(self):
abstract()

# Read a line of output from vm
def readline(self):
abstract()
# Read a line of output from vm
def readline(self):
abstract()

# Verify that the hypervisor is available
def available(self, config_data = None):
abstract()
# Verify that the hypervisor is available
def available(self, config_data = None):
abstract()

# Wait for this VM to exit
def wait(self):
abstract()
# Wait for this VM to exit
def wait(self):
abstract()

# Wait for this VM to exit
def poll(self):
abstract()
# Wait for this VM to exit
def poll(self):
abstract()

# A descriptive name
def name(self):
abstract()
# A descriptive name
def name(self):
abstract()

def image_name(self):
abstract()


# Qemu Hypervisor interface
Expand All @@ -149,13 +152,17 @@ def __init__(self, config):
self._proc = None
self._stopped = False
self._sudo = False
self._image_name = self._config if "image" in self._config else self.name() + " vm"

# Pretty printing
self.info = Logger(color.INFO("<" + type(self).__name__ + ">"))

def name(self):
return "Qemu"

def image_name(serlf):
return self._image_name

def drive_arg(self, filename, drive_type = "virtio", drive_format = "raw", media_type = "disk"):
return ["-drive","file=" + filename
+ ",format=" + drive_format
Expand Down Expand Up @@ -219,6 +226,8 @@ def boot(self, multiboot, kernel_args = "", image_name = None):
if not image_name:
image_name = self._config["image"]

self._image_name = image_name

# multiboot - e.g. boot with '-kernel' and no bootloader
if multiboot:

Expand Down Expand Up @@ -294,7 +303,7 @@ def stop(self):
parent = psutil.Process(self._proc.pid)
children = parent.children()

info ("Stopping", self._config["image"], "PID",self._proc.pid, "with", signal)
info ("Stopping", self._image_name, "PID",self._proc.pid, "with", signal)

for child in children:
info (" + child process ", child.pid)
Expand Down Expand Up @@ -421,8 +430,10 @@ def panic(self, panic_line):
def on_output(self, output, callback):
self._on_output[ output ] = callback

def on_success(self, callback):
self._on_output["SUCCESS"] = lambda(line) : [callback(line), self._on_success(line)]
def on_success(self, callback, do_exit = True):
if do_exit:
self._on_output["SUCCESS"] = lambda(line) : [callback(line), self._on_success(line)]
else: self._on_output["SUCCESS"] = callback

def on_panic(self, callback):
self._on_output["PANIC"] = lambda(line) : [callback(line), self._on_panic(line)]
Expand Down