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 13 #include "qemu/osdep.h" 14 #include "qemu/option.h" 15 #include "qapi/qmp/qerror.h" 16 #include "sysemu/replay.h" 17 #include "qemu/units.h" 18 #include "hw/boards.h" 19 #include "hw/loader.h" 20 #include "qapi/error.h" 21 #include "qapi/qapi-visit-common.h" 22 #include "qapi/visitor.h" 23 #include "hw/sysbus.h" 24 #include "sysemu/cpus.h" 25 #include "sysemu/sysemu.h" 26 #include "sysemu/reset.h" 27 #include "sysemu/runstate.h" 28 #include "sysemu/numa.h" 29 #include "qemu/error-report.h" 30 #include "sysemu/qtest.h" 31 #include "hw/pci/pci.h" 32 #include "hw/mem/nvdimm.h" 33 #include "migration/global_state.h" 34 #include "migration/vmstate.h" 35 #include "exec/confidential-guest-support.h" 36 #include "hw/virtio/virtio.h" 37 #include "hw/virtio/virtio-pci.h" 38 39 GlobalProperty hw_compat_5_2[] = { 40 { "ICH9-LPC", "smm-compat", "on"}, 41 { "PIIX4_PM", "smm-compat", "on"}, 42 { "virtio-blk-device", "report-discard-granularity", "off" }, 43 { "virtio-net-pci", "vectors", "3"}, 44 }; 45 const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2); 46 47 GlobalProperty hw_compat_5_1[] = { 48 { "vhost-scsi", "num_queues", "1"}, 49 { "vhost-user-blk", "num-queues", "1"}, 50 { "vhost-user-scsi", "num_queues", "1"}, 51 { "virtio-blk-device", "num-queues", "1"}, 52 { "virtio-scsi-device", "num_queues", "1"}, 53 { "nvme", "use-intel-id", "on"}, 54 { "pvpanic", "events", "1"}, /* PVPANIC_PANICKED */ 55 { "pl011", "migrate-clk", "off" }, 56 { "virtio-pci", "x-ats-page-aligned", "off"}, 57 }; 58 const size_t hw_compat_5_1_len = G_N_ELEMENTS(hw_compat_5_1); 59 60 GlobalProperty hw_compat_5_0[] = { 61 { "pci-host-bridge", "x-config-reg-migration-enabled", "off" }, 62 { "virtio-balloon-device", "page-poison", "false" }, 63 { "vmport", "x-read-set-eax", "off" }, 64 { "vmport", "x-signal-unsupported-cmd", "off" }, 65 { "vmport", "x-report-vmx-type", "off" }, 66 { "vmport", "x-cmds-v2", "off" }, 67 { "virtio-device", "x-disable-legacy-check", "true" }, 68 }; 69 const size_t hw_compat_5_0_len = G_N_ELEMENTS(hw_compat_5_0); 70 71 GlobalProperty hw_compat_4_2[] = { 72 { "virtio-blk-device", "queue-size", "128"}, 73 { "virtio-scsi-device", "virtqueue_size", "128"}, 74 { "virtio-blk-device", "x-enable-wce-if-config-wce", "off" }, 75 { "virtio-blk-device", "seg-max-adjust", "off"}, 76 { "virtio-scsi-device", "seg_max_adjust", "off"}, 77 { "vhost-blk-device", "seg_max_adjust", "off"}, 78 { "usb-host", "suppress-remote-wake", "off" }, 79 { "usb-redir", "suppress-remote-wake", "off" }, 80 { "qxl", "revision", "4" }, 81 { "qxl-vga", "revision", "4" }, 82 { "fw_cfg", "acpi-mr-restore", "false" }, 83 { "virtio-device", "use-disabled-flag", "false" }, 84 }; 85 const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2); 86 87 GlobalProperty hw_compat_4_1[] = { 88 { "virtio-pci", "x-pcie-flr-init", "off" }, 89 }; 90 const size_t hw_compat_4_1_len = G_N_ELEMENTS(hw_compat_4_1); 91 92 GlobalProperty hw_compat_4_0[] = { 93 { "VGA", "edid", "false" }, 94 { "secondary-vga", "edid", "false" }, 95 { "bochs-display", "edid", "false" }, 96 { "virtio-vga", "edid", "false" }, 97 { "virtio-gpu-device", "edid", "false" }, 98 { "virtio-device", "use-started", "false" }, 99 { "virtio-balloon-device", "qemu-4-0-config-size", "true" }, 100 { "pl031", "migrate-tick-offset", "false" }, 101 }; 102 const size_t hw_compat_4_0_len = G_N_ELEMENTS(hw_compat_4_0); 103 104 GlobalProperty hw_compat_3_1[] = { 105 { "pcie-root-port", "x-speed", "2_5" }, 106 { "pcie-root-port", "x-width", "1" }, 107 { "memory-backend-file", "x-use-canonical-path-for-ramblock-id", "true" }, 108 { "memory-backend-memfd", "x-use-canonical-path-for-ramblock-id", "true" }, 109 { "tpm-crb", "ppi", "false" }, 110 { "tpm-tis", "ppi", "false" }, 111 { "usb-kbd", "serial", "42" }, 112 { "usb-mouse", "serial", "42" }, 113 { "usb-tablet", "serial", "42" }, 114 { "virtio-blk-device", "discard", "false" }, 115 { "virtio-blk-device", "write-zeroes", "false" }, 116 { "virtio-balloon-device", "qemu-4-0-config-size", "false" }, 117 { "pcie-root-port-base", "disable-acs", "true" }, /* Added in 4.1 */ 118 }; 119 const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1); 120 121 GlobalProperty hw_compat_3_0[] = {}; 122 const size_t hw_compat_3_0_len = G_N_ELEMENTS(hw_compat_3_0); 123 124 GlobalProperty hw_compat_2_12[] = { 125 { "migration", "decompress-error-check", "off" }, 126 { "hda-audio", "use-timer", "false" }, 127 { "cirrus-vga", "global-vmstate", "true" }, 128 { "VGA", "global-vmstate", "true" }, 129 { "vmware-svga", "global-vmstate", "true" }, 130 { "qxl-vga", "global-vmstate", "true" }, 131 }; 132 const size_t hw_compat_2_12_len = G_N_ELEMENTS(hw_compat_2_12); 133 134 GlobalProperty hw_compat_2_11[] = { 135 { "hpet", "hpet-offset-saved", "false" }, 136 { "virtio-blk-pci", "vectors", "2" }, 137 { "vhost-user-blk-pci", "vectors", "2" }, 138 { "e1000", "migrate_tso_props", "off" }, 139 }; 140 const size_t hw_compat_2_11_len = G_N_ELEMENTS(hw_compat_2_11); 141 142 GlobalProperty hw_compat_2_10[] = { 143 { "virtio-mouse-device", "wheel-axis", "false" }, 144 { "virtio-tablet-device", "wheel-axis", "false" }, 145 }; 146 const size_t hw_compat_2_10_len = G_N_ELEMENTS(hw_compat_2_10); 147 148 GlobalProperty hw_compat_2_9[] = { 149 { "pci-bridge", "shpc", "off" }, 150 { "intel-iommu", "pt", "off" }, 151 { "virtio-net-device", "x-mtu-bypass-backend", "off" }, 152 { "pcie-root-port", "x-migrate-msix", "false" }, 153 }; 154 const size_t hw_compat_2_9_len = G_N_ELEMENTS(hw_compat_2_9); 155 156 GlobalProperty hw_compat_2_8[] = { 157 { "fw_cfg_mem", "x-file-slots", "0x10" }, 158 { "fw_cfg_io", "x-file-slots", "0x10" }, 159 { "pflash_cfi01", "old-multiple-chip-handling", "on" }, 160 { "pci-bridge", "shpc", "on" }, 161 { TYPE_PCI_DEVICE, "x-pcie-extcap-init", "off" }, 162 { "virtio-pci", "x-pcie-deverr-init", "off" }, 163 { "virtio-pci", "x-pcie-lnkctl-init", "off" }, 164 { "virtio-pci", "x-pcie-pm-init", "off" }, 165 { "cirrus-vga", "vgamem_mb", "8" }, 166 { "isa-cirrus-vga", "vgamem_mb", "8" }, 167 }; 168 const size_t hw_compat_2_8_len = G_N_ELEMENTS(hw_compat_2_8); 169 170 GlobalProperty hw_compat_2_7[] = { 171 { "virtio-pci", "page-per-vq", "on" }, 172 { "virtio-serial-device", "emergency-write", "off" }, 173 { "ioapic", "version", "0x11" }, 174 { "intel-iommu", "x-buggy-eim", "true" }, 175 { "virtio-pci", "x-ignore-backend-features", "on" }, 176 }; 177 const size_t hw_compat_2_7_len = G_N_ELEMENTS(hw_compat_2_7); 178 179 GlobalProperty hw_compat_2_6[] = { 180 { "virtio-mmio", "format_transport_address", "off" }, 181 /* Optional because not all virtio-pci devices support legacy mode */ 182 { "virtio-pci", "disable-modern", "on", .optional = true }, 183 { "virtio-pci", "disable-legacy", "off", .optional = true }, 184 }; 185 const size_t hw_compat_2_6_len = G_N_ELEMENTS(hw_compat_2_6); 186 187 GlobalProperty hw_compat_2_5[] = { 188 { "isa-fdc", "fallback", "144" }, 189 { "pvscsi", "x-old-pci-configuration", "on" }, 190 { "pvscsi", "x-disable-pcie", "on" }, 191 { "vmxnet3", "x-old-msi-offsets", "on" }, 192 { "vmxnet3", "x-disable-pcie", "on" }, 193 }; 194 const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5); 195 196 GlobalProperty hw_compat_2_4[] = { 197 /* Optional because the 'scsi' property is Linux-only */ 198 { "virtio-blk-device", "scsi", "true", .optional = true }, 199 { "e1000", "extra_mac_registers", "off" }, 200 { "virtio-pci", "x-disable-pcie", "on" }, 201 { "virtio-pci", "migrate-extra", "off" }, 202 { "fw_cfg_mem", "dma_enabled", "off" }, 203 { "fw_cfg_io", "dma_enabled", "off" } 204 }; 205 const size_t hw_compat_2_4_len = G_N_ELEMENTS(hw_compat_2_4); 206 207 GlobalProperty hw_compat_2_3[] = { 208 { "virtio-blk-pci", "any_layout", "off" }, 209 { "virtio-balloon-pci", "any_layout", "off" }, 210 { "virtio-serial-pci", "any_layout", "off" }, 211 { "virtio-9p-pci", "any_layout", "off" }, 212 { "virtio-rng-pci", "any_layout", "off" }, 213 { TYPE_PCI_DEVICE, "x-pcie-lnksta-dllla", "off" }, 214 { "migration", "send-configuration", "off" }, 215 { "migration", "send-section-footer", "off" }, 216 { "migration", "store-global-state", "off" }, 217 }; 218 const size_t hw_compat_2_3_len = G_N_ELEMENTS(hw_compat_2_3); 219 220 GlobalProperty hw_compat_2_2[] = {}; 221 const size_t hw_compat_2_2_len = G_N_ELEMENTS(hw_compat_2_2); 222 223 GlobalProperty hw_compat_2_1[] = { 224 { "intel-hda", "old_msi_addr", "on" }, 225 { "VGA", "qemu-extended-regs", "off" }, 226 { "secondary-vga", "qemu-extended-regs", "off" }, 227 { "virtio-scsi-pci", "any_layout", "off" }, 228 { "usb-mouse", "usb_version", "1" }, 229 { "usb-kbd", "usb_version", "1" }, 230 { "virtio-pci", "virtio-pci-bus-master-bug-migration", "on" }, 231 }; 232 const size_t hw_compat_2_1_len = G_N_ELEMENTS(hw_compat_2_1); 233 234 MachineState *current_machine; 235 236 static char *machine_get_kernel(Object *obj, Error **errp) 237 { 238 MachineState *ms = MACHINE(obj); 239 240 return g_strdup(ms->kernel_filename); 241 } 242 243 static void machine_set_kernel(Object *obj, const char *value, Error **errp) 244 { 245 MachineState *ms = MACHINE(obj); 246 247 g_free(ms->kernel_filename); 248 ms->kernel_filename = g_strdup(value); 249 } 250 251 static char *machine_get_initrd(Object *obj, Error **errp) 252 { 253 MachineState *ms = MACHINE(obj); 254 255 return g_strdup(ms->initrd_filename); 256 } 257 258 static void machine_set_initrd(Object *obj, const char *value, Error **errp) 259 { 260 MachineState *ms = MACHINE(obj); 261 262 g_free(ms->initrd_filename); 263 ms->initrd_filename = g_strdup(value); 264 } 265 266 static char *machine_get_append(Object *obj, Error **errp) 267 { 268 MachineState *ms = MACHINE(obj); 269 270 return g_strdup(ms->kernel_cmdline); 271 } 272 273 static void machine_set_append(Object *obj, const char *value, Error **errp) 274 { 275 MachineState *ms = MACHINE(obj); 276 277 g_free(ms->kernel_cmdline); 278 ms->kernel_cmdline = g_strdup(value); 279 } 280 281 static char *machine_get_dtb(Object *obj, Error **errp) 282 { 283 MachineState *ms = MACHINE(obj); 284 285 return g_strdup(ms->dtb); 286 } 287 288 static void machine_set_dtb(Object *obj, const char *value, Error **errp) 289 { 290 MachineState *ms = MACHINE(obj); 291 292 g_free(ms->dtb); 293 ms->dtb = g_strdup(value); 294 } 295 296 static char *machine_get_dumpdtb(Object *obj, Error **errp) 297 { 298 MachineState *ms = MACHINE(obj); 299 300 return g_strdup(ms->dumpdtb); 301 } 302 303 static void machine_set_dumpdtb(Object *obj, const char *value, Error **errp) 304 { 305 MachineState *ms = MACHINE(obj); 306 307 g_free(ms->dumpdtb); 308 ms->dumpdtb = g_strdup(value); 309 } 310 311 static void machine_get_phandle_start(Object *obj, Visitor *v, 312 const char *name, void *opaque, 313 Error **errp) 314 { 315 MachineState *ms = MACHINE(obj); 316 int64_t value = ms->phandle_start; 317 318 visit_type_int(v, name, &value, errp); 319 } 320 321 static void machine_set_phandle_start(Object *obj, Visitor *v, 322 const char *name, void *opaque, 323 Error **errp) 324 { 325 MachineState *ms = MACHINE(obj); 326 int64_t value; 327 328 if (!visit_type_int(v, name, &value, errp)) { 329 return; 330 } 331 332 ms->phandle_start = value; 333 } 334 335 static char *machine_get_dt_compatible(Object *obj, Error **errp) 336 { 337 MachineState *ms = MACHINE(obj); 338 339 return g_strdup(ms->dt_compatible); 340 } 341 342 static void machine_set_dt_compatible(Object *obj, const char *value, Error **errp) 343 { 344 MachineState *ms = MACHINE(obj); 345 346 g_free(ms->dt_compatible); 347 ms->dt_compatible = g_strdup(value); 348 } 349 350 static bool machine_get_dump_guest_core(Object *obj, Error **errp) 351 { 352 MachineState *ms = MACHINE(obj); 353 354 return ms->dump_guest_core; 355 } 356 357 static void machine_set_dump_guest_core(Object *obj, bool value, Error **errp) 358 { 359 MachineState *ms = MACHINE(obj); 360 361 ms->dump_guest_core = value; 362 } 363 364 static bool machine_get_mem_merge(Object *obj, Error **errp) 365 { 366 MachineState *ms = MACHINE(obj); 367 368 return ms->mem_merge; 369 } 370 371 static void machine_set_mem_merge(Object *obj, bool value, Error **errp) 372 { 373 MachineState *ms = MACHINE(obj); 374 375 ms->mem_merge = value; 376 } 377 378 static bool machine_get_usb(Object *obj, Error **errp) 379 { 380 MachineState *ms = MACHINE(obj); 381 382 return ms->usb; 383 } 384 385 static void machine_set_usb(Object *obj, bool value, Error **errp) 386 { 387 MachineState *ms = MACHINE(obj); 388 389 ms->usb = value; 390 ms->usb_disabled = !value; 391 } 392 393 static bool machine_get_graphics(Object *obj, Error **errp) 394 { 395 MachineState *ms = MACHINE(obj); 396 397 return ms->enable_graphics; 398 } 399 400 static void machine_set_graphics(Object *obj, bool value, Error **errp) 401 { 402 MachineState *ms = MACHINE(obj); 403 404 ms->enable_graphics = value; 405 } 406 407 static char *machine_get_firmware(Object *obj, Error **errp) 408 { 409 MachineState *ms = MACHINE(obj); 410 411 return g_strdup(ms->firmware); 412 } 413 414 static void machine_set_firmware(Object *obj, const char *value, Error **errp) 415 { 416 MachineState *ms = MACHINE(obj); 417 418 g_free(ms->firmware); 419 ms->firmware = g_strdup(value); 420 } 421 422 static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp) 423 { 424 MachineState *ms = MACHINE(obj); 425 426 ms->suppress_vmdesc = value; 427 } 428 429 static bool machine_get_suppress_vmdesc(Object *obj, Error **errp) 430 { 431 MachineState *ms = MACHINE(obj); 432 433 return ms->suppress_vmdesc; 434 } 435 436 static char *machine_get_memory_encryption(Object *obj, Error **errp) 437 { 438 MachineState *ms = MACHINE(obj); 439 440 if (ms->cgs) { 441 return g_strdup(object_get_canonical_path_component(OBJECT(ms->cgs))); 442 } 443 444 return NULL; 445 } 446 447 static void machine_set_memory_encryption(Object *obj, const char *value, 448 Error **errp) 449 { 450 Object *cgs = 451 object_resolve_path_component(object_get_objects_root(), value); 452 453 if (!cgs) { 454 error_setg(errp, "No such memory encryption object '%s'", value); 455 return; 456 } 457 458 object_property_set_link(obj, "confidential-guest-support", cgs, errp); 459 } 460 461 static void machine_check_confidential_guest_support(const Object *obj, 462 const char *name, 463 Object *new_target, 464 Error **errp) 465 { 466 /* 467 * So far the only constraint is that the target has the 468 * TYPE_CONFIDENTIAL_GUEST_SUPPORT interface, and that's checked 469 * by the QOM core 470 */ 471 } 472 473 static bool machine_get_nvdimm(Object *obj, Error **errp) 474 { 475 MachineState *ms = MACHINE(obj); 476 477 return ms->nvdimms_state->is_enabled; 478 } 479 480 static void machine_set_nvdimm(Object *obj, bool value, Error **errp) 481 { 482 MachineState *ms = MACHINE(obj); 483 484 ms->nvdimms_state->is_enabled = value; 485 } 486 487 static bool machine_get_hmat(Object *obj, Error **errp) 488 { 489 MachineState *ms = MACHINE(obj); 490 491 return ms->numa_state->hmat_enabled; 492 } 493 494 static void machine_set_hmat(Object *obj, bool value, Error **errp) 495 { 496 MachineState *ms = MACHINE(obj); 497 498 ms->numa_state->hmat_enabled = value; 499 } 500 501 static char *machine_get_nvdimm_persistence(Object *obj, Error **errp) 502 { 503 MachineState *ms = MACHINE(obj); 504 505 return g_strdup(ms->nvdimms_state->persistence_string); 506 } 507 508 static void machine_set_nvdimm_persistence(Object *obj, const char *value, 509 Error **errp) 510 { 511 MachineState *ms = MACHINE(obj); 512 NVDIMMState *nvdimms_state = ms->nvdimms_state; 513 514 if (strcmp(value, "cpu") == 0) { 515 nvdimms_state->persistence = 3; 516 } else if (strcmp(value, "mem-ctrl") == 0) { 517 nvdimms_state->persistence = 2; 518 } else { 519 error_setg(errp, "-machine nvdimm-persistence=%s: unsupported option", 520 value); 521 return; 522 } 523 524 g_free(nvdimms_state->persistence_string); 525 nvdimms_state->persistence_string = g_strdup(value); 526 } 527 528 void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) 529 { 530 QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type)); 531 } 532 533 bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev) 534 { 535 bool allowed = false; 536 strList *wl; 537 Object *obj = OBJECT(dev); 538 539 if (!object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE)) { 540 return false; 541 } 542 543 for (wl = mc->allowed_dynamic_sysbus_devices; 544 !allowed && wl; 545 wl = wl->next) { 546 allowed |= !!object_dynamic_cast(obj, wl->value); 547 } 548 549 return allowed; 550 } 551 552 static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) 553 { 554 MachineState *machine = opaque; 555 MachineClass *mc = MACHINE_GET_CLASS(machine); 556 557 if (!device_is_dynamic_sysbus(mc, DEVICE(sbdev))) { 558 error_report("Option '-device %s' cannot be handled by this machine", 559 object_class_get_name(object_get_class(OBJECT(sbdev)))); 560 exit(1); 561 } 562 } 563 564 static char *machine_get_memdev(Object *obj, Error **errp) 565 { 566 MachineState *ms = MACHINE(obj); 567 568 return g_strdup(ms->ram_memdev_id); 569 } 570 571 static void machine_set_memdev(Object *obj, const char *value, Error **errp) 572 { 573 MachineState *ms = MACHINE(obj); 574 575 g_free(ms->ram_memdev_id); 576 ms->ram_memdev_id = g_strdup(value); 577 } 578 579 580 static void machine_init_notify(Notifier *notifier, void *data) 581 { 582 MachineState *machine = MACHINE(qdev_get_machine()); 583 584 /* 585 * Loop through all dynamically created sysbus devices and check if they are 586 * all allowed. If a device is not allowed, error out. 587 */ 588 foreach_dynamic_sysbus_device(validate_sysbus_device, machine); 589 } 590 591 HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) 592 { 593 int i; 594 HotpluggableCPUList *head = NULL; 595 MachineClass *mc = MACHINE_GET_CLASS(machine); 596 597 /* force board to initialize possible_cpus if it hasn't been done yet */ 598 mc->possible_cpu_arch_ids(machine); 599 600 for (i = 0; i < machine->possible_cpus->len; i++) { 601 Object *cpu; 602 HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1); 603 604 cpu_item->type = g_strdup(machine->possible_cpus->cpus[i].type); 605 cpu_item->vcpus_count = machine->possible_cpus->cpus[i].vcpus_count; 606 cpu_item->props = g_memdup(&machine->possible_cpus->cpus[i].props, 607 sizeof(*cpu_item->props)); 608 609 cpu = machine->possible_cpus->cpus[i].cpu; 610 if (cpu) { 611 cpu_item->has_qom_path = true; 612 cpu_item->qom_path = object_get_canonical_path(cpu); 613 } 614 QAPI_LIST_PREPEND(head, cpu_item); 615 } 616 return head; 617 } 618 619 /** 620 * machine_set_cpu_numa_node: 621 * @machine: machine object to modify 622 * @props: specifies which cpu objects to assign to 623 * numa node specified by @props.node_id 624 * @errp: if an error occurs, a pointer to an area to store the error 625 * 626 * Associate NUMA node specified by @props.node_id with cpu slots that 627 * match socket/core/thread-ids specified by @props. It's recommended to use 628 * query-hotpluggable-cpus.props values to specify affected cpu slots, 629 * which would lead to exact 1:1 mapping of cpu slots to NUMA node. 630 * 631 * However for CLI convenience it's possible to pass in subset of properties, 632 * which would affect all cpu slots that match it. 633 * Ex for pc machine: 634 * -smp 4,cores=2,sockets=2 -numa node,nodeid=0 -numa node,nodeid=1 \ 635 * -numa cpu,node-id=0,socket_id=0 \ 636 * -numa cpu,node-id=1,socket_id=1 637 * will assign all child cores of socket 0 to node 0 and 638 * of socket 1 to node 1. 639 * 640 * On attempt of reassigning (already assigned) cpu slot to another NUMA node, 641 * return error. 642 * Empty subset is disallowed and function will return with error in this case. 643 */ 644 void machine_set_cpu_numa_node(MachineState *machine, 645 const CpuInstanceProperties *props, Error **errp) 646 { 647 MachineClass *mc = MACHINE_GET_CLASS(machine); 648 NodeInfo *numa_info = machine->numa_state->nodes; 649 bool match = false; 650 int i; 651 652 if (!mc->possible_cpu_arch_ids) { 653 error_setg(errp, "mapping of CPUs to NUMA node is not supported"); 654 return; 655 } 656 657 /* disabling node mapping is not supported, forbid it */ 658 assert(props->has_node_id); 659 660 /* force board to initialize possible_cpus if it hasn't been done yet */ 661 mc->possible_cpu_arch_ids(machine); 662 663 for (i = 0; i < machine->possible_cpus->len; i++) { 664 CPUArchId *slot = &machine->possible_cpus->cpus[i]; 665 666 /* reject unsupported by board properties */ 667 if (props->has_thread_id && !slot->props.has_thread_id) { 668 error_setg(errp, "thread-id is not supported"); 669 return; 670 } 671 672 if (props->has_core_id && !slot->props.has_core_id) { 673 error_setg(errp, "core-id is not supported"); 674 return; 675 } 676 677 if (props->has_socket_id && !slot->props.has_socket_id) { 678 error_setg(errp, "socket-id is not supported"); 679 return; 680 } 681 682 if (props->has_die_id && !slot->props.has_die_id) { 683 error_setg(errp, "die-id is not supported"); 684 return; 685 } 686 687 /* skip slots with explicit mismatch */ 688 if (props->has_thread_id && props->thread_id != slot->props.thread_id) { 689 continue; 690 } 691 692 if (props->has_core_id && props->core_id != slot->props.core_id) { 693 continue; 694 } 695 696 if (props->has_die_id && props->die_id != slot->props.die_id) { 697 continue; 698 } 699 700 if (props->has_socket_id && props->socket_id != slot->props.socket_id) { 701 continue; 702 } 703 704 /* reject assignment if slot is already assigned, for compatibility 705 * of legacy cpu_index mapping with SPAPR core based mapping do not 706 * error out if cpu thread and matched core have the same node-id */ 707 if (slot->props.has_node_id && 708 slot->props.node_id != props->node_id) { 709 error_setg(errp, "CPU is already assigned to node-id: %" PRId64, 710 slot->props.node_id); 711 return; 712 } 713 714 /* assign slot to node as it's matched '-numa cpu' key */ 715 match = true; 716 slot->props.node_id = props->node_id; 717 slot->props.has_node_id = props->has_node_id; 718 719 if (machine->numa_state->hmat_enabled) { 720 if ((numa_info[props->node_id].initiator < MAX_NODES) && 721 (props->node_id != numa_info[props->node_id].initiator)) { 722 error_setg(errp, "The initiator of CPU NUMA node %" PRId64 723 " should be itself", props->node_id); 724 return; 725 } 726 numa_info[props->node_id].has_cpu = true; 727 numa_info[props->node_id].initiator = props->node_id; 728 } 729 } 730 731 if (!match) { 732 error_setg(errp, "no match found"); 733 } 734 } 735 736 static void smp_parse(MachineState *ms, QemuOpts *opts) 737 { 738 if (opts) { 739 unsigned cpus = qemu_opt_get_number(opts, "cpus", 0); 740 unsigned sockets = qemu_opt_get_number(opts, "sockets", 0); 741 unsigned cores = qemu_opt_get_number(opts, "cores", 0); 742 unsigned threads = qemu_opt_get_number(opts, "threads", 0); 743 744 /* compute missing values, prefer sockets over cores over threads */ 745 if (cpus == 0 || sockets == 0) { 746 cores = cores > 0 ? cores : 1; 747 threads = threads > 0 ? threads : 1; 748 if (cpus == 0) { 749 sockets = sockets > 0 ? sockets : 1; 750 cpus = cores * threads * sockets; 751 } else { 752 ms->smp.max_cpus = 753 qemu_opt_get_number(opts, "maxcpus", cpus); 754 sockets = ms->smp.max_cpus / (cores * threads); 755 } 756 } else if (cores == 0) { 757 threads = threads > 0 ? threads : 1; 758 cores = cpus / (sockets * threads); 759 cores = cores > 0 ? cores : 1; 760 } else if (threads == 0) { 761 threads = cpus / (cores * sockets); 762 threads = threads > 0 ? threads : 1; 763 } else if (sockets * cores * threads < cpus) { 764 error_report("cpu topology: " 765 "sockets (%u) * cores (%u) * threads (%u) < " 766 "smp_cpus (%u)", 767 sockets, cores, threads, cpus); 768 exit(1); 769 } 770 771 ms->smp.max_cpus = 772 qemu_opt_get_number(opts, "maxcpus", cpus); 773 774 if (ms->smp.max_cpus < cpus) { 775 error_report("maxcpus must be equal to or greater than smp"); 776 exit(1); 777 } 778 779 if (sockets * cores * threads != ms->smp.max_cpus) { 780 error_report("Invalid CPU topology: " 781 "sockets (%u) * cores (%u) * threads (%u) " 782 "!= maxcpus (%u)", 783 sockets, cores, threads, 784 ms->smp.max_cpus); 785 exit(1); 786 } 787 788 ms->smp.cpus = cpus; 789 ms->smp.cores = cores; 790 ms->smp.threads = threads; 791 ms->smp.sockets = sockets; 792 } 793 794 if (ms->smp.cpus > 1) { 795 Error *blocker = NULL; 796 error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); 797 replay_add_blocker(blocker); 798 } 799 } 800 801 static void machine_class_init(ObjectClass *oc, void *data) 802 { 803 MachineClass *mc = MACHINE_CLASS(oc); 804 805 /* Default 128 MB as guest ram size */ 806 mc->default_ram_size = 128 * MiB; 807 mc->rom_file_has_mr = true; 808 mc->smp_parse = smp_parse; 809 810 /* numa node memory size aligned on 8MB by default. 811 * On Linux, each node's border has to be 8MB aligned 812 */ 813 mc->numa_mem_align_shift = 23; 814 815 object_class_property_add_str(oc, "kernel", 816 machine_get_kernel, machine_set_kernel); 817 object_class_property_set_description(oc, "kernel", 818 "Linux kernel image file"); 819 820 object_class_property_add_str(oc, "initrd", 821 machine_get_initrd, machine_set_initrd); 822 object_class_property_set_description(oc, "initrd", 823 "Linux initial ramdisk file"); 824 825 object_class_property_add_str(oc, "append", 826 machine_get_append, machine_set_append); 827 object_class_property_set_description(oc, "append", 828 "Linux kernel command line"); 829 830 object_class_property_add_str(oc, "dtb", 831 machine_get_dtb, machine_set_dtb); 832 object_class_property_set_description(oc, "dtb", 833 "Linux kernel device tree file"); 834 835 object_class_property_add_str(oc, "dumpdtb", 836 machine_get_dumpdtb, machine_set_dumpdtb); 837 object_class_property_set_description(oc, "dumpdtb", 838 "Dump current dtb to a file and quit"); 839 840 object_class_property_add(oc, "phandle-start", "int", 841 machine_get_phandle_start, machine_set_phandle_start, 842 NULL, NULL); 843 object_class_property_set_description(oc, "phandle-start", 844 "The first phandle ID we may generate dynamically"); 845 846 object_class_property_add_str(oc, "dt-compatible", 847 machine_get_dt_compatible, machine_set_dt_compatible); 848 object_class_property_set_description(oc, "dt-compatible", 849 "Overrides the \"compatible\" property of the dt root node"); 850 851 object_class_property_add_bool(oc, "dump-guest-core", 852 machine_get_dump_guest_core, machine_set_dump_guest_core); 853 object_class_property_set_description(oc, "dump-guest-core", 854 "Include guest memory in a core dump"); 855 856 object_class_property_add_bool(oc, "mem-merge", 857 machine_get_mem_merge, machine_set_mem_merge); 858 object_class_property_set_description(oc, "mem-merge", 859 "Enable/disable memory merge support"); 860 861 object_class_property_add_bool(oc, "usb", 862 machine_get_usb, machine_set_usb); 863 object_class_property_set_description(oc, "usb", 864 "Set on/off to enable/disable usb"); 865 866 object_class_property_add_bool(oc, "graphics", 867 machine_get_graphics, machine_set_graphics); 868 object_class_property_set_description(oc, "graphics", 869 "Set on/off to enable/disable graphics emulation"); 870 871 object_class_property_add_str(oc, "firmware", 872 machine_get_firmware, machine_set_firmware); 873 object_class_property_set_description(oc, "firmware", 874 "Firmware image"); 875 876 object_class_property_add_bool(oc, "suppress-vmdesc", 877 machine_get_suppress_vmdesc, machine_set_suppress_vmdesc); 878 object_class_property_set_description(oc, "suppress-vmdesc", 879 "Set on to disable self-describing migration"); 880 881 object_class_property_add_link(oc, "confidential-guest-support", 882 TYPE_CONFIDENTIAL_GUEST_SUPPORT, 883 offsetof(MachineState, cgs), 884 machine_check_confidential_guest_support, 885 OBJ_PROP_LINK_STRONG); 886 object_class_property_set_description(oc, "confidential-guest-support", 887 "Set confidential guest scheme to support"); 888 889 /* For compatibility */ 890 object_class_property_add_str(oc, "memory-encryption", 891 machine_get_memory_encryption, machine_set_memory_encryption); 892 object_class_property_set_description(oc, "memory-encryption", 893 "Set memory encryption object to use"); 894 895 object_class_property_add_str(oc, "memory-backend", 896 machine_get_memdev, machine_set_memdev); 897 object_class_property_set_description(oc, "memory-backend", 898 "Set RAM backend" 899 "Valid value is ID of hostmem based backend"); 900 } 901 902 static void machine_class_base_init(ObjectClass *oc, void *data) 903 { 904 MachineClass *mc = MACHINE_CLASS(oc); 905 mc->max_cpus = mc->max_cpus ?: 1; 906 mc->min_cpus = mc->min_cpus ?: 1; 907 mc->default_cpus = mc->default_cpus ?: 1; 908 909 if (!object_class_is_abstract(oc)) { 910 const char *cname = object_class_get_name(oc); 911 assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX)); 912 mc->name = g_strndup(cname, 913 strlen(cname) - strlen(TYPE_MACHINE_SUFFIX)); 914 mc->compat_props = g_ptr_array_new(); 915 } 916 } 917 918 static void machine_initfn(Object *obj) 919 { 920 MachineState *ms = MACHINE(obj); 921 MachineClass *mc = MACHINE_GET_CLASS(obj); 922 923 container_get(obj, "/peripheral"); 924 container_get(obj, "/peripheral-anon"); 925 926 ms->dump_guest_core = true; 927 ms->mem_merge = true; 928 ms->enable_graphics = true; 929 ms->kernel_cmdline = g_strdup(""); 930 931 if (mc->nvdimm_supported) { 932 Object *obj = OBJECT(ms); 933 934 ms->nvdimms_state = g_new0(NVDIMMState, 1); 935 object_property_add_bool(obj, "nvdimm", 936 machine_get_nvdimm, machine_set_nvdimm); 937 object_property_set_description(obj, "nvdimm", 938 "Set on/off to enable/disable " 939 "NVDIMM instantiation"); 940 941 object_property_add_str(obj, "nvdimm-persistence", 942 machine_get_nvdimm_persistence, 943 machine_set_nvdimm_persistence); 944 object_property_set_description(obj, "nvdimm-persistence", 945 "Set NVDIMM persistence" 946 "Valid values are cpu, mem-ctrl"); 947 } 948 949 if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) { 950 ms->numa_state = g_new0(NumaState, 1); 951 object_property_add_bool(obj, "hmat", 952 machine_get_hmat, machine_set_hmat); 953 object_property_set_description(obj, "hmat", 954 "Set on/off to enable/disable " 955 "ACPI Heterogeneous Memory Attribute " 956 "Table (HMAT)"); 957 } 958 959 /* Register notifier when init is done for sysbus sanity checks */ 960 ms->sysbus_notifier.notify = machine_init_notify; 961 qemu_add_machine_init_done_notifier(&ms->sysbus_notifier); 962 963 /* default to mc->default_cpus */ 964 ms->smp.cpus = mc->default_cpus; 965 ms->smp.max_cpus = mc->default_cpus; 966 ms->smp.cores = 1; 967 ms->smp.threads = 1; 968 ms->smp.sockets = 1; 969 } 970 971 static void machine_finalize(Object *obj) 972 { 973 MachineState *ms = MACHINE(obj); 974 975 g_free(ms->kernel_filename); 976 g_free(ms->initrd_filename); 977 g_free(ms->kernel_cmdline); 978 g_free(ms->dtb); 979 g_free(ms->dumpdtb); 980 g_free(ms->dt_compatible); 981 g_free(ms->firmware); 982 g_free(ms->device_memory); 983 g_free(ms->nvdimms_state); 984 g_free(ms->numa_state); 985 } 986 987 bool machine_usb(MachineState *machine) 988 { 989 return machine->usb; 990 } 991 992 int machine_phandle_start(MachineState *machine) 993 { 994 return machine->phandle_start; 995 } 996 997 bool machine_dump_guest_core(MachineState *machine) 998 { 999 return machine->dump_guest_core; 1000 } 1001 1002 bool machine_mem_merge(MachineState *machine) 1003 { 1004 return machine->mem_merge; 1005 } 1006 1007 static char *cpu_slot_to_string(const CPUArchId *cpu) 1008 { 1009 GString *s = g_string_new(NULL); 1010 if (cpu->props.has_socket_id) { 1011 g_string_append_printf(s, "socket-id: %"PRId64, cpu->props.socket_id); 1012 } 1013 if (cpu->props.has_die_id) { 1014 g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id); 1015 } 1016 if (cpu->props.has_core_id) { 1017 if (s->len) { 1018 g_string_append_printf(s, ", "); 1019 } 1020 g_string_append_printf(s, "core-id: %"PRId64, cpu->props.core_id); 1021 } 1022 if (cpu->props.has_thread_id) { 1023 if (s->len) { 1024 g_string_append_printf(s, ", "); 1025 } 1026 g_string_append_printf(s, "thread-id: %"PRId64, cpu->props.thread_id); 1027 } 1028 return g_string_free(s, false); 1029 } 1030 1031 static void numa_validate_initiator(NumaState *numa_state) 1032 { 1033 int i; 1034 NodeInfo *numa_info = numa_state->nodes; 1035 1036 for (i = 0; i < numa_state->num_nodes; i++) { 1037 if (numa_info[i].initiator == MAX_NODES) { 1038 error_report("The initiator of NUMA node %d is missing, use " 1039 "'-numa node,initiator' option to declare it", i); 1040 exit(1); 1041 } 1042 1043 if (!numa_info[numa_info[i].initiator].present) { 1044 error_report("NUMA node %" PRIu16 " is missing, use " 1045 "'-numa node' option to declare it first", 1046 numa_info[i].initiator); 1047 exit(1); 1048 } 1049 1050 if (!numa_info[numa_info[i].initiator].has_cpu) { 1051 error_report("The initiator of NUMA node %d is invalid", i); 1052 exit(1); 1053 } 1054 } 1055 } 1056 1057 static void machine_numa_finish_cpu_init(MachineState *machine) 1058 { 1059 int i; 1060 bool default_mapping; 1061 GString *s = g_string_new(NULL); 1062 MachineClass *mc = MACHINE_GET_CLASS(machine); 1063 const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(machine); 1064 1065 assert(machine->numa_state->num_nodes); 1066 for (i = 0; i < possible_cpus->len; i++) { 1067 if (possible_cpus->cpus[i].props.has_node_id) { 1068 break; 1069 } 1070 } 1071 default_mapping = (i == possible_cpus->len); 1072 1073 for (i = 0; i < possible_cpus->len; i++) { 1074 const CPUArchId *cpu_slot = &possible_cpus->cpus[i]; 1075 1076 if (!cpu_slot->props.has_node_id) { 1077 /* fetch default mapping from board and enable it */ 1078 CpuInstanceProperties props = cpu_slot->props; 1079 1080 props.node_id = mc->get_default_cpu_node_id(machine, i); 1081 if (!default_mapping) { 1082 /* record slots with not set mapping, 1083 * TODO: make it hard error in future */ 1084 char *cpu_str = cpu_slot_to_string(cpu_slot); 1085 g_string_append_printf(s, "%sCPU %d [%s]", 1086 s->len ? ", " : "", i, cpu_str); 1087 g_free(cpu_str); 1088 1089 /* non mapped cpus used to fallback to node 0 */ 1090 props.node_id = 0; 1091 } 1092 1093 props.has_node_id = true; 1094 machine_set_cpu_numa_node(machine, &props, &error_fatal); 1095 } 1096 } 1097 1098 if (machine->numa_state->hmat_enabled) { 1099 numa_validate_initiator(machine->numa_state); 1100 } 1101 1102 if (s->len && !qtest_enabled()) { 1103 warn_report("CPU(s) not present in any NUMA nodes: %s", 1104 s->str); 1105 warn_report("All CPU(s) up to maxcpus should be described " 1106 "in NUMA config, ability to start up with partial NUMA " 1107 "mappings is obsoleted and will be removed in future"); 1108 } 1109 g_string_free(s, true); 1110 } 1111 1112 MemoryRegion *machine_consume_memdev(MachineState *machine, 1113 HostMemoryBackend *backend) 1114 { 1115 MemoryRegion *ret = host_memory_backend_get_memory(backend); 1116 1117 if (memory_region_is_mapped(ret)) { 1118 error_report("memory backend %s can't be used multiple times.", 1119 object_get_canonical_path_component(OBJECT(backend))); 1120 exit(EXIT_FAILURE); 1121 } 1122 host_memory_backend_set_mapped(backend, true); 1123 vmstate_register_ram_global(ret); 1124 return ret; 1125 } 1126 1127 bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp) 1128 { 1129 MachineClass *mc = MACHINE_GET_CLASS(ms); 1130 1131 mc->smp_parse(ms, opts); 1132 1133 /* sanity-check smp_cpus and max_cpus against mc */ 1134 if (ms->smp.cpus < mc->min_cpus) { 1135 error_setg(errp, "Invalid SMP CPUs %d. The min CPUs " 1136 "supported by machine '%s' is %d", 1137 ms->smp.cpus, 1138 mc->name, mc->min_cpus); 1139 return false; 1140 } else if (ms->smp.max_cpus > mc->max_cpus) { 1141 error_setg(errp, "Invalid SMP CPUs %d. The max CPUs " 1142 "supported by machine '%s' is %d", 1143 current_machine->smp.max_cpus, 1144 mc->name, mc->max_cpus); 1145 return false; 1146 } 1147 return true; 1148 } 1149 1150 void machine_run_board_init(MachineState *machine) 1151 { 1152 MachineClass *machine_class = MACHINE_GET_CLASS(machine); 1153 ObjectClass *oc = object_class_by_name(machine->cpu_type); 1154 CPUClass *cc; 1155 1156 /* This checkpoint is required by replay to separate prior clock 1157 reading from the other reads, because timer polling functions query 1158 clock values from the log. */ 1159 replay_checkpoint(CHECKPOINT_INIT); 1160 1161 if (machine->ram_memdev_id) { 1162 Object *o; 1163 o = object_resolve_path_type(machine->ram_memdev_id, 1164 TYPE_MEMORY_BACKEND, NULL); 1165 machine->ram = machine_consume_memdev(machine, MEMORY_BACKEND(o)); 1166 } 1167 1168 if (machine->numa_state) { 1169 numa_complete_configuration(machine); 1170 if (machine->numa_state->num_nodes) { 1171 machine_numa_finish_cpu_init(machine); 1172 } 1173 } 1174 1175 /* If the machine supports the valid_cpu_types check and the user 1176 * specified a CPU with -cpu check here that the user CPU is supported. 1177 */ 1178 if (machine_class->valid_cpu_types && machine->cpu_type) { 1179 int i; 1180 1181 for (i = 0; machine_class->valid_cpu_types[i]; i++) { 1182 if (object_class_dynamic_cast(oc, 1183 machine_class->valid_cpu_types[i])) { 1184 /* The user specificed CPU is in the valid field, we are 1185 * good to go. 1186 */ 1187 break; 1188 } 1189 } 1190 1191 if (!machine_class->valid_cpu_types[i]) { 1192 /* The user specified CPU is not valid */ 1193 error_report("Invalid CPU type: %s", machine->cpu_type); 1194 error_printf("The valid types are: %s", 1195 machine_class->valid_cpu_types[0]); 1196 for (i = 1; machine_class->valid_cpu_types[i]; i++) { 1197 error_printf(", %s", machine_class->valid_cpu_types[i]); 1198 } 1199 error_printf("\n"); 1200 1201 exit(1); 1202 } 1203 } 1204 1205 /* Check if CPU type is deprecated and warn if so */ 1206 cc = CPU_CLASS(oc); 1207 if (cc && cc->deprecation_note) { 1208 warn_report("CPU model %s is deprecated -- %s", machine->cpu_type, 1209 cc->deprecation_note); 1210 } 1211 1212 if (machine->cgs) { 1213 /* 1214 * With confidential guests, the host can't see the real 1215 * contents of RAM, so there's no point in it trying to merge 1216 * areas. 1217 */ 1218 machine_set_mem_merge(OBJECT(machine), false, &error_abort); 1219 1220 /* 1221 * Virtio devices can't count on directly accessing guest 1222 * memory, so they need iommu_platform=on to use normal DMA 1223 * mechanisms. That requires also disabling legacy virtio 1224 * support for those virtio pci devices which allow it. 1225 */ 1226 object_register_sugar_prop(TYPE_VIRTIO_PCI, "disable-legacy", 1227 "on", true); 1228 object_register_sugar_prop(TYPE_VIRTIO_DEVICE, "iommu_platform", 1229 "on", false); 1230 } 1231 1232 machine_class->init(machine); 1233 phase_advance(PHASE_MACHINE_INITIALIZED); 1234 } 1235 1236 static NotifierList machine_init_done_notifiers = 1237 NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); 1238 1239 void qemu_add_machine_init_done_notifier(Notifier *notify) 1240 { 1241 notifier_list_add(&machine_init_done_notifiers, notify); 1242 if (phase_check(PHASE_MACHINE_READY)) { 1243 notify->notify(notify, NULL); 1244 } 1245 } 1246 1247 void qemu_remove_machine_init_done_notifier(Notifier *notify) 1248 { 1249 notifier_remove(notify); 1250 } 1251 1252 void qdev_machine_creation_done(void) 1253 { 1254 cpu_synchronize_all_post_init(); 1255 1256 if (current_machine->boot_once) { 1257 qemu_boot_set(current_machine->boot_once, &error_fatal); 1258 qemu_register_reset(restore_boot_order, g_strdup(current_machine->boot_order)); 1259 } 1260 1261 /* 1262 * ok, initial machine setup is done, starting from now we can 1263 * only create hotpluggable devices 1264 */ 1265 phase_advance(PHASE_MACHINE_READY); 1266 qdev_assert_realized_properly(); 1267 1268 /* TODO: once all bus devices are qdevified, this should be done 1269 * when bus is created by qdev.c */ 1270 /* 1271 * TODO: If we had a main 'reset container' that the whole system 1272 * lived in, we could reset that using the multi-phase reset 1273 * APIs. For the moment, we just reset the sysbus, which will cause 1274 * all devices hanging off it (and all their child buses, recursively) 1275 * to be reset. Note that this will *not* reset any Device objects 1276 * which are not attached to some part of the qbus tree! 1277 */ 1278 qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default()); 1279 1280 notifier_list_notify(&machine_init_done_notifiers, NULL); 1281 1282 if (rom_check_and_register_reset() != 0) { 1283 exit(1); 1284 } 1285 1286 replay_start(); 1287 1288 /* This checkpoint is required by replay to separate prior clock 1289 reading from the other reads, because timer polling functions query 1290 clock values from the log. */ 1291 replay_checkpoint(CHECKPOINT_RESET); 1292 qemu_system_reset(SHUTDOWN_CAUSE_NONE); 1293 register_global_state(); 1294 } 1295 1296 static const TypeInfo machine_info = { 1297 .name = TYPE_MACHINE, 1298 .parent = TYPE_OBJECT, 1299 .abstract = true, 1300 .class_size = sizeof(MachineClass), 1301 .class_init = machine_class_init, 1302 .class_base_init = machine_class_base_init, 1303 .instance_size = sizeof(MachineState), 1304 .instance_init = machine_initfn, 1305 .instance_finalize = machine_finalize, 1306 }; 1307 1308 static void machine_register_types(void) 1309 { 1310 type_register_static(&machine_info); 1311 } 1312 1313 type_init(machine_register_types) 1314