Commit 4ca1238e authored by @zhanghailiang's avatar @zhanghailiang Committed by zhuyanting
Browse files

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: default avatarYing Fang <fangying1@huawei.com>
parent 3a71cb4c
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -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