Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using both HD-D and config disk the server prioritizes HD-D while GUI prioritizes config disk #3036

Closed
ghost opened this issue Aug 17, 2020 · 3 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Aug 17, 2020

Describe the bug

When setting both HD-D and config disk the GUI indicates that the config disk is used:

hdd+config

But the server prioritizes HD-D

2020-08-17 04:15:57 INFO qemu_vm.py:1701 Executing qemu-img with: /usr/bin/qemu-img check /opt/gns3/images/QEMU/IOSv_startup_config.img
2020-08-17 04:15:57 INFO qemu_vm.py:1705 /usr/bin/qemu-img returned with 63
2020-08-17 04:15:57 INFO qemu_vm.py:1699 logging to /opt/gns3/projects/7cc58424-6729-468f-b975-db810c4fc2e6/project-files/qemu/cd1e3a67-0b26-47ef-a94c-a7b57a13f74c/qemu-img.log
2020-08-17 04:15:57 INFO qemu_vm.py:1701 Executing qemu-img with: /usr/bin/qemu-img create -o backing_file=/opt/gns3/images/QEMU/IOSv_startup_config.img -f qcow2 /opt/gns3/projects/7cc58424-6729-468f-b975-db810c4fc2e6/project-files/qemu/cd1e3a67-0b26-47ef-a94c-a7b57a13f74c/hdd_disk.qcow2
2020-08-17 04:15:57 INFO qemu_vm.py:1705 /usr/bin/qemu-img returned with 0
2020-08-17 04:15:57 WARNING qemu_vm.py:1880 Config disk: blocked by disk image 'hdd'
2020-08-17 04:15:57 INFO base_node.py:865 Qemu: 'MicroCore-1' [cd1e3a67-0b26-47ef-a94c-a7b57a13f74c]:local UDP tunnel created between port 10000 and 10001
2020-08-17 04:15:57 INFO qemu_vm.py:1064 Starting QEMU with: /usr/bin/qemu-system-i386 -name MicroCore-1 -m 64M -smp cpus=1,maxcpus=1 -enable-kvm -boot order=c -drive file=/opt/gns3/projects/7cc58424-6729-468f-b975-db810c4fc2e6/project-files/qemu/cd1e3a67-0b26-47ef-a94c-a7b57a13f74c/hda_disk.qcow2,if=ide,index=0,media=disk,id=drive0 -drive file=/opt/gns3/projects/7cc58424-6729-468f-b975-db810c4fc2e6/project-files/qemu/cd1e3a67-0b26-47ef-a94c-a7b57a13f74c/hdd_disk.qcow2,if=ide,index=3,media=disk,id=drive3 -uuid cd1e3a67-0b26-47ef-a94c-a7b57a13f74c -serial telnet:127.0.0.1:5001,server,nowait -monitor tcp:127.0.0.1:36207,server,nowait -net none -device e1000,mac=0c:c2:e6:f7:4c:00,netdev=gns3-0 -netdev socket,id=gns3-0,udp=127.0.0.1:10001,localaddr=127.0.0.1:10000 -display none

GNS3 version and operating system (please complete the following information):

  • OS: macOS 10.13.6
  • GNS3 version 2.3.0dev2
  • Using GNS3 VM

To Reproduce
Steps to reproduce the behavior:

  1. Open a QEMU VM configuration
  2. Set both HD-D and config disk
  3. Start QEMU VM
  4. Look into server log, alternatively check QEMU process arguments
@ghost ghost added the Bug label Aug 17, 2020
@grossmj grossmj added this to the 2.3 milestone Aug 17, 2020
@grossmj
Copy link
Member

grossmj commented Aug 17, 2020

I guess it will be better to handle this case on server side.

@ghost
Copy link
Author

ghost commented Aug 17, 2020

This prioritizes the config disk over HD-D on server side:

diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py
index 4993a8e6..3801cc08 100644
--- a/gns3server/compute/qemu/qemu_vm.py
+++ b/gns3server/compute/qemu/qemu_vm.py
@@ -1811,6 +1811,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
@@ -1876,24 +1880,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

grossmj added a commit to GNS3/gns3-server that referenced this issue Aug 18, 2020
@grossmj
Copy link
Member

grossmj commented Aug 18, 2020

Should be fixed now. Thanks 👍

@grossmj grossmj closed this as completed Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant