From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129034 invoked by alias); 22 May 2018 14:05:01 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 128883 invoked by uid 89); 22 May 2018 14:04:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=So, more X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 May 2018 14:04:55 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id DF464300090A; Tue, 22 May 2018 16:04:52 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 96DD140011A2; Tue, 22 May 2018 16:04:47 +0200 (CEST) Message-ID: <1526997887.2911.10.camel@klomp.org> Subject: Re: get backtrace of KVM VM from host From: Mark Wielaard To: Justin Cinkelj , elfutils-devel@sourceware.org Date: Tue, 22 May 2018 14:05:00 -0000 In-Reply-To: <9c68635a-3eac-cee5-d05f-dfc80bdaea2a@xlab.si> References: <9c68635a-3eac-cee5-d05f-dfc80bdaea2a@xlab.si> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.22.6 (3.22.6-14.el7) Mime-Version: 1.0 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00072.txt.bz2 Hi, On Mon, 2018-05-21 at 10:26 +0200, Justin Cinkelj wrote: > Is it possible to get stack backtrace into KVM VM from the host side? > So=C2=A0 > if I run './stack -p PID' (stack from elfutilfs=C2=A0 > https://sourceware.org/elfutils/), I get backtrace of some process. I=C2= =A0 > would like to do the same for VM. I can assume VM will run only a kernel= =C2=A0 > (a unikernel, like OSv or IncludeOS), so most/all debug symbols will be= =C2=A0 > there in a single file, and at least IncludeOS doesnt load any code=C2=A0 > beside its own kernel. >=20 > I did notice KVM_GET_REGS and KVM_SET_MEMORY_REGION, and at least for=C2= =A0 > > trivial examples (like https://github.com/dpw/kvm-hello-world) this=C2= =A0 > provides enough information to track which code was loaded into VM,=C2=A0 > observe current stack content and registers. I can only guess much more= =C2=A0 > work is required to get similar result with qemu-kvm. Hence I'm asking=C2= =A0 > if this is already implemented. Providing the registers and memory view inside the KVM VM would be the first step. elfutils would also need to know the memory/ELF process layout. For a normal process that would come from e.g. /proc/pid/maps. Using such a layout eu-stack would then be able to find the unwind tables and symbols associated with a particular address. I believe qemu already has an gdb stub that gdb can use to get at the registers, memory and process layout. Maybe you could adapt that provide the information needed. Cheers, Mark