qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: fix NetBSD qemu-iotests failure
@ 2019-07-25  9:59 Paolo Bonzini
  2019-07-25 11:26 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2019-07-25  9:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

Opening a block device on NetBSD has an additional step compared to other OSes,
corresponding to raw_normalize_devicepath.  The error message in that function
is slightly different from that in raw_open_common and this was causing spurious
failures in qemu-iotests.  However, in general it is not important to know what
exact step was failing, for example in the qemu-iotests case the error message
contains the fairly unequivocal "No such file or directory" text from strerror.
We can thus fix the failures by standardizing on a single error message for
both raw_open_common and raw_normalize_devicepath; in fact, we can even
use error_setg_file_open to make sure the error message is the same as in
the rest of QEMU.

Tested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/file-posix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 73a001ceb7..a2089b1f87 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -217,7 +217,7 @@ static int raw_normalize_devicepath(const char **filename, Error **errp)
     fname = *filename;
     dp = strrchr(fname, '/');
     if (lstat(fname, &sb) < 0) {
-        error_setg_errno(errp, errno, "%s: stat failed", fname);
+        error_setg_file_open(errp, errno, fname);
         return -errno;
     }
 
@@ -547,7 +547,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
     ret = fd < 0 ? -errno : 0;
 
     if (ret < 0) {
-        error_setg_errno(errp, -ret, "Could not open '%s'", filename);
+        error_setg_file_open(errp, -ret, filename);
         if (ret == -EROFS) {
             ret = -EACCES;
         }
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] block: fix NetBSD qemu-iotests failure
  2019-07-25  9:59 [Qemu-devel] [PATCH] block: fix NetBSD qemu-iotests failure Paolo Bonzini
@ 2019-07-25 11:26 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-07-25 11:26 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Thomas Huth

On 7/25/19 11:59 AM, Paolo Bonzini wrote:
> Opening a block device on NetBSD has an additional step compared to other OSes,
> corresponding to raw_normalize_devicepath.  The error message in that function
> is slightly different from that in raw_open_common and this was causing spurious
> failures in qemu-iotests.  However, in general it is not important to know what
> exact step was failing, for example in the qemu-iotests case the error message
> contains the fairly unequivocal "No such file or directory" text from strerror.
> We can thus fix the failures by standardizing on a single error message for
> both raw_open_common and raw_normalize_devicepath; in fact, we can even
> use error_setg_file_open to make sure the error message is the same as in
> the rest of QEMU.
> 
> Tested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block/file-posix.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 73a001ceb7..a2089b1f87 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -217,7 +217,7 @@ static int raw_normalize_devicepath(const char **filename, Error **errp)
>      fname = *filename;
>      dp = strrchr(fname, '/');
>      if (lstat(fname, &sb) < 0) {
> -        error_setg_errno(errp, errno, "%s: stat failed", fname);
> +        error_setg_file_open(errp, errno, fname);
>          return -errno;
>      }
>  
> @@ -547,7 +547,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
>      ret = fd < 0 ? -errno : 0;
>  
>      if (ret < 0) {
> -        error_setg_errno(errp, -ret, "Could not open '%s'", filename);
> +        error_setg_file_open(errp, -ret, filename);
>          if (ret == -EROFS) {
>              ret = -EACCES;
>          }
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Maybe other candidates:

$ git grep error_setg_errno.*open.*file
block.c:1303:            error_setg_errno(errp, -ret, "Could not open
'%s'", bs->filename);
block/file-posix.c:925:                error_setg_errno(errp, errno,
"Could not reopen file");
hw/core/loader.c:358:        error_setg_errno(errp, errno, "Failed to
open file: %s", filename);
net/dump.c:113:        error_setg_errno(errp, errno, "net dump: can't
open %s", filename);
qga/commands-posix.c:367:            error_setg_errno(&local_err, errno,
"failed to open file '%s' "
qga/commands-posix.c:2308:        error_setg_errno(errp, errno, "open
sysfs file \"%s\"", pathname);
qga/commands-posix.c:2329:        error_setg_errno(errp, errno, "open
sysfs file \"%s\"", pathname);
util/oslib-posix.c:107:            error_setg_errno(errp, errno, "Cannot
open pid file");
util/vfio-helpers.c:278:        error_setg_errno(errp, errno, "Failed to
open VFIO group file: %s",


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-25 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-25  9:59 [Qemu-devel] [PATCH] block: fix NetBSD qemu-iotests failure Paolo Bonzini
2019-07-25 11:26 ` Philippe Mathieu-Daudé

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).