mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-16 05:41:12 +00:00
Allow overriding the detected machine type
This makes developing HSI tests and UIs much easier when using VMs or containers.
This commit is contained in:
parent
2aed732249
commit
474a57b6f7
@ -20,6 +20,10 @@ with a non-standard filesystem layout.
|
|||||||
* standard glibc variables like `LANG` are also honored for CLI tools that are translated
|
* standard glibc variables like `LANG` are also honored for CLI tools that are translated
|
||||||
* libcurl respects the session proxy, e.g. `http_proxy`, `all_proxy`, `sftp_proxy` and `no_proxy`
|
* libcurl respects the session proxy, e.g. `http_proxy`, `all_proxy`, `sftp_proxy` and `no_proxy`
|
||||||
|
|
||||||
|
## daemon
|
||||||
|
|
||||||
|
* `FWUPD_MACHINE_KIND` can be used to override the detected machine type, e.g. `physical`, `virtual`, or `container`
|
||||||
|
|
||||||
## Self Tests
|
## Self Tests
|
||||||
|
|
||||||
* `CI_NETWORK` if CI is running with network access
|
* `CI_NETWORK` if CI is running with network access
|
||||||
|
@ -54,6 +54,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(PolkitSubject, g_object_unref)
|
|||||||
#endif /* HAVE_POLKIT */
|
#endif /* HAVE_POLKIT */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
FU_MAIN_MACHINE_KIND_UNKNOWN,
|
||||||
FU_MAIN_MACHINE_KIND_PHYSICAL,
|
FU_MAIN_MACHINE_KIND_PHYSICAL,
|
||||||
FU_MAIN_MACHINE_KIND_VIRTUAL,
|
FU_MAIN_MACHINE_KIND_VIRTUAL,
|
||||||
FU_MAIN_MACHINE_KIND_CONTAINER,
|
FU_MAIN_MACHINE_KIND_CONTAINER,
|
||||||
@ -85,6 +86,18 @@ typedef struct {
|
|||||||
FuMainMachineKind machine_kind;
|
FuMainMachineKind machine_kind;
|
||||||
} FuMainPrivate;
|
} FuMainPrivate;
|
||||||
|
|
||||||
|
static FuMainMachineKind
|
||||||
|
fu_main_machine_kind_from_string(const gchar *kind)
|
||||||
|
{
|
||||||
|
if (g_strcmp0(kind, "physical") == 0)
|
||||||
|
return FU_MAIN_MACHINE_KIND_PHYSICAL;
|
||||||
|
if (g_strcmp0(kind, "virtual") == 0)
|
||||||
|
return FU_MAIN_MACHINE_KIND_VIRTUAL;
|
||||||
|
if (g_strcmp0(kind, "container") == 0)
|
||||||
|
return FU_MAIN_MACHINE_KIND_CONTAINER;
|
||||||
|
return FU_MAIN_MACHINE_KIND_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_main_sigterm_cb(gpointer user_data)
|
fu_main_sigterm_cb(gpointer user_data)
|
||||||
{
|
{
|
||||||
@ -2187,6 +2200,7 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
gboolean immediate_exit = FALSE;
|
gboolean immediate_exit = FALSE;
|
||||||
gboolean timed_exit = FALSE;
|
gboolean timed_exit = FALSE;
|
||||||
|
const gchar *machine_kind = g_getenv("FWUPD_MACHINE_KIND");
|
||||||
const gchar *socket_filename = g_getenv("FWUPD_DBUS_SOCKET");
|
const gchar *socket_filename = g_getenv("FWUPD_DBUS_SOCKET");
|
||||||
const GOptionEntry options[] = {
|
const GOptionEntry options[] = {
|
||||||
{"timed-exit",
|
{"timed-exit",
|
||||||
@ -2237,6 +2251,23 @@ main(int argc, char *argv[])
|
|||||||
(GDestroyNotify)fu_main_sender_item_free);
|
(GDestroyNotify)fu_main_sender_item_free);
|
||||||
priv->loop = g_main_loop_new(NULL, FALSE);
|
priv->loop = g_main_loop_new(NULL, FALSE);
|
||||||
|
|
||||||
|
/* allow overriding for development */
|
||||||
|
if (machine_kind != NULL) {
|
||||||
|
priv->machine_kind = fu_main_machine_kind_from_string(machine_kind);
|
||||||
|
if (priv->machine_kind == FU_MAIN_MACHINE_KIND_UNKNOWN) {
|
||||||
|
g_printerr("Invalid machine kind specified: %s\n", machine_kind);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (fu_main_is_hypervisor()) {
|
||||||
|
priv->machine_kind = FU_MAIN_MACHINE_KIND_VIRTUAL;
|
||||||
|
} else if (fu_main_is_container()) {
|
||||||
|
priv->machine_kind = FU_MAIN_MACHINE_KIND_CONTAINER;
|
||||||
|
} else {
|
||||||
|
priv->machine_kind = FU_MAIN_MACHINE_KIND_PHYSICAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* load engine */
|
/* load engine */
|
||||||
priv->engine = fu_engine_new(FU_APP_FLAGS_NONE);
|
priv->engine = fu_engine_new(FU_APP_FLAGS_NONE);
|
||||||
g_signal_connect(FU_ENGINE(priv->engine),
|
g_signal_connect(FU_ENGINE(priv->engine),
|
||||||
@ -2306,13 +2337,6 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* are we a VM? */
|
|
||||||
if (fu_main_is_hypervisor()) {
|
|
||||||
priv->machine_kind = FU_MAIN_MACHINE_KIND_VIRTUAL;
|
|
||||||
} else if (fu_main_is_container()) {
|
|
||||||
priv->machine_kind = FU_MAIN_MACHINE_KIND_CONTAINER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* own the object */
|
/* own the object */
|
||||||
if (socket_filename != NULL) {
|
if (socket_filename != NULL) {
|
||||||
g_autofree gchar *address = g_strdup_printf("unix:path=%s", socket_filename);
|
g_autofree gchar *address = g_strdup_printf("unix:path=%s", socket_filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user