From: Gonglei <arei.gonglei@huawei.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: "peter.maydell@linaro.org" <peter.maydell@linaro.org>,
"Huangweidong (C)" <weidong.huang@huawei.com>,
"qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
Luonengjun <luonengjun@huawei.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"armbru@redhat.com" <armbru@redhat.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"Huangpeng (Peter)" <peter.huangpeng@huawei.com>
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/4] os-posix: report error message when lock file failed
Date: Fri, 24 Oct 2014 16:56:17 +0800 [thread overview]
Message-ID: <544A1431.9050109@huawei.com> (raw)
In-Reply-To: <544A007F.2090806@msgid.tls.msk.ru>
On 2014/10/24 15:32, Michael Tokarev wrote:
> On 09/25/2014 01:46 PM, arei.gonglei@huawei.com wrote:
>> 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 | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/os-posix.c b/os-posix.c
>> index 9d5ae70..89831dc 100644
>> --- a/os-posix.c
>> +++ b/os-posix.c
>> @@ -316,6 +316,7 @@ int qemu_create_pidfile(const char *filename)
>> return -1;
>> }
>> if (lockf(fd, F_TLOCK, 0) == -1) {
>> + error_report("lock file '%s' failed: %s", filename, strerror(errno));
>> close(fd);
>> return -1;
>> }
>
>
> I think I'll just revert this patch, because indeed, it makes
> no sense to do this like that.
>
> Context:
>
> qemu_create_pidfile() is only created from main(), and there,
> if that function returns failure, os_pidfile_error() function
> is called, to, guess that, report error (which is done differently
> whenever we're daemonizing or not).
>
> qemu_create_pidfile() function has several error returns, this
> lockf() failure is one of them, there are others (another shown
> in the patch context too).
>
Yes, agree.
> So this patch makes whole thing inconsistent at least.
>
> If we need to show error message when we're daemonizing, it
> looks like we should modify os_pidfile_error() routine to always
> report error and only after that check for daemon mode. This way
> all errors will be reported the same way.
>
In os_pidfile_error(), like below...
if (write(fds[1], &status, 1) != 1) {
perror("daemonize. Writing to pipe\n");
}
will call its child process to report error:
else if (status == 1) {
fprintf(stderr, "Could not acquire pidfile\n");
exit(1);
}
I just want to make the error message more clear so that
people can find the root reasons of errors as soon as possible. :)
> But I really wonder if we actually need os_pidfile_error() in the
> first place, why this can't be done in qemu_create_pidfile().
>
> So, I'm reverting this change now, to be revisited very soon.
>
If you think that's better, I'm fine with it.
Best regards,
-Gonglei
next prev parent reply other threads:[~2014-10-24 8:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 9:46 [Qemu-devel] [PATCH 0/4] os: convert fprintf/perror to error_report arei.gonglei
2014-09-25 9:46 ` [Qemu-devel] [PATCH 1/4] os-posix/win32: " arei.gonglei
2014-09-25 12:33 ` Eric Blake
2014-09-25 12:53 ` Gonglei (Arei)
2014-09-25 9:46 ` [Qemu-devel] [PATCH 2/4] os-posix: report error message when lock file failed arei.gonglei
2014-10-01 8:45 ` Markus Armbruster
2014-10-01 9:12 ` Gonglei
2014-10-01 10:24 ` Markus Armbruster
2014-10-01 11:58 ` Gonglei
2014-10-01 12:38 ` Markus Armbruster
2014-10-24 7:32 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-10-24 8:56 ` Gonglei [this message]
2014-09-25 9:46 ` [Qemu-devel] [PATCH 3/4] osdep: convert fprintf to error_report arei.gonglei
2014-09-25 12:35 ` Eric Blake
2014-09-25 12:54 ` Gonglei (Arei)
2014-09-25 9:46 ` [Qemu-devel] [PATCH 4/4] oslib-posix/win32: convert fprintf/perror " arei.gonglei
2014-09-25 12:36 ` Eric Blake
2014-09-25 12:55 ` Gonglei (Arei)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=544A1431.9050109@huawei.com \
--to=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=luonengjun@huawei.com \
--cc=mjt@tls.msk.ru \
--cc=pbonzini@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=weidong.huang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).