[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 7/9] vhost-vdpa: squash net_vhost_vdpa_init() into net_init_v
From: |
Laurent Vivier |
Subject: |
Re: [PATCH 7/9] vhost-vdpa: squash net_vhost_vdpa_init() into net_init_vhost_vdpa() |
Date: |
Wed, 16 Sep 2020 17:58:50 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
On 31/08/2020 10:27, Jason Wang wrote:
> This patch squashes net_vhost_vdpa_init() into
> net_init_vhost_vdpa(). This will simplify adding pre open file
> descriptor support.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> net/vhost-vdpa.c | 41 +++++++++++++++++++----------------------
> 1 file changed, 19 insertions(+), 22 deletions(-)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 1d3ac89135..f5cc4e8326 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -172,27 +172,6 @@ static NetClientInfo net_vhost_vdpa_info = {
> .has_ufo = vhost_vdpa_has_ufo,
> };
>
> -static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
> - const char *name, const char *vhostdev)
> -{
> - NetClientState *nc;
> - VhostVDPAState *s;
> - int vdpa_device_fd;
> - int ret;
> - assert(name);
> - nc = qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name);
> - snprintf(nc->info_str, sizeof(nc->info_str), "vhostdev=%s", vhostdev);
> - s = DO_UPCAST(VhostVDPAState, nc, nc);
> - vdpa_device_fd = qemu_open(vhostdev, O_RDWR);
> - if (vdpa_device_fd == -1) {
> - return -errno;
> - }
> - s->vhost_vdpa.device_fd = vdpa_device_fd;
> - ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa);
> -
> - return ret;
> -}
> -
> static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp)
> {
> const char *name = opaque;
> @@ -215,6 +194,10 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char
> *name,
> NetClientState *peer, Error **errp)
> {
> const NetdevVhostVDPAOptions *opts;
> + NetClientState *nc;
> + VhostVDPAState *s;
> + int vdpa_device_fd;
> + int ret;
>
> assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
> opts = &netdev->u.vhost_vdpa;
> @@ -227,5 +210,19 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char
> *name,
> error_setg(errp, "vhost-vdpa requires vhostdev to be set");
> return -1;
> }
> - return net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, opts->vhostdev);
> +
> + assert(name);
> +
> + nc = qemu_new_net_client(&net_vhost_vdpa_info, peer, TYPE_VHOST_VDPA,
> name);
> + snprintf(nc->info_str, sizeof(nc->info_str), "vhostdev=%s",
> opts->vhostdev);
> +
> + s = DO_UPCAST(VhostVDPAState, nc, nc);
> + vdpa_device_fd = qemu_open(opts->vhostdev, O_RDWR);
> + if (vdpa_device_fd == -1) {
> + return -errno;
> + }
> + s->vhost_vdpa.device_fd = vdpa_device_fd;
> + ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa);
> +
> + return ret;
You can avoid to declare and use "ret" by doing directly
"return vhost_vdpa_add()"
Anyway, the code move is correct:
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH 7/9] vhost-vdpa: squash net_vhost_vdpa_init() into net_init_vhost_vdpa(),
Laurent Vivier <=