[pve-devel] [PATCH pve-storage 03/10] common: qemu_img_create: add backing_file support

DERUMIER, Alexandre alexandre.derumier at groupe-cyllene.com
Mon Jul 7 09:16:27 CEST 2025


Ah, sorry, I just notice than I have rebase the wrong patch serie
version (I had already done some fix for last fiona review)

Fiona wanted a dedicated sub to create backed images like


our $QCOW2_CLUSTERS = {
   backed => ['extended_l2=on','cluster_size=128k']
};

=pod

=head3 qemu_img_create_qcow2_backed

    qemu_img_create_qcow2_backed($scfg, $path, $backing_path,
$backing_format)

Create a new qemu qcow2 image C<$path> using an existing backing image
C<$backing_path> with backing_format C<$backing_format>.

=cut

sub qemu_img_create_qcow2_backed {
    my ($scfg, $path, $backing_path, $backing_format) = @_;

    my $cmd = ['/usr/bin/qemu-img', 'create', '-F', $backing_format, '-
b', $backing_path, '-f', 'qcow2', $path];

    my $options = $QCOW2_CLUSTERS->{backed};

    push @$options, preallocation_cmd_option($scfg, 'qcow2');
    push @$cmd, '-o', join(',', @$options) if @$options > 0;

    run_command($cmd, errmsg => "unable to create image");
}



More information about the pve-devel mailing list