Sanitize linux-user stdout
cover Sanitize linux-user stdout
Hi Laurent,
Here 3 trivial patches, the first one resolves this launchpad issue:
https://bugs.launchpad.net/qemu/+bug/1777226, then the following two sanitize a bit further.
Regards,
Phil.
Philippe Mathieu-Daudé (3):
linux-user: Do not report "Unsupported syscall" by default
linux-user: Do not report "syscall not implemented" by default
linux-user: Report error message on stderr, rather than stdout
linux-user/alpha/cpu_loop.c | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/cris/signal.c | 4 ++-- linux-user/microblaze/cpu_loop.c | 6 +++--- linux-user/microblaze/signal.c | 4 ++-- linux-user/nios2/signal.c | 2 +- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sparc/cpu_loop.c | 2 +- linux-user/sparc/signal.c | 4 ++-- linux-user/syscall.c | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-)
Signature · 1 line
2.18.0
PATCH 1/3 linux-user: Do not report "Unsupported syscall" by default
This can still be reported using the "-d unimp" command line option.
--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -12757,7 +12757,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,default : unimplemented: -gemu_log ("qemu: Unsupported syscall: %d\n" , num); +qemu_log_mask (LOG_UNIMP ,"Unsupported syscall: %d\n" , num);#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn:#endif
Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH for-3.0 1/3] linux-user: Do not report "Unsupported syscall" by default
Quoted 24 lines · Philippe Mathieu-Daudé
This can still be reported using the "-d unimp" command line option.
Reported-by John Paul Adrian Glaubitz <[email protected]>Suggested-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/syscall.c +1
-2@@ -12757,7 +12757,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,default : unimplemented: -gemu_log ("qemu: Unsupported syscall: %d\n" , num); +qemu_log_mask (LOG_UNIMP ,"Unsupported syscall: %d\n" , num);#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn:#endif --
Quoted 1 line
2.18.0
thanks
-- PMM
PATCH 2/3 linux-user: Do not report "syscall not implemented" by default
In reply to Philippe Mathieu-DaudéThis can still be reported using the "-d unimp" command line option.
Code change produced with:
git ls-files linux-user | \
xargs sed -i -E 's/fprintf\(stderr,\s?(".*not implemented\\n")\);/qemu_log_mask(LOG_UNIMP, \1);/g'--- linux-user/cris/signal.c | 4 ++-- linux-user/microblaze/signal.c | 4 ++-- linux-user/nios2/signal.c | 2 +- linux-user/sparc/signal.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
linux-user/cris/signal.c +2 -2
@@ -146,7 +146,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUCRISState *env) { -fprintf (stderr,"CRIS setup_rt_frame: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"setup_rt_frame: not implemented\n" ); }long do_sigreturn (CPUCRISState *env)
@@ -183,6 +183,6 @@ badframe:long do_rt_sigreturn (CPUCRISState *env) {trace_user_do_rt_sigreturn (env,0 ); -fprintf (stderr,"CRIS do_rt_sigreturn: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }
linux-user/microblaze/signal.c +2 -2
@@ -200,7 +200,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUMBState *env) { -fprintf (stderr,"Microblaze setup_rt_frame: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"setup_rt_frame: not implemented\n" ); }long do_sigreturn (CPUMBState *env)
@@ -240,6 +240,6 @@ badframe:long do_rt_sigreturn (CPUMBState *env) {trace_user_do_rt_sigreturn (env,0 ); -fprintf (stderr,"Microblaze do_rt_sigreturn: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }
linux-user/nios2/signal.c +1 -1
@@ -203,7 +203,7 @@ give_sigsegv:long do_sigreturn (CPUNios2State *env) {trace_user_do_sigreturn (env,0 ); -fprintf (stderr,"do_sigreturn: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"do_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }
linux-user/sparc/signal.c +2 -2
@@ -278,7 +278,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUSPARCState *env) { -fprintf (stderr,"setup_rt_frame: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"setup_rt_frame: not implemented\n" ); }long do_sigreturn (CPUSPARCState *env)
@@ -357,7 +357,7 @@ segv_and_exit:long do_rt_sigreturn (CPUSPARCState *env) {trace_user_do_rt_sigreturn (env,0 ); -fprintf (stderr,"do_rt_sigreturn: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"do_rt_sigreturn: not implemented\n" );return -TARGET_ENOSYS ; }
Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH for-3.0 2/3] linux-user: Do not report "syscall not implemented" by default
Quoted 20 lines · Philippe Mathieu-Daudé
This can still be reported using the "-d unimp" command line option.
Code change produced with:
git ls-files linux-user | \ xargs sed -i -E 's/fprintf\(stderr,\s?(".*not implemented\\n")\);/qemu_log_mask(LOG_UNIMP, \1);/g'Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/cris/signal.c | 4 ++-- linux-user/microblaze/signal.c | 4 ++-- linux-user/nios2/signal.c | 2 +- linux-user/sparc/signal.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)linux-user/cris/signal.c +0
-0
linux-user/cris/signal.c void setup_rt_frame(int sig, struct target_sigaction *ka, · line 149
Quoted 5 lines
linux-user/cris/signal.c +1
-1@@ -146,7 +146,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUCRISState *env) { -fprintf (stderr,"CRIS setup_rt_frame: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"setup_rt_frame: not implemented\n" );
Your regex seems to have gone a bit awry here, because it's lost the "CRIS" part of the string (similarly below).
thanks
-- PMM
Re: [Qemu-devel] [PATCH for-3.0 2/3] linux-user: Do not report "syscall not implemented" by default
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Philippe Mathieu-Daudé
This can still be reported using the "-d unimp" command line option.
Code change produced with:
git ls-files linux-user | \ xargs sed -i -E 's/fprintf\(stderr,\s?(".*not implemented\\n")\);/qemu_log_mask(LOG_UNIMP, \1);/g'Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/cris/signal.c | 4 ++-- linux-user/microblaze/signal.c | 4 ++-- linux-user/nios2/signal.c | 2 +- linux-user/sparc/signal.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
Quoted 13 lines
linux-user/cris/signal.c void setup_rt_frame(int sig, struct target_sigaction *ka, · line 149
Quoted 10 lines
linux-user/cris/signal.c +1
-1@@ -146,7 +146,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUCRISState *env) { -fprintf (stderr,"CRIS setup_rt_frame: not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"setup_rt_frame: not implemented\n" );Your regex seems to have gone a bit awry here, because it's lost the "CRIS" part of the string (similarly below).
Oh I deliberately dropped it when using 'git add -p' after the regex because I noticed neither nios2 nor sparc arch were using it, and I don't think this is a relevant information.
Do you prefer I restore them, I reword the commit message, or even add similar description for the nios2/sparc?
Thanks,
Phil.
PATCH 3/3 linux-user: Report error message on stderr, rather than stdout
In reply to Philippe Mathieu-DaudéCode change produced with:
git ls-files linux-user | \
xargs sed -i -E 's/(\s+)printf\s*\(("Unhandled.*)\);/\1fprintf(stderr, \2);/g'--- linux-user/alpha/cpu_loop.c | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/microblaze/cpu_loop.c | 6 +++--- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sparc/cpu_loop.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
linux-user/alpha/cpu_loop.c +1 -1
@@ -196,7 +196,7 @@ void cpu_loop(CPUAlphaState *env) arch_interrupt = false;break ;default : -printf ("Unhandled trap: 0x%x\n" , trapnr); +fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr);cpu_dump_state (cs, stderr, fprintf,0 );exit (EXIT_FAILURE ); }
linux-user/cris/cpu_loop.c +1 -1
@@ -81,7 +81,7 @@ void cpu_loop(CPUCRISState *env)cpu_exec_step_atomic (cs);break ;default : -printf ("Unhandled trap: 0x%x\n" , trapnr); +fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr);cpu_dump_state (cs, stderr, fprintf,0 );exit (EXIT_FAILURE ); }
linux-user/microblaze/cpu_loop.c +3 -3
@@ -105,8 +105,8 @@ void cpu_loop(CPUMBState *env)queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ;default : -printf ("Unhandled hw-exception: 0x%" PRIx64"\n" , - env->sregs[SR_ESR ] &ESR_EC_MASK ); +fprintf (stderr,"Unhandled hw-exception: 0x%" PRIx64"\n" , + env->sregs[SR_ESR ] &ESR_EC_MASK );cpu_dump_state (cs, stderr, fprintf,0 );exit (EXIT_FAILURE );break ;
@@ -130,7 +130,7 @@ void cpu_loop(CPUMBState *env)cpu_exec_step_atomic (cs);break ;default : -printf ("Unhandled trap: 0x%x\n" , trapnr); +fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr);cpu_dump_state (cs, stderr, fprintf,0 );exit (EXIT_FAILURE ); }
linux-user/sh4/cpu_loop.c +1 -1
@@ -84,7 +84,7 @@ void cpu_loop(CPUSH4State *env) arch_interrupt = false;break ;default : -printf ("Unhandled trap: 0x%x\n" , trapnr); +fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr);cpu_dump_state (cs, stderr, fprintf,0 );exit (EXIT_FAILURE ); }
linux-user/sparc/cpu_loop.c +1 -1
@@ -285,7 +285,7 @@ void cpu_loop (CPUSPARCState *env)cpu_exec_step_atomic (cs);break ;default : -printf ("Unhandled trap: 0x%x\n" , trapnr); +fprintf (stderr,"Unhandled trap: 0x%x\n" , trapnr);cpu_dump_state (cs, stderr, fprintf,0 );exit (EXIT_FAILURE ); }
Signature · 1 line
2.18.0
Re: [Qemu-devel] [PATCH for-3.0 3/3] linux-user: Report error message on stderr, rather than stdout
Quoted 5 lines · Philippe Mathieu-Daudé
Code change produced with:
git ls-files linux-user | \ xargs sed -i -E 's/(\s+)printf\s*\(("Unhandled.*)\);/\1fprintf(stderr, \2);/g'
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/alpha/cpu_loop.c | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/microblaze/cpu_loop.c | 6 +++--- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sparc/cpu_loop.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
Makes sense, as we're about to print the cpu_dump_state output to stderr too.
thanks
-- PMM
Quoted 4 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (3):
linux-user: Do not report "Unsupported syscall" by default
linux-user: Do not report "syscall not implemented" by default
linux-user: Report error message on stderr, rather than stdout
r~
Le 06/07/2018 à 17:51, Philippe Mathieu-Daudé a écrit :
Quoted 15 lines
Hi Laurent,
Here 3 trivial patches, the first one resolves this launchpad issue:
https://bugs.launchpad.net/qemu/+bug/1777226, then the following two sanitize a bit further.Regards,
Phil.
Philippe Mathieu-Daudé (3):
linux-user: Do not report "Unsupported syscall" by default
linux-user: Do not report "syscall not implemented" by default
linux-user: Report error message on stderr, rather than stdout
Quoted 12 lines
linux-user/alpha/cpu_loop.c | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/cris/signal.c | 4 ++-- linux-user/microblaze/cpu_loop.c | 6 +++--- linux-user/microblaze/signal.c | 4 ++-- linux-user/nios2/signal.c | 2 +- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sparc/cpu_loop.c | 2 +- linux-user/sparc/signal.c | 4 ++-- linux-user/syscall.c | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-)
I have queued the series for the next pull request.
I think you can also replace the gemu_log("Unknown QEMU_IFLA..."), qemu_log("Unknown host ..") and qemu_log("Unknown target ...") from the netlink part in syscall.c with qemu_log_mask(LOG_UNIMP, ...).
Thanks,
Laurent