all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 3/3] image convert: make using zeroinit with target-image-opts work
Date: Wed, 30 Jul 2025 17:03:17 +0200	[thread overview]
Message-ID: <20250730150325.138087-4-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250730150325.138087-1-f.ebner@proxmox.com>

Also add a test to witness this combination.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer/QemuImage.pm        | 17 +++++++++++------
 src/test/run_qemu_img_convert_tests.pl | 21 +++++++++++++++++++++
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/src/PVE/QemuServer/QemuImage.pm b/src/PVE/QemuServer/QemuImage.pm
index f2cadd69..71be3abb 100644
--- a/src/PVE/QemuServer/QemuImage.pm
+++ b/src/PVE/QemuServer/QemuImage.pm
@@ -33,16 +33,16 @@ sub convert_iscsi_path {
 }
 
 my sub qcow2_target_image_opts {
-    my ($storecfg, $drive, @qcow2_opts) = @_;
+    my ($storecfg, $drive, $qcow2_opts, $zeroinit) = @_;
 
     # There is no machine version, the qemu-img binary version is what's important.
     my $version = PVE::QemuServer::Helpers::kvm_user_version();
 
+    my $blockdev_opts = { 'no-throttle' => 1 };
+    $blockdev_opts->{'zero-initialized'} = 1 if $zeroinit;
+
     my $blockdev = PVE::QemuServer::Blockdev::generate_drive_blockdev(
-        $storecfg,
-        $drive,
-        $version,
-        { 'no-throttle' => 1 },
+        $storecfg, $drive, $version, $blockdev_opts,
     );
 
     my $opts = [];
@@ -166,7 +166,12 @@ sub convert {
         # don't use any other drive options, those are intended for use with a running VM and just
         # use scsi0 as a dummy interface+index for now
         my $dst_drive = { file => $dst_volid, interface => 'scsi', index => 0 };
-        $dst_path = qcow2_target_image_opts($storecfg, $dst_drive, 'discard-no-unref=true');
+        $dst_path = qcow2_target_image_opts(
+            $storecfg,
+            $dst_drive,
+            ['discard-no-unref=true'],
+            $opts->{'is-zero-initialized'},
+        );
     } else {
         push @$cmd, '-O', $dst_format;
     }
diff --git a/src/test/run_qemu_img_convert_tests.pl b/src/test/run_qemu_img_convert_tests.pl
index 393fc4a8..8a0ad283 100755
--- a/src/test/run_qemu_img_convert_tests.pl
+++ b/src/test/run_qemu_img_convert_tests.pl
@@ -548,6 +548,27 @@ my $tests = [
                 . ",file.filename=/var/lib/vzsnapext/images/$vmid/vm-$vmid-disk-target.qcow2",
         ],
     },
+    {
+        name => "qcow2_external_snapshot_target_zeroinit",
+        parameters => [
+            "local:$vmid/vm-$vmid-disk-0.raw",
+            "localsnapext:$vmid/vm-$vmid-disk-target.qcow2",
+            1024 * 10,
+            { 'is-zero-initialized' => 1 },
+        ],
+        expected => [
+            "/usr/bin/qemu-img",
+            "convert",
+            "-p",
+            "-n",
+            "-f",
+            "raw",
+            "--target-image-opts",
+            "/var/lib/vz/images/$vmid/vm-$vmid-disk-0.raw",
+            "driver=zeroinit,file.discard-no-unref=true,file.driver=qcow2,file.file.driver=file"
+                . ",file.file.filename=/var/lib/vzsnapext/images/$vmid/vm-$vmid-disk-target.qcow2",
+        ],
+    },
     {
         name => "lvmqcow2_external_snapshot_target",
         parameters => [
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-07-30 15:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30 15:03 [pve-devel] [PATCH-SERIES qemu-server 0/3] image convert: fix handling qcow2 on snapshot-as-volume-chain dir target Fiona Ebner
2025-07-30 15:03 ` [pve-devel] [PATCH qemu-server 1/3] image convert: avoid combining target image options and zeroinit filter Fiona Ebner
2025-07-30 15:03 ` [pve-devel] [PATCH qemu-server 2/3] image convert: re-use generate_drive_blockdev() Fiona Ebner
2025-07-30 15:03 ` Fiona Ebner [this message]
2025-07-30 22:23 ` [pve-devel] applied: [PATCH-SERIES qemu-server 0/3] image convert: fix handling qcow2 on snapshot-as-volume-chain dir target Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250730150325.138087-4-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal