From patchwork Wed Sep 27 06:13:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 114341 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4665506qgf; Tue, 26 Sep 2017 23:17:09 -0700 (PDT) X-Received: by 10.107.186.6 with SMTP id k6mr448988iof.183.1506493029666; Tue, 26 Sep 2017 23:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506493029; cv=none; d=google.com; s=arc-20160816; b=jJcqqA3Ur66clTd0QGybuBkweZxBSbhjwI6CO3uB9+qCY7UhhPGinZIM4WlgB1ubfg 2CJR/Fz86aX/FYjeUdxkVb13fiGIe+gxE+KU24wK9xwLG0le8cDuoqCHjrttCBpSrI7W 9TieakPLrPCddHIpdtLxFkYeRT+JP5zvyX8zHF3Uqdw6aLXfCZml+GN1KyTTzLdm2f1o 7oFLDbGPbvKzNgkAjJ+kB5curqiVa285WZ1Nzu3lXd/ezyK91HReZgh7Xo+FVOu+dmiT ZDcpWB+Mv6h2yTfGfevT0My7A9RFrCJQ+hGP/Hex79487CS4g7Ck9F+sFOxzVNQEtRKm MnIg== 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=WXsVKFtSEvooh/gQViJFmbABTRKBe0u52bhIWXyD934=; b=TpqbsOUVp21zKao0yObXP5IJxHKCkeE2iWuZCYrvkvtTBnVeo9Gk7VOkqtROCnWWUa nUHcjyMwWTod39CpfK8zM+Pv/F/fGCSzdKolkep7xk92wnVUMOttgezwPsvEcs9PjKIZ rbVyI1BHVKFsQW2lIsOX8V++umb/aBFbg7jOVMSCQkpt90lU4XisCGKWn2t73bqAb2fV WkEv+JuRNn4UBr5l0f40EgH/sxSTYVVc9MnAPXBbTUgoSBM9B+shi1xaZ2AjmvTWdKwX Rujx4nOyOO61BnQYkMvI/TroM4awnLSfXA8+oCTP4npSthHmfb8a7xq4ef11tskreAd7 z9+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hjbXyCzS; 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 u26si9178235ioi.29.2017.09.26.23.17.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Sep 2017 23:17:09 -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=hjbXyCzS; 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 1dx5bZ-0002bD-7t; Wed, 27 Sep 2017 06:13:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5bX-0002Xk-IK for xen-devel@lists.xenproject.org; Wed, 27 Sep 2017 06:13:55 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 43/E2-01916-2A14BC95; Wed, 27 Sep 2017 06:13:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsXiVRtsqrvQ8XS kwf/jNhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bDibPMBW89K7oO7WBsYPxr08XIxSEkMJ1R 4tOTXcwgDovAPGaJJ9v72UEcCYF+VokJWy+ydjFyAjl5EqfbD7BD2GkS0zdeAOrgALIrJJ6cE AQJCwloSRw9NZsVYuoKJokVp64xgdSwCZhIzOqQAKkREVCSuLdqMhNIDbPAfEaJpkm9bCAJYY Esif0v/jGB2CwCqhLf+hvA4rwCPhIPTn9ggdgrJ3HzXCcziM0JFD/df5sNYrG3xKWV/awTGAU XMDKsYtQoTi0qSy3SNbTUSyrKTM8oyU3MzNE1NDDWy00tLk5MT81JTCrWS87P3cQIDLl6BgbG HYy/j/sdYpTkYFIS5a35fypSiC8pP6UyI7E4I76oNCe1+BCjDAeHkgTvPIfTkUKCRanpqRVpm TnA4IdJS3DwKInwRoGkeYsLEnOLM9MhUqcYLTm+9N74w8Sxb88tINlx8+4fJiGWvPy8VClx3i qQBgGQhozSPLhxsAi9xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmYdyHIFJ7MvBK4ra+ADmI COqh36gmQg0oSEVJSDYy1nuvvfpv11ELMN8/h2fdzf1xDZqt9qr5oXGVePEM3Z8ECNbbc2Ztu RUf9L9TZfON7zSLNvVpxvyRe3pi34EPoqZL5KbxK795fLtj59ZracodZeZ/vNzzQ3pWiVPpO9 bKTan7a0n0fJZease8R4Po0/wKvb/P/Y3aP/JYeZWGrlRJbWSqnVrVAiaU4I9FQi7moOBEADQ FPAcsCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1506492832!116761331!1 X-Originating-IP: [74.125.83.53] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38896 invoked from network); 27 Sep 2017 06:13:53 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-8.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Sep 2017 06:13:53 -0000 Received: by mail-pg0-f53.google.com with SMTP id v23so7222457pgc.5 for ; Tue, 26 Sep 2017 23:13:53 -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=/c87JD9XyWkvHP2iWascyeQ5IUSzbfWQc11J8Ir9N+k=; b=hjbXyCzSSoam0ZYpCx4eFRK/Xz6t0SMoAGwyAKnMM/wdyz6jAKs6eCuVkr3oDAR4ye /cvfCsw+SQLh+x7aLYImfz/scQIhb6eGXHSLWg0mHnzFD/Eg7CrKiiRBcE4hKjzWCMQG b45nqo+6ilxyfiIqTXnQIGN4DaCytVq38ebXk= 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=/c87JD9XyWkvHP2iWascyeQ5IUSzbfWQc11J8Ir9N+k=; b=fF3RKLuxp/ablPDSrPdBfCK1zW++LAPATV2Ee5XqYOQ0JGX64Tb/Z8mJnSJPKhxy0Q IKQtloXG4OyDPR1/m1UZf4nEnTCVtSBBmszGYVOeCorImvy7Q6RnYP5DzztRRQDzUoIG 09eTXNWHCp/p/gg5tNFEl00WIFvakeKWFe1+j2N6fe9qhFCje4g4iByx8yrGdFnJiWPw uvEX+nHq4IPqvKydh77ZSb1FNJKd3ML4xb8P3heCZYBA4RUZemHHE6AZuyIyXLDNF15F Z7ikxRNoGHDUHPdpB1q5irCq+euPiLwntAILKtYXQWpHd0/ozAsASj0TD0bddWLoGjer tm4w== X-Gm-Message-State: AHPjjUgbYeBv9PlE9L/ZCrgOJGKe/NtvI+puDb09o2xebt0vpGQ/AO1N XAkNRvE6v7Cw/+sYsmPnOHAQLDHAyR0= X-Google-Smtp-Source: AOwi7QC1KdjffUPy/2oGhLGZu3B+Tf5uQKuiudvd6yX4g2Rftt/njVPv1ltciehHP87+CvikkudUeQ== X-Received: by 10.98.68.206 with SMTP id m75mr333721pfi.163.1506492832102; Tue, 26 Sep 2017 23:13:52 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id s187sm18013485pgb.82.2017.09.26.23.13.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 23:13:51 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 27 Sep 2017 11:43:19 +0530 Message-Id: <1506492816-25954-11-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 10/27 v11] xen/arm: vpl011: Modify xenconsole functions to take console structure as input 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" Xenconsole functions take domain structure as input. These functions shall be modified to take console structure as input since these functions typically perform console specific operations. Also the console specific functions starting with prefix "domain_" shall be modified to "console_" to indicate that these are console specific functions. This patch is in preparation to support multiple consoles to support vuart console. Signed-off-by: Bhupinder Thakur Acked-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v3: - The changes in xenconsole have been split into multiple patches. This is the second patch. tools/console/daemon/io.c | 79 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 6f5c69c..a2a3496 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,10 +163,10 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } -static void buffer_append(struct domain *dom) +static void buffer_append(struct console *con) { - struct console *con = &dom->console; struct buffer *buffer = &con->buffer; + struct domain *dom = con->d; XENCONS_RING_IDX cons, prod, size; struct xencons_interface *intf = con->interface; @@ -296,12 +296,13 @@ static int create_hv_log(void) return fd; } -static int create_domain_log(struct domain *dom) +static int create_console_log(struct console *con) { char logfile[PATH_MAX]; char *namepath, *data, *s; int fd; unsigned int len; + struct domain *dom = con->d; namepath = xs_get_domain_path(xs, dom->domid); s = realloc(namepath, strlen(namepath) + 6); @@ -342,10 +343,8 @@ static int create_domain_log(struct domain *dom) return fd; } -static void domain_close_tty(struct domain *dom) +static void console_close_tty(struct console *con) { - struct console *con = &dom->console; - if (con->master_fd != -1) { close(con->master_fd); con->master_fd = -1; @@ -417,7 +416,7 @@ void cfmakeraw(struct termios *termios_p) } #endif /* __sun__ */ -static int domain_create_tty(struct domain *dom) +static int console_create_tty(struct console *con) { const char *slave; char *path; @@ -426,7 +425,7 @@ static int domain_create_tty(struct domain *dom) char *data; unsigned int len; struct termios term; - struct console *con = &dom->console; + struct domain *dom = con->d; assert(con->slave_fd == -1); assert(con->master_fd == -1); @@ -487,7 +486,7 @@ static int domain_create_tty(struct domain *dom) return 1; out: - domain_close_tty(dom); + console_close_tty(con); return 0; } @@ -526,10 +525,8 @@ static int xs_gather(struct xs_handle *xs, const char *dir, ...) return ret; } -static void domain_unmap_interface(struct domain *dom) +static void console_unmap_interface(struct console *con) { - struct console *con = &dom->console; - if (con->interface == NULL) return; if (xgt_handle && con->ring_ref == -1) @@ -540,11 +537,11 @@ static void domain_unmap_interface(struct domain *dom) con->ring_ref = -1; } -static int domain_create_ring(struct domain *dom) +static int console_create_ring(struct console *con) { int err, remote_port, ring_ref, rc; char *type, path[PATH_MAX]; - struct console *con = &dom->console; + struct domain *dom = con->d; err = xs_gather(xs, con->xspath, "ring-ref", "%u", &ring_ref, @@ -563,7 +560,7 @@ static int domain_create_ring(struct domain *dom) /* If using ring_ref and it has changed, remap */ if (ring_ref != con->ring_ref && con->ring_ref != -1) - domain_unmap_interface(dom); + console_unmap_interface(con); if (!con->interface && xgt_handle) { /* Prefer using grant table */ @@ -621,7 +618,7 @@ static int domain_create_ring(struct domain *dom) con->remote_port = remote_port; if (con->master_fd == -1) { - if (!domain_create_tty(dom)) { + if (!console_create_tty(con)) { err = errno; xenevtchn_close(con->xce_handle); con->xce_handle = NULL; @@ -632,7 +629,7 @@ static int domain_create_ring(struct domain *dom) } if (log_guest && (con->log_fd == -1)) - con->log_fd = create_domain_log(dom); + con->log_fd = create_console_log(con); out: return err; @@ -648,7 +645,7 @@ static bool watch_domain(struct domain *dom, bool watch) if (watch) { success = xs_watch(xs, con->xspath, domid_str); if (success) - domain_create_ring(dom); + console_create_ring(con); else xs_unwatch(xs, con->xspath, domid_str); } else { @@ -695,6 +692,7 @@ static struct domain *create_domain(int domid) 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; @@ -746,7 +744,7 @@ static void cleanup_domain(struct domain *d) { struct console *con = &d->console; - domain_close_tty(d); + console_close_tty(con); if (con->log_fd != -1) { close(con->log_fd); @@ -768,7 +766,7 @@ static void shutdown_domain(struct domain *d) d->is_dead = true; watch_domain(d, false); - domain_unmap_interface(d); + console_unmap_interface(con); if (con->xce_handle != NULL) xenevtchn_close(con->xce_handle); con->xce_handle = NULL; @@ -799,9 +797,8 @@ static void enum_domains(void) } } -static int ring_free_bytes(struct domain *dom) +static int ring_free_bytes(struct console *con) { - struct console *con = &dom->console; struct xencons_interface *intf = con->interface; XENCONS_RING_IDX cons, prod, space; @@ -816,30 +813,30 @@ static int ring_free_bytes(struct domain *dom) return (sizeof(intf->in) - space); } -static void domain_handle_broken_tty(struct domain *dom, int recreate) +static void console_handle_broken_tty(struct console *con, int recreate) { - domain_close_tty(dom); + console_close_tty(con); if (recreate) { - domain_create_tty(dom); + console_create_tty(con); } else { - shutdown_domain(dom); + shutdown_domain(con->d); } } -static void handle_tty_read(struct domain *dom) +static void handle_tty_read(struct console *con) { ssize_t len = 0; char msg[80]; int i; - struct console *con = &dom->console; struct xencons_interface *intf = con->interface; + struct domain *dom = con->d; XENCONS_RING_IDX prod; if (dom->is_dead) return; - len = ring_free_bytes(dom); + len = ring_free_bytes(con); if (len == 0) return; @@ -853,7 +850,7 @@ static void handle_tty_read(struct domain *dom) * keep the slave open for the duration. */ if (len < 0) { - domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); + console_handle_broken_tty(con, domain_is_valid(dom->domid)); } else if (domain_is_valid(dom->domid)) { prod = intf->in_prod; for (i = 0; i < len; i++) { @@ -864,15 +861,15 @@ static void handle_tty_read(struct domain *dom) intf->in_prod = prod; xenevtchn_notify(con->xce_handle, con->local_port); } else { - domain_close_tty(dom); + console_close_tty(con); shutdown_domain(dom); } } -static void handle_tty_write(struct domain *dom) +static void handle_tty_write(struct console *con) { ssize_t len; - struct console *con = &dom->console; + struct domain *dom = con->d; if (dom->is_dead) return; @@ -882,7 +879,7 @@ static void handle_tty_write(struct domain *dom) if (len < 1) { dolog(LOG_DEBUG, "Write failed on domain %d: %zd, %d\n", dom->domid, len, errno); - domain_handle_broken_tty(dom, domain_is_valid(dom->domid)); + console_handle_broken_tty(con, domain_is_valid(dom->domid)); } else { buffer_advance(&con->buffer, len); } @@ -901,7 +898,7 @@ static void handle_ring_read(struct domain *dom) con->event_count++; - buffer_append(dom); + buffer_append(con); if (con->event_count < RATE_LIMIT_ALLOWANCE) (void)xenevtchn_unmask(con->xce_handle, port); @@ -925,7 +922,7 @@ static void handle_xs(void) /* We may get watches firing for domains that have recently been removed, so dom may be NULL here. */ if (dom && dom->is_dead == false) - domain_create_ring(dom); + console_create_ring(&dom->console); } free(vec); @@ -975,7 +972,7 @@ static void handle_log_reload(void) if (con->log_fd != -1) close(con->log_fd); - con->log_fd = create_domain_log(d); + con->log_fd = create_console_log(con); } } @@ -1121,7 +1118,7 @@ void handle_io(void) if (con->master_fd != -1) { short events = 0; - if (!d->is_dead && ring_free_bytes(d)) + if (!d->is_dead && ring_free_bytes(con)) events |= POLLIN; if (!buffer_empty(&con->buffer)) @@ -1208,15 +1205,15 @@ void handle_io(void) if (con->master_fd != -1 && con->master_pollfd_idx != -1) { if (fds[con->master_pollfd_idx].revents & ~(POLLIN|POLLOUT|POLLPRI)) - domain_handle_broken_tty(d, + console_handle_broken_tty(con, domain_is_valid(d->domid)); else { if (fds[con->master_pollfd_idx].revents & POLLIN) - handle_tty_read(d); + handle_tty_read(con); if (fds[con->master_pollfd_idx].revents & POLLOUT) - handle_tty_write(d); + handle_tty_write(con); } }