From patchwork Tue Jan 28 14:28:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11354397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAAF5924 for ; Tue, 28 Jan 2020 14:29:20 +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 CFF1124698 for ; Tue, 28 Jan 2020 14:29:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFF1124698 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none 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.89) (envelope-from ) id 1iwRqw-0002YX-4s; Tue, 28 Jan 2020 14:28:30 +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.89) (envelope-from ) id 1iwRqu-0002XK-3x for xen-devel@lists.xenproject.org; Tue, 28 Jan 2020 14:28:28 +0000 X-Inumbo-ID: 6f790e74-41da-11ea-86e0-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 6f790e74-41da-11ea-86e0-12813bfff9fa; Tue, 28 Jan 2020 14:28:22 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 714E2ACE3; Tue, 28 Jan 2020 14:28:21 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Tue, 28 Jan 2020 15:28:17 +0100 Message-Id: <20200128142818.27200-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200128142818.27200-1-jgross@suse.com> References: <20200128142818.27200-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 2/3] xenstore: add console xenstore entries for xenstore stubdom X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Ian Jackson , Wei Liu MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In order to be able to connect to the console of Xenstore stubdom we need to create the appropriate entries in Xenstore. For the moment we don't support xenconsoled living in another domain than dom0, as this information isn't available other then via Xenstore which we are just setting up. Signed-off-by: Juergen Gross Acked-by: Andrew Cooper --- tools/helpers/init-xenstore-domain.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index a312bc38b8..a81a15a4de 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "init-dom-json.h" #include "_paths.h" @@ -312,6 +313,15 @@ static void do_xs_write(struct xs_handle *xsh, char *path, char *val) fprintf(stderr, "writing %s to xenstore failed.\n", path); } +static void do_xs_write_dir_node(struct xs_handle *xsh, char *dir, char *node, + char *val) +{ + char full_path[100]; + + snprintf(full_path, 100, "%s/%s", dir, node); + do_xs_write(xsh, full_path, val); +} + static void do_xs_write_dom(struct xs_handle *xsh, char *path, char *val) { char full_path[64]; @@ -325,7 +335,7 @@ int main(int argc, char** argv) int opt; xc_interface *xch; struct xs_handle *xsh; - char buf[16]; + char buf[16], be_path[64], fe_path[64]; int rv, fd; char *maxmem_str = NULL; @@ -414,6 +424,25 @@ int main(int argc, char** argv) if (maxmem) snprintf(buf, 16, "%d", maxmem * 1024); do_xs_write_dom(xsh, "memory/static-max", buf); + snprintf(be_path, 64, "/local/domain/0/backend/console/%d/0", domid); + snprintf(fe_path, 64, "/local/domain/%d/console", domid); + snprintf(buf, 16, "%d", domid); + do_xs_write_dir_node(xsh, be_path, "frontend-id", buf); + do_xs_write_dir_node(xsh, be_path, "frontend", fe_path); + do_xs_write_dir_node(xsh, be_path, "online", "1"); + snprintf(buf, 16, "%d", XenbusStateInitialising); + do_xs_write_dir_node(xsh, be_path, "state", buf); + do_xs_write_dir_node(xsh, be_path, "protocol", "vt100"); + do_xs_write_dir_node(xsh, fe_path, "backend", be_path); + do_xs_write_dir_node(xsh, fe_path, "backend-id", "0"); + do_xs_write_dir_node(xsh, fe_path, "limit", "1048576"); + do_xs_write_dir_node(xsh, fe_path, "type", "xenconsoled"); + do_xs_write_dir_node(xsh, fe_path, "output", "pty"); + do_xs_write_dir_node(xsh, fe_path, "tty", ""); + snprintf(buf, 16, "%d", console_evtchn); + do_xs_write_dir_node(xsh, fe_path, "port", buf); + snprintf(buf, 16, "%ld", console_mfn); + do_xs_write_dir_node(xsh, fe_path, "ring-ref", buf); xs_close(xsh); fd = creat(XEN_RUN_DIR "/xenstored.pid", 0666);