[Qemu-devel] [PATCH v2 0/2] [RFC] qemu: arm: Migration between machines with different MIDR values

mjaggi@caviumnetworks.com posted 2 patches 5 years, 6 months ago
Only 1 patches received!
qemu-options.hx  | 13 +++++++++++++
target/arm/kvm.c | 15 +++++++++++++--
vl.c             | 24 ++++++++++++++++++++++++
3 files changed, 50 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH v2 0/2] [RFC] qemu: arm: Migration between machines with different MIDR values
Posted by mjaggi@caviumnetworks.com 5 years, 6 months ago
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


[Qemu-devel] [PATCH v2 2/2] [RFC] arm: program migrated guests' invariant registers with host ones
Posted by mjaggi@caviumnetworks.com 5 years, 6 months ago
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