cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 51568d18bbfef1adce26d8cd33f3f4a4c12b1e78 Mon Sep 17 00:00:00 2001
9ae3a8
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
9ae3a8
Date: Fri, 26 Jan 2018 18:53:15 +0100
9ae3a8
Subject: [PATCH 4/4] savevm: fail if migration blockers are present
9ae3a8
9ae3a8
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
9ae3a8
Message-id: <20180126185315.2342-3-dgilbert@redhat.com>
9ae3a8
Patchwork-id: 78732
9ae3a8
O-Subject: [RHEL7.5 qemu-kvm PATCH 2/2] savevm: fail if migration blockers are present
9ae3a8
Bugzilla: 1536883
9ae3a8
RH-Acked-by: Peter Xu <peterx@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
From: Greg Kurz <gkurz@linux.vnet.ibm.com>
9ae3a8
9ae3a8
QEMU has currently two ways to prevent migration to occur:
9ae3a8
- migration blocker when it depends on runtime state
9ae3a8
- VMStateDescription.unmigratable when migration is not supported at all
9ae3a8
9ae3a8
This patch gathers all the logic into a single function to be called from
9ae3a8
both the savevm and the migrate paths.
9ae3a8
9ae3a8
This fixes a bug with 9p, at least, where savevm would succeed and the
9ae3a8
following would happen in the guest after loadvm:
9ae3a8
9ae3a8
$ ls /host
9ae3a8
ls: cannot access /host: Protocol error
9ae3a8
9ae3a8
With this patch:
9ae3a8
9ae3a8
(qemu) savevm foo
9ae3a8
Migration is disabled when VirtFS export path '/' is mounted in the guest
9ae3a8
using mount_tag 'host'
9ae3a8
9ae3a8
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
9ae3a8
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Message-Id: <146239057139.11271.9011797645454781543.stgit@bahia.huguette.org>
9ae3a8
[Update subject according to Paolo's suggestion - Amit]
9ae3a8
(cherry picked from commit 24f3902b088cd4f2dbebfd90527b5d81d6a050e9)
9ae3a8
  dgilbert: Manual merge
9ae3a8
9ae3a8
Signed-off-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 include/migration/migration.h |  1 +
9ae3a8
 migration.c                   | 21 +++++++++++++++------
9ae3a8
 savevm.c                      |  2 +-
9ae3a8
 3 files changed, 17 insertions(+), 7 deletions(-)
9ae3a8
9ae3a8
diff --git a/include/migration/migration.h b/include/migration/migration.h
9ae3a8
index c99a67c..0760984 100644
9ae3a8
--- a/include/migration/migration.h
9ae3a8
+++ b/include/migration/migration.h
9ae3a8
@@ -90,6 +90,7 @@ int migrate_fd_close(MigrationState *s);
9ae3a8
 
9ae3a8
 void add_migration_state_change_notifier(Notifier *notify);
9ae3a8
 void remove_migration_state_change_notifier(Notifier *notify);
9ae3a8
+bool migration_is_blocked(Error **errp);
9ae3a8
 bool migration_in_setup(MigrationState *);
9ae3a8
 bool migration_has_finished(MigrationState *);
9ae3a8
 bool migration_has_failed(MigrationState *);
9ae3a8
diff --git a/migration.c b/migration.c
9ae3a8
index e8c5939..5591601 100644
9ae3a8
--- a/migration.c
9ae3a8
+++ b/migration.c
9ae3a8
@@ -417,6 +417,20 @@ void migrate_del_blocker(Error *reason)
9ae3a8
     migration_blockers = g_slist_remove(migration_blockers, reason);
9ae3a8
 }
9ae3a8
 
9ae3a8
+bool migration_is_blocked(Error **errp)
9ae3a8
+{
9ae3a8
+    if (qemu_savevm_state_blocked(errp)) {
9ae3a8
+        return true;
9ae3a8
+    }
9ae3a8
+
9ae3a8
+    if (migration_blockers) {
9ae3a8
+        *errp = error_copy(migration_blockers->data);
9ae3a8
+        return true;
9ae3a8
+    }
9ae3a8
+
9ae3a8
+    return false;
9ae3a8
+}
9ae3a8
+
9ae3a8
 void qmp_migrate(const char *uri, bool has_blk, bool blk,
9ae3a8
                  bool has_inc, bool inc, bool has_detach, bool detach,
9ae3a8
                  Error **errp)
9ae3a8
@@ -447,12 +461,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
9ae3a8
         return;
9ae3a8
     }
9ae3a8
 
9ae3a8
-    if (qemu_savevm_state_blocked(errp)) {
9ae3a8
-        return;
9ae3a8
-    }
9ae3a8
-
9ae3a8
-    if (migration_blockers) {
9ae3a8
-        *errp = error_copy(migration_blockers->data);
9ae3a8
+    if (migration_is_blocked(errp)) {
9ae3a8
         return;
9ae3a8
     }
9ae3a8
 
9ae3a8
diff --git a/savevm.c b/savevm.c
9ae3a8
index d34004e..0216df2 100644
9ae3a8
--- a/savevm.c
9ae3a8
+++ b/savevm.c
9ae3a8
@@ -2207,7 +2207,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
9ae3a8
         .shared = 0
9ae3a8
     };
9ae3a8
 
9ae3a8
-    if (qemu_savevm_state_blocked(errp)) {
9ae3a8
+    if (migration_is_blocked(errp)) {
9ae3a8
         return -EINVAL;
9ae3a8
     }
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8