From: Erik Fastermann <e.fastermann@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Erik Fastermann <e.fastermann@proxmox.com>
Subject: [PATCH qemu-server v2 3/5] remote migration: pull in checks from qm
Date: Fri, 7 Aug 2026 11:12:25 +0200 [thread overview]
Message-ID: <20260807091227.73614-4-e.fastermann@proxmox.com> (raw)
In-Reply-To: <20260807091227.73614-1-e.fastermann@proxmox.com>
Pull in the checks that previously lived only in the qm CLI into the
endpoint. Direct API callers such as the web UI now run them too, so
fewer migrations start only to fail partway.
The logic is mostly identical. Error messages are reworded slightly and
errors are collected instead of dying on the first one.
Signed-off-by: Erik Fastermann <e.fastermann@proxmox.com>
---
src/PVE/API2/Qemu.pm | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index b16a1365..1d94babd 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -1136,6 +1136,47 @@ my sub validate_remote_migrate_preconditions {
return;
}
+ my $resources = eval { $api_client->get("/cluster/resources", { type => 'vm' }) };
+ if (my $err = $@) {
+ $add_error->('remote-query', $err);
+ } elsif (grep { defined($_->{vmid}) && $_->{vmid} eq $target_vmid } @$resources) {
+ $add_error->('target-vmid-exists', "remote: guest with ID '$target_vmid' already exists");
+ }
+
+ my $storages = eval { $api_client->get("/nodes/localhost/storage", { enabled => 1 }) };
+ if (my $err = $@) {
+ $add_error->('remote-query', $err);
+ } else {
+ my $check_remote_storage = sub {
+ my ($storage) = @_;
+ my $found = [grep { $_->{storage} eq $storage } @$storages];
+
+ if (!@$found) {
+ $add_error->(
+ 'storage-missing',
+ "remote: storage '$storage' does not exist (or missing permission)",
+ storage => $storage,
+ );
+ return;
+ }
+
+ $found = $found->[0];
+ my $content_types = [PVE::Tools::split_list($found->{content})];
+ $add_error->(
+ 'storage-no-images',
+ "remote: storage '$storage' cannot store images",
+ storage => $storage,
+ ) if !grep { $_ eq 'images' } @$content_types;
+ };
+
+ for my $target_sid (values $storagemap->{entries}->%*) {
+ $check_remote_storage->($target_sid);
+ }
+
+ $check_remote_storage->($storagemap->{default})
+ if $storagemap->{default};
+ }
+
my $repl_conf = PVE::ReplicationConfig->new();
my $is_replicated = $repl_conf->check_for_existing_jobs($source_vmid, 1);
$add_error->('vm-replicated', "cannot remote-migrate replicated VM")
--
2.47.3
next prev parent reply other threads:[~2026-08-07 9:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 9:12 [PATCH qemu-server v2 0/5] remote migration: extract preconditions and add check endpoint Erik Fastermann
2026-08-07 9:12 ` [PATCH qemu-server v2 1/5] remote migration: drop ineffective fingerprint auto-detection Erik Fastermann
2026-08-07 9:12 ` [PATCH qemu-server v2 2/5] remote migration: collect preconditions as structured findings Erik Fastermann
2026-08-07 9:12 ` Erik Fastermann [this message]
2026-08-07 9:12 ` [PATCH qemu-server v2 4/5] qm: remote-migrate: call API endpoint directly Erik Fastermann
2026-08-07 9:12 ` [PATCH qemu-server v2 5/5] remote migration: add precondition check endpoint Erik Fastermann
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=20260807091227.73614-4-e.fastermann@proxmox.com \
--to=e.fastermann@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.