Last active
July 21, 2022 05:25
-
-
Save kode54/4c9057d8f0cc16fe615bf22f0a3062de to your computer and use it in GitHub Desktop.
Proxmox Qemu backend support for virtual NVMe drives
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u js/pvemanagerlib.js.orig js/pvemanagerlib.js | |
--- js/pvemanagerlib.js.orig 2022-07-20 21:34:00.523128985 -0700 | |
+++ js/pvemanagerlib.js 2022-07-20 21:38:14.110192280 -0700 | |
@@ -1388,7 +1388,7 @@ | |
toolkit: undefined, // (extjs|touch), set inside Toolkit.js | |
- bus_match: /^(ide|sata|virtio|scsi)(\d+)$/, | |
+ bus_match: /^(ide|sata|virtio|scsi|nvme)(\d+)$/, | |
log_severity_hash: { | |
0: "panic", | |
@@ -2888,6 +2888,7 @@ | |
sata: 6, | |
scsi: 31, | |
virtio: 16, | |
+ nvme: 16, | |
unused: 256, | |
}, | |
@@ -3102,7 +3103,7 @@ | |
sortByPreviousUsage: function(vmconfig, controllerList) { | |
if (!controllerList) { | |
- controllerList = ['ide', 'virtio', 'scsi', 'sata']; | |
+ controllerList = ['ide', 'virtio', 'scsi', 'sata', 'nvme']; | |
} | |
let usedControllers = {}; | |
for (const type of Object.keys(PVE.Utils.diskControllerMaxIDs)) { | |
@@ -4514,7 +4515,7 @@ | |
initComponent: function() { | |
var me = this; | |
- me.comboItems = [['ide', 'IDE'], ['sata', 'SATA']]; | |
+ me.comboItems = [['ide', 'IDE'], ['sata', 'SATA'], ['nvme', 'NVMe']]; | |
if (me.withVirtIO) { | |
me.comboItems.push(['virtio', 'VirtIO Block']); | |
diff -u touch/pvemanager-mobile.js.orig touch/pvemanager-mobile.js | |
--- touch/pvemanager-mobile.js.orig 2022-07-20 21:37:27.170369126 -0700 | |
+++ touch/pvemanager-mobile.js 2022-07-20 21:39:51.149826685 -0700 | |
@@ -98,7 +98,7 @@ | |
toolkit: undefined, // (extjs|touch), set inside Toolkit.js | |
- bus_match: /^(ide|sata|virtio|scsi)(\d+)$/, | |
+ bus_match: /^(ide|sata|virtio|scsi|nvme)(\d+)$/, | |
log_severity_hash: { | |
0: "panic", | |
@@ -1598,6 +1598,7 @@ | |
sata: 6, | |
scsi: 31, | |
virtio: 16, | |
+ nvme: 16, | |
unused: 256, | |
}, | |
@@ -1812,7 +1813,7 @@ | |
sortByPreviousUsage: function(vmconfig, controllerList) { | |
if (!controllerList) { | |
- controllerList = ['ide', 'virtio', 'scsi', 'sata']; | |
+ controllerList = ['ide', 'virtio', 'scsi', 'sata', 'nvme']; | |
} | |
let usedControllers = {}; | |
for (const type of Object.keys(PVE.Utils.diskControllerMaxIDs)) { | |
@@ -4217,7 +4218,7 @@ | |
config_keys: [ | |
'name', 'memory', 'sockets', 'cores', 'ostype', 'bootdisk', /^net\d+/, | |
- /^ide\d+/, /^virtio\d+/, /^sata\d+/, /^scsi\d+/, /^unused\d+/ | |
+ /^ide\d+/, /^virtio\d+/, /^sata\d+/, /^scsi\d+/, /^nvme\d+/, /^unused\d+/ | |
], | |
initialize: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u QemuServer.pm.orig QemuServer.pm | |
--- QemuServer.pm.orig 2022-07-20 21:20:36.582033558 -0700 | |
+++ QemuServer.pm 2022-07-20 21:02:02.168907705 -0700 | |
@@ -426,7 +426,7 @@ | |
optional => 1, | |
type => 'string', format => 'pve-qm-bootdisk', | |
description => "Enable booting from specified disk. Deprecated: Use 'boot: order=foo;bar' instead.", | |
- pattern => '(ide|sata|scsi|virtio)\d+', | |
+ pattern => '(ide|sata|scsi|nvme|virtio)\d+', | |
}, | |
smp => { | |
optional => 1, | |
@@ -1546,6 +1546,9 @@ | |
} elsif ($drive->{interface} eq 'usb') { | |
die "implement me"; | |
# -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 | |
+ } elsif ($drive->{interface} eq 'nvme') { | |
+ $device = 'nvme'; | |
+ $device .= ",drive=drive-$drive_id,id=$drive_id"; | |
} else { | |
die "unsupported interface type"; | |
} | |
diff -u QemuServer/Drive.pm.orig QemuServer/Drive.pm | |
--- QemuServer/Drive.pm.orig 2022-07-20 21:24:40.009154074 -0700 | |
+++ QemuServer/Drive.pm 2022-07-20 21:09:19.355833986 -0700 | |
@@ -30,6 +30,7 @@ | |
my $MAX_IDE_DISKS = 4; | |
my $MAX_SCSI_DISKS = 31; | |
+my $MAX_NVME_DISKS = 16; | |
my $MAX_VIRTIO_DISKS = 16; | |
our $MAX_SATA_DISKS = 6; | |
our $MAX_UNUSED_DISKS = 256; | |
@@ -301,6 +302,18 @@ | |
}; | |
PVE::JSONSchema::register_standard_option("pve-qm-sata", $satadesc); | |
+my $nvme_fmt = { | |
+ %drivedesc_base, | |
+ %iothread_fmt, | |
+ %readonly_fmt, | |
+}; | |
+my $nvmedesc = { | |
+ optional => 1, | |
+ type => 'string', format => $nvme_fmt, | |
+ description => "Use volume as NVMe SSD (n is 0 to " . ($MAX_NVME_DISKS - 1). ").", | |
+}; | |
+PVE::JSONSchema::register_standard_option("pve-qm-nvme", $nvmedesc); | |
+ | |
my $virtio_fmt = { | |
%drivedesc_base, | |
%iothread_fmt, | |
@@ -487,6 +500,11 @@ | |
$drivedesc_hash_with_alloc->{"scsi$i"} = $desc_with_alloc->('scsi', $scsidesc); | |
} | |
+for (my $i = 0; $i < $MAX_NVME_DISKS; $i++) { | |
+ $drivedesc_hash->{"nvme$i"} = $nvmedesc; | |
+ $drivedesc_hash_with_alloc->{"nvme$i"} = $desc_with_alloc->('nvme', $nvmedesc); | |
+} | |
+ | |
for (my $i = 0; $i < $MAX_VIRTIO_DISKS; $i++) { | |
$drivedesc_hash->{"virtio$i"} = $virtiodesc; | |
$drivedesc_hash_with_alloc->{"virtio$i"} = $desc_with_alloc->('virtio', $virtiodesc); | |
@@ -513,6 +531,7 @@ | |
(map { "scsi$_" } (0 .. ($MAX_SCSI_DISKS - 1))), | |
(map { "virtio$_" } (0 .. ($MAX_VIRTIO_DISKS - 1))), | |
(map { "sata$_" } (0 .. ($MAX_SATA_DISKS - 1))), | |
+ (map { "nvme$_" } (0 .. ($MAX_NVME_DISKS - 1))), | |
'efidisk0', | |
'tpmstate0'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment