desc.go 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package desc
  15. import (
  16. "yunion.io/x/jsonutils"
  17. api "yunion.io/x/onecloud/pkg/apis/compute"
  18. "yunion.io/x/onecloud/pkg/apis/host"
  19. )
  20. type SGuestCpu struct {
  21. Cpus uint
  22. Sockets uint
  23. Cores uint
  24. Threads uint
  25. MaxCpus uint
  26. Model string
  27. Vendor string
  28. Level string
  29. Features map[string]bool `json:",omitempty"`
  30. Accel string
  31. // emulate, passthrough, disable
  32. // CpuCacheMode string
  33. }
  34. type SCpuPin struct {
  35. Vcpus string
  36. Pcpus string
  37. }
  38. type SMemDevice struct {
  39. Type string
  40. Id string
  41. }
  42. type SMemSlot struct {
  43. SizeMB int64
  44. MemObj *SMemDesc
  45. MemDev *SMemDevice
  46. }
  47. type SCpuNumaPin struct {
  48. SizeMB int64
  49. Unregular bool
  50. NodeId *uint16 `json:",omitempty"`
  51. VcpuPin []SVCpuPin `json:",omitempty"`
  52. ExtraCpuCount int `json:"extra_cpu_count"`
  53. }
  54. type SVCpuPin struct {
  55. Vcpu int
  56. Pcpu int
  57. }
  58. type SMemDesc struct {
  59. *Object
  60. NodeId *uint16 `json:",omitempty"`
  61. // vcpus
  62. Cpus *string `json:",omitempty"`
  63. }
  64. type SMemsDesc struct {
  65. SMemDesc
  66. Mems []SMemDesc `json:",omitempty"`
  67. }
  68. type SGuestMem struct {
  69. Slots uint
  70. MaxMem uint
  71. SizeMB int64
  72. Mem *SMemsDesc `json:",omitempty"`
  73. // hotplug mem devices
  74. MemSlots []*SMemSlot `json:",omitempty"`
  75. }
  76. type SGuestHardwareDesc struct {
  77. Cpu int64
  78. CpuDesc *SGuestCpu `json:",omitempty"`
  79. VcpuPin []SCpuPin `json:",omitempty"`
  80. // Clock *SGuestClock `json:",omitempty"`
  81. // memory size in MB
  82. Mem int64
  83. MemDesc *SGuestMem `json:",omitempty"`
  84. CpuNumaPin []*SCpuNumaPin `json:",omitempty"`
  85. Bios string
  86. BootOrder string
  87. // supported machine type: pc, q35, virt
  88. Machine string
  89. MachineDesc *SGuestMachine `json:",omitempty"`
  90. NoHpet *bool `json:",omitempty"` // i386 target only
  91. VirtioSerial *SGuestVirtioSerial
  92. Tpm *SGuestTpm
  93. // std virtio cirrus vmware qlx none
  94. Vga string
  95. VgaDevice *SGuestVga `json:",omitempty"`
  96. // vnc or spice
  97. Vdi string
  98. VdiDevice *SGuestVdi `json:",omitempty"`
  99. VirtioScsi *SGuestVirtioScsi `json:",omitempty"`
  100. PvScsi *SGuestPvScsi `json:",omitempty"`
  101. SataController *SGuestAhciDevice `json:",omitempty"`
  102. Cdroms []*SGuestCdrom `json:"cdroms,omitempty"`
  103. Floppys []*SGuestFloppy `json:",omitempty"`
  104. Disks []*SGuestDisk `json:",omitempty"`
  105. Nics []*SGuestNetwork `json:",omitempty"`
  106. IsolatedDevices []*SGuestIsolatedDevice `json:",omitempty"`
  107. // Random Number Generator Device
  108. Rng *SGuestRng `json:",omitempty"`
  109. Qga *SGuestQga `json:",omitempty"`
  110. Pvpanic *SGuestPvpanic `json:",omitempty"`
  111. IsaSerial *SGuestIsaSerial `json:",omitempty"`
  112. Usb *UsbController `json:",omitempty"`
  113. PCIControllers []*PCIController `json:",omitempty"`
  114. AnonymousPCIDevs []*PCIDevice `json:",omitempty"`
  115. RescueInitdPath string `json:",omitempty"` // rescue initramfs path
  116. RescueKernelPath string `json:",omitempty"` // rescue kernel path
  117. RescueDiskPath string `json:",omitempty"` // rescue disk path
  118. RescueDiskDeviceBus uint `json:",omitempty"` // rescue disk device bus
  119. RescueDiskDeviceSlot uint `json:",omitempty"` // rescue disk device slot
  120. }
  121. type SGuestIsaSerial struct {
  122. Pty *CharDev
  123. Id string
  124. }
  125. type SGuestQga struct {
  126. Socket *CharDev
  127. SerialPort *VirtSerialPort
  128. }
  129. type VirtSerialPort struct {
  130. Chardev string
  131. Name string
  132. Options map[string]string `json:",omitempty"`
  133. }
  134. type SGuestPvpanic struct {
  135. Ioport uint // default ioport 1285(0x505)
  136. Id string
  137. }
  138. type SGuestTpm struct {
  139. TpmSock *CharDev
  140. // default emulator tpm
  141. Id string
  142. }
  143. // -device pcie-pci-bridge,id=pci.1,bus=pcie.0 \
  144. // -device pci-bridge,id=pci.2,bus=pci.1,chassis_nr=1,addr=0x01 \
  145. type PCIController struct {
  146. *PCIDevice
  147. CType PCI_CONTROLLER_TYPE
  148. }
  149. type SGuestMachine struct {
  150. Accel string
  151. // arm only
  152. GicVersion *string `json:",omitempty"`
  153. }
  154. type SGuestDisk struct {
  155. api.GuestdiskJsonDesc
  156. // disk driver virtio
  157. Pci *PCIDevice `json:",omitempty"`
  158. // disk driver scsi/pvscsi
  159. Scsi *SCSIDevice `json:",omitempty"`
  160. // disk driver ide/sata
  161. Ide *IDEDevice `json:",omitempty"`
  162. }
  163. // -device ide-cd,drive=ide0-cd0,bus=ide.1
  164. // -drive id=ide0-cd0,media=cdrom,if=none,file=%s
  165. // --- mac os
  166. // -device ide-drive,drive=MacDVD,bus=ide.%d
  167. // -drive id=MacDVD,if=none,snapshot=on,file=%s
  168. type SGuestCdrom struct {
  169. Id string
  170. Path string
  171. Ordinal int64
  172. BootIndex *int8
  173. Ide *IDEDevice `json:",omitempty"`
  174. Scsi *SCSIDevice `json:",omitempty"`
  175. DriveOptions map[string]string `json:",omitempty"`
  176. }
  177. type SGuestFloppy struct {
  178. Id string
  179. Path string
  180. Ordinal int64
  181. Floppy *FloppyDevice `json:",omitempty"`
  182. DriveOptions map[string]string `json:",omitempty"`
  183. }
  184. type SGuestNetwork struct {
  185. api.GuestnetworkJsonDesc
  186. Pci *PCIDevice `json:",omitempty"`
  187. }
  188. type VFIODevice struct {
  189. *PCIDevice
  190. HostAddr string
  191. XVga bool
  192. }
  193. type SGuestIsolatedDevice struct {
  194. api.IsolatedDeviceJsonDesc
  195. VfioDevs []*VFIODevice `json:",omitempty"`
  196. Usb *UsbDevice
  197. }
  198. type SGuestVga struct {
  199. *PCIDevice `json:",omitempty"`
  200. }
  201. type SGuestRng struct {
  202. *PCIDevice `json:",omitempty"`
  203. RngRandom *Object
  204. }
  205. type SoundCard struct {
  206. *PCIDevice `json:",omitempty"`
  207. Codec *Codec
  208. }
  209. type Codec struct {
  210. Id string
  211. Type string
  212. Cad int
  213. }
  214. type SSpiceDesc struct {
  215. // Intel High Definition Audio
  216. IntelHDA *SoundCard
  217. // vdagent
  218. VdagentSerial *SGuestVirtioSerial
  219. Vdagent *CharDev
  220. VdagentSerialPort *VirtSerialPort
  221. // usb redirect
  222. UsbRedirct *UsbRedirctDesc
  223. Options map[string]string `json:",omitempty"`
  224. }
  225. type UsbMasterBus struct {
  226. Masterbus string
  227. Port int
  228. }
  229. type UsbController struct {
  230. *PCIDevice
  231. MasterBus *UsbMasterBus `json:",omitempty"`
  232. }
  233. type UsbAddr struct {
  234. Bus int
  235. Port int
  236. }
  237. type UsbDevice struct {
  238. *UsbAddr
  239. Id string
  240. DevType string
  241. Options map[string]string `json:",omitempty"`
  242. }
  243. type UsbRedirctDesc struct {
  244. // EHCI adapter: Enhanced Host Controller Interface, USB2.0
  245. // Depends on UHCI to support full of usb devices
  246. EHCI1 *UsbController
  247. // UHCI controllers: Universal Host Controller Interface, USB 1.0, 1.1
  248. UHCI1 *UsbController
  249. UHCI2 *UsbController
  250. UHCI3 *UsbController
  251. UsbRedirDev1 *UsbRedir
  252. UsbRedirDev2 *UsbRedir
  253. }
  254. type UsbRedir struct {
  255. Id string
  256. Source *CharDev
  257. }
  258. type SGuestVdi struct {
  259. Spice *SSpiceDesc
  260. }
  261. type SGuestVirtioSerial struct {
  262. *PCIDevice
  263. }
  264. type SGuestVirtioScsi struct {
  265. *PCIDevice
  266. NumQueues *uint8 `json:"num_queues"`
  267. }
  268. type SGuestPvScsi struct {
  269. *PCIDevice
  270. }
  271. type SGuestAhciDevice struct {
  272. *PCIDevice
  273. }
  274. type SGuestProjectDesc struct {
  275. Tenant string
  276. TenantId string
  277. DomainId string
  278. ProjectDomain string
  279. }
  280. type SGuestRegionDesc struct {
  281. Zone string `json:"zone"`
  282. Domain string `json:"domain"`
  283. HostId string `json:"host_id"`
  284. Hostname string `json:"hostname"`
  285. HostAccessIp string `json:"host_access_ip"`
  286. HostEIP string `json:"host_eip"`
  287. }
  288. type SGuestControlDesc struct {
  289. IsDaemon bool
  290. IsMaster bool
  291. IsSlave bool
  292. // is volatile host meaning guest not running on this host right now
  293. IsVolatileHost bool
  294. ScalingGroupId string
  295. SrcIpCheck bool
  296. SrcMacCheck bool
  297. SecurityRules string
  298. AdminSecurityRules string
  299. NicSecgroups []*api.GuestnetworkSecgroupDesc `json:"nic_secgroups,omitempty"`
  300. EncryptKeyId string
  301. LightMode bool // light mode
  302. Hypervisor string
  303. }
  304. type SGuestMetaDesc struct {
  305. Name string
  306. Uuid string
  307. OsName string
  308. Pubkey string
  309. Keypair string
  310. Secgroup string
  311. Flavor string
  312. UserData string
  313. Metadata map[string]string
  314. ExtraOptions map[string]jsonutils.JSONObject
  315. }
  316. type SGuestContainerDesc struct {
  317. Containers []*host.ContainerDesc
  318. }
  319. type SGuestDesc struct {
  320. SGuestProjectDesc
  321. SGuestRegionDesc
  322. SGuestControlDesc
  323. SGuestHardwareDesc
  324. SGuestMetaDesc
  325. SGuestContainerDesc
  326. }