* [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing
@ 2014-09-26 8:14 arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 1/3] os-posix: change tab to space avoid violating coding style arei.gonglei
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: arei.gonglei @ 2014-09-26 8:14 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, weidong.huang, qemu-trivial, mjt, armbru, Gonglei,
pbonzini
From: Gonglei <arei.gonglei@huawei.com>
The patches mainly improve the error message printing.
And adjust coding style of os-posix.c.
Daemonize the QEMU process after initialization, QEMU will not detach from
standard IO until it is ready to receive connections on any of its devices.
So, using fprintf print error.
Cc: Eric Blake <eblake@redhat.com>
Gonglei (3):
os-posix: change tab to space avoid violating coding style
os-posix: remove confused errno
os-posix: report error message when lock file failed
os-posix.c | 83 ++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 45 insertions(+), 38 deletions(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 1/3] os-posix: change tab to space avoid violating coding style
2014-09-26 8:14 [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing arei.gonglei
@ 2014-09-26 8:14 ` arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 2/3] os-posix: remove confused errno arei.gonglei
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: arei.gonglei @ 2014-09-26 8:14 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, weidong.huang, qemu-trivial, mjt, armbru, Gonglei,
pbonzini
From: Gonglei <arei.gonglei@huawei.com>
Cc: Eric Blake <eblake@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
os-posix.c | 79 +++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 42 insertions(+), 37 deletions(-)
diff --git a/os-posix.c b/os-posix.c
index cb2a7f7..f0564ef 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -204,45 +204,49 @@ static void change_root(void)
void os_daemonize(void)
{
if (daemonize) {
- pid_t pid;
+ pid_t pid;
- if (pipe(fds) == -1)
- exit(1);
+ if (pipe(fds) == -1) {
+ exit(1);
+ }
- pid = fork();
- if (pid > 0) {
- uint8_t status;
- ssize_t len;
+ pid = fork();
+ if (pid > 0) {
+ uint8_t status;
+ ssize_t len;
- close(fds[1]);
+ close(fds[1]);
- again:
+ again:
len = read(fds[0], &status, 1);
- if (len == -1 && (errno == EINTR))
+ if (len == -1 && (errno == EINTR)) {
goto again;
-
- if (len != 1)
+ }
+ if (len != 1) {
exit(1);
+ }
else if (status == 1) {
fprintf(stderr, "Could not acquire pidfile: %s\n", strerror(errno));
exit(1);
- } else
+ } else {
exit(0);
- } else if (pid < 0)
- exit(1);
-
- close(fds[0]);
- qemu_set_cloexec(fds[1]);
+ }
+ } else if (pid < 0) {
+ exit(1);
+ }
- setsid();
+ close(fds[0]);
+ qemu_set_cloexec(fds[1]);
- pid = fork();
- if (pid > 0)
- exit(0);
- else if (pid < 0)
- exit(1);
+ setsid();
- umask(027);
+ pid = fork();
+ if (pid > 0) {
+ exit(0);
+ } else if (pid < 0) {
+ exit(1);
+ }
+ umask(027);
signal(SIGTSTP, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
@@ -255,24 +259,25 @@ void os_setup_post(void)
int fd = 0;
if (daemonize) {
- uint8_t status = 0;
- ssize_t len;
+ uint8_t status = 0;
+ ssize_t len;
again1:
- len = write(fds[1], &status, 1);
- if (len == -1 && (errno == EINTR))
- goto again1;
-
- if (len != 1)
- exit(1);
-
+ len = write(fds[1], &status, 1);
+ if (len == -1 && (errno == EINTR)) {
+ goto again1;
+ }
+ if (len != 1) {
+ exit(1);
+ }
if (chdir("/")) {
perror("not able to chdir to /");
exit(1);
}
- TFR(fd = qemu_open("/dev/null", O_RDWR));
- if (fd == -1)
- exit(1);
+ TFR(fd = qemu_open("/dev/null", O_RDWR));
+ if (fd == -1) {
+ exit(1);
+ }
}
change_root();
--
1.7.12.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/3] os-posix: remove confused errno
2014-09-26 8:14 [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 1/3] os-posix: change tab to space avoid violating coding style arei.gonglei
@ 2014-09-26 8:14 ` arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 3/3] os-posix: report error message when lock file failed arei.gonglei
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: arei.gonglei @ 2014-09-26 8:14 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, weidong.huang, qemu-trivial, mjt, armbru, Gonglei,
pbonzini
From: Gonglei <arei.gonglei@huawei.com>
If we get inside the 'else if (status == 1)' conditional,
then we know that read() succeeded, and therefore errno is
unspecified. Printing strerror(errno) on a random value
is not helpful.
Cc: Eric Blake <eblake@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
os-posix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/os-posix.c b/os-posix.c
index f0564ef..e31a099 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -226,7 +226,7 @@ void os_daemonize(void)
exit(1);
}
else if (status == 1) {
- fprintf(stderr, "Could not acquire pidfile: %s\n", strerror(errno));
+ fprintf(stderr, "Could not acquire pidfile\n");
exit(1);
} else {
exit(0);
--
1.7.12.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 3/3] os-posix: report error message when lock file failed
2014-09-26 8:14 [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 1/3] os-posix: change tab to space avoid violating coding style arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 2/3] os-posix: remove confused errno arei.gonglei
@ 2014-09-26 8:14 ` arei.gonglei
2014-09-26 8:27 ` [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing Paolo Bonzini
2014-09-26 17:22 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
4 siblings, 0 replies; 7+ messages in thread
From: arei.gonglei @ 2014-09-26 8:14 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, weidong.huang, qemu-trivial, mjt, armbru, Gonglei,
pbonzini
From: Gonglei <arei.gonglei@huawei.com>
It will cause that create vm failed When manager
tool is killed forcibly (kill -9 libvirtd_pid),
the file not was unlink, and unlock. It's better
that report the error message for users.
Signed-off-by: Huangweidong <weidong.huang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
os-posix.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/os-posix.c b/os-posix.c
index e31a099..4898ebf 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -319,6 +319,8 @@ int qemu_create_pidfile(const char *filename)
return -1;
}
if (lockf(fd, F_TLOCK, 0) == -1) {
+ fprintf(stderr, "lock file '%s' failed: %s\n",
+ filename, strerror(errno));
close(fd);
return -1;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing
2014-09-26 8:14 [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing arei.gonglei
` (2 preceding siblings ...)
2014-09-26 8:14 ` [Qemu-devel] [PATCH 3/3] os-posix: report error message when lock file failed arei.gonglei
@ 2014-09-26 8:27 ` Paolo Bonzini
2014-09-26 8:32 ` Gonglei (Arei)
2014-09-26 17:22 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
4 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2014-09-26 8:27 UTC (permalink / raw)
To: arei.gonglei, qemu-devel, Michael Tokarev
Cc: peter.maydell, weidong.huang, qemu-trivial, armbru
Il 26/09/2014 10:14, arei.gonglei@huawei.com ha scritto:
> From: Gonglei <arei.gonglei@huawei.com>
>
> The patches mainly improve the error message printing.
> And adjust coding style of os-posix.c.
>
> Daemonize the QEMU process after initialization, QEMU will not detach from
> standard IO until it is ready to receive connections on any of its devices.
> So, using fprintf print error.
>
> Cc: Eric Blake <eblake@redhat.com>
>
> Gonglei (3):
> os-posix: change tab to space avoid violating coding style
> os-posix: remove confused errno
> os-posix: report error message when lock file failed
>
> os-posix.c | 83 ++++++++++++++++++++++++++++++++++----------------------------
> 1 file changed, 45 insertions(+), 38 deletions(-)
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Michael, are you going to pick these up?
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing
2014-09-26 8:27 ` [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing Paolo Bonzini
@ 2014-09-26 8:32 ` Gonglei (Arei)
0 siblings, 0 replies; 7+ messages in thread
From: Gonglei (Arei) @ 2014-09-26 8:32 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel, Michael Tokarev
Cc: peter.maydell, Huangweidong (C), qemu-trivial, armbru
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Subject: Re: [PATCH 0/3] os-posix: improve the error message printing
>
> Il 26/09/2014 10:14, arei.gonglei@huawei.com ha scritto:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > The patches mainly improve the error message printing.
> > And adjust coding style of os-posix.c.
> >
> > Daemonize the QEMU process after initialization, QEMU will not detach from
> > standard IO until it is ready to receive connections on any of its devices.
> > So, using fprintf print error.
> >
> > Cc: Eric Blake <eblake@redhat.com>
> >
> > Gonglei (3):
> > os-posix: change tab to space avoid violating coding style
> > os-posix: remove confused errno
> > os-posix: report error message when lock file failed
> >
> > os-posix.c | 83
> ++++++++++++++++++++++++++++++++++----------------------------
> > 1 file changed, 45 insertions(+), 38 deletions(-)
> >
>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>
Thanks! :)
Best regards,
-Gonglei
> Michael, are you going to pick these up?
>
> Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH 0/3] os-posix: improve the error message printing
2014-09-26 8:14 [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing arei.gonglei
` (3 preceding siblings ...)
2014-09-26 8:27 ` [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing Paolo Bonzini
@ 2014-09-26 17:22 ` Michael Tokarev
4 siblings, 0 replies; 7+ messages in thread
From: Michael Tokarev @ 2014-09-26 17:22 UTC (permalink / raw)
To: arei.gonglei, qemu-devel
Cc: peter.maydell, weidong.huang, qemu-trivial, armbru, pbonzini
26.09.2014 12:14, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> The patches mainly improve the error message printing.
> And adjust coding style of os-posix.c.
>
> Daemonize the QEMU process after initialization, QEMU will not detach from
> standard IO until it is ready to receive connections on any of its devices.
> So, using fprintf print error.
>
> Cc: Eric Blake <eblake@redhat.com>
>
> Gonglei (3):
> os-posix: change tab to space avoid violating coding style
> os-posix: remove confused errno
> os-posix: report error message when lock file failed
Applied all 3 to -trivial, thank you!
/mjt
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-09-26 17:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-26 8:14 [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 1/3] os-posix: change tab to space avoid violating coding style arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 2/3] os-posix: remove confused errno arei.gonglei
2014-09-26 8:14 ` [Qemu-devel] [PATCH 3/3] os-posix: report error message when lock file failed arei.gonglei
2014-09-26 8:27 ` [Qemu-devel] [PATCH 0/3] os-posix: improve the error message printing Paolo Bonzini
2014-09-26 8:32 ` Gonglei (Arei)
2014-09-26 17:22 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.