dom0/core: API CHANGE: change 'template_vm' to 'template'

Just to match property displayed everywhere, also simplifying tools like
qvm-prefs.
This commit is contained in:
Marek Marczykowski 2012-03-09 11:01:20 +01:00
parent e9d341ff71
commit d7aed8b233
10 changed files with 92 additions and 92 deletions

View File

@ -18,7 +18,7 @@ def main():
print templ, 'is not a template'
sys.exit(1)
for vm in qvm_collection.values():
if vm.template_vm is not None and vm.template_vm.qid == tvm.qid:
if vm.template is not None and vm.template.qid == tvm.qid:
vm.create_config_file()
main()

View File

@ -229,7 +229,7 @@ class QubesVm(object):
"firewall_conf": { "eval": 'self.absolute_path(value, default_firewall_conf_file)', 'order': 10 },
"installed_by_rpm": { "default": False, 'order': 10 },
"updateable": { "default": False, 'order': 10 },
"template_vm": { "default": None, 'order': 10 },
"template": { "default": None, 'order': 10 },
# order >= 20: have template set
"uses_default_netvm": { "default": True, 'order': 20 },
"netvm": { "default": None, "attr": "_netvm", 'order': 20 },
@ -242,7 +242,7 @@ class QubesVm(object):
"internal": { "default": False },
"vcpus": { "default": None },
"kernel": { "default": None, 'eval': \
'self.template_vm.kernel if self.template_vm is not None else value' },
'self.template.kernel if self.template is not None else value' },
"uses_default_kernel": { "default": True },
"uses_default_kernelopts": { "default": True },
"kernelopts": { "default": "", "eval": \
@ -253,10 +253,10 @@ class QubesVm(object):
##### 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 ' + \
'self.template_vm.appmenus_templates_dir if self.template_vm is not None else None' },
'self.template.appmenus_templates_dir if self.template is not None else None' },
"config_file_template": { "eval": "config_template_pv" },
"icon_path": { "eval": 'self.dir_path + "/icon.png" if self.dir_path is not None else None' },
"kernels_dir": { 'eval': 'self.template_vm.kernels_dir if self.template_vm is not None else ' + \
"kernels_dir": { 'eval': 'self.template.kernels_dir if self.template is not None else ' + \
'qubes_kernels_base_dir + "/" + self.kernel if self.kernel is not None else ' + \
# for backward compatibility (or another rare case): kernel=None -> kernel in VM dir
'self.dir_path + "/" + default_kernels_subdir' },
@ -279,8 +279,8 @@ class QubesVm(object):
attrs['netvm']['save'] = 'str(self.netvm.qid) if self.netvm is not None else "none"'
attrs['netvm']['save_attr'] = "netvm_qid"
attrs['template_vm']['save'] = 'str(self.template_vm.qid) if self.template_vm and not self.is_updateable() else "none"'
attrs['template_vm']['save_attr'] = "template_qid"
attrs['template']['save'] = 'str(self.template.qid) if self.template and not self.is_updateable() else "none"'
attrs['template']['save_attr'] = "template_qid"
attrs['label']['save'] = 'self.label.name'
return attrs
@ -326,15 +326,15 @@ class QubesVm(object):
self.vcpus = qubes_host.no_cpus
# Some additional checks for template based VM
if self.template_vm is not None:
if self.template is not None:
if self.updateable:
print >> sys.stderr, "ERROR: Template based VM cannot be updateable!"
return False
if not self.template_vm.is_template():
if not self.template.is_template():
print >> sys.stderr, "ERROR: template_qid={0} doesn't point to a valid TemplateVM".\
format(self.template_vm.qid)
format(self.template.qid)
return False
self.template_vm.appvms[self.qid] = self
self.template.appvms[self.qid] = self
else:
assert self.root_img is not None, "Missing root_img for standalone VM!"
@ -676,14 +676,14 @@ class QubesVm(object):
def is_outdated(self):
# Makes sense only on VM based on template
if self.template_vm is None:
if self.template is None:
return False
if not self.is_running():
return False
rootimg_inode = os.stat(self.template_vm.root_img)
rootcow_inode = os.stat(self.template_vm.rootcow_img)
rootimg_inode = os.stat(self.template.root_img)
rootcow_inode = os.stat(self.template.rootcow_img)
current_dmdev = "/dev/mapper/snapshot-{0:x}:{1}-{2:x}:{3}".format(
rootimg_inode[2], rootimg_inode[1],
@ -844,8 +844,8 @@ class QubesVm(object):
[{ 'dom': xid }])
def get_rootdev(self, source_template=None):
if self.template_vm:
return "'script:snapshot:{dir}/root.img:{dir}/root-cow.img,xvda,r',".format(dir=self.template_vm.dir_path)
if self.template:
return "'script:snapshot:{dir}/root.img:{dir}/root-cow.img,xvda,r',".format(dir=self.template.dir_path)
else:
return "'script:file:{dir}/root.img,xvda,w',".format(dir=self.dir_path)
@ -886,7 +886,7 @@ class QubesVm(object):
if file_path is None:
file_path = self.conf_file
if source_template is None:
source_template = self.template_vm
source_template = self.template
f_conf_template = open(self.config_file_template, 'r')
conf_template = f_conf_template.read()
@ -904,7 +904,7 @@ class QubesVm(object):
def create_on_disk(self, verbose, source_template = None):
if source_template is None:
source_template = self.template_vm
source_template = self.template
assert source_template is not None
if dry_run:
@ -963,7 +963,7 @@ class QubesVm(object):
def create_appmenus(self, verbose, source_template = None):
if source_template is None:
source_template = self.template_vm
source_template = self.template
vmtype = None
if self.is_netvm():
@ -1097,7 +1097,7 @@ class QubesVm(object):
assert not self.is_running(), "Attempt to clean volatile image of running VM!"
if source_template is None:
source_template = self.template_vm
source_template = self.template
# Only makes sense on template based VM
if source_template is None:
@ -1563,7 +1563,7 @@ class QubesTemplateVm(QubesVm):
def create_appmenus(self, verbose, source_template = None):
if source_template is None:
source_template = self.template_vm
source_template = self.template
try:
subprocess.check_call ([qubes_appmenu_create_cmd, self.appmenus_templates_dir, self.name, "vm-templates"])
@ -1653,7 +1653,7 @@ class QubesTemplateVm(QubesVm):
retcode = subprocess.call (["tar", "xf", self.clean_volatile_img, "-C", self.dir_path])
if retcode != 0:
raise IOError ("Error while unpacking {0} to {1}".\
format(self.template_vm.clean_volatile_img, self.volatile_img))
format(self.template.clean_volatile_img, self.volatile_img))
def commit_changes (self, verbose = False):
@ -1978,7 +1978,7 @@ class QubesDom0NetVm(QubesNetVm):
super(QubesDom0NetVm, self).__init__(qid=0, name="dom0", netid=0,
dir_path=None,
private_img = None,
template_vm = None,
template = None,
label = default_template_label)
self.xid = 0
@ -2050,7 +2050,7 @@ class QubesDisposableVm(QubesVm):
super(QubesDisposableVm, self).__init__(dir_path="/nonexistent", **kwargs)
assert self.template_vm is not None, "Missing template_vm for DisposableVM!"
assert self.template is not None, "Missing template for DisposableVM!"
# Use DispVM icon with the same color
if self._label:
@ -2075,7 +2075,7 @@ class QubesDisposableVm(QubesVm):
attrs["qid"] = str(self.qid)
attrs["name"] = self.name
attrs["dispid"] = str(self.dispid)
attrs["template_qid"] = str(self.template_vm.qid)
attrs["template_qid"] = str(self.template.qid)
attrs["label"] = self.label.name
attrs["firewall_conf"] = self.relative_path(self.firewall_conf)
return attrs
@ -2167,14 +2167,14 @@ class QubesVmCollection(dict):
assert False, "Attempt to add VM with qid that already exists in the collection!"
def add_new_appvm(self, name, template_vm,
def add_new_appvm(self, name, template,
dir_path = None, conf_file = None,
private_img = None,
updateable = False,
label = None):
qid = self.get_new_unused_qid()
vm = QubesAppVm (qid=qid, name=name, template_vm=template_vm,
vm = QubesAppVm (qid=qid, name=name, template=template,
dir_path=dir_path, conf_file=conf_file,
private_img=private_img,
netvm = self.get_default_netvm(),
@ -2188,11 +2188,11 @@ class QubesVmCollection(dict):
self[vm.qid]=vm
return vm
def add_new_disposablevm(self, name, template_vm, dispid,
def add_new_disposablevm(self, name, template, dispid,
label = None):
qid = self.get_new_unused_qid()
vm = QubesDisposableVm (qid=qid, name=name, template_vm=template_vm,
vm = QubesDisposableVm (qid=qid, name=name, template=template,
netvm = self.get_default_netvm(),
label=label, dispid=dispid)
@ -2220,27 +2220,27 @@ class QubesVmCollection(dict):
self[vm.qid]=vm
if self.default_template_qid is None:
self.set_default_template_vm(vm)
self.set_default_template(vm)
return vm
def clone_templatevm(self, src_template_vm, name, dir_path = None, verbose = False):
def clone_templatevm(self, src_template, name, dir_path = None, verbose = False):
assert not src_template_vm.is_running(), "Attempt to clone a running Template VM!"
assert not src_template.is_running(), "Attempt to clone a running Template VM!"
vm = self.add_new_templatevm (name=name, dir_path=dir_path, installed_by_rpm = False)
return vm
def add_new_netvm(self, name, template_vm,
def add_new_netvm(self, name, template,
dir_path = None, conf_file = None,
private_img = None, installed_by_rpm = False,
label = None, updateable = False):
qid = self.get_new_unused_qid()
netid = self.get_new_unused_netid()
vm = QubesNetVm (qid=qid, name=name, template_vm=template_vm,
vm = QubesNetVm (qid=qid, name=name, template=template,
netid=netid, label=label,
private_img=private_img, installed_by_rpm=installed_by_rpm,
updateable=updateable,
@ -2261,14 +2261,14 @@ class QubesVmCollection(dict):
return vm
def add_new_proxyvm(self, name, template_vm,
def add_new_proxyvm(self, name, template,
dir_path = None, conf_file = None,
private_img = None, installed_by_rpm = False,
label = None, updateable = False):
qid = self.get_new_unused_qid()
netid = self.get_new_unused_netid()
vm = QubesProxyVm (qid=qid, name=name, template_vm=template_vm,
vm = QubesProxyVm (qid=qid, name=name, template=template,
netid=netid, label=label,
private_img=private_img, installed_by_rpm=installed_by_rpm,
dir_path=dir_path, conf_file=conf_file,
@ -2289,11 +2289,11 @@ class QubesVmCollection(dict):
return vm
def set_default_template_vm(self, vm):
def set_default_template(self, vm):
assert vm.is_template(), "VM {0} is not a TemplateVM!".format(vm.name)
self.default_template_qid = vm.qid
def get_default_template_vm(self):
def get_default_template(self):
if self.default_template_qid is None:
return None
else:
@ -2356,7 +2356,7 @@ class QubesVmCollection(dict):
def get_vms_based_on(self, template_qid):
vms = set([vm for vm in self.values()
if (vm.template_vm and vm.template_vm.qid == template_qid)])
if (vm.template and vm.template.qid == template_qid)])
return vms
def get_vms_connected_to(self, netvm_qid):
@ -2510,12 +2510,12 @@ class QubesVmCollection(dict):
kwargs.pop("template_qid")
else:
kwargs["template_qid"] = int(kwargs["template_qid"])
template_vm = self[kwargs.pop("template_qid")]
if template_vm is None:
template = self[kwargs.pop("template_qid")]
if template is None:
print >> sys.stderr, "ERROR: VM '{0}' uses unkown template qid='{1}'!".\
format(kwargs["name"], kwargs["template_qid"])
else:
kwargs["template_vm"] = template_vm
kwargs["template"] = template
if "label" in kwargs:
if kwargs["label"] not in QubesVmLabels:
@ -2732,12 +2732,12 @@ class QubesVmCollection(dict):
kwargs["dispid"] = int(kwargs["dispid"])
kwargs["template_qid"] = int(kwargs["template_qid"])
template_vm = self[kwargs.pop("template_qid")]
if template_vm is None:
template = self[kwargs.pop("template_qid")]
if template is None:
print >> sys.stderr, "ERROR: DisposableVM '{0}' uses unkown template qid='{1}'!".\
format(kwargs["name"], kwargs["template_qid"])
else:
kwargs["template_vm"] = template_vm
kwargs["template"] = template
kwargs["netvm"] = self.get_default_netvm()

View File

@ -624,10 +624,10 @@ def backup_restore_prepare(backup_dir, options = {}, host_collection = None):
vms_to_restore[vm.name]['already-exists'] = True
vms_to_restore[vm.name]['good-to-go'] = False
if vm.template_vm is None:
if vm.template is None:
vms_to_restore[vm.name]['template'] = None
else:
templatevm_name = find_template_name(vm.template_vm.name, options['replace-template'])
templatevm_name = find_template_name(vm.template.name, options['replace-template'])
vms_to_restore[vm.name]['template'] = templatevm_name
template_vm_on_host = host_collection.get_vm_by_name (templatevm_name)
@ -638,7 +638,7 @@ def backup_restore_prepare(backup_dir, options = {}, host_collection = None):
if template_vm_on_backup is None or not template_vm_on_backup.is_template():
if options['use-default-template']:
vms_to_restore[vm.name]['orig-template'] = templatevm_name
vms_to_restore[vm.name]['template'] = host_collection.get_default_template_vm().name
vms_to_restore[vm.name]['template'] = host_collection.get_default_template().name
else:
vms_to_restore[vm.name]['missing-template'] = True
vms_to_restore[vm.name]['good-to-go'] = False
@ -704,7 +704,7 @@ def backup_restore_print_summary(restore_info, print_callback = print_stdout):
"updbl" : {"func": "'Yes' if vm.is_updateable() else ''"},
"template": {"func": "'n/a' if vm.is_template() or vm.template_vm is None else\
"template": {"func": "'n/a' if vm.is_template() or vm.template is None else\
vm_info['template']"},
"netvm": {"func": "'n/a' if vm.is_netvm() else\
@ -877,10 +877,10 @@ def backup_restore_do(backup_dir, restore_info, host_collection = None, print_ca
error_callback("Skiping...")
continue
template_vm = None
if vm.template_vm is not None:
template = None
if vm.template is not None:
template_name = vm_info['template']
template_vm = host_collection.get_vm_by_name(template_name)
template = host_collection.get_vm_by_name(template_name)
if not vm.uses_default_netvm:
uses_default_netvm = False
@ -895,13 +895,13 @@ def backup_restore_do(backup_dir, restore_info, host_collection = None, print_ca
restore_vm_dir (backup_dir, vm.dir_path, qubes_servicevms_dir);
if vm.type == "NetVM":
new_vm = host_collection.add_new_netvm(vm.name, template_vm,
new_vm = host_collection.add_new_netvm(vm.name, template,
conf_file=vm.conf_file,
dir_path=vm.dir_path,
updateable=updateable,
label=vm.label)
elif vm.type == "ProxyVM":
new_vm = host_collection.add_new_proxyvm(vm.name, template_vm,
new_vm = host_collection.add_new_proxyvm(vm.name, template,
conf_file=vm.conf_file,
dir_path=vm.dir_path,
updateable=updateable,
@ -942,10 +942,10 @@ def backup_restore_do(backup_dir, restore_info, host_collection = None, print_ca
error_callback("Skiping...")
continue
template_vm = None
if vm.template_vm is not None:
template = None
if vm.template is not None:
template_name = vm_info['template']
template_vm = host_collection.get_vm_by_name(template_name)
template = host_collection.get_vm_by_name(template_name)
if not vm.uses_default_netvm:
uses_default_netvm = False
@ -958,7 +958,7 @@ def backup_restore_do(backup_dir, restore_info, host_collection = None, print_ca
new_vm = None
try:
restore_vm_dir (backup_dir, vm.dir_path, qubes_appvms_dir);
new_vm = host_collection.add_new_appvm(vm.name, template_vm,
new_vm = host_collection.add_new_appvm(vm.name, template,
conf_file=vm.conf_file,
dir_path=vm.dir_path,
updateable=updateable,

View File

@ -32,7 +32,7 @@ def handle_vm(vms, label, new_value = None):
functions = { # label: [ getter, setter ],
'default-netvm': [ 'get_default_netvm', 'set_default_netvm' ],
'default-fw-netvm': [ 'get_default_fw_netvm', 'set_default_fw_netvm' ],
'default-template': [ 'get_default_template_vm', 'set_default_template_vm' ],
'default-template': [ 'get_default_template', 'set_default_template' ],
'clockvm': [ 'get_clockvm_vm', 'set_clockvm_vm' ],
'updatevm': [ 'get_updatevm_vm', 'set_updatevm_vm' ],
}

View File

@ -52,13 +52,13 @@ def main():
print >> sys.stderr, "ERROR: A VM with the name '{0}' already exists in the system.".format(vmname)
exit(1)
template_vm = qvm_collection.get_vm_by_name(templatename)
if template_vm is None:
template = qvm_collection.get_vm_by_name(templatename)
if template is None:
print >> sys.stderr, "ERROR: A Template VM with the name '{0}' does not exist in the system.".format(templatename)
exit(1)
vm = qvm_collection.add_new_appvm(vmname, template_vm,
vm = qvm_collection.add_new_appvm(vmname, template,
conf_file=options.conf_file,
dir_path=options.dir_path)

View File

@ -59,7 +59,7 @@ def main():
dst_vm = qvm_collection.add_new_templatevm(name=dstname,
dir_path=options.dir_path, installed_by_rpm=False)
elif isinstance(src_vm, QubesAppVm):
dst_vm = qvm_collection.add_new_appvm(name=dstname, template_vm=src_vm.template_vm,
dst_vm = qvm_collection.add_new_appvm(name=dstname, template=src_vm.template,
updateable=src_vm.updateable, label=src_vm.label,
dir_path=options.dir_path)
else:

View File

@ -91,29 +91,29 @@ def main():
exit(1)
if options.template is not None:
template_vm = qvm_collection.get_vm_by_name(options.template)
if template_vm is None:
template = qvm_collection.get_vm_by_name(options.template)
if template is None:
print >> sys.stderr, "There is no (Templete)VM with the name '{0}'".format(options.template)
exit (1)
if not template_vm.is_template():
if not template.is_template():
print >> sys.stderr, "VM '{0}' is not a TemplateVM".format(options.template)
exit (1)
if (options.verbose):
print "--> Using TemplateVM: {0}".format(template_vm.name)
print "--> Using TemplateVM: {0}".format(template.name)
else:
if qvm_collection.get_default_template_vm() is None:
if qvm_collection.get_default_template() is None:
print >> sys.stderr, "No default TempleteVM defined!"
exit (1)
else:
template_vm = qvm_collection.get_default_template_vm()
template = qvm_collection.get_default_template()
if (options.verbose):
print "--> Using default TemplateVM: {0}".format(template_vm.name)
print "--> Using default TemplateVM: {0}".format(template.name)
if options.standalone:
new_vm_template = None
else:
new_vm_template = template_vm
new_vm_template = template
vm = None
if options.netvm:
@ -133,7 +133,7 @@ def main():
vm.vcpus = options.vcpus
try:
vm.create_on_disk(verbose=options.verbose, source_template=template_vm)
vm.create_on_disk(verbose=options.verbose, source_template=template)
except (IOError, OSError) as err:
print >> sys.stderr, "ERROR: {0}".format(err)

View File

@ -30,8 +30,8 @@ import sys
fields = {
"qid": {"func": "vm.qid"},
"name": {"func": "('=>' if qvm_collection.get_default_template_vm() is not None\
and vm.qid == qvm_collection.get_default_template_vm().qid else '')\
"name": {"func": "('=>' if qvm_collection.get_default_template() is not None\
and vm.qid == qvm_collection.get_default_template().qid else '')\
+ ('[' if vm.is_template() else '')\
+ ('<' if vm.is_disposablevm() else '')\
+ ('{' if vm.is_netvm() else '')\
@ -47,8 +47,8 @@ fields = {
"updbl" : {"func": "'Yes' if vm.is_updateable() else ''"},
"template": {"func": "'n/a' if vm.is_template() else\
('None' if vm.template_vm is None else\
qvm_collection[vm.template_vm.qid].name)"},
('None' if vm.template is None else\
qvm_collection[vm.template.qid].name)"},
"netvm": {"func": "'n/a' if vm.is_netvm() and not vm.is_proxyvm() else\
('*' if vm.uses_default_netvm else '') +\
@ -149,7 +149,7 @@ def main():
# Now, the AppVMs without template...
for appvm in vms_list:
if appvm.is_appvm() and appvm.template_vm is None:
if appvm.is_appvm() and appvm.template is None:
vms_to_display.append (appvm)
# Now, the template, and all its AppVMs...
@ -158,7 +158,7 @@ def main():
vms_to_display.append (tvm)
for vm in vms_list:
if (vm.is_appvm() or vm.is_disposablevm()) and \
vm.template_vm and vm.template_vm.qid == tvm.qid:
vm.template and vm.template.qid == tvm.qid:
vms_to_display.append(vm)
assert len(vms_to_display) == no_vms

View File

@ -37,8 +37,8 @@ def do_list(vm):
print fmt.format ("name", vm.name)
print fmt.format ("label", vm.label.name)
print fmt.format ("type", vm.type)
if vm.template_vm is not None:
print fmt.format ("template", vm.template_vm.name)
if vm.template is not None:
print fmt.format ("template", vm.template.name)
if vm.netvm is not None:
print fmt.format ("netvm", vm.netvm.name)
print fmt.format ("updateable?", vm.is_updateable())
@ -47,12 +47,12 @@ def do_list(vm):
print fmt.format ("dir", vm.dir_path)
print fmt.format ("config", vm.conf_file)
print fmt.format ("pcidevs", vm.pcidevs)
if vm.template_vm is None:
if vm.template is None:
print fmt.format ("root img", vm.root_img)
if vm.is_template():
print fmt.format ("root COW img", vm.rootcow_img)
if vm.template_vm is not None:
print fmt.format ("root img", vm.template_vm.root_img)
if vm.template is not None:
print fmt.format ("root img", vm.template.root_img)
print fmt.format ("root volatile img", vm.volatile_img)
print fmt.format ("private img", vm.private_img)
@ -60,7 +60,7 @@ def do_list(vm):
print fmt.format ("memory", vm.memory)
print fmt.format ("maxmem", vm.maxmem)
print fmt.format ("MAC", "%s%s" % (vm.mac, " (auto)" if vm._mac is None else ""))
if vm.template_vm is not None:
if vm.template is not None:
print fmt.format ("kernel", "%s (from template)" % vm.kernel)
elif vm.uses_default_kernel:
print fmt.format ("kernel", "%s (default)" % vm.kernel)
@ -163,11 +163,11 @@ def set_updateable(vms, vm, args):
if vm.is_appvm():
# Check if the Template is *non* updateable...
if not vm.template_vm.is_updateable():
if not vm.template.is_updateable():
print >> sys.stderr, "VM '{0}': Setting 'updateable' attribute to True.".format(vm.name)
vm.set_updateable()
else:
print >> sys.stderr, "The Template VM ('{0}') is marked as 'updateable' itself!".format(vm.template_vm.name)
print >> sys.stderr, "The Template VM ('{0}') is marked as 'updateable' itself!".format(vm.template.name)
print >> sys.stderr, "Cannot make the AppVM updateable too, as this might cause COW-backed storage incoherency."
print >> sys.stderr, "If you want to make this AppVM updateable, you must first make the Template VM nonupdateable."
return False
@ -206,7 +206,7 @@ def set_nonupdateable(vms, vm, args):
return True
def set_kernel(vms, vm, args):
if vm.template_vm is not None:
if vm.template is not None:
print >> sys.stderr, "Cannot set kernel for template-based VM. Set it for template instead."
return False
@ -241,17 +241,17 @@ def set_template(vms, vm, args):
return False
template_name = args[0];
template_vm = vms.get_vm_by_name(template_name)
if template_vm is None or template_vm.qid not in vms:
template = vms.get_vm_by_name(template_name)
if template is None or template.qid not in vms:
print >> sys.stderr, "A VM with the name '{0}' does not exist in the system.".format(template_name)
return False
if not template_vm.is_template():
if not template.is_template():
print >> sys.stderr, "VM '{0}' is not a TemplateVM".format(template_name)
return False
print >> sys.stderr, "Setting template for VM '{0}' to '{1}'...".format (vm.name, template_name)
vm.template_vm = template_vm
vm.template = template
return True
def set_vcpus(vms, vm, args):

View File

@ -80,7 +80,7 @@ class QfileDaemonDvm:
qvm_collection.unlock_db()
return None
dispid=int(disp_name[4:])
dispvm=qvm_collection.add_new_disposablevm(disp_name, vm_disptempl.template_vm, label=vm.label, dispid=dispid)
dispvm=qvm_collection.add_new_disposablevm(disp_name, vm_disptempl.template, label=vm.label, dispid=dispid)
# By default inherit firewall rules from calling VM
if os.path.exists(vm.firewall_conf):
disp_firewall_conf = '/var/run/qubes/%s-firewall.xml' % disp_name