Skip to contentSkip to conversation

vdpa: Check for existence of opts.vhostdev

PATCH In review Eugenio Pérez 2 participants 5 messages Nov 12, 2021 – Nov 15, 2021 Networking

lore
Share & tools
lore
#0 lore raw

cover vdpa: Check for existence of opts.vhostdev

Since net_init_vhost_vdpa is trying to open it. Not specifying it in the command line crash qemu.

While we're at it, stop using qemu_open_old.

Eugenio Pérez (2):
vdpa: Replace qemu_open_old by qemu_open at
vdpa: Check for existence of opts.vhostdev

 net/vhost-vdpa.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/2 vdpa: Replace qemu_open_old by qemu_open at

There is no reason to keep using the old one, since we neither use the variadics arguments nor open it with O_DIRECT.

Also, net_client_init1, the caller of net_init_vhost_vdpa, wants all net_client_init_fun to use Error API, so it's a good step in that direction.

---
 net/vhost-vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/vhost-vdpa.c +1 -1
index 49ab322511..6ffb29f4da 100644
@@ -261,7 +261,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
     assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
     opts = &netdev->u.vhost_vdpa;
 
-    vdpa_device_fd = qemu_open_old(opts->vhostdev, O_RDWR);
+    vdpa_device_fd = qemu_open(opts->vhostdev, O_RDWR, errp);
     if (vdpa_device_fd == -1) {
         return -errno;
     }
Signature · 1 line
2.27.0
#3 lore raw

PATCH 2/2 vdpa: Check for existence of opts.vhostdev

In reply to Eugenio Pérez

Since net_init_vhost_vdpa is trying to open it. Not specifying it in the command line crash qemu.

Fixes 7327813d17 ("vhost-vdpa: open device fd in net_init_vhost_vdpa()")
---
 net/vhost-vdpa.c | 4 ++++
 1 file changed, 4 insertions(+)
net/vhost-vdpa.c +4 -0
index 6ffb29f4da..bbd3576f23 100644
@@ -260,6 +260,10 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
 
     assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
     opts = &netdev->u.vhost_vdpa;
+    if (!opts->vhostdev) {
+        error_setg(errp, "vdpa character device not specified with vhostdev");
+        return -1;
+    }
 
     vdpa_device_fd = qemu_open(opts->vhostdev, O_RDWR, errp);
     if (vdpa_device_fd == -1) {
Signature · 1 line
2.27.0
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] vdpa: Replace qemu_open_old by qemu_open at

In reply to Eugenio Pérez
Quoted 9 lines · Eugenio Pérez

There is no reason to keep using the old one, since we neither use the variadics arguments nor open it with O_DIRECT.

Also, net_client_init1, the caller of net_init_vhost_vdpa, wants all net_client_init_fun to use Error API, so it's a good step in that direction.

Quoted 20 lines
---
 net/vhost-vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/vhost-vdpa.c +1 -2
index 49ab322511..6ffb29f4da 100644
@@ -261,7 +261,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
     assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
     opts = &netdev->u.vhost_vdpa;
 
-    vdpa_device_fd = qemu_open_old(opts->vhostdev, O_RDWR);
+    vdpa_device_fd = qemu_open(opts->vhostdev, O_RDWR, errp);
     if (vdpa_device_fd == -1) {
         return -errno;
     }
--

2.27.0

Acked-by on v1 2/2
#4 lore raw
In reply to Eugenio Pérez
Quoted 6 lines · Eugenio Pérez

Since net_init_vhost_vdpa is trying to open it. Not specifying it in the command line crash qemu.

Fixes 7327813d17 ("vhost-vdpa: open device fd in net_init_vhost_vdpa()")
Quoted 22 lines
---
 net/vhost-vdpa.c | 4 ++++
 1 file changed, 4 insertions(+)
net/vhost-vdpa.c +4 -1
index 6ffb29f4da..bbd3576f23 100644
@@ -260,6 +260,10 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
 
     assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
     opts = &netdev->u.vhost_vdpa;
+    if (!opts->vhostdev) {
+        error_setg(errp, "vdpa character device not specified with vhostdev");
+        return -1;
+    }
 
     vdpa_device_fd = qemu_open(opts->vhostdev, O_RDWR, errp);
     if (vdpa_device_fd == -1) {
--

2.27.0