From: Dominik Csapak <d.csapak@proxmox.com>
To: Fiona Ebner <f.ebner@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH qemu-server 2/3] fix #7743: api: disk import: avoid locking twice when importing from OVA or same VM
Date: Fri, 3 Jul 2026 11:31:02 +0200 [thread overview]
Message-ID: <9aee436a-69a0-41ed-a6c8-46107aded293@proxmox.com> (raw)
In-Reply-To: <20260629124625.115457-3-f.ebner@proxmox.com>
On 6/29/26 2:46 PM, Fiona Ebner wrote:
> When import_from_volid->() is called, the VM configuration of the
> destination VM is already locked. In case the source volume belongs to
> the same VM, there would be a second attempt to lock the config. In
> particular, this also happens when importing from OVA, because the
> source image is first extracted and belongs to the same VM.
the explanation makes sense, and it fixes the issue (works now for POST
& PUT) but i'm somehow missing the connection here?
AFAIU the reason is that in the async case we lock the config
then fork and then lock again (which does not work)
but in the sync case we lock and later lock again in the
same process so the cached lock in PVE::Tools succeeds?
IMHO the code and rationale is fine here, but i would find it good
to get the actual reason why it failed + why this change
impacts the POST vs PUT case.
Otherwise from the commit message consider this
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
>
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
> src/PVE/API2/Qemu.pm | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
> index e575d36b..b2a15d96 100644
> --- a/src/PVE/API2/Qemu.pm
> +++ b/src/PVE/API2/Qemu.pm
> @@ -390,10 +390,13 @@ my $import_from_volid = sub {
> };
>
> my $cloned;
> - if ($running) {
> - $cloned = PVE::QemuConfig->lock_config_full($src_vmid, 30, $clonefn);
> - } elsif ($src_vmid) {
> - $cloned = PVE::QemuConfig->lock_config_shared($src_vmid, 30, $clonefn);
> + # The config is already locked for the destination.
> + if ($src_vmid && $src_vmid != $dest_info->{vmid}) {
> + if ($running) {
> + $cloned = PVE::QemuConfig->lock_config_full($src_vmid, 30, $clonefn);
> + } else {
> + $cloned = PVE::QemuConfig->lock_config_shared($src_vmid, 30, $clonefn);
> + }
> } else {
> $cloned = $clonefn->();
> }
next prev parent reply other threads:[~2026-07-03 9:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 12:45 [PATCH-SERIES qemu-server 0/3] fix #7743: api: disk import: avoid locking twice when importing from OVA or same VM Fiona Ebner
2026-06-29 12:45 ` [PATCH qemu-server 1/3] api: disk import: remove unused wrongly named variable Fiona Ebner
2026-07-03 9:32 ` Dominik Csapak
2026-06-29 12:45 ` [PATCH qemu-server 2/3] fix #7743: api: disk import: avoid locking twice when importing from OVA or same VM Fiona Ebner
2026-07-03 9:31 ` Dominik Csapak [this message]
2026-06-29 12:45 ` [PATCH qemu-server 3/3] api: update vm: fork before locking Fiona Ebner
2026-07-03 9:41 ` Dominik Csapak
2026-07-03 11:44 ` Fiona Ebner
2026-07-03 12:00 ` Dominik Csapak
2026-06-30 9:49 ` [PATCH-SERIES qemu-server 0/3] fix #7743: api: disk import: avoid locking twice when importing from OVA or same VM Manuel Federanko
2026-07-03 11:59 ` superseded: " Fiona Ebner
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=9aee436a-69a0-41ed-a6c8-46107aded293@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=f.ebner@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