mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Set default disk interface type to "none".
Fail-safe: use "ide" if an image is set but no interface type is configured. Use the HDA disk interface type if none has been configured for HDD.
This commit is contained in:
parent
56aba96a5f
commit
464fd804ce
@ -103,10 +103,10 @@ class QemuVM(BaseNode):
|
|||||||
self._hdb_disk_image = ""
|
self._hdb_disk_image = ""
|
||||||
self._hdc_disk_image = ""
|
self._hdc_disk_image = ""
|
||||||
self._hdd_disk_image = ""
|
self._hdd_disk_image = ""
|
||||||
self._hda_disk_interface = "ide"
|
self._hda_disk_interface = "none"
|
||||||
self._hdb_disk_interface = "ide"
|
self._hdb_disk_interface = "none"
|
||||||
self._hdc_disk_interface = "ide"
|
self._hdc_disk_interface = "none"
|
||||||
self._hdd_disk_interface = "ide"
|
self._hdd_disk_interface = "none"
|
||||||
self._cdrom_image = ""
|
self._cdrom_image = ""
|
||||||
self._bios_image = ""
|
self._bios_image = ""
|
||||||
self._boot_priority = "c"
|
self._boot_priority = "c"
|
||||||
@ -1760,13 +1760,15 @@ class QemuVM(BaseNode):
|
|||||||
|
|
||||||
for disk_index, drive in enumerate(drives):
|
for disk_index, drive in enumerate(drives):
|
||||||
disk_image = getattr(self, "_hd{}_disk_image".format(drive))
|
disk_image = getattr(self, "_hd{}_disk_image".format(drive))
|
||||||
interface = getattr(self, "hd{}_disk_interface".format(drive))
|
|
||||||
|
|
||||||
if not disk_image:
|
if not disk_image:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
disk_name = "hd" + drive
|
interface = getattr(self, "hd{}_disk_interface".format(drive))
|
||||||
|
# fail-safe: use "ide" if there is a disk image and no interface type has been explicitly configured
|
||||||
|
if interface == "none":
|
||||||
|
setattr(self, "hd{}_disk_interface".format(drive), "ide")
|
||||||
|
|
||||||
|
disk_name = "hd" + drive
|
||||||
if not os.path.isfile(disk_image) or not os.path.exists(disk_image):
|
if not os.path.isfile(disk_image) or not os.path.exists(disk_image):
|
||||||
if os.path.islink(disk_image):
|
if os.path.islink(disk_image):
|
||||||
raise QemuError("{} disk image '{}' linked to '{}' is not accessible".format(disk_name, disk_image, os.path.realpath(disk_image)))
|
raise QemuError("{} disk image '{}' linked to '{}' is not accessible".format(disk_name, disk_image, os.path.realpath(disk_image)))
|
||||||
@ -1826,9 +1828,9 @@ class QemuVM(BaseNode):
|
|||||||
else:
|
else:
|
||||||
disk_name = getattr(self, "config_disk_name")
|
disk_name = getattr(self, "config_disk_name")
|
||||||
disk = os.path.join(self.working_dir, disk_name)
|
disk = os.path.join(self.working_dir, disk_name)
|
||||||
interface = getattr(self, "hdd_disk_interface", "ide")
|
if self.hdd_disk_interface == "none":
|
||||||
if interface == "ide":
|
# use the HDA interface type if none has been configured for HDD
|
||||||
interface = getattr(self, "hda_disk_interface", "none")
|
self.hdd_disk_interface = getattr(self, "hda_disk_interface", "none")
|
||||||
await self._import_config()
|
await self._import_config()
|
||||||
disk_exists = os.path.exists(disk)
|
disk_exists = os.path.exists(disk)
|
||||||
if not disk_exists:
|
if not disk_exists:
|
||||||
@ -1838,8 +1840,7 @@ class QemuVM(BaseNode):
|
|||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.warning("Could not create '{}' disk image: {}".format(disk_name, e))
|
log.warning("Could not create '{}' disk image: {}".format(disk_name, e))
|
||||||
if disk_exists:
|
if disk_exists:
|
||||||
options.extend(self._disk_interface_options(disk, 3, interface, "raw"))
|
options.extend(self._disk_interface_options(disk, 3, self.hdd_disk_interface, "raw"))
|
||||||
self.hdd_disk_image = disk
|
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ QEMU_TEMPLATE_PROPERTIES = {
|
|||||||
"hda_disk_interface": {
|
"hda_disk_interface": {
|
||||||
"description": "QEMU hda interface",
|
"description": "QEMU hda interface",
|
||||||
"enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
|
"enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
|
||||||
"default": "ide"
|
"default": "none"
|
||||||
},
|
},
|
||||||
"hdb_disk_image": {
|
"hdb_disk_image": {
|
||||||
"description": "QEMU hdb disk image path",
|
"description": "QEMU hdb disk image path",
|
||||||
@ -121,7 +121,7 @@ QEMU_TEMPLATE_PROPERTIES = {
|
|||||||
"hdb_disk_interface": {
|
"hdb_disk_interface": {
|
||||||
"description": "QEMU hdb interface",
|
"description": "QEMU hdb interface",
|
||||||
"enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
|
"enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
|
||||||
"default": "ide"
|
"default": "none"
|
||||||
},
|
},
|
||||||
"hdc_disk_image": {
|
"hdc_disk_image": {
|
||||||
"description": "QEMU hdc disk image path",
|
"description": "QEMU hdc disk image path",
|
||||||
@ -131,7 +131,7 @@ QEMU_TEMPLATE_PROPERTIES = {
|
|||||||
"hdc_disk_interface": {
|
"hdc_disk_interface": {
|
||||||
"description": "QEMU hdc interface",
|
"description": "QEMU hdc interface",
|
||||||
"enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
|
"enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
|
||||||
"default": "ide"
|
"default": "none"
|
||||||
},
|
},
|
||||||
"hdd_disk_image": {
|
"hdd_disk_image": {
|
||||||
"description": "QEMU hdd disk image path",
|
"description": "QEMU hdd disk image path",
|
||||||
@ -141,7 +141,7 @@ QEMU_TEMPLATE_PROPERTIES = {
|
|||||||
"hdd_disk_interface": {
|
"hdd_disk_interface": {
|
||||||
"description": "QEMU hdd interface",
|
"description": "QEMU hdd interface",
|
||||||
"enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
|
"enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
|
||||||
"default": "ide"
|
"default": "none"
|
||||||
},
|
},
|
||||||
"cdrom_image": {
|
"cdrom_image": {
|
||||||
"description": "QEMU cdrom image path",
|
"description": "QEMU cdrom image path",
|
||||||
|
Loading…
Reference in New Issue
Block a user