sculpt: release part_block after device discovery

This patch triggers the immediate removal of part_block once the
discovery of a fresh inserted USB stick has completed. Without the
patch, part_block was retained until the runtime was reconfigured the
next time for other reasons (e.g., toggling an inspect view). Until the
next reconfituration, part_block tended to stand in the way of directly
assigning the USB device to a VM.
This commit is contained in:
Norman Feske 2021-03-05 14:28:28 +01:00
parent 7ce1f8e92d
commit 366fda0e47

View File

@ -18,18 +18,25 @@
void Sculpt::Storage::handle_storage_devices_update()
{
bool reconfigure_runtime = false;
auto process_part_block_report = [&] (Storage_device &dev)
{
Storage_device::State const orig_state = dev.state;
dev.process_part_block_report();
if (dev.state != orig_state
|| dev.state == Storage_device::UNKNOWN)
reconfigure_runtime = true;
};
{
_block_devices_rom.update();
Block_device_update_policy policy(_env, _alloc, _storage_device_update_handler);
_storage_devices.update_block_devices_from_xml(policy, _block_devices_rom.xml());
_storage_devices.block_devices.for_each([&] (Block_device &dev) {
dev.process_part_block_report();
if (dev.state == Storage_device::UNKNOWN) {
reconfigure_runtime = true; };
});
process_part_block_report(dev); });
}
{
@ -43,12 +50,8 @@ void Sculpt::Storage::handle_storage_devices_update()
reconfigure_runtime = true;
_storage_devices.usb_storage_devices.for_each([&] (Usb_storage_device &dev) {
dev.process_driver_report();
dev.process_part_block_report();
if (dev.state == Storage_device::UNKNOWN) {
reconfigure_runtime = true; };
process_part_block_report(dev);
});
}