Hi Richard,
On 2019/3/12 22:59, Richard Henderson wrote:
On 3/12/19 12:57 AM, Heyi Guo wrote:
int kvm_arm_vcpu_init(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(cs);
struct kvm_vcpu_init init;
+ /*
+ * Only add change state handler for arch timer once, for KVM will help to
+ * synchronize virtual timer of all VCPUs.
+ */
+ static bool arch_timer_change_state_handler_added;
+
+
+ if (!arch_timer_change_state_handler_added) {
+ qemu_add_vm_change_state_handler(arch_timer_change_state_handler, cs);
+ arch_timer_change_state_handler_added = true;
+ }
Which means that this will not trigger for the second time that you pause the
vm. You need to key this off of something else, like cpu id 0.
I don't quite understand. Do you mean the handler will be deactivated after one
trigger? Or something else?
I suppose the state change handler will take effect for the whole VM life time,
so I believed one handler for one VM is enough, in whichever vCPU
initialization it is created. I also tested several times for one VM, and
fortunately the rough code worked.
Thanks,
Heyi
r~