WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Re: [Bug 1612] Can't start VM when vif set and udev vers

To: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [Bug 1612] Can't start VM when vif set and udev version is greater than 151
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Wed, 07 Jul 2010 10:34:41 -0700
Cc: james.harper@xxxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, Jan Beulich <JBeulich@xxxxxxxxxx>, bastian@xxxxxxxxxxxx
Delivery-date: Wed, 07 Jul 2010 10:35:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20100707171830.GA4275@xxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <bug-1612-1575@xxxxxxxxxxxxxxxxxxxxxxxxxxx/bugzilla/> <201007051720.o65HKsI6030388@xxxxxxxxxxxxxxxxxxxxxx> <20100706151023.GA25263@xxxxxxxxxxxxxxxxxxx> <4C3369970200007800009C71@xxxxxxxxxxxxxxxxxx> <20100706164642.GA31742@xxxxxxxxxxxxxxxxxxx> <4C34492B0200007800009EC0@xxxxxxxxxxxxxxxxxx> <20100707144857.GF4823@xxxxxxxxxxxxxxxxxxx> <4C349C9C.2090909@xxxxxxxx> <20100707171830.GA4275@xxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc12 Lightning/1.0b2pre Thunderbird/3.0.4
On 07/07/2010 10:18 AM, Konrad Rzeszutek Wilk wrote:
> Here is a redux that is compile and regression tested. And I've
> addressed your concerns Jeremy. Putting this on the BZ to solicit some
> testing from folks.
>
> diff --git a/drivers/xen/netback/xenbus.c b/drivers/xen/netback/xenbus.c
> index ba7b1de..7a9ae2e 100644
> --- a/drivers/xen/netback/xenbus.c
> +++ b/drivers/xen/netback/xenbus.c
> @@ -19,6 +19,7 @@
>  
>  #include <stdarg.h>
>  #include <linux/module.h>
> +#include <linux/rwsem.h>
>  #include <xen/xenbus.h>
>  #include "common.h"
>  
> @@ -28,6 +29,7 @@
>      printk("netback/xenbus (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, 
> ##args)
>  #endif
>  
> +static DECLARE_RWSEM(teardown_sem);
>  
>  static int connect_rings(struct backend_info *);
>  static void connect(struct backend_info *);
> @@ -41,14 +43,19 @@ static int netback_remove(struct xenbus_device *dev)
>       //netback_remove_accelerators(be, dev);
>  
>       unregister_hotplug_status_watch(be);
> -     if (be->netif) {
> +     if (be->netif)
>               kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
> +
> +     down_write(&teardown_sem);
> +     if (be->netif) {
>               xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status");
>               netif_disconnect(be->netif);
>               be->netif = NULL;
>       }
> -     kfree(be);
>       dev_set_drvdata(&dev->dev, NULL);
> +     up_write(&teardown_sem);
> +     kfree(be);
> +
>       return 0;
>  }
>  
> @@ -187,9 +194,15 @@ static int netback_uevent(struct xenbus_device *xdev, 
> struct kobj_uevent_env *en
>               kfree(val);
>       }
>  
> -     if (add_uevent_var(env, "vif=%s", netif->dev->name))
> -             return -ENOMEM;
> -
> +     down_read(&teardown_sem);
> +     be = dev_get_drvdata(&xdev->dev);
> +     if (be && be->netif) {
> +             if (add_uevent_var(env, "vif=%s", netif->dev->name)) {
>   

The extra {} helps, but I was thinking more along the lines of:

        if (be && be->netif && add_uevent_var(env, "vif=%s", netif->dev->name)) 
{
                ...

(with line break after the second && if that's too long).

> +                     up_read(&teardown_sem);
> +                     return -ENOMEM;
> +             }
> +     }
> +     up_read(&teardown_sem);
>       return 0;
>  }
>  
> @@ -199,6 +212,7 @@ static void backend_create_netif(struct backend_info *be)
>       int err;
>       long handle;
>       struct xenbus_device *dev = be->dev;
> +     struct xen_netif *netif;
>  
>       if (be->netif != NULL)
>               return;
> @@ -209,13 +223,13 @@ static void backend_create_netif(struct backend_info 
> *be)
>               return;
>       }
>  
> -     be->netif = netif_alloc(&dev->dev, dev->otherend_id, handle);
> -     if (IS_ERR(be->netif)) {
> -             err = PTR_ERR(be->netif);
> -             be->netif = NULL;
> +     netif = netif_alloc(&dev->dev, dev->otherend_id, handle);
> +     if (IS_ERR(netif)) {
> +             err = PTR_ERR(netif);
>               xenbus_dev_fatal(dev, err, "creating interface");
>               return;
>       }
> +     be->netif = netif;
>  
>       kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE);
>  }
>   


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel