diff --git a/qubes/vm/__init__.py b/qubes/vm/__init__.py index 1b0772b23..d80e40a12 100644 --- a/qubes/vm/__init__.py +++ b/qubes/vm/__init__.py @@ -52,6 +52,12 @@ def validate_name(holder, prop, value): raise qubes.exc.QubesValueError( 'VM name must be shorter than 32 characters') + if re.match(r"\A[0-9_-].*\Z", value) is not None: + if holder is not None and prop is not None: + raise qubes.exc.QubesPropertyValueError(holder, prop, value, + 'VM name cannot start with hyphen, underscore ' + 'or numbers'.format(prop.__name__)) + # this regexp does not contain '+'; if it had it, we should specifically # disallow 'lost+found' #1440 if re.match(r"\A[a-zA-Z][a-zA-Z0-9_-]*\Z", value) is None: