All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] [RFC] qemu: arm: Migration between machines with different MIDR values
@ 2018-10-23  9:31 mjaggi
  2018-10-23  9:31 ` [Qemu-devel] [PATCH v2 1/2] [RFC] arm: Introduce hostinvariant command line option mjaggi
  2018-10-23  9:31 ` [Qemu-devel] [PATCH v2 2/2] [RFC] arm: program migrated guests' invariant registers with host ones mjaggi
  0 siblings, 2 replies; 4+ messages in thread
From: mjaggi @ 2018-10-23  9:31 UTC (permalink / raw)
  To: Jaggi, Manish, quintela, dgilbert, eric.auger, qemu-devel,
	peter.maydell, Nair, Jayachandran, Nowicki, Tomasz

From: Manish Jaggi <manish.jaggi@cavium.com>

QEMU on arm systems use -machine virt -cpu host option for a VM.
Migration thus is limited between machines with same cpu.

This is a limitation if migration is desired between cpus which are of same
family and have only few difeerences like bug fixes which have no effect on
VM operation. They just differ in say MIDR values.

This patchset introduces an option -hostinvariant whic along with a new KVM
error code -KVM_EINVARIANT will enable qemu to replace migrated guests'
invariant regiters with destination machines cpu regs.

This feature is user opt-in. So user is aware of the differences in MIDR.

Changes since v1-
This patch is revised after previous RFC comments
https://lists.gnu.org/archive/html/qemu-devel/2018-09/msg03546.html

Manish Jaggi (2):
  arm: Introduce hostinvariant command line option
  arm: program migrated guests' invariant registers with host ones

 qemu-options.hx  | 13 +++++++++++++
 target/arm/kvm.c | 15 +++++++++++++--
 vl.c             | 24 ++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] [RFC] arm: Introduce hostinvariant command line option
  2018-10-23  9:31 [Qemu-devel] [PATCH v2 0/2] [RFC] qemu: arm: Migration between machines with different MIDR values mjaggi
@ 2018-10-23  9:31 ` mjaggi
  2018-10-24 10:02   ` Juan Quintela
  2018-10-23  9:31 ` [Qemu-devel] [PATCH v2 2/2] [RFC] arm: program migrated guests' invariant registers with host ones mjaggi
  1 sibling, 1 reply; 4+ messages in thread
From: mjaggi @ 2018-10-23  9:31 UTC (permalink / raw)
  To: Jaggi, Manish, quintela, dgilbert, eric.auger, qemu-devel,
	peter.maydell, Nair, Jayachandran, Nowicki, Tomasz

From: Manish Jaggi <manish.jaggi@cavium.com>

This option is user opt-in. hostinvariant will replace guest's invariant
registers with hosts.

Signed-off-by: Manish Jaggi <manish.jaggi@cavium.com>

diff --git a/qemu-options.hx b/qemu-options.hx
index 654ef48..d8c0da7 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3896,6 +3896,19 @@ STEXI
 prepend a timestamp to each log message.(default:on)
 ETEXI
 
+DEF("hostinvariant", HAS_ARG, QEMU_OPTION_hostinvariant,
+    "-hostinvariant enable[=on|off]\n"
+    "                migrated guest should use invariant register values of host\n"
+    "                on|off controls migration between arch64 systems using -cpu host but with different MIDR values (default:off)\n",
+    QEMU_ARCH_ARM)
+STEXI
+@item -hostinvariant enable[=on|off]
+@findex -hostinvariant
+controls migration between arch64 systems using -cpu host but with different MIDR values.(default:off)
+ETEXI
+
+
+
 DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
     "-dump-vmstate <file>\n"
     "                Output vmstate information in JSON format to file.\n"
diff --git a/vl.c b/vl.c
index 5ba06ad..b6df5f0 100644
--- a/vl.c
+++ b/vl.c
@@ -144,6 +144,7 @@ const char *mem_path = NULL;
 int mem_prealloc = 0; /* force preallocation of physical target memory */
 bool enable_mlock = false;
 bool enable_cpu_pm = false;
+bool enable_hostinvariant = false;
 int nb_nics;
 NICInfo nd_table[MAX_NICS];
 int autostart;
@@ -420,6 +421,19 @@ static QemuOptsList qemu_msg_opts = {
     },
 };
 
+static QemuOptsList qemu_hostinvariant_opts = {
+    .name = "hostinvariant",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_hostinvariant_opts.head),
+    .desc = {
+        {
+            .name = "enable",
+            .type = QEMU_OPT_BOOL,
+        },
+        { /* end of list */ }
+    },
+};
+
+
 static QemuOptsList qemu_name_opts = {
     .name = "name",
     .implied_opt_name = "guest",
@@ -2989,6 +3003,7 @@ int main(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_realtime_opts);
     qemu_add_opts(&qemu_overcommit_opts);
     qemu_add_opts(&qemu_msg_opts);
+    qemu_add_opts(&qemu_hostinvariant_opts);
     qemu_add_opts(&qemu_name_opts);
     qemu_add_opts(&qemu_numa_opts);
     qemu_add_opts(&qemu_icount_opts);
@@ -3948,6 +3963,15 @@ int main(int argc, char **argv, char **envp)
                 }
                 configure_msg(opts);
                 break;
+            case QEMU_OPTION_hostinvariant:
+                opts = qemu_opts_parse_noisily(qemu_find_opts("hostinvariant"), optarg,
+                                               false);
+                if (!opts) {
+                    exit(1);
+                }
+                enable_hostinvariant = qemu_opt_get_bool(opts, "hostinvariant", true);
+                error_report("Host Invariant=%d", enable_hostinvariant);
+                break;
             case QEMU_OPTION_dump_vmstate:
                 if (vmstate_dump_file) {
                     error_report("only one '-dump-vmstate' "
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] [RFC] arm: program migrated guests' invariant registers with host ones
  2018-10-23  9:31 [Qemu-devel] [PATCH v2 0/2] [RFC] qemu: arm: Migration between machines with different MIDR values mjaggi
  2018-10-23  9:31 ` [Qemu-devel] [PATCH v2 1/2] [RFC] arm: Introduce hostinvariant command line option mjaggi
@ 2018-10-23  9:31 ` mjaggi
  1 sibling, 0 replies; 4+ messages in thread
From: mjaggi @ 2018-10-23  9:31 UTC (permalink / raw)
  To: Jaggi, Manish, quintela, dgilbert, eric.auger, qemu-devel,
	peter.maydell, Nair, Jayachandran, Nowicki, Tomasz

From: Manish Jaggi <manish.jaggi@cavium.com>

When KVM_SET_ONE_REG returns KVM_EINVARIANT call KVM_GET_ONE_REG to query
and then replace the particular guest invariant register value with destination
hosts register.

Signed-off-by: Manish Jaggi <manish.jaggi@cavium.com>

diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 65f867d..8cf4dc9 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -19,6 +19,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "kvm_arm.h"
+#include "standard-headers/asm-arm/kvm_para.h"
 #include "cpu.h"
 #include "trace.h"
 #include "internals.h"
@@ -37,6 +38,8 @@ static bool cap_has_mp_state;
 
 static ARMHostCPUFeatures arm_host_cpu_features;
 
+extern bool enable_hostinvariant;
+
 int kvm_arm_vcpu_init(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
@@ -451,8 +454,16 @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
         default:
             abort();
         }
-        ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r);
-        if (ret) {
+	ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r);
+	if (enable_hostinvariant && ret == -KVM_EINVARIANT) {
+		/* Update Guest invariant to match with migrated host regs*/
+		ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r);
+		if (ret)
+			ok = false;
+		else
+                	cpu->cpreg_values[i] = r.addr;
+        }
+        else if (ret) {
             /* We might fail for "unknown register" and also for
              * "you tried to set a register which is constant with
              * a different value from what it actually contains".
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] [RFC] arm: Introduce hostinvariant command line option
  2018-10-23  9:31 ` [Qemu-devel] [PATCH v2 1/2] [RFC] arm: Introduce hostinvariant command line option mjaggi
@ 2018-10-24 10:02   ` Juan Quintela
  0 siblings, 0 replies; 4+ messages in thread
From: Juan Quintela @ 2018-10-24 10:02 UTC (permalink / raw)
  To: mjaggi
  Cc: Jaggi, Manish, dgilbert, eric.auger, qemu-devel, peter.maydell,
	Nair, Jayachandran, Nowicki, Tomasz

<mjaggi@caviumnetworks.com> wrote:
> From: Manish Jaggi <manish.jaggi@cavium.com>
>
> This option is user opt-in. hostinvariant will replace guest's invariant
> registers with hosts.
>
> Signed-off-by: Manish Jaggi <manish.jaggi@cavium.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

As I said in previous discussions, I still think that you should create
a better cpu model.  But as there is nothing like that on ARM, this is a
"showstop" solution.

Later, Juan.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-24 10:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23  9:31 [Qemu-devel] [PATCH v2 0/2] [RFC] qemu: arm: Migration between machines with different MIDR values mjaggi
2018-10-23  9:31 ` [Qemu-devel] [PATCH v2 1/2] [RFC] arm: Introduce hostinvariant command line option mjaggi
2018-10-24 10:02   ` Juan Quintela
2018-10-23  9:31 ` [Qemu-devel] [PATCH v2 2/2] [RFC] arm: program migrated guests' invariant registers with host ones mjaggi

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.