fix: implement multiqueue support for network interfaces and update UI documentation
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user