qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: jasowang@redhat.com, qemu-devel@nongnu.org
Cc: lulu@redhat.com, mst@redhat.com
Subject: [PATCH 7/9] vhost-vdpa: squash net_vhost_vdpa_init() into net_init_vhost_vdpa()
Date: Mon, 31 Aug 2020 16:27:35 +0800	[thread overview]
Message-ID: <20200831082737.10983-8-jasowang@redhat.com> (raw)
In-Reply-To: <20200831082737.10983-1-jasowang@redhat.com>

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;
 }
-- 
2.20.1



  parent reply	other threads:[~2020-08-31  8:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31  8:27 [PATCH 0/9] refine vhost-vdpa initialization Jason Wang
2020-08-31  8:27 ` [PATCH 1/9] vhost-vdpa: remove the default devname Jason Wang
2020-09-09  8:40   ` Laurent Vivier
2020-08-31  8:27 ` [PATCH 2/9] vhost-vdpa: mandate vhostdev Jason Wang
2020-09-09  8:42   ` Laurent Vivier
2020-08-31  8:27 ` [PATCH 3/9] vhost-vdpa: remove the unnecessary assert(s->vhost_net) Jason Wang
2020-08-31  8:27 ` [PATCH 4/9] vhost-vdpa: refine info string Jason Wang
2020-09-16 15:52   ` Laurent Vivier
2020-08-31  8:27 ` [PATCH 5/9] vhost-vdpa: remove the unnecessary initialization Jason Wang
2020-09-16 15:53   ` Laurent Vivier
2020-08-31  8:27 ` [PATCH 6/9] vhost-vdpa: remove the unnecessary queue index assignment Jason Wang
2020-09-16 15:54   ` Laurent Vivier
2020-08-31  8:27 ` Jason Wang [this message]
2020-09-16 15:58   ` [PATCH 7/9] vhost-vdpa: squash net_vhost_vdpa_init() into net_init_vhost_vdpa() Laurent Vivier
2020-08-31  8:27 ` [PATCH 8/9] vhost-vdpa: add accurate error string when fail to open vhost vDPA device Jason Wang
2020-09-16 16:09   ` Laurent Vivier
2020-08-31  8:27 ` [PATCH 9/9] vhost-vdpa: allow pre-opend file descriptor Jason Wang
2020-08-31 11:16   ` Cindy Lu
2020-09-01  6:53     ` Jason Wang
2020-09-16 16:04     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200831082737.10983-8-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=lulu@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).