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: qemu-stable@nongnu.org, lulu@redhat.com, mst@redhat.com
Subject: [PATCH 2/9] vhost-vdpa: mandate vhostdev
Date: Mon, 31 Aug 2020 16:27:30 +0800	[thread overview]
Message-ID: <20200831082737.10983-3-jasowang@redhat.com> (raw)
In-Reply-To: <20200831082737.10983-1-jasowang@redhat.com>

vhost-dev is mandatory for vhost-vdpa to be initialized otherwise
net_vhost_vdpa_init will pass an uninitialized pointer to qemu_open()
which will lead a SIGSEV:

#0  0x0000555555c3a640 in strstart (str=str@entry=0x0, val=val@entry=0x555555dbcb65 "/dev/fdset/", ptr=ptr@entry=0x7fffffffdfb8) at ../util/cutils.c:77
#1  0x0000555555c572a7 in qemu_open (name=name@entry=0x0, flags=flags@entry=2) at ../util/osdep.c:294
#2  0x000055555584314a in net_vhost_vdpa_init (device=0x555555c81baa "vhost-vdpa", vhostdev=0x0, name=0x555556396600 "hn0", peer=0x0) at ../net/vhost-vdpa.c:187
#3  0x000055555584314a in net_init_vhost_vdpa (netdev=<optimized out>, name=0x555556396600 "hn0", peer=0x0, errp=<optimized out>) at ../net/vhost-vdpa.c:227
#4  0x000055555587e8c9 in net_client_init1 (netdev=0x555556398790, is_netdev=is_netdev@entry=true, errp=errp@entry=0x7fffffffe290) at ../net/net.c:1008
#5  0x000055555587ecc7 in net_client_init (opts=0x555556192ff0, is_netdev=<optimized out>, errp=0x7fffffffe290) at ../net/net.c:1113
#6  0x0000555555c33082 in qemu_opts_foreach
    (list=<optimized out>, func=func@entry=0x55555587ed50 <net_init_netdev>, opaque=opaque@entry=0x0, errp=errp@entry=0x7fffffffe290) at ../util/qemu-option.c:1172
#7  0x0000555555880057 in net_init_clients (errp=errp@entry=0x7fffffffe290) at ../net/net.c:1494
#8  0x0000555555a7f8e9 in qemu_init (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at ../softmmu/vl.c:4250
#9  0x00005555557f26cd in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at ../softmmu/main.c:49

Cc: qemu-stable@nongnu.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/vhost-vdpa.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index bc0e0d2d35..b7221beaa1 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -206,7 +206,7 @@ static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp)
     }
     if (strcmp(netdev, name) == 0 &&
         !g_str_has_prefix(driver, "virtio-net-")) {
-        error_setg(errp, "vhost-vdpa requires frontend driver virtio-net-*");
+        error_setg(errp, "Vhost-vdpa requires frontend driver virtio-net-*");
         return -1;
     }
     return 0;
@@ -224,5 +224,9 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
                           (char *)name, errp)) {
         return -1;
     }
+    if (!opts->has_vhostdev) {
+        error_setg(errp, "vhost-vdpa requires vhostdev to be set");
+        return -1;
+    }
     return net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, opts->vhostdev);
 }
-- 
2.20.1



  parent reply	other threads:[~2020-08-31  8:29 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 ` Jason Wang [this message]
2020-09-09  8:42   ` [PATCH 2/9] vhost-vdpa: mandate vhostdev 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 ` [PATCH 7/9] vhost-vdpa: squash net_vhost_vdpa_init() into net_init_vhost_vdpa() Jason Wang
2020-09-16 15:58   ` 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-3-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=lulu@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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).