Explorar el Código

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 hace 7 meses
padre
commit
f0cf825c22
Se han modificado 2 ficheros con 12 adiciones y 1 borrados
  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.">
           <property name="argument string" code="ArSt" type="text"
             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 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] = [
             "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
     }
@@ -517,7 +521,10 @@ extension UTMScriptingConfigImpl {
         let additionalArguments = records.compactMap { record -> QEMUArgument? in
             guard let argumentString = record["argumentString"] as? String else { return nil }
             var argument = QEMUArgument(argumentString)
-            
+            // fileUrls are used as required resources by QEMU.
+            if let fileUrls = record["fileUrls"] as? [URL] {
+                argument.fileUrls = fileUrls
+            }
             return argument
         }
         // Update entire additional arguments with new one.