Commit Graph

122 Commits

Author SHA1 Message Date
Richard Hughes
003ae2ba3c trivial: Add FuProgress to FuPlugin->backend_device_added()
Now we know fu_synaptics_mst_plugin_device_rescan() takes ~267ms...
2023-02-23 13:04:12 -06:00
Richard Hughes
5ddaf0f610 Remove unused API for setting backend tags
It turns out we do not want to know the current phase of the device, and we can
achieve the same thing tagging the GUsbDevice manually and clearing the events
at exactly the correct time.
2023-02-23 13:04:11 -06:00
Richard Hughes
72f5c1e01e trivial: Make the installed-tests redfish.conf secure to avoid a warning
Also, don't attempt to change the permissions if the correct one is already
set.
2023-01-17 19:29:39 +00:00
Richard Hughes
83c90262d1 Remove plugin and device GRWLocks
This only have any protective effect if we're using multiple threads -- which
we're not. Removing these unused locks does not affect startup speed, but does
drop the idle RSS by ~10kB.
2022-12-12 17:29:38 +00:00
Richard Hughes
7c4398615e trivial: Watch the plugin config even if there's no ->startup() 2022-10-25 06:54:08 -05:00
Richard Hughes
5987a9691a Ensure the configure file is correct for built-in plugins
The fu_plugin_open() function is only called for modular plugins.
2022-10-25 06:54:08 -05:00
Richard Hughes
617137922d Add some more profiling to debug custom device GType creation
It turns out using tss2_esys is slow (200ms) -- and now we know.
2022-10-07 14:41:48 +01:00
Richard Hughes
1b6438e8ff trivial: Only set the fallback builtin plugin name when required
We only want to use the gtype-generated name if the plugin has not already used
fu_plugin_set_name() to set a custom name.
2022-10-04 08:32:18 +01:00
Richard Hughes
1f261ba283 Rename the source file and private data of modular plugins
This would allow us to convert more easily to a built-in plugin in the future
and means we match the source style used in 97% of the other plugins.

No logic changes.
2022-09-30 15:20:23 +01:00
Richard Hughes
fc3cfbad92 Do not check the build hash of modular plugins
We removed the abilty to easily build modular plugins, and so we don't need to
worry so much about random 3rd party modules being loaded.
2022-09-30 14:19:56 +01:00
Richard Hughes
439c364f46 trivial: Fold FuPluginVfuncs into FuPluginClass
This adds 7 pointer-size blocks of wasted space for each modular plugin, and
three pointers for builtin plugins, but allows us to use the exact same vfuncs
when building plugins in either mode.

This will allow us to convert nearly all the plugins to being builtin.
2022-09-28 14:42:04 +01:00
Richard Hughes
f8400ffaae trivial: Rename the FuPluginClass signals callbacks
The aim is to fold FuPluginVfuncs into this, and the names clash.
2022-09-28 14:42:04 +01:00
Richard Hughes
2a5f7766a4 trivial: Remove the deprecated fu_plugin_set_secure_config_value() 2022-09-28 14:42:04 +01:00
Richard Hughes
99e9e5d523 Allow compiling plugin as built-in GObjects
Allow plugins to be built into libfwupdpluginbuiltin.so and created via GType.
2022-09-28 12:52:00 +01:00
Richard Hughes
24db10ac1c trivial: Add fu_plugin_set_context() for future use 2022-09-26 22:24:41 +01:00
Richard Hughes
c73a55faa1 Remove a potential foot-gun when saving config values
If a specific plugin calls fu_plugin_set_secure_config_value() and then
fu_plugin_set_config_value() then we'll save the file with the world-readable
permissions.

Set a plugin flag to say that 'this plugin is storing sensitive details' which
allows us to use the same entrypoint and also fix up any files at startup that
do not have the correct permissions.
2022-09-22 14:47:12 +01:00
Richard Hughes
ea676855f2 Never save the Redfish passwords to a file readable by users
When the redfish plugin automatically creates an OPERATOR user account on the
BMC we save the autogenerated password to /etc/fwupd/redfish.conf, ensuring it
is chmod'ed to 0660 before writing the file with g_key_file_save_to_file().

Under the covers, g_key_file_save_to_file() calls g_file_set_contents() with
the keyfile string data.
I was under the impression that G_FILE_CREATE_REPLACE_DESTINATION was being
used to copy permissions, but alas not.

GLib instead calls g_file_set_contents_full() with the mode hardcoded to 0666,
which undoes the previous chmod().

Use g_file_set_contents_full() with the correct mode for newer GLib versions,
and provide a fallback with the same semantics for older versions.
2022-09-22 14:46:44 +01:00
Richard Hughes
139188a5b0 Allow adding backend tags to devices
This allows the backend to identify the specific device for a specific phase.

For instance, there might be a pre-update runtime, a bootloader and a
post-update runtime and allowing tags to be saved to the backend object allows
us to identify each version of the same physical device.

This takes us one step closer to emulating a complete byte-perfect end-to-end
update without actual hardware installed.
2022-09-14 16:54:55 +01:00
Richard Hughes
77006b75eb Set the target value on the security attribute
Semantically it is the desire of the security attribute, not the bios
attribute, i.e. you could imagine that a specific attribute would have
to be *foo or bar or baz* for HSI-1 and *only foo* for HSI-2

Also make it easier to add possible BIOS attribute target values in
plugin code.
2022-08-01 07:12:18 +01:00
Richard Hughes
829258401e Allow plugins and backends to print debugging information to the console
This is really useful for debugging.
2022-07-28 16:10:06 +01:00
Richard Hughes
f336a43936 Avoid duplicate device actions where possible
This removes at least two open(),probe(),setup(),close() chains for the
common case where the vfuncs are not implemented.
2022-07-20 19:01:02 +01:00
Richard Hughes
2203b3ce7b trivial: gi-docgenize some of the function comments 2022-06-14 14:36:52 -05:00
Richard Hughes
067d7d8088 Split out the path helpers to a new source file 2022-06-14 14:36:52 -05:00
Richard Hughes
3f77af3cd4 Split out the kernel helpers to a new source file 2022-06-14 14:36:52 -05:00
Richard Hughes
4b1313b406 Split out the GByte helpers to a new source file 2022-06-14 14:36:52 -05:00
Richard Hughes
9d33c29e92 Split out the string helpers to a new source file 2022-06-14 14:36:52 -05:00
Richard Hughes
9b29d70f31 Add a progress flag to indicate for when the child returns early
Using `fu_progress_finished(fu_progress_get_child(progress))` is IMHO
a hacky workaround.
2022-06-14 14:31:19 +01:00
Richard Hughes
e6b487e762 Add FuProgress to ->startup() and ->coldplug()
This allows us to profile the daemon startup so we can find any plugins
taking an inordinate amount of time to start.
2022-06-04 20:21:50 +01:00
Richard Hughes
dc91d59f8e Remove the recently added fu_progress_add_step_full()
Just break API instead.
2022-06-03 13:47:11 -05:00
Richard Hughes
d6fd08e3a5 Remove some deprecated API 2022-06-03 13:47:11 -05:00
Richard Hughes
7e62e5b0c9 Add a FuProgress to ->verify() 2022-06-03 13:47:11 -05:00
Richard Hughes
d3d7cfa816 Add plugin quirk keys earlier in the startup process
This allows creating the silo when starting the engine with custom
plugin keys such as WacomI2cFlashBaseAddr.

If we move the plugin initialization earlier then we don't get the
HwID matches, so we really do have to split this into a 4-stage startup,
e.g. ->load(), ->init(), ->startup() and ->coldplug().
2022-05-09 11:13:52 +01:00
Richard Hughes
2d5186622c Add FuProgress to ->prepare and ->cleanup
Some plugins were creating local versions (which were not attached to
the daemon progress in any way) as a workaround as they needed to do
actions that took a long time to complete.
2022-04-15 16:50:06 +01:00
Richard Hughes
da37d93eb0 trivial: Remove some long dead docs about fu_plugin_device_add_delay() 2022-03-16 09:18:29 +00:00
Richard Hughes
ca43733a8c Show why devices are not marked as updatable
At the moment a lot of the failures are only visible when running the
daemon in verbose mode, and the inhibit functionalit provides us a way
to unset FWUPD_DEVICE_FLAG_UPDATABLE from multiple places, as well as
setting the update error for the user to see why.
2022-01-13 12:40:56 +00:00
Richard Hughes
e17a107ce1 trivial: Cast the g_signal_connect() object to allow static analysis
This is useful when using https://gitlab.freedesktop.org/tartan/tartan
2022-01-03 22:46:23 +00:00
Richard Hughes
2e99055d1e trivial: Add some more annotations for language bindings 2022-01-03 22:46:23 +00:00
Mario Limonciello
17db067d13 libfwupdplugin: add a helper to set a config file to secure 2021-12-17 11:05:05 -06:00
Richard Hughes
a561b1a8ba Make the plugin startup order deterministic
At the moment only the order is considered, and the rest is unspecified
by the filesystem.
2021-12-10 15:58:11 +00:00
Yehezkel Bernat
86286c3efd trivial: remove outdated comment
This comment became outdated with #3940, where the `NULL` check for `priv->ctx` that followed by early return was removed
2021-11-09 20:20:03 +00:00
Richard Hughes
e87fc05ab9 Speed up the daemon startup by ~2% by doing dlsym much less
We were calling g_module_symbol() 2703 times, which is actually more
expensive than you'd think.

It also means the plugins are actually what we tell people they are:
A set of vfuncs that get run. The reality before that they were dlsym'd
functions that get called at pretty random times.
2021-11-09 12:02:07 +00:00
Richard Hughes
eb508129a8 trivial: Remove devices already added on failed coldplug
Calling into the now-disabled makes things very tricky to debug.
2021-11-09 07:42:05 +00:00
Richard Hughes
1a077289bc Speed up daemon startup by 15%
During my fwupd startup fu_plugin_has_custom_flag gets called 21 times
which causes all HWIDs to be enumerated with 346 calls to the quite
expensive fu_context_lookup_quirk_by_id() function.

Move the flag to a private hashset and enumerate the HWIDs only during
startup. There's nothing plugin specific about them anyway...
2021-11-03 07:14:37 +00:00
Richard Hughes
ccc0f9b0c6 trivial: Assign the context of incorporated devices early
This means we can use GObject->constructed() to copy the context over
to FuDevice helpers that also require the context.
2021-10-15 15:57:57 +01:00
Richard Hughes
907a60573d bcm57xx: Fix a FuProgress thinko 2021-09-21 16:20:20 +01:00
Richard Hughes
1ff96eb4b3 Restore the ABI for fu_device_detach() and provide new symbols
Quite a few plugins are using a FuDeviceLocker to detach then attach in
the error path, and finding them isn't easy as we explicitly cast to a
FuDeviceLockerFunc.

For sanity, just provide both symbols so we can do the right thing in
both cases. It seems like a sensible thing to allow.

Fixes https://github.com/fwupd/fwupd/issues/3771
2021-09-17 16:35:21 +01:00
Richard Hughes
40cd18fa97 Allow using a per-device global percentage completion
It's actually quite hard to build a front-end for fwupd at the moment
as you're never sure when the progress bar is going to zip back to 0%
and start all over again. Some plugins go 0..100% for write, others
go 0..100% for erase, then again for write, then *again* for verify.

By creating a helper object we can easily split up the progress of the
specific task, e.g. write_firmware().

We can encode at the plugin level "the erase takes 50% of the time, the
write takes 40% and the read takes 10%". This means we can have a
progressbar which goes up just once at a consistent speed.
2021-09-13 14:28:15 +01:00
Richard Hughes
33a24c77b7 trivial: Add fu_plugin_set_config_value() for future usage 2021-09-07 17:25:37 +01:00
Mario Limonciello
55de39c077 trivial: reformat the whole tree to match new format 2021-08-24 11:18:40 -05:00
Richard Hughes
6f8ab5e70c Restart the daemon if any of the the plugin config files are modified
Fixes https://github.com/fwupd/fwupd/issues/3625
2021-08-11 14:27:47 +01:00