1. 01 Dec, 2020 7 commits
  2. 30 Nov, 2020 6 commits
    • Christian Kellner's avatar
      test/mock: plug another tiny leak · c687041c
      Christian Kellner authored
      When removing the host device via mock_sysfs_host_remove, destroy
      the MockDevice for the host.
    • Christian Kellner's avatar
      glue: fix memory leak in conv_flags_to_str · 0b97bcaa
      Christian Kellner authored
      The function 'bolt_flags_class_to_string' returns a dynamically
      allocated string. This was previously not freed, creating a memory
      leak. Its ownership is now correctly transferred to the GVariant
    • Christian Kellner's avatar
      glue: plug tiny memory leak by freeing custom_id · 27ae4440
      Christian Kellner authored
      The memory for custom_id, to identify a custom conversion, is
      dynamically allocated, but was not freed in bolt_wire_conv_unref.
      Explicitly set it to NULL in the other constructor so we don't
      attempt to free invalid memory.
    • Christian Kellner's avatar
      guard: ensure guard->path is always freed · 6f7b323f
      Christian Kellner authored
      Normally 'path' gets freed in bolt_guard_remove, which is called
      from the dispose method of the BoltGuard. There is one exception
      though: when the pipe (named fifo) is still active, we do not
      unlink the path, since we want to recover that guard later. In
      that case the memory for path will be leaked. Add an additional
      g_clear_pointer for path in the 'finalize' method to ensure that
      path always gets freed.
    • Christian Kellner's avatar
      guard: add pre-condition check in guard_save · 48cdeb20
      Christian Kellner authored
      Ensure that we are not saved already in 'bolt_guard_save'.
    • Christian Kellner's avatar
      test: fix various small memory leaks · c4e35871
      Christian Kellner authored
      Add missing g_clear_pointer / g_clear_object calls when a pointer
      was re-used during the tests. In MockSysfs, free the force-power
      path. In test-glue, use g_autoptr for all allocated GParamSpecs.
  3. 28 Nov, 2020 16 commits
    • Christian Kellner's avatar
      manager: plug tiny leak on finalize · 78fe16e3
      Christian Kellner authored
      Properly unref the config key file when finalizing the object.
    • Christian Kellner's avatar
      device: use host ident for host devices · 6a6968a7
      Christian Kellner authored
      If a device is a host device, i.e. does not have a parent device, use
      the new host identification method, which will transparently fall
      back to use the SMBIOS/DMI information, in case the standard
      device information is not available, which is the case on embedded
      thunderbolt controllers.
    • Christian Kellner's avatar
      test/sysfs: check host identification · 290143fb
      Christian Kellner authored
      Add a test to check all host identification method code paths,
      including the standard one via 'bolt_sysfs_device_ident' as
      well as the fallback to DMI information.
    • Christian Kellner's avatar
      test/mock: add the ability to mock the DMI id dev · 2dd16dbb
      Christian Kellner authored
      Add the ability to mock the SMBBIOS/DMI sysfs device. For now only
      the sys_vendor, product_{name, version} attributes are supported,
      which is what we us in bolt.
    • Christian Kellner's avatar
      test/mock: remove force power in finalize · 4ab9f056
      Christian Kellner authored
      If the force power device has not yet been removed, do so in the
      'finalize' method of the MockSysfs object. Move the un-ref'ing of
      the umockdev TestBed down so it happens after the hash tables
      are destroyed.
    • Christian Kellner's avatar
      test/mock-sysfs: ability to remove the host · dfbcf877
      Christian Kellner authored
      Add a new method that allows to remove a host device, i.e. unplug
      the device and remove it from the associated domain.
    • Christian Kellner's avatar
      sysfs: method to perform host identification · de337834
      Christian Kellner authored
      Add a new method to do host identification, which will first check
      if the host device can be identified via the normal device ident
      method. This will fail in case of embedded thunderbolt controller,
      which do not have a DROM and have no device and vendor information
      and thus no corresponding sysfs attributes. In that case we fall
      back to using the SMBIOS/DMI information for the system to ident
      the host.
    • Christian Kellner's avatar
      names: add dmi id sysfs path and attribute names · 0defa936
      Christian Kellner authored
      The SMBIOS/DMI information is exported to userspace via sysfs,
      which is convenient, because the information can thus be read
      conveniently and as a non-root user.
      Define constants for relevant information that can be used to
      identify the computer / host, like the product, vendor and the
      general path to the sysfs device providing that information.
    • Christian Kellner's avatar
      test/syfs: check the sysfs_device_ident method · 520ef841
      Christian Kellner authored
      Check the 'bolt_sysfs_device_ident' method and the newly added
      'BoltIdent' structs.
    • Christian Kellner's avatar
      device+sysfs: new device ident struct · 95ef1b8b
      Christian Kellner authored
      Introduce a new BoltIdent struct that holds the name and vendor
      information for a thunderbolt device together with a reference
      to the 'struct udev_device' that provides those information.
      This binds the lifetime of the char pointers directly to the
      struct where they are contained and thus prevent accidental
      bugs where the strings are used after the udev_device is not
      valid anymore (got un-referenced).
      Since the struct holds a reference, define a clear method for
      it and the corresponding auto-cleanup method.
      Use the new BoltIdent struct for 'bolt_device_ident'. Re-factor
      it to not use a loop anymore.
      The read_sysattr_name helper, use in 'bolt_device_ident' now
      uses the recently introduced sysattr value getter.
    • Christian Kellner's avatar
      sysfs: new attribute getter with glib style errors · 1adb3d00
      Christian Kellner authored
      Add a new sysfs attribute getter that does error reporting via
      GErrors. This will be convenient in a lot of places where the
      error handling is duplicated. Use it in the existing unique_id
    • Christian Kellner's avatar
      manager: relabel Dell Inc. → Dell · e3282a50
      Christian Kellner authored
      This is mostly in preparation for the host identification via DMI
      where 'Dell Inc.' is used, whereby the thunderbolt host controller
      usually identifies itself as "Dell". To stay consistent we relabel
      the dmi id one.
    • Christian Kellner's avatar
      manager: don't de-duplicate host device names · 9094fa36
      Christian Kellner authored
      When labeling a device, we normally do a duplication check, and
      if we find more than once device with the same name, we append
      a number suffix. Let's not do that for host devices, since they
      are arguably represent the same thing, even if technically the
      are different controllers with their own unique id.
    • Christian Kellner's avatar
      manager: only import hosts with stable uuids · fbde3fd0
      Christian Kellner authored
      We started auto-importing the host device in commit f9205d16, with
      the reason that in non-native enumeration mode, the host device
      will disappear and the generation information will thus not be
      available anymore. But on embedded thunderbolt controller, the
      host device has an unstable unique_id, which means that host device
      will have a different uuid on next boot and thus can not be matched
      with the previously stored one. Thus stale host devices would
      accumulate in the store. Luckily, on embedded thunderbolt, the host
      device does not have device/vendor sysfs attributes, which means
      that currently creating a BoltDevice for it will not work, which is
      a bug, that also prevents stale host devices for now. Once that bug
      will get fixed we were to get stale host records, unless we don't
      store those host devices. To do so we check if the domain of the
      host device is stored which is an indicator of the uuid stability,
      checked via the pci id of the native host interface. If the domain
      is stored we store the host and vice versa.
    • Christian Kellner's avatar
      device: move device identification to sysfs · 09aa6c53
      Christian Kellner authored
      Move the device identification, i.e. name and vendor detection, to
      bolt-sysfs.c as 'bolt_sysfs_device_ident'. This uses the existing
      helper function to first check `${attr}_name` for vendor and name
      attributes and then fall back to plain `${attr}`.
    • Christian Kellner's avatar
      device: add domain getter · f653fee2
      Christian Kellner authored
      Add the missing getter for the domain associated with a device, or
      NULL if there is none, i.e. the device is offline.
  4. 24 Nov, 2020 6 commits
  5. 20 Nov, 2020 5 commits
    • Christian Kellner's avatar
      manager+sysfs: wait for hosts instead of domains · 8be049a5
      Christian Kellner authored
      In the manager's initialization, we want to make sure that we have
      at least one domain controller online in order detect the security
      level. Additionally, now that stale domains are cleaned up on store
      upgrades, we also want to make sure that domain controllers are
      fully initialized and the corresponding BotlDomain is online, so
      that we don't accidentally clean up a non-stale domain. In order
      to do so, we wait for at least one host controller to be present,
      not just the plain domain. For this we enumerate all domains and
      for each domain we enumerate the thunderbolt udev device directly
      beneath it (should only be one).
      Rename and re-purpose the various `count_domains` functions.
      Adapt the test to add host devices to the corresponding domains.
    • Christian Kellner's avatar
      manager: better logging for domain de-registration · f3395f9c
      Christian Kellner authored
      Use the LOG_DOM () macro and do not use `bolt_domain_get_id`
      which might return NULL for disconnected domains.
    • Christian Kellner's avatar
      test/integration: cleanup stale domains check · 2f9a04d6
      Christian Kellner authored
      Simulate stale domains by creating a store with four domains, one
      of which has a bootacl journal with entries. Since the store does
      not have a 'version' file, an upgrade will be performed which will
      lead to the cleanup of stale domains. All domains, except the one
      with the non-empty bootacl journal should be cleaned up.
    • Christian Kellner's avatar
      manager: clean up stale domains on store upgrade · 9e859394
      Christian Kellner authored
      When the store is upgraded, clean up any stale domains. Previous
      versions of bolt (< 0.9.1) would store domains that did not have
      stable uuids, i.e. their uuid would change on every boot. These
      stored domains would be loaded and exported but would never come
      online, since they can not ever by matched to an online domain.
      When the store cleanup method is executed, in the manager's
      initialization method, the domain controller should either be
      powered (they use runtime power management only and are thus not
      physically powered down on ice lake anyway) or force-powered and
      thus any domain that is not yet online will be removed. This can
      fail if the domain has a boot acl journal with entries, which
      protects the loss of data for domains that are not force-powered,
      maybe because they are even slower, but do have a stable uuid.
    • Christian Kellner's avatar
      manager: correctly report upgraded version · 3ec3e0ef
      Christian Kellner authored
      After the store was upgraded, get the new version from the store
      and report that in the logs, not the old, pre-upgrade version.