IDE/SATA do not support being configured as read-only, so the inserted block node needs to be marked as writable too, but -blockdev will complain if it's marked as writable but the actual backing device is read-only (e.g. read-only LV).
To cleanly solve this, 'ide-hd', which is used by both IDE and SATA, should not be used as the front-end, but disks be attached differently for template backup. For now, use a stop-gap fix, setting the machine version to pre-10.0 in the temporary config used to start the template VM in pre-launch mode for backup. With -drive, it seems that the check for the actual device being the same r/rw mode is not done. Reported in the community forum: https://forum.proxmox.com/threads/169638/ Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> --- src/PVE/QemuServer.pm | 7 +++++++ src/test/cfg2cmd/efi-raw-template.conf.cmd | 7 +++---- .../cfg2cmd/q35-linux-hostpci-template.conf.cmd | 12 +++++------- src/test/cfg2cmd/simple1-template.conf.cmd | 15 +++++++-------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index cfc54568..6781311e 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -3212,6 +3212,13 @@ sub config_to_command { template => 1, # in case below code checks that kvm => 0, # to prevent an error on hosts without virtualization extensions vga => 'none', # to not start a vnc server + # FIXME machine version is set to pre-10.0, because IDE/SATA do not support being + # configured as read-only, so the inserted block node needs to be marked as writable + # too, but -blockdev will complain if it's marked as writable but the actual backing + # device is read-only (e.g. read-only LV). + # To cleanly solve this, ide-hd should not be used as the front-end, but disks be + # attached differently for template backup. + machine => 'pc-i440fx-9.2+pve1', scsihw => $conf->{scsihw}, # so that the scsi disks are correctly added bios => $conf->{bios}, # so efidisk gets included if it exists name => $conf->{name}, # so it's correct in the process list diff --git a/src/test/cfg2cmd/efi-raw-template.conf.cmd b/src/test/cfg2cmd/efi-raw-template.conf.cmd index d027d776..3a6c1b04 100644 --- a/src/test/cfg2cmd/efi-raw-template.conf.cmd +++ b/src/test/cfg2cmd/efi-raw-template.conf.cmd @@ -8,9 +8,8 @@ -mon 'chardev=qmp-event,mode=control' \ -pidfile /var/run/qemu-server/8006.pid \ -daemonize \ - -object '{"id":"throttle-drive-efidisk0","limits":{},"qom-type":"throttle-group"}' \ - -blockdev '{"driver":"raw","file":{"driver":"file","filename":"/usr/share/pve-edk2-firmware//OVMF_CODE.fd"},"node-name":"pflash0","read-only":true}' \ - -blockdev '{"detect-zeroes":"on","discard":"ignore","driver":"throttle","file":{"cache":{"direct":false,"no-flush":false},"detect-zeroes":"on","discard":"ignore","driver":"raw","file":{"aio":"io_uring","cache":{"direct":false,"no-flush":false},"detect-zeroes":"on","discard":"ignore","driver":"file","filename":"/var/lib/vz/images/100/base-100-disk-0.raw","node-name":"e2ab65c8ec567acbeb645244f6c4982","read-only":true},"node-name":"f2ab65c8ec567acbeb645244f6c4982","read-only":true,"size":131072},"node-name":"drive-efidisk0","read-only":true,"throttle-group":"throttle-drive-efidisk0"}' \ + -drive 'if=pflash,unit=0,format=raw,readonly=on,file=/usr/share/pve-edk2-firmware//OVMF_CODE.fd' \ + -drive 'if=pflash,unit=1,id=drive-efidisk0,format=raw,file=/var/lib/vz/images/100/base-100-disk-0.raw,size=131072,readonly=on' \ -smp '1,sockets=1,cores=1,maxcpus=1' \ -nodefaults \ -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \ @@ -26,5 +25,5 @@ -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' \ -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \ -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \ - -machine 'pflash0=pflash0,pflash1=drive-efidisk0,accel=tcg,type=pc+pve0' \ + -machine 'accel=tcg,type=pc-i440fx-9.2+pve1' \ -snapshot diff --git a/src/test/cfg2cmd/q35-linux-hostpci-template.conf.cmd b/src/test/cfg2cmd/q35-linux-hostpci-template.conf.cmd index 20e3c81d..7172fb4c 100644 --- a/src/test/cfg2cmd/q35-linux-hostpci-template.conf.cmd +++ b/src/test/cfg2cmd/q35-linux-hostpci-template.conf.cmd @@ -8,9 +8,8 @@ -mon 'chardev=qmp-event,mode=control' \ -pidfile /var/run/qemu-server/8006.pid \ -daemonize \ - -object '{"id":"throttle-drive-efidisk0","limits":{},"qom-type":"throttle-group"}' \ - -blockdev '{"driver":"raw","file":{"driver":"file","filename":"/usr/share/pve-edk2-firmware//OVMF_CODE.fd"},"node-name":"pflash0","read-only":true}' \ - -blockdev '{"detect-zeroes":"on","discard":"ignore","driver":"throttle","file":{"cache":{"direct":false,"no-flush":false},"detect-zeroes":"on","discard":"ignore","driver":"qcow2","file":{"aio":"io_uring","cache":{"direct":false,"no-flush":false},"detect-zeroes":"on","discard":"ignore","driver":"file","filename":"/var/lib/vz/images/100/base-100-disk-1.qcow2","node-name":"eb6bec0e3c391fabb7fb7dd73ced9bf","read-only":true},"node-name":"fb6bec0e3c391fabb7fb7dd73ced9bf","read-only":true},"node-name":"drive-efidisk0","read-only":true,"throttle-group":"throttle-drive-efidisk0"}' \ + -drive 'if=pflash,unit=0,format=raw,readonly=on,file=/usr/share/pve-edk2-firmware//OVMF_CODE.fd' \ + -drive 'if=pflash,unit=1,id=drive-efidisk0,format=qcow2,file=/var/lib/vz/images/100/base-100-disk-1.qcow2,readonly=on' \ -smp '1,sockets=1,cores=1,maxcpus=1' \ -nodefaults \ -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \ @@ -18,7 +17,6 @@ -nographic \ -cpu qemu64 \ -m 512 \ - -object '{"id":"throttle-drive-scsi0","limits":{},"qom-type":"throttle-group"}' \ -global 'PIIX4_PM.disable_s3=1' \ -global 'PIIX4_PM.disable_s4=1' \ -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' \ @@ -28,7 +26,7 @@ -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \ -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \ -device 'virtio-scsi-pci,id=scsihw0,bus=pci.0,addr=0x5' \ - -blockdev '{"detect-zeroes":"on","discard":"ignore","driver":"throttle","file":{"cache":{"direct":true,"no-flush":false},"detect-zeroes":"on","discard":"ignore","driver":"raw","file":{"aio":"io_uring","cache":{"direct":true,"no-flush":false},"detect-zeroes":"on","discard":"ignore","driver":"file","filename":"/var/lib/vz/images/100/base-100-disk-2.raw","node-name":"e24dfe239201bb9924fc4cfb899ca70","read-only":true},"node-name":"f24dfe239201bb9924fc4cfb899ca70","read-only":true},"node-name":"drive-scsi0","read-only":true,"throttle-group":"throttle-drive-scsi0"}' \ - -device 'scsi-hd,bus=scsihw0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0,id=scsi0,device_id=drive-scsi0,write-cache=on' \ - -machine 'pflash0=pflash0,pflash1=drive-efidisk0,accel=tcg,type=pc+pve0' \ + -drive 'file=/var/lib/vz/images/100/base-100-disk-2.raw,if=none,id=drive-scsi0,format=raw,cache=none,aio=io_uring,detect-zeroes=on,readonly=on' \ + -device 'scsi-hd,bus=scsihw0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0,id=scsi0' \ + -machine 'accel=tcg,type=pc-i440fx-9.2+pve1' \ -snapshot diff --git a/src/test/cfg2cmd/simple1-template.conf.cmd b/src/test/cfg2cmd/simple1-template.conf.cmd index df51a4a5..5bde9fd6 100644 --- a/src/test/cfg2cmd/simple1-template.conf.cmd +++ b/src/test/cfg2cmd/simple1-template.conf.cmd @@ -15,8 +15,6 @@ -nographic \ -cpu qemu64 \ -m 512 \ - -object '{"id":"throttle-drive-scsi0","limits":{},"qom-type":"throttle-group"}' \ - -object '{"id":"throttle-drive-sata0","limits":{},"qom-type":"throttle-group"}' \ -global 'PIIX4_PM.disable_s3=1' \ -global 'PIIX4_PM.disable_s4=1' \ -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' \ @@ -25,12 +23,13 @@ -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' \ -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \ -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \ - -device 'ide-cd,bus=ide.1,unit=0,id=ide2,bootindex=200' \ + -drive 'if=none,id=drive-ide2,media=cdrom,aio=io_uring' \ + -device 'ide-cd,bus=ide.1,unit=0,drive=drive-ide2,id=ide2,bootindex=200' \ -device 'virtio-scsi-pci,id=scsihw0,bus=pci.0,addr=0x5' \ - -blockdev '{"detect-zeroes":"unmap","discard":"unmap","driver":"throttle","file":{"cache":{"direct":true,"no-flush":false},"detect-zeroes":"unmap","discard":"unmap","driver":"qcow2","file":{"aio":"io_uring","cache":{"direct":true,"no-flush":false},"detect-zeroes":"unmap","discard":"unmap","driver":"file","filename":"/var/lib/vz/images/8006/base-8006-disk-1.qcow2","node-name":"e1085774206ae4a6b6bf8426ff08f16","read-only":true},"node-name":"f1085774206ae4a6b6bf8426ff08f16","read-only":true},"node-name":"drive-scsi0","read-only":true,"throttle-group":"throttle-drive-scsi0"}' \ - -device 'scsi-hd,bus=scsihw0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0,id=scsi0,device_id=drive-scsi0,write-cache=on' \ + -drive 'file=/var/lib/vz/images/8006/base-8006-disk-1.qcow2,if=none,id=drive-scsi0,discard=on,format=qcow2,cache=none,aio=io_uring,detect-zeroes=unmap,readonly=on' \ + -device 'scsi-hd,bus=scsihw0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0,id=scsi0' \ -device 'ahci,id=ahci0,multifunction=on,bus=pci.0,addr=0x7' \ - -blockdev '{"detect-zeroes":"unmap","discard":"unmap","driver":"throttle","file":{"cache":{"direct":true,"no-flush":false},"detect-zeroes":"unmap","discard":"unmap","driver":"qcow2","file":{"aio":"io_uring","cache":{"direct":true,"no-flush":false},"detect-zeroes":"unmap","discard":"unmap","driver":"file","filename":"/var/lib/vz/images/8006/base-8006-disk-0.qcow2","node-name":"eab334c2e07734480f33dd80d89871b","read-only":false},"node-name":"fab334c2e07734480f33dd80d89871b","read-only":false},"node-name":"drive-sata0","read-only":false,"throttle-group":"throttle-drive-sata0"}' \ - -device 'ide-hd,bus=ahci0.0,drive=drive-sata0,id=sata0,write-cache=on' \ - -machine 'accel=tcg,smm=off,type=pc+pve0' \ + -drive 'file=/var/lib/vz/images/8006/base-8006-disk-0.qcow2,if=none,id=drive-sata0,discard=on,format=qcow2,cache=none,aio=io_uring,detect-zeroes=unmap' \ + -device 'ide-hd,bus=ahci0.0,drive=drive-sata0,id=sata0' \ + -machine 'accel=tcg,smm=off,type=pc-i440fx-9.2+pve1' \ -snapshot -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel