From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHw1Q-0000hx-Rg for qemu-devel@nongnu.org; Fri, 06 Sep 2013 09:24:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHw1J-0000Yd-9i for qemu-devel@nongnu.org; Fri, 06 Sep 2013 09:24:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59259) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHw1J-0000YY-22 for qemu-devel@nongnu.org; Fri, 06 Sep 2013 09:24:17 -0400 Message-ID: <5229D77D.2000503@redhat.com> Date: Fri, 06 Sep 2013 15:24:13 +0200 From: Michal Novotny MIME-Version: 1.0 References: <5824aebefdadb9beb24cda3fab0398931bedbfb1.1378383549.git.minovotn@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vl.c: Implement SIGILL signal handler for triggering SIGSEGV List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel On 09/06/2013 12:50 AM, Anthony Liguori wrote: > On Thu, Sep 5, 2013 at 7:20 AM, Michal Novotny wrote: >> This is the patch to introduce SIGILL handler to be able to trigger >> SIGSEGV signal in qemu. This has been written to help debugging >> state when qemu crashes by SIGSEGV as a simple reproducer to >> emulate such situation in case of need. >> >> Signed-off-by: Michal Novotny >> --- >> vl.c | 24 ++++++++++++++++++++++++ >> 1 file changed, 24 insertions(+) >> >> diff --git a/vl.c b/vl.c >> index 7e04641..3966271 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -2897,6 +2897,26 @@ static int object_create(QemuOpts *opts, void *opaque) >> return 0; >> } >> >> +#ifdef CONFIG_POSIX >> +static void signal_handler(int signal) >> +{ >> + int *p = NULL; >> + >> + *p = 0xDEADBEEF; > I won't repeat the questions from Paolo and Lazlo (I share their > confusion) but will simply add that you cannot rely on NULL address > accessing causing a SEGV. Even with all the use of volatile in the > world, there's no guarantee this is going to crash. > > Regards, > > Anthony Liguori The idea was to trigger SIGSEGV (working at least at test conditions) to find out current qemu state. Of course, using gdb is also an option. Please ignore this patch, it was rather one purpose patch used in testing... Thanks, Michal > >> +} >> + >> +static void setup_signal_handlers(void) >> +{ >> + struct sigaction action; >> + >> + memset(&action, 0, sizeof(action)); >> + sigfillset(&action.sa_mask); >> + action.sa_handler = signal_handler; >> + action.sa_flags = 0; >> + sigaction(SIGILL, &action, NULL); >> +} >> +#endif >> + >> int main(int argc, char **argv, char **envp) >> { >> int i; >> @@ -2945,6 +2965,10 @@ int main(int argc, char **argv, char **envp) >> #endif >> } >> >> +#ifdef CONFIG_POSIX >> + setup_signal_handlers(); >> +#endif >> + >> module_call_init(MODULE_INIT_QOM); >> >> qemu_add_opts(&qemu_drive_opts); >> -- >> 1.7.11.7 >> -- Michal Novotny , RHCE, Red Hat Virtualization | libvirt-php bindings | php-virt-control.org