From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: Re: [Bug 1612] Can't start VM when vif set and udev version is greater than 151 Date: Wed, 7 Jul 2010 13:18:30 -0400 Message-ID: <20100707171830.GA4275@phenom.dumpdata.com> References: <201007051720.o65HKsI6030388@bugzilla.xensource.com> <20100706151023.GA25263@phenom.dumpdata.com> <4C3369970200007800009C71@vpn.id2.novell.com> <20100706164642.GA31742@phenom.dumpdata.com> <4C34492B0200007800009EC0@vpn.id2.novell.com> <20100707144857.GF4823@phenom.dumpdata.com> <4C349C9C.2090909@goop.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="EeQfGwPcQSOJBaQU" Return-path: Content-Disposition: inline In-Reply-To: <4C349C9C.2090909@goop.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jeremy Fitzhardinge Cc: james.harper@bendigoit.com.au, xen-devel@lists.xensource.com, Jan Beulich , bastian@waldi.eu.org List-Id: xen-devel@lists.xenproject.org --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jul 07, 2010 at 08:26:20AM -0700, Jeremy Fitzhardinge wrote: > On 07/07/2010 07:48 AM, Konrad Rzeszutek Wilk wrote: > > On Wed, Jul 07, 2010 at 08:30:19AM +0100, Jan Beulich wrote: > > > >>>>> On 06.07.10 at 18:46, Konrad Rzeszutek Wilk wrote: > >>>>> > >>>> For reference, below is the diff for what we're now using. > >>>> > >>> Ah nice.. > >>> > >>> I get this: > >>> patch -p1 --dry-run < ~/p.patch > >>> patching file drivers/xen/netback/xenbus.c > >>> Hunk #1 succeeded at 19 with fuzz 1. > >>> Hunk #2 FAILED at 29. > >>> Hunk #3 FAILED at 40. > >>> patch: **** malformed patch at line 120: nv *env) > >>> > >>> If it would not be too much trouble, can you attach it as an attachment? > >>> > >> Sure, here you go. > >> > > And attached is it redone against the pv-ops kernel. Let me poke the > > folks on the BZ to see if they would be willing to test this. 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 #include +#include #include #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)) { + 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); } --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="netback-xenbus-redone.diff" 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 #include +#include #include #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)) { + 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); } --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --EeQfGwPcQSOJBaQU--