[PATCH for 8.1 v2 4/6] vdpa: return errno in vhost_vdpa_get_vring_group error

Eugenio Pérez posted 6 patches 2 years, 10 months ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>
There is a newer version of this series
[PATCH for 8.1 v2 4/6] vdpa: return errno in vhost_vdpa_get_vring_group error
Posted by Eugenio Pérez 2 years, 10 months ago
We need to tell in the caller, as some errors are expected in a normal
workflow.  In particular, parent drivers in recent kernels with
VHOST_BACKEND_F_IOTLB_ASID may not support vring groups.  In that case,
-ENOTSUP is returned.

This is the case of vp_vdpa in Linux 6.2.

Next patches in this series will use that information to know if it must
abort or not.  Also, next patches return properly an errp instead of
printing with error_report.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 net/vhost-vdpa.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 99904a0da7..4397c0d4b3 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -361,6 +361,14 @@ static NetClientInfo net_vhost_vdpa_info = {
         .check_peer_type = vhost_vdpa_check_peer_type,
 };
 
+/**
+ * Get vring virtqueue group
+ *
+ * @device_fd  vdpa device fd
+ * @vq_index   Virtqueue index
+ *
+ * Return -errno in case of error, or vq group if success.
+ */
 static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index)
 {
     struct vhost_vring_state state = {
@@ -369,6 +377,7 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index)
     int r = ioctl(device_fd, VHOST_VDPA_GET_VRING_GROUP, &state);
 
     if (unlikely(r < 0)) {
+        r = -errno;
         error_report("Cannot get VQ %u group: %s", vq_index,
                      g_strerror(errno));
         return r;
-- 
2.31.1


Re: [PATCH for 8.1 v2 4/6] vdpa: return errno in vhost_vdpa_get_vring_group error
Posted by Jason Wang 2 years, 10 months ago
On Fri, Mar 24, 2023 at 3:54 AM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> We need to tell in the caller, as some errors are expected in a normal
> workflow.  In particular, parent drivers in recent kernels with
> VHOST_BACKEND_F_IOTLB_ASID may not support vring groups.  In that case,
> -ENOTSUP is returned.
>
> This is the case of vp_vdpa in Linux 6.2.
>
> Next patches in this series will use that information to know if it must
> abort or not.  Also, next patches return properly an errp instead of
> printing with error_report.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks

> ---
>  net/vhost-vdpa.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 99904a0da7..4397c0d4b3 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -361,6 +361,14 @@ static NetClientInfo net_vhost_vdpa_info = {
>          .check_peer_type = vhost_vdpa_check_peer_type,
>  };
>
> +/**
> + * Get vring virtqueue group
> + *
> + * @device_fd  vdpa device fd
> + * @vq_index   Virtqueue index
> + *
> + * Return -errno in case of error, or vq group if success.
> + */
>  static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index)
>  {
>      struct vhost_vring_state state = {
> @@ -369,6 +377,7 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index)
>      int r = ioctl(device_fd, VHOST_VDPA_GET_VRING_GROUP, &state);
>
>      if (unlikely(r < 0)) {
> +        r = -errno;
>          error_report("Cannot get VQ %u group: %s", vq_index,
>                       g_strerror(errno));
>          return r;
> --
> 2.31.1
>
Re: [PATCH for 8.1 v2 4/6] vdpa: return errno in vhost_vdpa_get_vring_group error
Posted by Stefano Garzarella 2 years, 10 months ago
On Thu, Mar 23, 2023 at 08:54:02PM +0100, Eugenio Pérez wrote:
>We need to tell in the caller, as some errors are expected in a normal
>workflow.  In particular, parent drivers in recent kernels with
>VHOST_BACKEND_F_IOTLB_ASID may not support vring groups.  In that case,
>-ENOTSUP is returned.
>
>This is the case of vp_vdpa in Linux 6.2.
>
>Next patches in this series will use that information to know if it must
>abort or not.  Also, next patches return properly an errp instead of
>printing with error_report.
>
>Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
>---
> net/vhost-vdpa.c | 9 +++++++++
> 1 file changed, 9 insertions(+)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
>index 99904a0da7..4397c0d4b3 100644
>--- a/net/vhost-vdpa.c
>+++ b/net/vhost-vdpa.c
>@@ -361,6 +361,14 @@ static NetClientInfo net_vhost_vdpa_info = {
>         .check_peer_type = vhost_vdpa_check_peer_type,
> };
>
>+/**
>+ * Get vring virtqueue group
>+ *
>+ * @device_fd  vdpa device fd
>+ * @vq_index   Virtqueue index
>+ *
>+ * Return -errno in case of error, or vq group if success.
>+ */
> static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index)
> {
>     struct vhost_vring_state state = {
>@@ -369,6 +377,7 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index)
>     int r = ioctl(device_fd, VHOST_VDPA_GET_VRING_GROUP, &state);
>
>     if (unlikely(r < 0)) {
>+        r = -errno;
>         error_report("Cannot get VQ %u group: %s", vq_index,
>                      g_strerror(errno));
>         return r;
>-- 
>2.31.1
>