[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/20] nbd: correctly propagate errors
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH 02/20] nbd: correctly propagate errors |
Date: |
Mon, 10 Feb 2014 17:11:29 +0800 |
User-agent: |
Mutt/1.5.22 (2013-10-16) |
On Mon, 02/10 09:24, Paolo Bonzini wrote:
> Il 10/02/2014 08:38, Fam Zheng ha scritto:
> >>> if (s->client.is_unix) {
> >>> - sock = unix_socket_outgoing(qemu_opt_get(s->socket_opts,
> >>> "path"));
> >>> + sock = unix_connect(qemu_opt_get(s->socket_opts, "path"), errp);
> >Why not use unix_connect_opts like below?
>
> Right!
>
> >>> } else {
> >>> - sock = tcp_socket_outgoing_opts(s->socket_opts);
> >>> + sock = inet_connect_opts(s->socket_opts, errp, NULL, NULL);
> >>> if (sock >= 0) {
> >>> socket_set_nodelay(sock);
> >>> }
> >>> @@ -255,17 +251,19 @@ static int nbd_open(BlockDriverState *bs, QDict
> >>> *options, int flags,
> >>> BDRVNBDState *s = bs->opaque;
> >>> char *export = NULL;
> >>> int result, sock;
> >>> + Error *local_err = NULL;
> >>>
> >>> /* Pop the config into our state object. Exit if invalid. */
> >>> - result = nbd_config(s, options, &export);
> >>> - if (result != 0) {
> >>> - return result;
> >>> + nbd_config(s, options, &export, &local_err);
> >>> + if (local_err) {
> >Isn't error_is_set() better here?
>
> No, error_is_set(&foo) is the same as foo != NULL.
>
> So we use error_is_set only with Error**, which really should never happen
> because you miss errors if the errp is NULL. :)
>
Clear! Thanks for the explanation!
Fam
- [Qemu-devel] [PATCH 00/20] Improve bdrv_open error messages, Paolo Bonzini, 2014/02/09
- [Qemu-devel] [PATCH 03/20] nbd: inline tcp_socket_incoming_spec into sole caller, Paolo Bonzini, 2014/02/09
- [Qemu-devel] [PATCH 09/20] cow: correctly propagate errors, Paolo Bonzini, 2014/02/09
- [Qemu-devel] [PATCH 04/20] nbd: move socket wrappers to qemu-nbd, Paolo Bonzini, 2014/02/09
- [Qemu-devel] [PATCH 05/20] iscsi: fix indentation, Paolo Bonzini, 2014/02/09
- [Qemu-devel] [PATCH 06/20] iscsi: correctly propagate errors in iscsi_open, Paolo Bonzini, 2014/02/09