From patchwork Mon Jul 17 13:06:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107937 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495001qge; Mon, 17 Jul 2017 06:09:23 -0700 (PDT) X-Received: by 10.36.91.20 with SMTP id g20mr5676211itb.113.1500296963019; Mon, 17 Jul 2017 06:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296963; cv=none; d=google.com; s=arc-20160816; b=q0VUlI3kUql5NccX48yE9/JYJx2XvG/tFteoVp9sK2uHZQfD/RC6+LnK0i7XgCme7f 0mZ1meKAqOFIj8tZ/lKvM6iRIb3g6zQniAb6EcwR3aLT9dIum1BgfpQp8AtFhkXBvA2m AkGWcJsZPCdENfqDLhlm30S1ZB71YMKCgFt/0djq4prcdD09c82GHu7/zuMq1yhF+vqN BwO1UVVnOD2GbucRSLTZb8M768/80FG7CcBLHMe865GWL1rvXyLMKTsNJC+dbxBsF1Z+ RCJ4/tHrRW8DRwhh4tcBNQX2ZfAEqLYdf6idwanF8cQEyQMh9vfeZzFj9MZKHqw0qWoC zNvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=y50pSFgLghEJgiQ48wLZ2wTjoOUf4Z4edg2+h1CIhl8=; b=pmxx8MR6JJyyC+L42V1vSiltGeRB9RTPm5QeTc8NKROPhrg2BQPIKXYFXxtlrAa7YZ kxCOoRl2Z7wiPhNXziu13MkXmaMAYlpNv0xCaqVwItmZ+IR9T8sKclBGg+swyC10nsh4 r+tUIvzj6fICGFe1c6HolXd/zy3IANAYhx0C08xLbXLcYlHcM3qPDzF38vc554PRoH3u S/Im77qwijT6u7wTMqJwaPa6MIjlm0O+9f4x+LoubpQzkJ38aCt6PZjBx5pqYt3aIEoF bQMlNVhTpVJpWFHx7eQgVxM2uNr3Oprjw9i38+j1Oy7JnGtS4Bqrmr0sybBMhZmPIU6g 2B1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=a2+XmI5J; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l20si16354875ioe.171.2017.07.17.06.09.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:23 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=a2+XmI5J; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kS-0004QO-Al; Mon, 17 Jul 2017 13:07:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kQ-0004Ox-Su for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:38 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 62/D5-27137-A96BC695; Mon, 17 Jul 2017 13:07:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRusoztzW06 kwapDYhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aHbQ/ZCtrEKxYumMnSwLhYuIuRi0NIYDqj xKQ3ZxhBHBaBecwS3S1nwRwJgX5WiSs7rrB3MXICOWkS2/YsYoSwKyR2nmsEiwsJaEkcPTWbF WJUK5PE3rmzgBwODjYBE4lZHRIgNSICShL3Vk1mAqlhFpjPKNE0qZcNJCEsECGxvmkT2FAWAV WJpYf+s4DYvAI+Eqf79kAtk5O4ea6TGcTmBIqf2bCaCWKxt8TNIxOZJjAKLGBkWMWoUZxaVJZ apGtkqJdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERhcDECwg/HPsoBDjJIcTEqi vBfZsiOF+JLyUyozEosz4otKc1KLDzHKcHAoSfC6b82JFBIsSk1PrUjLzAGGOUxagoNHSYS3G iTNW1yQmFucmQ6ROsVozDHpwPYvTByvJvz/xiTEkpeflyolzqsHUioAUppRmgc3CBZ/lxhlpY R5GYFOE+IpSC3KzSxBlX/FKM7BqCTMuxxkCk9mXgncvldApzABnSLsC3ZKSSJCSqqB0UXihfe +UwfP7i86GJSk/au6V+mQu3H16sdxs/e6F0Wa6D/70XWJ22xPpmldTXNnVMd/gUk1U9buCC9/ 8m39//jlkzw2vle6d+JsH2/Yn4hWyf74rL9qx3fpJk3IErTOOFF80+h/fhlDhQe7aMuPtXObC xlNI4Tv/Mv02HLrfdCuLUJXDwSlKLEUZyQaajEXFScCAADrWFS6AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1500296856!107623548!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30171 invoked from network); 17 Jul 2017 13:07:37 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:37 -0000 Received: by mail-pg0-f44.google.com with SMTP id 123so6568556pgj.1 for ; Mon, 17 Jul 2017 06:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6B3hwzMdVFS42UPpfp85EMbOcIpuHsakwVd0ckhk56Q=; b=a2+XmI5J+Ak/a3O+OYPAb9xg+BGxKhMVcNvNMzZO2HBLhFE4xiEYj1oaOvuz9cQSnE cd4Qh8u45U/hwG65gGq0+YfpA/0zcFxY7FXq1oDblR6CR7/qvN++Dj7LKa0a2s3nYWM/ Zi7z3O89Npu9ZqDHmq4osMmzIbzoQQvObr2WA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6B3hwzMdVFS42UPpfp85EMbOcIpuHsakwVd0ckhk56Q=; b=SL7MZXG8CSyuXWt0f6uLaGMw7SjS1c/O+Kg2zawIZWrs8edn5UiasoTpP+kYOtLdV3 veJqIzNRMNFDrls3wDTkbEjSyp6LgWcbd/otVs4ZIta2j2EXyvVgIMYxb6FBEPLyUb8E r4+1xiPQB+N8gmBRWnCfja5KeMh9NehMBNbudhOM7mtvxOuoYFhxFZ+5jy24zHBMgvl1 bQ9igR3fyrlcif/dGyLmqsDBLMv7RJDrGDKaWlfYipAkAZCj1au+7sQv+UZTlfo8dOTV piBAoXi8ghdX5j8CaMg9lYiEYfhauv1gdncExKBQTHJDT7kIJf+bnRjJDErY6YJiWBdq 7A0Q== X-Gm-Message-State: AIVw110DIt6NeeAAVEUCj87/5fgxFmFsmios6wM5plLu+hMpTMEL46x2 7RmGY0rHtsMdRq1Qeo64xQ== X-Received: by 10.99.177.6 with SMTP id r6mr18880492pgf.106.1500296855756; Mon, 17 Jul 2017 06:07:35 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:35 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:41 +0530 Message-Id: <1500296815-10243-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/25 v6] xen/arm: vpl011: Add a new console_init function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This patch introduces a new console_init function. This function initializes the console structure. Signed-off-by: Bhupinder Thakur --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 64 +++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..9e92097 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -655,13 +655,10 @@ static bool watch_domain(struct domain *dom, bool watch) return success; } - -static struct domain *create_domain(int domid) +static int console_init(struct console *con, struct domain *dom) { - struct domain *dom; char *s; struct timespec ts; - struct console *con; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", @@ -669,6 +666,41 @@ static struct domain *create_domain(int domid) return NULL; } + con->master_fd = -1; + con->master_pollfd_idx = -1; + con->slave_fd = -1; + con->log_fd = -1; + con->ring_ref = -1; + con->local_port = -1; + con->remote_port = -1; + con->xce_pollfd_idx = -1; + con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; + con->d = dom; + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + + strlen("/console") + 1); + if (s) + { + con->xspath = s; + strcat(con->xspath, "/console"); + err = 0; + } + + return err; +} + +static void console_free(struct console *con) +{ + if (con->xspath) + free(con->xspath); +} + +static struct domain *create_domain(int domid) +{ + struct domain *dom; + char *s; + struct console *con; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -677,28 +709,10 @@ static struct domain *create_domain(int domid) } dom->domid = domid; - con = &dom->console; - con->xspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->xspath, strlen(con->xspath) + - strlen("/console") + 1); - if (s == NULL) - goto out; - con->xspath = s; - strcat(con->xspath, "/console"); - con->master_fd = -1; - con->master_pollfd_idx = -1; - con->slave_fd = -1; - con->log_fd = -1; - con->xce_pollfd_idx = -1; - con->d = dom; - - con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; - - con->ring_ref = -1; - con->local_port = -1; - con->remote_port = -1; + if (console_init(con, dom)) + goto out; if (!watch_domain(dom, true)) goto out; @@ -710,7 +724,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_free(con); free(dom); return NULL; }