1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Prioritize the config disk over HD-D for Qemu VMs.

Fixes https://github.com/GNS3/gns3-gui/issues/3036

(cherry picked from commit c12b675691)
This commit is contained in:
grossmj 2020-08-18 10:54:11 +09:30 committed by Bernhard Ehlers
parent 01db2d2a86
commit 4843084158

View File

@ -1781,6 +1781,10 @@ class QemuVM(BaseNode):
drives = ["a", "b", "c", "d"] drives = ["a", "b", "c", "d"]
for disk_index, drive in enumerate(drives): for disk_index, drive in enumerate(drives):
# prioritize config disk over harddisk d
if drive == 'd' and self._create_config_disk:
continue
disk_image = getattr(self, "_hd{}_disk_image".format(drive)) disk_image = getattr(self, "_hd{}_disk_image".format(drive))
if not disk_image: if not disk_image:
continue continue
@ -1846,24 +1850,21 @@ class QemuVM(BaseNode):
# config disk # config disk
disk_image = getattr(self, "config_disk_image") disk_image = getattr(self, "config_disk_image")
if disk_image and self._create_config_disk: if disk_image and self._create_config_disk:
if getattr(self, "_hdd_disk_image"): disk_name = getattr(self, "config_disk_name")
log.warning("Config disk: blocked by disk image 'hdd'") disk = os.path.join(self.working_dir, disk_name)
else: if self.hdd_disk_interface == "none":
disk_name = getattr(self, "config_disk_name") # use the HDA interface type if none has been configured for HDD
disk = os.path.join(self.working_dir, disk_name) self.hdd_disk_interface = getattr(self, "hda_disk_interface", "none")
if self.hdd_disk_interface == "none": await self._import_config()
# use the HDA interface type if none has been configured for HDD disk_exists = os.path.exists(disk)
self.hdd_disk_interface = getattr(self, "hda_disk_interface", "none") if not disk_exists:
await self._import_config() try:
disk_exists = os.path.exists(disk) shutil.copyfile(disk_image, disk)
if not disk_exists: disk_exists = True
try: except OSError as e:
shutil.copyfile(disk_image, disk) log.warning("Could not create '{}' disk image: {}".format(disk_name, e))
disk_exists = True if disk_exists:
except OSError as e: options.extend(self._disk_interface_options(disk, 3, self.hdd_disk_interface, "raw"))
log.warning("Could not create '{}' disk image: {}".format(disk_name, e))
if disk_exists:
options.extend(self._disk_interface_options(disk, 3, self.hdd_disk_interface, "raw"))
return options return options