qemu: arm: Migration between machines with different MIDR values
v2 cover qemu: arm: Migration between machines with different MIDR values
From: Manish Jaggi <[email protected]>
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(-)
Signature · 1 line
1.8.3.1
RFC PATCH v2 1/2 arm: Introduce hostinvariant command line option
From: Manish Jaggi <[email protected]>
This option is user opt-in. hostinvariant will replace guest's invariant registers with hosts.
qemu-options.hx +13 -0
@@ -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"
vl.c +24 -0
@@ -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' "
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v2 1/2] [RFC] arm: Introduce hostinvariant command line option
Quoted 6 lines · <[email protected]> wrote:
From: Manish Jaggi <[email protected]>
This option is user opt-in. hostinvariant will replace guest's invariant registers with hosts.
Signed-off-by Manish Jaggi <[email protected]>
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.
RFC PATCH v2 2/2 arm: program migrated guests' invariant registers with host ones
In reply to [email protected]From: Manish Jaggi <[email protected]>
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.
target/arm/kvm.c +13 -2
@@ -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".
Signature · 1 line
1.8.3.1