Browse Source

Revert "config(qemu): support manual bus location for IDE and SCSI"

This reverts commit b2b88d9424634693f194fc857a5bc09a4affead6.
osy 2 tuần trước cách đây
mục cha
commit
006e00589f

+ 4 - 14
Configuration/UTMQemuConfiguration+Arguments.swift

@@ -725,18 +725,13 @@ import Virtualization // for getting network interfaces
             } else {
                 "ide-hd"
             }
-            if let location = drive.interfaceLocation, location.count == 3 {
-                "bus=ide.\(location[0])"
-                "unit=\(location[1])"
-                "index=\(location[2])"
-            } else if drive.interfaceVersion >= 1 && !isIdeInterfaceSingleUnit {
+            if drive.interfaceVersion >= 1 && !isIdeInterfaceSingleUnit {
                 "bus=ide.\(busindex / 2)"
                 "unit=\(busindex % 2)"
-                busindex += 1
             } else {
                 "bus=ide.\(busindex)"
-                busindex += 1
             }
+            busindex += 1
             "drive=drive\(drive.id)"
             if !disableBootIndex {
                 "bootindex=\(bootindex)"
@@ -760,13 +755,8 @@ import Virtualization // for getting network interfaces
             }
             "bus=\(bus).0"
             "channel=0"
-            if let location = drive.interfaceLocation, location.count == 2 {
-                "scsi-id=\(location[0])"
-                "lun=\(location[1])"
-            } else {
-                "scsi-id=\(busindex)"
-                busindex += 1
-            }
+            "scsi-id=\(busindex)"
+            busindex += 1
             "drive=drive\(drive.id)"
             if !disableBootIndex {
                 "bootindex=\(bootindex)"

+ 0 - 7
Configuration/UTMQemuConfigurationDrive.swift

@@ -47,9 +47,6 @@ struct UTMQemuConfigurationDrive: UTMConfigurationDrive {
     /// Interface version for backwards compatibility
     var interfaceVersion: Int = Self.latestInterfaceVersion
     
-    /// Meaning differs by interface. Allows manually specifying where the device is located on the bus.
-    var interfaceLocation: [Int]?
-    
     /// If true, the created image will be raw format and not QCOW2. Not saved.
     var isRawImage: Bool = false
     
@@ -61,7 +58,6 @@ struct UTMQemuConfigurationDrive: UTMConfigurationDrive {
         case imageType = "ImageType"
         case interface = "Interface"
         case interfaceVersion = "InterfaceVersion"
-        case interfaceLocation = "InterfaceLocation"
         case identifier = "Identifier"
         case isReadOnly = "ReadOnly"
     }
@@ -85,7 +81,6 @@ struct UTMQemuConfigurationDrive: UTMConfigurationDrive {
         imageType = try values.decode(QEMUDriveImageType.self, forKey: .imageType)
         interface = try values.decode(QEMUDriveInterface.self, forKey: .interface)
         interfaceVersion = try values.decodeIfPresent(Int.self, forKey: .interfaceVersion) ?? 0
-        interfaceLocation = try values.decodeIfPresent([Int].self, forKey: .interfaceLocation)
         id = try values.decode(String.self, forKey: .identifier)
     }
     
@@ -102,7 +97,6 @@ struct UTMQemuConfigurationDrive: UTMConfigurationDrive {
             try container.encode(QEMUDriveInterface.none, forKey: .interface)
         }
         try container.encode(interfaceVersion, forKey: .interfaceVersion)
-        try container.encodeIfPresent(interfaceLocation, forKey: .interfaceLocation)
         try container.encode(id, forKey: .identifier)
     }
     
@@ -115,7 +109,6 @@ struct UTMQemuConfigurationDrive: UTMConfigurationDrive {
         imageType.hash(into: &hasher)
         interface.hash(into: &hasher)
         interfaceVersion.hash(into: &hasher)
-        interfaceLocation?.hash(into: &hasher)
         isRawImage.hash(into: &hasher)
     }
     

+ 0 - 60
Platform/Shared/VMConfigDriveDetailsView.swift

@@ -44,11 +44,6 @@ struct VMConfigDriveDetailsView: View {
     @State private var isResizePopoverShown: Bool = false
     @State private var proposedSizeMib: Int = 0
     
-    @State private var hasAutoLocation: Bool = true
-    @State private var locationA: Int = 0
-    @State private var locationB: Int = 0
-    @State private var locationC: Int = 0
-    
     var body: some View {
         Form {
             Toggle(isOn: $config.isExternal.animation(), label: {
@@ -92,8 +87,6 @@ struct VMConfigDriveDetailsView: View {
                         if interface == .floppy && config.imageType == .cd {
                             config.imageType = .disk
                         }
-                        hasAutoLocation = true
-                        updateLocation()
                     }
             }
             if config.interface == .ide && config.interfaceVersion != UTMQemuConfigurationDrive.latestInterfaceVersion {
@@ -104,29 +97,6 @@ struct VMConfigDriveDetailsView: View {
                 }.help("Older versions of UTM added each IDE device to a separate bus. Check this to change the configuration to place two units on each bus.")
             }
             
-            if config.interface == .ide || config.interface == .scsi {
-                Toggle("Automatically assign bus location", isOn: $hasAutoLocation)
-                    .help("Some older operating systems expect a drive to be on a specific location. Most users should leave this enabled.")
-                    .onChange(of: hasAutoLocation) { _ in updateLocation() }
-                if !hasAutoLocation {
-                    DetailedSection("Bus Location", description: "If you have multiple drives on the same interface, you must specify bus location for all of them.") {
-                        if config.interface == .ide {
-                            NumberTextField("Bus", number: $locationA)
-                                .onChange(of: locationA) { _ in updateLocation() }
-                            NumberTextField("Unit", number: $locationB)
-                                .onChange(of: locationB) { _ in updateLocation() }
-                            NumberTextField("Index", number: $locationC)
-                                .onChange(of: locationC) { _ in updateLocation() }
-                        } else if config.interface == .scsi {
-                            NumberTextField("Target", number: $locationA)
-                                .onChange(of: locationA) { _ in updateLocation() }
-                            NumberTextField("LUN", number: $locationB)
-                                .onChange(of: locationB) { _ in updateLocation() }
-                        }
-                    }
-                }
-            }
-            
             if let imageUrl = config.imageURL {
                 let fileSize = data.computeSize(for: imageUrl)
                 DefaultTextField("Size", text: .constant(ByteCountFormatter.string(fromByteCount: fileSize, countStyle: .binary))).disabled(true)
@@ -184,36 +154,6 @@ struct VMConfigDriveDetailsView: View {
             }
             #endif
         }
-        .onAppear {
-            fetchLocation()
-        }
-    }
-    
-    private func fetchLocation() {
-        if let interfaceLocation = config.interfaceLocation {
-            hasAutoLocation = false
-            locationA = interfaceLocation.count > 0 ? interfaceLocation[0] : 0
-            locationB = interfaceLocation.count > 1 ? interfaceLocation[1] : 0
-            locationC = interfaceLocation.count > 2 ? interfaceLocation[2] : 0
-        }
-    }
-    
-    private func updateLocation() {
-        guard !hasAutoLocation else {
-            locationA = 0
-            locationB = 0
-            locationC = 0
-            config.interfaceLocation = nil
-            return
-        }
-        switch config.interface {
-        case .ide:
-            config.interfaceLocation = [locationA, locationB, locationC]
-        case .scsi:
-            config.interfaceLocation = [locationA, locationB]
-        default:
-            config.interfaceLocation = nil
-        }
     }
     
     #if os(macOS)