public inbox for pve-devel@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] api: create disks: also convert tpmstate and efidisk to base image for templates
Date: Fri, 10 Jan 2025 18:05:32 +0100	[thread overview]
Message-ID: <20250110170532.204262-1-d.kral@proxmox.com> (raw)

The commit 37a1f42a introduced a conversion step for newly allocated
volume disks to base volumes for VM templates. This wrongly excluded
efidisk and tmpstate volumes from this conversion, even though those
should be converted to base volumes too.

Therefore, include efidisks and tpmstate volumes to be converted to base
volumes when newly allocating them.

Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
Fixes: 37a1f42a ("fix #5301: convert added volume disks to base images for templates")
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
I tested these changes in the same way as the patch, which introduced
this behavior [0] with the small obvious change, that efidisk0 and
tpmstate0 should now be converted to base volume images instead as well:

```
55,56c55,56
< test_qmset "efidisk0" "$TEST_STORAGE:1,efitype=4m,pre-enrolled-keys=1" "base"
< test_qmset "tpmstate0" "$TEST_STORAGE:1,version=v2.0" "base"
---
> test_qmset "efidisk0" "$TEST_STORAGE:1,efitype=4m,pre-enrolled-keys=1" "vm"
> test_qmset "tpmstate0" "$TEST_STORAGE:1,version=v2.0" "vm"
```

[0] https://lore.proxmox.com/pve-devel/20241017115124.75539-3-d.kral@proxmox.com/

 PVE/API2/Qemu.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index db356b7e..8392400e 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -554,11 +554,12 @@ my sub create_disks : prototype($$$$$$$$$$$) {
 		    $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, "raw", undef, $size);
 		} else {
 		    $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $fmt, undef, $size);
-
-		    # change created disk to a base volume in case the VM is a template
-		    $volid = PVE::Storage::vdisk_create_base($storecfg, $volid)
-			if PVE::QemuConfig->is_template($conf);
 		}
+
+		# change created disk to a base volume in case the VM is a template
+		$volid = PVE::Storage::vdisk_create_base($storecfg, $volid)
+		    if PVE::QemuConfig->is_template($conf);
+
 		push @$vollist, $volid;
 		$disk->{file} = $volid;
 		$disk->{size} = PVE::Tools::convert_size($size, 'kb' => 'b');
-- 
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:[~2025-01-10 17:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250110170532.204262-1-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 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