Commit Graph

138 Commits

Author SHA1 Message Date
Mario Limonciello
0e500321d7 fu-engine: Check multiple plugins if quirks match
`ata` and `emmc` both have block devices and so they both need to
be checked
2019-10-18 14:18:09 -05:00
Patrick Rudolph
a60b547edb fu-plugin: Add fu_plugin_get_hwid_replace_value
Allow a plugins to cherry-pick specific HWIDs and add them as InstanceIds.
By adding them as InstanceIds rather than adding them as GUIDs, the
original string can be found in the output generated by:
$ fupdmgr get-devices

Example output:
  Guid:                 230c8b18-8d9b-53ec-838b-6cfc0383493a <- main-system-firmware
  Guid:                 de6fd40f-4ec9-5c0b-95e1-8fb13d1b030c <- LENOVO&ThinkPad T410&2537VG5
  Guid:                 978b0d18-bfe9-5279-9a9f-68dc247a705f <- LENOVO&ThinkPad T410&LENOVO&2537VG5

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2019-10-17 18:31:01 +02:00
Mario Limonciello
8fa0b382fa Add new flags can-verify and can-verify-image
These are used to indicate that the device can verify checksums or
can dump an image for checksumming.
2019-10-14 12:41:09 -05:00
Richard Hughes
cbf53fe52d trivial: Fix a recent regression causing a double-free
This was introduced accidentally in a9be536ef0.

Fixes https://github.com/fwupd/fwupd/issues/1461
2019-10-14 12:31:03 +01:00
Mario Limonciello
a9be536ef0 trivial: fu-plugin: quiet down debug output for optionrom plugin
All of these messages continually output are just noise for unsupported
devices:

```
18:11:52:0851 FuPlugin             using generic udev_device_added() on optionrom
18:11:52:0851 FuEngine             optionrom ignoring: no FWUPD_GUID property
```
2019-10-12 14:29:21 -05:00
Richard Hughes
f0eb091173 Read firmware back from the device as a FuFirmware
Returning a GBytes is not good enough when the device may be returning multiple
partitions which have to be stored as FuFirmwareImage objects.
2019-10-10 11:57:48 +01:00
Richard Hughes
d8a8d5e776 Set all FuUdevDevice plugins to use FU_QUIRKS_PLUGIN
This speeds up startup as we're only calling fu_plugin_udev_device_added() on
plugins that can actually handle the device.
2019-10-09 20:02:16 +01:00
Richard Hughes
42f33df3dc trivial: Remove some now-unused vfuncs 2019-10-07 12:37:21 +01:00
Richard Hughes
989acf12e7 Create the custom plugin GType in common code
This reduces the amount of boilerplate in plugins.
2019-10-07 12:37:21 +01:00
Richard Hughes
7f67721432 Reduce more boilerplate in plugins 2019-10-07 12:37:21 +01:00
Richard Hughes
4b30380e78 Provide a default implementation of common FuDevice actions
This reduces the amount of boilerplate in each plugin.

    32 files changed, 156 insertions(+), 584 deletions(-)
2019-10-04 14:57:32 +01:00
Richard Hughes
1984180592 Add a DMI quirk for the Minnowboard Turbot
The fwupd UEFI plugin refuses to start if bit 3 of the "BIOS Characteristics
Extension Byte 2" (13h) is cleared. Bit 3 is UEFI Specification is supported.

Also, double-check that /sys/firmware/efi does not exist before disabling the
plugin as other machines may be affected too. The quirk then acts to supress
the console warning about the broken SMBIOS value.

Fixes https://github.com/fwupd/fwupd/issues/1342
2019-09-10 20:39:45 +01:00
Richard Hughes
5e952ce35f Add a ->udev_device_changed plugin vfunc
This allows plugins to rescan hardware based on uevents of any device class
registered with fu_plugin_add_udev_subsystem().

Additionally, the events are rate limited to avoid causing lots of extra plugin
processing when replugging hardware.
2019-08-26 13:55:55 +01:00
Richard Hughes
b106542aef trivial: Fix a potential crash when using FuPlugin in the self tests 2019-08-15 16:50:44 +01:00
Richard Hughes
dfaca2de2e Fix a crash when stopping the fwupd service
This difficult to debug bug only showed up when the fwupd service was stopped,
which the user never noticed, but services like abrt were still keen to report.
The root issue was that the call to fu_plugin_get_smbios_data() in
fu-plugin-uefi.c:fu_plugin_startup() was freeing the returned const GBytes,
which rippled down all the way to a double-free deep in libxmlb.

It's somewhat unusual to have a const GBytes, so just change the plugin helper
to returned a ref'd copy, on the logic a potential 16 byte memory leak is better
than a double-free when the next plugin gets the logic the wrong way around.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1734746
2019-08-01 13:00:51 +01:00
Richard Hughes
161e9b531b Use the newer features of GRWLock rather than reinventing it
The debug features the object provides are not useful and are much too verbose
to be useful.

Backport the new reader/writer g_autoptr defines to avoid bumping the GLib dep.

Most of the work was done by Kalev Lember <klember@redhat.com>, many thanks.
2019-06-12 15:20:27 +01:00
Richard Hughes
0a90626413 Use the correct file extension for the offline updates cache
For a long time these have been cabinet archives, not UEFI update capsules.
2019-05-18 14:07:09 +01:00
Richard Hughes
5cbb5cf908 Allow using --force to trigger a duplicate offline update 2019-05-07 14:30:07 +01:00
Richard Hughes
8499930a45 trivial: Fix a memory leak found using libasan 2019-05-02 10:46:12 +01:00
Mario Limonciello
e1b4b20978 Dynamically read path to use for /system-update
This allows `fwupdoffline` to work in installations that don't use
`/var/lib/fwupd`.
2019-05-01 09:24:55 -05:00
Richard Hughes
dce91204c9 Fix some typos spotted using codespell 2019-04-08 12:47:53 +01:00
Richard Hughes
994b4d9532 Save the new version in the history database for offline updates
This allows us to write the downgrade/upgrade text correctly in fwupdoffline.
2019-03-25 16:59:48 +00:00
Richard Hughes
809abea834 Ask to reboot after scheduling an offline firmware update 2019-03-23 11:14:44 +00:00
Richard Hughes
db69c81e86 trivial: Show the progressbar properly when scheduling complete 2019-03-23 10:52:47 +00:00
Richard Hughes
484ee298da Do not fail when scheduling more than one update to be run offline 2019-03-23 10:52:14 +00:00
Richard Hughes
42a1b9aea3 trivial: Make testing the offline update easier by allowing reinstalls
Only refuse to schedule an offline update if the device is already pending.
2019-03-21 20:58:42 +00:00
Richard Hughes
c9223be26c Add optional vfuncs to allow detaching and attaching verify()
Some devices (e.g. Wacom, DFU and SuperIO) require the device to be in
'bootloader' mode before the device checksums can be populated.

Rather than each plugin handle both the open()->detach()->detach()->close()
sequence handle this in the plugin loader. It's not super-easy to do the right
thing for the failure case, and having two new dedicated vfuncs makes it a lot
simpler.
2019-03-19 20:25:26 +00:00
Mario Limonciello
96a0dd5606 Add a support for delayed activation
This is intended for devices that it is not safe to immediately activate
the firmware.  It may be called at a more convenient time instead.

Both fwupdmgr and fwupdtool support the feature.

- if called at runtime with fwupdmgr it uses the daemon
- during shutdown fwupdtool uses the pending.db to perform this feature.
2019-02-27 09:04:54 +00:00
Richard Hughes
c6c312f267 trivial: Move fu_plugin_runner_schedule_update() into the engine 2019-02-04 14:54:54 +00:00
Richard Hughes
f425d29a28 Show a console warning if loading an out-of-tree plugin
Fixes https://github.com/hughsie/fwupd/issues/950
2019-01-19 07:26:20 +00:00
Richard Hughes
f803964e37 Add _NEEDS_SHUTDOWN flag for devices
Some devices require the system to be powered down and back up, rather than
just being "warm" rebooted.
2019-01-17 16:35:34 +00:00
Richard Hughes
08435169a7 trivial: Don't invalidate the current checksums for fw that requries a reboot 2018-12-14 19:23:04 +00:00
Richard Hughes
1812fc783b trivial: Clear the device checksums only if the plugin implements verify()
This ensures that plugins that set the checksums in probe() or setup() don't
get erased by accident.
2018-12-14 19:23:04 +00:00
Richard Hughes
cd2fb3eb62 Check plugins set error on failure
Don't explode in a ball of flames if the plugin forgets to set the error.
This at least gives us a journal warning when a plugin goes crazy.
2018-11-30 15:22:17 +00:00
Richard Hughes
75b965d01d Shut down the daemon after 2h of inactivity
Plugins are allowed to 'opt-out' of this behaviour using _RULE_INHIBITS_IDLE.
This should be used where waking up the hardware to coldplug is expensive,
either from a power consumption point of view, or if other artifacts are going
to be seem -- for instance if the screen flickers when probing display devices.

This functionality is also inhibited when the actual upgrade is happening,
for obvious reasons.

Admins can turn off this auto-sleep behaviour by editing the daemon.conf file.

Fixes https://github.com/hughsie/fwupd/issues/417
2018-11-21 18:54:44 +00:00
Richard Hughes
aabdc371c1 Query the XbSilo when calling fu_plugin_check_supported()
This means we don't have to have all the thousands of GUIDs as tiny allocated
strings being passed around to all plugins in a GPtrArray.

This also reduces our heap usage by about 6%.
2018-11-14 15:32:55 +00:00
Richard Hughes
e9dfeb49c1 trivial: Remove unused functionality 2018-11-14 15:32:55 +00:00
Richard Hughes
3c8ada3f80 Don't segfault if a plugin returns FALSE from UpdateFunc with no error set
This is clearly a plugin bug that needs fixing, but exploding in a ball of
flames is not what anybody wants to see.
2018-10-12 10:34:12 +01:00
Richard Hughes
be78d0f0ce trivial: Remove unused header 2018-10-11 07:54:01 +01:00
Richard Hughes
37d0943844 Add FuMutex helper to make various parts of the daemon thread-safe 2018-09-12 16:10:38 +01:00
Richard Hughes
b08e7bc7aa trivial: Set a log domain for each file
This allows us to do something like:

G_MESSAGES_DEBUG=FuEngine ./src/fwupd
2018-09-11 18:59:05 +01:00
Richard Hughes
ebae396d0a udev: Do not add devices after a small delay
Now devices can have multiple GUIDs and do not share platform IDs there is
really no point waiting to add the device.

This allows us to remove a whole lot of code for this now-unused functionality.
2018-09-09 16:24:30 +01:00
Richard Hughes
c125ec02ed Clarify what the platform ID actually is by renaming it
It wasn't hugely clear what the platform ID was actually meant to represent. In
some cases it was being used like a physical ID, in others it was a logical ID,
and in others it was both. In some cases it was even used as a sysfs path.

Clear up all the confusion by splitting the platform ID into two parts, an
optional *physical* ID to represent the electrical connection, and an optional
*logical* ID to disambiguate composite devices with the same physical ID.

Also create an explicit sysfs_path getter for FuUdevDevice to make this clear.

This allows WAIT_FOR_REPLUG to always work, rather than depending on the order
that the GUIDs were added, and that the kernel would always return the same
sysfs path (which it doesn't have to do, especially for hidraw devices).
2018-09-06 16:22:46 +01:00
Richard Hughes
2c0635ae55 trivial: Fix up some more gtk-doc issues 2018-09-04 14:52:46 +01:00
Richard Hughes
127248560b trivial: Modernize FuPlugin to use 'self' as the instance name 2018-09-04 08:22:39 -05:00
Richard Hughes
ff704414f6 Use superclassed versions of FuDevice when calling udev_added() and usb_added()
The daemon creates a baseclass of either FuUsbDevice or FuUdevDevice when the
devices are added or coldplugged to match the quirk database and to find out
what plugin to run.

This is proxied to plugins, but they are given the GUsbDevice or GUdevDevice and
the FuDevice is just thrown away. Most plugins either use a FuUsbDevice or
superclassed version like FuNvmeDevice and so we re-create the FuDevice, re-probe
the hardware, re-query the quirk database and then return this to the daemon.

In some cases, plugins actually probe the hardware three times (!) by creating
a FuUsbDevice to get the quirks, so that the plugin knows what kind of
superclass to create, which then itself probes the hardware again.

Passing the temporary FuDevice to the plugins means that the simplest ones can
just fu_plugin_device_add() the passed in object, or create a superclass and
incorporate the actual GUsbDevice and all the GUIDs.

This breaks internal plugin API but speeds up startup substantially and deletes
a lot of code.
2018-09-04 08:22:39 -05:00
Mario Limonciello
e260ead594 Notify all plugins of device removals through a new vfunc 2018-09-04 10:00:52 +01:00
Richard Hughes
6dec401a67 Store the DeviceInstanceId as a GUID in the quirk database
This allows us to match non-DeviceID GUIDs, and also GUIDs we don't know how to
generate.

To make this fully useful, search for device quirks when GUIDs are added.
2018-08-28 18:30:00 +01:00
Richard Hughes
73bf2337c1 trivial: Add fu_common_strtoull() as a shared function 2018-08-28 09:41:10 +01:00
Richard Hughes
9d6e0e743b Move the GUdevClient to the core daemon
Allowing plugins to 'register' for different udev subsystems in _init() allows
us to move the client to the engine, reducing the number of wakeups considerably
for each device event. It also will reduce the amount of boilerplate code in
each plugin that uses GUdev, much like we have done for GUsb.
2018-08-26 19:42:28 +01:00