os-posix: report error message when lock file failed

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>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
Gonglei 2014-09-26 16:14:32 +08:00 committed by Michael Tokarev
parent 97699eff3a
commit e5048d15ce
1 changed files with 2 additions and 0 deletions

View File

@ -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;
}