There are two migration methods with virtiofsd.

Virtiofsd in the 'find-paths' migration mode, tries to find the path
inside of the shared directory for every filesystem object that must be
transferred to the destination.
Add two extra parameters that verify file handles and confirm paths.

In the 'file-handles' migration mode every filesystem object is
converted to a file handle.

Add a parameter so that migration does not abort if an error occurs.
Aborting on error would result in a stopped VM on the destination node.

Signed-off-by: Markus Frank <[email protected]>
---
 src/PVE/QemuMigrate/Helpers.pm | 14 +++++++++++---
 src/PVE/QemuServer/Virtiofs.pm | 17 +++++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm
index f191565a..fef5e422 100644
--- a/src/PVE/QemuMigrate/Helpers.pm
+++ b/src/PVE/QemuMigrate/Helpers.pm
@@ -20,7 +20,6 @@ sub check_non_migratable_resources {
     my @blockers = ();
     if ($state) {
         push @blockers, "amd-sev" if $conf->{"amd-sev"};
-        push @blockers, "virtiofs" if 
PVE::QemuServer::Virtiofs::virtiofs_enabled($conf);
     }
 
     if (scalar(@blockers) && !$noerr) {
@@ -99,8 +98,17 @@ sub check_local_resources {
         }
         if ($k =~ m/^virtiofs/) {
             my $entry = parse_property_string('pve-qm-virtiofs', $conf->{$k});
-            $add_missing_mapping->('dir', $k, $entry->{dirid});
-            $mapped_res->{$k} = { name => $entry->{dirid} };
+            if (my $dirid = $entry->{dirid}) {
+                $add_missing_mapping->('dir', $k, $dirid);
+                my $mapped_device = { name => $dirid };
+                $mapped_res->{$k} = $mapped_device;
+
+                if ($dir_map->{ids}->{$dirid}->{'live-migration-method'}) {
+                    $mapped_device->{'live-migration'} = 1;
+                    # don't add mapped device with live migration as blocker
+                    next;
+                }
+            }
         }
         # sockets are safe: they will recreated be on the target side 
post-migrate
         next if $k =~ m/^serial/ && ($conf->{$k} eq 'socket');
diff --git a/src/PVE/QemuServer/Virtiofs.pm b/src/PVE/QemuServer/Virtiofs.pm
index b820ad27..b8285192 100644
--- a/src/PVE/QemuServer/Virtiofs.pm
+++ b/src/PVE/QemuServer/Virtiofs.pm
@@ -177,6 +177,9 @@ sub start_virtiofsd {
 
     my $dir_cfg = PVE::Mapping::Dir::find_on_current_node($virtiofs->{dirid});
 
+    my $dirid = $virtiofs->{dirid};
+    my $dir_properties = PVE::Mapping::Dir::config()->{ids}->{$dirid};
+
     my $virtiofsd_bin = '/usr/libexec/virtiofsd';
     if (!-f $virtiofsd_bin) {
         die "virtiofsd is not installed. To use virtio-fs, install virtiofsd 
via apt.\n";
@@ -201,6 +204,20 @@ sub start_virtiofsd {
             push @$cmd, '--readonly' if $virtiofs->{readonly};
             push @$cmd, '--cache=' . $virtiofs->{cache} if $virtiofs->{cache};
             push @$cmd, '--inode-file-handles=prefer' if $prefer_inode_fh;
+
+            if (my $method = $dir_properties->{'live-migration-method'}) {
+                # migration-on-error=abort would result in a stopped VM on the 
target node
+                push @$cmd, '--migration-on-error=guest-error';
+                if ($method eq 'find-paths') {
+                    push @$cmd, '--migration-mode=find-paths';
+                    push @$cmd, '--migration-verify-handles';
+                    push @$cmd, '--migration-confirm-paths';
+                }
+                if ($method eq 'file-handles') {
+                    push @$cmd, '--migration-mode=file-handles';
+                }
+            }
+
             push @$cmd, '--syslog';
             exec(@$cmd);
         } elsif (!defined($pid2)) {
-- 
2.47.3



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to