dom0/drive: add "cdrom:" prefix (#19)

To deal with VM named "hd". Also add --cdrom and --hddisk options to qvm-start.
This commit is contained in:
Marek Marczykowski 2012-03-26 20:25:49 +02:00
parent 1465b8f104
commit 7d66d7c842
2 changed files with 17 additions and 1 deletions

View File

@ -2224,7 +2224,9 @@ class QubesHVm(QubesVm):
backend_domain = "" backend_domain = ""
if drive_path.startswith("hd:"): if drive_path.startswith("hd:"):
type_mode = ",w" type_mode = ",w"
drive_path = drive_path[3:] elif drive_path.startswith("cdrom:"):
type_mode = ":cdrom,r"
drive_path = drive_path[6:]
backend_split = re.match(r"^([a-zA-Z0-9]*):(.*)", drive_path) backend_split = re.match(r"^([a-zA-Z0-9]*):(.*)", drive_path)
if backend_split: if backend_split:
backend_domain = "," + backend_split.group(1) backend_domain = "," + backend_split.group(1)

View File

@ -38,6 +38,10 @@ def main():
parser.add_option ("--console", action="store_true", dest="debug_console", default=False, parser.add_option ("--console", action="store_true", dest="debug_console", default=False,
help="Attach debugging console to the newly started VM") help="Attach debugging console to the newly started VM")
parser.add_option ("--drive", dest="drive", default=None, parser.add_option ("--drive", dest="drive", default=None,
help="Temporarily attach specified drive as CD/DVD or hard disk (can be specified with prefix 'hd:' or 'cdrom:', default is cdrom)")
parser.add_option ("--hddisk", dest="drive_hd", default=None,
help="Temporarily attach specified drive as hard disk")
parser.add_option ("--cdrom", dest="drive_cdrom", default=None,
help="Temporarily attach specified drive as CD/DVD") help="Temporarily attach specified drive as CD/DVD")
parser.add_option ("--dvm", action="store_true", dest="preparing_dvm", default=False, parser.add_option ("--dvm", action="store_true", dest="preparing_dvm", default=False,
help="Do actions necessary when preparing DVM image") help="Do actions necessary when preparing DVM image")
@ -59,6 +63,16 @@ def main():
print >> sys.stderr, "A VM with the name '{0}' does not exist in the system.".format(vmname) print >> sys.stderr, "A VM with the name '{0}' does not exist in the system.".format(vmname)
exit(1) exit(1)
if bool(options.drive_hd) + bool(options.drive_cdrom) + bool(options.drive) > 1:
print >> sys.stderr, "Only one of --drive, --cdrom, --hddisk can be specified"
exit(1)
if options.drive_hd:
options.drive = 'hd:' + options.drive_hd
if options.drive_cdrom:
options.drive = 'cdrom:' + options.drive_hd
if options.drive: if options.drive:
if hasattr(vm, 'drive'): if hasattr(vm, 'drive'):
vm.drive = options.drive vm.drive = options.drive