dom0/core: add 'debug' VM property (#537)

This commit is contained in:
Marek Marczykowski 2012-04-23 12:19:54 +02:00
parent c76d2fd864
commit a38f1b4284
2 changed files with 29 additions and 3 deletions

View File

@ -256,6 +256,7 @@ class QubesVm(object):
"mac": { "attr": "_mac", "default": None },
"include_in_backups": { "default": True },
"services": { "default": {}, "eval": "eval(str(value))" },
"debug": { "default": False },
##### Internal attributes - will be overriden in __init__ regardless of args
"appmenus_templates_dir": { "eval": \
'self.dir_path + "/" + default_appmenus_templates_subdir if self.updateable else ' + \
@ -272,7 +273,7 @@ class QubesVm(object):
for prop in ['qid', 'name', 'dir_path', 'memory', 'maxmem', 'pcidevs', 'vcpus', 'internal',\
'uses_default_kernel', 'kernel', 'uses_default_kernelopts',\
'kernelopts', 'services', 'installed_by_rpm',\
'uses_default_netvm', 'include_in_backups' ]:
'uses_default_netvm', 'include_in_backups', 'debug' ]:
attrs[prop]['save'] = 'str(self.%s)' % prop
# Simple paths
for prop in ['conf_file', 'root_img', 'volatile_img', 'private_img']:
@ -899,6 +900,9 @@ class QubesVm(object):
args['otherdevs'] = "'script:file:{dir}/modules.img,xvdd,{mode}',".format(dir=self.kernels_dir, mode=modulesmode)
if hasattr(self, 'kernelopts'):
args['kernelopts'] = self.kernelopts
if self.debug:
print >> sys.stderr, "--> Debug mode: adding 'earlyprintk=xen' to kernel opts"
args['kernelopts'] += ' earlyprintk=xen'
return args
@ -1332,7 +1336,10 @@ class QubesVm(object):
print >> sys.stderr, "--> Starting Qubes GUId..."
xid = self.get_xid()
retcode = subprocess.call ([qubes_guid_path, "-d", str(xid), "-c", self.label.color, "-i", self.label.icon, "-l", str(self.label.index)])
guid_cmd = [qubes_guid_path, "-d", str(xid), "-c", self.label.color, "-i", self.label.icon, "-l", str(self.label.index)]
if self.debug:
guid_cmd += ['-v', '-v']
retcode = subprocess.call (guid_cmd)
if (retcode != 0) :
raise QubesException("Cannot start qubes_guid!")
@ -2724,7 +2731,7 @@ class QubesVmCollection(dict):
"installed_by_rpm", "internal",
"uses_default_netvm", "label", "memory", "vcpus", "pcidevs",
"maxmem", "kernel", "uses_default_kernel", "kernelopts", "uses_default_kernelopts",
"mac", "services", "include_in_backups" )
"mac", "services", "include_in_backups", "debug" )
for attribute in common_attr_list:
kwargs[attribute] = element.get(attribute)
@ -2783,6 +2790,9 @@ class QubesVmCollection(dict):
if "kernelopts" not in kwargs:
kwargs["uses_default_kernelopts"] = True
if "debug" in kwargs:
kwargs["debug"] = True if kwargs["debug"] == "True" else False
return kwargs
def set_netvm_dependency(self, element):

View File

@ -75,6 +75,8 @@ def do_list(vm):
print fmt.format ("kernelopts", "%s (default)" % vm.kernelopts)
else:
print fmt.format ("kernelopts", vm.kernelopts)
if hasattr(vm, 'debug'):
print fmt.format("debug", "on" if vm.debug else "off")
if hasattr(vm, 'drive'):
print fmt.format("drive", str(vm.drive))
@ -289,6 +291,19 @@ def set_include_in_backups(vms, vm, args):
vm.include_in_backups = bool(eval(args[0].capitalize()))
return True
def set_debug(vms, vm, args):
if len (args) != 1:
print >> sys.stderr, "Missing value (True/False or on/off)!"
return False
if args[0].lower() == "on":
vm.debug = True
elif args[0].lower() == "off":
vm.debug = False
else:
vm.debug = bool(eval(args[0].capitalize()))
return True
properties = {
"include_in_backups": set_include_in_backups,
"pcidevs": set_pcidevs,
@ -303,6 +318,7 @@ properties = {
"name": set_name,
"drive": set_drive,
"mac": set_mac,
"debug": set_debug,
}