public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Mira Limbeck <m.limbeck@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 2/2] fix volume_size_info failing for nonexistent cloudinit disk
Date: Fri, 25 Sep 2020 10:51:04 +0200	[thread overview]
Message-ID: <20200925085104.17299-2-m.limbeck@proxmox.com> (raw)
In-Reply-To: <20200925085104.17299-1-m.limbeck@proxmox.com>

After migration or a rollback the cloudinit disk might not be allocated, so
volume_size_info() fails. As we override the value anyway for cloudinit
and efi disks simply move the volume_size_info() call into the 'else'
branch.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
---
 PVE/QemuServer.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 2747c66..49765b7 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6895,10 +6895,10 @@ sub clone_disk {
 	$storeid = $storage if $storage;
 
 	my $dst_format = resolve_dst_disk_format($storecfg, $storeid, $volname, $format);
-	my ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 3);
 
 	print "create full clone of drive $drivename ($drive->{file})\n";
 	my $name = undef;
+	my $size = undef;
 	if (drive_is_cloudinit($drive)) {
 	    $name = "vm-$newvmid-cloudinit";
 	    $name .= ".$dst_format" if $dst_format ne 'raw';
@@ -6906,6 +6906,8 @@ sub clone_disk {
 	    $size = PVE::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE;
 	} elsif ($drivename eq 'efidisk0') {
 	    $size = get_efivars_size($conf);
+	} else {
+	    ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 3);
 	}
 	$size /= 1024;
 	$newvolid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $newvmid, $dst_format, $name, $size);
-- 
2.20.1





  reply	other threads:[~2020-09-25  8:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25  8:51 [pve-devel] [PATCH qemu-server 1/2] fix VM clone from snapshot with " Mira Limbeck
2020-09-25  8:51 ` Mira Limbeck [this message]
2020-09-25  9:40   ` [pve-devel] [PATCH qemu-server 2/2] fix volume_size_info failing for nonexistent " Mira Limbeck

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=20200925085104.17299-2-m.limbeck@proxmox.com \
    --to=m.limbeck@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal