diff mbox series

[Xen-devel] Input: xen-kbdfront - signal the backend that we disconnect

Message ID 20190315092348.32613-1-andr2000@gmail.com (mailing list archive)
State Rejected
Headers show
Series [Xen-devel] Input: xen-kbdfront - signal the backend that we disconnect | expand

Commit Message

Oleksandr Andrushchenko March 15, 2019, 9:23 a.m. UTC
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

While disconnecting from the backend we clean up shared resources
(event channel, ring buffer), but never let the backend know about
that. This may lead to inconsistent backend state and/or shared
resources use.
Fix this by explicitly letting the backend know that frontend has
destroyed shared resources by changing its Xen bus state accordingly.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
---
 drivers/input/misc/xen-kbdfront.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jürgen Groß March 22, 2019, 11:03 a.m. UTC | #1
On 15/03/2019 10:23, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> 
> While disconnecting from the backend we clean up shared resources
> (event channel, ring buffer), but never let the backend know about
> that. This may lead to inconsistent backend state and/or shared
> resources use.
> Fix this by explicitly letting the backend know that frontend has
> destroyed shared resources by changing its Xen bus state accordingly.
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> ---
>  drivers/input/misc/xen-kbdfront.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
> index 24bc5c5d876f..ecb6e719e0e2 100644
> --- a/drivers/input/misc/xen-kbdfront.c
> +++ b/drivers/input/misc/xen-kbdfront.c
> @@ -488,6 +488,8 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
>  
>  static void xenkbd_disconnect_backend(struct xenkbd_info *info)
>  {
> +	xenbus_switch_state(info->xbdev, XenbusStateClosing);
> +
>  	if (info->irq >= 0)
>  		unbind_from_irqhandler(info->irq, info);
>  	info->irq = -1;
> 

As already stated for the related netfront patch: I'm not sure this
is really what we want. Have you tested xl save/restore or migration
of the guest with your patch applied?


Juergen
Oleksandr Andrushchenko March 22, 2019, 11:09 a.m. UTC | #2
On 3/22/19 1:03 PM, Juergen Gross wrote:
> On 15/03/2019 10:23, Oleksandr Andrushchenko wrote:
>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>>
>> While disconnecting from the backend we clean up shared resources
>> (event channel, ring buffer), but never let the backend know about
>> that. This may lead to inconsistent backend state and/or shared
>> resources use.
>> Fix this by explicitly letting the backend know that frontend has
>> destroyed shared resources by changing its Xen bus state accordingly.
>>
>> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>> ---
>>   drivers/input/misc/xen-kbdfront.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
>> index 24bc5c5d876f..ecb6e719e0e2 100644
>> --- a/drivers/input/misc/xen-kbdfront.c
>> +++ b/drivers/input/misc/xen-kbdfront.c
>> @@ -488,6 +488,8 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
>>   
>>   static void xenkbd_disconnect_backend(struct xenkbd_info *info)
>>   {
>> +	xenbus_switch_state(info->xbdev, XenbusStateClosing);
>> +
>>   	if (info->irq >= 0)
>>   		unbind_from_irqhandler(info->irq, info);
>>   	info->irq = -1;
>>
> As already stated for the related netfront patch: I'm not sure this
> is really what we want. Have you tested xl save/restore or migration
> of the guest with your patch applied?
Well, it comes out that this is not enough and needs much more work,
so please let's abandon this patch
>
> Juergen
Thank you,
Oleksandr
diff mbox series

Patch

diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 24bc5c5d876f..ecb6e719e0e2 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -488,6 +488,8 @@  static int xenkbd_connect_backend(struct xenbus_device *dev,
 
 static void xenkbd_disconnect_backend(struct xenkbd_info *info)
 {
+	xenbus_switch_state(info->xbdev, XenbusStateClosing);
+
 	if (info->irq >= 0)
 		unbind_from_irqhandler(info->irq, info);
 	info->irq = -1;