template: add -snapshot to KVM command

this allows effectively setting ALL volumes as read-only, even if the
disk controller does not support it. without it, IDE and SATA disks
with (base) volumes which are marked read-only/immutable on the storage
level prevent the template VM from starting for backup purposes.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2021-06-04 11:47:47 +02:00 committed by Thomas Lamprecht
parent 2c53ff94fa
commit 85fcf79e21
3 changed files with 9 additions and 2 deletions

View File

@ -3782,6 +3782,11 @@ sub config_to_command {
print "activating and using '$vmstate' as vmstate\n"; print "activating and using '$vmstate' as vmstate\n";
} }
if (PVE::QemuConfig->is_template($conf)) {
# needed to workaround base volumes being read-only
push @$cmd, '-snapshot';
}
# add custom args # add custom args
if ($conf->{args}) { if ($conf->{args}) {
my $aa = PVE::Tools::split_args($conf->{args}); my $aa = PVE::Tools::split_args($conf->{args});

View File

@ -24,4 +24,5 @@
-device 'VGA,id=vga,bus=pci.0,addr=0x2' \ -device 'VGA,id=vga,bus=pci.0,addr=0x2' \
-device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' \ -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' \
-iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \ -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
-machine 'type=pc+pve0' -machine 'type=pc+pve0' \
-snapshot

View File

@ -33,4 +33,5 @@
-device 'ide-hd,bus=ahci0.0,drive=drive-sata0,id=sata0' -device 'ide-hd,bus=ahci0.0,drive=drive-sata0,id=sata0'
-netdev 'type=tap,id=net0,ifname=tap8006i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' \ -netdev 'type=tap,id=net0,ifname=tap8006i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' \
-device 'virtio-net-pci,mac=A2:C0:43:77:08:A0,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' \ -device 'virtio-net-pci,mac=A2:C0:43:77:08:A0,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' \
-machine 'type=pc' -machine 'type=pc' \
-snapshot