qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Steve Sistare <steven.sistare@oracle.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrange" <berrange@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Zeng" <jason.zeng@linux.intel.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Juan Quintela" <quintela@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Steve Sistare" <steven.sistare@oracle.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH V2 20/22] cpr: only-cpr-capable option
Date: Tue,  5 Jan 2021 07:42:08 -0800	[thread overview]
Message-ID: <1609861330-129855-21-git-send-email-steven.sistare@oracle.com> (raw)
In-Reply-To: <1609861330-129855-1-git-send-email-steven.sistare@oracle.com>

Add the only-cpr-capable option, which causes qemu to exit with an error
if any devices that are not capable of cpr are added.  This guarantees that
a cprsave operation will not fail with an unsupported device error.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 chardev/char-socket.c   |  1 +
 exec.c                  |  3 +++
 include/sysemu/sysemu.h |  1 +
 migration/migration.c   |  6 ++++++
 qemu-options.hx         |  8 ++++++++
 softmmu/vl.c            | 13 +++++++++++++
 6 files changed, 32 insertions(+)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 0965305..580d731 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -36,6 +36,7 @@
 #include "qapi/qapi-visit-sockets.h"
 
 #include "chardev/char-io.h"
+#include "sysemu/sysemu.h"
 #include "qemu/env.h"
 
 /***********************************************************/
diff --git a/exec.c b/exec.c
index 6a6e43d..01732f5 100644
--- a/exec.c
+++ b/exec.c
@@ -2271,6 +2271,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
                 new_block->flags |= RAM_SHARED;
                 addr = file_ram_alloc(new_block, maxlen, mfd, false, errp);
                 trace_anon_memfd_alloc(name, maxlen, addr, mfd);
+            } else if (only_cpr_capable) {
+                error_report("only-cpr-capable requires memfd-alloc");
+                errno = 0;
             } else {
                 addr = phys_mem_alloc(maxlen, &mr->align, shared);
             }
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index f0017d4..a72e7da 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -14,6 +14,7 @@ extern const char *qemu_name;
 extern QemuUUID qemu_uuid;
 extern bool qemu_uuid_set;
 extern bool memfd_alloc;
+extern bool only_cpr_capable;
 extern int start_on_wake;
 
 void qemu_add_data_dir(const char *path);
diff --git a/migration/migration.c b/migration/migration.c
index 8fe3633..5459a2a 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1099,6 +1099,12 @@ static bool migrate_caps_check(bool *cap_list,
         }
     }
 
+    if (cap_list[MIGRATION_CAPABILITY_X_COLO] && only_cpr_capable) {
+        error_setg(errp, "x-colo is not compatible with -only-cpr-capable");
+        return false;
+    }
+
+
     return true;
 }
 
diff --git a/qemu-options.hx b/qemu-options.hx
index 1ab5af5..ff8464f 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4116,6 +4116,14 @@ SRST
     an unmigratable state.
 ERST
 
+DEF("only-cpr-capable", 0, QEMU_OPTION_only_cpr_capable, \
+    "-only-cpr-capable    allow only cpr capable devices\n", QEMU_ARCH_ALL)
+SRST
+``-only-cpr-capable``
+    Only allow cpr capable devices, which guarantees that cprsave will not fail
+    with an unsupported device error.
+ERST
+
 #ifdef __linux__
 DEF("memfd-alloc", 0,  QEMU_OPTION_memfd_alloc, \
     "-memfd-alloc         allocate anonymous memory using memfd_create\n",
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 9f2be5c..e101056 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -164,6 +164,7 @@ bool boot_strict;
 uint8_t *boot_splash_filedata;
 int only_migratable; /* turn it off unless user states otherwise */
 bool wakeup_suspend_enabled;
+bool only_cpr_capable;
 bool memfd_alloc;
 int start_on_wake;
 static char **argv_main;
@@ -3679,6 +3680,9 @@ void qemu_init(int argc, char **argv, char **envp)
             case QEMU_OPTION_only_migratable:
                 only_migratable = 1;
                 break;
+            case QEMU_OPTION_only_cpr_capable:
+                only_cpr_capable = true;
+                break;
             case QEMU_OPTION_memfd_alloc:
                 memfd_alloc = true;
                 break;
@@ -4433,6 +4437,15 @@ void qemu_init(int argc, char **argv, char **envp)
 
     cpu_synchronize_all_post_init();
 
+    if (only_cpr_capable && replay_mode != REPLAY_MODE_NONE) {
+        error_report("replay is not compatible with -only-cpr-capable");
+        exit(1);
+    }
+    if (only_cpr_capable && !qemu_chr_cpr_capable(&err)) {
+        error_report_err(err);
+        exit(1);
+    }
+
     rom_reset_order_override();
 
     /* Did we create any drives that we failed to create a device for? */
-- 
1.8.3.1



  parent reply	other threads:[~2021-01-05 16:26 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 15:41 [PATCH V2 00/22] Live Update Steve Sistare
2021-01-05 15:41 ` [PATCH V2 01/22] as_flat_walk Steve Sistare
2021-01-05 15:41 ` [PATCH V2 02/22] qemu_ram_volatile Steve Sistare
2021-01-05 15:41 ` [PATCH V2 03/22] oslib: qemu_clr_cloexec Steve Sistare
2021-01-05 15:41 ` [PATCH V2 04/22] util: env var helpers Steve Sistare
2021-01-05 15:41 ` [PATCH V2 05/22] vl: memfd-alloc option Steve Sistare
2021-01-05 16:27   ` Daniel P. Berrangé
2021-01-06 16:36     ` Steven Sistare
2021-01-06 20:10       ` Paolo Bonzini
2021-01-06 21:19         ` Steven Sistare
2021-01-05 15:41 ` [PATCH V2 06/22] vl: add helper to request re-exec Steve Sistare
2021-01-05 15:41 ` [PATCH V2 07/22] cpr Steve Sistare
2021-01-05 15:41 ` [PATCH V2 08/22] cpr: QMP interfaces Steve Sistare
2021-01-05 15:41 ` [PATCH V2 09/22] cpr: HMP interfaces Steve Sistare
2021-01-05 15:41 ` [PATCH V2 10/22] pci: export functions for cpr Steve Sistare
2021-01-05 15:41 ` [PATCH V2 11/22] vfio-pci: refactor " Steve Sistare
2021-01-05 15:42 ` [PATCH V2 12/22] vfio-pci: cpr Steve Sistare
2021-01-05 15:42 ` [PATCH V2 13/22] vhost: reset vhost devices upon cprsave Steve Sistare
2021-01-05 15:42 ` [PATCH V2 14/22] chardev: cpr framework Steve Sistare
2021-01-05 15:42 ` [PATCH V2 15/22] chardev: cpr for simple devices Steve Sistare
2021-01-05 15:42 ` [PATCH V2 16/22] chardev: cpr for pty Steve Sistare
2021-01-05 15:42 ` [PATCH V2 17/22] chardev: socket accept subroutine Steve Sistare
2021-01-05 15:42 ` [PATCH V2 18/22] chardev: cpr for sockets Steve Sistare
2021-01-05 16:22   ` Daniel P. Berrangé
2021-01-05 16:35     ` Steven Sistare
2021-01-05 15:42 ` [PATCH V2 19/22] monitor: cpr support Steve Sistare
2021-01-05 15:42 ` Steve Sistare [this message]
2021-01-05 15:42 ` [PATCH V2 21/22] cpr: maintainers Steve Sistare
2021-01-05 15:42 ` [PATCH V2 22/22] simplify savevm Steve Sistare

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=1609861330-129855-21-git-send-email-steven.sistare@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=alex.bennee@linaro.org \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=jason.zeng@linux.intel.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.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;
as well as URLs for NNTP newsgroup(s).