qsd: Do not use error_report() before monitor_init
PATCH 1/1 qsd: Do not use error_report() before monitor_init
error_report() only works once monitor_init_globals_core() has been called, which is not the case when parsing the --daemonize option. Use fprintf(stderr, ...) instead.
--- storage-daemon/qemu-storage-daemon.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
storage-daemon/qemu-storage-daemon.c +5 -1
@@ -286,7 +286,11 @@ static void process_options(int argc, char *argv[], bool pre_init_pass) }case OPTION_DAEMONIZE :if (os_set_daemonize (true) <0 ) { -error_report ("--daemonize not supported in this build" ); +/* +* --daemonize is parsed before monitor_init_globals_core(), so +* error_report() does not work yet +*/ +fprintf (stderr,"--daemonize not supported in this build\n" );exit (EXIT_FAILURE ); }break ;
Signature · 1 line
2.35.3
Quoted 9 lines · Hanna Reitz
error_report()only works oncemonitor_init_globals_core()has been called, which is not the case when parsing the --daemonize option. Usefprintf(stderr, ...)instead.Fixes 2525edd85fec53e23fda98974a15e3b3c8957596 ("qsd: Add --daemonize")Signed-off-by Hanna Reitz <[email protected]>--- storage-daemon/qemu-storage-daemon.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Quoted 18 lines · Hanna Reitz
error_report()only works oncemonitor_init_globals_core()has been called, which is not the case when parsing the --daemonize option. Usefprintf(stderr, ...)instead.Fixes 2525edd85fec53e23fda98974a15e3b3c8957596 ("qsd: Add --daemonize")Signed-off-by Hanna Reitz <[email protected]>--- storage-daemon/qemu-storage-daemon.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)storage-daemon/qemu-storage-daemon.c +0
-0@@ -286,7 +286,11 @@ static void process_options(int argc, char *argv[], bool pre_init_pass) }case OPTION_DAEMONIZE :
storage-daemon/qemu-storage-daemon.c static void process_options(int argc, char *argv[], bool pre_init_pass) · line 296
Quoted 10 lines
storage-daemon/qemu-storage-daemon.c +5
-1if (os_set_daemonize (true) <0 ) { -error_report ("--daemonize not supported in this build" ); +/* +* --daemonize is parsed before monitor_init_globals_core(), so +* error_report() does not work yet +*/ +fprintf (stderr,"--daemonize not supported in this build\n" );exit (EXIT_FAILURE ); }break ;
Is it worth making error_report() have code for "called in early startup before monitor was initialized" that falls back to "just print to stderr"? Having our standard error reporting function not be usable everywhere is kind of surprising...
-- PMM