gns3-qemu-config - QEMU config disk
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.6KB

  1. From 406d04b465178b85d7b4d79e278aca5eb4d9f492 Mon Sep 17 00:00:00 2001
  2. From: Bernhard Ehlers <none@bernhard-ehlers.de>
  3. Date: Thu, 16 Apr 2020 11:07:56 +0200
  4. Subject: [PATCH 4/4] QEMU config disk - add missing config disk to image
  5. directory
  6. ---
  7. gns3server/compute/qemu/qemu_vm.py | 27 +++++++++++++++++------
  8. gns3server/compute/qemu/resources/config.img.zip | Bin 0 -> 1368 bytes
  9. 2 files changed, 20 insertions(+), 7 deletions(-)
  10. create mode 100644 gns3server/compute/qemu/resources/config.img.zip
  11. diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py
  12. index f4a9aa9c..d9e87a09 100644
  13. --- a/gns3server/compute/qemu/qemu_vm.py
  14. +++ b/gns3server/compute/qemu/qemu_vm.py
  15. @@ -46,6 +46,7 @@ from ..nios.nio_tap import NIOTAP
  16. from ..base_node import BaseNode
  17. from ...schemas.qemu import QEMU_OBJECT_SCHEMA, QEMU_PLATFORMS
  18. from ...utils.asyncio import monitor_process
  19. +from ...utils.get_resource import get_resource
  20. from ...utils.images import md5sum
  21. from ...utils import macaddress_to_int, int_to_macaddress
  22. @@ -128,19 +129,31 @@ class QemuVM(BaseNode):
  23. self.adapters = 1 # creates 1 adapter by default
  24. # config disk
  25. - self.config_disk_name = "config.img"
  26. + config_disk_name = "config.img"
  27. + self.config_disk_name = ""
  28. + self.config_disk_image = ""
  29. if not shutil.which("mcopy"):
  30. log.warning("Config disk: 'mtools' are not installed.")
  31. - self.config_disk_name = ""
  32. - self.config_disk_image = ""
  33. else:
  34. try:
  35. self.config_disk_image = self.manager.get_abs_image_path(
  36. - self.config_disk_name, self.project.path)
  37. + config_disk_name, self.project.path)
  38. + self.config_disk_name = config_disk_name
  39. except (NodeError, ImageMissingError) as e:
  40. - log.warning("Config disk: {}".format(e))
  41. - self.config_disk_name = ""
  42. - self.config_disk_image = ""
  43. + config_disk_zip = get_resource("compute/qemu/resources/{}.zip"
  44. + .format(config_disk_name))
  45. + if config_disk_zip and os.path.exists(config_disk_zip):
  46. + directory = self.manager.get_images_directory()
  47. + try:
  48. + unpack_zip(config_disk_zip, directory)
  49. + self.config_disk_image = os.path.join(directory,
  50. + config_disk_name)
  51. + self.config_disk_name = config_disk_name
  52. + except OSError as e:
  53. + log.warning("Config disk creation: {}".format(e))
  54. + else:
  55. + log.warning("Config disk: image '{}' missing"
  56. + .format(config_disk_name))
  57. log.info('QEMU VM "{name}" [{id}] has been created'.format(name=self._name, id=self._id))
  58. diff --git a/gns3server/compute/qemu/resources/config.img.zip b/gns3server/compute/qemu/resources/config.img.zip
  59. new file mode 100644
  60. index 0000000000000000000000000000000000000000..7ba43f9e0db1535a2d465dad484dbb05046d0575
  61. GIT binary patch
  62. literal 1368
  63. zcmWIWW@Zs#U|`^2;D~Dru#K9RvW^AFWe{NCVvu1-&d*EBOxMfIO%Dy>WMF>qt1IsH
  64. zrM|e*3T_5QmKV$n3}E8zbwxksKmmpeKW95!pUTp@`shWc00pfBTeG9qHMp<8A#4)E
  65. zbXhoHmV<u4dC9ILIUJsmt%oKEh)w!_re}s{+8rO3|KU@EmgL<#JA2Q&n*H@w|36Ly
  66. zI^oCUxN~{#lNVW7O3AoitC<{`Qo8(Jugy25|7)yb=FN}m@4i=IvFnAYUi;*K3p(@v
  67. zUVT%!tt#H7s^^pDs_VPYhPu?v-;_FqKU61Z&G-B=vp}~s{84u%ulITWwe0pc0S1Nx
  68. z`i1|2UKj<VAut*OBP0YaEaMOGW@M6M##QD?zyo4QBZ!Gy0<uC%K(x{?z?+o~q>>Q`
  69. L1Az1=aQO)Uu<e1^
  70. literal 0
  71. HcmV?d00001
  72. --
  73. 2.15.1 (Apple Git-101)