vdpa: Check for existence of opts.vhostdev
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
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
@@ -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
PATCH 2/2 vdpa: Check for existence of opts.vhostdev
In reply to Eugenio PérezSince net_init_vhost_vdpa is trying to open it. Not specifying it in the command line crash qemu.
--- net/vhost-vdpa.c | 4 ++++ 1 file changed, 4 insertions(+)
net/vhost-vdpa.c +4 -0
@@ -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
Re: [PATCH 1/2] vdpa: Replace qemu_open_old by qemu_open at
In reply to Eugenio PérezQuoted 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 ofnet_init_vhost_vdpa, wants allnet_client_init_funto use Error API, so it's a good step in that direction.Signed-off-by Eugenio Pérez <[email protected]>
Quoted 20 lines
--- net/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/vhost-vdpa.c +1
-2@@ -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
Quoted 6 lines · Eugenio Pérez
Since
net_init_vhost_vdpais 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()")Signed-off-by Eugenio Pérez <[email protected]>
Quoted 22 lines
--- net/vhost-vdpa.c | 4 ++++ 1 file changed, 4 insertions(+)net/vhost-vdpa.c +4
-1@@ -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