[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 21/25 v7] xen/arm: vpl011: Add support for multiple consoles in xenconsole



On Mon, Aug 07, 2017 at 02:23:13PM +0530, Bhupinder Thakur wrote:
> This patch adds the support for multiple consoles and introduces the
> iterator functions to operate on multiple consoles.
> 

Please check all the functions called by the iterator functions to make
sure they have properly guarded against partially constructed states and
uninitialised states. If they don't have such property, they need to be
changed before this patch. If they already have such property, say so in
the commit message.

And some comments below.

> This patch is in preparation to support a new vuart console.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@xxxxxxxxxx>
> ---
> CC: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> CC: Wei Liu <wei.liu2@xxxxxxxxxx>
> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> CC: Julien Grall <julien.grall@xxxxxxx>
> 
> Changes since v5:
> - Split this patch in multiple smaller patches.
> 
> Changes since v4:
> - Changes to make event channel handling per console rather than per domain.
> 
> Changes since v3:
> - The changes in xenconsole have been split into four patches. This is the 
> third patch.
> 
>  tools/console/daemon/io.c | 156 
> ++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 122 insertions(+), 34 deletions(-)
> 
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index 71465a0..f60312d 100644
> --- a/tools/console/daemon/io.c
> +++ b/tools/console/daemon/io.c
> @@ -90,12 +90,14 @@ struct buffer {
>  };
>  
>  struct console {
> +     char *ttyname;
>       int master_fd;
>       int master_pollfd_idx;
>       int slave_fd;
>       int log_fd;
>       struct buffer buffer;
>       char *xspath;
> +     char *log_suffix;
>       int ring_ref;
>       xenevtchn_handle *xce_handle;
>       int xce_pollfd_idx;
> @@ -107,21 +109,107 @@ struct console {
>       struct domain *d;
>  };
>  
> +struct console_data {

console_type?

> +     char *xsname;
> +     char *ttyname;
> +     char *log_suffix;
> +};
> +
> +static struct console_data console_data[] = {
> +     {
> +             .xsname = "/console",
> +             .ttyname = "tty",
> +             .log_suffix = "",
> +     },
> +};
> +
> +#define MAX_CONSOLE (sizeof(console_data)/sizeof(struct console_data))

NUM_CONSOLE_TYPE?

I think we can already have multiple PV consoles, so the original name
you proposed is confusing.

> +
>  struct domain {
>       int domid;
>       bool is_dead;
>       unsigned last_seen;
>       struct domain *next;
> -     struct console console;
> +     struct console console[MAX_CONSOLE];
>  };
>  
>  static struct domain *dom_head;
>  
> +typedef void (*VOID_ITER_FUNC_ARG1)(struct console *);
> +typedef bool (*BOOL_ITER_FUNC_ARG1)(struct console *);
> +typedef int (*INT_ITER_FUNC_ARG1)(struct console *);
> +typedef void (*VOID_ITER_FUNC_ARG2)(struct console *,  void *);
> +typedef int (*INT_ITER_FUNC_ARG3)(struct console *,
> +                               struct domain *dom, void **);
> +
>  static inline bool console_enabled(struct console *con)
>  {
>       return con->local_port != -1;
>  }
>  
> +static inline void console_iter_void_arg1(struct domain *d,
> +                                       VOID_ITER_FUNC_ARG1 iter_func)
> +{
> +     int i = 0;

unsigned int here and in other functions.

> +     struct console *con = &d->console[0];
> +
> +     for (i = 0; i < MAX_CONSOLE; i++, con++) {
> +             iter_func(con);
> +     }
> +}
> +
[...]
> +
> +static inline int console_iter_int_arg1(struct domain *d,
> +                                     INT_ITER_FUNC_ARG1 iter_func)
> +{
> +     int i = 0;
> +     struct console *con = &d->console[0];
> +
> +     for (i = 0; i < MAX_CONSOLE; i++, con++) {
> +             if (iter_func(con))
> +                     return 1;

Do you maybe want to return the return value of your iterator function?
Otherwise I don't see a point for this function to return int -- using
bool is fine.

And please document what return value means what.

> +     }
> +     return 0;
> +}
> +
> +static inline int console_iter_int_arg3(struct domain *d,
> +                                     INT_ITER_FUNC_ARG3 iter_func,
> +                                     void **iter_data)
> +{
> +     int i = 0;
> +     struct console *con = &d->console[0];
> +
> +     for (i = 0; i < MAX_CONSOLE; i++, con++) {
> +             if (iter_func(con, d, iter_data))
> +                     return 1;
> +     }
> +     return 0;
> +}
> +
>  static int write_all(int fd, const char* buf, size_t len)
>  {
>       while (len) {
> @@ -336,7 +424,7 @@ static int create_console_log(struct console *con)
>               return -1;
>       }
>  
> -     snprintf(logfile, PATH_MAX-1, "%s/guest-%s.log", log_dir, data);
> +     snprintf(logfile, PATH_MAX-1, "%s/guest-%s%s.log", log_dir, data, 
> con->log_suffix);

Line too long.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.