From 92ac250bc7406f9a09db1d384ea0bb86a1644678 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 25 Jan 2020 16:22:34 +0800 Subject: [PATCH] Add nvme disk interface and fix scsi disk interface for Qemu VMs. --- gns3server/compute/qemu/qemu_vm.py | 13 +++++++++++-- gns3server/schemas/qemu_template.py | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 7790cd1a..c5e169b1 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1645,9 +1645,18 @@ class QemuVM(BaseNode): if interface == "sata": # special case, sata controller doesn't exist in Qemu options.extend(["-device", 'ahci,id=ahci{}'.format(disk_index)]) - options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk'.format(disk, disk_index, disk_index)]) + options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk,format=raw'.format(disk, disk_index, disk_index)]) options.extend(["-device", 'ide-drive,drive=drive{},bus=ahci{}.0,id=drive{}'.format(disk_index, disk_index, disk_index)]) - + elif interface == "nvme": + options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk,format=raw'.format(disk, disk_index, disk_index)]) + options.extend(["-device", 'nvme,drive=drive{},serial={}'.format(disk_index, disk_index)]) + elif interface == "scsi": + options.extend(["-device", 'virtio-scsi-pci,id=scsi{}'.format(disk_index)]) + options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk,format=raw'.format(disk, disk_index, disk_index)]) + options.extend(["-device", 'scsi-hd,drive=drive{}'.format(disk_index)]) + #elif interface == "sd": + # options.extend(["-drive", 'file={},id=drive{},index={},format=raw'.format(disk, disk_index, disk_index)]) + # options.extend(["-device", 'sd-card,drive=drive{},id=drive{}'.format(disk_index, disk_index, disk_index)]) else: options.extend(["-drive", 'file={},if={},index={},media=disk,id=drive{}'.format(disk, interface, disk_index, disk_index)]) diff --git a/gns3server/schemas/qemu_template.py b/gns3server/schemas/qemu_template.py index ef3bf9c3..18e2a284 100644 --- a/gns3server/schemas/qemu_template.py +++ b/gns3server/schemas/qemu_template.py @@ -115,7 +115,7 @@ QEMU_TEMPLATE_PROPERTIES = { }, "hda_disk_interface": { "description": "QEMU hda interface", - "enum": ["ide", "sata", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], + "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], "default": "ide" }, "hdb_disk_image": { @@ -125,7 +125,7 @@ QEMU_TEMPLATE_PROPERTIES = { }, "hdb_disk_interface": { "description": "QEMU hdb interface", - "enum": ["ide", "sata", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], + "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], "default": "ide" }, "hdc_disk_image": { @@ -135,7 +135,7 @@ QEMU_TEMPLATE_PROPERTIES = { }, "hdc_disk_interface": { "description": "QEMU hdc interface", - "enum": ["ide", "sata", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], + "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], "default": "ide" }, "hdd_disk_image": { @@ -145,7 +145,7 @@ QEMU_TEMPLATE_PROPERTIES = { }, "hdd_disk_interface": { "description": "QEMU hdd interface", - "enum": ["ide", "sata", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], + "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], "default": "ide" }, "cdrom_image": {