public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server v7 6/7] migration: check for mapped resources
Date: Fri, 16 Jun 2023 15:05:26 +0200	[thread overview]
Message-ID: <20230616130542.199182-7-d.csapak@proxmox.com> (raw)
In-Reply-To: <20230616130542.199182-1-d.csapak@proxmox.com>

they can only be migrated to nodes where there exists a mapping and if
the migration is done offline

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
no changes since v6
 PVE/QemuMigrate.pm | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 09cc1d83..3975ae41 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -210,15 +210,32 @@ sub prepare {
 	$self->{vm_was_paused} = 1 if PVE::QemuServer::vm_is_paused($vmid);
     }
 
-    my $loc_res = PVE::QemuServer::check_local_resources($conf, 1);
-    if (scalar @$loc_res) {
+    my ($loc_res, $mapped_res, $missing_mappings_by_node) = PVE::QemuServer::check_local_resources($conf, 1);
+    my $blocking_resources = [];
+    for my $res ($loc_res->@*) {
+	if (!grep($res, $mapped_res->@*)) {
+	    push $blocking_resources->@*, $res;
+	}
+    }
+    if (scalar($blocking_resources->@*)) {
 	if ($self->{running} || !$self->{opts}->{force}) {
-	    die "can't migrate VM which uses local devices: " . join(", ", @$loc_res) . "\n";
+	    die "can't migrate VM which uses local devices: " . join(", ", $blocking_resources->@*) . "\n";
 	} else {
 	    $self->log('info', "migrating VM which uses local devices");
 	}
     }
 
+    if (scalar($mapped_res->@*)) {
+	my $missing_mappings = $missing_mappings_by_node->{$self->{node}};
+	if ($running) {
+	    die "can't migrate running VM which uses mapped devices: " . join(", ", $mapped_res->@*) . "\n";
+	} elsif (scalar($missing_mappings->@*)) {
+	    die "can't migrate to '$self->{node}': missing mapped devices " . join(", ", $missing_mappings->@*) . "\n";
+	} else {
+	    $self->log('info', "migrating VM which uses mapped local devices");
+	}
+    }
+
     my $vollist = PVE::QemuServer::get_vm_volumes($conf);
 
     my $storages = {};
-- 
2.30.2





  parent reply	other threads:[~2023-06-16 13:06 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 13:05 [pve-devel] [PATCH qemu-server/manager/docs v7] cluster mapping Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH qemu-server v7 1/7] usb: refactor usb code and move some into USB module Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH qemu-server v7 2/7] enable cluster mapped USB devices for guests Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH qemu-server v7 3/7] enable cluster mapped PCI " Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH qemu-server v7 4/7] check_local_resources: extend for mapped resources Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH qemu-server v7 5/7] api: migrate preconditions: use new check_local_resources info Dominik Csapak
2023-06-16 13:05 ` Dominik Csapak [this message]
2023-06-16 13:05 ` [pve-devel] [PATCH qemu-server v7 7/7] add test for mapped pci devices Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 01/14] api: add resource map api endpoints for PCI and USB Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 02/14] ui: parser: add helper for lists of property strings Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 03/14] ui: form/USBSelector: make it more flexible with nodename Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 04/14] ui: form: add PCIMapSelector Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 05/14] ui: form: add USBMapSelector Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 06/14] ui: qemu/PCIEdit: rework panel to add a mapped configuration Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 07/14] ui: qemu/USBEdit: add 'mapped' device case Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 08/14] ui: form: add MultiPCISelector Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 09/14] ui: add edit window for pci mappings Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 10/14] ui: add edit window for usb mappings Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 11/14] ui: add ResourceMapTree Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 12/14] ui: allow configuring pci and usb mapping Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 13/14] ui: window/Migrate: allow mapped devices Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH manager v7 14/14] ui: improve permission handling for hardware Dominik Csapak
2023-06-16 13:05 ` [pve-devel] [PATCH docs v7 1/1] qemu: add documentation about cluster device mapping Dominik Csapak
2023-06-19  7:12   ` [pve-devel] applied: " Thomas Lamprecht
2023-06-16 15:00 ` [pve-devel] [PATCH qemu-server/manager/docs v7] cluster mapping Friedrich Weber
2023-06-19  5:29 ` [pve-devel] partially-applied: " Thomas Lamprecht
2023-06-19  7:28 ` [pve-devel] applied: " 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=20230616130542.199182-7-d.csapak@proxmox.com \
    --to=d.csapak@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