From e989df97a5788fe606ce0337747cfc5fb0205308 Mon Sep 17 00:00:00 2001 From: Claw Date: Tue, 17 Nov 2026 20:31:47 +0100 Subject: [PATCH] 0.3.3: allow argv jobs (create), fix zero timeout, longer stop wait, template name without .conf --- bin/vmm-jobd | 17 +++++++++++++---- gui/ext/vmmngr/vmmngr.conf | 2 +- gui/vmmngr_create.php | 4 +++- gui/vmmngr_vm.php | 6 ++++++ version.txt | 2 +- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/bin/vmm-jobd b/bin/vmm-jobd index 240e088..be551bc 100644 --- a/bin/vmm-jobd +++ b/bin/vmm-jobd @@ -20,7 +20,8 @@ if ($job === null) { $verb = (string)$job['verb']; $name = (string)$job['vm']; -if (!isset(VMM_ACTIONS[$verb])) { +$action = VMM_ACTIONS[$verb] ?? null; +if ($action === null && (!isset($job['argv']) || !is_array($job['argv']) || $job['argv'] === [])) { $job['state'] = 'failed'; $job['error'] = 'unknown verb'; $job['ended'] = time(); @@ -61,7 +62,7 @@ vmm_job_write($job); $argvVm = isset($job['argv']) && is_array($job['argv']) && $job['argv'] !== [] ? $job['argv'] - : array_merge(VMM_ACTIONS[$verb]['argv'], [$name]); + : array_merge($action['argv'], [$name]); joblog($log, 'start: vm ' . implode(' ', $argvVm)); $vm = vmm_resolve('vm'); @@ -120,7 +121,10 @@ fclose($pipes[0]); stream_set_blocking($pipes[1], false); stream_set_blocking($pipes[2], false); -$timeout = (int)($job['timeout'] ?? (VMM_ACTIONS[$verb]['timeout'] ?? 300)); +$timeout = (int)($job['timeout'] ?? 0); +if ($timeout <= 0) { + $timeout = (int)($action['timeout'] ?? 300); +} $start = time(); $timedOut = false; $cancelFile = VMM_JOBDIR . '/' . $id . '.cancel'; @@ -179,10 +183,15 @@ $accept = [ 'reset' => ['running', 'bootloader'], 'poweroff' => ['stopped'], 'destroy' => ['absent'], + 'create' => ['stopped'], + 'install' => ['stopped'], ][$verb] ?? []; +// a graceful stop can take a while (ACPI), and vm-bhyve reports "locked" while +// it works - never treat that as the final state +$waitFor = ['stop' => 180, 'poweroff' => 120, 'start' => 60, 'restart' => 90, 'reset' => 60, 'create' => 60, 'install' => 60][$verb] ?? 30; $stateAfter = vmm_vm_state($name); -$deadline = time() + 30; +$deadline = time() + $waitFor; while ($accept !== [] && !in_array($stateAfter, $accept, true) && time() < $deadline) { usleep(500000); $stateAfter = vmm_vm_state($name); diff --git a/gui/ext/vmmngr/vmmngr.conf b/gui/ext/vmmngr/vmmngr.conf index ff48387..d8f515a 100644 --- a/gui/ext/vmmngr/vmmngr.conf +++ b/gui/ext/vmmngr/vmmngr.conf @@ -1,6 +1,6 @@ { "appname": "VM Manager", - "version": "0.3.2", + "version": "0.3.3", "rootfolder": "/mnt/Daten/extensions/vmmngr", "vm_source": "auto", "bridges": ["ix0bridge"], diff --git a/gui/vmmngr_create.php b/gui/vmmngr_create.php index 9b988ee..cef16cd 100644 --- a/gui/vmmngr_create.php +++ b/gui/vmmngr_create.php @@ -48,7 +48,9 @@ if ($post) { vmm_human_bytes($budget['limit']) ); } else { - $argv = ['create', '-t', $tpl, '-d', $ds, '-s', strtoupper($size), '-m', strtoupper($mem), '-c', $cpu]; + // vm-bhyve expects the template name without the .conf suffix + $tplName = preg_replace('/\.conf$/', '', $tpl); + $argv = ['create', '-t', $tplName, '-d', $ds, '-s', strtoupper($size), '-m', strtoupper($mem), '-c', $cpu]; if ($cloud) { $argv[] = '-C'; $argv[] = '-i'; diff --git a/gui/vmmngr_vm.php b/gui/vmmngr_vm.php index 7a1ff3c..8d9f621 100644 --- a/gui/vmmngr_vm.php +++ b/gui/vmmngr_vm.php @@ -28,6 +28,12 @@ if (strtoupper((string)($_SERVER['REQUEST_METHOD'] ?? '')) === 'POST' && isset($ exit; } +if (vmm_vm_state($name) === 'absent') { + $_SESSION['vmmngr_error'] = sprintf(gettext('Virtual machine %s does not exist (yet).'), $name); + header('Location: vmmngr.php'); + exit; +} + $info = vmm_info($name); $pgtitle = [gettext('Extensions'), gettext('VM Manager'), $name]; $jobs = vmm_job_list(10, $name); diff --git a/version.txt b/version.txt index d15723f..1c09c74 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.2 +0.3.3