Commit Graph

1423 Commits

Author SHA1 Message Date
Richard Hughes
f4998a7636 trivial: Fix up some NULL/FALSE confusion 2019-11-01 13:55:32 +00:00
Richard Hughes
cd644907e4 trivial: Fix a typo that means that UEFI results were never cleared 2019-11-01 08:16:18 -05:00
Richard Hughes
0bbef29d3e Always report the update-error correctly for multiple updates
The root of this problem is that we were trying to use pending.db as both a
pending report store and also a record of history, so you could see updates for
device foo 1.2.3->1.2.4 and then 1.2.4->1.2.5.
This sort-of half worked, but it meant in some cases we matched on the old
device version, sometimes on the new release version and sometimes matching on
either.

The problem was that in various places we were using the device ID as *the*
primary key, and so we had various functions like fu_history_get_device_by_id()
that expected to return just one device, not several.

The device ID also changes if the device is moved from USB plug to another, and
so it got even more complicated again trying to de-dupe the devices.

The sanest thing to do is to decide that pending.db only contains the latest
attempt to go from one version to another using device-id as the primary key.
This makes reporting work reliably now, although has the effect you can't
report a 1.2.3->1.2.4 and 1.2.4->1.2.5 at the same time. Note, if you tried to
do the latter before, the update-error (if set) would be wrong on the second
report...

For the 1.3.3 release make it all simpler and so the reporting works reliably.
Longer term we can design a better database schema that uses unique ID to
represent the *transaction* itself, that isn't tied to the device ID in any way.
This might mean extending the DBus API to cope with multiple devices being
returned with the same device-id set.
2019-11-01 08:16:18 -05:00
Richard Hughes
9fcd29f92e trivial: Fix fwupdmgr get-history if the firmware was not installed from the LVFS
If you install a local .cab file that's not available on the LVFS then none
of the history for any devices is available.
2019-11-01 08:16:18 -05:00
Richard Hughes
ec14e4bdd0 trivial: Do not emit a warning if a child has no version number 2019-11-01 08:16:18 -05:00
Richard Hughes
bf00080d3f Move the file descriptor lifecycle into FuUdevDevice
This also means we can provide common 'safe' versions for plugins to use.
This makes a lot of plugins much simpler and we can delete a lot of code.
2019-10-31 09:21:35 -05:00
Richard Hughes
6436953562 trivial: Fix some GtkDoc annotations 2019-10-31 09:21:35 -05:00
Mario Limonciello
98b951688a Use device safety flags to show prompts before installing updates 2019-10-30 11:30:36 -05:00
Richard Hughes
45a1815587 trivial: Use the new possible_plugin support for USB devices too
This matches the UDEV device add, and was missed from the original commit due
to a failed rebase.

Fixes https://github.com/fwupd/fwupd/issues/1512
2019-10-30 10:49:00 -05:00
Richard Hughes
2031ce3bf6 Ensure the device is open when doing the subclassed prepare() and cleanup()
It's not usual to open the device from inside the device, otherwise there is a
possibility of a deadlock. For devices without the ->prepare() virtual function
the ->open() should either be a NOP or very fast indeed.
2019-10-30 09:44:52 -05:00
Richard Hughes
a58510b246 Allow verifying the device image itself from fwupdtool
To debug flashing failures it's sometimes requried to get a SPI dump of the
hardware to analysis.

Add a debug-only command that lets us dump the device from the engine.
2019-10-30 13:55:55 +00:00
Richard Hughes
51a869a01d Use XMLb to query quirks
During startup we do 1898 persistent allocations to load the quirk files, which
equates to ~90kb of RSS. Use libxmlb to create a mmap'able store we can query
with XPath queries at runtime.
2019-10-30 08:29:58 -05:00
Mario Limonciello
0a956799ed trivial: fu-util: fix typo 2019-10-25 09:16:11 -05:00
Mario Limonciello
44b9e46d37 uefi: rework ESP path detection and lifecycle
This makes the daemon less destructive at startup, especially if the ESP
is not mounted.

It's stored in 3 different places right now, so move it into one point of truth.

Now the ESP is detected when needed including all point of time safety checks and
dynamically mounted and unmounted if necessary.
2019-10-24 15:22:01 -05:00
Mario Limonciello
776f143caf trivial: fu-device: add new method to remove metadata
This will be used by the UEFI plugin.
2019-10-24 15:22:01 -05:00
Richard Hughes
c21a0b933c trivial: Add fu_common_read_uint8_safe() 2019-10-24 12:52:18 +01:00
Richard Hughes
7d01ac9ad8 trivial: Fix two typos in fu_common_read_uint16_safe() 2019-10-23 14:33:52 +01:00
Richard Hughes
95c98a95b6 Allow fwupdtool to dump details of common firmware formats
To do this, the plugins have to register the GType(s) they are using for
firmware, along with a short 'id' that can be used in CLI scripts.
2019-10-22 12:36:15 -05:00
Richard Hughes
8fb2e6a881 trivial: Do not do system coldplug when using FU_ENGINE_LOAD_FLAG_NO_ENUMERATE 2019-10-22 12:36:15 -05:00
Mario Limonciello
dd0b437d86 trivial: fu-self-test: set polling self tests to slow
Currently the test runs for 100ms and looks to see that at least 8 times
the poll function callback hit.

This normally works well enough, but during self tests it depends upon
too much timing and leads to failures sometimes:

```
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.189: poll cnt=0
*# DEBUG: poll cnt=1
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.199: poll cnt=1
*** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.209: poll cnt=2
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.227: poll cnt=3
*# DEBUG: poll cnt=4
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.255: poll cnt=4
*# DEBUG: poll cnt=5
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.267: poll cnt=5
Bail out! ERROR:../src/fu-self-test.c:3489:fu_device_poll_func: assertion failed (cnt >= 8): (6 >= 8)
--- stderr ---
**
ERROR:../src/fu-self-test.c:3489:fu_device_poll_func: assertion failed (cnt >= 8): (6 >= 8)
-------
```

Mark this as a slow test so that it doesn't cause CI failures.
2019-10-22 09:58:05 -05:00
Mario Limonciello
a61b4d88c9 trivial: fu-tool: Allow detach/attach to prompt for device
Makes using `fwupdtool detach` easier to use.
2019-10-22 09:12:26 -05:00
Richard Hughes
77606cc3b8 Strip trailing whitespace from USB descriptors
Some vendors use a space to fill, rather than NUL to terminate the string.
Keeping the space makes fwupdmgr and gnome-firmware look broken.
2019-10-22 14:39:39 +01:00
Richard Hughes
80768f557f trivial: Add fu_common_read_uint16_safe()
This allows us to put the offsets-to-offset checks in the right place.
2019-10-22 11:50:10 +01:00
Richard Hughes
afca71aeb3 trivial: Add version to the FuFirmware->to_string() output 2019-10-21 18:03:07 +01:00
Richard Hughes
fd3c8ae7fd Add fu_firmware_set_version()
In the future, for firmware that supports getting a version we can check the
parsed version matches the version specified in the metainfo file.
2019-10-21 10:35:01 -05:00
Mario Limonciello
eb5d7a4659 Add a new plugin for working with eMMC devices (Fixes: #1455) 2019-10-18 14:18:09 -05:00
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
Mario Limonciello
561751faff trivial: don't try to enable LVFS from systemd 2019-10-18 09:21:19 -05:00
Mario Limonciello
fd877a02e0 fu-util: Add user friendly strings for all device flags
This also hides some flags that users don't care about unless run with
`--verbose`
2019-10-17 11:38:46 -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
Richard Hughes
791c91be1e trivial: Increase verbosity when actually updating devices
As the plugin is allowed to change print out the entire FuDevice before
performing each step when in verbose mode.

Note, these are only show during update if run with --verbose, not at startup.
2019-10-17 14:06:27 +01:00
Richard Hughes
802bb313c6 trivial: Allow plugins to use WAIT_FOR_REPLUG in prepare and cleanup 2019-10-17 14:06:27 +01:00
Richard Hughes
b05d39adff Add FuDevice->prepare() and FuDevice->cleanup() vfuncs for future use 2019-10-17 14:06:27 +01:00
Mario Limonciello
326950cd68 trivial: fu-util: break out of automatic reports if one is not automatic
Currently this is controlled by the order of remotes enumerated and might
return the wrong result with too many remotes.
2019-10-16 10:13:10 -05:00
Richard Hughes
1db25c9f2c Allow a custom FuFirmwareImage->write() in superclassed objects 2019-10-15 08:10:11 -05:00
Mario Limonciello
1d01d3bb38 Fix device flag filtering
When multiple flags were passed, they made combinations that would never
exist in the daemon causing advanced filtering to not work.
2019-10-14 12:41:09 -05:00
Mario Limonciello
2a0e20bfaa trivial: fu-engine: Don't compare device and content checksums
Use `FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE` to register that a content
checksum should be used.
2019-10-14 12:41:09 -05:00
Mario Limonciello
91d36095e1 fu-engine: Read all releases and convert versions when comparing
Fixes matching ESRT version to metadata version for UEFI
2019-10-14 12:41:09 -05: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
Mario Limonciello
49556a3948 trivial: make verify and verify-update safer
Don't show output for all devices - it doesn't work for most of them.

I also found that running verify on my Synaptics touchpad device puts it
into a pretty bad state until reboot.  That's of course a problem on
it's own, but at least prompting for it will prevent it from easily
happening.
2019-10-14 12:41:09 -05:00
Mario Limonciello
248e3f8d6e trivial: fu-udev-device: use parent udev device to indicate internal
If the parent device is hooked up via I2C that's a pretty good
indication that the touchpad is internal to the device.
2019-10-14 11:36:42 -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
e202a39851 trivial: fu-util: add some extra checks around automatic reports
Avoid some extra roundtrips to the daemon if user has poked at some
files.
2019-10-13 07:34:09 +01:00
Mario Limonciello
8692d01cf9 trivial: fu-tool: typo 2019-10-13 07:30:43 +01:00
Mario Limonciello
3a10c3cf3d fu-systemd: Use correct method for stopping units.
Fixes a regression in 3d00522dd3 that caused systemd stopping to
not work.

Previously the flow was to use `GetUnit` and `StopUnit` on the manager
interface.  In that code this was switched over it should have been
using the unit interface + `Stop` or manager interface + `StopUnit`
not try to use the manager interface on the unit proxy with `StopUnit`.
2019-10-13 07:30:43 +01:00
Mario Limonciello
fece7553af trivial: fu-udev-device: Use ID_PCI_CLASS_FROM_DATABASE if name not set
This helps at least with display controllers
2019-10-12 14:29:21 -05: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
Mario Limonciello
e1b4d8ebcd Add a new device flag for indicating device won't come back
Devices like this can't be verified that the version was updated
until they're manually put into the correct mode by the user.
2019-10-12 14:07:34 -05:00
Richard Hughes
c0695320c8 Add a generic DFU firmware object for plugins to use 2019-10-11 13:19:46 +01:00
Richard Hughes
f591a3594b trivial: Add fu_firmware_parse_file() helper for future use 2019-10-10 16:18:58 +01:00