misc: Improve error reporting on Windows
cover misc: Improve error reporting on Windows
Two patches to improve bug reports on Windows. (i.e. https://bugs.launchpad.net/qemu/+bug/1657841)
Philippe Mathieu-Daudé (2):
chardev: Improve error report by calling error_setg_win32() util/oslib-win32: Improve error report by calling error_setg_win32()
chardev/char-pipe.c | 2 +- chardev/char-win.c | 2 +- util/oslib-win32.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.21.1
PATCH 1/2 chardev: Improve error report by calling error_setg_win32()
Use error_setg_win32() which adds a hint similar to strerror(errno)).
--- chardev/char-pipe.c | 2 +- chardev/char-win.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
chardev/char-pipe.c +1 -1
@@ -70,7 +70,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename, MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL);g_free (openname);if (s->file ==INVALID_HANDLE_VALUE ) { -error_setg (errp,"Failed CreateNamedPipe (%lu)" ,GetLastError ()); +error_setg_win32 (errp,GetLastError (),"Failed CreateNamedPipe" ); s->file =NULL ; goto fail; }
chardev/char-win.c +1 -1
@@ -96,7 +96,7 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp) s->file =CreateFile (filename,GENERIC_READ |GENERIC_WRITE ,0 ,NULL ,OPEN_EXISTING ,FILE_FLAG_OVERLAPPED ,0 );if (s->file ==INVALID_HANDLE_VALUE ) { -error_setg (errp,"Failed CreateFile (%lu)" ,GetLastError ()); +error_setg_win32 (errp,GetLastError (),"Failed CreateFile" ); s->file =NULL ; goto fail; }
Signature · 1 line
2.21.1
Re: [PATCH 1/2] chardev: Improve error report by calling error_setg_win32()
Quoted 7 lines · Philippe Mathieu-Daudé
Use
error_setg_win32()which adds a hint similar to strerror(errno)).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- chardev/char-pipe.c | 2 +- chardev/char-win.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [PATCH 1/2] chardev: Improve error report by calling error_setg_win32()
In reply to Philippe Mathieu-DaudéQuoted 36 lines · Philippe Mathieu-Daudé
Use
error_setg_win32()which adds a hint similar to strerror(errno)).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- chardev/char-pipe.c | 2 +- chardev/char-win.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)chardev/char-pipe.c +1
-1@@ -70,7 +70,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename, MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL);g_free (openname);if (s->file ==INVALID_HANDLE_VALUE ) { -error_setg (errp,"Failed CreateNamedPipe (%lu)" ,GetLastError ()); +error_setg_win32 (errp,GetLastError (),"Failed CreateNamedPipe" ); s->file =NULL ; goto fail; }chardev/char-win.c +1
-2@@ -96,7 +96,7 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp) s->file =CreateFile (filename,GENERIC_READ |GENERIC_WRITE ,0 ,NULL ,OPEN_EXISTING ,FILE_FLAG_OVERLAPPED ,0 );if (s->file ==INVALID_HANDLE_VALUE ) { -error_setg (errp,"Failed CreateFile (%lu)" ,GetLastError ()); +error_setg_win32 (errp,GetLastError (),"Failed CreateFile" ); s->file =NULL ; goto fail; } --
Quoted 2 lines
2.21.1
Daniel, do you mind queuing this with the qio patch?
PATCH 2/2 util/oslib-win32: Improve error report by calling error_setg_win32()
In reply to Philippe Mathieu-DaudéUse error_setg_win32() which adds a hint similar to strerror(errno)).
--- util/oslib-win32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
util/oslib-win32.c +2 -1
@@ -46,7 +46,8 @@void *qemu_oom_check (void *ptr) {if (ptr ==NULL ) { -fprintf (stderr,"Failed to allocate memory: %lu\n" ,GetLastError ()); + g_autofree gchar *emsg = g_win32_error_message(GetLastError()); +fprintf (stderr,"Failed to allocate memory: %s\n" , emsg);abort (); }return ptr;
Signature · 1 line
2.21.1
Re: [PATCH 2/2] util/oslib-win32: Improve error report by calling error_setg_win32()
Quoted 6 lines · Philippe Mathieu-Daudé
Use
error_setg_win32()which adds a hint similar to strerror(errno)).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/oslib-win32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [PATCH 2/2] util/oslib-win32: Improve error report by calling error_setg_win32()
In reply to Philippe Mathieu-DaudéQuoted 12 lines · Philippe Mathieu-Daudé
Use
error_setg_win32()which adds a hint similar to strerror(errno)).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/oslib-win32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)util/oslib-win32.c +0
-0
util/oslib-win32.c line 49
Quoted 5 lines
util/oslib-win32.c +1
-1@@ -46,7 +46,8 @@void *qemu_oom_check (void *ptr) {if (ptr ==NULL ) { -fprintf (stderr,"Failed to allocate memory: %lu\n" ,GetLastError ()); + g_autofree gchar *emsg = g_win32_error_message(GetLastError());
Since we're on a path to abort(), I wouldn't bother with g_autofree.
util/oslib-win32.c line 50
Quoted 1 line
util/oslib-win32.c +1
-0+fprintf (stderr,"Failed to allocate memory: %s\n" , emsg);
Any particular reason not to use error_report()?
Quoted 3 lines
util/oslib-win32.c +0
-0abort (); }return ptr;
Re: [PATCH 2/2] util/oslib-win32: Improve error report by calling error_setg_win32()
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Philippe Mathieu-Daudé
Use
error_setg_win32()which adds a hint similar to strerror(errno)).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/oslib-win32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines
util/oslib-win32.c line 49
Quoted 10 lines
util/oslib-win32.c +1
-1@@ -46,7 +46,8 @@void *qemu_oom_check (void *ptr) {if (ptr ==NULL ) { -fprintf (stderr,"Failed to allocate memory: %lu\n" ,GetLastError ()); + g_autofree gchar *emsg = g_win32_error_message(GetLastError());Since we're on a path to
abort(), I wouldn't bother with g_autofree.\
This is in case other developers copy that elsewhere.
Quoted 4 lines
util/oslib-win32.c line 50
Quoted 2 lines
util/oslib-win32.c +1
-0+fprintf (stderr,"Failed to allocate memory: %s\n" , emsg);Any particular reason not to use
error_report()?
Pre-existing call, but I can change.
Quoted 5 lines
Quoted 4 lines
util/oslib-win32.c +0
-0abort (); }return ptr;