[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v9 2/5] generic vhost user server
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v9 2/5] generic vhost user server |
Date: |
Fri, 19 Jun 2020 13:13:00 +0100 |
On Mon, Jun 15, 2020 at 02:39:04AM +0800, Coiby Xu wrote:
> +/*
> + * a wrapper for vu_kick_cb
> + *
> + * since aio_dispatch can only pass one user data pointer to the
> + * callback function, pack VuDev and pvt into a struct. Then unpack it
> + * and pass them to vu_kick_cb
> + */
> +static void kick_handler(void *opaque)
> +{
> + KickInfo *kick_info = opaque;
> + kick_info->cb(kick_info->vu_dev, 0, (void *) kick_info->index);
Where is kick_info->index assigned? It appears to be NULL in all cases.
> +}
> +
> +
> +static void
> +set_watch(VuDev *vu_dev, int fd, int vu_evt,
> + vu_watch_cb cb, void *pvt)
> +{
> +
> + VuServer *server = container_of(vu_dev, VuServer, vu_dev);
> + g_assert(vu_dev);
> + g_assert(fd >= 0);
> + long index = (intptr_t) pvt;
The meaning of the pvt argument is not defined in the library interface.
set_watch() callbacks shouldn't interpret pvt.
You could modify libvhost-user to explicitly pass the virtqueue index
(or -1 if the fd is not associated with a virtqueue), but it's nice to
avoid libvhost-user API changes so that existing libvhost-user
applications don't require modifications.
What I would do here is to change the ->kick_info[] data struct. How
about a linked list of VuFdWatch objects? That way the code can handle
any number of fd watches and doesn't make assumptions about virtqueues.
set_watch() is a generic fd monitoring interface and doesn't need to be
tied to virtqueues.
signature.asc
Description: PGP signature
- [PATCH v9 1/5] Allow vu_message_read to be replaced, (continued)
- [PATCH v9 1/5] Allow vu_message_read to be replaced, Coiby Xu, 2020/06/14
- [PATCH v9 2/5] generic vhost user server, Coiby Xu, 2020/06/14
- Re: [PATCH v9 2/5] generic vhost user server, Kevin Wolf, 2020/06/18
- [PATCH 1/6] vhost-user-server: fix VHOST_MEMORY_MAX_REGIONS compiler error, Stefan Hajnoczi, 2020/06/19
- [PATCH 3/6] vhost-user-server: adjust vhost_user_server_set_aio_context() arguments, Stefan Hajnoczi, 2020/06/19
- [PATCH 2/6] vhost-user-server: drop unused #include <eventfd.h>, Stefan Hajnoczi, 2020/06/19
- [PATCH 5/6] vhost-user-server: fix s/initialized/initialize/ typo, Stefan Hajnoczi, 2020/06/19
- [PATCH 6/6] vhost-user-server: use DevicePanicNotifierFn everywhere, Stefan Hajnoczi, 2020/06/19
- [PATCH 4/6] vhost-user-server: mark fd handlers "external", Stefan Hajnoczi, 2020/06/19
- Re: [PATCH v9 2/5] generic vhost user server,
Stefan Hajnoczi <=
- [PATCH v9 3/5] move logical block size check function to a common utility function, Coiby Xu, 2020/06/14
- Re: [PATCH v9 3/5] move logical block size check function to a common utility function, Kevin Wolf, 2020/06/18
- [PATCH 1/6] block-helpers: move MIN/MAX_BLOCK_SIZE constants into header file, Stefan Hajnoczi, 2020/06/19
- [PATCH 2/6] block-helpers: switch to int64_t block size values, Stefan Hajnoczi, 2020/06/19
- [PATCH 3/6] block-helpers: rename check_logical_block_size() to check_block_size(), Stefan Hajnoczi, 2020/06/19
- [PATCH 4/6] block-helpers: use local_err in case errp is NULL, Stefan Hajnoczi, 2020/06/19
- [PATCH 5/6] block-helpers: keep the copyright line from the original file, Stefan Hajnoczi, 2020/06/19
- [PATCH 6/6] block-helpers: update doc comment in gtkdoc style, Stefan Hajnoczi, 2020/06/19
- [PATCH v9 4/5] vhost-user block device backend server, Coiby Xu, 2020/06/14