Initial migration patches for s390
cover Initial migration patches for s390
Alex,
here is a small subset of migration patches for s390. Several things are still missing/under work (storage key/dirty pages tracking, guest time..)
Anyway, with those 3 patches, it is possible to stop + save a guest that contains just a kernel+busybox initrd into a file and reload it afterwards.
Patch 2 should be applied together with patch 1 to avoid a bump in the version number.
Please have a look
Christian Borntraeger (1):
s390/migration: Provide a cpu save for initial life migration work
Heinz Graalfs (1):
s390/migration: Add code to support SCLP live migration
Jason J. herne (1):
s390/migration: Qemu S390 special register migration
hw/s390x/event-facility.c | 46 +++++++++++++ hw/s390x/event-facility.h | 3 + hw/s390x/sclpconsole.c | 46 +++++++++++++ hw/s390x/sclpquiesce.c | 18 ++++++ target-s390x/cpu.h | 5 ++ target-s390x/machine.c | 156 +++++++++++++++++++++++++++++++++++++++++---- 6 files changed, 261 insertions(+), 13 deletions(-)
Signature · 1 line
1.7.10.1
PATCH 1/3 s390/migration: Provide a cpu save for initial life migration work
This provides a simple cpu load and save function. With the recent addition of sync regs we have the crs,acrs, the prefix and the PSW already up to date. Lets also save the fpu via pre/post hooks.
This patch also changes the license of machine.c to GPLv2 or later. (The old code was just empty glue code, so there is no need to go the "contributions after" way).
--- target-s390x/cpu.h | 1 + target-s390x/machine.c | 115 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 103 insertions(+), 13 deletions(-)
target-s390x/cpu.h +1 -0
@@ -27,6 +27,7 @@#define ELF_MACHINE EM_S390#define CPUArchState struct CPUS390XState +#define CPU_SAVE_VERSION 1#include "cpu-defs.h" #define TARGET_PAGE_BITS 12
target-s390x/machine.c +102 -13
131 lines not on this page · raw message
Signature · 1 line
1.7.10.1
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
Quoted 86 lines · Christian Borntraeger
This provides a simple cpu load and save function. With the recent addition of sync regs we have the crs,acrs, the prefix and the PSW already up to date. Lets also save the fpu via pre/post hooks.
This patch also changes the license of
machine.cto GPLv2 or later. (The old code was just empty glue code, so there is no need to go the "contributions after" way).Signed-off-by Christian Borntraeger<[email protected]>--- target-s390x/cpu.h | 1 + target-s390x/machine.c | 115 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 103 insertions(+), 13 deletions(-)target-s390x/cpu.h +1
-0@@ -27,6 +27,7 @@#define ELF_MACHINE EM_S390#define CPUArchState struct CPUS390XState +#define CPU_SAVE_VERSION 1#include "cpu-defs.h" #define TARGET_PAGE_BITS 12target-s390x/machine.c +35
-12@@ -2,29 +2,118 @@* QEMU S390x machine definitions * * Copyright (c) 2009 Alexander Graf<[email protected]> +* Copyright IBM Corp. 2012 * -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see<http://www.gnu.org/licenses/>. +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. */ #include "hw/hw.h" #include "hw/boards.h" +#include "cpu.h" +#include "kvm.h" + +#if definedCONFIG_KVM +static void cpu_pre_save (void *opaque) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return ; + } + + r =kvm_vcpu_ioctl (env,KVM_GET_FPU ,&fpu); +assert (r ==0 ); +for (i =0 ; i<16 ; i++) { + env->fregs[i].ll = fpu.fprs[i]; + } + env->fpc = fpu.fpc; +} + +static int cpu_post_load (void *opaque,int version_id) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return 0 ; + } +
target-s390x/machine.c line 54
Quoted 10 lines
target-s390x/machine.c +10
-0+for (i =0 ; i<16 ; i++) { + fpu.fprs[i] = env->fregs[i].ll; + } + fpu.fpc = env->fpc; + + r =kvm_vcpu_ioctl (env,KVM_SET_FPU ,&fpu); +assert (r ==0 ); + +return 0 ; +}
The kvm register sync needs to happen in the kvm register sync function :)
Alex
Quoted 66 lines
target-s390x/machine.c +57
-1+#else +static int cpu_post_load (void *opaque,int version_id) +{ +return 0 ; +} + +static void cpu_pre_save (void *opaque) +{ +} +#endif + + +static const VMStateDescription vmstate_cpu = { + .name ="cpu" , + .version_id =CPU_SAVE_VERSION , + .pre_save = cpu_pre_save, + .post_load = cpu_post_load, + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT64 (fregs[0 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[1 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[2 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[3 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[4 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[5 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[6 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[7 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[8 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[9 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[10 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[11 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[12 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[13 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[14 ].ll, CPUS390XState), +VMSTATE_UINT64 (fregs[15 ].ll, CPUS390XState), +VMSTATE_UINT64_ARRAY (regs, CPUS390XState,16 ), +VMSTATE_UINT64 (psw.mask, CPUS390XState), +VMSTATE_UINT64 (psw.addr, CPUS390XState), +VMSTATE_UINT64 (psa, CPUS390XState), +VMSTATE_UINT32 (fpc, CPUS390XState), +VMSTATE_UINT32_ARRAY (aregs, CPUS390XState,16 ), +VMSTATE_UINT64_ARRAY (cregs, CPUS390XState,16 ), +VMSTATE_END_OF_LIST () + }, + .subsections = (VMStateSubsection []) { + { +/* empty */ + } + } + +}; + + +void cpu_save (QEMUFile *f,void *opaque) { +vmstate_save_state (f,&vmstate_cpu, opaque); }int cpu_load (QEMUFile *f,void *opaque,int version_id) { -return 0 ; +return vmstate_load_state (f,&vmstate_cpu, opaque, version_id); }
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
Quoted 91 lines · Alexander Graf
Quoted 90 lines · Christian Borntraeger
This provides a simple cpu load and save function. With the recent addition of sync regs we have the crs,acrs, the prefix and the PSW already up to date. Lets also save the fpu via pre/post hooks.
This patch also changes the license of
machine.cto GPLv2 or later. (The old code was just empty glue code, so there is no need to go the "contributions after" way).Signed-off-by Christian Borntraeger<[email protected]>--- target-s390x/cpu.h | 1 + target-s390x/machine.c | 115 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 103 insertions(+), 13 deletions(-)target-s390x/cpu.h +1
-0@@ -27,6 +27,7 @@#define ELF_MACHINE EM_S390#define CPUArchState struct CPUS390XState +#define CPU_SAVE_VERSION 1#include "cpu-defs.h" #define TARGET_PAGE_BITS 12target-s390x/machine.c +39
-12@@ -2,29 +2,118 @@* QEMU S390x machine definitions * * Copyright (c) 2009 Alexander Graf<[email protected]> +* Copyright IBM Corp. 2012 * -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see<http://www.gnu.org/licenses/>. +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. */ #include "hw/hw.h" #include "hw/boards.h" +#include "cpu.h" +#include "kvm.h" + +#if definedCONFIG_KVM +static void cpu_pre_save (void *opaque) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return ; + } + + r =kvm_vcpu_ioctl (env,KVM_GET_FPU ,&fpu); +assert (r ==0 ); +for (i =0 ; i<16 ; i++) { + env->fregs[i].ll = fpu.fprs[i]; + } + env->fpc = fpu.fpc; +} + +static int cpu_post_load (void *opaque,int version_id) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return 0 ; + } + +for (i =0 ; i<16 ; i++) { + fpu.fprs[i] = env->fregs[i].ll; + } + fpu.fpc = env->fpc;
Quoted 8 lines
target-s390x/machine.c line 43
Quoted 6 lines
target-s390x/machine.c +6
-0+ + r =kvm_vcpu_ioctl (env,KVM_SET_FPU ,&fpu); +assert (r ==0 ); + +return 0 ; +}The kvm register sync needs to happen in the kvm register sync function :)
That would eliminate the whole purpose of sync regs and forces us to have an expensive ioctl on lots of exits (again). I would prefer to sync the registers that we never need in qemu just here.
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
Quoted 99 lines · Christian Borntraeger
Quoted 90 lines · Alexander Graf
Quoted 89 lines · Christian Borntraeger
This provides a simple cpu load and save function. With the recent addition of sync regs we have the crs,acrs, the prefix and the PSW already up to date. Lets also save the fpu via pre/post hooks.
This patch also changes the license of
machine.cto GPLv2 or later. (The old code was just empty glue code, so there is no need to go the "contributions after" way).Signed-off-by Christian Borntraeger<[email protected]>--- target-s390x/cpu.h | 1 + target-s390x/machine.c | 115 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 103 insertions(+), 13 deletions(-)target-s390x/cpu.h +1
-0@@ -27,6 +27,7 @@#define ELF_MACHINE EM_S390#define CPUArchState struct CPUS390XState +#define CPU_SAVE_VERSION 1#include "cpu-defs.h" #define TARGET_PAGE_BITS 12target-s390x/machine.c +38
-12@@ -2,29 +2,118 @@* QEMU S390x machine definitions * * Copyright (c) 2009 Alexander Graf<[email protected]> +* Copyright IBM Corp. 2012 * -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see<http://www.gnu.org/licenses/>. +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. */ #include "hw/hw.h" #include "hw/boards.h" +#include "cpu.h" +#include "kvm.h" + +#if definedCONFIG_KVM +static void cpu_pre_save (void *opaque) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return ; + } + + r =kvm_vcpu_ioctl (env,KVM_GET_FPU ,&fpu); +assert (r ==0 ); +for (i =0 ; i<16 ; i++) { + env->fregs[i].ll = fpu.fprs[i]; + } + env->fpc = fpu.fpc; +} + +static int cpu_post_load (void *opaque,int version_id) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return 0 ; + } + +for (i =0 ; i<16 ; i++) { + fpu.fprs[i] = env->fregs[i].ll; + }Quoted 8 lines
target-s390x/machine.c line 54
Quoted 7 lines
target-s390x/machine.c +7
-0+ fpu.fpc = env->fpc; + + r =kvm_vcpu_ioctl (env,KVM_SET_FPU ,&fpu); +assert (r ==0 ); + +return 0 ; +}The kvm register sync needs to happen in the kvm register sync function :)
Quoted 3 lines
That would eliminate the whole purpose of sync regs and forces us to have an expensive ioctl on lots of exits (again). I would prefer to sync the registers that we never need in qemu just here.
That's why the register sync has different stages.
Alex
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
Quoted 100 lines · Alexander Graf
Quoted 99 lines · Christian Borntraeger
Quoted 98 lines · Alexander Graf
Quoted 86 lines · Christian Borntraeger
This provides a simple cpu load and save function. With the recent addition of sync regs we have the crs,acrs, the prefix and the PSW already up to date. Lets also save the fpu via pre/post hooks.
This patch also changes the license of
machine.cto GPLv2 or later. (The old code was just empty glue code, so there is no need to go the "contributions after" way).Signed-off-by Christian Borntraeger<[email protected]>--- target-s390x/cpu.h | 1 + target-s390x/machine.c | 115 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 103 insertions(+), 13 deletions(-)target-s390x/cpu.h +1
-0@@ -27,6 +27,7 @@#define ELF_MACHINE EM_S390#define CPUArchState struct CPUS390XState +#define CPU_SAVE_VERSION 1#include "cpu-defs.h" #define TARGET_PAGE_BITS 12target-s390x/machine.c +35
-12@@ -2,29 +2,118 @@* QEMU S390x machine definitions * * Copyright (c) 2009 Alexander Graf<[email protected]> +* Copyright IBM Corp. 2012 * -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see<http://www.gnu.org/licenses/>. +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. */ #include "hw/hw.h" #include "hw/boards.h" +#include "cpu.h" +#include "kvm.h" + +#if definedCONFIG_KVM +static void cpu_pre_save (void *opaque) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return ; + } + + r =kvm_vcpu_ioctl (env,KVM_GET_FPU ,&fpu); +assert (r ==0 ); +for (i =0 ; i<16 ; i++) { + env->fregs[i].ll = fpu.fprs[i]; + } + env->fpc = fpu.fpc; +} + +static int cpu_post_load (void *opaque,int version_id) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return 0 ; + } +target-s390x/machine.c line 54
Quoted 10 lines
target-s390x/machine.c +10
-0+for (i =0 ; i<16 ; i++) { + fpu.fprs[i] = env->fregs[i].ll; + } + fpu.fpc = env->fpc; + + r =kvm_vcpu_ioctl (env,KVM_SET_FPU ,&fpu); +assert (r ==0 ); + +return 0 ; +}The kvm register sync needs to happen in the kvm register sync function :)
Quoted 5 lines
Quoted 3 lines
That would eliminate the whole purpose of sync regs and forces us to have an expensive ioctl on lots of exits (again). I would prefer to sync the registers that we never need in qemu just here.
That's why the register sync has different stages.
Not the get_register. Which is called on every synchronize_state. Which happen quite often on s390.
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
Quoted 101 lines · Christian Borntraeger
Quoted 100 lines · Alexander Graf
Quoted 99 lines · Christian Borntraeger
Quoted 98 lines · Alexander Graf
Quoted 86 lines · Christian Borntraeger
This provides a simple cpu load and save function. With the recent addition of sync regs we have the crs,acrs, the prefix and the PSW already up to date. Lets also save the fpu via pre/post hooks.
This patch also changes the license of
machine.cto GPLv2 or later. (The old code was just empty glue code, so there is no need to go the "contributions after" way).Signed-off-by Christian Borntraeger<[email protected]>--- target-s390x/cpu.h | 1 + target-s390x/machine.c | 115 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 103 insertions(+), 13 deletions(-)target-s390x/cpu.h +1
-0@@ -27,6 +27,7 @@#define ELF_MACHINE EM_S390#define CPUArchState struct CPUS390XState +#define CPU_SAVE_VERSION 1#include "cpu-defs.h" #define TARGET_PAGE_BITS 12target-s390x/machine.c +35
-12@@ -2,29 +2,118 @@* QEMU S390x machine definitions * * Copyright (c) 2009 Alexander Graf<[email protected]> +* Copyright IBM Corp. 2012 * -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see<http://www.gnu.org/licenses/>. +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. */ #include "hw/hw.h" #include "hw/boards.h" +#include "cpu.h" +#include "kvm.h" + +#if definedCONFIG_KVM +static void cpu_pre_save (void *opaque) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return ; + } + + r =kvm_vcpu_ioctl (env,KVM_GET_FPU ,&fpu); +assert (r ==0 ); +for (i =0 ; i<16 ; i++) { + env->fregs[i].ll = fpu.fprs[i]; + } + env->fpc = fpu.fpc; +} + +static int cpu_post_load (void *opaque,int version_id) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return 0 ; + } +target-s390x/machine.c line 54
Quoted 10 lines
target-s390x/machine.c +10
-0+for (i =0 ; i<16 ; i++) { + fpu.fprs[i] = env->fregs[i].ll; + } + fpu.fpc = env->fpc; + + r =kvm_vcpu_ioctl (env,KVM_SET_FPU ,&fpu); +assert (r ==0 ); + +return 0 ; +}The kvm register sync needs to happen in the kvm register sync function :)
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
That would eliminate the whole purpose of sync regs and forces us to have an expensive ioctl on lots of exits (again). I would prefer to sync the registers that we never need in qemu just here.
That's why the register sync has different stages.
Not the
get_register. Which is called on everysynchronize_state. Which happen quite often on s390.
Sounds like bad design then :).
Maybe we should explicitly tell the register synchronization which register sets to sync, so that we don't waste time getting _all_ the state every time we sync registers?
Jan, ideas?
Alex
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
On 21/11/12 16:06, Alexander Graf wrote:
[...]
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 13 lines
Quoted 13 lines
target-s390x/machine.c +13
-0+static int cpu_post_load (void *opaque,int version_id) +{ +CPUS390XState *env = opaque; +struct kvm_fpu fpu; +int i, r; + +if (!kvm_enabled ()) { +return 0 ; + } + +for (i =0 ; i<16 ; i++) { + fpu.fprs[i] = env->fregs[i].ll; + }Quoted 8 lines
target-s390x/machine.c line 54
Quoted 7 lines
target-s390x/machine.c +7
-0+ fpu.fpc = env->fpc; + + r =kvm_vcpu_ioctl (env,KVM_SET_FPU ,&fpu); +assert (r ==0 ); + +return 0 ; +}The kvm register sync needs to happen in the kvm register sync function :)
That would eliminate the whole purpose of sync regs and forces us to have an expensive ioctl on lots of exits (again). I would prefer to sync the registers that we never need in qemu just here.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
That's why the register sync has different stages.
Not the
get_register. Which is called on everysynchronize_state. Which happen quite often on s390.Sounds like bad design then :).
Maybe we should explicitly tell the register synchronization which register sets to sync, so that we don't waste time getting _all_ the state every time we sync registers?
Yes, a level statement for kvm_arch_get_registers would be good.
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
Quoted 27 lines · Christian Borntraeger
On 21/11/12 16:06, Alexander Graf wrote:
[...]Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 21 lines
Quoted 13 lines
Quoted 13 lines
(quoted diff) +13
-0+static int cpu_post_load(void *opaque, int version_id) +{ + CPUS390XState *env = opaque; + struct kvm_fpu fpu; + int i, r; + + if (!kvm_enabled()) { + return 0; + } + + for (i = 0; i< 16; i++) { + fpu.fprs[i] = env->fregs[i].ll; + }Quoted 8 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+ fpu.fpc = env->fpc; + + r = kvm_vcpu_ioctl(env, KVM_SET_FPU,&fpu); + assert(r == 0); + + return 0; +}The kvm register sync needs to happen in the kvm register sync function :)
Quoted 3 lines
That would eliminate the whole purpose of sync regs and forces us to have an expensive ioctl on lots of exits (again). I would prefer to sync the registers that we never need in qemu just here.
That's why the register sync has different stages.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Not the
get_register. Which is called on everysynchronize_state. Which happen quite often on s390.Sounds like bad design then :).
Maybe we should explicitly tell the register synchronization which register sets to sync, so that we don't waste time getting _all_ the state every time we sync registers?
Yes, a level statement for
kvm_arch_get_registerswould be good.
The challenge is defining those levels generically - as it is also generic code that calls cpu_synchronize_state. What levels do you have in mind? And where would they be applied?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
Quoted 33 lines · Jan Kiszka
Quoted 32 lines · Christian Borntraeger
On 21/11/12 16:06, Alexander Graf wrote:
[...]Quoted 30 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
(quoted diff) +10
-0+static int cpu_post_load(void *opaque, int version_id) +{ + CPUS390XState *env = opaque; + struct kvm_fpu fpu; + int i, r; + + if (!kvm_enabled()) { + return 0; + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ for (i = 0; i< 16; i++) { + fpu.fprs[i] = env->fregs[i].ll; + } + fpu.fpc = env->fpc; + + r = kvm_vcpu_ioctl(env, KVM_SET_FPU,&fpu); + assert(r == 0); + + return 0; +}The kvm register sync needs to happen in the kvm register sync function :)
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
That would eliminate the whole purpose of sync regs and forces us to have an expensive ioctl on lots of exits (again). I would prefer to sync the registers that we never need in qemu just here.
That's why the register sync has different stages.
Not the
get_register. Which is called on everysynchronize_state. Which happen quite often on s390.Sounds like bad design then :).
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Maybe we should explicitly tell the register synchronization which register sets to sync, so that we don't waste time getting _all_ the state every time we sync registers?
Yes, a level statement for
kvm_arch_get_registerswould be good.The challenge is defining those levels generically - as it is also generic code that calls
cpu_synchronize_state. What levels do you have in mind? And where would they be applied?
I think that RUNTIME_STATE and FULL_STATE would be sufficient for the needs that I have. The registers that I need during runtime can be accessed quite fast, but for life migration I also need those registers that are accessed via ONE_REG or other ioctls.
Christian
Re: [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work
Quoted 39 lines · Christian Borntraeger
Quoted 38 lines · Jan Kiszka
Quoted 36 lines · Christian Borntraeger
On 21/11/12 16:06, Alexander Graf wrote:
[...]Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 13 lines
Quoted 13 lines
(quoted diff) +13
-0+static int cpu_post_load(void *opaque, int version_id) +{ + CPUS390XState *env = opaque; + struct kvm_fpu fpu; + int i, r; + + if (!kvm_enabled()) { + return 0; + } + + for (i = 0; i< 16; i++) { + fpu.fprs[i] = env->fregs[i].ll; + }Quoted 8 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+ fpu.fpc = env->fpc; + + r = kvm_vcpu_ioctl(env, KVM_SET_FPU,&fpu); + assert(r == 0); + + return 0; +}The kvm register sync needs to happen in the kvm register sync function :)
That would eliminate the whole purpose of sync regs and forces us to have an expensive ioctl on lots of exits (again). I would prefer to sync the registers that we never need in qemu just here.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
That's why the register sync has different stages.
Not the
get_register. Which is called on everysynchronize_state. Which happen quite often on s390.Sounds like bad design then :).
Maybe we should explicitly tell the register synchronization which register sets to sync, so that we don't waste time getting _all_ the state every time we sync registers?
Yes, a level statement for
kvm_arch_get_registerswould be good.
Quoted 8 lines
Quoted 3 lines
The challenge is defining those levels generically - as it is also generic code that calls
cpu_synchronize_state. What levels do you have in mind? And where would they be applied?I think that
RUNTIME_STATEandFULL_STATEwould be sufficient for the needs that I have. The registers that I need during runtime can be accessed quite fast, but for life migration I also need those registers that are accessed viaONE_REGor other ioctls.
OK, if all existing synchronization points remain FULL_STATE and only s390-specific points become RUNTIME_STATE, I'm fine with it. Other archs could then do their optimizations as the like (and actually need) to.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux
PATCH 2/3 s390/migration: Qemu S390 special register migration
In reply to Christian BorntraegerFrom: "Jason J. herne" <[email protected]>
Use the KVM ONE_REG capability to save and restore the following special S390 cpu registers: clock comparator, tod clock programmable register and the cpu timer. Save/loading of these registers is required to enable guest migration on the S390 platform.
--- target-s390x/cpu.h | 4 ++++ target-s390x/machine.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
target-s390x/cpu.h +4 -0
@@ -92,6 +92,10 @@ typedef struct CPUS390XState {int ext_index; +uint64_t ckc; +uint64_t cputm; +uint32_t todpr; +CPU_COMMON /* reset does memset(0) up to here */
target-s390x/machine.c +41 -0
71 lines not on this page · raw message
Signature · 1 line
1.7.10.1
Re: [Qemu-devel] [PATCH 2/3] s390/migration: Qemu S390 special register migration
Quoted 52 lines · Christian Borntraeger
From: "Jason J. herne"<[email protected]>
Use the KVM
ONE_REGcapability to save and restore the following special S390 cpu registers: clock comparator, tod clock programmable register and the cpu timer. Save/loading of these registers is required to enable guest migration on the S390 platform.Signed-off-by Jason J. herne<[email protected]>Signed-off-by Christian Borntraeger<[email protected]>--- target-s390x/cpu.h | 4 ++++ target-s390x/machine.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)target-s390x/cpu.h +4
-0@@ -92,6 +92,10 @@ typedef struct CPUS390XState {int ext_index; +uint64_t ckc; +uint64_t cputm; +uint32_t todpr; +CPU_COMMON /* reset does memset(0) up to here */ target-s390x/machine.c +8
-0@@ -18,6 +18,7 @@ static void cpu_pre_save(void *opaque) {CPUS390XState *env = opaque;struct kvm_fpu fpu; +struct kvm_one_reg reg;int i, r;if (!kvm_enabled ()) {@@ -30,12 +31,31 @@ static void cpu_pre_save(void *opaque) env->fregs[i].ll = fpu.fprs[i]; } env->fpc = fpu.fpc; + +/* Retreive cpu timer value from kvm */ + reg.id =KVM_REG_S390_CPU_TIMER ; + reg.addr = (__u64)&(env->cputm); + r =kvm_vcpu_ioctl (env,KVM_GET_ONE_REG ,®); +assert (r ==0 ); +
target-s390x/machine.c static void cpu_pre_save(void *opaque) · line 50
Quoted 10 lines
target-s390x/machine.c +10
-0+/* Retreive clock comparator value from kvm */ + reg.id =KVM_REG_S390_CLOCK_COMP ; + reg.addr = (__u64)&(env->ckc); + r =kvm_vcpu_ioctl (env,KVM_GET_ONE_REG ,®); +assert (r ==0 ); + +/* Retreive clock comparator value from kvm */ + reg.id =KVM_REG_S390_TODPR ; + reg.addr = (__u64)&(env->todpr); + r =kvm_vcpu_ioctl (env,KVM_GET_ONE_REG ,®);
Same here. There must not be any KVM specific code in the save/restore path.
Alex
Quoted 46 lines
target-s390x/machine.c +23
-0+assert (r ==0 ); }static int cpu_post_load (void *opaque,int version_id) {CPUS390XState *env = opaque;struct kvm_fpu fpu; +struct kvm_one_reg reg;int i, r;if (!kvm_enabled ()) {@@ -50,6 +70,24 @@ static int cpu_post_load(void *opaque, int version_id) r =kvm_vcpu_ioctl (env,KVM_SET_FPU ,&fpu);assert (r ==0 ); +/* Tell KVM what the new cpu timer value is */ + reg.id =KVM_REG_S390_CPU_TIMER ; + reg.addr = (__u64)&(env->cputm); + r =kvm_vcpu_ioctl (env,KVM_SET_ONE_REG ,®); +assert (r ==0 ); + +/* Tell KVM what the new clock comparator value is */ + reg.id =KVM_REG_S390_CLOCK_COMP ; + reg.addr = (__u64)&(env->ckc); + r =kvm_vcpu_ioctl (env,KVM_SET_ONE_REG ,®); +assert (r ==0 ); + +/* Tell KVM what the new todpr value is */ + reg.id =KVM_REG_S390_TODPR ; + reg.addr = (__u64)&(env->todpr); + r =kvm_vcpu_ioctl (env,KVM_SET_ONE_REG ,®); +assert (r ==0 ); + return 0; }#else @@ -93,6 +131,9 @@ static const VMStateDescription vmstate_cpu = {VMSTATE_UINT64 (psw.addr, CPUS390XState),VMSTATE_UINT64 (psa, CPUS390XState),VMSTATE_UINT32 (fpc, CPUS390XState), +VMSTATE_UINT32 (todpr, CPUS390XState), +VMSTATE_UINT64 (cputm, CPUS390XState), +VMSTATE_UINT64 (ckc, CPUS390XState),VMSTATE_UINT32_ARRAY (aregs, CPUS390XState,16 ),VMSTATE_UINT64_ARRAY (cregs, CPUS390XState,16 ),VMSTATE_END_OF_LIST ()
PATCH 3/3 s390/migration: Add code to support SCLP live migration
In reply to Christian BorntraegerFrom: Heinz Graalfs <[email protected]>
This patch adds the necessary life migration pieces to the sclp code.
--- hw/s390x/event-facility.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/event-facility.h | 3 +++ hw/s390x/sclpconsole.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/sclpquiesce.c | 18 ++++++++++++++++++ 4 files changed, 113 insertions(+)
hw/s390x/event-facility.c +46 -0
@@ -312,6 +312,49 @@ static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t code) } } +static void event_facility_save (QEMUFile *f,void *opaque) +{ +S390SCLPDevice *sdev = opaque; +BusChild *kid; +SCLPEvent *event; +SCLPEventClass *event_class; + +qemu_put_be32 (f, sdev->ef->receive_mask); + + QTAILQ_FOREACH(kid, &sdev->ef->sbus.qbus.children, sibling) { +DeviceState *qdev = kid->child; + event =DO_UPCAST (SCLPEvent, qdev, qdev); + event_class =SCLP_EVENT_GET_CLASS (event); +if (event_class->save) { + event_class->save (f, event); + } + } +} + +static int event_facility_load (QEMUFile *f,void *opaque,int version_id) +{ +S390SCLPDevice *sdev = opaque; +int rc =0 ; +BusChild *kid; +SCLPEvent *event; +SCLPEventClass *event_class; + + sdev->ef->receive_mask =qemu_get_be32 (f); + + QTAILQ_FOREACH(kid, &sdev->ef->sbus.qbus.children, sibling) { +DeviceState *qdev = kid->child; + event =DO_UPCAST (SCLPEvent, qdev, qdev); + event_class =SCLP_EVENT_GET_CLASS (event); +if (event_class->load) { + rc = event_class->load (f, event, version_id); +if (rc) { +break ; + } + } + } +return rc; +} +static int init_event_facility (S390SCLPDevice *sdev) {SCLPEventFacility *event_facility;
@@ -334,6 +377,9 @@ static int init_event_facility(S390SCLPDevice *sdev) }qdev_init_nofail (quiesce); +register_savevm (&sdev->busdev.qdev,"event-facility" ,-1 ,0 , + event_facility_save, event_facility_load, sdev); +return 0 ; }
hw/s390x/event-facility.h +3 -0
@@ -91,6 +91,9 @@ typedef struct SCLPEventClass {/* returns the supported event type */ int (*event_type)(void ); +/* live migration */ +int (*load)(QEMUFile *f,void *opaque,int version_id); + void (*save)(QEMUFile *f, void *opaque); } SCLPEventClass;#endif
hw/s390x/sclpconsole.c +46 -0
58 lines not on this page · raw message
hw/s390x/sclpquiesce.c +18 -0
@@ -65,6 +65,22 @@ static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,return 1 ; } +static void quiesce_save (QEMUFile *f,void *opaque) +{ +SCLPEvent *event = opaque; + +qemu_put_be16 (f, event->event_pending ?1 :0 ); +} + +static int quiesce_load (QEMUFile *f,void *opaque,int version_id) +{ +SCLPEvent *event = opaque; + + event->event_pending =qemu_get_be16 (f) ? true : false; + +return 0 ; +} +typedef struct QuiesceNotifier QuiesceNotifier ; static struct QuiesceNotifier {
@@ -105,6 +121,8 @@ static void quiesce_class_init(ObjectClass *klass, void *data) k->event_type = event_type; k->read_event_data = read_event_data; k->write_event_data =NULL ; + k->load = quiesce_load; + k->save = quiesce_save; }static TypeInfo sclp_quiesce_info = {
Signature · 1 line
1.7.10.1
Re: [Qemu-devel] [PATCH 3/3] s390/migration: Add code to support SCLP live migration
Quoted 3 lines · Christian Borntraeger
From: Heinz Graalfs<[email protected]>
This patch adds the necessary life migration pieces to the sclp code.
Juan, could you please review and note whether it's possible to use VMSTATE for this? :)
Alex
Quoted 188 lines
Signed-off-by Heinz Graalfs<[email protected]>Signed-off-by Christian Borntraeger<[email protected]>--- hw/s390x/event-facility.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/event-facility.h | 3 +++ hw/s390x/sclpconsole.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/sclpquiesce.c | 18 ++++++++++++++++++ 4 files changed, 113 insertions(+)hw/s390x/event-facility.c +46
-0@@ -312,6 +312,49 @@ static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t code) } } +static void event_facility_save (QEMUFile *f,void *opaque) +{ +S390SCLPDevice *sdev = opaque; +BusChild *kid; +SCLPEvent *event; +SCLPEventClass *event_class; + +qemu_put_be32 (f, sdev->ef->receive_mask); + + QTAILQ_FOREACH(kid,&sdev->ef->sbus.qbus.children, sibling) { +DeviceState *qdev = kid->child; + event =DO_UPCAST (SCLPEvent, qdev, qdev); + event_class =SCLP_EVENT_GET_CLASS (event); +if (event_class->save) { + event_class->save (f, event); + } + } +} + +static int event_facility_load (QEMUFile *f,void *opaque,int version_id) +{ +S390SCLPDevice *sdev = opaque; +int rc =0 ; +BusChild *kid; +SCLPEvent *event; +SCLPEventClass *event_class; + + sdev->ef->receive_mask =qemu_get_be32 (f); + + QTAILQ_FOREACH(kid,&sdev->ef->sbus.qbus.children, sibling) { +DeviceState *qdev = kid->child; + event =DO_UPCAST (SCLPEvent, qdev, qdev); + event_class =SCLP_EVENT_GET_CLASS (event); +if (event_class->load) { + rc = event_class->load (f, event, version_id); +if (rc) { +break ; + } + } + } +return rc; +} +static int init_event_facility (S390SCLPDevice *sdev) {SCLPEventFacility *event_facility;@@ -334,6 +377,9 @@ static int init_event_facility(S390SCLPDevice *sdev) }qdev_init_nofail (quiesce); +register_savevm (&sdev->busdev.qdev,"event-facility" ,-1 ,0 , + event_facility_save, event_facility_load, sdev); +return 0 ; }hw/s390x/event-facility.h +3
-0@@ -91,6 +91,9 @@ typedef struct SCLPEventClass {/* returns the supported event type */ int (*event_type)(void ); +/* live migration */ +int (*load)(QEMUFile *f,void *opaque,int version_id); + void (*save)(QEMUFile *f, void *opaque); } SCLPEventClass;#endif hw/s390x/sclpconsole.c +46
-0@@ -243,6 +243,50 @@ static void trigger_ascii_console_data(void *env, int n, int level)/* qemu object creation and initialization functions */ /* tell character layer our call-back functions */ + +static void console_save (QEMUFile *f,void *opaque) +{ +SCLPConsole *scon = opaque; + +if (!scon->iov) { +return ; + } + +qemu_put_be16 (f, scon->event.event_pending ?1 :0 ); +qemu_put_be32 (f, scon->iov_data_len); +qemu_put_be32 (f, scon->iov_sclp_rest); +qemu_put_be32 (f, scon->iov_sclp - scon->iov); +qemu_put_be32 (f, scon->iov_bs - scon->iov); +if (scon->event.event_pending) { +qemu_put_buffer (f, scon->iov,SIZE_BUFFER_VT220 ); + } +} + +static int console_load (QEMUFile *f,void *opaque,int version_id) +{ +SCLPConsole *scon = opaque; +int l; + +if (!scon->iov) { + scon->iov =g_malloc0 (SIZE_BUFFER_VT220 ); + } + + scon->event.event_pending =qemu_get_be16 (f) ? true : false; + scon->iov_data_len =qemu_get_be32 (f); + scon->iov_sclp_rest =qemu_get_be32 (f); + scon->iov_bs = scon->iov +qemu_get_be32 (f); + scon->iov_sclp = scon->iov +qemu_get_be32 (f); +if (scon->event.event_pending) { + l =qemu_get_buffer (f, scon->iov,SIZE_BUFFER_VT220 ); +if (l !=SIZE_BUFFER_VT220 ) { +error_report ("Failed to restore SCLP console buffer." ); +return -1 ; + } + } + +return 0 ; +} +static int console_init (SCLPEvent *event) {static bool console_available;@@ -288,6 +332,8 @@ static void console_class_init(ObjectClass *klass, void *data) ec->event_type = event_type; ec->read_event_data = read_event_data; ec->write_event_data = write_event_data; + ec->load = console_load; + ec->save = console_save; }static TypeInfo sclp_console_info = {hw/s390x/sclpquiesce.c +18
-0@@ -65,6 +65,22 @@ static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,return 1 ; } +static void quiesce_save (QEMUFile *f,void *opaque) +{ +SCLPEvent *event = opaque; + +qemu_put_be16 (f, event->event_pending ?1 :0 ); +} + +static int quiesce_load (QEMUFile *f,void *opaque,int version_id) +{ +SCLPEvent *event = opaque; + + event->event_pending =qemu_get_be16 (f) ? true : false; + +return 0 ; +} +typedef struct QuiesceNotifier QuiesceNotifier ; static struct QuiesceNotifier {@@ -105,6 +121,8 @@ static void quiesce_class_init(ObjectClass *klass, void *data) k->event_type = event_type; k->read_event_data = read_event_data; k->write_event_data =NULL ; + k->load = quiesce_load; + k->save = quiesce_save; }static TypeInfo sclp_quiesce_info = {