mirror of
https://git.proxmox.com/git/qemu-server
synced 2026-01-26 05:06:45 +00:00
fix #2173: use qemu-img to check cloudinit disk existence
use file_size_info to check for existence of cloudinit disk instead of '-e'. It uses `qemu-img info` to get some file info, which can handle rbd, and various other paths for volumes not exposed as normal file or not mapped, yet. this addresses a problem with rbd where the path returned available is not checkable with '-e'. Any size > 0 is interpreted as the image existing. Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
5294c110bb
commit
b56d56cf3a
@ -31,17 +31,18 @@ sub commit_cloudinit_disk {
|
||||
my $iso_path = PVE::Storage::path($storecfg, $drive->{file});
|
||||
my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
|
||||
my $format = PVE::QemuServer::qemu_img_format($scfg, $volname);
|
||||
if (! -e $iso_path) {
|
||||
|
||||
my $size = eval { PVE::Storage::file_size_info($iso_path) };
|
||||
if (!$size) {
|
||||
$volname =~ m/(vm-$vmid-cloudinit(.(qcow2|raw))?)/;
|
||||
my $name = $1;
|
||||
my $d = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $format, $name, 4 * 1024);
|
||||
$size = PVE::Storage::file_size_info($iso_path);
|
||||
}
|
||||
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
$plugin->activate_volume($storeid, $scfg, $volname);
|
||||
|
||||
my $size = PVE::Storage::file_size_info($iso_path);
|
||||
|
||||
eval {
|
||||
run_command([['genisoimage', '-R', '-V', $label, $path],
|
||||
['qemu-img', 'dd', '-n', '-f', 'raw', '-O', $format,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user