From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAJc7-0001VL-2g for qemu-devel@nongnu.org; Wed, 01 Jul 2015 11:07:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAJc4-0003JT-5j for qemu-devel@nongnu.org; Wed, 01 Jul 2015 11:07:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAJc3-0003JN-Uq for qemu-devel@nongnu.org; Wed, 01 Jul 2015 11:07:48 -0400 References: <1435664007-4965-1-git-send-email-den@openvz.org> <1435664007-4965-10-git-send-email-den@openvz.org> From: Paolo Bonzini Message-ID: <5594023F.70104@redhat.com> Date: Wed, 1 Jul 2015 17:07:43 +0200 MIME-Version: 1.0 In-Reply-To: <1435664007-4965-10-git-send-email-den@openvz.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 9/9] qemu/kvm: kvm hyper-v based guest crash event handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: Andrey Smetanin , qemu-devel@nongnu.org, kvm@vger.kernel.org, =?UTF-8?Q?Andreas_F=c3=a4rber?= On 30/06/2015 13:33, Denis V. Lunev wrote: >=20 > +static int kvm_arch_handle_hv_crash(CPUState *cs) > +{ > + X86CPU *cpu =3D X86_CPU(cs); > + CPUX86State *env =3D &cpu->env; > + > + /* Mark that Hyper-v guest crash occurred */ > + env->hv_crash_occurred =3D 1; This need not be a hv crash. You can add crash_occurred to CPUState directly, and set it in qemu_system_guest_panicked: if (current_cpu) { current_cpu->crash_occurred =3D true; } Then you would add two subsections: one for crash_occurred in exec.c (attached to vmstate_cpu_common), one for hyperv crash params in target-i386/machine.c. This also gives an idea about splitting the patch: first the introduction of qemu_system_guest_panicked and crash_occurred, second the Hyper-V specific bits. > + if (cpu->hyperv_crash) { > + c->edx |=3D HV_X64_GUEST_CRASH_MSR_AVAILABLE; > + has_msr_hv_crash =3D true; You can only set this to true if the kernel also supports the MSRs. > + } > + > c =3D &cpuid_data.entries[cpuid_i++]; > c->function =3D HYPERV_CPUID_ENLIGHTMENT_INFO; > if (cpu->hyperv_relaxed_timing) { > @@ -761,6 +767,10 @@ void kvm_arch_reset_vcpu(X86CPU *cpu) > } else { > env->mp_state =3D KVM_MP_STATE_RUNNABLE; > } > + if (has_msr_hv_crash) { > + env->msr_hv_crash_ctl =3D HV_X64_MSR_CRASH_CTL_NOTIFY; The value is always host-defined, so I think it doesn't need a field in CPUX86State. On the other hand, this: +static bool hyperv_crash_enable_needed(void *opaque) +{ + X86CPU *cpu =3D opaque; + CPUX86State *env =3D &cpu->env; + + return (env->msr_hv_crash_ctl & HV_X64_MSR_CRASH_CTL_CONTENTS) ? + true : false; +} + can just check if any of the params fields is nonzero. Thanks, Paolo > + env->hv_crash_occurred =3D 0; > + }