[pve-devel] [PATCH qemu-server] resume: error out if VM is a template

Fiona Ebner f.ebner at proxmox.com
Tue Feb 18 14:39:07 CET 2025


Am 18.02.25 um 12:03 schrieb Fabian Grünbichler:
> template VMs might be started in prelaunch state when creating a backup, but
> they must never be actually started fully, to avoid modifying their disks.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
> ---
>  PVE/QemuServer.pm | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index c1fbd468..b23b79e1 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -6403,6 +6403,9 @@ sub vm_resume {
>  	    $conf = PVE::QemuConfig->load_config($vmid);
>  	}
>  
> +	die "VM $vmid is a template and cannot be resumed!\n"
> +	    if PVE::QemuConfig->is_template($conf);
> +
>  	if ($res->{status}) {
>  	    return if $res->{status} eq 'running'; # job done, go home
>  	    $resume_cmd = 'system_wakeup' if $res->{status} eq 'suspended';

IMHO, it'd be slightly more natural to make this check before issuing
the "query-status" QMP call. Mostly pre-existing, because the config
loading is already done in between the QMP call and using its result.

Either way:
Reviewed-by: Fiona Ebner <f.ebner at proxmox.com>




More information about the pve-devel mailing list