* [Qemu-devel] [PATCH] sheepdog: Set error when connection fails @ 2017-04-20 4:00 Fam Zheng 2017-04-20 9:12 ` Philippe Mathieu-Daudé ` (3 more replies) 0 siblings, 4 replies; 14+ messages in thread From: Fam Zheng @ 2017-04-20 4:00 UTC (permalink / raw) To: qemu-devel Cc: sheepdog, qemu-block, Hitoshi Mitake, Kevin Wolf, Max Reitz, Jeff Cody, Liu Yuan Signed-off-by: Fam Zheng <famz@redhat.com> --- block/sheepdog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/sheepdog.c b/block/sheepdog.c index fb9203e..7e889ee 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) qemu_set_nonblock(fd); } else { fd = -EIO; + error_setg(errp, "Failed to connect to sheepdog server"); } return fd; -- 2.9.3 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 4:00 [Qemu-devel] [PATCH] sheepdog: Set error when connection fails Fam Zheng @ 2017-04-20 9:12 ` Philippe Mathieu-Daudé 2017-04-20 15:21 ` Jeff Cody ` (2 subsequent siblings) 3 siblings, 0 replies; 14+ messages in thread From: Philippe Mathieu-Daudé @ 2017-04-20 9:12 UTC (permalink / raw) To: Fam Zheng, qemu-devel Cc: Kevin Wolf, sheepdog, qemu-block, Hitoshi Mitake, Jeff Cody, Max Reitz, Liu Yuan On 04/20/2017 01:00 AM, Fam Zheng wrote: > Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > block/sheepdog.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/block/sheepdog.c b/block/sheepdog.c > index fb9203e..7e889ee 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > qemu_set_nonblock(fd); > } else { > fd = -EIO; > + error_setg(errp, "Failed to connect to sheepdog server"); > } > > return fd; > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 4:00 [Qemu-devel] [PATCH] sheepdog: Set error when connection fails Fam Zheng 2017-04-20 9:12 ` Philippe Mathieu-Daudé @ 2017-04-20 15:21 ` Jeff Cody 2017-04-20 15:23 ` Jeff Cody 2017-04-20 15:30 ` Daniel P. Berrange 3 siblings, 0 replies; 14+ messages in thread From: Jeff Cody @ 2017-04-20 15:21 UTC (permalink / raw) To: Fam Zheng Cc: qemu-devel, sheepdog, qemu-block, Hitoshi Mitake, Kevin Wolf, Max Reitz, Liu Yuan On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > block/sheepdog.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/block/sheepdog.c b/block/sheepdog.c > index fb9203e..7e889ee 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > qemu_set_nonblock(fd); > } else { > fd = -EIO; > + error_setg(errp, "Failed to connect to sheepdog server"); > } A bit odd that we don't just return right away in this function after a failed called to socket_connect(), but that has nothing to do with your patch. Reviewed-by: Jeff Cody <jcody@redhat.com> > > return fd; > -- > 2.9.3 > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 4:00 [Qemu-devel] [PATCH] sheepdog: Set error when connection fails Fam Zheng 2017-04-20 9:12 ` Philippe Mathieu-Daudé 2017-04-20 15:21 ` Jeff Cody @ 2017-04-20 15:23 ` Jeff Cody 2017-04-20 15:30 ` Daniel P. Berrange 3 siblings, 0 replies; 14+ messages in thread From: Jeff Cody @ 2017-04-20 15:23 UTC (permalink / raw) To: Fam Zheng Cc: qemu-devel, sheepdog, qemu-block, Hitoshi Mitake, Kevin Wolf, Max Reitz, Liu Yuan On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > block/sheepdog.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/block/sheepdog.c b/block/sheepdog.c > index fb9203e..7e889ee 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > qemu_set_nonblock(fd); > } else { > fd = -EIO; > + error_setg(errp, "Failed to connect to sheepdog server"); > } > > return fd; > -- > 2.9.3 > Thanks, Applied to my block branch: git://github.com/codyprime/qemu-kvm-jtc block -Jeff ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 4:00 [Qemu-devel] [PATCH] sheepdog: Set error when connection fails Fam Zheng ` (2 preceding siblings ...) 2017-04-20 15:23 ` Jeff Cody @ 2017-04-20 15:30 ` Daniel P. Berrange 2017-04-20 15:42 ` Jeff Cody 2017-04-20 20:32 ` Kevin Wolf 3 siblings, 2 replies; 14+ messages in thread From: Daniel P. Berrange @ 2017-04-20 15:30 UTC (permalink / raw) To: Fam Zheng Cc: qemu-devel, Kevin Wolf, sheepdog, qemu-block, Hitoshi Mitake, Jeff Cody, Max Reitz, Liu Yuan On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > block/sheepdog.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/block/sheepdog.c b/block/sheepdog.c > index fb9203e..7e889ee 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > qemu_set_nonblock(fd); > } else { > fd = -EIO; > + error_setg(errp, "Failed to connect to sheepdog server"); > } This doesn't make much sense to me. The lines just above the diff context have this: fd = socket_connect(s->addr, errp, NULL, NULL); socket_connect should have already reported an error on "errp" in the scenario that 'fd == -1'. So AFAICT the new error_setg is just throwing away the real detailed error message in favour of a generic message. So I'm puzzelled why we need to change anything - error reporting should already be working fine. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 15:30 ` Daniel P. Berrange @ 2017-04-20 15:42 ` Jeff Cody 2017-04-20 15:45 ` Daniel P. Berrange 2017-04-20 20:32 ` Kevin Wolf 1 sibling, 1 reply; 14+ messages in thread From: Jeff Cody @ 2017-04-20 15:42 UTC (permalink / raw) To: Daniel P. Berrange Cc: Fam Zheng, qemu-devel, Kevin Wolf, sheepdog, qemu-block, Hitoshi Mitake, Max Reitz, Liu Yuan On Thu, Apr 20, 2017 at 04:30:16PM +0100, Daniel P. Berrange wrote: > On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > > Signed-off-by: Fam Zheng <famz@redhat.com> > > --- > > block/sheepdog.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/block/sheepdog.c b/block/sheepdog.c > > index fb9203e..7e889ee 100644 > > --- a/block/sheepdog.c > > +++ b/block/sheepdog.c > > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > > qemu_set_nonblock(fd); > > } else { > > fd = -EIO; > > + error_setg(errp, "Failed to connect to sheepdog server"); > > } > > This doesn't make much sense to me. The lines just above the > diff context have this: > > fd = socket_connect(s->addr, errp, NULL, NULL); > > socket_connect should have already reported an error on "errp" > in the scenario that 'fd == -1'. So AFAICT the new error_setg is > just throwing away the real detailed error message in favour of > a generic message. > > So I'm puzzelled why we need to change anything - error reporting > should already be working fine. > Indeed, you are right. (Dequeuing patch) It would also make more sense to check fd after the socket_connect() call and return error then, rather than keep checking fd throughout the rest of the function. -Jeff ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 15:42 ` Jeff Cody @ 2017-04-20 15:45 ` Daniel P. Berrange 0 siblings, 0 replies; 14+ messages in thread From: Daniel P. Berrange @ 2017-04-20 15:45 UTC (permalink / raw) To: Jeff Cody Cc: Fam Zheng, qemu-devel, Kevin Wolf, sheepdog, qemu-block, Hitoshi Mitake, Max Reitz, Liu Yuan On Thu, Apr 20, 2017 at 11:42:00AM -0400, Jeff Cody wrote: > On Thu, Apr 20, 2017 at 04:30:16PM +0100, Daniel P. Berrange wrote: > > On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > > > Signed-off-by: Fam Zheng <famz@redhat.com> > > > --- > > > block/sheepdog.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/block/sheepdog.c b/block/sheepdog.c > > > index fb9203e..7e889ee 100644 > > > --- a/block/sheepdog.c > > > +++ b/block/sheepdog.c > > > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > > > qemu_set_nonblock(fd); > > > } else { > > > fd = -EIO; > > > + error_setg(errp, "Failed to connect to sheepdog server"); > > > } > > > > This doesn't make much sense to me. The lines just above the > > diff context have this: > > > > fd = socket_connect(s->addr, errp, NULL, NULL); > > > > socket_connect should have already reported an error on "errp" > > in the scenario that 'fd == -1'. So AFAICT the new error_setg is > > just throwing away the real detailed error message in favour of > > a generic message. > > > > So I'm puzzelled why we need to change anything - error reporting > > should already be working fine. > > > > Indeed, you are right. (Dequeuing patch) > > It would also make more sense to check fd after the socket_connect() call > and return error then, rather than keep checking fd throughout the rest of > the function. Yeah that would make it much more obvious that the error reporting is correct. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 15:30 ` Daniel P. Berrange 2017-04-20 15:42 ` Jeff Cody @ 2017-04-20 20:32 ` Kevin Wolf 2017-04-20 20:40 ` Jeff Cody ` (2 more replies) 1 sibling, 3 replies; 14+ messages in thread From: Kevin Wolf @ 2017-04-20 20:32 UTC (permalink / raw) To: Daniel P. Berrange Cc: Fam Zheng, qemu-devel, sheepdog, qemu-block, Hitoshi Mitake, Jeff Cody, Max Reitz, Liu Yuan Am 20.04.2017 um 17:30 hat Daniel P. Berrange geschrieben: > On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > > Signed-off-by: Fam Zheng <famz@redhat.com> > > --- > > block/sheepdog.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/block/sheepdog.c b/block/sheepdog.c > > index fb9203e..7e889ee 100644 > > --- a/block/sheepdog.c > > +++ b/block/sheepdog.c > > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > > qemu_set_nonblock(fd); > > } else { > > fd = -EIO; > > + error_setg(errp, "Failed to connect to sheepdog server"); > > } > > This doesn't make much sense to me. The lines just above the > diff context have this: > > fd = socket_connect(s->addr, errp, NULL, NULL); > > socket_connect should have already reported an error on "errp" > in the scenario that 'fd == -1'. By the way, am I the only one who thinks that having errp anywhere else than as the last argument is bad style? I can easily see myself missing that this functions sets it because the last argument is NULL. Kevin ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 20:32 ` Kevin Wolf @ 2017-04-20 20:40 ` Jeff Cody 2017-04-21 0:19 ` Fam Zheng 2017-04-21 5:43 ` Markus Armbruster 2 siblings, 0 replies; 14+ messages in thread From: Jeff Cody @ 2017-04-20 20:40 UTC (permalink / raw) To: Kevin Wolf Cc: Daniel P. Berrange, Fam Zheng, qemu-devel, sheepdog, qemu-block, Hitoshi Mitake, Max Reitz, Liu Yuan On Thu, Apr 20, 2017 at 10:32:50PM +0200, Kevin Wolf wrote: > Am 20.04.2017 um 17:30 hat Daniel P. Berrange geschrieben: > > On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > > > Signed-off-by: Fam Zheng <famz@redhat.com> > > > --- > > > block/sheepdog.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/block/sheepdog.c b/block/sheepdog.c > > > index fb9203e..7e889ee 100644 > > > --- a/block/sheepdog.c > > > +++ b/block/sheepdog.c > > > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > > > qemu_set_nonblock(fd); > > > } else { > > > fd = -EIO; > > > + error_setg(errp, "Failed to connect to sheepdog server"); > > > } > > > > This doesn't make much sense to me. The lines just above the > > diff context have this: > > > > fd = socket_connect(s->addr, errp, NULL, NULL); > > > > socket_connect should have already reported an error on "errp" > > in the scenario that 'fd == -1'. > > By the way, am I the only one who thinks that having errp anywhere else > than as the last argument is bad style? I can easily see myself missing > that this functions sets it because the last argument is NULL. > No, you are not - that is precisely why I missed it in my review. -Jeff ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 20:32 ` Kevin Wolf 2017-04-20 20:40 ` Jeff Cody @ 2017-04-21 0:19 ` Fam Zheng 2017-04-21 5:43 ` Markus Armbruster 2 siblings, 0 replies; 14+ messages in thread From: Fam Zheng @ 2017-04-21 0:19 UTC (permalink / raw) To: Kevin Wolf Cc: Daniel P. Berrange, qemu-devel, sheepdog, qemu-block, Hitoshi Mitake, Jeff Cody, Max Reitz, Liu Yuan On Thu, 04/20 22:32, Kevin Wolf wrote: > Am 20.04.2017 um 17:30 hat Daniel P. Berrange geschrieben: > > On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > > > Signed-off-by: Fam Zheng <famz@redhat.com> > > > --- > > > block/sheepdog.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/block/sheepdog.c b/block/sheepdog.c > > > index fb9203e..7e889ee 100644 > > > --- a/block/sheepdog.c > > > +++ b/block/sheepdog.c > > > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > > > qemu_set_nonblock(fd); > > > } else { > > > fd = -EIO; > > > + error_setg(errp, "Failed to connect to sheepdog server"); > > > } > > > > This doesn't make much sense to me. The lines just above the > > diff context have this: > > > > fd = socket_connect(s->addr, errp, NULL, NULL); Oops! :( > > > > socket_connect should have already reported an error on "errp" > > in the scenario that 'fd == -1'. > > By the way, am I the only one who thinks that having errp anywhere else > than as the last argument is bad style? I can easily see myself missing > that this functions sets it because the last argument is NULL. Hmm, exactly.. Socket code does this here and there, and it's hard to read. Fam ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-20 20:32 ` Kevin Wolf 2017-04-20 20:40 ` Jeff Cody 2017-04-21 0:19 ` Fam Zheng @ 2017-04-21 5:43 ` Markus Armbruster 2017-04-21 8:31 ` Daniel P. Berrange 2 siblings, 1 reply; 14+ messages in thread From: Markus Armbruster @ 2017-04-21 5:43 UTC (permalink / raw) To: Kevin Wolf Cc: Daniel P. Berrange, sheepdog, qemu-block, Hitoshi Mitake, Jeff Cody, qemu-devel, Max Reitz, Liu Yuan, Fam Zheng Kevin Wolf <kwolf@redhat.com> writes: > Am 20.04.2017 um 17:30 hat Daniel P. Berrange geschrieben: >> On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: >> > Signed-off-by: Fam Zheng <famz@redhat.com> >> > --- >> > block/sheepdog.c | 1 + >> > 1 file changed, 1 insertion(+) >> > >> > diff --git a/block/sheepdog.c b/block/sheepdog.c >> > index fb9203e..7e889ee 100644 >> > --- a/block/sheepdog.c >> > +++ b/block/sheepdog.c >> > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) >> > qemu_set_nonblock(fd); >> > } else { >> > fd = -EIO; >> > + error_setg(errp, "Failed to connect to sheepdog server"); >> > } >> >> This doesn't make much sense to me. The lines just above the >> diff context have this: >> >> fd = socket_connect(s->addr, errp, NULL, NULL); >> >> socket_connect should have already reported an error on "errp" >> in the scenario that 'fd == -1'. > > By the way, am I the only one who thinks that having errp anywhere else > than as the last argument is bad style? I can easily see myself missing > that this functions sets it because the last argument is NULL. Yes, it's bad style because it's suprising. Worth fixing. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-21 5:43 ` Markus Armbruster @ 2017-04-21 8:31 ` Daniel P. Berrange 2017-04-21 8:50 ` Fam Zheng 0 siblings, 1 reply; 14+ messages in thread From: Daniel P. Berrange @ 2017-04-21 8:31 UTC (permalink / raw) To: Markus Armbruster Cc: Kevin Wolf, sheepdog, qemu-block, Hitoshi Mitake, Jeff Cody, qemu-devel, Max Reitz, Liu Yuan, Fam Zheng On Fri, Apr 21, 2017 at 07:43:36AM +0200, Markus Armbruster wrote: > Kevin Wolf <kwolf@redhat.com> writes: > > > Am 20.04.2017 um 17:30 hat Daniel P. Berrange geschrieben: > >> On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > >> > Signed-off-by: Fam Zheng <famz@redhat.com> > >> > --- > >> > block/sheepdog.c | 1 + > >> > 1 file changed, 1 insertion(+) > >> > > >> > diff --git a/block/sheepdog.c b/block/sheepdog.c > >> > index fb9203e..7e889ee 100644 > >> > --- a/block/sheepdog.c > >> > +++ b/block/sheepdog.c > >> > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > >> > qemu_set_nonblock(fd); > >> > } else { > >> > fd = -EIO; > >> > + error_setg(errp, "Failed to connect to sheepdog server"); > >> > } > >> > >> This doesn't make much sense to me. The lines just above the > >> diff context have this: > >> > >> fd = socket_connect(s->addr, errp, NULL, NULL); > >> > >> socket_connect should have already reported an error on "errp" > >> in the scenario that 'fd == -1'. > > > > By the way, am I the only one who thinks that having errp anywhere else > > than as the last argument is bad style? I can easily see myself missing > > that this functions sets it because the last argument is NULL. > > Yes, it's bad style because it's suprising. Worth fixing. In fact we can simply delete the last two arguments to socket_connect() entirely. Most code is now switched over to use QIOChannel APIs, so we don't have anything which uses the non-blocking connect feature of socket_connect() anymore. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-21 8:31 ` Daniel P. Berrange @ 2017-04-21 8:50 ` Fam Zheng 2017-04-21 10:06 ` Daniel P. Berrange 0 siblings, 1 reply; 14+ messages in thread From: Fam Zheng @ 2017-04-21 8:50 UTC (permalink / raw) To: Daniel P. Berrange Cc: Markus Armbruster, Kevin Wolf, sheepdog, qemu-block, Hitoshi Mitake, Jeff Cody, qemu-devel, Max Reitz, Liu Yuan On Fri, 04/21 09:31, Daniel P. Berrange wrote: > On Fri, Apr 21, 2017 at 07:43:36AM +0200, Markus Armbruster wrote: > > Kevin Wolf <kwolf@redhat.com> writes: > > > > > Am 20.04.2017 um 17:30 hat Daniel P. Berrange geschrieben: > > >> On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > > >> > Signed-off-by: Fam Zheng <famz@redhat.com> > > >> > --- > > >> > block/sheepdog.c | 1 + > > >> > 1 file changed, 1 insertion(+) > > >> > > > >> > diff --git a/block/sheepdog.c b/block/sheepdog.c > > >> > index fb9203e..7e889ee 100644 > > >> > --- a/block/sheepdog.c > > >> > +++ b/block/sheepdog.c > > >> > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > > >> > qemu_set_nonblock(fd); > > >> > } else { > > >> > fd = -EIO; > > >> > + error_setg(errp, "Failed to connect to sheepdog server"); > > >> > } > > >> > > >> This doesn't make much sense to me. The lines just above the > > >> diff context have this: > > >> > > >> fd = socket_connect(s->addr, errp, NULL, NULL); > > >> > > >> socket_connect should have already reported an error on "errp" > > >> in the scenario that 'fd == -1'. > > > > > > By the way, am I the only one who thinks that having errp anywhere else > > > than as the last argument is bad style? I can easily see myself missing > > > that this functions sets it because the last argument is NULL. > > > > Yes, it's bad style because it's suprising. Worth fixing. > > In fact we can simply delete the last two arguments to socket_connect() > entirely. Most code is now switched over to use QIOChannel APIs, so we > don't have anything which uses the non-blocking connect feature of > socket_connect() anymore. There is one caller that passes non-NULL last two parameters, which seems non-trivial to convert: static int net_socket_connect_init(NetClientState *peer, const char *model, const char *name, const char *host_str) { socket_connect_data *c = g_new0(socket_connect_data, 1); int fd = -1; Error *local_error = NULL; c->peer = peer; c->model = g_strdup(model); c->name = g_strdup(name); c->saddr = socket_parse(host_str, &local_error); if (c->saddr == NULL) { goto err; } fd = socket_connect(c->saddr, net_socket_connected, c, &local_error); if (fd < 0) { goto err; } return 0; err: error_report_err(local_error); socket_connect_data_free(c); return -1; } ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH] sheepdog: Set error when connection fails 2017-04-21 8:50 ` Fam Zheng @ 2017-04-21 10:06 ` Daniel P. Berrange 0 siblings, 0 replies; 14+ messages in thread From: Daniel P. Berrange @ 2017-04-21 10:06 UTC (permalink / raw) To: Fam Zheng Cc: Markus Armbruster, Kevin Wolf, sheepdog, qemu-block, Hitoshi Mitake, Jeff Cody, qemu-devel, Max Reitz, Liu Yuan On Fri, Apr 21, 2017 at 04:50:34PM +0800, Fam Zheng wrote: > On Fri, 04/21 09:31, Daniel P. Berrange wrote: > > On Fri, Apr 21, 2017 at 07:43:36AM +0200, Markus Armbruster wrote: > > > Kevin Wolf <kwolf@redhat.com> writes: > > > > > > > Am 20.04.2017 um 17:30 hat Daniel P. Berrange geschrieben: > > > >> On Thu, Apr 20, 2017 at 12:00:03PM +0800, Fam Zheng wrote: > > > >> > Signed-off-by: Fam Zheng <famz@redhat.com> > > > >> > --- > > > >> > block/sheepdog.c | 1 + > > > >> > 1 file changed, 1 insertion(+) > > > >> > > > > >> > diff --git a/block/sheepdog.c b/block/sheepdog.c > > > >> > index fb9203e..7e889ee 100644 > > > >> > --- a/block/sheepdog.c > > > >> > +++ b/block/sheepdog.c > > > >> > @@ -608,6 +608,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > > > >> > qemu_set_nonblock(fd); > > > >> > } else { > > > >> > fd = -EIO; > > > >> > + error_setg(errp, "Failed to connect to sheepdog server"); > > > >> > } > > > >> > > > >> This doesn't make much sense to me. The lines just above the > > > >> diff context have this: > > > >> > > > >> fd = socket_connect(s->addr, errp, NULL, NULL); > > > >> > > > >> socket_connect should have already reported an error on "errp" > > > >> in the scenario that 'fd == -1'. > > > > > > > > By the way, am I the only one who thinks that having errp anywhere else > > > > than as the last argument is bad style? I can easily see myself missing > > > > that this functions sets it because the last argument is NULL. > > > > > > Yes, it's bad style because it's suprising. Worth fixing. > > > > In fact we can simply delete the last two arguments to socket_connect() > > entirely. Most code is now switched over to use QIOChannel APIs, so we > > don't have anything which uses the non-blocking connect feature of > > socket_connect() anymore. > > There is one caller that passes non-NULL last two parameters, which seems > non-trivial to convert: > > static int net_socket_connect_init(NetClientState *peer, > const char *model, > const char *name, > const char *host_str) > { > socket_connect_data *c = g_new0(socket_connect_data, 1); > int fd = -1; > Error *local_error = NULL; > > c->peer = peer; > c->model = g_strdup(model); > c->name = g_strdup(name); > c->saddr = socket_parse(host_str, &local_error); > if (c->saddr == NULL) { > goto err; > } > > fd = socket_connect(c->saddr, net_socket_connected, c, &local_error); > if (fd < 0) { > goto err; > } > > return 0; > > err: > error_report_err(local_error); > socket_connect_data_free(c); > return -1; > } Oh i missed that in my grep. I think it could probably be converted to QIOChannel though, at least for the initial connection setup. Then just steal the FD from the QIOChannel object for direct usage thereafter or something like that. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2017-04-21 10:06 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-04-20 4:00 [Qemu-devel] [PATCH] sheepdog: Set error when connection fails Fam Zheng 2017-04-20 9:12 ` Philippe Mathieu-Daudé 2017-04-20 15:21 ` Jeff Cody 2017-04-20 15:23 ` Jeff Cody 2017-04-20 15:30 ` Daniel P. Berrange 2017-04-20 15:42 ` Jeff Cody 2017-04-20 15:45 ` Daniel P. Berrange 2017-04-20 20:32 ` Kevin Wolf 2017-04-20 20:40 ` Jeff Cody 2017-04-21 0:19 ` Fam Zheng 2017-04-21 5:43 ` Markus Armbruster 2017-04-21 8:31 ` Daniel P. Berrange 2017-04-21 8:50 ` Fam Zheng 2017-04-21 10:06 ` Daniel P. Berrange
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.