2
0

machine.c 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758
  1. /*
  2. * QEMU Machine
  3. *
  4. * Copyright (C) 2014 Red Hat Inc
  5. *
  6. * Authors:
  7. * Marcel Apfelbaum <marcel.a@redhat.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. */
  12. #include "qemu/osdep.h"
  13. #include "qemu/units.h"
  14. #include "qemu/accel.h"
  15. #include "system/replay.h"
  16. #include "hw/boards.h"
  17. #include "hw/loader.h"
  18. #include "qemu/error-report.h"
  19. #include "qapi/error.h"
  20. #include "qapi/qapi-visit-machine.h"
  21. #include "qemu/madvise.h"
  22. #include "qom/object_interfaces.h"
  23. #include "system/cpus.h"
  24. #include "system/system.h"
  25. #include "system/reset.h"
  26. #include "system/runstate.h"
  27. #include "system/xen.h"
  28. #include "system/qtest.h"
  29. #include "hw/pci/pci_bridge.h"
  30. #include "hw/mem/nvdimm.h"
  31. #include "migration/global_state.h"
  32. #include "system/confidential-guest-support.h"
  33. #include "hw/virtio/virtio-pci.h"
  34. #include "hw/virtio/virtio-net.h"
  35. #include "hw/virtio/virtio-iommu.h"
  36. #include "audio/audio.h"
  37. GlobalProperty hw_compat_9_2[] = {
  38. {"arm-cpu", "backcompat-pauth-default-use-qarma5", "true"},
  39. { "virtio-balloon-pci", "vectors", "0" },
  40. { "virtio-balloon-pci-transitional", "vectors", "0" },
  41. { "virtio-balloon-pci-non-transitional", "vectors", "0" },
  42. { "virtio-mem-pci", "vectors", "0" },
  43. };
  44. const size_t hw_compat_9_2_len = G_N_ELEMENTS(hw_compat_9_2);
  45. GlobalProperty hw_compat_9_1[] = {
  46. { TYPE_PCI_DEVICE, "x-pcie-ext-tag", "false" },
  47. };
  48. const size_t hw_compat_9_1_len = G_N_ELEMENTS(hw_compat_9_1);
  49. GlobalProperty hw_compat_9_0[] = {
  50. {"arm-cpu", "backcompat-cntfrq", "true" },
  51. { "scsi-hd", "migrate-emulated-scsi-request", "false" },
  52. { "scsi-cd", "migrate-emulated-scsi-request", "false" },
  53. {"vfio-pci", "skip-vsc-check", "false" },
  54. { "virtio-pci", "x-pcie-pm-no-soft-reset", "off" },
  55. {"sd-card", "spec_version", "2" },
  56. };
  57. const size_t hw_compat_9_0_len = G_N_ELEMENTS(hw_compat_9_0);
  58. GlobalProperty hw_compat_8_2[] = {
  59. { "migration", "zero-page-detection", "legacy"},
  60. { TYPE_VIRTIO_IOMMU_PCI, "granule", "4k" },
  61. { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "64" },
  62. { "virtio-gpu-device", "x-scanout-vmstate-version", "1" },
  63. };
  64. const size_t hw_compat_8_2_len = G_N_ELEMENTS(hw_compat_8_2);
  65. GlobalProperty hw_compat_8_1[] = {
  66. { TYPE_PCI_BRIDGE, "x-pci-express-writeable-slt-bug", "true" },
  67. { "ramfb", "x-migrate", "off" },
  68. { "vfio-pci-nohotplug", "x-ramfb-migrate", "off" },
  69. { "igb", "x-pcie-flr-init", "off" },
  70. { TYPE_VIRTIO_NET, "host_uso", "off"},
  71. { TYPE_VIRTIO_NET, "guest_uso4", "off"},
  72. { TYPE_VIRTIO_NET, "guest_uso6", "off"},
  73. };
  74. const size_t hw_compat_8_1_len = G_N_ELEMENTS(hw_compat_8_1);
  75. GlobalProperty hw_compat_8_0[] = {
  76. { "migration", "multifd-flush-after-each-section", "on"},
  77. { TYPE_PCI_DEVICE, "x-pcie-ari-nextfn-1", "on" },
  78. };
  79. const size_t hw_compat_8_0_len = G_N_ELEMENTS(hw_compat_8_0);
  80. GlobalProperty hw_compat_7_2[] = {
  81. { "e1000e", "migrate-timadj", "off" },
  82. { "virtio-mem", "x-early-migration", "false" },
  83. { "migration", "x-preempt-pre-7-2", "true" },
  84. { TYPE_PCI_DEVICE, "x-pcie-err-unc-mask", "off" },
  85. };
  86. const size_t hw_compat_7_2_len = G_N_ELEMENTS(hw_compat_7_2);
  87. GlobalProperty hw_compat_7_1[] = {
  88. { "virtio-device", "queue_reset", "false" },
  89. { "virtio-rng-pci", "vectors", "0" },
  90. { "virtio-rng-pci-transitional", "vectors", "0" },
  91. { "virtio-rng-pci-non-transitional", "vectors", "0" },
  92. };
  93. const size_t hw_compat_7_1_len = G_N_ELEMENTS(hw_compat_7_1);
  94. GlobalProperty hw_compat_7_0[] = {
  95. { "arm-gicv3-common", "force-8-bit-prio", "on" },
  96. { "nvme-ns", "eui64-default", "on"},
  97. };
  98. const size_t hw_compat_7_0_len = G_N_ELEMENTS(hw_compat_7_0);
  99. GlobalProperty hw_compat_6_2[] = {
  100. { "PIIX4_PM", "x-not-migrate-acpi-index", "on"},
  101. };
  102. const size_t hw_compat_6_2_len = G_N_ELEMENTS(hw_compat_6_2);
  103. GlobalProperty hw_compat_6_1[] = {
  104. { "vhost-user-vsock-device", "seqpacket", "off" },
  105. { "nvme-ns", "shared", "off" },
  106. };
  107. const size_t hw_compat_6_1_len = G_N_ELEMENTS(hw_compat_6_1);
  108. GlobalProperty hw_compat_6_0[] = {
  109. { "gpex-pcihost", "allow-unmapped-accesses", "false" },
  110. { "i8042", "extended-state", "false"},
  111. { "nvme-ns", "eui64-default", "off"},
  112. { "e1000", "init-vet", "off" },
  113. { "e1000e", "init-vet", "off" },
  114. { "vhost-vsock-device", "seqpacket", "off" },
  115. };
  116. const size_t hw_compat_6_0_len = G_N_ELEMENTS(hw_compat_6_0);
  117. GlobalProperty hw_compat_5_2[] = {
  118. { "ICH9-LPC", "smm-compat", "on"},
  119. { "PIIX4_PM", "smm-compat", "on"},
  120. { "virtio-blk-device", "report-discard-granularity", "off" },
  121. { "virtio-net-pci-base", "vectors", "3"},
  122. { "nvme", "msix-exclusive-bar", "on"},
  123. };
  124. const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2);
  125. GlobalProperty hw_compat_5_1[] = {
  126. { "vhost-scsi", "num_queues", "1"},
  127. { "vhost-user-blk", "num-queues", "1"},
  128. { "vhost-user-scsi", "num_queues", "1"},
  129. { "virtio-blk-device", "num-queues", "1"},
  130. { "virtio-scsi-device", "num_queues", "1"},
  131. { "nvme", "use-intel-id", "on"},
  132. { "pvpanic", "events", "1"}, /* PVPANIC_PANICKED */
  133. { "pl011", "migrate-clk", "off" },
  134. { "virtio-pci", "x-ats-page-aligned", "off"},
  135. };
  136. const size_t hw_compat_5_1_len = G_N_ELEMENTS(hw_compat_5_1);
  137. GlobalProperty hw_compat_5_0[] = {
  138. { "pci-host-bridge", "x-config-reg-migration-enabled", "off" },
  139. { "virtio-balloon-device", "page-poison", "false" },
  140. { "vmport", "x-read-set-eax", "off" },
  141. { "vmport", "x-signal-unsupported-cmd", "off" },
  142. { "vmport", "x-report-vmx-type", "off" },
  143. { "vmport", "x-cmds-v2", "off" },
  144. { "virtio-device", "x-disable-legacy-check", "true" },
  145. };
  146. const size_t hw_compat_5_0_len = G_N_ELEMENTS(hw_compat_5_0);
  147. GlobalProperty hw_compat_4_2[] = {
  148. { "virtio-blk-device", "queue-size", "128"},
  149. { "virtio-scsi-device", "virtqueue_size", "128"},
  150. { "virtio-blk-device", "x-enable-wce-if-config-wce", "off" },
  151. { "virtio-blk-device", "seg-max-adjust", "off"},
  152. { "virtio-scsi-device", "seg_max_adjust", "off"},
  153. { "vhost-blk-device", "seg_max_adjust", "off"},
  154. { "usb-host", "suppress-remote-wake", "off" },
  155. { "usb-redir", "suppress-remote-wake", "off" },
  156. { "qxl", "revision", "4" },
  157. { "qxl-vga", "revision", "4" },
  158. { "fw_cfg", "acpi-mr-restore", "false" },
  159. { "virtio-device", "use-disabled-flag", "false" },
  160. };
  161. const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
  162. GlobalProperty hw_compat_4_1[] = {
  163. { "virtio-pci", "x-pcie-flr-init", "off" },
  164. };
  165. const size_t hw_compat_4_1_len = G_N_ELEMENTS(hw_compat_4_1);
  166. GlobalProperty hw_compat_4_0[] = {
  167. { "VGA", "edid", "false" },
  168. { "secondary-vga", "edid", "false" },
  169. { "bochs-display", "edid", "false" },
  170. { "virtio-vga", "edid", "false" },
  171. { "virtio-gpu-device", "edid", "false" },
  172. { "virtio-device", "use-started", "false" },
  173. { "virtio-balloon-device", "qemu-4-0-config-size", "true" },
  174. { "pl031", "migrate-tick-offset", "false" },
  175. };
  176. const size_t hw_compat_4_0_len = G_N_ELEMENTS(hw_compat_4_0);
  177. GlobalProperty hw_compat_3_1[] = {
  178. { "pcie-root-port", "x-speed", "2_5" },
  179. { "pcie-root-port", "x-width", "1" },
  180. { "memory-backend-file", "x-use-canonical-path-for-ramblock-id", "true" },
  181. { "memory-backend-memfd", "x-use-canonical-path-for-ramblock-id", "true" },
  182. { "tpm-crb", "ppi", "false" },
  183. { "tpm-tis", "ppi", "false" },
  184. { "usb-kbd", "serial", "42" },
  185. { "usb-mouse", "serial", "42" },
  186. { "usb-tablet", "serial", "42" },
  187. { "virtio-blk-device", "discard", "false" },
  188. { "virtio-blk-device", "write-zeroes", "false" },
  189. { "virtio-balloon-device", "qemu-4-0-config-size", "false" },
  190. { "pcie-root-port-base", "disable-acs", "true" }, /* Added in 4.1 */
  191. };
  192. const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1);
  193. GlobalProperty hw_compat_3_0[] = {};
  194. const size_t hw_compat_3_0_len = G_N_ELEMENTS(hw_compat_3_0);
  195. GlobalProperty hw_compat_2_12[] = {
  196. { "hda-audio", "use-timer", "false" },
  197. { "cirrus-vga", "global-vmstate", "true" },
  198. { "VGA", "global-vmstate", "true" },
  199. { "vmware-svga", "global-vmstate", "true" },
  200. { "qxl-vga", "global-vmstate", "true" },
  201. };
  202. const size_t hw_compat_2_12_len = G_N_ELEMENTS(hw_compat_2_12);
  203. GlobalProperty hw_compat_2_11[] = {
  204. { "hpet", "hpet-offset-saved", "false" },
  205. { "virtio-blk-pci", "vectors", "2" },
  206. { "vhost-user-blk-pci", "vectors", "2" },
  207. { "e1000", "migrate_tso_props", "off" },
  208. };
  209. const size_t hw_compat_2_11_len = G_N_ELEMENTS(hw_compat_2_11);
  210. GlobalProperty hw_compat_2_10[] = {
  211. { "virtio-mouse-device", "wheel-axis", "false" },
  212. { "virtio-tablet-device", "wheel-axis", "false" },
  213. };
  214. const size_t hw_compat_2_10_len = G_N_ELEMENTS(hw_compat_2_10);
  215. GlobalProperty hw_compat_2_9[] = {
  216. { "pci-bridge", "shpc", "off" },
  217. { "intel-iommu", "pt", "off" },
  218. { "virtio-net-device", "x-mtu-bypass-backend", "off" },
  219. { "pcie-root-port", "x-migrate-msix", "false" },
  220. };
  221. const size_t hw_compat_2_9_len = G_N_ELEMENTS(hw_compat_2_9);
  222. GlobalProperty hw_compat_2_8[] = {
  223. { "fw_cfg_mem", "x-file-slots", "0x10" },
  224. { "fw_cfg_io", "x-file-slots", "0x10" },
  225. { "pflash_cfi01", "old-multiple-chip-handling", "on" },
  226. { "pci-bridge", "shpc", "on" },
  227. { TYPE_PCI_DEVICE, "x-pcie-extcap-init", "off" },
  228. { "virtio-pci", "x-pcie-deverr-init", "off" },
  229. { "virtio-pci", "x-pcie-lnkctl-init", "off" },
  230. { "virtio-pci", "x-pcie-pm-init", "off" },
  231. { "cirrus-vga", "vgamem_mb", "8" },
  232. { "isa-cirrus-vga", "vgamem_mb", "8" },
  233. };
  234. const size_t hw_compat_2_8_len = G_N_ELEMENTS(hw_compat_2_8);
  235. GlobalProperty hw_compat_2_7[] = {
  236. { "virtio-pci", "page-per-vq", "on" },
  237. { "virtio-serial-device", "emergency-write", "off" },
  238. { "ioapic", "version", "0x11" },
  239. { "intel-iommu", "x-buggy-eim", "true" },
  240. { "virtio-pci", "x-ignore-backend-features", "on" },
  241. };
  242. const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7);
  243. GlobalProperty hw_compat_2_6[] = {
  244. { "virtio-mmio", "format_transport_address", "off" },
  245. /* Optional because not all virtio-pci devices support legacy mode */
  246. { "virtio-pci", "disable-modern", "on", .optional = true },
  247. { "virtio-pci", "disable-legacy", "off", .optional = true },
  248. };
  249. const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6);
  250. GlobalProperty hw_compat_2_5[] = {
  251. { "isa-fdc", "fallback", "144" },
  252. { "pvscsi", "x-old-pci-configuration", "on" },
  253. { "pvscsi", "x-disable-pcie", "on" },
  254. { "vmxnet3", "x-old-msi-offsets", "on" },
  255. { "vmxnet3", "x-disable-pcie", "on" },
  256. };
  257. const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5);
  258. GlobalProperty hw_compat_2_4[] = {
  259. { "e1000", "extra_mac_registers", "off" },
  260. { "virtio-pci", "x-disable-pcie", "on" },
  261. { "virtio-pci", "migrate-extra", "off" },
  262. { "fw_cfg_mem", "dma_enabled", "off" },
  263. { "fw_cfg_io", "dma_enabled", "off" }
  264. };
  265. const size_t hw_compat_2_4_len = G_N_ELEMENTS(hw_compat_2_4);
  266. MachineState *current_machine;
  267. static char *machine_get_kernel(Object *obj, Error **errp)
  268. {
  269. MachineState *ms = MACHINE(obj);
  270. return g_strdup(ms->kernel_filename);
  271. }
  272. static void machine_set_kernel(Object *obj, const char *value, Error **errp)
  273. {
  274. MachineState *ms = MACHINE(obj);
  275. g_free(ms->kernel_filename);
  276. ms->kernel_filename = g_strdup(value);
  277. }
  278. static char *machine_get_shim(Object *obj, Error **errp)
  279. {
  280. MachineState *ms = MACHINE(obj);
  281. return g_strdup(ms->shim_filename);
  282. }
  283. static void machine_set_shim(Object *obj, const char *value, Error **errp)
  284. {
  285. MachineState *ms = MACHINE(obj);
  286. g_free(ms->shim_filename);
  287. ms->shim_filename = g_strdup(value);
  288. }
  289. static char *machine_get_initrd(Object *obj, Error **errp)
  290. {
  291. MachineState *ms = MACHINE(obj);
  292. return g_strdup(ms->initrd_filename);
  293. }
  294. static void machine_set_initrd(Object *obj, const char *value, Error **errp)
  295. {
  296. MachineState *ms = MACHINE(obj);
  297. g_free(ms->initrd_filename);
  298. ms->initrd_filename = g_strdup(value);
  299. }
  300. static char *machine_get_append(Object *obj, Error **errp)
  301. {
  302. MachineState *ms = MACHINE(obj);
  303. return g_strdup(ms->kernel_cmdline);
  304. }
  305. static void machine_set_append(Object *obj, const char *value, Error **errp)
  306. {
  307. MachineState *ms = MACHINE(obj);
  308. g_free(ms->kernel_cmdline);
  309. ms->kernel_cmdline = g_strdup(value);
  310. }
  311. static char *machine_get_dtb(Object *obj, Error **errp)
  312. {
  313. MachineState *ms = MACHINE(obj);
  314. return g_strdup(ms->dtb);
  315. }
  316. static void machine_set_dtb(Object *obj, const char *value, Error **errp)
  317. {
  318. MachineState *ms = MACHINE(obj);
  319. g_free(ms->dtb);
  320. ms->dtb = g_strdup(value);
  321. }
  322. static char *machine_get_dumpdtb(Object *obj, Error **errp)
  323. {
  324. MachineState *ms = MACHINE(obj);
  325. return g_strdup(ms->dumpdtb);
  326. }
  327. static void machine_set_dumpdtb(Object *obj, const char *value, Error **errp)
  328. {
  329. MachineState *ms = MACHINE(obj);
  330. g_free(ms->dumpdtb);
  331. ms->dumpdtb = g_strdup(value);
  332. }
  333. static void machine_get_phandle_start(Object *obj, Visitor *v,
  334. const char *name, void *opaque,
  335. Error **errp)
  336. {
  337. MachineState *ms = MACHINE(obj);
  338. int64_t value = ms->phandle_start;
  339. visit_type_int(v, name, &value, errp);
  340. }
  341. static void machine_set_phandle_start(Object *obj, Visitor *v,
  342. const char *name, void *opaque,
  343. Error **errp)
  344. {
  345. MachineState *ms = MACHINE(obj);
  346. int64_t value;
  347. if (!visit_type_int(v, name, &value, errp)) {
  348. return;
  349. }
  350. ms->phandle_start = value;
  351. }
  352. static char *machine_get_dt_compatible(Object *obj, Error **errp)
  353. {
  354. MachineState *ms = MACHINE(obj);
  355. return g_strdup(ms->dt_compatible);
  356. }
  357. static void machine_set_dt_compatible(Object *obj, const char *value, Error **errp)
  358. {
  359. MachineState *ms = MACHINE(obj);
  360. g_free(ms->dt_compatible);
  361. ms->dt_compatible = g_strdup(value);
  362. }
  363. static bool machine_get_dump_guest_core(Object *obj, Error **errp)
  364. {
  365. MachineState *ms = MACHINE(obj);
  366. return ms->dump_guest_core;
  367. }
  368. static void machine_set_dump_guest_core(Object *obj, bool value, Error **errp)
  369. {
  370. MachineState *ms = MACHINE(obj);
  371. if (!value && QEMU_MADV_DONTDUMP == QEMU_MADV_INVALID) {
  372. error_setg(errp, "Dumping guest memory cannot be disabled on this host");
  373. return;
  374. }
  375. ms->dump_guest_core = value;
  376. }
  377. static bool machine_get_mem_merge(Object *obj, Error **errp)
  378. {
  379. MachineState *ms = MACHINE(obj);
  380. return ms->mem_merge;
  381. }
  382. static void machine_set_mem_merge(Object *obj, bool value, Error **errp)
  383. {
  384. MachineState *ms = MACHINE(obj);
  385. if (value && QEMU_MADV_MERGEABLE == QEMU_MADV_INVALID) {
  386. error_setg(errp, "Memory merging is not supported on this host");
  387. return;
  388. }
  389. ms->mem_merge = value;
  390. }
  391. #ifdef CONFIG_POSIX
  392. static bool machine_get_aux_ram_share(Object *obj, Error **errp)
  393. {
  394. MachineState *ms = MACHINE(obj);
  395. return ms->aux_ram_share;
  396. }
  397. static void machine_set_aux_ram_share(Object *obj, bool value, Error **errp)
  398. {
  399. MachineState *ms = MACHINE(obj);
  400. ms->aux_ram_share = value;
  401. }
  402. #endif
  403. static bool machine_get_usb(Object *obj, Error **errp)
  404. {
  405. MachineState *ms = MACHINE(obj);
  406. return ms->usb;
  407. }
  408. static void machine_set_usb(Object *obj, bool value, Error **errp)
  409. {
  410. MachineState *ms = MACHINE(obj);
  411. ms->usb = value;
  412. ms->usb_disabled = !value;
  413. }
  414. static bool machine_get_graphics(Object *obj, Error **errp)
  415. {
  416. MachineState *ms = MACHINE(obj);
  417. return ms->enable_graphics;
  418. }
  419. static void machine_set_graphics(Object *obj, bool value, Error **errp)
  420. {
  421. MachineState *ms = MACHINE(obj);
  422. ms->enable_graphics = value;
  423. }
  424. static char *machine_get_firmware(Object *obj, Error **errp)
  425. {
  426. MachineState *ms = MACHINE(obj);
  427. return g_strdup(ms->firmware);
  428. }
  429. static void machine_set_firmware(Object *obj, const char *value, Error **errp)
  430. {
  431. MachineState *ms = MACHINE(obj);
  432. g_free(ms->firmware);
  433. ms->firmware = g_strdup(value);
  434. }
  435. static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp)
  436. {
  437. MachineState *ms = MACHINE(obj);
  438. ms->suppress_vmdesc = value;
  439. }
  440. static bool machine_get_suppress_vmdesc(Object *obj, Error **errp)
  441. {
  442. MachineState *ms = MACHINE(obj);
  443. return ms->suppress_vmdesc;
  444. }
  445. static char *machine_get_memory_encryption(Object *obj, Error **errp)
  446. {
  447. MachineState *ms = MACHINE(obj);
  448. if (ms->cgs) {
  449. return g_strdup(object_get_canonical_path_component(OBJECT(ms->cgs)));
  450. }
  451. return NULL;
  452. }
  453. static void machine_set_memory_encryption(Object *obj, const char *value,
  454. Error **errp)
  455. {
  456. Object *cgs =
  457. object_resolve_path_component(object_get_objects_root(), value);
  458. if (!cgs) {
  459. error_setg(errp, "No such memory encryption object '%s'", value);
  460. return;
  461. }
  462. object_property_set_link(obj, "confidential-guest-support", cgs, errp);
  463. }
  464. static void machine_check_confidential_guest_support(const Object *obj,
  465. const char *name,
  466. Object *new_target,
  467. Error **errp)
  468. {
  469. /*
  470. * So far the only constraint is that the target has the
  471. * TYPE_CONFIDENTIAL_GUEST_SUPPORT interface, and that's checked
  472. * by the QOM core
  473. */
  474. }
  475. static bool machine_get_nvdimm(Object *obj, Error **errp)
  476. {
  477. MachineState *ms = MACHINE(obj);
  478. return ms->nvdimms_state->is_enabled;
  479. }
  480. static void machine_set_nvdimm(Object *obj, bool value, Error **errp)
  481. {
  482. MachineState *ms = MACHINE(obj);
  483. ms->nvdimms_state->is_enabled = value;
  484. }
  485. static bool machine_get_hmat(Object *obj, Error **errp)
  486. {
  487. MachineState *ms = MACHINE(obj);
  488. return ms->numa_state->hmat_enabled;
  489. }
  490. static void machine_set_hmat(Object *obj, bool value, Error **errp)
  491. {
  492. MachineState *ms = MACHINE(obj);
  493. ms->numa_state->hmat_enabled = value;
  494. }
  495. static void machine_get_mem(Object *obj, Visitor *v, const char *name,
  496. void *opaque, Error **errp)
  497. {
  498. MachineState *ms = MACHINE(obj);
  499. MemorySizeConfiguration mem = {
  500. .has_size = true,
  501. .size = ms->ram_size,
  502. .has_max_size = !!ms->ram_slots,
  503. .max_size = ms->maxram_size,
  504. .has_slots = !!ms->ram_slots,
  505. .slots = ms->ram_slots,
  506. };
  507. MemorySizeConfiguration *p_mem = &mem;
  508. visit_type_MemorySizeConfiguration(v, name, &p_mem, &error_abort);
  509. }
  510. static void machine_set_mem(Object *obj, Visitor *v, const char *name,
  511. void *opaque, Error **errp)
  512. {
  513. ERRP_GUARD();
  514. MachineState *ms = MACHINE(obj);
  515. MachineClass *mc = MACHINE_GET_CLASS(obj);
  516. MemorySizeConfiguration *mem;
  517. if (!visit_type_MemorySizeConfiguration(v, name, &mem, errp)) {
  518. return;
  519. }
  520. if (!mem->has_size) {
  521. mem->has_size = true;
  522. mem->size = mc->default_ram_size;
  523. }
  524. mem->size = QEMU_ALIGN_UP(mem->size, 8192);
  525. if (mc->fixup_ram_size) {
  526. mem->size = mc->fixup_ram_size(mem->size);
  527. }
  528. if ((ram_addr_t)mem->size != mem->size) {
  529. error_setg(errp, "ram size %llu exceeds permitted maximum %llu",
  530. (unsigned long long)mem->size,
  531. (unsigned long long)RAM_ADDR_MAX);
  532. goto out_free;
  533. }
  534. if (mem->has_max_size) {
  535. if ((ram_addr_t)mem->max_size != mem->max_size) {
  536. error_setg(errp, "ram size %llu exceeds permitted maximum %llu",
  537. (unsigned long long)mem->max_size,
  538. (unsigned long long)RAM_ADDR_MAX);
  539. goto out_free;
  540. }
  541. if (mem->max_size < mem->size) {
  542. error_setg(errp, "invalid value of maxmem: "
  543. "maximum memory size (0x%" PRIx64 ") must be at least "
  544. "the initial memory size (0x%" PRIx64 ")",
  545. mem->max_size, mem->size);
  546. goto out_free;
  547. }
  548. if (mem->has_slots && mem->slots && mem->max_size == mem->size) {
  549. error_setg(errp, "invalid value of maxmem: "
  550. "memory slots were specified but maximum memory size "
  551. "(0x%" PRIx64 ") is equal to the initial memory size "
  552. "(0x%" PRIx64 ")", mem->max_size, mem->size);
  553. goto out_free;
  554. }
  555. ms->maxram_size = mem->max_size;
  556. } else {
  557. if (mem->has_slots) {
  558. error_setg(errp, "slots specified but no max-size");
  559. goto out_free;
  560. }
  561. ms->maxram_size = mem->size;
  562. }
  563. ms->ram_size = mem->size;
  564. ms->ram_slots = mem->has_slots ? mem->slots : 0;
  565. out_free:
  566. qapi_free_MemorySizeConfiguration(mem);
  567. }
  568. static char *machine_get_nvdimm_persistence(Object *obj, Error **errp)
  569. {
  570. MachineState *ms = MACHINE(obj);
  571. return g_strdup(ms->nvdimms_state->persistence_string);
  572. }
  573. static void machine_set_nvdimm_persistence(Object *obj, const char *value,
  574. Error **errp)
  575. {
  576. MachineState *ms = MACHINE(obj);
  577. NVDIMMState *nvdimms_state = ms->nvdimms_state;
  578. if (strcmp(value, "cpu") == 0) {
  579. nvdimms_state->persistence = 3;
  580. } else if (strcmp(value, "mem-ctrl") == 0) {
  581. nvdimms_state->persistence = 2;
  582. } else {
  583. error_setg(errp, "-machine nvdimm-persistence=%s: unsupported option",
  584. value);
  585. return;
  586. }
  587. g_free(nvdimms_state->persistence_string);
  588. nvdimms_state->persistence_string = g_strdup(value);
  589. }
  590. void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type)
  591. {
  592. QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type));
  593. }
  594. bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev)
  595. {
  596. Object *obj = OBJECT(dev);
  597. if (!object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE)) {
  598. return false;
  599. }
  600. return device_type_is_dynamic_sysbus(mc, object_get_typename(obj));
  601. }
  602. bool device_type_is_dynamic_sysbus(MachineClass *mc, const char *type)
  603. {
  604. bool allowed = false;
  605. strList *wl;
  606. ObjectClass *klass = object_class_by_name(type);
  607. for (wl = mc->allowed_dynamic_sysbus_devices;
  608. !allowed && wl;
  609. wl = wl->next) {
  610. allowed |= !!object_class_dynamic_cast(klass, wl->value);
  611. }
  612. return allowed;
  613. }
  614. static char *machine_get_audiodev(Object *obj, Error **errp)
  615. {
  616. MachineState *ms = MACHINE(obj);
  617. return g_strdup(ms->audiodev);
  618. }
  619. static void machine_set_audiodev(Object *obj, const char *value,
  620. Error **errp)
  621. {
  622. MachineState *ms = MACHINE(obj);
  623. if (!audio_state_by_name(value, errp)) {
  624. return;
  625. }
  626. g_free(ms->audiodev);
  627. ms->audiodev = g_strdup(value);
  628. }
  629. HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine)
  630. {
  631. int i;
  632. HotpluggableCPUList *head = NULL;
  633. MachineClass *mc = MACHINE_GET_CLASS(machine);
  634. /* force board to initialize possible_cpus if it hasn't been done yet */
  635. mc->possible_cpu_arch_ids(machine);
  636. for (i = 0; i < machine->possible_cpus->len; i++) {
  637. CPUState *cpu;
  638. HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1);
  639. cpu_item->type = g_strdup(machine->possible_cpus->cpus[i].type);
  640. cpu_item->vcpus_count = machine->possible_cpus->cpus[i].vcpus_count;
  641. cpu_item->props = g_memdup(&machine->possible_cpus->cpus[i].props,
  642. sizeof(*cpu_item->props));
  643. cpu = machine->possible_cpus->cpus[i].cpu;
  644. if (cpu) {
  645. cpu_item->qom_path = object_get_canonical_path(OBJECT(cpu));
  646. }
  647. QAPI_LIST_PREPEND(head, cpu_item);
  648. }
  649. return head;
  650. }
  651. /**
  652. * machine_set_cpu_numa_node:
  653. * @machine: machine object to modify
  654. * @props: specifies which cpu objects to assign to
  655. * numa node specified by @props.node_id
  656. * @errp: if an error occurs, a pointer to an area to store the error
  657. *
  658. * Associate NUMA node specified by @props.node_id with cpu slots that
  659. * match socket/core/thread-ids specified by @props. It's recommended to use
  660. * query-hotpluggable-cpus.props values to specify affected cpu slots,
  661. * which would lead to exact 1:1 mapping of cpu slots to NUMA node.
  662. *
  663. * However for CLI convenience it's possible to pass in subset of properties,
  664. * which would affect all cpu slots that match it.
  665. * Ex for pc machine:
  666. * -smp 4,cores=2,sockets=2 -numa node,nodeid=0 -numa node,nodeid=1 \
  667. * -numa cpu,node-id=0,socket_id=0 \
  668. * -numa cpu,node-id=1,socket_id=1
  669. * will assign all child cores of socket 0 to node 0 and
  670. * of socket 1 to node 1.
  671. *
  672. * On attempt of reassigning (already assigned) cpu slot to another NUMA node,
  673. * return error.
  674. * Empty subset is disallowed and function will return with error in this case.
  675. */
  676. void machine_set_cpu_numa_node(MachineState *machine,
  677. const CpuInstanceProperties *props, Error **errp)
  678. {
  679. MachineClass *mc = MACHINE_GET_CLASS(machine);
  680. NodeInfo *numa_info = machine->numa_state->nodes;
  681. bool match = false;
  682. int i;
  683. if (!mc->possible_cpu_arch_ids) {
  684. error_setg(errp, "mapping of CPUs to NUMA node is not supported");
  685. return;
  686. }
  687. /* disabling node mapping is not supported, forbid it */
  688. assert(props->has_node_id);
  689. /* force board to initialize possible_cpus if it hasn't been done yet */
  690. mc->possible_cpu_arch_ids(machine);
  691. for (i = 0; i < machine->possible_cpus->len; i++) {
  692. CPUArchId *slot = &machine->possible_cpus->cpus[i];
  693. /* reject unsupported by board properties */
  694. if (props->has_thread_id && !slot->props.has_thread_id) {
  695. error_setg(errp, "thread-id is not supported");
  696. return;
  697. }
  698. if (props->has_core_id && !slot->props.has_core_id) {
  699. error_setg(errp, "core-id is not supported");
  700. return;
  701. }
  702. if (props->has_module_id && !slot->props.has_module_id) {
  703. error_setg(errp, "module-id is not supported");
  704. return;
  705. }
  706. if (props->has_cluster_id && !slot->props.has_cluster_id) {
  707. error_setg(errp, "cluster-id is not supported");
  708. return;
  709. }
  710. if (props->has_socket_id && !slot->props.has_socket_id) {
  711. error_setg(errp, "socket-id is not supported");
  712. return;
  713. }
  714. if (props->has_die_id && !slot->props.has_die_id) {
  715. error_setg(errp, "die-id is not supported");
  716. return;
  717. }
  718. /* skip slots with explicit mismatch */
  719. if (props->has_thread_id && props->thread_id != slot->props.thread_id) {
  720. continue;
  721. }
  722. if (props->has_core_id && props->core_id != slot->props.core_id) {
  723. continue;
  724. }
  725. if (props->has_module_id &&
  726. props->module_id != slot->props.module_id) {
  727. continue;
  728. }
  729. if (props->has_cluster_id &&
  730. props->cluster_id != slot->props.cluster_id) {
  731. continue;
  732. }
  733. if (props->has_die_id && props->die_id != slot->props.die_id) {
  734. continue;
  735. }
  736. if (props->has_socket_id && props->socket_id != slot->props.socket_id) {
  737. continue;
  738. }
  739. /* reject assignment if slot is already assigned, for compatibility
  740. * of legacy cpu_index mapping with SPAPR core based mapping do not
  741. * error out if cpu thread and matched core have the same node-id */
  742. if (slot->props.has_node_id &&
  743. slot->props.node_id != props->node_id) {
  744. error_setg(errp, "CPU is already assigned to node-id: %" PRId64,
  745. slot->props.node_id);
  746. return;
  747. }
  748. /* assign slot to node as it's matched '-numa cpu' key */
  749. match = true;
  750. slot->props.node_id = props->node_id;
  751. slot->props.has_node_id = props->has_node_id;
  752. if (machine->numa_state->hmat_enabled) {
  753. if ((numa_info[props->node_id].initiator < MAX_NODES) &&
  754. (props->node_id != numa_info[props->node_id].initiator)) {
  755. error_setg(errp, "The initiator of CPU NUMA node %" PRId64
  756. " should be itself (got %" PRIu16 ")",
  757. props->node_id, numa_info[props->node_id].initiator);
  758. return;
  759. }
  760. numa_info[props->node_id].has_cpu = true;
  761. numa_info[props->node_id].initiator = props->node_id;
  762. }
  763. }
  764. if (!match) {
  765. error_setg(errp, "no match found");
  766. }
  767. }
  768. static void machine_get_smp(Object *obj, Visitor *v, const char *name,
  769. void *opaque, Error **errp)
  770. {
  771. MachineState *ms = MACHINE(obj);
  772. SMPConfiguration *config = &(SMPConfiguration){
  773. .has_cpus = true, .cpus = ms->smp.cpus,
  774. .has_drawers = true, .drawers = ms->smp.drawers,
  775. .has_books = true, .books = ms->smp.books,
  776. .has_sockets = true, .sockets = ms->smp.sockets,
  777. .has_dies = true, .dies = ms->smp.dies,
  778. .has_clusters = true, .clusters = ms->smp.clusters,
  779. .has_modules = true, .modules = ms->smp.modules,
  780. .has_cores = true, .cores = ms->smp.cores,
  781. .has_threads = true, .threads = ms->smp.threads,
  782. .has_maxcpus = true, .maxcpus = ms->smp.max_cpus,
  783. };
  784. if (!visit_type_SMPConfiguration(v, name, &config, &error_abort)) {
  785. return;
  786. }
  787. }
  788. static void machine_set_smp(Object *obj, Visitor *v, const char *name,
  789. void *opaque, Error **errp)
  790. {
  791. MachineState *ms = MACHINE(obj);
  792. g_autoptr(SMPConfiguration) config = NULL;
  793. if (!visit_type_SMPConfiguration(v, name, &config, errp)) {
  794. return;
  795. }
  796. machine_parse_smp_config(ms, config, errp);
  797. }
  798. static void machine_get_smp_cache(Object *obj, Visitor *v, const char *name,
  799. void *opaque, Error **errp)
  800. {
  801. MachineState *ms = MACHINE(obj);
  802. SmpCache *cache = &ms->smp_cache;
  803. SmpCachePropertiesList *head = NULL;
  804. SmpCachePropertiesList **tail = &head;
  805. for (int i = 0; i < CACHE_LEVEL_AND_TYPE__MAX; i++) {
  806. SmpCacheProperties *node = g_new(SmpCacheProperties, 1);
  807. node->cache = cache->props[i].cache;
  808. node->topology = cache->props[i].topology;
  809. QAPI_LIST_APPEND(tail, node);
  810. }
  811. visit_type_SmpCachePropertiesList(v, name, &head, errp);
  812. qapi_free_SmpCachePropertiesList(head);
  813. }
  814. static void machine_set_smp_cache(Object *obj, Visitor *v, const char *name,
  815. void *opaque, Error **errp)
  816. {
  817. MachineState *ms = MACHINE(obj);
  818. SmpCachePropertiesList *caches;
  819. if (!visit_type_SmpCachePropertiesList(v, name, &caches, errp)) {
  820. return;
  821. }
  822. machine_parse_smp_cache(ms, caches, errp);
  823. qapi_free_SmpCachePropertiesList(caches);
  824. }
  825. static void machine_get_boot(Object *obj, Visitor *v, const char *name,
  826. void *opaque, Error **errp)
  827. {
  828. MachineState *ms = MACHINE(obj);
  829. BootConfiguration *config = &ms->boot_config;
  830. visit_type_BootConfiguration(v, name, &config, &error_abort);
  831. }
  832. static void machine_free_boot_config(MachineState *ms)
  833. {
  834. g_free(ms->boot_config.order);
  835. g_free(ms->boot_config.once);
  836. g_free(ms->boot_config.splash);
  837. }
  838. static void machine_copy_boot_config(MachineState *ms, BootConfiguration *config)
  839. {
  840. MachineClass *machine_class = MACHINE_GET_CLASS(ms);
  841. machine_free_boot_config(ms);
  842. ms->boot_config = *config;
  843. if (!config->order) {
  844. ms->boot_config.order = g_strdup(machine_class->default_boot_order);
  845. }
  846. }
  847. static void machine_set_boot(Object *obj, Visitor *v, const char *name,
  848. void *opaque, Error **errp)
  849. {
  850. ERRP_GUARD();
  851. MachineState *ms = MACHINE(obj);
  852. BootConfiguration *config = NULL;
  853. if (!visit_type_BootConfiguration(v, name, &config, errp)) {
  854. return;
  855. }
  856. if (config->order) {
  857. validate_bootdevices(config->order, errp);
  858. if (*errp) {
  859. goto out_free;
  860. }
  861. }
  862. if (config->once) {
  863. validate_bootdevices(config->once, errp);
  864. if (*errp) {
  865. goto out_free;
  866. }
  867. }
  868. machine_copy_boot_config(ms, config);
  869. /* Strings live in ms->boot_config. */
  870. free(config);
  871. return;
  872. out_free:
  873. qapi_free_BootConfiguration(config);
  874. }
  875. void machine_add_audiodev_property(MachineClass *mc)
  876. {
  877. ObjectClass *oc = OBJECT_CLASS(mc);
  878. object_class_property_add_str(oc, "audiodev",
  879. machine_get_audiodev,
  880. machine_set_audiodev);
  881. object_class_property_set_description(oc, "audiodev",
  882. "Audiodev to use for default machine devices");
  883. }
  884. static bool create_default_memdev(MachineState *ms, const char *path,
  885. Error **errp)
  886. {
  887. Object *obj;
  888. MachineClass *mc = MACHINE_GET_CLASS(ms);
  889. bool r = false;
  890. obj = object_new(path ? TYPE_MEMORY_BACKEND_FILE : TYPE_MEMORY_BACKEND_RAM);
  891. if (path) {
  892. if (!object_property_set_str(obj, "mem-path", path, errp)) {
  893. goto out;
  894. }
  895. }
  896. if (!object_property_set_int(obj, "size", ms->ram_size, errp)) {
  897. goto out;
  898. }
  899. object_property_add_child(object_get_objects_root(), mc->default_ram_id,
  900. obj);
  901. /* Ensure backend's memory region name is equal to mc->default_ram_id */
  902. if (!object_property_set_bool(obj, "x-use-canonical-path-for-ramblock-id",
  903. false, errp)) {
  904. goto out;
  905. }
  906. if (!user_creatable_complete(USER_CREATABLE(obj), errp)) {
  907. goto out;
  908. }
  909. r = object_property_set_link(OBJECT(ms), "memory-backend", obj, errp);
  910. out:
  911. object_unref(obj);
  912. return r;
  913. }
  914. static void machine_class_init(ObjectClass *oc, void *data)
  915. {
  916. MachineClass *mc = MACHINE_CLASS(oc);
  917. /* Default 128 MB as guest ram size */
  918. mc->default_ram_size = 128 * MiB;
  919. mc->rom_file_has_mr = true;
  920. /*
  921. * SMBIOS 3.1.0 7.18.5 Memory Device — Extended Size
  922. * use max possible value that could be encoded into
  923. * 'Extended Size' field (2047Tb).
  924. */
  925. mc->smbios_memory_device_size = 2047 * TiB;
  926. /* numa node memory size aligned on 8MB by default.
  927. * On Linux, each node's border has to be 8MB aligned
  928. */
  929. mc->numa_mem_align_shift = 23;
  930. mc->create_default_memdev = create_default_memdev;
  931. object_class_property_add_str(oc, "kernel",
  932. machine_get_kernel, machine_set_kernel);
  933. object_class_property_set_description(oc, "kernel",
  934. "Linux kernel image file");
  935. object_class_property_add_str(oc, "shim",
  936. machine_get_shim, machine_set_shim);
  937. object_class_property_set_description(oc, "shim",
  938. "shim.efi file");
  939. object_class_property_add_str(oc, "initrd",
  940. machine_get_initrd, machine_set_initrd);
  941. object_class_property_set_description(oc, "initrd",
  942. "Linux initial ramdisk file");
  943. object_class_property_add_str(oc, "append",
  944. machine_get_append, machine_set_append);
  945. object_class_property_set_description(oc, "append",
  946. "Linux kernel command line");
  947. object_class_property_add_str(oc, "dtb",
  948. machine_get_dtb, machine_set_dtb);
  949. object_class_property_set_description(oc, "dtb",
  950. "Linux kernel device tree file");
  951. object_class_property_add_str(oc, "dumpdtb",
  952. machine_get_dumpdtb, machine_set_dumpdtb);
  953. object_class_property_set_description(oc, "dumpdtb",
  954. "Dump current dtb to a file and quit");
  955. object_class_property_add(oc, "boot", "BootConfiguration",
  956. machine_get_boot, machine_set_boot,
  957. NULL, NULL);
  958. object_class_property_set_description(oc, "boot",
  959. "Boot configuration");
  960. object_class_property_add(oc, "smp", "SMPConfiguration",
  961. machine_get_smp, machine_set_smp,
  962. NULL, NULL);
  963. object_class_property_set_description(oc, "smp",
  964. "CPU topology");
  965. object_class_property_add(oc, "smp-cache", "SmpCachePropertiesWrapper",
  966. machine_get_smp_cache, machine_set_smp_cache, NULL, NULL);
  967. object_class_property_set_description(oc, "smp-cache",
  968. "Cache properties list for SMP machine");
  969. object_class_property_add(oc, "phandle-start", "int",
  970. machine_get_phandle_start, machine_set_phandle_start,
  971. NULL, NULL);
  972. object_class_property_set_description(oc, "phandle-start",
  973. "The first phandle ID we may generate dynamically");
  974. object_class_property_add_str(oc, "dt-compatible",
  975. machine_get_dt_compatible, machine_set_dt_compatible);
  976. object_class_property_set_description(oc, "dt-compatible",
  977. "Overrides the \"compatible\" property of the dt root node");
  978. object_class_property_add_bool(oc, "dump-guest-core",
  979. machine_get_dump_guest_core, machine_set_dump_guest_core);
  980. object_class_property_set_description(oc, "dump-guest-core",
  981. "Include guest memory in a core dump");
  982. object_class_property_add_bool(oc, "mem-merge",
  983. machine_get_mem_merge, machine_set_mem_merge);
  984. object_class_property_set_description(oc, "mem-merge",
  985. "Enable/disable memory merge support");
  986. #ifdef CONFIG_POSIX
  987. object_class_property_add_bool(oc, "aux-ram-share",
  988. machine_get_aux_ram_share,
  989. machine_set_aux_ram_share);
  990. #endif
  991. object_class_property_add_bool(oc, "usb",
  992. machine_get_usb, machine_set_usb);
  993. object_class_property_set_description(oc, "usb",
  994. "Set on/off to enable/disable usb");
  995. object_class_property_add_bool(oc, "graphics",
  996. machine_get_graphics, machine_set_graphics);
  997. object_class_property_set_description(oc, "graphics",
  998. "Set on/off to enable/disable graphics emulation");
  999. object_class_property_add_str(oc, "firmware",
  1000. machine_get_firmware, machine_set_firmware);
  1001. object_class_property_set_description(oc, "firmware",
  1002. "Firmware image");
  1003. object_class_property_add_bool(oc, "suppress-vmdesc",
  1004. machine_get_suppress_vmdesc, machine_set_suppress_vmdesc);
  1005. object_class_property_set_description(oc, "suppress-vmdesc",
  1006. "Set on to disable self-describing migration");
  1007. object_class_property_add_link(oc, "confidential-guest-support",
  1008. TYPE_CONFIDENTIAL_GUEST_SUPPORT,
  1009. offsetof(MachineState, cgs),
  1010. machine_check_confidential_guest_support,
  1011. OBJ_PROP_LINK_STRONG);
  1012. object_class_property_set_description(oc, "confidential-guest-support",
  1013. "Set confidential guest scheme to support");
  1014. /* For compatibility */
  1015. object_class_property_add_str(oc, "memory-encryption",
  1016. machine_get_memory_encryption, machine_set_memory_encryption);
  1017. object_class_property_set_description(oc, "memory-encryption",
  1018. "Set memory encryption object to use");
  1019. object_class_property_add_link(oc, "memory-backend", TYPE_MEMORY_BACKEND,
  1020. offsetof(MachineState, memdev), object_property_allow_set_link,
  1021. OBJ_PROP_LINK_STRONG);
  1022. object_class_property_set_description(oc, "memory-backend",
  1023. "Set RAM backend"
  1024. "Valid value is ID of hostmem based backend");
  1025. object_class_property_add(oc, "memory", "MemorySizeConfiguration",
  1026. machine_get_mem, machine_set_mem,
  1027. NULL, NULL);
  1028. object_class_property_set_description(oc, "memory",
  1029. "Memory size configuration");
  1030. }
  1031. static void machine_class_base_init(ObjectClass *oc, void *data)
  1032. {
  1033. MachineClass *mc = MACHINE_CLASS(oc);
  1034. mc->max_cpus = mc->max_cpus ?: 1;
  1035. mc->min_cpus = mc->min_cpus ?: 1;
  1036. mc->default_cpus = mc->default_cpus ?: 1;
  1037. if (!object_class_is_abstract(oc)) {
  1038. const char *cname = object_class_get_name(oc);
  1039. assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
  1040. mc->name = g_strndup(cname,
  1041. strlen(cname) - strlen(TYPE_MACHINE_SUFFIX));
  1042. mc->compat_props = g_ptr_array_new();
  1043. }
  1044. }
  1045. static void machine_initfn(Object *obj)
  1046. {
  1047. MachineState *ms = MACHINE(obj);
  1048. MachineClass *mc = MACHINE_GET_CLASS(obj);
  1049. ms->dump_guest_core = true;
  1050. ms->mem_merge = (QEMU_MADV_MERGEABLE != QEMU_MADV_INVALID);
  1051. ms->enable_graphics = true;
  1052. ms->kernel_cmdline = g_strdup("");
  1053. ms->ram_size = mc->default_ram_size;
  1054. ms->maxram_size = mc->default_ram_size;
  1055. if (mc->nvdimm_supported) {
  1056. ms->nvdimms_state = g_new0(NVDIMMState, 1);
  1057. object_property_add_bool(obj, "nvdimm",
  1058. machine_get_nvdimm, machine_set_nvdimm);
  1059. object_property_set_description(obj, "nvdimm",
  1060. "Set on/off to enable/disable "
  1061. "NVDIMM instantiation");
  1062. object_property_add_str(obj, "nvdimm-persistence",
  1063. machine_get_nvdimm_persistence,
  1064. machine_set_nvdimm_persistence);
  1065. object_property_set_description(obj, "nvdimm-persistence",
  1066. "Set NVDIMM persistence"
  1067. "Valid values are cpu, mem-ctrl");
  1068. }
  1069. if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) {
  1070. ms->numa_state = g_new0(NumaState, 1);
  1071. object_property_add_bool(obj, "hmat",
  1072. machine_get_hmat, machine_set_hmat);
  1073. object_property_set_description(obj, "hmat",
  1074. "Set on/off to enable/disable "
  1075. "ACPI Heterogeneous Memory Attribute "
  1076. "Table (HMAT)");
  1077. }
  1078. /* default to mc->default_cpus */
  1079. ms->smp.cpus = mc->default_cpus;
  1080. ms->smp.max_cpus = mc->default_cpus;
  1081. ms->smp.drawers = 1;
  1082. ms->smp.books = 1;
  1083. ms->smp.sockets = 1;
  1084. ms->smp.dies = 1;
  1085. ms->smp.clusters = 1;
  1086. ms->smp.modules = 1;
  1087. ms->smp.cores = 1;
  1088. ms->smp.threads = 1;
  1089. for (int i = 0; i < CACHE_LEVEL_AND_TYPE__MAX; i++) {
  1090. ms->smp_cache.props[i].cache = (CacheLevelAndType)i;
  1091. ms->smp_cache.props[i].topology = CPU_TOPOLOGY_LEVEL_DEFAULT;
  1092. }
  1093. machine_copy_boot_config(ms, &(BootConfiguration){ 0 });
  1094. }
  1095. static void machine_finalize(Object *obj)
  1096. {
  1097. MachineState *ms = MACHINE(obj);
  1098. machine_free_boot_config(ms);
  1099. g_free(ms->kernel_filename);
  1100. g_free(ms->initrd_filename);
  1101. g_free(ms->kernel_cmdline);
  1102. g_free(ms->dtb);
  1103. g_free(ms->dumpdtb);
  1104. g_free(ms->dt_compatible);
  1105. g_free(ms->firmware);
  1106. g_free(ms->device_memory);
  1107. g_free(ms->nvdimms_state);
  1108. g_free(ms->numa_state);
  1109. g_free(ms->audiodev);
  1110. }
  1111. bool machine_usb(MachineState *machine)
  1112. {
  1113. return machine->usb;
  1114. }
  1115. int machine_phandle_start(MachineState *machine)
  1116. {
  1117. return machine->phandle_start;
  1118. }
  1119. bool machine_dump_guest_core(MachineState *machine)
  1120. {
  1121. return machine->dump_guest_core;
  1122. }
  1123. bool machine_mem_merge(MachineState *machine)
  1124. {
  1125. return machine->mem_merge;
  1126. }
  1127. bool machine_require_guest_memfd(MachineState *machine)
  1128. {
  1129. return machine->cgs && machine->cgs->require_guest_memfd;
  1130. }
  1131. static char *cpu_slot_to_string(const CPUArchId *cpu)
  1132. {
  1133. GString *s = g_string_new(NULL);
  1134. if (cpu->props.has_socket_id) {
  1135. g_string_append_printf(s, "socket-id: %"PRId64, cpu->props.socket_id);
  1136. }
  1137. if (cpu->props.has_die_id) {
  1138. if (s->len) {
  1139. g_string_append_printf(s, ", ");
  1140. }
  1141. g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id);
  1142. }
  1143. if (cpu->props.has_cluster_id) {
  1144. if (s->len) {
  1145. g_string_append_printf(s, ", ");
  1146. }
  1147. g_string_append_printf(s, "cluster-id: %"PRId64, cpu->props.cluster_id);
  1148. }
  1149. if (cpu->props.has_module_id) {
  1150. if (s->len) {
  1151. g_string_append_printf(s, ", ");
  1152. }
  1153. g_string_append_printf(s, "module-id: %"PRId64, cpu->props.module_id);
  1154. }
  1155. if (cpu->props.has_core_id) {
  1156. if (s->len) {
  1157. g_string_append_printf(s, ", ");
  1158. }
  1159. g_string_append_printf(s, "core-id: %"PRId64, cpu->props.core_id);
  1160. }
  1161. if (cpu->props.has_thread_id) {
  1162. if (s->len) {
  1163. g_string_append_printf(s, ", ");
  1164. }
  1165. g_string_append_printf(s, "thread-id: %"PRId64, cpu->props.thread_id);
  1166. }
  1167. return g_string_free(s, false);
  1168. }
  1169. static void numa_validate_initiator(NumaState *numa_state)
  1170. {
  1171. int i;
  1172. NodeInfo *numa_info = numa_state->nodes;
  1173. for (i = 0; i < numa_state->num_nodes; i++) {
  1174. if (numa_info[i].initiator == MAX_NODES) {
  1175. continue;
  1176. }
  1177. if (!numa_info[numa_info[i].initiator].present) {
  1178. error_report("NUMA node %" PRIu16 " is missing, use "
  1179. "'-numa node' option to declare it first",
  1180. numa_info[i].initiator);
  1181. exit(1);
  1182. }
  1183. if (!numa_info[numa_info[i].initiator].has_cpu) {
  1184. error_report("The initiator of NUMA node %d is invalid", i);
  1185. exit(1);
  1186. }
  1187. }
  1188. }
  1189. static void machine_numa_finish_cpu_init(MachineState *machine)
  1190. {
  1191. int i;
  1192. bool default_mapping;
  1193. GString *s = g_string_new(NULL);
  1194. MachineClass *mc = MACHINE_GET_CLASS(machine);
  1195. const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(machine);
  1196. assert(machine->numa_state->num_nodes);
  1197. for (i = 0; i < possible_cpus->len; i++) {
  1198. if (possible_cpus->cpus[i].props.has_node_id) {
  1199. break;
  1200. }
  1201. }
  1202. default_mapping = (i == possible_cpus->len);
  1203. for (i = 0; i < possible_cpus->len; i++) {
  1204. const CPUArchId *cpu_slot = &possible_cpus->cpus[i];
  1205. if (!cpu_slot->props.has_node_id) {
  1206. /* fetch default mapping from board and enable it */
  1207. CpuInstanceProperties props = cpu_slot->props;
  1208. props.node_id = mc->get_default_cpu_node_id(machine, i);
  1209. if (!default_mapping) {
  1210. /* record slots with not set mapping,
  1211. * TODO: make it hard error in future */
  1212. char *cpu_str = cpu_slot_to_string(cpu_slot);
  1213. g_string_append_printf(s, "%sCPU %d [%s]",
  1214. s->len ? ", " : "", i, cpu_str);
  1215. g_free(cpu_str);
  1216. /* non mapped cpus used to fallback to node 0 */
  1217. props.node_id = 0;
  1218. }
  1219. props.has_node_id = true;
  1220. machine_set_cpu_numa_node(machine, &props, &error_fatal);
  1221. }
  1222. }
  1223. if (machine->numa_state->hmat_enabled) {
  1224. numa_validate_initiator(machine->numa_state);
  1225. }
  1226. if (s->len && !qtest_enabled()) {
  1227. warn_report("CPU(s) not present in any NUMA nodes: %s",
  1228. s->str);
  1229. warn_report("All CPU(s) up to maxcpus should be described "
  1230. "in NUMA config, ability to start up with partial NUMA "
  1231. "mappings is obsoleted and will be removed in future");
  1232. }
  1233. g_string_free(s, true);
  1234. }
  1235. static void validate_cpu_cluster_to_numa_boundary(MachineState *ms)
  1236. {
  1237. MachineClass *mc = MACHINE_GET_CLASS(ms);
  1238. NumaState *state = ms->numa_state;
  1239. const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms);
  1240. const CPUArchId *cpus = possible_cpus->cpus;
  1241. int i, j;
  1242. if (qtest_enabled() || state->num_nodes <= 1 || possible_cpus->len <= 1) {
  1243. return;
  1244. }
  1245. /*
  1246. * The Linux scheduling domain can't be parsed when the multiple CPUs
  1247. * in one cluster have been associated with different NUMA nodes. However,
  1248. * it's fine to associate one NUMA node with CPUs in different clusters.
  1249. */
  1250. for (i = 0; i < possible_cpus->len; i++) {
  1251. for (j = i + 1; j < possible_cpus->len; j++) {
  1252. if (cpus[i].props.has_socket_id &&
  1253. cpus[i].props.has_cluster_id &&
  1254. cpus[i].props.has_node_id &&
  1255. cpus[j].props.has_socket_id &&
  1256. cpus[j].props.has_cluster_id &&
  1257. cpus[j].props.has_node_id &&
  1258. cpus[i].props.socket_id == cpus[j].props.socket_id &&
  1259. cpus[i].props.cluster_id == cpus[j].props.cluster_id &&
  1260. cpus[i].props.node_id != cpus[j].props.node_id) {
  1261. warn_report("CPU-%d and CPU-%d in socket-%" PRId64 "-cluster-%" PRId64
  1262. " have been associated with node-%" PRId64 " and node-%" PRId64
  1263. " respectively. It can cause OSes like Linux to"
  1264. " misbehave", i, j, cpus[i].props.socket_id,
  1265. cpus[i].props.cluster_id, cpus[i].props.node_id,
  1266. cpus[j].props.node_id);
  1267. }
  1268. }
  1269. }
  1270. }
  1271. MemoryRegion *machine_consume_memdev(MachineState *machine,
  1272. HostMemoryBackend *backend)
  1273. {
  1274. MemoryRegion *ret = host_memory_backend_get_memory(backend);
  1275. if (host_memory_backend_is_mapped(backend)) {
  1276. error_report("memory backend %s can't be used multiple times.",
  1277. object_get_canonical_path_component(OBJECT(backend)));
  1278. exit(EXIT_FAILURE);
  1279. }
  1280. host_memory_backend_set_mapped(backend, true);
  1281. vmstate_register_ram_global(ret);
  1282. return ret;
  1283. }
  1284. const char *machine_class_default_cpu_type(MachineClass *mc)
  1285. {
  1286. if (mc->valid_cpu_types && !mc->valid_cpu_types[1]) {
  1287. /* Only a single CPU type allowed: use it as default. */
  1288. return mc->valid_cpu_types[0];
  1289. }
  1290. return mc->default_cpu_type;
  1291. }
  1292. static bool is_cpu_type_supported(const MachineState *machine, Error **errp)
  1293. {
  1294. MachineClass *mc = MACHINE_GET_CLASS(machine);
  1295. ObjectClass *oc = object_class_by_name(machine->cpu_type);
  1296. CPUClass *cc;
  1297. int i;
  1298. /*
  1299. * Check if the user specified CPU type is supported when the valid
  1300. * CPU types have been determined. Note that the user specified CPU
  1301. * type is provided through '-cpu' option.
  1302. */
  1303. if (mc->valid_cpu_types) {
  1304. assert(mc->valid_cpu_types[0] != NULL);
  1305. for (i = 0; mc->valid_cpu_types[i]; i++) {
  1306. if (object_class_dynamic_cast(oc, mc->valid_cpu_types[i])) {
  1307. break;
  1308. }
  1309. }
  1310. /* The user specified CPU type isn't valid */
  1311. if (!mc->valid_cpu_types[i]) {
  1312. g_autofree char *requested = cpu_model_from_type(machine->cpu_type);
  1313. error_setg(errp, "Invalid CPU model: %s", requested);
  1314. if (!mc->valid_cpu_types[1]) {
  1315. g_autofree char *model = cpu_model_from_type(
  1316. mc->valid_cpu_types[0]);
  1317. error_append_hint(errp, "The only valid type is: %s\n", model);
  1318. } else {
  1319. error_append_hint(errp, "The valid models are: ");
  1320. for (i = 0; mc->valid_cpu_types[i]; i++) {
  1321. g_autofree char *model = cpu_model_from_type(
  1322. mc->valid_cpu_types[i]);
  1323. error_append_hint(errp, "%s%s",
  1324. model,
  1325. mc->valid_cpu_types[i + 1] ? ", " : "");
  1326. }
  1327. error_append_hint(errp, "\n");
  1328. }
  1329. return false;
  1330. }
  1331. }
  1332. /* Check if CPU type is deprecated and warn if so */
  1333. cc = CPU_CLASS(oc);
  1334. assert(cc != NULL);
  1335. if (cc->deprecation_note) {
  1336. warn_report("CPU model %s is deprecated -- %s",
  1337. machine->cpu_type, cc->deprecation_note);
  1338. }
  1339. return true;
  1340. }
  1341. void machine_run_board_init(MachineState *machine, const char *mem_path, Error **errp)
  1342. {
  1343. ERRP_GUARD();
  1344. MachineClass *machine_class = MACHINE_GET_CLASS(machine);
  1345. /* This checkpoint is required by replay to separate prior clock
  1346. reading from the other reads, because timer polling functions query
  1347. clock values from the log. */
  1348. replay_checkpoint(CHECKPOINT_INIT);
  1349. if (!xen_enabled()) {
  1350. /* On 32-bit hosts, QEMU is limited by virtual address space */
  1351. if (machine->ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {
  1352. error_setg(errp, "at most 2047 MB RAM can be simulated");
  1353. return;
  1354. }
  1355. }
  1356. if (machine->memdev) {
  1357. ram_addr_t backend_size = object_property_get_uint(OBJECT(machine->memdev),
  1358. "size", &error_abort);
  1359. if (backend_size != machine->ram_size) {
  1360. error_setg(errp, "Machine memory size does not match the size of the memory backend");
  1361. return;
  1362. }
  1363. } else if (machine_class->default_ram_id && machine->ram_size &&
  1364. numa_uses_legacy_mem()) {
  1365. if (object_property_find(object_get_objects_root(),
  1366. machine_class->default_ram_id)) {
  1367. error_setg(errp, "object's id '%s' is reserved for the default"
  1368. " RAM backend, it can't be used for any other purposes",
  1369. machine_class->default_ram_id);
  1370. error_append_hint(errp,
  1371. "Change the object's 'id' to something else or disable"
  1372. " automatic creation of the default RAM backend by setting"
  1373. " 'memory-backend=%s' with '-machine'.\n",
  1374. machine_class->default_ram_id);
  1375. return;
  1376. }
  1377. if (!machine_class->create_default_memdev(current_machine, mem_path,
  1378. errp)) {
  1379. return;
  1380. }
  1381. }
  1382. if (machine->numa_state) {
  1383. numa_complete_configuration(machine);
  1384. if (machine->numa_state->num_nodes) {
  1385. machine_numa_finish_cpu_init(machine);
  1386. if (machine_class->cpu_cluster_has_numa_boundary) {
  1387. validate_cpu_cluster_to_numa_boundary(machine);
  1388. }
  1389. }
  1390. }
  1391. if (!machine->ram && machine->memdev) {
  1392. machine->ram = machine_consume_memdev(machine, machine->memdev);
  1393. }
  1394. /* Check if the CPU type is supported */
  1395. if (machine->cpu_type && !is_cpu_type_supported(machine, errp)) {
  1396. return;
  1397. }
  1398. if (machine->cgs) {
  1399. /*
  1400. * With confidential guests, the host can't see the real
  1401. * contents of RAM, so there's no point in it trying to merge
  1402. * areas.
  1403. */
  1404. machine_set_mem_merge(OBJECT(machine), false, &error_abort);
  1405. /*
  1406. * Virtio devices can't count on directly accessing guest
  1407. * memory, so they need iommu_platform=on to use normal DMA
  1408. * mechanisms. That requires also disabling legacy virtio
  1409. * support for those virtio pci devices which allow it.
  1410. */
  1411. object_register_sugar_prop(TYPE_VIRTIO_PCI, "disable-legacy",
  1412. "on", true);
  1413. object_register_sugar_prop(TYPE_VIRTIO_DEVICE, "iommu_platform",
  1414. "on", false);
  1415. }
  1416. accel_init_interfaces(ACCEL_GET_CLASS(machine->accelerator));
  1417. machine_class->init(machine);
  1418. phase_advance(PHASE_MACHINE_INITIALIZED);
  1419. }
  1420. static NotifierList machine_init_done_notifiers =
  1421. NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers);
  1422. void qemu_add_machine_init_done_notifier(Notifier *notify)
  1423. {
  1424. notifier_list_add(&machine_init_done_notifiers, notify);
  1425. if (phase_check(PHASE_MACHINE_READY)) {
  1426. notify->notify(notify, NULL);
  1427. }
  1428. }
  1429. void qemu_remove_machine_init_done_notifier(Notifier *notify)
  1430. {
  1431. notifier_remove(notify);
  1432. }
  1433. void qdev_machine_creation_done(void)
  1434. {
  1435. cpu_synchronize_all_post_init();
  1436. if (current_machine->boot_config.once) {
  1437. qemu_boot_set(current_machine->boot_config.once, &error_fatal);
  1438. qemu_register_reset(restore_boot_order, g_strdup(current_machine->boot_config.order));
  1439. }
  1440. /*
  1441. * ok, initial machine setup is done, starting from now we can
  1442. * only create hotpluggable devices
  1443. */
  1444. phase_advance(PHASE_MACHINE_READY);
  1445. qdev_assert_realized_properly();
  1446. /* TODO: once all bus devices are qdevified, this should be done
  1447. * when bus is created by qdev.c */
  1448. /*
  1449. * This is where we arrange for the sysbus to be reset when the
  1450. * whole simulation is reset. In turn, resetting the sysbus will cause
  1451. * all devices hanging off it (and all their child buses, recursively)
  1452. * to be reset. Note that this will *not* reset any Device objects
  1453. * which are not attached to some part of the qbus tree!
  1454. */
  1455. qemu_register_resettable(OBJECT(sysbus_get_default()));
  1456. notifier_list_notify(&machine_init_done_notifiers, NULL);
  1457. if (rom_check_and_register_reset() != 0) {
  1458. exit(1);
  1459. }
  1460. replay_start();
  1461. /* This checkpoint is required by replay to separate prior clock
  1462. reading from the other reads, because timer polling functions query
  1463. clock values from the log. */
  1464. replay_checkpoint(CHECKPOINT_RESET);
  1465. qemu_system_reset(SHUTDOWN_CAUSE_NONE);
  1466. register_global_state();
  1467. }
  1468. static const TypeInfo machine_info = {
  1469. .name = TYPE_MACHINE,
  1470. .parent = TYPE_OBJECT,
  1471. .abstract = true,
  1472. .class_size = sizeof(MachineClass),
  1473. .class_init = machine_class_init,
  1474. .class_base_init = machine_class_base_init,
  1475. .instance_size = sizeof(MachineState),
  1476. .instance_init = machine_initfn,
  1477. .instance_finalize = machine_finalize,
  1478. };
  1479. static void machine_register_types(void)
  1480. {
  1481. type_register_static(&machine_info);
  1482. }
  1483. type_init(machine_register_types)