From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751401AbcGREip (ORCPT ); Mon, 18 Jul 2016 00:38:45 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:33512 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750786AbcGREim (ORCPT ); Mon, 18 Jul 2016 00:38:42 -0400 From: Namhyung Kim To: LKML Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , "Michael S. Tsirkin" , Anthony Liguori , Anton Vorontsov , Colin Cross , Kees Cook , Tony Luck , Steven Rostedt , Ingo Molnar , Minchan Kim , kvm@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org Subject: [RFC/PATCHSET 0/3] virtio-pstore: Implement virtio pstore device Date: Mon, 18 Jul 2016 13:37:38 +0900 Message-Id: <1468816661-6345-1-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This patchset is a proof of concept of virtio-pstore idea [1]. It has some rough edges and I'm not familiar with this area, so please give me feedbacks and advices if I'm going to a wrong direction. It started from the fact that dumping ftrace buffer at kernel oops/panic takes too much time. Although there's a way to reduce the size of the original data, sometimes I want to have the information as many as possible. Maybe kexec/kdump can solve this problem but it consumes some portion of guest memory so I'd like to avoid it. And I know the qemu + crashtool can dump and analyze the whole guest memory including the ftrace buffer without wasting guest memory, but it adds one more layer and has some limitation as an out-of-tree tool like not being in sync with the kernel changes. So I think it'd be great using the pstore interface to dump guest kernel data on the host. One can read the data on the host directly or on the guest (at the next boot) using pstore filesystem as usual. While this patchset only implements dumping kernel log buffer, it can be extended to have ftrace buffer and probably some more.. The patch 0001 implements virtio pstore driver. It has a single virt queue, pstore buffer and header structure. The virtio_pstore_hdr struct is to give information about the current pstore operation. The patch 0002 and 0003 implement virtio-pstore legacy PCI device on qemu-kvm and kvmtool respectively. I referenced virtio-baloon and virtio-rng implementations and I don't know whether kvmtool supports modern virtio 1.0+ spec. For example, using virtio-pstore on qemu looks like below: $ qemu-system-x86_64 -enable-kvm -device virtio-pstore,directory=xxx When guest kernel gets panic the log messages will be saved under the xxx directory. $ ls xxx dmesg-0.enc.z dmesg-1.enc.z As you can see the pstore subsystem compresses the log data using zlib. The data can be extracted with the following command: $ cat xxx/dmesg-0.enc.z | \ > python -c 'import sys, zlib; print(zlib.decompress(sys.stdin.read()))' Oops#1 Part1 <5>[ 0.000000] Linux version 4.6.0kvm+ (namhyung@danjae) (gcc version 5.3.0 (GCC) ) #145 SMP Mon Jul 18 10:22:45 KST 2016 <6>[ 0.000000] Command line: root=/dev/vda console=ttyS0 <6>[ 0.000000] x86/fpu: Legacy x87 FPU detected. <6>[ 0.000000] x86/fpu: Using 'eager' FPU context switches. <6>[ 0.000000] e820: BIOS-provided physical RAM map: <6>[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable <6>[ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved <6>[ 0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved <6>[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x0000000007fddfff] usable <6>[ 0.000000] BIOS-e820: [mem 0x0000000007fde000-0x0000000007ffffff] reserved <6>[ 0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved <6>[ 0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved <6>[ 0.000000] NX (Execute Disable) protection: active <6>[ 0.000000] SMBIOS 2.8 present. <7>[ 0.000000] DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014 ... Maybe we can add a config option to control the compression later. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: "Michael S. Tsirkin" Cc: Anthony Liguori Cc: Anton Vorontsov Cc: Colin Cross Cc: Kees Cook Cc: Tony Luck Cc: Steven Rostedt Cc: Ingo Molnar Cc: Minchan Kim Cc: kvm@vger.kernel.org Cc: qemu-devel@nongnu.org Cc: virtualization@lists.linux-foundation.org [1] https://lkml.org/lkml/2016/7/1/6 Thanks, Namhyung