trim-template: Fix handling long named templates
Trim template name to fit full VM name in 31 chars. At the same time, check if the VM already exists - if so - remove it first (or error out asking the user to remove it manually - if VM isn't marked as internal). Now that VM is created as internal, to skip appmenus creation. QubesOS/qubes-issues#1910 Fixes QubesOS/qubes-issues#1655
This commit is contained in:
parent
92b49fe9a4
commit
10f0716911
@ -92,10 +92,21 @@ def main():
|
||||
touch_dvm_savefile = is_dvm_up_to_date(tvm, dvm_tmpl)
|
||||
|
||||
print >> sys.stderr, "Creating temporary VM..."
|
||||
fstrim_vm = qvm_collection.add_new_vm("QubesAppVm",
|
||||
template=tvm,
|
||||
name="{}-fstrim".format(tvm_name),
|
||||
netvm=None,
|
||||
trim_vmname = "trim-{}".format(tvm_name[:31 - len('trim-')])
|
||||
fstrim_vm = qvm_collection.get_vm_by_name(trim_vmname)
|
||||
if fstrim_vm is not None:
|
||||
if not fstrim_vm.internal:
|
||||
print >>sys.stderr, \
|
||||
"ERROR: VM '{}' already exists and is not marked as internal. " \
|
||||
"Remove it manually."
|
||||
fstrim_vm.remove_from_disk()
|
||||
qvm_collection.pop(fstrim_vm.qid)
|
||||
fstrim_vm = qvm_collection.add_new_vm(
|
||||
"QubesAppVm",
|
||||
template=tvm,
|
||||
name=trim_vmname,
|
||||
netvm=None,
|
||||
internal=True,
|
||||
)
|
||||
if not fstrim_vm:
|
||||
print >> sys.stderr, "ERROR: Failed to create new VM"
|
||||
|
Loading…
Reference in New Issue
Block a user