From patchwork Mon Aug 28 08:55:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111124 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548219qge; Mon, 28 Aug 2017 01:59:00 -0700 (PDT) X-Received: by 10.107.182.194 with SMTP id g185mr4929417iof.243.1503910740813; Mon, 28 Aug 2017 01:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910740; cv=none; d=google.com; s=arc-20160816; b=02DPPct1/ZFZQ4Qr/LusM+FX1JiRz4OdqvMPRntH9VHaFUY+hWfXpITUhhVh6mft3M NTyuaTiZ/D0D8kB2g0NMamOgY8ibPa1vHqDoaxVah4X2qAt6llCZ6YJ8D9xbPNvBzHUQ w0xNxcympVYH5O5My24hKAi7OmlcT5pFG4NhLmpbuRKv4SkmRinu7lD85fbB51VMzyeN PhDsA/P6VP+DEPNrCFAofJzSlEf63MM1qXG2MACfS7p4l4XWw63EYuGk04BG7U2KnO56 thw2PTe6lYVqBrvHVnDQ6IjM+hnjmzhAyVipI4vbSzZ84AWwngkhUSQCn/o9+cCFNKMr DaYw== 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=+uFY/pVc8SURBInWhEretAHlX4Js5xxDKWVSHnOsbQU=; b=r/8oQdbwNGu4Mlpt+xiU0u2hhiXiC39GEDkKlb3yPiGad4bDCLUDOCVDXdwiiFNXMK 3wd3mF6ztN8aut1PsN4URM9613mAEliqWG+RHABq4l/BKz0YQIx47mS69cvlkVFc+kh7 KtyxIGwmwoxbJoKT9X69MrDjF0BmivMStBWARnfOYbDrEWE2FJjOXZuUkK32AArhtR1C WCUyhe5r1k68Izy1F+ooB4To9VpTAgSAeMQe/PEC/JcP758q41lcEJKSnsZEF5V9/lha 7i60FrEEOBuFOABEPVwAiKOFrOe8eZe46SaxtIzRyFZCfRc9Q39Y6eHD7UCmfog1RZ0M 8uSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I8teHis6; 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 s40si11733507ioi.361.2017.08.28.01.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:59:00 -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.s=google header.b=I8teHis6; 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 1dmFqs-0004zj-ON; Mon, 28 Aug 2017 08:56:58 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqr-0004yp-Vl for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:56:58 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 0D/23-02176-9DAD3A95; Mon, 28 Aug 2017 08:56:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTAJt0btxZ HGsy9JGnxfctkJgdGj8MfrrAEMEaxZuYl5VcksGY8vLaeqaBBvGLH2vVsDYzThLsYuTiEBGYy SvTenc0O4rAIzGOWmLd3KUsXIyeHhEA/q0TL90wIO03iVm8LI4RdIbH660awGiEBLYmjp2azQ kzazySxbeMN5i5GDg42AROJWR0SIDUiAkoS91ZNZgKpYRaYzyjRNKmXDSQhLBAhMenlIWYQm0 VAVWLl+SfsIL28Aj4SC2cbQuySk7h5rhOshBMovGPtXXaIvd4SXa8/sE5gFFjAyLCKUb04tag stUjXRC+pKDM9oyQ3MTNH19DAWC83tbg4MT01JzGpWC85P3cTIzCsGIBgB2PjF6dDjJIcTEqi vDsrFkcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuANuQmUEyxKTU+tSMvMAQY4TFqCg0dJhHffD aA0b3FBYm5xZjpE6hSjMceVK+u+MHFMObD9C5MQS15+XqqUOO9FkFIBkNKM0jy4QbDIu8QoKy XMywh0mhBPQWpRbmYJqvwrRnEORiVhXm+Qe3gy80rg9r0COoUJ6BRFwYUgp5QkIqSkGhg5S9+ +D+FZN/m50fGLx3jZ3SbVrmK/6VFVfaznU+ubl5WvW6Q+qFydxFSx8b7+BIOPYWmf7K6uflNa cvHq9RtNgtVcbG5Wd3gmrwmeMmH1WrfGpSUPs3d96ku0FtZaE5K+/ij7h73Lk86bzMrS0F17e Vpqe5DX2ydTeY4slZmy+6m8Msdr5f1ZSizFGYmGWsxFxYkADUkvsrcCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1503910615!111979373!1 X-Originating-IP: [209.85.192.178] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62070 invoked from network); 28 Aug 2017 08:56:56 -0000 Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by server-8.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:56 -0000 Received: by mail-pf0-f178.google.com with SMTP id h75so14502296pfh.1 for ; Mon, 28 Aug 2017 01:56:56 -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=CK3WW8RxUoVEpZ5UMzdRikYESdsFXDtL/nQkFOdJcGQ=; b=I8teHis6t8b8nnFYDUXd4+EPpUpSiYD9/qM0OPTQVQq6PSsVQ3dy25m9C6hgfYPGYo y2t6W6ZC1rAp+ze8MeZgWUMOwRSAMCTslGy8V/UkMC+FO9UYO1S6OnG7w7bfQUbz5v9P 9vfY9MSLQiOaJcImZvggtlxxwEsLR8vDFQbZk= 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=CK3WW8RxUoVEpZ5UMzdRikYESdsFXDtL/nQkFOdJcGQ=; b=hDWlS+TWZB6WHpJTeFfg+Af2gRC1SvnWpZaJC7qzZd94h6srImF7+D0FiFVczj5wfn 3IQmCtO6fZDr0fSSQ94zhy6xS4eeMT2LdmAImtdwOuh0fmcrWFSWglVL1hsyfh8bcK3k WyRMxc1TMRvebosUfxOLmsN/WWsCATFitW5YRq8/frmoP5HjqAe9pGqfpj6iSSUM4Uyh EjETUILuAphCxKFuyEH/6AgO0nKWCyO5OMJ3A1pi0TY4f3p0X0oSgtYqNK8ow1IS8oVa W2Z49b1wlhvysZnxafW5cFsxyXBefdzPfB2Lo+js3flHzpOJgPIwr7V45SPDzDEXj9qt uQTw== X-Gm-Message-State: AHYfb5gSoGIFunVGy7nMQ6z0e8Zn5W3BZkW4WahqJWzC1j+BCSzHPhkb ogcXFfy3poUmHhui/aprmA== X-Received: by 10.84.132.76 with SMTP id 70mr7236165ple.291.1503910614742; Mon, 28 Aug 2017 01:56:54 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:54 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:54 +0530 Message-Id: <1503910570-24427-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/27 v8] 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 Acked-by: Wei Liu --- 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 | 65 ++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..1da08d7 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -655,20 +655,51 @@ 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; + int err = -1; 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", __FILE__, __FUNCTION__, __LINE__); - return NULL; + return err; } + 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; + struct console *con; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -677,28 +708,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 +723,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_free(con); free(dom); return NULL; }