qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>, qemu-devel@nongnu.org
Cc: Cindy Lu <lulu@redhat.com>
Subject: Re: [PATCH 2/2] vhost-vdpa: improve error reporting
Date: Wed, 9 Sep 2020 09:53:17 +0800	[thread overview]
Message-ID: <38c8862b-e033-1b8c-33bd-5b1f0cd37a01@redhat.com> (raw)
In-Reply-To: <20200903185327.774708-3-lvivier@redhat.com>


On 2020/9/4 上午2:53, Laurent Vivier wrote:
> Use Error framework to report the id of the device and the details of
> the error (vhostdev name and errno).
>
> For instance:
>
>   qemu-system-x86_64 ... -netdev vhost-vdpa,id=hostnet1 ...
>   hostnet1: Cannot open '/dev/vhost-vdpa-0': No such file or directory
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>   net/vhost-vdpa.c | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)


Hi Laurent:

If you don't mind I will add this patch to v2 of my series[1]

Thanks

[1] 
https://lore.kernel.org/qemu-devel/20200831082737.10983-1-jasowang@redhat.com/


> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 24103ef241e4..8260902334ae 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -176,7 +176,8 @@ static NetClientInfo net_vhost_vdpa_info = {
>   };
>   
>   static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
> -                               const char *name, const char *vhostdev)
> +                               const char *name, const char *vhostdev,
> +                               Error **errp)
>   {
>       NetClientState *nc = NULL;
>       VhostVDPAState *s;
> @@ -189,11 +190,15 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
>       s = DO_UPCAST(VhostVDPAState, nc, nc);
>       vdpa_device_fd = qemu_open(vhostdev, O_RDWR);
>       if (vdpa_device_fd == -1) {
> -        return -errno;
> +        error_setg_errno(errp, errno, "%s: Cannot open '%s'", name, vhostdev);
> +        return -1;
>       }
>       s->vhost_vdpa.device_fd = vdpa_device_fd;
>       ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa);
> -    assert(s->vhost_net);
> +    if (ret == -1) {
> +        error_setg(errp, "%s: Cannot add vhost-vdpa '%s'", name, vhostdev);
> +        return -1;
> +    }
>       return ret;
>   }
>   
> @@ -229,5 +234,6 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
>       }
>       return net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
>                                  opts->has_vhostdev ?
> -                               opts->vhostdev : VHOST_VDPA_DEFAULT_VHOSTDEV);
> +                               opts->vhostdev : VHOST_VDPA_DEFAULT_VHOSTDEV,
> +                               errp);
>   }



  parent reply	other threads:[~2020-09-09  1:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 18:53 [PATCH 0/2] vhost-vdpa: improve parameters error management Laurent Vivier
2020-09-03 18:53 ` [PATCH 1/2] vhost-vdpa: define and use default value for vhostdev Laurent Vivier
2020-09-09  1:50   ` Jason Wang
2020-09-03 18:53 ` [PATCH 2/2] vhost-vdpa: improve error reporting Laurent Vivier
2020-09-04 13:41   ` Philippe Mathieu-Daudé
2020-09-09  1:53   ` Jason Wang [this message]
2020-09-09  8:45     ` Laurent Vivier
2020-09-04 13:24 ` [PATCH 0/2] vhost-vdpa: improve parameters error management no-reply
2020-09-04 13:28 ` no-reply

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=38c8862b-e033-1b8c-33bd-5b1f0cd37a01@redhat.com \
    --to=jasowang@redhat.com \
    --cc=lulu@redhat.com \
    --cc=lvivier@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).