From patchwork Wed May 11 16:10:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 776732 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4BGBfH2009086 for ; Wed, 11 May 2011 16:11:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757182Ab1EKQK7 (ORCPT ); Wed, 11 May 2011 12:10:59 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:46051 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757177Ab1EKQK5 (ORCPT ); Wed, 11 May 2011 12:10:57 -0400 Received: by eyx24 with SMTP id 24so186079eyx.19 for ; Wed, 11 May 2011 09:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=oww7zLYQ1ykDCyT0qwY0IPP2/Dcr0PnHAJoXdoTTXLc=; b=qeveBMCsiBwK0QU5X1Y5QkhEwrPfqGcVE/o2w9apfbofozZaotMSKws3wuagLpJYoa gVvjtytBqAok/6/pnDD51DF+X38IqUAL/t8vxgZnwrjy98hBAaqdUEtKHliV+agXCk48 1LcoWi1JRv8O3Qqjkzd27FbhcFlBCQSbjC9ok= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=lafGNOBBwoLLmjBrF11gv2t9iIq5R3kYV/EVrD6/MFFWVrCs8mIL6+V/5zDXCzlzNv C8adokgKwRWw9fb/67KstTc1rbl3uTjloIXKh5z1c+eKFII66HZ4kukF7osBU9DxgtwU l+O4Z1MYEW9xA3mn9ZrQY5ZWAidH1we6tEobQ= Received: by 10.213.34.193 with SMTP id m1mr3208926ebd.6.1305130255832; Wed, 11 May 2011 09:10:55 -0700 (PDT) Received: from [10.10.0.150] (95-26-151-125.broadband.corbina.ru [95.26.151.125]) by mx.google.com with ESMTPS id y2sm54228eeh.11.2011.05.11.09.10.52 (version=SSLv3 cipher=OTHER); Wed, 11 May 2011 09:10:53 -0700 (PDT) Message-ID: <4DCAB50B.9030605@gmail.com> Date: Wed, 11 May 2011 20:10:51 +0400 From: Cyrill Gorcunov User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: Pekka Enberg CC: Ingo Molnar , Asias He , Sasha Levin , Prasad Joshi , kvm-vger Subject: [PATCH] kvm tools: Add debug() helper Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 11 May 2011 16:11:51 +0000 (UTC) Useful for debugging. It adds "--debug" option as well so debug prints are seen only if user asked for them. Signed-off-by: Cyrill Gorcunov --- No real users in code yet, the patches with debug() are in stage, posted out to not loose it. Thanks. tools/kvm/Documentation/kvm-run.txt | 3 +++ tools/kvm/include/kvm/util.h | 10 ++++++++++ tools/kvm/kvm-run.c | 4 ++++ 3 files changed, 17 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6.git/tools/kvm/Documentation/kvm-run.txt ===================================================================== --- linux-2.6.git.orig/tools/kvm/Documentation/kvm-run.txt +++ linux-2.6.git/tools/kvm/Documentation/kvm-run.txt @@ -55,6 +55,9 @@ OPTIONS --cpus:: The number of virtual CPUs to run. +--debug:: + Enable debug messages. + SEE ALSO -------- linkkvm: Index: linux-2.6.git/tools/kvm/include/kvm/util.h ===================================================================== --- linux-2.6.git.orig/tools/kvm/include/kvm/util.h +++ linux-2.6.git/tools/kvm/include/kvm/util.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,8 @@ #endif #endif +extern bool do_debug_print; + extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); extern void die_perror(const char *s) NORETURN; extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); @@ -36,6 +39,13 @@ extern void warning(const char *err, ... extern void info(const char *err, ...) __attribute__((format (printf, 1, 2))); extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN); +#define debug(fmt, ...) \ + do { \ + if (do_debug_print) \ + info("(%s) %s:%d: " fmt, __FILE__, \ + __func__, __LINE__, ##__VA_ARGS__); \ + } while (0) + #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) #define DIE_IF(cnd) \ Index: linux-2.6.git/tools/kvm/kvm-run.c ===================================================================== --- linux-2.6.git.orig/tools/kvm/kvm-run.c +++ linux-2.6.git/tools/kvm/kvm-run.c @@ -66,6 +66,8 @@ static bool virtio_rng; extern bool ioport_debug; extern int active_console; +bool do_debug_print = false; + static int nrcpus = 1; static const char * const run_usage[] = { @@ -126,6 +128,8 @@ static const struct option options[] = { "Enable single stepping"), OPT_BOOLEAN('g', "ioport-debug", &ioport_debug, "Enable ioport debugging"), + OPT_BOOLEAN('\0', "debug", &do_debug_print, + "Enable debug messages"), OPT_END() };