From d68b43587a86eb8eb55a6dad545adccec10d565a Mon Sep 17 00:00:00 2001 From: Ying Fang Date: Wed, 27 May 2020 11:45:35 +0800 Subject: [PATCH] migration: Compat virtual timer adjust for v4.0.1 and v4.1.0 Vtimer adjust is used in openEuler qemu-4.0.1, however kvm_adjvtime is introduced in openEuler qemu-4.1.0. To maintain the compatibility and enable cross version migration, let's enable vtimer adjust only if kvm_adjvtime is not enabled, otherwise there may be conflicts between vtimer adjust and kvm_adjvtime. After this modification: 1: openEuler qemu-4.0.1 use vtimer as the default virtual timer 2: openEuler qemu-4.1.0 use kvm_adjvtime as the defaut virtual timer Migration from openEuler qemu-4.0.1 to openEuler qemu-4.1.0 will be ok, but migration path from upstream qemu-4.0.1 to openEuler qemu-4..0.1 will be broken. Since openEuler qemu-4.1.0, kvm_adjvtime is used as the default virtual timer. So please upgrade to openEuler qemu-4.1.0 and use the virt-4.1 machine. Signed-off-by: Ying Fang --- ...-virtual-timer-adjust-for-v4.0.1-and.patch | 80 +++++++++++++++++++ qemu.spec | 2 + 2 files changed, 82 insertions(+) create mode 100644 migration-Compat-virtual-timer-adjust-for-v4.0.1-and.patch diff --git a/migration-Compat-virtual-timer-adjust-for-v4.0.1-and.patch b/migration-Compat-virtual-timer-adjust-for-v4.0.1-and.patch new file mode 100644 index 0000000..7954894 --- /dev/null +++ b/migration-Compat-virtual-timer-adjust-for-v4.0.1-and.patch @@ -0,0 +1,80 @@ +From 79d722679731233ccb1aa775d896a4bf21e13d44 Mon Sep 17 00:00:00 2001 +From: Ying Fang +Date: Wed, 27 May 2020 10:02:06 +0800 +Subject: [PATCH] migration: Compat virtual timer adjust for v4.0.1 and v4.1.0 + +Vtimer adjust is used in openEuler qemu-4.0.1, however kvm_adjvtime +is introduced in openEuler qemu-4.1.0. To maintain the compatibility +and enable cross version migration, let's enable vtimer adjust only +if kvm_adjvtime is not enabled, otherwise there may be conflicts +between vtimer adjust and kvm_adjvtime. + +After this modification: +1: openEuler qemu-4.0.1 use vtimer as the default virtual timer +2: openEuler qemu-4.1.0 use kvm_adjvtime as the defaut virtual timer + +Migration from openEuler qemu-4.0.1 to openEuler qemu-4.1.0 will +be ok, but migration path from upstream qemu-4.0.1 to openEuler +qemu-4..0.1 will be broken. + +Since openEuler qemu-4.1.0, kvm_adjvtime is used as the default +virtual timer. So please upgrade to openEuler qemu-4.1.0 and +use the virt-4.1 machine. + +Signed-off-by: Ying Fang + +diff --git a/cpus.c b/cpus.c +index b9aa51f8..6a28bdef 100644 +--- a/cpus.c ++++ b/cpus.c +@@ -1067,6 +1067,12 @@ void cpu_synchronize_all_pre_loadvm(void) + } + + #ifdef __aarch64__ ++static bool kvm_adjvtime_enabled(CPUState *cs) ++{ ++ ARMCPU *cpu = ARM_CPU(cs); ++ return cpu->kvm_adjvtime == true; ++} ++ + static void get_vcpu_timer_tick(CPUState *cs) + { + CPUARMState *env = &ARM_CPU(cs)->env; +@@ -1096,7 +1102,13 @@ static int do_vm_stop(RunState state, bool send_stop) + cpu_disable_ticks(); + pause_all_vcpus(); + #ifdef __aarch64__ +- if (first_cpu) { ++ /* vtimer adjust is used in openEuler qemu-4.0.1, however kvm_adjvtime ++ * is introduced in openEuler qemu-4.1.0. To maintain the compatibility ++ * and enable cross version migration, let's enable vtimer adjust only ++ * if kvm_adjvtime is not enabled, otherwise there may be conflicts ++ * between vtimer adjust and kvm_adjvtime. ++ */ ++ if (first_cpu && !kvm_adjvtime_enabled(first_cpu)) { + get_vcpu_timer_tick(first_cpu); + } + #endif +@@ -1946,6 +1958,7 @@ void cpu_resume(CPUState *cpu) + } + + #ifdef __aarch64__ ++ + static void set_vcpu_timer_tick(CPUState *cs) + { + CPUARMState *env = &ARM_CPU(cs)->env; +@@ -1977,7 +1990,10 @@ void resume_all_vcpus(void) + + qemu_clock_enable(QEMU_CLOCK_VIRTUAL, true); + #ifdef __aarch64__ +- if (first_cpu) { ++ /* Enable vtimer adjust only if kvm_adjvtime is not enabled, otherwise ++ * there may be conflicts between vtimer adjust and kvm_adjvtime. ++ */ ++ if (first_cpu && !kvm_adjvtime_enabled(first_cpu)) { + set_vcpu_timer_tick(first_cpu); + } + #endif +-- +2.23.0 + diff --git a/qemu.spec b/qemu.spec index 1de0ed2..f2ee54a 100644 --- a/qemu.spec +++ b/qemu.spec @@ -171,6 +171,7 @@ Patch0158: log-Add-some-logs-on-VM-runtime-path.patch Patch0159: Revert-vtimer-compat-cross-version-migration-from-v4.patch Patch0160: ARM64-record-vtimer-tick-when-cpu-is-stopped.patch Patch0161: hw-arm-virt-add-missing-compat-for-kvm-no-adjvtime.patch +Patch0162: migration-Compat-virtual-timer-adjust-for-v4.0.1-and.patch BuildRequires: flex BuildRequires: bison @@ -520,6 +521,7 @@ getent passwd qemu >/dev/null || \ - Revert: "vtimer: compat cross version migration from v4.0.1" - ARM64: record vtimer tick when cpu is stopped - hw/arm/virt: add missing compat for kvm-no-adjvtime +- migration: Compat virtual timer adjust for v4.0.1 and v4.1.0 * Fri May 22 2020 Huawei Technologies Co., Ltd. - ip_reass: Fix use after free