hostnamed: add various debugging log messages when we determine chassis type
No actual code flow changes, just a bunch of debug messages.
This commit is contained in:
parent
965cccae8b
commit
2ac4d1d45b
|
@ -189,19 +189,25 @@ static const char* fallback_chassis(void) {
|
||||||
int v, r;
|
int v, r;
|
||||||
|
|
||||||
v = detect_virtualization();
|
v = detect_virtualization();
|
||||||
if (VIRTUALIZATION_IS_VM(v))
|
if (v < 0)
|
||||||
|
log_debug_errno(v, "Failed to detect virtualization, ignoring: %m");
|
||||||
|
else if (VIRTUALIZATION_IS_VM(v))
|
||||||
return "vm";
|
return "vm";
|
||||||
if (VIRTUALIZATION_IS_CONTAINER(v))
|
else if (VIRTUALIZATION_IS_CONTAINER(v))
|
||||||
return "container";
|
return "container";
|
||||||
|
|
||||||
r = read_one_line_file("/sys/class/dmi/id/chassis_type", &type);
|
r = read_one_line_file("/sys/class/dmi/id/chassis_type", &type);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
|
log_debug_errno(v, "Failed to read DMI chassis type, ignoring: %m");
|
||||||
goto try_acpi;
|
goto try_acpi;
|
||||||
|
}
|
||||||
|
|
||||||
r = safe_atou(type, &t);
|
r = safe_atou(type, &t);
|
||||||
free(type);
|
free(type);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
|
log_debug_errno(v, "Failed to parse DMI chassis type, ignoring: %m");
|
||||||
goto try_acpi;
|
goto try_acpi;
|
||||||
|
}
|
||||||
|
|
||||||
/* We only list the really obvious cases here. The DMI data is unreliable enough, so let's not do any
|
/* We only list the really obvious cases here. The DMI data is unreliable enough, so let's not do any
|
||||||
additional guesswork on top of that.
|
additional guesswork on top of that.
|
||||||
|
@ -240,17 +246,24 @@ static const char* fallback_chassis(void) {
|
||||||
case 0x1F: /* Convertible */
|
case 0x1F: /* Convertible */
|
||||||
case 0x20: /* Detachable */
|
case 0x20: /* Detachable */
|
||||||
return "convertible";
|
return "convertible";
|
||||||
|
|
||||||
|
default:
|
||||||
|
log_debug("Unhandled DMI chassis type 0x%02x, ignoring.", t);
|
||||||
}
|
}
|
||||||
|
|
||||||
try_acpi:
|
try_acpi:
|
||||||
r = read_one_line_file("/sys/firmware/acpi/pm_profile", &type);
|
r = read_one_line_file("/sys/firmware/acpi/pm_profile", &type);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
|
log_debug_errno(v, "Failed read ACPI PM profile, ignoring: %m");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
r = safe_atou(type, &t);
|
r = safe_atou(type, &t);
|
||||||
free(type);
|
free(type);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
|
log_debug_errno(v, "Failed parse ACPI PM profile, ignoring: %m");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* We only list the really obvious cases here as the ACPI data is not really super reliable.
|
/* We only list the really obvious cases here as the ACPI data is not really super reliable.
|
||||||
*
|
*
|
||||||
|
@ -276,6 +289,9 @@ try_acpi:
|
||||||
|
|
||||||
case 8: /* Tablet */
|
case 8: /* Tablet */
|
||||||
return "tablet";
|
return "tablet";
|
||||||
|
|
||||||
|
default:
|
||||||
|
log_debug("Unhandled ACPI PM profile 0x%02x, ignoring.", t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -911,13 +927,13 @@ static const BusObjectImplementation manager_object = {
|
||||||
.vtables = BUS_VTABLES(hostname_vtable),
|
.vtables = BUS_VTABLES(hostname_vtable),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
|
static int connect_bus(Context *c, sd_event *event, sd_bus **ret) {
|
||||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(c);
|
assert(c);
|
||||||
assert(event);
|
assert(event);
|
||||||
assert(_bus);
|
assert(ret);
|
||||||
|
|
||||||
r = sd_bus_default_system(&bus);
|
r = sd_bus_default_system(&bus);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -939,8 +955,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to attach bus to event loop: %m");
|
return log_error_errno(r, "Failed to attach bus to event loop: %m");
|
||||||
|
|
||||||
*_bus = TAKE_PTR(bus);
|
*ret = TAKE_PTR(bus);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue