Message ID | 1433237561-10846-1-git-send-email-famz@redhat.com |
---|---|
State | New |
Headers | show |
[ CC to Sheepdog maintainers ] Am 02.06.2015 um 11:32 hat Fam Zheng geschrieben: > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > block/sheepdog.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/block/sheepdog.c b/block/sheepdog.c > index bd7cbed..a22f838 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -2556,7 +2556,11 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data, > } > > if (ret < 0) { > - error_report("failed to save vmstate %s", strerror(errno)); > + if (load) { > + error_report("failed to load vmstate %s", strerror(errno)); > + } else { > + error_report("failed to save vmstate %s", strerror(errno)); > + } > goto cleanup; > } Why do we even print this message? We usually don't do this for a failed request, and much less so if we don't actually add any information that isn't covered by the return code. qemu_savevm_state() will already set an error that is even visible in QMP. In fact, errno doesn't even contain anything relevant here, or in most (all?) other places that it's used in the sheepdog block driver. I think we might be better off just removing the message. Kevin
02.06.2015 12:32, Fam Zheng wrote: > if (ret < 0) { > - error_report("failed to save vmstate %s", strerror(errno)); > + if (load) { > + error_report("failed to load vmstate %s", strerror(errno)); > + } else { > + error_report("failed to save vmstate %s", strerror(errno)); > + } + error_report("failed to %s vmstate: %s", load ? "load" : "save", strerror(errno)); (note also the addition of ":") (besides what Kevin said). Thanks, /mjt
On Tue, 06/02 11:45, Kevin Wolf wrote: > [ CC to Sheepdog maintainers ] > > Am 02.06.2015 um 11:32 hat Fam Zheng geschrieben: > > Signed-off-by: Fam Zheng <famz@redhat.com> > > --- > > block/sheepdog.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/block/sheepdog.c b/block/sheepdog.c > > index bd7cbed..a22f838 100644 > > --- a/block/sheepdog.c > > +++ b/block/sheepdog.c > > @@ -2556,7 +2556,11 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data, > > } > > > > if (ret < 0) { > > - error_report("failed to save vmstate %s", strerror(errno)); > > + if (load) { > > + error_report("failed to load vmstate %s", strerror(errno)); > > + } else { > > + error_report("failed to save vmstate %s", strerror(errno)); > > + } > > goto cleanup; > > } > > Why do we even print this message? We usually don't do this for a failed > request, and much less so if we don't actually add any information that > isn't covered by the return code. qemu_savevm_state() will already set > an error that is even visible in QMP. > > In fact, errno doesn't even contain anything relevant here, or in most > (all?) other places that it's used in the sheepdog block driver. Now I followed the called function and agree that reporting errno is not helpful. Maybe it's better to do a clean up on error reportings in this driver, later. Fam
On Tue, 06/02 13:16, Michael Tokarev wrote: > 02.06.2015 12:32, Fam Zheng wrote: > > if (ret < 0) { > > - error_report("failed to save vmstate %s", strerror(errno)); > > + if (load) { > > + error_report("failed to load vmstate %s", strerror(errno)); > > + } else { > > + error_report("failed to save vmstate %s", strerror(errno)); > > + } > > + error_report("failed to %s vmstate: %s", load ? "load" : "save", strerror(errno)); The reason I didn't use a one-liner was, "git grep 'failed to load vmstate'" in the code base would just work, besides my eyes also like the readability. > > (note also the addition of ":") Yes that applies to all error_report() in this file. > (besides what Kevin said). > > Thanks, Thanks, Fam
On 06/02/2015 06:26 AM, Fam Zheng wrote: > On Tue, 06/02 13:16, Michael Tokarev wrote: >> 02.06.2015 12:32, Fam Zheng wrote: >>> if (ret < 0) { >>> - error_report("failed to save vmstate %s", strerror(errno)); >>> + if (load) { >>> + error_report("failed to load vmstate %s", strerror(errno)); >>> + } else { >>> + error_report("failed to save vmstate %s", strerror(errno)); >>> + } >> >> + error_report("failed to %s vmstate: %s", load ? "load" : "save", strerror(errno)); > > The reason I didn't use a one-liner was, "git grep 'failed to load vmstate'" > in the code base would just work, besides my eyes also like the readability. > +1, Error messages should be kept on one line and intact where possible and convenient. Greppable code is happy code. >> >> (note also the addition of ":") > > Yes that applies to all error_report() in this file. > >> (besides what Kevin said). >> >> Thanks, > > Thanks, > > Fam >
diff --git a/block/sheepdog.c b/block/sheepdog.c index bd7cbed..a22f838 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2556,7 +2556,11 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data, } if (ret < 0) { - error_report("failed to save vmstate %s", strerror(errno)); + if (load) { + error_report("failed to load vmstate %s", strerror(errno)); + } else { + error_report("failed to save vmstate %s", strerror(errno)); + } goto cleanup; }
Signed-off-by: Fam Zheng <famz@redhat.com> --- block/sheepdog.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)