core/hvm: check if VM serving cdrom content is running
This commit is contained in:
		
							parent
							
								
									4a01c53787
								
							
						
					
					
						commit
						8f862cdf69
					
				@ -329,6 +329,10 @@ class QubesHVm(QubesVm):
 | 
				
			|||||||
            return -1
 | 
					            return -1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def start(self, *args, **kwargs):
 | 
					    def start(self, *args, **kwargs):
 | 
				
			||||||
 | 
					        # make it available to storage.prepare_for_vm_startup, which is
 | 
				
			||||||
 | 
					        # called before actually building VM libvirt configuration
 | 
				
			||||||
 | 
					        self.storage.drive = self.drive
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if self.template and self.template.is_running():
 | 
					        if self.template and self.template.is_running():
 | 
				
			||||||
            raise QubesException("Cannot start the HVM while its template is running")
 | 
					            raise QubesException("Cannot start the HVM while its template is running")
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
 | 
				
			|||||||
@ -226,3 +226,24 @@ class QubesXenVmStorage(QubesVmStorage):
 | 
				
			|||||||
                return
 | 
					                return
 | 
				
			||||||
        super(QubesXenVmStorage, self).reset_volatile_storage(
 | 
					        super(QubesXenVmStorage, self).reset_volatile_storage(
 | 
				
			||||||
            verbose=verbose, source_template=source_template)
 | 
					            verbose=verbose, source_template=source_template)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def prepare_for_vm_startup(self, verbose):
 | 
				
			||||||
 | 
					        super(QubesXenVmStorage, self).prepare_for_vm_startup(verbose=verbose)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if self.drive is not None:
 | 
				
			||||||
 | 
					            (drive_type, drive_domain, drive_path) = self.drive.split(":")
 | 
				
			||||||
 | 
					            if drive_domain.lower() != "dom0":
 | 
				
			||||||
 | 
					                try:
 | 
				
			||||||
 | 
					                    # FIXME: find a better way to access QubesVmCollection
 | 
				
			||||||
 | 
					                    drive_vm = self.vm._collection.get_vm_by_name(drive_domain)
 | 
				
			||||||
 | 
					                    # prepare for improved QubesVmCollection
 | 
				
			||||||
 | 
					                    if drive_vm is None:
 | 
				
			||||||
 | 
					                        raise KeyError
 | 
				
			||||||
 | 
					                    if not drive_vm.is_running():
 | 
				
			||||||
 | 
					                        raise QubesException(
 | 
				
			||||||
 | 
					                            "VM '{}' holding '{}' isn't running".format(
 | 
				
			||||||
 | 
					                                drive_domain, drive_path))
 | 
				
			||||||
 | 
					                except KeyError:
 | 
				
			||||||
 | 
					                    raise QubesException(
 | 
				
			||||||
 | 
					                        "VM '{}' holding '{}' does not exists".format(
 | 
				
			||||||
 | 
					                            drive_domain, drive_path))
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user