all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 2/4] importdisk: convert imported volume disks to base images for templates
Date: Thu, 17 Oct 2024 13:51:22 +0200	[thread overview]
Message-ID: <20241017115124.75539-2-d.kral@proxmox.com> (raw)
In-Reply-To: <20241017115124.75539-1-d.kral@proxmox.com>

Automatically converts any imported volume disk to a base volume image
if the VM is a template and the volume was imported using the
"target-disk" option, as "unused" disks are not needed to be converted
as they won't be cloned with either linked nor full clones.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---

Notes:
    Change to the command line output
    
    There is a small change to the console output at the end, because (a)
    it produces less code than correctly setting the $drive_id and $volid
    again, and (b) it is more consistent with the console prints of
    `create_disks` used when creating new VM disks.

 PVE/CLI/qm.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index 30282f6f..e65684bd 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -622,7 +622,13 @@ __PACKAGE__->register_method ({
 		format => $format,
 	    });
 
-	print "Successfully imported disk as '$drive_id:$volid'\n";
+	$vm_conf = PVE::QemuConfig->load_config($vmid);
+
+	# change imported _used_ disk to a base volume in case the VM is a template
+	PVE::QemuServer::template_create($vmid, $vm_conf, $drive_id)
+	    if is_valid_drivename($drive_id) && PVE::QemuConfig->is_template($vm_conf);
+
+	print "$drive_id: successfully imported disk '$vm_conf->{$drive_id}'\n";
 
 	return;
     }});
-- 
2.39.5



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


  reply	other threads:[~2024-10-17 11:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 11:51 [pve-devel] [PATCH qemu-server 1/4] importdisk: add 'target-disk' option to add imported volume to disk Daniel Kral
2024-10-17 11:51 ` Daniel Kral [this message]
2024-10-17 11:51 ` [pve-devel] [PATCH qemu-server 3/4] fix #5301: convert added volume disks to base image for templates Daniel Kral
2024-10-17 11:51 ` [pve-devel] [PATCH qemu-server 4/4] templates: add documentation to template_create Daniel Kral
2024-11-17 18:54 ` [pve-devel] applied-series: [PATCH qemu-server 1/4] importdisk: add 'target-disk' option to add imported volume to disk 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=20241017115124.75539-2-d.kral@proxmox.com \
    --to=d.kral@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