]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
xen/xenbus: Add 'will_handle' callback support in xenbus_watch_path()
authorSeongJae Park <sjpark@amazon.de>
Mon, 14 Dec 2020 09:04:18 +0000 (10:04 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 20 Jan 2021 13:26:37 +0000 (14:26 +0100)
BugLink: https://bugs.launchpad.net/bugs/1910822
commit 2e85d32b1c865bec703ce0c962221a5e955c52c2 upstream.

Some code does not directly make 'xenbus_watch' object and call
'register_xenbus_watch()' but use 'xenbus_watch_path()' instead.  This
commit adds support of 'will_handle' callback in the
'xenbus_watch_path()' and it's wrapper, 'xenbus_watch_pathfmt()'.

This is part of XSA-349

Cc: stable@vger.kernel.org
Signed-off-by: SeongJae Park <sjpark@amazon.de>
Reported-by: Michael Kurth <mku@amazon.de>
Reported-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/block/xen-blkback/xenbus.c
drivers/net/xen-netback/xenbus.c
drivers/xen/xen-pciback/xenbus.c
drivers/xen/xenbus/xenbus_client.c
drivers/xen/xenbus/xenbus_probe.c
include/xen/xenbus.h

index b2243c70b67d3e4d03ea145b4ca3b07f3b49f4c0..040d7bb2139787fae291b648258098c882189547 100644 (file)
@@ -644,7 +644,8 @@ static int xen_blkbk_probe(struct xenbus_device *dev,
        /* setup back pointer */
        be->blkif->be = be;
 
-       err = xenbus_watch_pathfmt(dev, &be->backend_watch, backend_changed,
+       err = xenbus_watch_pathfmt(dev, &be->backend_watch, NULL,
+                                  backend_changed,
                                   "%s/%s", dev->nodename, "physical-device");
        if (err)
                goto fail;
index caa8add9e3f17e19f12bf0535905e8d4bd6ea95a..9e61a6f29464100c825ce91ad304bebb47b8fd3c 100644 (file)
@@ -979,7 +979,7 @@ static void connect(struct backend_info *be)
        xenvif_carrier_on(be->vif);
 
        unregister_hotplug_status_watch(be);
-       err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch,
+       err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL,
                                   hotplug_status_changed,
                                   "%s/%s", dev->nodename, "hotplug-status");
        if (!err)
index e7a6702359655d5df68cc208bf5734da4d49f1e9..7fb65836230acdf2db618f93bfc80c24226be9f1 100644 (file)
@@ -688,7 +688,7 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev,
 
        /* watch the backend node for backend configuration information */
        err = xenbus_watch_path(dev, dev->nodename, &pdev->be_watch,
-                               xen_pcibk_be_watch);
+                               NULL, xen_pcibk_be_watch);
        if (err)
                goto out;
 
index 160cec90b19068013925ab4bbdb3476e58264cd4..81eddb8529ffcaaeab384b07a08b3dc1b0f615c1 100644 (file)
@@ -114,19 +114,22 @@ EXPORT_SYMBOL_GPL(xenbus_strstate);
  */
 int xenbus_watch_path(struct xenbus_device *dev, const char *path,
                      struct xenbus_watch *watch,
+                     bool (*will_handle)(struct xenbus_watch *,
+                                         const char *, const char *),
                      void (*callback)(struct xenbus_watch *,
                                       const char *, const char *))
 {
        int err;
 
        watch->node = path;
-       watch->will_handle = NULL;
+       watch->will_handle = will_handle;
        watch->callback = callback;
 
        err = register_xenbus_watch(watch);
 
        if (err) {
                watch->node = NULL;
+               watch->will_handle = NULL;
                watch->callback = NULL;
                xenbus_dev_fatal(dev, err, "adding watch on %s", path);
        }
@@ -153,6 +156,8 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path);
  */
 int xenbus_watch_pathfmt(struct xenbus_device *dev,
                         struct xenbus_watch *watch,
+                        bool (*will_handle)(struct xenbus_watch *,
+                                       const char *, const char *),
                         void (*callback)(struct xenbus_watch *,
                                          const char *, const char *),
                         const char *pathfmt, ...)
@@ -169,7 +174,7 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev,
                xenbus_dev_fatal(dev, -ENOMEM, "allocating path for watch");
                return -ENOMEM;
        }
-       err = xenbus_watch_path(dev, path, watch, callback);
+       err = xenbus_watch_path(dev, path, watch, will_handle, callback);
 
        if (err)
                kfree(path);
index 5b471889d7237c926682392b123db99e7ab6656f..d7474ff2c2778a042f0994634c7aa5f56088cbae 100644 (file)
@@ -136,7 +136,7 @@ static int watch_otherend(struct xenbus_device *dev)
                container_of(dev->dev.bus, struct xen_bus_type, bus);
 
        return xenbus_watch_pathfmt(dev, &dev->otherend_watch,
-                                   bus->otherend_changed,
+                                   NULL, bus->otherend_changed,
                                    "%s/%s", dev->otherend, "state");
 }
 
index 55f543fe0bd8c48e4bfaf7b1288a4b715bdb6db2..de5ae6c6fa0f54de12af88f3c8d59b63c46f7b05 100644 (file)
@@ -199,10 +199,14 @@ void xenbus_probe(struct work_struct *);
 
 int xenbus_watch_path(struct xenbus_device *dev, const char *path,
                      struct xenbus_watch *watch,
+                     bool (*will_handle)(struct xenbus_watch *,
+                                         const char *, const char *),
                      void (*callback)(struct xenbus_watch *,
                                       const char *, const char *));
-__printf(4, 5)
+__printf(5, 6)
 int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch,
+                        bool (*will_handle)(struct xenbus_watch *,
+                                            const char *, const char *),
                         void (*callback)(struct xenbus_watch *,
                                          const char *, const char *),
                         const char *pathfmt, ...);