From 4843084158313a9c4ecfcd3ff4b5669647f1f48d Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 18 Aug 2020 10:54:11 +0930 Subject: [PATCH] Prioritize the config disk over HD-D for Qemu VMs. Fixes https://github.com/GNS3/gns3-gui/issues/3036 (cherry picked from commit c12b675691e01bedf093c57660db6a5ad19f39eb) --- gns3server/compute/qemu/qemu_vm.py | 37 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 62148042..611442e3 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1781,6 +1781,10 @@ class QemuVM(BaseNode): drives = ["a", "b", "c", "d"] 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)) if not disk_image: continue @@ -1846,24 +1850,21 @@ class QemuVM(BaseNode): # config disk disk_image = getattr(self, "config_disk_image") if disk_image and self._create_config_disk: - if getattr(self, "_hdd_disk_image"): - log.warning("Config disk: blocked by disk image 'hdd'") - else: - disk_name = getattr(self, "config_disk_name") - disk = os.path.join(self.working_dir, disk_name) - if self.hdd_disk_interface == "none": - # use the HDA interface type if none has been configured for HDD - self.hdd_disk_interface = getattr(self, "hda_disk_interface", "none") - await self._import_config() - disk_exists = os.path.exists(disk) - if not disk_exists: - try: - shutil.copyfile(disk_image, disk) - disk_exists = True - except OSError as e: - 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")) + disk_name = getattr(self, "config_disk_name") + disk = os.path.join(self.working_dir, disk_name) + if self.hdd_disk_interface == "none": + # use the HDA interface type if none has been configured for HDD + self.hdd_disk_interface = getattr(self, "hda_disk_interface", "none") + await self._import_config() + disk_exists = os.path.exists(disk) + if not disk_exists: + try: + shutil.copyfile(disk_image, disk) + disk_exists = True + except OSError as e: + 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