fix: implement multiqueue support for network interfaces and update UI documentation

This commit is contained in:
2025-12-04 21:43:37 -05:00
parent 9836f321c1
commit a8ea880d94
2 changed files with 92 additions and 0 deletions

View File

@@ -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;