From 9feb3fba8674b7613c22887aa38a6a5549a26076 Mon Sep 17 00:00:00 2001 From: Claw Date: Tue, 17 Nov 2026 21:17:21 +0100 Subject: [PATCH] 0.10.1: create wizard can pick/download an ISO and optionally start the guest right away --- bin/vmm-jobd | 20 +++++++++++++++++++ gui/ext/vmmngr/vmmngr.conf | 2 +- gui/vmmngr_create.php | 40 +++++++++++++++++++++++++++++++++++++- version.txt | 2 +- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/bin/vmm-jobd b/bin/vmm-jobd index 221f3c0..ff24710 100755 --- a/bin/vmm-jobd +++ b/bin/vmm-jobd @@ -190,6 +190,26 @@ if ($verb === 'create' && !empty($job['switch'])) { } } +// optional: attach the chosen ISO and boot right away +if ($verb === 'create' && $rc === 0 && empty($timedOut)) { + if (!empty($job['iso'])) { + $att = vmm_iso_attach($name, [(string)$job['iso']]); + if (isset($att['error'])) { + joblog($log, 'iso attach failed: ' . $att['error']); + } else { + joblog($log, 'iso attached: ' . basename((string)$job['iso'])); + } + } + if (!empty($job['autostart']) && !empty($job['iso'])) { + joblog($log, 'starting guest'); + $start = vmm_run(['start', $name], 180); + if ($start['stdout'] !== '') { + fwrite($log, $start['stdout']); + } + joblog($log, 'start rc=' . $start['rc']); + } +} + // vm-bhyve often returns 0 even when it refused the operation, so the // resulting state is what counts. Some states are transitional (a guest that // just booted reports "bootloader" for a moment), so wait a little. diff --git a/gui/ext/vmmngr/vmmngr.conf b/gui/ext/vmmngr/vmmngr.conf index 9d73304..8da579e 100644 --- a/gui/ext/vmmngr/vmmngr.conf +++ b/gui/ext/vmmngr/vmmngr.conf @@ -1,6 +1,6 @@ { "appname": "VM Manager", - "version": "0.10.0", + "version": "0.10.1", "rootfolder": "/mnt/Daten/extensions/vmmngr", "vm_source": "auto", "bridges": ["ix0bridge"], diff --git a/gui/vmmngr_create.php b/gui/vmmngr_create.php index 3f050b1..d981f14 100644 --- a/gui/vmmngr_create.php +++ b/gui/vmmngr_create.php @@ -12,6 +12,18 @@ $templates = vmm_file_list(vmm_data_dir('.templates'), ['conf']); $datastores = vmm_datastores(); $switches = vmm_switches(); $images = vmm_file_list(vmm_data_dir('.img'), ['img']); +$isos = vmm_file_list(vmm_data_dir('.iso'), ['iso']); + +if ($post && ($_POST['act'] ?? '') === 'download_iso') { + $url = trim((string)($_POST['iso_url'] ?? '')); + if (!preg_match('#^https?://[^\s"\'<>]+$#i', $url)) { + $err = gettext('Only http(s) URLs are allowed.'); + } else { + $job = vmm_job_new('iso_download', basename((string)parse_url($url, PHP_URL_PATH)) ?: 'iso', ['iso', $url], 21600); + header('Location: ' . vmm_after_job_target((string)$job['id'], 'vmmngr_create.php')); + exit; + } +} if ($post) { $name = trim((string)($_POST['name'] ?? '')); @@ -23,6 +35,8 @@ if ($post) { $cloud = isset($_POST['cloudinit']); $img = (string)($_POST['image'] ?? ''); $switch = trim((string)($_POST['switch'] ?? '')); + $iso = vmm_safe_basename((string)($_POST['iso'] ?? '')); + $autostart = isset($_POST['autostart']); if (!vmm_valid_name($name)) { $err = gettext('Invalid name: letters, digits, dot, dash, underscore (max 32).'); @@ -58,7 +72,14 @@ if ($post) { $argv[] = $img; } $argv[] = $name; - $job = vmm_job_new('create', $name, $argv, 900, ['switch' => $switch]); + $meta = ['switch' => $switch]; + if ($iso !== '' && str_ends_with(strtolower($iso), '.iso')) { + $meta['iso'] = vmm_data_dir('.iso') . '/' . $iso; + } + if ($autostart) { + $meta['autostart'] = '1'; + } + $job = vmm_job_new('create', $name, $argv, 900, $meta); header('Location: vmmngr_jobs.php?id=' . urlencode((string)$job['id'])); exit; } @@ -153,6 +174,23 @@ vmm_nav('create'); + + + + + +
+ + + +
+ + diff --git a/version.txt b/version.txt index 78bc1ab..5712157 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.10.0 +0.10.1