[Xen-devel,07/10] xen/arm: vpl011: Add a new console type to domain structure in xenconsole

Message ID 1491212673-13476-8-git-send-email-bhupinder.thakur@linaro.org
State New
Headers show
Series
  • pl011 emulation support in Xen
Related show

Commit Message

Bhupinder Thakur April 3, 2017, 9:44 a.m.
Modify the domain structure to to make console specific fields as an array indexed
by the console type. Two console types are defined - PV and VCON.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
 tools/console/daemon/io.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

Comments

Wei Liu April 12, 2017, 4:33 p.m. | #1
On Mon, Apr 03, 2017 at 03:14:30PM +0530, Bhupinder Thakur wrote:
> Modify the domain structure to to make console specific fields as an array indexed
> by the console type. Two console types are defined - PV and VCON.

Why? Can you have both for an ARM guest?

Also this patch alone is going to break xencosnole. Please make sure the
whole series is bisectable.

Wei.
Bhupinder Thakur April 13, 2017, 9:49 a.m. | #2
Hi Wei,

On 12 April 2017 at 22:03, Wei Liu <wei.liu2@citrix.com> wrote:
> On Mon, Apr 03, 2017 at 03:14:30PM +0530, Bhupinder Thakur wrote:
>> Modify the domain structure to to make console specific fields as an array indexed
>> by the console type. Two console types are defined - PV and VCON.
>
> Why? Can you have both for an ARM guest?
>
Ideally, user could specify multiple consoles for a domU guest.

> Also this patch alone is going to break xencosnole. Please make sure the
> whole series is bisectable.
>
I will review the patch series to see if there are any other
bisectability issues.

Regards,
Bhupinder
Stefano Stabellini April 19, 2017, 7:09 p.m. | #3
On Mon, 3 Apr 2017, Bhupinder Thakur wrote:
> Modify the domain structure to to make console specific fields as an array indexed
> by the console type. Two console types are defined - PV and VCON.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
>  tools/console/daemon/io.c | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index 7e6a886..0cd1fee 100644
> --- a/tools/console/daemon/io.c
> +++ b/tools/console/daemon/io.c
> @@ -61,6 +61,10 @@
>  /* Duration of each time period in ms */
>  #define RATE_LIMIT_PERIOD 200
>  
> +#define MAX_CONSOLE 2
> +#define CONSOLE_TYPE_PV 0
> +#define CONSOLE_TYPE_VCON 1
> +
>  extern int log_reload;
>  extern int log_guest;
>  extern int log_hv;
> @@ -91,23 +95,25 @@ struct buffer {
>  
>  struct domain {
>  	int domid;
> -	int master_fd;
> -	int master_pollfd_idx;
> -	int slave_fd;
> -	int log_fd;
> +	int master_fd[MAX_CONSOLE];
> +	int master_pollfd_idx[MAX_CONSOLE];
> +	int slave_fd[MAX_CONSOLE];
> +	int log_fd[MAX_CONSOLE];
>  	bool is_dead;
>  	unsigned last_seen;
> -	struct buffer buffer;
> +	struct buffer buffer[MAX_CONSOLE];
>  	struct domain *next;
>  	char *conspath;
> -	int ring_ref;
> -	xenevtchn_port_or_error_t local_port;
> -	xenevtchn_port_or_error_t remote_port;
> +	int ring_ref[MAX_CONSOLE];
> +	xenevtchn_port_or_error_t local_port[MAX_CONSOLE];
> +	xenevtchn_port_or_error_t remote_port[MAX_CONSOLE];
>  	xenevtchn_handle *xce_handle;
>  	int xce_pollfd_idx;
> -	struct xencons_interface *interface;
> +	struct xencons_interface *interface[MAX_CONSOLE];
>  	int event_count;
>  	long long next_period;
> +	int console_data_pending;
> +	bool vcon_enabled;

I think you need to gather together all the info of one console into a
single struct, maybe called struct console. Then you'll have an array of
MAX_CONSOLE struct consoles for each domain. Something like:

    struct console {
        int master_fd;
        int master_pollfd_idx;
        int slave_fd;
        int log_fd;
        struct buffer buffer;
        int ring_ref;
        xenevtchn_port_or_error_t local_port;
        xenevtchn_port_or_error_t remote_port;
        struct xencons_interface *interface;
    }

At that point, you'll be able to generalize all functions in this file,
like buffer_append and handle_ring_read, to take a struct console* as
argument instead of a struct domain*, and they will work seamlessly on
the old pv console and the new vuart console.

The for loop in handle_io can figure out which struct console* to pass
as parameter.

The resulting patch will be much nicer.



>  };
>  
>  static struct domain *dom_head;
> -- 
> 2.7.4
>

Patch hide | download patch | download mbox

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 7e6a886..0cd1fee 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -61,6 +61,10 @@ 
 /* Duration of each time period in ms */
 #define RATE_LIMIT_PERIOD 200
 
+#define MAX_CONSOLE 2
+#define CONSOLE_TYPE_PV 0
+#define CONSOLE_TYPE_VCON 1
+
 extern int log_reload;
 extern int log_guest;
 extern int log_hv;
@@ -91,23 +95,25 @@  struct buffer {
 
 struct domain {
 	int domid;
-	int master_fd;
-	int master_pollfd_idx;
-	int slave_fd;
-	int log_fd;
+	int master_fd[MAX_CONSOLE];
+	int master_pollfd_idx[MAX_CONSOLE];
+	int slave_fd[MAX_CONSOLE];
+	int log_fd[MAX_CONSOLE];
 	bool is_dead;
 	unsigned last_seen;
-	struct buffer buffer;
+	struct buffer buffer[MAX_CONSOLE];
 	struct domain *next;
 	char *conspath;
-	int ring_ref;
-	xenevtchn_port_or_error_t local_port;
-	xenevtchn_port_or_error_t remote_port;
+	int ring_ref[MAX_CONSOLE];
+	xenevtchn_port_or_error_t local_port[MAX_CONSOLE];
+	xenevtchn_port_or_error_t remote_port[MAX_CONSOLE];
 	xenevtchn_handle *xce_handle;
 	int xce_pollfd_idx;
-	struct xencons_interface *interface;
+	struct xencons_interface *interface[MAX_CONSOLE];
 	int event_count;
 	long long next_period;
+	int console_data_pending;
+	bool vcon_enabled;
 };
 
 static struct domain *dom_head;