launcher: Add more error logging to launcher backends
Add error logging in three different launcher backends: launcher-logind, launcher-weston-launch, and launcher-direct to indicate failures for easier debug Signed-off-by: Anurup M <anurup.m@huawei.com>
This commit is contained in:
@@ -211,8 +211,10 @@ setup_tty(struct launcher_direct *launcher, int tty)
|
|||||||
loop = wl_display_get_event_loop(launcher->compositor->wl_display);
|
loop = wl_display_get_event_loop(launcher->compositor->wl_display);
|
||||||
launcher->vt_source =
|
launcher->vt_source =
|
||||||
wl_event_loop_add_signal(loop, SIGRTMIN, vt_handler, launcher);
|
wl_event_loop_add_signal(loop, SIGRTMIN, vt_handler, launcher);
|
||||||
if (!launcher->vt_source)
|
if (!launcher->vt_source) {
|
||||||
|
weston_log("failed to add SIGRTMIN signal\n");
|
||||||
goto err_close;
|
goto err_close;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -229,8 +231,10 @@ launcher_direct_open(struct weston_launcher *launcher_base, const char *path, in
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = open(path, flags | O_CLOEXEC);
|
fd = open(path, flags | O_CLOEXEC);
|
||||||
if (fd == -1)
|
if (fd == -1) {
|
||||||
|
weston_log("couldn't open: %s! error=%s\n", path, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (geteuid() != 0) {
|
if (geteuid() != 0) {
|
||||||
weston_log("WARNING! Succeeded opening %s as non-root user."
|
weston_log("WARNING! Succeeded opening %s as non-root user."
|
||||||
@@ -239,6 +243,7 @@ launcher_direct_open(struct weston_launcher *launcher_base, const char *path, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fstat(fd, &s) == -1) {
|
if (fstat(fd, &s) == -1) {
|
||||||
|
weston_log("couldn't fstat: %s! error=%s\n", path, strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -283,7 +288,8 @@ launcher_direct_restore(struct weston_launcher *launcher_base)
|
|||||||
|
|
||||||
mode.mode = VT_AUTO;
|
mode.mode = VT_AUTO;
|
||||||
if (ioctl(launcher->tty, VT_SETMODE, &mode) < 0)
|
if (ioctl(launcher->tty, VT_SETMODE, &mode) < 0)
|
||||||
weston_log("could not reset vt handling\n");
|
weston_log("could not reset vt handling! error=%s\n",
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -300,8 +306,10 @@ launcher_direct_connect(struct weston_launcher **out, struct weston_compositor *
|
|||||||
struct launcher_direct *launcher;
|
struct launcher_direct *launcher;
|
||||||
|
|
||||||
launcher = zalloc(sizeof(*launcher));
|
launcher = zalloc(sizeof(*launcher));
|
||||||
if (launcher == NULL)
|
if (launcher == NULL) {
|
||||||
|
weston_log("failed to alloc for launcher\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
launcher->base.iface = &launcher_direct_iface;
|
launcher->base.iface = &launcher_direct_iface;
|
||||||
launcher->compositor = compositor;
|
launcher->compositor = compositor;
|
||||||
@@ -338,13 +346,16 @@ launcher_direct_get_vt(struct weston_launcher *base)
|
|||||||
{
|
{
|
||||||
struct launcher_direct *launcher = wl_container_of(base, launcher, base);
|
struct launcher_direct *launcher = wl_container_of(base, launcher, base);
|
||||||
struct stat s;
|
struct stat s;
|
||||||
if (fstat(launcher->tty, &s) < 0)
|
if (fstat(launcher->tty, &s) < 0) {
|
||||||
|
weston_log("couldn't fstat launcher tty: %s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return minor(s.st_rdev);
|
return minor(s.st_rdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct launcher_interface launcher_direct_iface = {
|
const struct launcher_interface launcher_direct_iface = {
|
||||||
|
.name = "direct",
|
||||||
.connect = launcher_direct_connect,
|
.connect = launcher_direct_connect,
|
||||||
.destroy = launcher_direct_destroy,
|
.destroy = launcher_direct_destroy,
|
||||||
.open = launcher_direct_open,
|
.open = launcher_direct_open,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
struct weston_launcher;
|
struct weston_launcher;
|
||||||
|
|
||||||
struct launcher_interface {
|
struct launcher_interface {
|
||||||
|
char *name;
|
||||||
int (* connect) (struct weston_launcher **launcher_out, struct weston_compositor *compositor,
|
int (* connect) (struct weston_launcher **launcher_out, struct weston_compositor *compositor,
|
||||||
int tty, const char *seat_id, bool sync_drm);
|
int tty, const char *seat_id, bool sync_drm);
|
||||||
void (* destroy) (struct weston_launcher *launcher);
|
void (* destroy) (struct weston_launcher *launcher);
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ launcher_logind_take_device(struct launcher_logind *wl, uint32_t major,
|
|||||||
reply = dbus_connection_send_with_reply_and_block(wl->dbus, m,
|
reply = dbus_connection_send_with_reply_and_block(wl->dbus, m,
|
||||||
-1, NULL);
|
-1, NULL);
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
|
weston_log("logind: TakeDevice on %d:%d failed.\n", major, minor);
|
||||||
r = -ENODEV;
|
r = -ENODEV;
|
||||||
goto err_unref;
|
goto err_unref;
|
||||||
}
|
}
|
||||||
@@ -106,6 +107,7 @@ launcher_logind_take_device(struct launcher_logind *wl, uint32_t major,
|
|||||||
DBUS_TYPE_BOOLEAN, &paused,
|
DBUS_TYPE_BOOLEAN, &paused,
|
||||||
DBUS_TYPE_INVALID);
|
DBUS_TYPE_INVALID);
|
||||||
if (!b) {
|
if (!b) {
|
||||||
|
weston_log("logind: error parsing reply to TakeDevice.\n");
|
||||||
r = -ENODEV;
|
r = -ENODEV;
|
||||||
goto err_reply;
|
goto err_reply;
|
||||||
}
|
}
|
||||||
@@ -173,17 +175,25 @@ launcher_logind_open(struct weston_launcher *launcher, const char *path, int fla
|
|||||||
int fl, r, fd;
|
int fl, r, fd;
|
||||||
|
|
||||||
r = stat(path, &st);
|
r = stat(path, &st);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
|
weston_log("logind: cannot stat: %s! error=%s\n", path, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!S_ISCHR(st.st_mode)) {
|
if (!S_ISCHR(st.st_mode)) {
|
||||||
|
weston_log("logind: %s is not a character special file!\n", path);
|
||||||
errno = ENODEV;
|
errno = ENODEV;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = launcher_logind_take_device(wl, major(st.st_rdev),
|
fd = launcher_logind_take_device(wl, major(st.st_rdev),
|
||||||
minor(st.st_rdev), NULL);
|
minor(st.st_rdev), NULL);
|
||||||
if (fd < 0)
|
if (fd < 0) {
|
||||||
return fd;
|
weston_log("logind: TakeDevice on %s failed, error=%s\n",
|
||||||
|
path, strerror(-fd));
|
||||||
|
errno = -fd;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Compared to weston_launcher_open() we cannot specify the open-mode
|
/* Compared to weston_launcher_open() we cannot specify the open-mode
|
||||||
* directly. Instead, logind passes us an fd with sane default modes.
|
* directly. Instead, logind passes us an fd with sane default modes.
|
||||||
@@ -195,6 +205,7 @@ launcher_logind_open(struct weston_launcher *launcher, const char *path, int fla
|
|||||||
fl = fcntl(fd, F_GETFL);
|
fl = fcntl(fd, F_GETFL);
|
||||||
if (fl < 0) {
|
if (fl < 0) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
|
weston_log("logind: cannot get file flags: %s\n", strerror(errno));
|
||||||
goto err_close;
|
goto err_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +215,7 @@ launcher_logind_open(struct weston_launcher *launcher, const char *path, int fla
|
|||||||
r = fcntl(fd, F_SETFL, fl);
|
r = fcntl(fd, F_SETFL, fl);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
|
weston_log("logind: cannot set O_NONBLOCK: %s\n", strerror(errno));
|
||||||
goto err_close;
|
goto err_close;
|
||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
@@ -816,7 +828,8 @@ err_seat:
|
|||||||
err_wl:
|
err_wl:
|
||||||
free(wl);
|
free(wl);
|
||||||
err_out:
|
err_out:
|
||||||
weston_log("logind: cannot setup systemd-logind helper (%d), using legacy fallback\n", r);
|
weston_log("logind: cannot setup systemd-logind helper error: (%s), using legacy fallback\n",
|
||||||
|
strerror(-r));
|
||||||
errno = -r;
|
errno = -r;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -847,6 +860,7 @@ launcher_logind_get_vt(struct weston_launcher *launcher)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const struct launcher_interface launcher_logind_iface = {
|
const struct launcher_interface launcher_logind_iface = {
|
||||||
|
.name = "logind",
|
||||||
.connect = launcher_logind_connect,
|
.connect = launcher_logind_connect,
|
||||||
.destroy = launcher_logind_destroy,
|
.destroy = launcher_logind_destroy,
|
||||||
.open = launcher_logind_open,
|
.open = launcher_logind_open,
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ weston_launcher_connect(struct weston_compositor *compositor, int tty,
|
|||||||
const struct launcher_interface *iface = *it;
|
const struct launcher_interface *iface = *it;
|
||||||
struct weston_launcher *launcher;
|
struct weston_launcher *launcher;
|
||||||
|
|
||||||
|
weston_log("Trying %s launcher...\n", iface->name);
|
||||||
if (iface->connect(&launcher, compositor, tty, seat_id, sync_drm) == 0)
|
if (iface->connect(&launcher, compositor, tty, seat_id, sync_drm) == 0)
|
||||||
return launcher;
|
return launcher;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,12 +253,17 @@ launcher_weston_environment_get_fd(const char *env)
|
|||||||
int fd, flags;
|
int fd, flags;
|
||||||
|
|
||||||
e = getenv(env);
|
e = getenv(env);
|
||||||
if (!e || !safe_strtoint(e, &fd))
|
if (!e || !safe_strtoint(e, &fd)) {
|
||||||
|
weston_log("could not get launcher fd from env\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
flags = fcntl(fd, F_GETFD);
|
flags = fcntl(fd, F_GETFD);
|
||||||
if (flags == -1)
|
if (flags == -1) {
|
||||||
|
weston_log("could not get fd flags!, env: %s, error: %s\n",
|
||||||
|
env, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
|
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
|
||||||
unsetenv(env);
|
unsetenv(env);
|
||||||
@@ -297,6 +302,7 @@ launcher_weston_launch_connect(struct weston_launcher **out, struct weston_compo
|
|||||||
launcher);
|
launcher);
|
||||||
if (launcher->source == NULL) {
|
if (launcher->source == NULL) {
|
||||||
free(launcher);
|
free(launcher);
|
||||||
|
weston_log("failed to get weston-launcher socket fd event source\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,13 +335,16 @@ launcher_weston_launch_get_vt(struct weston_launcher *base)
|
|||||||
{
|
{
|
||||||
struct launcher_weston_launch *launcher = wl_container_of(base, launcher, base);
|
struct launcher_weston_launch *launcher = wl_container_of(base, launcher, base);
|
||||||
struct stat s;
|
struct stat s;
|
||||||
if (fstat(launcher->tty, &s) < 0)
|
if (fstat(launcher->tty, &s) < 0) {
|
||||||
|
weston_log("could not fstat launcher tty: %s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return minor(s.st_rdev);
|
return minor(s.st_rdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct launcher_interface launcher_weston_launch_iface = {
|
const struct launcher_interface launcher_weston_launch_iface = {
|
||||||
|
.name = "weston_launch",
|
||||||
.connect = launcher_weston_launch_connect,
|
.connect = launcher_weston_launch_connect,
|
||||||
.destroy = launcher_weston_launch_destroy,
|
.destroy = launcher_weston_launch_destroy,
|
||||||
.open = launcher_weston_launch_open,
|
.open = launcher_weston_launch_open,
|
||||||
|
|||||||
Reference in New Issue
Block a user