From a8ea880d94dca873b1efdcd728f4d878a0bba3c8 Mon Sep 17 00:00:00 2001 From: "Joseph.Rawlings" Date: Thu, 4 Dec 2025 21:43:37 -0500 Subject: [PATCH] fix: implement multiqueue support for network interfaces and update UI documentation --- .../Servers/Proxmox/Livewire/Network.php | 66 +++++++++++++++++++ .../Servers/Proxmox/views/network.blade.php | 26 ++++++++ 2 files changed, 92 insertions(+) diff --git a/extensions/Servers/Proxmox/Livewire/Network.php b/extensions/Servers/Proxmox/Livewire/Network.php index 5c85758ef..9eabe6c3f 100644 --- a/extensions/Servers/Proxmox/Livewire/Network.php +++ b/extensions/Servers/Proxmox/Livewire/Network.php @@ -528,6 +528,9 @@ class Network extends Component $this->interfaceSelections = collect($this->interfaces) ->map(fn ($meta) => $meta['model'] ?? 'virtio') ->toArray(); + $this->interfaceMultiqueues = collect($this->interfaces) + ->map(fn ($meta) => $meta['queues'] ?? 1) + ->toArray(); $this->selectedInterface = array_key_first($this->interfaces) ?? 'net0'; $this->interfaceType = $this->interfaceSelections[$this->selectedInterface] ?? 'virtio'; $this->canRemoveInterfaces = count($this->interfaces) > 1; @@ -547,6 +550,69 @@ class Network extends Component $this->interfaceType = $this->interfaceSelections[$name]; } + public function updateMultiqueue(string $name, int $queues): void + { + if (!isset($this->interfaces[$name])) { + $this->notify('Network device not found.', 'error'); + return; + } + + $cpuCores = $this->getCpuCores(); + $queues = max(1, min($queues, $cpuCores)); + + $this->interfaceMultiqueues[$name] = $queues; + + try { + $proxmox = new Proxmox; + $currentConfig = $proxmox->request('/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/config')->json()['data'] ?? []; + $currentValue = (string) ($currentConfig[$name] ?? ''); + + if (empty($currentValue)) { + $this->notify('Network device configuration not found.', 'error'); + return; + } + + $segments = array_filter(array_map('trim', explode(',', $currentValue))); + $newSegments = []; + $queuesFound = false; + + foreach ($segments as $segment) { + if (!str_contains($segment, '=')) { + $newSegments[] = $segment; + continue; + } + + [$key, $value] = array_map('trim', explode('=', $segment, 2)); + $lowerKey = strtolower($key); + + if ($lowerKey === 'queues') { + $queuesFound = true; + $newSegments[] = 'queues=' . $queues; + } else { + $newSegments[] = $key . '=' . $value; + } + } + + // If queues parameter wasn't found, add it + if (!$queuesFound) { + $newSegments[] = 'queues=' . $queues; + } + + $newValue = implode(',', $newSegments); + + $proxmox->request( + '/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/config', + 'put', + [$name => $newValue] + ); + + $this->interfaces[$name]['queues'] = $queues; + $this->notify('Multiqueue updated for ' . strtoupper($name) . ' to ' . $queues . ' queues.', 'success'); + } catch (\Exception $e) { + $this->notify('Failed to update multiqueue: ' . $e->getMessage(), 'error'); + } + } + public function getCanAddInterfaceProperty(): bool { return count($this->interfaces) < 5; diff --git a/extensions/Servers/Proxmox/views/network.blade.php b/extensions/Servers/Proxmox/views/network.blade.php index c64b48c8c..02a9169f6 100644 --- a/extensions/Servers/Proxmox/views/network.blade.php +++ b/extensions/Servers/Proxmox/views/network.blade.php @@ -226,6 +226,9 @@

Remove Device: Removes a network interface from the VM configuration. Changes take effect after the VM is restarted.

+

+ Multiqueue: Enables the network adapter to distribute packet processing across multiple CPU cores. Set this value equal to your vCPU count for optimal performance in multi-core VMs. This improves network throughput significantly. +

The "Synced" indicator shows when your local changes match the server configuration; "Unsynced" indicates modifications that need to be saved.

@@ -249,6 +252,7 @@ Adapter MAC Address MTU + Multiqueue Actions @@ -267,6 +271,25 @@ {{ strtoupper($interfaces[$name]['mac'] ?? 'N/A') }} {{ $interfaces[$name]['mtu'] ?? 'Default' }} + +
+ +
+

VirtIO provides the best performance; legacy adapters (E1000, Realtek, PCnet, VMware) improve compatibility.

+

+ Multiqueue: Allows the network adapter to use multiple CPU cores for packet processing. Set to the number of vCPU cores (max {{ $this->getCpuCores() }}) for best performance. Higher values improve throughput for multi-core VMs. +

@foreach($server->ipAddresses as $network)