xen: when removing a backend don't remove many of them

When a Xenstore watch fires indicating a backend has to be removed
don't remove all backends for that domain with the specified device
index, but just the one which has the correct type.

The easiest way to achieve this is to use the already determined
xendev as parameter for xen_be_del_xendev() instead of only the domid
and device index.

This at once removes the open coded QTAILQ_FOREACH_SAVE() in
xen_be_del_xendev() as there is no need to search for the correct
xendev any longer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Message-id: 1470140044-16492-2-git-send-email-jgross@suse.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Juergen Gross 2016-08-02 14:14:03 +02:00 committed by Gerd Hoffmann
parent 72aa364b1d
commit c8e36e865c

View File

@ -321,26 +321,8 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
/*
* release xen backend device.
*/
static struct XenDevice *xen_be_del_xendev(int dom, int dev)
static void xen_be_del_xendev(struct XenDevice *xendev)
{
struct XenDevice *xendev, *xnext;
/*
* This is pretty much like QTAILQ_FOREACH(xendev, &xendevs, next) but
* we save the next pointer in xnext because we might free xendev.
*/
xnext = xendevs.tqh_first;
while (xnext) {
xendev = xnext;
xnext = xendev->next.tqe_next;
if (xendev->dom != dom) {
continue;
}
if (xendev->dev != dev && dev != -1) {
continue;
}
if (xendev->ops->free) {
xendev->ops->free(xendev);
}
@ -361,8 +343,6 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev)
QTAILQ_REMOVE(&xendevs, xendev, next);
g_free(xendev);
}
return NULL;
}
/*
@ -682,7 +662,7 @@ static void xenstore_update_be(char *watch, char *type, int dom,
if (xendev != NULL) {
bepath = xs_read(xenstore, 0, xendev->be, &len);
if (bepath == NULL) {
xen_be_del_xendev(dom, dev);
xen_be_del_xendev(xendev);
} else {
free(bepath);
xen_be_backend_changed(xendev, path);