From patchwork Wed Aug 3 13:05:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9261231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EC05B6048B for ; Wed, 3 Aug 2016 13:08:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD453284A6 for ; Wed, 3 Aug 2016 13:08:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1E7628580; Wed, 3 Aug 2016 13:08:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E56F6284A6 for ; Wed, 3 Aug 2016 13:08:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUvry-0005TE-Fa; Wed, 03 Aug 2016 13:05:58 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUvrx-0005Sx-4P for xen-devel@lists.xensource.com; Wed, 03 Aug 2016 13:05:57 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 43/F3-07858-43CE1A75; Wed, 03 Aug 2016 13:05:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVysWW7jK7xm4X hBnv26lvcm/Ke3YHRY3vfLvYAxijWzLyk/IoE1oytS5oYCx5IVuy80sfcwLhNuIuRk0NIYDeT xL6/GhD2eUaJ2f1ZEHaZxO6FE9lBbDYBdYkzsw+zgtgiApISv7tOM3cxcnEwCzxjlPi97jobS EJYwEuifelZZhCbRUBV4umb1WA2r4CjxMfnn8EGcQo4Sbx5cJQZYoGjxLLZy1hAbAkBbYmGWZ NZQIZKCPQxShxdtIFtAiPvAkaGVYzqxalFZalFusZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTm JScV6yfm5mxiB4cAABDsYO/45HWKU5GBSEuWdeHBhuBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ 3tuvgHKCRanpqRVpmTnAwIRJS3DwKInwFoOkeYsLEnOLM9MhUqcYdTmW7HqwlkmIJS8/L1VKn JfnNVCRAEhRRmke3AhYlFxilJUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMO8EkFU8mXklcJteAR 3BBHTECYMFIEeUJCKkpBoYfeT7jN8f5O3PPzhv/izLJe7lPo/yvxXuty/nuVatcC3aunrX44O Fjb9P9e6wdree3vTz/df4avmuLS8mL53ZdL830Epe9yKrYkjUB+6uZkGZqXw3jtet8Lx+5vyU oENO9Zbt2U0r+dYtzfMMKZF806hU2BMw3cO3/v9S5lf5jgknDijzvixQYinOSDTUYi4qTgQA6 JCVz40CAAA= X-Env-Sender: kraxel@redhat.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1470229554!27011706!1 X-Originating-IP: [209.132.183.28] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMjA5LjEzMi4xODMuMjggPT4gNTQwNjQ=\n X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25791 invoked from network); 3 Aug 2016 13:05:55 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 Aug 2016 13:05:55 -0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B1081556C; Wed, 3 Aug 2016 13:05:53 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u73D5qNv014993; Wed, 3 Aug 2016 09:05:52 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id A543980FC9; Wed, 3 Aug 2016 15:05:51 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 3 Aug 2016 15:05:47 +0200 Message-Id: <1470229549-32477-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1470229549-32477-1-git-send-email-kraxel@redhat.com> References: <1470229549-32477-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 03 Aug 2016 13:05:53 +0000 (UTC) Cc: Juergen Gross , Anthony Perard , Stefano Stabellini , Gerd Hoffmann , "open list:X86" Subject: [Xen-devel] [PULL 4/6] xen: when removing a backend don't remove many of them X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Juergen Gross 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 Reviewed-by: Stefano Stabellini Message-id: 1470140044-16492-2-git-send-email-jgross@suse.com Signed-off-by: Gerd Hoffmann --- hw/xen/xen_backend.c | 58 +++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index bab79b1..3ceb778 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -321,48 +321,28 @@ 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); - } - - if (xendev->fe) { - char token[XEN_BUFSIZE]; - snprintf(token, sizeof(token), "fe:%p", xendev); - xs_unwatch(xenstore, xendev->fe, token); - g_free(xendev->fe); - } + if (xendev->ops->free) { + xendev->ops->free(xendev); + } - if (xendev->evtchndev != NULL) { - xenevtchn_close(xendev->evtchndev); - } - if (xendev->gnttabdev != NULL) { - xengnttab_close(xendev->gnttabdev); - } + if (xendev->fe) { + char token[XEN_BUFSIZE]; + snprintf(token, sizeof(token), "fe:%p", xendev); + xs_unwatch(xenstore, xendev->fe, token); + g_free(xendev->fe); + } - QTAILQ_REMOVE(&xendevs, xendev, next); - g_free(xendev); + if (xendev->evtchndev != NULL) { + xenevtchn_close(xendev->evtchndev); } - return NULL; + if (xendev->gnttabdev != NULL) { + xengnttab_close(xendev->gnttabdev); + } + + QTAILQ_REMOVE(&xendevs, xendev, next); + g_free(xendev); } /* @@ -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);