Skip to content

Commit

Permalink
system: use bootindex to order boot devices
Browse files Browse the repository at this point in the history
Fixes #2333
  • Loading branch information
osy committed Feb 26, 2021
1 parent f347556 commit 9b9bdec
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Managers/UTMQemuSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,26 +170,26 @@ - (void)targetSpecificConfiguration {
}
}

- (NSString *)expandDriveInterface:(NSString *)interface identifier:(NSString *)identifier removable:(BOOL)removable {
- (NSString *)expandDriveInterface:(NSString *)interface identifier:(NSString *)identifier removable:(BOOL)removable bootindex:(NSInteger *)bootindex {
if ([interface isEqualToString:@"ide"]) {
[self pushArgv:@"-device"];
[self pushArgv:[NSString stringWithFormat:@"%@,drive=%@", removable ? @"ide-cd" : @"ide-hd", identifier]];
[self pushArgv:[NSString stringWithFormat:@"%@,drive=%@,bootindex=%lu", removable ? @"ide-cd" : @"ide-hd", identifier, (*bootindex)++]];
return @"none";
} else if ([interface isEqualToString:@"scsi"]) {
[self pushArgv:@"-device"];
[self pushArgv:[NSString stringWithFormat:@"%@,drive=%@", removable ? @"scsi-cd" : @"scsi-hd", identifier]];
[self pushArgv:[NSString stringWithFormat:@"%@,drive=%@,bootindex=%lu", removable ? @"scsi-cd" : @"scsi-hd", identifier, (*bootindex)++]];
return @"none";
} else if ([interface isEqualToString:@"virtio"]) {
[self pushArgv:@"-device"];
[self pushArgv:[NSString stringWithFormat:@"%@,drive=%@", [self.configuration.systemArchitecture isEqualToString:@"s390x"] ? @"virtio-blk-ccw" : @"virtio-blk-pci", identifier]];
[self pushArgv:[NSString stringWithFormat:@"%@,drive=%@,bootindex=%lu", [self.configuration.systemArchitecture isEqualToString:@"s390x"] ? @"virtio-blk-ccw" : @"virtio-blk-pci", identifier, (*bootindex)++]];
return @"none";
} else if ([interface isEqualToString:@"nvme"]) {
[self pushArgv:@"-device"];
[self pushArgv:[NSString stringWithFormat:@"nvme,drive=%@,serial=%@", identifier, identifier]];
[self pushArgv:[NSString stringWithFormat:@"nvme,drive=%@,serial=%@,bootindex=%lu", identifier, identifier, (*bootindex)++]];
return @"none";
} else if ([interface isEqualToString:@"usb"]) {
[self pushArgv:@"-device"];
[self pushArgv:[NSString stringWithFormat:@"usb-storage,drive=%@,removable=%@", identifier, removable ? @"true" : @"false"]];
[self pushArgv:[NSString stringWithFormat:@"usb-storage,drive=%@,removable=%@,bootindex=%lu", identifier, removable ? @"true" : @"false", (*bootindex)++]];
return @"none";
} else {
return interface; // no expand needed
Expand Down Expand Up @@ -219,6 +219,7 @@ - (void)argsForCpu {
}

- (void)argsForDrives {
NSInteger bootindex = 1;
for (NSUInteger i = 0; i < self.configuration.countDrives; i++) {
NSString *path = [self.configuration driveImagePathForIndex:i];
UTMDiskImageType type = [self.configuration driveImageTypeForIndex:i];
Expand All @@ -243,7 +244,7 @@ - (void)argsForDrives {
NSString *interface = [self.configuration driveInterfaceTypeForIndex:i];
BOOL removable = [self.configuration driveRemovableForIndex:i];
NSString *identifier = [NSString stringWithFormat:@"drive%lu", i];
NSString *realInterface = [self expandDriveInterface:interface identifier:identifier removable:removable];
NSString *realInterface = [self expandDriveInterface:interface identifier:identifier removable:removable bootindex:&bootindex];
NSString *drive;
[self pushArgv:@"-drive"];
drive = [NSString stringWithFormat:@"if=%@,media=%@,id=%@", realInterface, removable ? @"cdrom" : @"disk", identifier];
Expand Down

0 comments on commit 9b9bdec

Please sign in to comment.