From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111686 invoked by alias); 22 May 2018 15:07:23 -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 111661 invoked by uid 89); 22 May 2018 15:07:22 -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.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:U*mark, learn X-Spam-Status: No, score=-1.7 required=5.0 tests=AWL,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: spamtitan.xlab.si Received: from mx1.xlab.si (HELO spamtitan.xlab.si) (91.217.255.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 May 2018 15:07:16 +0000 X-Virus-Scanned: by SpamTitan at xlab.si Received: from jcpc.xlab.lan (5-255-217-91.xlab.si [91.217.255.5]) by zimbra.xlab.si (Postfix) with ESMTPSA id B584D5BB22AF; Tue, 22 May 2018 17:07:08 +0200 (CEST) Subject: Re: get backtrace of KVM VM from host To: Mark Wielaard , elfutils-devel@sourceware.org References: <9c68635a-3eac-cee5-d05f-dfc80bdaea2a@xlab.si> <1526997887.2911.10.camel@klomp.org> From: Justin Cinkelj Message-ID: <57cf8bac-adbc-d3d6-ec86-be5e03d82aac@xlab.si> Date: Tue, 22 May 2018 15:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1526997887.2911.10.camel@klomp.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00073.txt.bz2 Something like that was suggested at KVM devel list too. I was able to get an useful backtrace for a trivial VM (a single ELF file, VM code runs directly from (virtual) physical memory). Well, that was more to learn a bit about elfutils than anything else. A more realistic VM will be more difficult, I guess. Justin On 05/22/2018 04:04 PM, Mark Wielaard wrote: > 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 >> if I run './stack -p PID' (stack from elfutilfs >> https://sourceware.org/elfutils/), I get backtrace of some process. I >> would like to do the same for VM. I can assume VM will run only a kernel >> (a unikernel, like OSv or IncludeOS), so most/all debug symbols will be >> there in a single file, and at least IncludeOS doesnt load any code >> beside its own kernel. >> >> I did notice KVM_GET_REGS and KVM_SET_MEMORY_REGION, and at least for >>> trivial examples (like https://github.com/dpw/kvm-hello-world) this >> provides enough information to track which code was loaded into VM, >> observe current stack content and registers. I can only guess much more >> work is required to get similar result with qemu-kvm. Hence I'm asking >> 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