core/device: do not downgrade device state if it is already enumerated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 20 May 2022 08:25:12 +0000 (10:25 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 26 May 2022 15:07:59 +0000 (17:07 +0200)
commit4fc69e8a0949c2537019466f839d9b7aee5628c9
tree95a747e6ba8d1cdb6bd5cb0495ad601e974ea076
parentcf1ac0cfe44997747b0f857a1d0b67cea1298272
core/device: do not downgrade device state if it is already enumerated

On switching root, a device may have a persistent databse. In that case,
Device.enumerated_found may have DEVICE_FOUND_UDEV flag, and it is not
necessary to downgrade the Device.deserialized_found and
Device.deserialized_state. Otherwise, the state of the device unit may
be changed plugged -> dead -> plugged, if the device has not been mounted.

Fixes #23429.

[mwilck: cherry-picked from #23437]
src/core/device.c