redfish: Identify hardware that needs to be updated to the same version

For instance, the EFI driver for a given network card cannot be
different for identical hardware.
This commit is contained in:
Richard Hughes 2021-07-22 21:19:47 +01:00
parent a8206b2bf6
commit 25c93aa7ca
4 changed files with 49 additions and 0 deletions

View File

@ -193,6 +193,8 @@ fwupd_device_flag_to_string (FwupdDeviceFlags device_flag)
return "has-multiple-branches";
if (device_flag == FWUPD_DEVICE_FLAG_BACKUP_BEFORE_INSTALL)
return "backup-before-install";
if (device_flag == FWUPD_DEVICE_FLAG_WILDCARD_INSTALL)
return "wildcard-install";
if (device_flag == FWUPD_DEVICE_FLAG_UNKNOWN)
return "unknown";
return NULL;
@ -297,6 +299,8 @@ fwupd_device_flag_from_string (const gchar *device_flag)
return FWUPD_DEVICE_FLAG_HAS_MULTIPLE_BRANCHES;
if (g_strcmp0 (device_flag, "backup-before-install") == 0)
return FWUPD_DEVICE_FLAG_BACKUP_BEFORE_INSTALL;
if (g_strcmp0 (device_flag, "wildcard-install") == 0)
return FWUPD_DEVICE_FLAG_WILDCARD_INSTALL;
return FWUPD_DEVICE_FLAG_UNKNOWN;
}

View File

@ -449,6 +449,18 @@ typedef enum {
* Deprecated 1.5.5
*/
#define FWUPD_DEVICE_FLAG_MD_SET_ICON (1llu << 41)
/**
* FWUPD_DEVICE_FLAG_WILDCARD_INSTALL:
*
* All devices with matching GUIDs will be updated at the same time.
*
* For some devices it is not possible to have different versions of firmware
* for hardware of the same type. Updating one device will force update of
* others with exactly the same instance IDs.
*
* Since: 1.6.2
*/
#define FWUPD_DEVICE_FLAG_WILDCARD_INSTALL (1llu << 42)
/**
* FWUPD_DEVICE_FLAG_UNKNOWN:
*

View File

@ -187,6 +187,28 @@ fu_redfish_backend_coldplug_inventory (FuRedfishBackend *self,
return fu_redfish_backend_coldplug_collection (self, json_obj, error);
}
static void
fu_redfish_backend_check_wildcard_targets (FuRedfishBackend *self)
{
g_autoptr(GPtrArray) devices = fu_backend_get_devices (FU_BACKEND (self));
g_autoptr(GHashTable) device_by_id0 = g_hash_table_new (g_str_hash, g_str_equal);
/* does the SoftwareId exist from a different device */
for (guint i = 0; i < devices->len; i++) {
FuDevice *device_old;
FuDevice *device_tmp = g_ptr_array_index (devices, i);
GPtrArray *ids =fu_device_get_instance_ids (device_tmp);
const gchar *id0 = g_ptr_array_index (ids, 0);
device_old = g_hash_table_lookup (device_by_id0, id0);
if (device_old == NULL) {
g_hash_table_insert (device_by_id0, (gpointer) device_tmp, (gpointer) id0);
continue;
}
fu_device_add_flag (device_tmp, FWUPD_DEVICE_FLAG_WILDCARD_INSTALL);
fu_device_add_flag (device_old, FWUPD_DEVICE_FLAG_WILDCARD_INSTALL);
}
}
static gboolean
fu_redfish_backend_coldplug (FuBackend *backend, GError **error)
{
@ -253,6 +275,12 @@ fu_redfish_backend_coldplug (FuBackend *backend, GError **error)
JsonObject *tmp = json_object_get_object_member (json_obj, "SoftwareInventory");
return fu_redfish_backend_coldplug_inventory (self, tmp, error);
}
/* work out if we have multiple devices with the same SoftwareId */
if (self->wildcard_targets)
fu_redfish_backend_check_wildcard_targets (self);
/* success */
return TRUE;
}

View File

@ -1180,6 +1180,11 @@ fu_util_device_flag_to_string (guint64 device_flag)
/* TRANSLATORS: save the old firmware to disk before installing the new one */
return _("Device will backup firmware before installing");
}
if (device_flag == FWUPD_DEVICE_FLAG_WILDCARD_INSTALL) {
/* TRANSLATORS: on some systems certain devices have to have matching versions,
* e.g. the EFI driver for a given network card cannot be different */
return _("All devices of the same type will be updated at the same time");
}
if (device_flag == FWUPD_DEVICE_FLAG_SKIPS_RESTART) {
/* skip */
return NULL;