From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 171AA1FF164 for ; Fri, 4 Jul 2025 08:45:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 93A823036F; Fri, 4 Jul 2025 08:45:48 +0200 (CEST) To: pve-devel@lists.proxmox.com Date: Fri, 4 Jul 2025 08:44:57 +0200 In-Reply-To: <20250704064507.511884-1-alexandre.derumier@groupe-cyllene.com> References: <20250704064507.511884-1-alexandre.derumier@groupe-cyllene.com> MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Alexandre Derumier via pve-devel Precedence: list Cc: Alexandre Derumier X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] [PATCH qemu-server 2/3] blockdev: add backing_chain support Content-Type: multipart/mixed; boundary="===============6247922918576148936==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============6247922918576148936== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C6159D5456 for ; Fri, 4 Jul 2025 08:45:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 992D61FE9B for ; Fri, 4 Jul 2025 08:45:17 +0200 (CEST) Received: from bastiontest.odiso.net (unknown [185.151.190.228]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 4 Jul 2025 08:45:15 +0200 (CEST) Received: from formationkvm1.odiso.net (unknown [10.11.201.57]) by bastiontest.odiso.net (Postfix) with ESMTP id EDABE860F14; Fri, 4 Jul 2025 08:45:08 +0200 (CEST) Received: by formationkvm1.odiso.net (Postfix, from userid 0) id E2E08115F577; Fri, 4 Jul 2025 08:45:08 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server 2/3] blockdev: add backing_chain support Date: Fri, 4 Jul 2025 08:44:57 +0200 Message-Id: <20250704064507.511884-4-alexandre.derumier@groupe-cyllene.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250704064507.511884-1-alexandre.derumier@groupe-cyllene.com> References: <20250704064507.511884-1-alexandre.derumier@groupe-cyllene.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL -0.204 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_NONE 0.1 DMARC none policy HEADER_FROM_DIFFERENT_DOMAINS 0.001 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_NONE 0.25 DKIM has Failed or SPF has failed on the message and the domain has no DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods KAM_LOTSOFHASH 0.25 Emails with lots of hash-like gibberish RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.218 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [8006.pid,blockdev.pm] We need to define name-nodes for all backing chain images, to be able to live rename them with blockdev-reopen For linked clone, we don't need to definebase image(s) chain. They are auto added with #block nodename. Signed-off-by: Alexandre Derumier --- src/PVE/QemuServer/Blockdev.pm | 49 +++++++++++++++++++ src/test/cfg2cmd/simple-backingchain.conf | 25 ++++++++++ src/test/cfg2cmd/simple-backingchain.conf.cmd | 33 +++++++++++++ src/test/run_config2command_tests.pl | 47 ++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 src/test/cfg2cmd/simple-backingchain.conf create mode 100644 src/test/cfg2cmd/simple-backingchain.conf.cmd diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm index 5f1fdae3..2a0513fb 100644 --- a/src/PVE/QemuServer/Blockdev.pm +++ b/src/PVE/QemuServer/Blockdev.pm @@ -360,6 +360,46 @@ my sub generate_format_blockdev { return $blockdev; } =20 +my sub generate_backing_blockdev; + +sub generate_backing_blockdev { + my ($storecfg, $snapshots, $deviceid, $drive, $machine_version, $optio= ns) =3D @_; + + my $snap_id =3D $options->{'snapshot-name'}; + my $snapshot =3D $snapshots->{$snap_id}; + my $parentid =3D $snapshot->{parent}; + + my $volid =3D $drive->{file}; + + my $snap_file_blockdev =3D generate_file_blockdev($storecfg, $drive, $= machine_version, $options); + $snap_file_blockdev->{filename} =3D $snapshot->{file}; + + my $snap_fmt_blockdev =3D + generate_format_blockdev($storecfg, $drive, $snap_file_blockdev, $= options); + + if ($parentid) { + my $options =3D { 'snapshot-name' =3D> $parentid }; + $snap_fmt_blockdev->{backing} =3D generate_backing_blockdev( + $storecfg, $snapshots, $deviceid, $drive, $machine_version, $o= ptions, + ); + } + return $snap_fmt_blockdev; +} + +my sub generate_backing_chain_blockdev { + my ($storecfg, $deviceid, $drive, $machine_version) =3D @_; + + my $volid =3D $drive->{file}; + + my $snapshots =3D PVE::Storage::volume_snapshot_info($storecfg, $volid= ); + my $parentid =3D $snapshots->{'current'}->{parent}; + return undef if !$parentid; + my $options =3D { 'snapshot-name' =3D> $parentid }; + return generate_backing_blockdev( + $storecfg, $snapshots, $deviceid, $drive, $machine_version, $optio= ns, + ); +} + sub generate_drive_blockdev { my ($storecfg, $drive, $machine_version, $options) =3D @_; =20 @@ -371,6 +411,15 @@ sub generate_drive_blockdev { my $child =3D generate_file_blockdev($storecfg, $drive, $machine_versi= on, $options); if (!is_nbd($drive)) { $child =3D generate_format_blockdev($storecfg, $drive, $child, $op= tions); + + my $support_qemu_snapshots =3D + PVE::Storage::volume_support_qemu_snapshot($storecfg, $drive->= {file}); + if ($support_qemu_snapshots && $support_qemu_snapshots eq 'externa= l') { + my $backing_chain =3D generate_backing_chain_blockdev( + $storecfg, "drive-$drive_id", $drive, $machine_version, + ); + $child->{backing} =3D $backing_chain if $backing_chain; + } } =20 if ($options->{'zero-initialized'}) { diff --git a/src/test/cfg2cmd/simple-backingchain.conf b/src/test/cfg2cmd/s= imple-backingchain.conf new file mode 100644 index 00000000..2c0b0f2c --- /dev/null +++ b/src/test/cfg2cmd/simple-backingchain.conf @@ -0,0 +1,25 @@ +# TEST: Simple test for external snapshot backing chain +name: simple +parent: snap3 +scsi0: localsnapext:8006/vm-8006-disk-0.qcow2,size=3D1G +scsi1: lvm-store:vm-8006-disk-0.qcow2,size=3D1G + +[snap1] +name: simple +scsi0: localsnapext:8006/vm-8006-disk-0.qcow2,size=3D1G +scsi1: lvm-store:vm-8006-disk-0.qcow2,size=3D1G +snaptime: 1748933042 + +[snap2] +parent: snap1 +name: simple +scsi0: localsnapext:8006/vm-8006-disk-0.qcow2,size=3D1G +scsi1: lvm-store:vm-8006-disk-0.qcow2,size=3D1G +snaptime: 1748933043 + +[snap3] +parent: snap2 +name: simple +scsi0: localsnapext:8006/vm-8006-disk-0.qcow2,size=3D1G +scsi1: lvm-store:vm-8006-disk-0.qcow2,size=3D1G +snaptime: 1748933044 diff --git a/src/test/cfg2cmd/simple-backingchain.conf.cmd b/src/test/cfg2c= md/simple-backingchain.conf.cmd new file mode 100644 index 00000000..40c957f5 --- /dev/null +++ b/src/test/cfg2cmd/simple-backingchain.conf.cmd @@ -0,0 +1,33 @@ +/usr/bin/kvm \ + -id 8006 \ + -name 'simple,debug-threads=3Don' \ + -no-shutdown \ + -chardev 'socket,id=3Dqmp,path=3D/var/run/qemu-server/8006.qmp,server=3D= on,wait=3Doff' \ + -mon 'chardev=3Dqmp,mode=3Dcontrol' \ + -chardev 'socket,id=3Dqmp-event,path=3D/var/run/qmeventd.sock,reconnect-= ms=3D5000' \ + -mon 'chardev=3Dqmp-event,mode=3Dcontrol' \ + -pidfile /var/run/qemu-server/8006.pid \ + -daemonize \ + -smp '1,sockets=3D1,cores=3D1,maxcpus=3D1' \ + -nodefaults \ + -boot 'menu=3Don,strict=3Don,reboot-timeout=3D1000,splash=3D/usr/share/q= emu-server/bootsplash.jpg' \ + -vnc 'unix:/var/run/qemu-server/8006.vnc,password=3Don' \ + -cpu kvm64,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep \ + -m 512 \ + -object '{"id":"throttle-drive-scsi0","limits":{},"qom-type":"throttle-g= roup"}' \ + -object '{"id":"throttle-drive-scsi1","limits":{},"qom-type":"throttle-g= roup"}' \ + -global 'PIIX4_PM.disable_s3=3D1' \ + -global 'PIIX4_PM.disable_s4=3D1' \ + -device 'pci-bridge,id=3Dpci.1,chassis_nr=3D1,bus=3Dpci.0,addr=3D0x1e' \ + -device 'pci-bridge,id=3Dpci.2,chassis_nr=3D2,bus=3Dpci.0,addr=3D0x1f' \ + -device 'piix3-usb-uhci,id=3Duhci,bus=3Dpci.0,addr=3D0x1.0x2' \ + -device 'usb-tablet,id=3Dtablet,bus=3Duhci.0,port=3D1' \ + -device 'VGA,id=3Dvga,bus=3Dpci.0,addr=3D0x2' \ + -device 'virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3,free-pa= ge-reporting=3Don' \ + -iscsi 'initiator-name=3Diqn.1993-08.org.debian:01:aabbccddeeff' \ + -device 'lsi,id=3Dscsihw0,bus=3Dpci.0,addr=3D0x5' \ + -blockdev '{"driver":"throttle","file":{"backing":{"backing":{"cache":{"= direct":true,"no-flush":false},"driver":"qcow2","file":{"aio":"io_uring","c= ache":{"direct":true,"no-flush":false},"detect-zeroes":"on","discard":"igno= re","driver":"file","filename":"/var/lib/vzsnapext/images/8006/snap1-vm-800= 6-disk-0.qcow2","node-name":"ea91a385a49a008a4735c0aec5c6749","read-only":f= alse},"node-name":"fa91a385a49a008a4735c0aec5c6749","read-only":false},"cac= he":{"direct":true,"no-flush":false},"driver":"qcow2","file":{"aio":"io_uri= ng","cache":{"direct":true,"no-flush":false},"detect-zeroes":"on","discard"= :"ignore","driver":"file","filename":"/var/lib/vzsnapext/images/8006/snap2-= vm-8006-disk-0.qcow2","node-name":"ec0289317073959d450248d8cd7a480","read-o= nly":false},"node-name":"fc0289317073959d450248d8cd7a480","read-only":false= },"cache":{"direct":true,"no-flush":false},"driver":"qcow2","file":{"aio":"= io_uring","cache":{"direct":true,"no-flush":false},"detect-zeroes":"on","di= scard":"ignore","driver":"file","filename":"/var/lib/vzsnapext/images/8006/= vm-8006-disk-0.qcow2","node-name":"e74f4959037afb46eddc7313c43dfdd","read-o= nly":false},"node-name":"f74f4959037afb46eddc7313c43dfdd","read-only":false= },"node-name":"drive-scsi0","throttle-group":"throttle-drive-scsi0"}' \ + -device 'scsi-hd,bus=3Dscsihw0.0,scsi-id=3D0,drive=3Ddrive-scsi0,id=3Dsc= si0,write-cache=3Don' \ + -blockdev '{"driver":"throttle","file":{"backing":{"backing":{"cache":{"= direct":true,"no-flush":false},"driver":"qcow2","file":{"aio":"native","cac= he":{"direct":true,"no-flush":false},"detect-zeroes":"on","discard":"ignore= ","driver":"host_device","filename":"/dev/veegee/snap1-vm-8006-disk-0.qcow2= ","node-name":"e25f58d3e6e11f2065ad41253988915","read-only":false},"node-na= me":"f25f58d3e6e11f2065ad41253988915","read-only":false},"cache":{"direct":= true,"no-flush":false},"driver":"qcow2","file":{"aio":"native","cache":{"di= rect":true,"no-flush":false},"detect-zeroes":"on","discard":"ignore","drive= r":"host_device","filename":"/dev/veegee/snap2-vm-8006-disk-0.qcow2","node-= name":"e9415bb5e484c1e25d25063b01686fe","read-only":false},"node-name":"f94= 15bb5e484c1e25d25063b01686fe","read-only":false},"cache":{"direct":true,"no= -flush":false},"driver":"qcow2","file":{"aio":"native","cache":{"direct":tr= ue,"no-flush":false},"detect-zeroes":"on","discard":"ignore","driver":"host= _device","filename":"/dev/veegee/vm-8006-disk-0.qcow2","node-name":"e87358a= 470ca311f94d5cc61d1eb428","read-only":false},"node-name":"f87358a470ca311f9= 4d5cc61d1eb428","read-only":false},"node-name":"drive-scsi1","throttle-grou= p":"throttle-drive-scsi1"}' \ + -device 'scsi-hd,bus=3Dscsihw0.0,scsi-id=3D1,drive=3Ddrive-scsi1,id=3Dsc= si1,write-cache=3Don' \ + -machine 'type=3Dpc+pve0' diff --git a/src/test/run_config2command_tests.pl b/src/test/run_config2com= mand_tests.pl index 1262a0df..61302f6b 100755 --- a/src/test/run_config2command_tests.pl +++ b/src/test/run_config2command_tests.pl @@ -21,6 +21,7 @@ use PVE::QemuServer::Helpers; use PVE::QemuServer::Monitor; use PVE::QemuServer::QMPHelpers; use PVE::QemuServer::CPUConfig; +use PVE::Storage; =20 my $base_env =3D { storage_config =3D> { @@ -34,6 +35,15 @@ my $base_env =3D { type =3D> 'dir', shared =3D> 0, }, + localsnapext =3D> { + content =3D> { + images =3D> 1, + }, + path =3D> '/var/lib/vzsnapext', + type =3D> 'dir', + shared =3D> 0, + snapext =3D> 1, + }, noimages =3D> { content =3D> { iso =3D> 1, @@ -264,6 +274,43 @@ $storage_module->mock( deactivate_volumes =3D> sub { return; }, + volume_snapshot_info =3D> sub { + my ($cfg, $volid) =3D @_; + + my ($storeid, $volname) =3D PVE::Storage::parse_volume_id($volid); + + my $snapshots =3D {}; + if ($storeid eq 'localsnapext') { + $snapshots =3D { + current =3D> { + file =3D> 'var/lib/vzsnapext/images/8006/vm-8006-disk-= 0.qcow2', + parent =3D> 'snap2', + }, + snap2 =3D> { + file =3D> '/var/lib/vzsnapext/images/8006/snap2-vm-800= 6-disk-0.qcow2', + parent =3D> 'snap1', + }, + snap1 =3D> { + file =3D> '/var/lib/vzsnapext/images/8006/snap1-vm-800= 6-disk-0.qcow2', + }, + }; + } elsif ($storeid eq 'lvm-store') { + $snapshots =3D { + current =3D> { + file =3D> '/dev/veegee/vm-8006-disk-0.qcow2', + parent =3D> 'snap2', + }, + snap2 =3D> { + file =3D> '/dev/veegee/snap2-vm-8006-disk-0.qcow2', + parent =3D> 'snap1', + }, + snap1 =3D> { + file =3D> '/dev/veegee/snap1-vm-8006-disk-0.qcow2', + }, + }; + } + return $snapshots; + }, ); =20 my $file_stat_module =3D Test::MockModule->new("File::stat"); --=20 2.39.5 --===============6247922918576148936== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============6247922918576148936==--