From: Stefano Stabellini <sstabellini@kernel.org>
To: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Cc: xen-devel@lists.xenproject.org,
Julien Grall <julien.grall@arm.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH 09/14 v4] xen/arm: vpl011: Modify xenconsole functions to take console structure as input
Date: Tue, 6 Jun 2017 17:43:39 -0700 (PDT) [thread overview]
Message-ID: <alpine.DEB.2.10.1706061743130.15791@sstabellini-ThinkPad-X260> (raw)
In-Reply-To: <1496769929-23355-10-git-send-email-bhupinder.thakur@linaro.org>
On Tue, 6 Jun 2017, Bhupinder Thakur wrote:
> 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 <bhupinder.thakur@linaro.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
> ---
> CC: ij
> CC: wl
> CC: ss
> CC: jg
>
> Changes since v3:
> - The changes in xenconsole have been split into four patches. This is the second patch.
>
> tools/console/daemon/io.c | 82 +++++++++++++++++++++++------------------------
> 1 file changed, 41 insertions(+), 41 deletions(-)
>
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index 0402ddf..c5dd08d 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->conspath,
> "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(dom->xce_handle);
> dom->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->conspath, domid_str);
> if (success)
> - domain_create_ring(dom);
> + console_create_ring(con);
> else
> xs_unwatch(xs, con->conspath, domid_str);
> } else {
> @@ -694,6 +691,7 @@ static struct domain *create_domain(int domid)
> con->master_pollfd_idx = -1;
> con->slave_fd = -1;
> con->log_fd = -1;
> + con->d = dom;
> dom->xce_pollfd_idx = -1;
>
> dom->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);
> @@ -764,9 +762,11 @@ static void cleanup_domain(struct domain *d)
>
> static void shutdown_domain(struct domain *d)
> {
> + struct console *con = &d->console;
> +
> d->is_dead = true;
> watch_domain(d, false);
> - domain_unmap_interface(d);
> + console_unmap_interface(con);
> if (d->xce_handle != NULL)
> xenevtchn_close(d->xce_handle);
> d->xce_handle = NULL;
> @@ -797,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;
>
> @@ -814,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;
>
> @@ -851,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++) {
> @@ -862,15 +861,15 @@ static void handle_tty_read(struct domain *dom)
> intf->in_prod = prod;
> xenevtchn_notify(dom->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;
> @@ -880,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);
> }
> @@ -889,6 +888,7 @@ static void handle_tty_write(struct domain *dom)
> static void handle_ring_read(struct domain *dom)
> {
> xenevtchn_port_or_error_t port;
> + struct console *con = &dom->console;
>
> if (dom->is_dead)
> return;
> @@ -898,7 +898,7 @@ static void handle_ring_read(struct domain *dom)
>
> dom->event_count++;
>
> - buffer_append(dom);
> + buffer_append(con);
>
> if (dom->event_count < RATE_LIMIT_ALLOWANCE)
> (void)xenevtchn_unmask(dom->xce_handle, port);
> @@ -922,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);
> @@ -972,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);
> }
> }
>
> @@ -1118,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))
> @@ -1201,15 +1201,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);
> }
> }
>
> --
> 2.7.4
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-06-07 0:43 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-06 17:25 [PATCH 00/14 v4] PL011 emulation support in Xen Bhupinder Thakur
2017-06-06 17:25 ` [PATCH 01/14 v4] xen/arm: vpl011: Move vgic register access functions to vreg.h Bhupinder Thakur
2017-06-09 12:49 ` Julien Grall
2017-06-06 17:25 ` [PATCH 02/14 v4] xen/arm: vpl011: Define generic vreg_reg* access functions in vreg.h Bhupinder Thakur
2017-06-09 12:54 ` Julien Grall
2017-06-19 9:33 ` Andre Przywara
2017-06-19 16:53 ` Bhupinder Thakur
2017-06-19 16:59 ` Andre Przywara
2017-06-06 17:25 ` [PATCH 03/14 v4] xen/arm: vpl011: Add pl011 uart emulation in Xen Bhupinder Thakur
2017-06-06 23:02 ` Stefano Stabellini
2017-06-09 13:15 ` Julien Grall
2017-06-09 18:02 ` Stefano Stabellini
2017-06-13 8:58 ` Bhupinder Thakur
2017-06-13 9:25 ` Julien Grall
2017-06-09 13:54 ` Julien Grall
2017-06-13 10:57 ` Bhupinder Thakur
2017-06-13 12:44 ` Julien Grall
2017-06-13 17:50 ` Stefano Stabellini
2017-06-14 5:47 ` Bhupinder Thakur
2017-06-14 9:33 ` Julien Grall
2017-06-19 10:14 ` Andre Przywara
2017-06-22 5:16 ` Bhupinder Thakur
2017-06-23 12:45 ` Julien Grall
2017-06-06 17:25 ` [PATCH 04/14 v4] xen/arm: vpl011: Add support for vuart in libxl Bhupinder Thakur
2017-06-06 23:07 ` Stefano Stabellini
2017-06-06 17:25 ` [PATCH 05/14 v4] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart Bhupinder Thakur
2017-06-06 23:17 ` Stefano Stabellini
2017-06-07 16:43 ` Wei Liu
2017-06-06 17:25 ` [PATCH 06/14 v4] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
2017-06-06 23:26 ` Stefano Stabellini
2017-06-09 14:06 ` Julien Grall
2017-06-09 18:32 ` Stefano Stabellini
2017-06-14 7:35 ` Bhupinder Thakur
2017-06-14 8:34 ` Bhupinder Thakur
2017-06-09 14:13 ` Julien Grall
2017-06-14 9:16 ` Bhupinder Thakur
2017-06-14 10:15 ` Julien Grall
2017-06-15 6:33 ` Bhupinder Thakur
2017-06-19 10:59 ` Bhupinder Thakur
2017-06-19 11:01 ` Julien Grall
2017-06-19 11:47 ` Wei Liu
2017-06-19 13:11 ` Bhupinder Thakur
2017-06-20 11:16 ` Julien Grall
2017-06-20 11:42 ` Wei Liu
2017-06-21 10:18 ` Bhupinder Thakur
2017-06-06 17:25 ` [PATCH 07/14 v4] xen/arm: vpl011: Add a new vuart node in the xenstore Bhupinder Thakur
2017-06-06 23:38 ` Stefano Stabellini
2017-06-06 17:25 ` [PATCH 08/14 v4] xen/arm: vpl011: Modify xenconsole to define and use a new console structure Bhupinder Thakur
2017-06-07 1:13 ` Stefano Stabellini
2017-06-06 17:25 ` [PATCH 09/14 v4] xen/arm: vpl011: Modify xenconsole functions to take console structure as input Bhupinder Thakur
2017-06-07 0:43 ` Stefano Stabellini [this message]
2017-06-06 17:25 ` [PATCH 10/14 v4] xen/arm: vpl011: Modify xenconsole to support multiple consoles Bhupinder Thakur
2017-06-07 1:03 ` Stefano Stabellini
2017-06-07 3:51 ` Bhupinder Thakur
2017-06-07 16:46 ` Wei Liu
2017-06-07 17:54 ` Stefano Stabellini
2017-06-06 17:25 ` [PATCH 11/14 v4] xen/arm: vpl011: Add support for vuart console in xenconsole Bhupinder Thakur
2017-06-07 1:08 ` Stefano Stabellini
2017-06-07 16:44 ` Wei Liu
2017-06-06 17:25 ` [PATCH 12/14 v4] xen/arm: vpl011: Add a new vuart console type to xenconsole client Bhupinder Thakur
2017-06-06 23:41 ` Stefano Stabellini
2017-06-06 17:25 ` [PATCH 13/14 v4] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Bhupinder Thakur
2017-06-06 17:25 ` [PATCH 14/14 v4] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
2017-06-09 13:58 ` [PATCH 00/14 v4] PL011 emulation support in Xen Julien Grall
-- strict thread matches above, loose matches on Subject: below --
2017-06-06 10:04 [PATCH 09/14 v4] xen/arm: vpl011: Modify xenconsole functions to take console structure as input Bhupinder Thakur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.10.1706061743130.15791@sstabellini-ThinkPad-X260 \
--to=sstabellini@kernel.org \
--cc=bhupinder.thakur@linaro.org \
--cc=ian.jackson@eu.citrix.com \
--cc=julien.grall@arm.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).