Genode Packages collection https://git.sr.ht/~ehmry/genodepkgs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vbox-guest.dhall 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. let Genode = env:DHALL_GENODE
  2. let Prelude = Genode.Prelude
  3. let XML = Prelude.XML
  4. let Init = Genode.Init
  5. let Child = Init.Child
  6. let Resources = Init.Resources
  7. let ServiceRoute = Init.ServiceRoute
  8. let Vfs/inline =
  9. λ(name : Text)
  10. → λ(body : Text)
  11. → XML.element
  12. { name = "inline"
  13. , attributes = toMap { name = name }
  14. , content = [ XML.text body ]
  15. }
  16. let BootFormat = < ISO | VDI >
  17. let Params
  18. : Type
  19. = { bootFilename : Text
  20. , bootPkg : Text
  21. , bootUuid : Text
  22. , bootFormat : BootFormat
  23. , memorySize : Natural
  24. , vmName : Text
  25. }
  26. let toVbox =
  27. λ(params : Params)
  28. → let vboxConfig =
  29. let hardDisks =
  30. merge
  31. { ISO = XML.text ""
  32. , VDI =
  33. XML.leaf
  34. { name = "HardDisk"
  35. , attributes = toMap
  36. { uuid = "{${params.bootUuid}}"
  37. , location = "${params.bootFilename}"
  38. , format = "VDI"
  39. , type = "Normal"
  40. }
  41. }
  42. }
  43. params.bootFormat
  44. let dvdImages =
  45. merge
  46. { ISO =
  47. XML.leaf
  48. { name = "Image"
  49. , attributes = toMap
  50. { uuid = "{${params.bootUuid}}"
  51. , location = "${params.bootFilename}"
  52. }
  53. }
  54. , VDI = XML.text ""
  55. }
  56. params.bootFormat
  57. let attachedDevices =
  58. XML.element
  59. { name = "AttachedDevice"
  60. , attributes =
  61. merge
  62. { ISO = toMap
  63. { passthrough = "false"
  64. , type = "DVD"
  65. , port = "3"
  66. , device = "0"
  67. }
  68. , VDI = toMap
  69. { type = "HardDisk", port = "0", device = "0" }
  70. }
  71. params.bootFormat
  72. , content =
  73. [ XML.leaf
  74. { name = "Image"
  75. , attributes = toMap
  76. { uuid = "{${params.bootUuid}}" }
  77. }
  78. ]
  79. }
  80. in ''
  81. <VirtualBox xmlns="http://www.virtualbox.org/" version="1.14-freebsd">
  82. <Machine uuid="{37ab43a5-38d8-4491-93f5-5b0b077f5c32}" name="${params.vmName}" OSType="Linux26_64" snapshotFolder="Snapshots" lastStateChange="2018-01-23T18:40:00Z">
  83. <MediaRegistry>
  84. <HardDisks>${XML.render hardDisks}</HardDisks>
  85. <DVDImages>${XML.render dvdImages}</DVDImages>
  86. </MediaRegistry>
  87. <Hardware>
  88. <CPU count="2">
  89. <PAE enabled="true"/>
  90. <LongMode enabled="true"/>
  91. <HardwareVirtExLargePages enabled="false"/>
  92. </CPU>
  93. <Memory RAMSize="${Prelude.Natural.show
  94. params.memorySize}"/>
  95. <HID Pointing="USBTablet"/>
  96. <Display VRAMSize="20"/>
  97. <RemoteDisplay enabled="false"/>
  98. <BIOS>
  99. <IOAPIC enabled="true"/>
  100. </BIOS>
  101. <USB>
  102. <Controllers/>
  103. </USB>
  104. <Network>
  105. <Adapter slot="0" enabled="true" MACAddress="0800271D7901" cable="true" type="82540EM">
  106. <BridgedInterface/>
  107. </Adapter>
  108. </Network>
  109. <UART>
  110. <Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
  111. <Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
  112. </UART>
  113. <LPT>
  114. <Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
  115. <Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
  116. </LPT>
  117. <AudioAdapter controller="HDA" driver="OSS" enabled="false"/>
  118. <RTC localOrUTC="UTC"/>
  119. <SharedFolders/>
  120. </Hardware>
  121. <StorageControllers>
  122. <StorageController name="SATA" type="AHCI" PortCount="4" useHostIOCache="true" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
  123. ${XML.render attachedDevices}
  124. </StorageController>
  125. </StorageControllers>
  126. </Machine>
  127. </VirtualBox>
  128. ''
  129. in Child.flat
  130. Child.Attributes::{
  131. , binary = "virtualbox5"
  132. , config = Init.Config::{
  133. , attributes = toMap
  134. { vbox_file = "machine.vbox", vm_name = params.vmName }
  135. , content =
  136. [ XML.leaf
  137. { name = "libc"
  138. , attributes = toMap
  139. { stdout = "/log", stderr = "/log", rtc = "/dev/rtc" }
  140. }
  141. , XML.element
  142. { name = "vfs"
  143. , attributes = XML.emptyAttributes
  144. , content =
  145. let tag =
  146. λ(name : Text)
  147. → XML.leaf
  148. { name = name
  149. , attributes = XML.emptyAttributes
  150. }
  151. let mutableVfs =
  152. let fsNode =
  153. [ XML.leaf
  154. { name = "fs"
  155. , attributes = toMap
  156. { label = "nix/store"
  157. , root = "${params.bootPkg}"
  158. }
  159. }
  160. ]
  161. in merge
  162. { ISO =
  163. [ XML.leaf
  164. { name = "fs"
  165. , attributes = toMap
  166. { writeable = "yes" }
  167. }
  168. , XML.element
  169. { name = "import"
  170. , attributes = toMap
  171. { overwrite = "no" }
  172. , content = fsNode
  173. }
  174. ]
  175. , VDI =
  176. [ XML.leaf
  177. { name = "fs"
  178. , attributes = toMap
  179. { writeable = "yes" }
  180. }
  181. , XML.element
  182. { name = "import"
  183. , attributes = toMap
  184. { overwrite = "no" }
  185. , content = fsNode
  186. }
  187. ]
  188. }
  189. params.bootFormat
  190. in [ Vfs/inline "machine.vbox" vboxConfig
  191. , XML.element
  192. { name = "dir"
  193. , attributes = toMap { name = "dev" }
  194. , content = [ tag "log", tag "rtc" ]
  195. }
  196. ]
  197. # mutableVfs
  198. }
  199. ]
  200. }
  201. , resources = Resources::{
  202. , caps = 1024
  203. , ram =
  204. Genode.units.MiB 128 + Genode.units.MiB params.memorySize
  205. }
  206. , routes =
  207. [ ServiceRoute.parent "File_system"
  208. , ServiceRoute.parent "Nic"
  209. , ServiceRoute.parent "Nitpicker"
  210. , ServiceRoute.parent "Rtc"
  211. , ServiceRoute.parent "Timer"
  212. , ServiceRoute.parent "VM"
  213. , ServiceRoute.parent "Report"
  214. , ServiceRoute.parentLabel
  215. "ROM"
  216. (Some "platform_info")
  217. (Some "platform_info")
  218. ]
  219. }
  220. in toVbox