Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE406C2D0A8 for ; Wed, 23 Sep 2020 06:46:13 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A197E20739 for ; Wed, 23 Sep 2020 06:46:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="f/Ph/ufS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A197E20739 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKyXF-0001Wc-Lv; Wed, 23 Sep 2020 06:45:49 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKyXE-0001WR-ED for xen-devel@lists.xenproject.org; Wed, 23 Sep 2020 06:45:48 +0000 X-Inumbo-ID: 3fb7b2e5-4c87-41cf-ad32-591d896f3405 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 3fb7b2e5-4c87-41cf-ad32-591d896f3405; Wed, 23 Sep 2020 06:45:46 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1600843545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sv7P9R7t+6Lz9Xw4HtSzYW6xSNj+0ova4G9FBISr/CY=; b=f/Ph/ufSeI5JvN5e1GEKiiWK7l/HtEb3y6bhLFAZ6tl6zSERQTomGwgsTZmNgzUQj0J0gv oi4C6cMVe4ccIWPqiuyddA/HRj9ktVm3FRn/LXOTrmubd6ApNK15FOJV+6OSidhW5udMnw wq2RjPn/pGKvD0T0p7MQsubLBVGHJ7w= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6B2A1AE71; Wed, 23 Sep 2020 06:46:22 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH 1/3] tools/init-xenstore-domain: add logging Date: Wed, 23 Sep 2020 08:45:39 +0200 Message-Id: <20200923064541.19546-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200923064541.19546-1-jgross@suse.com> References: <20200923064541.19546-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add a possibility to do logging in init-xenstore-domain: use -v[...] for selecting the log-level as in xl, log to stderr. Signed-off-by: Juergen Gross --- tools/helpers/init-xenstore-domain.c | 51 ++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index 5bdb48dc80..22c4be6a3f 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ static struct option options[] = { { "param", 1, NULL, 'p' }, { "name", 1, NULL, 'n' }, { "maxmem", 1, NULL, 'M' }, + { "verbose", 0, NULL, 'v' }, { NULL, 0, NULL, 0 } }; @@ -57,7 +59,8 @@ static void usage(void) " --maxmem maximum memory size in the format:\n" " |/|:/\n" " (an absolute value in MB, a fraction a/b of\n" -" the host memory, or the maximum of both)\n"); +" the host memory, or the maximum of both)\n" +" -v[v[v]] verbosity of domain building\n"); } static int build(xc_interface *xch) @@ -349,8 +352,10 @@ int main(int argc, char** argv) char buf[16], be_path[64], fe_path[64]; int rv, fd; char *maxmem_str = NULL; + xentoollog_level minmsglevel = XTL_PROGRESS; + xentoollog_logger *logger = NULL; - while ( (opt = getopt_long(argc, argv, "", options, NULL)) != -1 ) + while ( (opt = getopt_long(argc, argv, "v", options, NULL)) != -1 ) { switch ( opt ) { @@ -375,6 +380,10 @@ int main(int argc, char** argv) case 'M': maxmem_str = optarg; break; + case 'v': + if ( minmsglevel ) + minmsglevel--; + break; default: usage(); return 2; @@ -387,11 +396,15 @@ int main(int argc, char** argv) return 2; } - xch = xc_interface_open(NULL, NULL, 0); + logger = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, + minmsglevel, 0); + + xch = xc_interface_open(logger, logger, 0); if ( !xch ) { fprintf(stderr, "xc_interface_open() failed\n"); - return 1; + rv = 1; + goto out; } if ( maxmem_str ) @@ -400,7 +413,8 @@ int main(int argc, char** argv) if ( maxmem < 0 ) { xc_interface_close(xch); - return 1; + rv = 1; + goto out; } } @@ -414,17 +428,24 @@ int main(int argc, char** argv) xc_interface_close(xch); if ( rv ) - return 1; + { + rv = 1; + goto out; + } rv = gen_stub_json_config(domid, NULL); if ( rv ) - return 3; + { + rv = 3; + goto out; + } xsh = xs_open(0); if ( !xsh ) { fprintf(stderr, "xs_open() failed.\n"); - return 3; + rv = 3; + goto out; } snprintf(buf, 16, "%d", domid); do_xs_write(xsh, "/tool/xenstored/domid", buf); @@ -460,7 +481,8 @@ int main(int argc, char** argv) if ( fd < 0 ) { fprintf(stderr, "Creating " XEN_RUN_DIR "/xenstored.pid failed\n"); - return 3; + rv = 3; + goto out; } rv = snprintf(buf, 16, "domid:%d\n", domid); rv = write(fd, buf, rv); @@ -469,10 +491,17 @@ int main(int argc, char** argv) { fprintf(stderr, "Writing domid to " XEN_RUN_DIR "/xenstored.pid failed\n"); - return 3; + rv = 3; + goto out; } - return 0; + rv = 0; + + out: + if ( logger ) + xtl_logger_destroy(logger); + + return rv; } /* -- 2.26.2