Przeglądaj źródła

scripting: add file urls to qemu additional arguments
* file urls is a list of file
* file urls are not saved to the disk (config.plist)
* QEMU launcher looks at file urls of args to collect required resources
* QEMU uses file URLs to access its corresponding bookmark
* The permissions of these urls is not handled as part of config update (ConfigImpl) , they should be handled at VM level(VMImpl) to update registryEntry of each VM

Naveenraj M 7 miesięcy temu
rodzic
commit
f0cf825c22
2 zmienionych plików z 12 dodań i 1 usunięć
  1. 4 0
      Scripting/UTM.sdef
  2. 8 1
      Scripting/UTMScriptingConfigImpl.swift

+ 4 - 0
Scripting/UTM.sdef

@@ -561,6 +561,10 @@
         <record-type name="qemu argument" code="QeAr" description="QEMU argument configuration.">
         <record-type name="qemu argument" code="QeAr" description="QEMU argument configuration.">
           <property name="argument string" code="ArSt" type="text"
           <property name="argument string" code="ArSt" type="text"
             description="The QEMU argument as a string."/>
             description="The QEMU argument as a string."/>
+          <property name="file urls" code="FlUr" 
+            description="Optional URLs associated with this argument.">
+            <type type="file" list="yes"/>
+          </property>
         </record-type>
         </record-type>
         
         
         <record-type name="apple configuration" code="ApCf" description="Apple virtual machine configuration.">
         <record-type name="apple configuration" code="ApCf" description="Apple virtual machine configuration.">

+ 8 - 1
Scripting/UTMScriptingConfigImpl.swift

@@ -193,6 +193,10 @@ extension UTMScriptingConfigImpl {
         var serializedArgument: [AnyHashable: Any] = [
         var serializedArgument: [AnyHashable: Any] = [
             "argumentString": argument.string
             "argumentString": argument.string
         ]
         ]
+        // Only add fileUrls if it is not nil and contains URLs
+        if let fileUrls = argument.fileUrls, !fileUrls.isEmpty {
+            serializedArgument["fileUrls"] = fileUrls.map({ $0 as AnyHashable })
+        }
         
         
         return serializedArgument
         return serializedArgument
     }
     }
@@ -517,7 +521,10 @@ extension UTMScriptingConfigImpl {
         let additionalArguments = records.compactMap { record -> QEMUArgument? in
         let additionalArguments = records.compactMap { record -> QEMUArgument? in
             guard let argumentString = record["argumentString"] as? String else { return nil }
             guard let argumentString = record["argumentString"] as? String else { return nil }
             var argument = QEMUArgument(argumentString)
             var argument = QEMUArgument(argumentString)
-            
+            // fileUrls are used as required resources by QEMU.
+            if let fileUrls = record["fileUrls"] as? [URL] {
+                argument.fileUrls = fileUrls
+            }
             return argument
             return argument
         }
         }
         // Update entire additional arguments with new one.
         // Update entire additional arguments with new one.