From 08090ccf7ad8886f2ef6d9c3bf477b60d6c96229 Mon Sep 17 00:00:00 2001 From: jdolecek Date: Tue, 7 Apr 2020 13:36:22 +0000 Subject: [PATCH] revert the watch.node change, xenbus_watch_path() and xenbus_watch_path2() need to use non-constant path --- sys/arch/xen/include/xenbus.h | 4 ++-- sys/arch/xen/xen/xbdback_xenbus.c | 5 +++-- sys/arch/xen/xenbus/xenbus_probe.c | 11 +++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/arch/xen/include/xenbus.h b/sys/arch/xen/include/xenbus.h index 945ffff71322..f9b8c24c9dd8 100644 --- a/sys/arch/xen/include/xenbus.h +++ b/sys/arch/xen/include/xenbus.h @@ -1,4 +1,4 @@ -/* $NetBSD: xenbus.h,v 1.16 2020/04/07 11:47:05 jdolecek Exp $ */ +/* $NetBSD: xenbus.h,v 1.17 2020/04/07 13:36:22 jdolecek Exp $ */ /****************************************************************************** * xenbus.h * @@ -57,7 +57,7 @@ struct xenbus_watch { SLIST_ENTRY(xenbus_watch) watch_next; /* Path being watched. */ - const char *node; + char *node; /* Callback (executed in a process context with no locks held). */ void (*xbw_callback)(struct xenbus_watch *, diff --git a/sys/arch/xen/xen/xbdback_xenbus.c b/sys/arch/xen/xen/xbdback_xenbus.c index 28e2bbc7b6b1..e6bf07ebf101 100644 --- a/sys/arch/xen/xen/xbdback_xenbus.c +++ b/sys/arch/xen/xen/xbdback_xenbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.75 2020/04/07 11:47:06 jdolecek Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.76 2020/04/07 13:36:22 jdolecek Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.75 2020/04/07 11:47:06 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.76 2020/04/07 13:36:22 jdolecek Exp $"); #include #include @@ -489,6 +489,7 @@ xbdback_xenbus_destroy(void *arg) /* unregister watch */ if (xbdi->xbdi_watch.node) { unregister_xenbus_watch(&xbdi->xbdi_watch); + free(xbdi->xbdi_watch.node, M_DEVBUF); xbdi->xbdi_watch.node = NULL; } /* unmap ring */ diff --git a/sys/arch/xen/xenbus/xenbus_probe.c b/sys/arch/xen/xenbus/xenbus_probe.c index 43f66e12fe5f..ea22f1456c59 100644 --- a/sys/arch/xen/xenbus/xenbus_probe.c +++ b/sys/arch/xen/xenbus/xenbus_probe.c @@ -1,4 +1,4 @@ -/* $NetBSD: xenbus_probe.c,v 1.42 2020/04/07 11:47:06 jdolecek Exp $ */ +/* $NetBSD: xenbus_probe.c,v 1.43 2020/04/07 13:36:22 jdolecek Exp $ */ /****************************************************************************** * Talks to Xen Store to figure out what devices we have. * @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.42 2020/04/07 11:47:06 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.43 2020/04/07 13:36:22 jdolecek Exp $"); #if 0 #define DPRINTK(fmt, args...) \ @@ -234,6 +234,7 @@ free_otherend_watch(struct xenbus_device *dev) { if (dev->xbusd_otherend_watch.node) { unregister_xenbus_watch(&dev->xbusd_otherend_watch); + free(dev->xbusd_otherend_watch.node, M_DEVBUF); dev->xbusd_otherend_watch.node = NULL; } } @@ -614,10 +615,12 @@ xenbus_probe(void *unused) xenbus_probe_backends(); /* Watch for changes. */ - fe_watch.node = "device"; + fe_watch.node = malloc(strlen("device") + 1, M_DEVBUF, M_NOWAIT); + strcpy(fe_watch.node, "device"); fe_watch.xbw_callback = frontend_changed; register_xenbus_watch(&fe_watch); - be_watch.node = "backend"; + be_watch.node = malloc(strlen("backend") + 1, M_DEVBUF, M_NOWAIT); + strcpy(be_watch.node, "backend"); be_watch.xbw_callback = backend_changed; register_xenbus_watch(&be_watch);