On 11/25/19 11:05 AM, Fabian Grünbichler wrote:
> On November 25, 2019 10:53 am, Thomas Lamprecht wrote:
>> On 11/25/19 10:49 AM, Fabian Grünbichler wrote:
>>> if we don't know which format the source volume/file has, let qemu-img
>>> decide.
>>>
>>> Signed-off-by: Fabian Grünbichler <f.gruenbich...@proxmox.com>
>>> ---
>>> also checked EFI disk creation, auto-detection works correctly there.
>>>
>>>  PVE/QemuServer.pm                  | 7 ++++---
>>>  test/run_qemu_img_convert_tests.pl | 4 ++--
>>>  2 files changed, 6 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>>> index fcedcf1..26f1797 100644
>>> --- a/PVE/QemuServer.pm
>>> +++ b/PVE/QemuServer.pm
>>> @@ -6715,7 +6715,7 @@ sub qemu_img_convert {
>>>      my $cachemode;
>>>      my $src_path;
>>>      my $src_is_iscsi = 0;
>>> -    my $src_format = 'raw';
>>> +    my $src_format;
>>>  
>>>      if ($src_storeid) {
>>>     PVE::Storage::activate_volumes($storecfg, [$src_volid], $snapname);
>>> @@ -6740,14 +6740,15 @@ sub qemu_img_convert {
>>>  
>>>      my $cmd = [];
>>>      push @$cmd, '/usr/bin/qemu-img', 'convert', '-p', '-n';
>>> -    push @$cmd, '-l', "snapshot.name=$snapname" if($snapname && 
>>> $src_format eq "qcow2");
>>> +    push @$cmd, '-l', "snapshot.name=$snapname"
>>> +   if $snapname && defined($src_format) && $src_format eq "qcow2";
>>>      push @$cmd, '-t', 'none' if $dst_scfg->{type} eq 'zfspool';
>>>      push @$cmd, '-T', $cachemode if defined($cachemode);
>>>  
>>>      if ($src_is_iscsi) {
>>>     push @$cmd, '--image-opts';
>>>     $src_path = convert_iscsi_path($src_path);
>>> -    } else {
>>> +    } elsif($src_format) {
>>
>> defined-ness check also here, if you use it in the postif too..
>>
>> looks OK, besides that
> 
> we don't strictly need the defined-ness check in the postif either,
> since $src_format can only either be undef, or true/non-empty ;)

I know.. keep it consistent.

> 
>>
>>>     push @$cmd, '-f', $src_format;
>>>      }
>>>  
>>> diff --git a/test/run_qemu_img_convert_tests.pl 
>>> b/test/run_qemu_img_convert_tests.pl
>>> index 8a57108..bd5542f 100755
>>> --- a/test/run_qemu_img_convert_tests.pl
>>> +++ b/test/run_qemu_img_convert_tests.pl
>>> @@ -170,7 +170,7 @@ my $tests = [
>>>     name => "efidisk",
>>>     parameters => [ "/usr/share/kvm/OVMF_VARS-pure-efi.fd", 
>>> "local:$vmid/vm-$vmid-disk-0.raw", 1024*10, undef, 0 ],
>>>     expected => [
>>> -       "/usr/bin/qemu-img", "convert", "-p", "-n", "-f", "raw", "-O", 
>>> "raw",
>>> +       "/usr/bin/qemu-img", "convert", "-p", "-n", "-O", "raw",
>>>         "/usr/share/kvm/OVMF_VARS-pure-efi.fd",
>>>         "/var/lib/vz/images/$vmid/vm-$vmid-disk-0.raw",
>>>     ]
>>> @@ -179,7 +179,7 @@ my $tests = [
>>>     name => "efi2zos",
>>>     parameters => [ "/usr/share/kvm/OVMF_VARS-pure-efi.fd", 
>>> "zfs-over-iscsi:vm-$vmid-disk-0", 1024*10, undef, 0 ],
>>>     expected => [
>>> -       "/usr/bin/qemu-img", "convert", "-p", "-n", "-f", "raw", 
>>> "--target-image-opts",
>>> +       "/usr/bin/qemu-img", "convert", "-p", "-n", "--target-image-opts",
>>>         "/usr/share/kvm/OVMF_VARS-pure-efi.fd",
>>>         
>>> "file.driver=iscsi,file.transport=tcp,file.initiator-name=foobar,file.portal=127.0.0.1,file.target=iqn.2019-10.org.test:foobar,file.lun=1,driver=raw",
>>>     ]
>>>
>>
>>
>>



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

Reply via email to