diff options
author | Emil Condrea <emilcondrea@gmail.com> | 2016-10-25 08:50:12 +0300 |
---|---|---|
committer | Stefano Stabellini <sstabellini@kernel.org> | 2016-10-28 17:53:25 -0700 |
commit | 148512e062ec99acb06bfb1d559d7254d84403f9 (patch) | |
tree | 3656f069e76db5eadbb1c8ca645913fbeeb5e6df /hw/xen/xen_pvdev.c | |
parent | 31c17aa5c38d8aa177730b0c4429f8023f8ad79b (diff) | |
download | qemu-148512e062ec99acb06bfb1d559d7254d84403f9.zip |
xen: Prepare xendev qtail to be shared with frontends
* move xendevs qtail to xen_pvdev.c
* change xen_be_get_xendev to use a new function: xen_pv_insert_xendev
Signed-off-by: Emil Condrea <emilcondrea@gmail.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Quan Xu <xuquan8@huawei.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Diffstat (limited to 'hw/xen/xen_pvdev.c')
-rw-r--r-- | hw/xen/xen_pvdev.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index 7607e44c9a..96ed2a3c80 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -22,7 +22,11 @@ #include "hw/xen/xen_backend.h" #include "hw/xen/xen_pvdev.h" +/* private */ static int debug; +static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = + QTAILQ_HEAD_INITIALIZER(xendevs); + /* ------------------------------------------------------------- */ int xenstore_write_str(const char *base, const char *node, const char *val) @@ -206,3 +210,56 @@ int xen_be_send_notify(struct XenDevice *xendev) { return xenevtchn_notify(xendev->evtchndev, xendev->local_port); } + +/* ------------------------------------------------------------- */ + +struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev) +{ + struct XenDevice *xendev; + + QTAILQ_FOREACH(xendev, &xendevs, next) { + if (xendev->dom != dom) { + continue; + } + if (xendev->dev != dev) { + continue; + } + if (strcmp(xendev->type, type) != 0) { + continue; + } + return xendev; + } + return NULL; +} + +/* + * release xen backend device. + */ +void xen_be_del_xendev(struct XenDevice *xendev) +{ + 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->evtchndev != NULL) { + xenevtchn_close(xendev->evtchndev); + } + if (xendev->gnttabdev != NULL) { + xengnttab_close(xendev->gnttabdev); + } + + QTAILQ_REMOVE(&xendevs, xendev, next); + g_free(xendev); +} + +void xen_pv_insert_xendev(struct XenDevice *xendev) +{ + QTAILQ_INSERT_TAIL(&xendevs, xendev, next); +} |