Fix request-abs-pointer (again)
cover Fix request-abs-pointer (again)
A little while ago, Jeremy Fitzhardinge has a problem that was preventing request-abs-pointer from being honoured. A simple fix for this in 805ed3b20492d2f4bb465bfda65cedd286e23209 actually turned out to be wrong.
Konrad Rzeszutek Wilk and Stefano Stabellini suggested a different
approach: introduce a new hook in xen_backend that, if defined, is called when the frontend is connected. The first of these two patches does just that (the old connect hook is now called "initialise" and the new hook is
called "connected"). The second patch uses this to set up the pointer at
the right time. I haven't been able to test this in a Xen 4.0
environment, but it works properly in a Xen 3.4 environment.
jch
PATCH 1/2 Introduce a new 'connected' xendev op called when Connected.
Rename the existing xendev 'connect' op to 'initialised' and introduce a new 'connected' op. This new op, if defined, is called when the backend is connected. Note that since there is no state transition this may be called more than once.
--- hw/xen_backend.c | 39 +++++++++++++++++++++++++++++++++------ hw/xen_backend.h | 3 ++- hw/xen_console.c | 4 ++-- hw/xenfb.c | 8 ++++---- 4 files changed, 41 insertions(+), 13 deletions(-)
hw/xen_backend.c +33 -6
@@ -401,13 +401,13 @@ static int xen_be_try_init(struct XenDevice *xendev) }/* -* Try to connect xendev. Depends on the frontend being ready +* Try to initialise xendev. Depends on the frontend being ready * for it (shared ring and evtchn info in xenstore, state being * Initialised or Connected). * * Goes to Connected on success. */ -static int xen_be_try_connect (struct XenDevice *xendev) +static int xen_be_try_initialise (struct XenDevice *xendev) {int rc =0 ;
@@ -421,10 +421,10 @@ static int xen_be_try_connect(struct XenDevice *xendev) } } -if (xendev->ops->connect) - rc = xendev->ops->connect (xendev); +if (xendev->ops->initialise) + rc = xendev->ops->initialise (xendev);if (rc !=0 ) { -xen_be_printf (xendev,0 ,"connect() failed\n" ); +xen_be_printf (xendev,0 ,"initialise() failed\n" );return rc; }
@@ -433,6 +433,28 @@ static int xen_be_try_connect(struct XenDevice *xendev) }/* +* Try to let xendev know that it is connected. Depends on the +* frontend being Connected. Note that this may be called more +* than once since the backend state is not modified. +*/ +static void xen_be_try_connected (struct XenDevice *xendev) +{ +if (!xendev->ops->connected) +return ; + +if (xendev->fe_state != XenbusStateConnected) { +if (xendev->ops->flags &DEVOPS_FLAG_IGNORE_STATE ) { +xen_be_printf (xendev,2 ,"frontend not ready, ignoring\n" ); + }else { +xen_be_printf (xendev,2 ,"frontend not ready (yet)\n" ); +return ; + } + } + + xendev->ops->connected (xendev); +} + +/* * Teardown connection. * * Goes to Closed when done.
@@ -484,7 +506,12 @@ void xen_be_check_state(struct XenDevice *xendev) rc =xen_be_try_init (xendev);break ;case XenbusStateInitWait: - rc =xen_be_try_connect (xendev); + rc =xen_be_try_initialise (xendev); +break ; +case XenbusStateConnected: +/* xendev->be_state doesn't change */ +xen_be_try_connected (xendev); + rc =-1 ;break ;case XenbusStateClosed: rc =xen_be_try_reset (xendev);
hw/xen_backend.h +2 -1
@@ -19,7 +19,8 @@ struct XenDevOps {uint32_t flags;void (*alloc)(struct XenDevice *xendev);int (*init)(struct XenDevice *xendev); -int (*connect)(struct XenDevice *xendev); +int (*initialise)(struct XenDevice *xendev); +void (*connected)(struct XenDevice *xendev);void (*event)(struct XenDevice *xendev);void (*disconnect)(struct XenDevice *xendev);int (*free)(struct XenDevice *xendev);
hw/xen_console.c +2 -2
@@ -209,7 +209,7 @@ static int con_init(struct XenDevice *xendev)return 0 ; } -static int con_connect (struct XenDevice *xendev) +static int con_initialise (struct XenDevice *xendev) { struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);int limit;
@@ -278,7 +278,7 @@ struct XenDevOps xen_console_ops = { .size = sizeof(struct XenConsole), .flags = DEVOPS_FLAG_IGNORE_STATE|DEVOPS_FLAG_NEED_GNTDEV, .init = con_init, - .connect = con_connect, + .initialise = con_initialise, .event = con_event, .disconnect = con_disconnect, };
hw/xenfb.c +4 -4
@@ -361,7 +361,7 @@ static int input_init(struct XenDevice *xendev)return 0 ; } -static int input_connect (struct XenDevice *xendev) +static int input_initialise (struct XenDevice *xendev) { struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);int rc;
@@ -863,7 +863,7 @@ static int fb_init(struct XenDevice *xendev)return 0 ; } -static int fb_connect (struct XenDevice *xendev) +static int fb_initialise (struct XenDevice *xendev) { struct XenFB *fb = container_of(xendev, struct XenFB, c.xendev);struct xenfb_page *fb_page;
@@ -957,7 +957,7 @@ static void fb_event(struct XenDevice *xendev)struct XenDevOps xen_kbdmouse_ops = { .size =sizeof (struct XenInput ), .init = input_init, - .connect = input_connect, + .initialise = input_initialise, .disconnect = input_disconnect, .event = input_event, };
@@ -965,7 +965,7 @@ struct XenDevOps xen_kbdmouse_ops = {struct XenDevOps xen_framebuffer_ops = { .size =sizeof (struct XenFB ), .init = fb_init, - .connect = fb_connect, + .initialise = fb_initialise, .disconnect = fb_disconnect, .event = fb_event, .frontend_changed = fb_frontend_changed,
Signature · 1 line
1.7.1
Re: [PATCH 1/2] Introduce a new 'connected' xendev op called when Connected.
CC'ing Gerd.
Quoted 6 lines · John Haxby
Rename the existing xendev 'connect' op to 'initialised' and introduce a new 'connected' op. This new op, if defined, is called when the backend is connected. Note that since there is no state transition this may be called more than once.
Signed-off-by John Haxby <[email protected]>
Quoted 169 lines
--- hw/xen_backend.c | 39 +++++++++++++++++++++++++++++++++------ hw/xen_backend.h | 3 ++- hw/xen_console.c | 4 ++-- hw/xenfb.c | 8 ++++---- 4 files changed, 41 insertions(+), 13 deletions(-)hw/xen_backend.c +33
-6@@ -401,13 +401,13 @@ static int xen_be_try_init(struct XenDevice *xendev) }/* -* Try to connect xendev. Depends on the frontend being ready +* Try to initialise xendev. Depends on the frontend being ready * for it (shared ring and evtchn info in xenstore, state being * Initialised or Connected). * * Goes to Connected on success. */ -static int xen_be_try_connect (struct XenDevice *xendev) +static int xen_be_try_initialise (struct XenDevice *xendev) {int rc =0 ;@@ -421,10 +421,10 @@ static int xen_be_try_connect(struct XenDevice *xendev) } } -if (xendev->ops->connect) - rc = xendev->ops->connect (xendev); +if (xendev->ops->initialise) + rc = xendev->ops->initialise (xendev);if (rc !=0 ) { -xen_be_printf (xendev,0 ,"connect() failed\n" ); +xen_be_printf (xendev,0 ,"initialise() failed\n" );return rc; }@@ -433,6 +433,28 @@ static int xen_be_try_connect(struct XenDevice *xendev) }/* +* Try to let xendev know that it is connected. Depends on the +* frontend being Connected. Note that this may be called more +* than once since the backend state is not modified. +*/ +static void xen_be_try_connected (struct XenDevice *xendev) +{ +if (!xendev->ops->connected) +return ; + +if (xendev->fe_state != XenbusStateConnected) { +if (xendev->ops->flags &DEVOPS_FLAG_IGNORE_STATE ) { +xen_be_printf (xendev,2 ,"frontend not ready, ignoring\n" ); + }else { +xen_be_printf (xendev,2 ,"frontend not ready (yet)\n" ); +return ; + } + } + + xendev->ops->connected (xendev); +} + +/* * Teardown connection. * * Goes to Closed when done. @@ -484,7 +506,12 @@ void xen_be_check_state(struct XenDevice *xendev) rc =xen_be_try_init (xendev);break ;case XenbusStateInitWait: - rc =xen_be_try_connect (xendev); + rc =xen_be_try_initialise (xendev); +break ; +case XenbusStateConnected: +/* xendev->be_state doesn't change */ +xen_be_try_connected (xendev); + rc =-1 ;break ;case XenbusStateClosed: rc =xen_be_try_reset (xendev);hw/xen_backend.h +2
-1@@ -19,7 +19,8 @@ struct XenDevOps {uint32_t flags;void (*alloc)(struct XenDevice *xendev);int (*init)(struct XenDevice *xendev); -int (*connect)(struct XenDevice *xendev); +int (*initialise)(struct XenDevice *xendev); +void (*connected)(struct XenDevice *xendev);void (*event)(struct XenDevice *xendev);void (*disconnect)(struct XenDevice *xendev);int (*free)(struct XenDevice *xendev);hw/xen_console.c +2
-2@@ -209,7 +209,7 @@ static int con_init(struct XenDevice *xendev)return 0 ; } -static int con_connect (struct XenDevice *xendev) +static int con_initialise (struct XenDevice *xendev) { struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);int limit;@@ -278,7 +278,7 @@ struct XenDevOps xen_console_ops = { .size = sizeof(struct XenConsole), .flags = DEVOPS_FLAG_IGNORE_STATE|DEVOPS_FLAG_NEED_GNTDEV, .init = con_init, - .connect = con_connect, + .initialise = con_initialise, .event = con_event, .disconnect = con_disconnect, };hw/xenfb.c +4
-4@@ -361,7 +361,7 @@ static int input_init(struct XenDevice *xendev)return 0 ; } -static int input_connect (struct XenDevice *xendev) +static int input_initialise (struct XenDevice *xendev) { struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);int rc;@@ -863,7 +863,7 @@ static int fb_init(struct XenDevice *xendev)return 0 ; } -static int fb_connect (struct XenDevice *xendev) +static int fb_initialise (struct XenDevice *xendev) { struct XenFB *fb = container_of(xendev, struct XenFB, c.xendev);struct xenfb_page *fb_page;@@ -957,7 +957,7 @@ static void fb_event(struct XenDevice *xendev)struct XenDevOps xen_kbdmouse_ops = { .size =sizeof (struct XenInput ), .init = input_init, - .connect = input_connect, + .initialise = input_initialise, .disconnect = input_disconnect, .event = input_event, };@@ -965,7 +965,7 @@ struct XenDevOps xen_kbdmouse_ops = {struct XenDevOps xen_framebuffer_ops = { .size =sizeof (struct XenFB ), .init = fb_init, - .connect = fb_connect, + .initialise = fb_initialise, .disconnect = fb_disconnect, .event = fb_event, .frontend_changed = fb_frontend_changed,Signature · 7 lines
1.7.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xensource.com/xen-devel
PATCH 2/2 Move the xenfb pointer handler to the connected method
In reply to John HaxbyEnsure that we read "request-abs-pointer" after the frontend has written it. This means that we will correctly set up an ansolute or relative pointer handler correctly.
--- hw/xenfb.c | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)
hw/xenfb.c +14 -5
@@ -366,19 +366,27 @@ static int input_initialise(struct XenDevice *xendev) struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);int rc; -if (xenstore_read_fe_int (xendev,"request-abs-pointer" , - &in->abs_pointer_wanted) ==-1 ) - in->abs_pointer_wanted =0 ; - rc =common_bind (&in->c);if (rc !=0 )return rc;qemu_add_kbd_event_handler (xenfb_key_event, in); +return 0 ; +} + +static void input_connected (struct XenDevice *xendev) +{ + struct XenInput *in = container_of(xendev, struct XenInput, c.xendev); + +if (xenstore_read_fe_int (xendev,"request-abs-pointer" , + &in->abs_pointer_wanted) ==-1 ) + in->abs_pointer_wanted =0 ; + +if (in->qmouse) +qemu_remove_mouse_event_handler (in->qmouse); in->qmouse =qemu_add_mouse_event_handler (xenfb_mouse_event, in, in->abs_pointer_wanted,"Xen PVFB Mouse" ); -return 0 ; }static void input_disconnect (struct XenDevice *xendev)
@@ -958,6 +966,7 @@ struct XenDevOps xen_kbdmouse_ops = { .size = sizeof(struct XenInput), .init = input_init, .initialise = input_initialise, + .connected = input_connected, .disconnect = input_disconnect, .event = input_event, };
Signature · 1 line
1.7.1
Re: [PATCH 2/2] Move the xenfb pointer handler to the connected method
CC'ing Gerd.
Quoted 5 lines · John Haxby
Ensure that we read "request-abs-pointer" after the frontend has written it. This means that we will correctly set up an ansolute or relative pointer handler correctly.
Signed-off-by John Haxby <[email protected]>
Quoted 58 lines
--- hw/xenfb.c | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)hw/xenfb.c +14
-5@@ -366,19 +366,27 @@ static int input_initialise(struct XenDevice *xendev) struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);int rc; -if (xenstore_read_fe_int (xendev,"request-abs-pointer" , - &in->abs_pointer_wanted) ==-1 ) - in->abs_pointer_wanted =0 ; - rc =common_bind (&in->c);if (rc !=0 )return rc;qemu_add_kbd_event_handler (xenfb_key_event, in); +return 0 ; +} + +static void input_connected (struct XenDevice *xendev) +{ + struct XenInput *in = container_of(xendev, struct XenInput, c.xendev); + +if (xenstore_read_fe_int (xendev,"request-abs-pointer" , + &in->abs_pointer_wanted) ==-1 ) + in->abs_pointer_wanted =0 ; + +if (in->qmouse) +qemu_remove_mouse_event_handler (in->qmouse); in->qmouse =qemu_add_mouse_event_handler (xenfb_mouse_event, in, in->abs_pointer_wanted,"Xen PVFB Mouse" ); -return 0 ; }static void input_disconnect (struct XenDevice *xendev)@@ -958,6 +966,7 @@ struct XenDevOps xen_kbdmouse_ops = { .size = sizeof(struct XenInput), .init = input_init, .initialise = input_initialise, + .connected = input_connected, .disconnect = input_disconnect, .event = input_event, };Signature · 7 lines
1.7.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xensource.com/xen-devel
Quoted 11 lines · John Haxby
A little while ago, Jeremy Fitzhardinge has a problem that was preventing request-abs-pointer from being honoured. A simple fix for this in
805ed3b20492d2f4bb465bfda65cedd286e23209actually turned out to be wrong.Konrad Rzeszutek Wilk and Stefano Stabellini suggested a different
approach: introduce a new hook inxen_backendthat, if defined, is called when the frontend is connected. The first of these two patches does just that (the old connect hook is now called "initialise" and the new hook is
called "connected"). The second patch uses this to set up the pointer at
the right time. I haven't been able to test this in a Xen 4.0
environment, but it works properly in a Xen 3.4 environment.
I tested them by:
1). Reverting c/s 21260 and 21651 from Xen unstable 2). Applied both of your patches on top ofadd968aaf68cb57257428f8cfadb209f2614a6d8
and tested the pv-grub launch with success.
I did not test the HVM stubdomain launch.