From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuO91-00049p-BB for qemu-devel@nongnu.org; Tue, 10 Jun 2014 11:39:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuO8u-00033Q-CW for qemu-devel@nongnu.org; Tue, 10 Jun 2014 11:39:27 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:55216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuO8u-00033C-6l for qemu-devel@nongnu.org; Tue, 10 Jun 2014 11:39:20 -0400 Received: by mail-pa0-f52.google.com with SMTP id eu11so816639pac.25 for ; Tue, 10 Jun 2014 08:39:18 -0700 (PDT) Message-ID: <539726A1.2090807@ozlabs.ru> Date: Wed, 11 Jun 2014 01:39:13 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <1402381083-17241-1-git-send-email-aik@ozlabs.ru> <1402381083-17241-2-git-send-email-aik@ozlabs.ru> <20140610134340.35a18fff.cornelia.huck@de.ibm.com> In-Reply-To: <20140610134340.35a18fff.cornelia.huck@de.ibm.com> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 1/4] cpus: Define callback for QEMU "nmi" command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck Cc: Peter Maydell , Paolo Bonzini , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Alexander Graf On 06/10/2014 09:43 PM, Cornelia Huck wrote: > On Tue, 10 Jun 2014 16:18:00 +1000 > Alexey Kardashevskiy wrote: > >> This introduces an NMI (Non Maskable Interrupt) nmi_monitor_handler() >> callback to the CPU class. It is called from QMP's "nmi" command and >> performs an action required to cause debug crash dump on in-kernel >> debugger invocation. The callback returns Error**. >> >> This adds support for it in qmp_inject_nmi(). Since no architecture >> supports it at the moment, there is no change in behaviour. >> >> This changes inject-nmi command description for HMP and QMP. >> >> Signed-off-by: Alexey Kardashevskiy >> --- >> Changes: >> v5: >> * s/given guest's (CPU|VCPU)/default CPU/ >> * nmi_monitor_handler() now returns Error** >> >> >> v4: >> * s/\/nmi_monitor_handler/ >> >> v3: >> * actual nmi() enablement moved from last patch to first patch >> * changed description for QMP command too >> --- >> cpus.c | 9 ++++++++- >> hmp-commands.hx | 6 ++---- >> include/qom/cpu.h | 1 + >> qapi-schema.json | 4 ++-- >> qmp-commands.hx | 3 +-- >> 5 files changed, 14 insertions(+), 9 deletions(-) >> >> diff --git a/cpus.c b/cpus.c >> index dd7ac13..b9d6602 100644 >> --- a/cpus.c >> +++ b/cpus.c >> @@ -1495,6 +1495,13 @@ void qmp_inject_nmi(Error **errp) >> } >> } >> #else >> - error_set(errp, QERR_UNSUPPORTED); >> + CPUState *cs = qemu_get_cpu(monitor_get_cpu_index()); >> + CPUClass *cc = CPU_GET_CLASS(cs); > > Just wondering: Is CPU_GET_CLASS(NULL) really safe? I expect it to assert so it is kind of safe. > >> + >> + if (cs && cc->nmi_monitor_handler) { > > Or is cs == NULL simply not possible, and the code should check for > cc != NULL here instead? This is definitely a mistype, I meant "if (cc &&...)" >> + cc->nmi_monitor_handler(cs, errp); >> + } else { >> + error_set(errp, QERR_UNSUPPORTED); >> + } >> #endif >> } > -- Alexey