When loading any device fails, also release resources of already successful devices.
Avoids still-loading devices blocking resources, potentially leading to such devices blocking each other from loading.
This commit is contained in:
@@ -46,8 +46,9 @@ public final class VirtualMachineDeviceBusAdapter {
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
for (int i = incompleteLoads.size() - 1; i >= 0; i--) {
|
||||
final VMDevice device = incompleteLoads.remove(i);
|
||||
boolean anyFailed = false;
|
||||
for (int i = 0; i < incompleteLoads.size(); i++) {
|
||||
final VMDevice device = incompleteLoads.get(i);
|
||||
|
||||
final ManagedVMContext context = new ManagedVMContext(
|
||||
board, claimedInterrupts, reservedInterrupts,
|
||||
@@ -59,15 +60,20 @@ public final class VirtualMachineDeviceBusAdapter {
|
||||
context.freeze();
|
||||
|
||||
if (!result.wasSuccessful()) {
|
||||
context.invalidate();
|
||||
incompleteLoads.add(device);
|
||||
anyFailed = true;
|
||||
for (; i >= 0; i--) {
|
||||
deviceContexts.get(incompleteLoads.get(i)).invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!incompleteLoads.isEmpty()) {
|
||||
if (anyFailed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
incompleteLoads.clear();
|
||||
|
||||
reservedInterrupts.clear();
|
||||
reservedInterrupts.or(claimedInterrupts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user