Skip to content

Commit

Permalink
Don't allow VM name ending in -dm
Browse files Browse the repository at this point in the history
This is used internally for device-model stubdomains (untrusted qemu)
for HVMs, and causes conflicts when trying to boot foo (HVM) and foo-dm
(any type).

Partially fixes QubesOS/qubes-issues#2422
  • Loading branch information
jpouellet committed Nov 22, 2016
1 parent 68a116e commit c4f30bc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core-modules/000QubesVm.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def __init__(self, **kwargs):

if not self.verify_name(self.name):
msg = ("'%s' is invalid VM name (invalid characters, over 31 chars long, "
"or one of 'none', 'true', 'false')") % self.name
"ends with '-dm', or one of 'none', 'true', 'false')") % self.name
if 'xml_element' in kwargs:
print >>sys.stderr, "WARNING: %s" % msg
else:
Expand Down Expand Up @@ -569,6 +569,9 @@ def verify_name(self, name):
# avoid conflict when /var/lib/qubes/appvms is mounted on
# separate partition
return False
if name.endswith('-dm'):
# avoid conflict with device model stubdomain names for HVMs
return False
return re.match(r"^[a-zA-Z][a-zA-Z0-9_.-]*$", name) is not None

def pre_rename(self, new_name):
Expand All @@ -585,7 +588,7 @@ def set_name(self, name):
raise QubesException("Cannot change name of running VM!")

if not self.verify_name(name):
raise QubesException("Invalid characters in VM name")
raise QubesException("Invalid VM name")

if self.installed_by_rpm:
raise QubesException("Cannot rename VM installed by RPM -- first clone VM and then use yum to remove package.")
Expand Down

0 comments on commit c4f30bc

Please sign in to comment.