10d09e41aSPaolo Bonzini /* Declarations for use by board files for creating devices. */ 20d09e41aSPaolo Bonzini 30d09e41aSPaolo Bonzini #ifndef HW_BOARDS_H 40d09e41aSPaolo Bonzini #define HW_BOARDS_H 50d09e41aSPaolo Bonzini 6d4842052SMarkus Armbruster #include "exec/memory.h" 7aa8b1839SIgor Mammedov #include "sysemu/hostmem.h" 80d09e41aSPaolo Bonzini #include "sysemu/blockdev.h" 98ac25c84SMarkus Armbruster #include "qapi/qapi-types-machine.h" 100b8fa32fSMarkus Armbruster #include "qemu/module.h" 1136d20cb2SMarcel Apfelbaum #include "qom/object.h" 122e5b09fdSMarkus Armbruster #include "hw/core/cpu.h" 130d09e41aSPaolo Bonzini 14dfabb8b9SPaolo Bonzini #define TYPE_MACHINE_SUFFIX "-machine" 15c84a8f01SEduardo Habkost 16c84a8f01SEduardo Habkost /* Machine class name that needs to be used for class-name-based machine 17c84a8f01SEduardo Habkost * type lookup to work. 18c84a8f01SEduardo Habkost */ 19c84a8f01SEduardo Habkost #define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX) 20c84a8f01SEduardo Habkost 2136d20cb2SMarcel Apfelbaum #define TYPE_MACHINE "machine" 22c8897e8eSMarcel Apfelbaum #undef MACHINE /* BSD defines it and QEMU does not use it */ 23a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE) 2436d20cb2SMarcel Apfelbaum 250056ae24SMarcel Apfelbaum extern MachineState *current_machine; 260056ae24SMarcel Apfelbaum 2762b4a227SPhilippe Mathieu-Daudé /** 2862b4a227SPhilippe Mathieu-Daudé * machine_class_default_cpu_type: Return the machine default CPU type. 2962b4a227SPhilippe Mathieu-Daudé * @mc: Machine class 3062b4a227SPhilippe Mathieu-Daudé */ 3162b4a227SPhilippe Mathieu-Daudé const char *machine_class_default_cpu_type(MachineClass *mc); 3262b4a227SPhilippe Mathieu-Daudé 337a2c7da6SMartin Kletzander void machine_add_audiodev_property(MachineClass *mc); 3426f88d84SPaolo Bonzini void machine_run_board_init(MachineState *machine, const char *mem_path, Error **errp); 355e97b623SMarcel Apfelbaum bool machine_usb(MachineState *machine); 366cabe7faSMarcel Apfelbaum int machine_phandle_start(MachineState *machine); 3747c8ca53SMarcel Apfelbaum bool machine_dump_guest_core(MachineState *machine); 3875cc7f01SMarcel Apfelbaum bool machine_mem_merge(MachineState *machine); 3937662d85SXiaoyao Li bool machine_require_guest_memfd(MachineState *machine); 40f2d672c2SIgor Mammedov HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine); 417c88e65dSIgor Mammedov void machine_set_cpu_numa_node(MachineState *machine, 427c88e65dSIgor Mammedov const CpuInstanceProperties *props, 437c88e65dSIgor Mammedov Error **errp); 443e2f1498SPhilippe Mathieu-Daudé void machine_parse_smp_config(MachineState *ms, 453e2f1498SPhilippe Mathieu-Daudé const SMPConfiguration *config, Error **errp); 46a1d027beSZhao Liu unsigned int machine_topo_get_cores_per_socket(const MachineState *ms); 47a1d027beSZhao Liu unsigned int machine_topo_get_threads_per_socket(const MachineState *ms); 48cc0afd8aSDavid Hildenbrand void machine_memory_devices_init(MachineState *ms, hwaddr base, uint64_t size); 495e97b623SMarcel Apfelbaum 50387c0e8bSPeter Maydell /** 51387c0e8bSPeter Maydell * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices 52387c0e8bSPeter Maydell * @mc: Machine class 53387c0e8bSPeter Maydell * @type: type to allow (should be a subtype of TYPE_SYS_BUS_DEVICE) 54387c0e8bSPeter Maydell * 55387c0e8bSPeter Maydell * Add the QOM type @type to the list of devices of which are subtypes 56387c0e8bSPeter Maydell * of TYPE_SYS_BUS_DEVICE but which are still permitted to be dynamically 57387c0e8bSPeter Maydell * created (eg by the user on the command line with -device). 58387c0e8bSPeter Maydell * By default if the user tries to create any devices on the command line 59387c0e8bSPeter Maydell * that are subtypes of TYPE_SYS_BUS_DEVICE they will get an error message; 60387c0e8bSPeter Maydell * for the special cases which are permitted for this machine model, the 61387c0e8bSPeter Maydell * machine model class init code must call this function to add them 62387c0e8bSPeter Maydell * to the list of specifically permitted devices. 63387c0e8bSPeter Maydell */ 640bd1909dSEduardo Habkost void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); 65387c0e8bSPeter Maydell 660fb124dbSPeter Maydell /** 67b5fdf410SDamien Hedde * device_type_is_dynamic_sysbus: Check if type is an allowed sysbus device 68b5fdf410SDamien Hedde * type for the machine class. 69b5fdf410SDamien Hedde * @mc: Machine class 70b5fdf410SDamien Hedde * @type: type to check (should be a subtype of TYPE_SYS_BUS_DEVICE) 71b5fdf410SDamien Hedde * 72b5fdf410SDamien Hedde * Returns: true if @type is a type in the machine's list of 73b5fdf410SDamien Hedde * dynamically pluggable sysbus devices; otherwise false. 74b5fdf410SDamien Hedde * 75b5fdf410SDamien Hedde * Check if the QOM type @type is in the list of allowed sysbus device 76b5fdf410SDamien Hedde * types (see machine_class_allowed_dynamic_sysbus_dev()). 77b5fdf410SDamien Hedde * Note that if @type has a parent type in the list, it is allowed too. 78b5fdf410SDamien Hedde */ 79b5fdf410SDamien Hedde bool device_type_is_dynamic_sysbus(MachineClass *mc, const char *type); 80b5fdf410SDamien Hedde 81b5fdf410SDamien Hedde /** 820fb124dbSPeter Maydell * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device 830fb124dbSPeter Maydell * @mc: Machine class 840fb124dbSPeter Maydell * @dev: device to check 850fb124dbSPeter Maydell * 860fb124dbSPeter Maydell * Returns: true if @dev is a sysbus device on the machine's list 870fb124dbSPeter Maydell * of dynamically pluggable sysbus devices; otherwise false. 880fb124dbSPeter Maydell * 890fb124dbSPeter Maydell * This function checks whether @dev is a valid dynamic sysbus device, 900fb124dbSPeter Maydell * by first confirming that it is a sysbus device and then checking it 910fb124dbSPeter Maydell * against the list of permitted dynamic sysbus devices which has been 920fb124dbSPeter Maydell * set up by the machine using machine_class_allow_dynamic_sysbus_dev(). 930fb124dbSPeter Maydell * 940fb124dbSPeter Maydell * It is valid to call this with something that is not a subclass of 950fb124dbSPeter Maydell * TYPE_SYS_BUS_DEVICE; the function will return false in this case. 960fb124dbSPeter Maydell * This allows hotplug callback functions to be written as: 970fb124dbSPeter Maydell * if (device_is_dynamic_sysbus(mc, dev)) { 980fb124dbSPeter Maydell * handle dynamic sysbus case; 990fb124dbSPeter Maydell * } else if (some other kind of hotplug) { 1000fb124dbSPeter Maydell * handle that; 1010fb124dbSPeter Maydell * } 1020fb124dbSPeter Maydell */ 1030fb124dbSPeter Maydell bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev); 1040fb124dbSPeter Maydell 10582b911aaSIgor Mammedov /* 10682b911aaSIgor Mammedov * Checks that backend isn't used, preps it for exclusive usage and 10782b911aaSIgor Mammedov * returns migratable MemoryRegion provided by backend. 10882b911aaSIgor Mammedov */ 10982b911aaSIgor Mammedov MemoryRegion *machine_consume_memdev(MachineState *machine, 11082b911aaSIgor Mammedov HostMemoryBackend *backend); 1110bd1909dSEduardo Habkost 11236d20cb2SMarcel Apfelbaum /** 1133811ef14SIgor Mammedov * CPUArchId: 1143811ef14SIgor Mammedov * @arch_id - architecture-dependent CPU ID of present or possible CPU 1153811ef14SIgor Mammedov * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise 116d342eb76SIgor Mammedov * @type - QOM class name of possible @cpu object 117c67ae933SIgor Mammedov * @props - CPU object properties, initialized by board 118f2d672c2SIgor Mammedov * #vcpus_count - number of threads provided by @cpu object 1193811ef14SIgor Mammedov */ 120a44432b4SMarkus Armbruster typedef struct CPUArchId { 1213811ef14SIgor Mammedov uint64_t arch_id; 122f2d672c2SIgor Mammedov int64_t vcpus_count; 123c67ae933SIgor Mammedov CpuInstanceProperties props; 12497e03106SPhilippe Mathieu-Daudé CPUState *cpu; 125d342eb76SIgor Mammedov const char *type; 1263811ef14SIgor Mammedov } CPUArchId; 1273811ef14SIgor Mammedov 1283811ef14SIgor Mammedov /** 1293811ef14SIgor Mammedov * CPUArchIdList: 1303811ef14SIgor Mammedov * @len - number of @CPUArchId items in @cpus array 1313811ef14SIgor Mammedov * @cpus - array of present or possible CPUs for current machine configuration 1323811ef14SIgor Mammedov */ 1333811ef14SIgor Mammedov typedef struct { 1343811ef14SIgor Mammedov int len; 135880a7817SPhilippe Mathieu-Daudé CPUArchId cpus[]; 1363811ef14SIgor Mammedov } CPUArchIdList; 1373811ef14SIgor Mammedov 1383811ef14SIgor Mammedov /** 139e4a97a89SYanan Wang * SMPCompatProps: 1402b526199SYanan Wang * @prefer_sockets - whether sockets are preferred over cores in smp parsing 141e4a97a89SYanan Wang * @dies_supported - whether dies are supported by the machine 142864c3b5cSYanan Wang * @clusters_supported - whether clusters are supported by the machine 14397f4effeSYicong Yang * @has_clusters - whether clusters are explicitly specified in the user 14497f4effeSYicong Yang * provided SMP configuration 1455de1aff2SPierre Morel * @books_supported - whether books are supported by the machine 1465de1aff2SPierre Morel * @drawers_supported - whether drawers are supported by the machine 147dcba73b4SZhao Liu * @modules_supported - whether modules are supported by the machine 148e4a97a89SYanan Wang */ 149e4a97a89SYanan Wang typedef struct { 1502b526199SYanan Wang bool prefer_sockets; 151e4a97a89SYanan Wang bool dies_supported; 152864c3b5cSYanan Wang bool clusters_supported; 15397f4effeSYicong Yang bool has_clusters; 1545de1aff2SPierre Morel bool books_supported; 1555de1aff2SPierre Morel bool drawers_supported; 156dcba73b4SZhao Liu bool modules_supported; 157e4a97a89SYanan Wang } SMPCompatProps; 158e4a97a89SYanan Wang 159e4a97a89SYanan Wang /** 16036d20cb2SMarcel Apfelbaum * MachineClass: 16108fe6824SThomas Huth * @deprecation_reason: If set, the machine is marked as deprecated. The 16208fe6824SThomas Huth * string should provide some clear information about what to use instead. 16372649619SEmilio G. Cota * @max_cpus: maximum number of CPUs supported. Default: 1 16472649619SEmilio G. Cota * @min_cpus: minimum number of CPUs supported. Default: 1 16572649619SEmilio G. Cota * @default_cpus: number of CPUs instantiated if none are specified. Default: 1 166ea0ac7f6SPhilippe Mathieu-Daudé * @is_default: 167ea0ac7f6SPhilippe Mathieu-Daudé * If true QEMU will use this machine by default if no '-M' option is given. 168b7454548SIgor Mammedov * @get_hotplug_handler: this function is called during bus-less 169b7454548SIgor Mammedov * device hotplug. If defined it returns pointer to an instance 170b7454548SIgor Mammedov * of HotplugHandler object, which handles hotplug operation 171b7454548SIgor Mammedov * for a given @dev. It may return NULL if @dev doesn't require 172b7454548SIgor Mammedov * any actions to be performed by hotplug handler. 173ea089eebSIgor Mammedov * @cpu_index_to_instance_props: 174ea089eebSIgor Mammedov * used to provide @cpu_index to socket/core/thread number mapping, allowing 175a1a62cedSMichael Tokarev * legacy code to perform mapping from cpu_index to topology properties 176ea089eebSIgor Mammedov * Returns: tuple of socket/core/thread ids given cpu_index belongs to. 17757924bcdSIgor Mammedov * used to provide @cpu_index to socket number mapping, allowing 17857924bcdSIgor Mammedov * a machine to group CPU threads belonging to the same socket/package 17957924bcdSIgor Mammedov * Returns: socket number given cpu_index belongs to. 180fac862ffSEduardo Habkost * @hw_version: 181fac862ffSEduardo Habkost * Value of QEMU_VERSION when the machine was added to QEMU. 182fac862ffSEduardo Habkost * Set only by old machines because they need to keep 183fac862ffSEduardo Habkost * compatibility on code that exposed QEMU_VERSION to guests in 184fac862ffSEduardo Habkost * the past (and now use qemu_hw_version()). 1853811ef14SIgor Mammedov * @possible_cpu_arch_ids: 1863811ef14SIgor Mammedov * Returns an array of @CPUArchId architecture-dependent CPU IDs 1873811ef14SIgor Mammedov * which includes CPU IDs for present and possible to hotplug CPUs. 1883811ef14SIgor Mammedov * Caller is responsible for freeing returned list. 18979e07936SIgor Mammedov * @get_default_cpu_node_id: 19079e07936SIgor Mammedov * returns default board specific node_id value for CPU slot specified by 19179e07936SIgor Mammedov * index @idx in @ms->possible_cpus[] 192c5514d0eSIgor Mammedov * @has_hotpluggable_cpus: 193c5514d0eSIgor Mammedov * If true, board supports CPUs creation with -device/device_add. 1946063d4c0SIgor Mammedov * @default_cpu_type: 1956063d4c0SIgor Mammedov * specifies default CPU_TYPE, which will be used for parsing target 1966063d4c0SIgor Mammedov * specific features and for creating CPUs if CPU name wasn't provided 1976063d4c0SIgor Mammedov * explicitly at CLI 19820bccb82SPeter Maydell * @minimum_page_bits: 19920bccb82SPeter Maydell * If non-zero, the board promises never to create a CPU with a page size 20020bccb82SPeter Maydell * smaller than this, so QEMU can use a more efficient larger page 20120bccb82SPeter Maydell * size than the target architecture's minimum. (Attempting to create 20220bccb82SPeter Maydell * such a CPU will fail.) Note that changing this is a migration 20320bccb82SPeter Maydell * compatibility break for the machine. 204ed860129SPeter Maydell * @ignore_memory_transaction_failures: 205ed860129SPeter Maydell * If this is flag is true then the CPU will ignore memory transaction 206ed860129SPeter Maydell * failures which should cause the CPU to take an exception due to an 207ed860129SPeter Maydell * access to an unassigned physical address; the transaction will instead 208ed860129SPeter Maydell * return zero (for a read) or be ignored (for a write). This should be 209ed860129SPeter Maydell * set only by legacy board models which rely on the old RAZ/WI behaviour 210ed860129SPeter Maydell * for handling devices that QEMU does not yet model. New board models 211ed860129SPeter Maydell * should instead use "unimplemented-device" for all memory ranges where 212ed860129SPeter Maydell * the guest will attempt to probe for a device that QEMU doesn't 213ed860129SPeter Maydell * implement and a stub device is required. 214dc0ca80eSEric Auger * @kvm_type: 215dc0ca80eSEric Auger * Return the type of KVM corresponding to the kvm-type string option or 216dc0ca80eSEric Auger * computed based on other criteria such as the host kernel capabilities. 217516fc0a0SAndrew Jones * kvm-type may be NULL if it is not needed. 218cd5ff833SIgor Mammedov * @numa_mem_supported: 219cd5ff833SIgor Mammedov * true if '--numa node.mem' option is supported and false otherwise 220d2321d31SPeter Xu * @hotplug_allowed: 221d2321d31SPeter Xu * If the hook is provided, then it'll be called for each device 222d2321d31SPeter Xu * hotplug to check whether the device hotplug is allowed. Return 223d2321d31SPeter Xu * true to grant allowance or false to reject the hotplug. When 224d2321d31SPeter Xu * false is returned, an error must be set to show the reason of 225d2321d31SPeter Xu * the rejection. If the hook is not provided, all hotplug will be 226d2321d31SPeter Xu * allowed. 227900c0ba3SIgor Mammedov * @default_ram_id: 228a1a62cedSMichael Tokarev * Specifies initial RAM MemoryRegion name to be used for default backend 229900c0ba3SIgor Mammedov * creation if user explicitly hasn't specified backend with "memory-backend" 230900c0ba3SIgor Mammedov * property. 231a1a62cedSMichael Tokarev * It also will be used as a way to option into "-m" option support. 232900c0ba3SIgor Mammedov * If it's not set by board, '-m' will be ignored and generic code will 233900c0ba3SIgor Mammedov * not create default RAM MemoryRegion. 2345c30ef93SChristian Borntraeger * @fixup_ram_size: 2355c30ef93SChristian Borntraeger * Amends user provided ram size (with -m option) using machine 2365c30ef93SChristian Borntraeger * specific algorithm. To be used by old machine types for compat 2375c30ef93SChristian Borntraeger * purposes only. 2385c30ef93SChristian Borntraeger * Applies only to default memory backend, i.e., explicit memory backend 2395c30ef93SChristian Borntraeger * wasn't used. 24036d20cb2SMarcel Apfelbaum */ 24136d20cb2SMarcel Apfelbaum struct MachineClass { 24236d20cb2SMarcel Apfelbaum /*< private >*/ 24336d20cb2SMarcel Apfelbaum ObjectClass parent_class; 24436d20cb2SMarcel Apfelbaum /*< public >*/ 24536d20cb2SMarcel Apfelbaum 2462709f263SLaszlo Ersek const char *family; /* NULL iff @name identifies a standalone machtype */ 2478ea75371SMarc-André Lureau char *name; 24800b4fbe2SMarcel Apfelbaum const char *alias; 24900b4fbe2SMarcel Apfelbaum const char *desc; 25008fe6824SThomas Huth const char *deprecation_reason; 25100b4fbe2SMarcel Apfelbaum 2523ef96221SMarcel Apfelbaum void (*init)(MachineState *state); 2537966d70fSJason A. Donenfeld void (*reset)(MachineState *state, ShutdownCause reason); 2544b5e06c9SNicholas Piggin void (*wakeup)(MachineState *state); 255dc0ca80eSEric Auger int (*kvm_type)(MachineState *machine, const char *arg); 25600b4fbe2SMarcel Apfelbaum 25700b4fbe2SMarcel Apfelbaum BlockInterfaceType block_default_type; 25816026518SJohn Snow int units_per_default_bus; 25900b4fbe2SMarcel Apfelbaum int max_cpus; 26072649619SEmilio G. Cota int min_cpus; 26172649619SEmilio G. Cota int default_cpus; 26200b4fbe2SMarcel Apfelbaum unsigned int no_serial:1, 26300b4fbe2SMarcel Apfelbaum no_parallel:1, 26400b4fbe2SMarcel Apfelbaum no_floppy:1, 26500b4fbe2SMarcel Apfelbaum no_cdrom:1, 26633cd52b5SAlexander Graf no_sdcard:1, 267bab47d9aSGerd Hoffmann pci_allow_0_address:1, 268bab47d9aSGerd Hoffmann legacy_fw_cfg_order:1; 269ea0ac7f6SPhilippe Mathieu-Daudé bool is_default; 27000b4fbe2SMarcel Apfelbaum const char *default_machine_opts; 27100b4fbe2SMarcel Apfelbaum const char *default_boot_order; 2726f00494aSGerd Hoffmann const char *default_display; 27301ecdaa4SThomas Huth const char *default_nic; 274b66bbee3SMarc-André Lureau GPtrArray *compat_props; 27500b4fbe2SMarcel Apfelbaum const char *hw_version; 276076b35b5SNikunj A Dadhania ram_addr_t default_ram_size; 2776063d4c0SIgor Mammedov const char *default_cpu_type; 278b2fc91dbSPeter Xu bool default_kernel_irqchip_split; 27971ae9e94SEduardo Habkost bool option_rom_has_mr; 28071ae9e94SEduardo Habkost bool rom_file_has_mr; 28120bccb82SPeter Maydell int minimum_page_bits; 282c5514d0eSIgor Mammedov bool has_hotpluggable_cpus; 283ed860129SPeter Maydell bool ignore_memory_transaction_failures; 28455641213SLaurent Vivier int numa_mem_align_shift; 285790a4428SGavin Shan const char * const *valid_cpu_types; 2860bd1909dSEduardo Habkost strList *allowed_dynamic_sysbus_devices; 2877b8be49dSDou Liyang bool auto_enable_numa_with_memhp; 288195784a0SDavid Hildenbrand bool auto_enable_numa_with_memdev; 289907aac2fSMark Cave-Ayland bool ignore_boot_device_suffixes; 2907fccf2a0SCorey Minyard bool smbus_no_migration_support; 291f6a0d06bSEric Auger bool nvdimm_supported; 292cd5ff833SIgor Mammedov bool numa_mem_supported; 2930533ef5fSTao Xu bool auto_enable_numa; 294a494fdb7SGavin Shan bool cpu_cluster_has_numa_boundary; 295e4a97a89SYanan Wang SMPCompatProps smp_props; 296900c0ba3SIgor Mammedov const char *default_ram_id; 297b7454548SIgor Mammedov 298b7454548SIgor Mammedov HotplugHandler *(*get_hotplug_handler)(MachineState *machine, 299b7454548SIgor Mammedov DeviceState *dev); 300d2321d31SPeter Xu bool (*hotplug_allowed)(MachineState *state, DeviceState *dev, 301d2321d31SPeter Xu Error **errp); 302ea089eebSIgor Mammedov CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *machine, 303ea089eebSIgor Mammedov unsigned cpu_index); 30480e5db30SIgor Mammedov const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); 30579e07936SIgor Mammedov int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx); 3065c30ef93SChristian Borntraeger ram_addr_t (*fixup_ram_size)(ram_addr_t size); 30736d20cb2SMarcel Apfelbaum }; 30836d20cb2SMarcel Apfelbaum 30936d20cb2SMarcel Apfelbaum /** 310e017da37SDavid Hildenbrand * DeviceMemoryState: 311b0c14ec4SDavid Hildenbrand * @base: address in guest physical address space where the memory 312b0c14ec4SDavid Hildenbrand * address space for memory devices starts 313f9716f4bSDavid Hildenbrand * @mr: memory region container for memory devices 314f9716f4bSDavid Hildenbrand * @as: address space for memory devices 315f9716f4bSDavid Hildenbrand * @listener: memory listener used to track used memslots in the address space 316e919402bSYangming * @dimm_size: the sum of plugged DIMMs' sizes 317ac23dd2fSDavid Hildenbrand * @used_region_size: the part of @mr already used by memory devices 318f9716f4bSDavid Hildenbrand * @required_memslots: the number of memslots required by memory devices 319f9716f4bSDavid Hildenbrand * @used_memslots: the number of memslots currently used by memory devices 320a2335113SDavid Hildenbrand * @memslot_auto_decision_active: whether any plugged memory device 321a2335113SDavid Hildenbrand * automatically decided to use more than 322a2335113SDavid Hildenbrand * one memslot 323b0c14ec4SDavid Hildenbrand */ 324e017da37SDavid Hildenbrand typedef struct DeviceMemoryState { 325b0c14ec4SDavid Hildenbrand hwaddr base; 326b0c14ec4SDavid Hildenbrand MemoryRegion mr; 327f9716f4bSDavid Hildenbrand AddressSpace as; 328f9716f4bSDavid Hildenbrand MemoryListener listener; 329e919402bSYangming uint64_t dimm_size; 330ac23dd2fSDavid Hildenbrand uint64_t used_region_size; 331f9716f4bSDavid Hildenbrand unsigned int required_memslots; 332f9716f4bSDavid Hildenbrand unsigned int used_memslots; 333a2335113SDavid Hildenbrand unsigned int memslot_auto_decision_active; 334e017da37SDavid Hildenbrand } DeviceMemoryState; 335b0c14ec4SDavid Hildenbrand 336b0c14ec4SDavid Hildenbrand /** 337edeeec91SLike Xu * CpuTopology: 338edeeec91SLike Xu * @cpus: the number of present logical processors on the machine 3395de1aff2SPierre Morel * @drawers: the number of drawers on the machine 3405de1aff2SPierre Morel * @books: the number of books in one drawer 3415de1aff2SPierre Morel * @sockets: the number of sockets in one book 342003f230eSYanan Wang * @dies: the number of dies in one socket 343864c3b5cSYanan Wang * @clusters: the number of clusters in one die 344dcba73b4SZhao Liu * @modules: the number of modules in one cluster 345864c3b5cSYanan Wang * @cores: the number of cores in one cluster 346003f230eSYanan Wang * @threads: the number of threads in one core 347edeeec91SLike Xu * @max_cpus: the maximum number of logical processors on the machine 348edeeec91SLike Xu */ 349edeeec91SLike Xu typedef struct CpuTopology { 350edeeec91SLike Xu unsigned int cpus; 3515de1aff2SPierre Morel unsigned int drawers; 3525de1aff2SPierre Morel unsigned int books; 353003f230eSYanan Wang unsigned int sockets; 35467872eb8SPaolo Bonzini unsigned int dies; 355864c3b5cSYanan Wang unsigned int clusters; 356dcba73b4SZhao Liu unsigned int modules; 357edeeec91SLike Xu unsigned int cores; 358edeeec91SLike Xu unsigned int threads; 359edeeec91SLike Xu unsigned int max_cpus; 360edeeec91SLike Xu } CpuTopology; 361edeeec91SLike Xu 362edeeec91SLike Xu /** 36336d20cb2SMarcel Apfelbaum * MachineState: 36436d20cb2SMarcel Apfelbaum */ 36536d20cb2SMarcel Apfelbaum struct MachineState { 36636d20cb2SMarcel Apfelbaum /*< private >*/ 36736d20cb2SMarcel Apfelbaum Object parent_obj; 36833cd52b5SAlexander Graf 36936d20cb2SMarcel Apfelbaum /*< public >*/ 37036d20cb2SMarcel Apfelbaum 371a6487d37SAlex Bennée void *fdt; 37236d20cb2SMarcel Apfelbaum char *dtb; 37336d20cb2SMarcel Apfelbaum char *dumpdtb; 37436d20cb2SMarcel Apfelbaum int phandle_start; 37536d20cb2SMarcel Apfelbaum char *dt_compatible; 37636d20cb2SMarcel Apfelbaum bool dump_guest_core; 37736d20cb2SMarcel Apfelbaum bool mem_merge; 37836d20cb2SMarcel Apfelbaum bool usb; 379c6e76503SPaolo Bonzini bool usb_disabled; 38036d20cb2SMarcel Apfelbaum char *firmware; 381a52a7fdfSLe Tan bool iommu; 3829850c604SAlexander Graf bool suppress_vmdesc; 383cfc58cf3SEduardo Habkost bool enable_graphics; 384e0292d7cSDavid Gibson ConfidentialGuestSupport *cgs; 38526f88d84SPaolo Bonzini HostMemoryBackend *memdev; 38682b911aaSIgor Mammedov /* 38782b911aaSIgor Mammedov * convenience alias to ram_memdev_id backend memory region 38882b911aaSIgor Mammedov * or to numa container memory region 38982b911aaSIgor Mammedov */ 39082b911aaSIgor Mammedov MemoryRegion *ram; 391e017da37SDavid Hildenbrand DeviceMemoryState *device_memory; 39236d20cb2SMarcel Apfelbaum 3937a2c7da6SMartin Kletzander /* 3947a2c7da6SMartin Kletzander * Included in MachineState for simplicity, but not supported 3957a2c7da6SMartin Kletzander * unless machine_add_audiodev_property is called. Boards 3967a2c7da6SMartin Kletzander * that have embedded audio devices can call it from the 3977a2c7da6SMartin Kletzander * machine init function and forward the property to the device. 3987a2c7da6SMartin Kletzander */ 3997a2c7da6SMartin Kletzander char *audiodev; 4007a2c7da6SMartin Kletzander 4013ef96221SMarcel Apfelbaum ram_addr_t ram_size; 402c270fb9eSIgor Mammedov ram_addr_t maxram_size; 403c270fb9eSIgor Mammedov uint64_t ram_slots; 40497ec4d21SPaolo Bonzini BootConfiguration boot_config; 4056b1b1440SMarcel Apfelbaum char *kernel_filename; 4066b1b1440SMarcel Apfelbaum char *kernel_cmdline; 4076b1b1440SMarcel Apfelbaum char *initrd_filename; 4086063d4c0SIgor Mammedov const char *cpu_type; 409ac2da55eSEduardo Habkost AccelState *accelerator; 41038690a1cSIgor Mammedov CPUArchIdList *possible_cpus; 411edeeec91SLike Xu CpuTopology smp; 412f6a0d06bSEric Auger struct NVDIMMState *nvdimms_state; 413aa570207STao Xu struct NumaState *numa_state; 41436d20cb2SMarcel Apfelbaum }; 41536d20cb2SMarcel Apfelbaum 416a1c31486SDaniel P. Berrangé /* 417a1c31486SDaniel P. Berrangé * The macros which follow are intended to facilitate the 418a1c31486SDaniel P. Berrangé * definition of versioned machine types, using a somewhat 419a1c31486SDaniel P. Berrangé * similar pattern across targets. 420a1c31486SDaniel P. Berrangé * 421a1c31486SDaniel P. Berrangé * For example, a macro that can be used to define versioned 422a1c31486SDaniel P. Berrangé * 'virt' machine types would look like: 423a1c31486SDaniel P. Berrangé * 424a1c31486SDaniel P. Berrangé * #define DEFINE_VIRT_MACHINE_IMPL(latest, ...) \ 425a1c31486SDaniel P. Berrangé * static void MACHINE_VER_SYM(class_init, virt, __VA_ARGS__)( \ 426a1c31486SDaniel P. Berrangé * ObjectClass *oc, \ 427a1c31486SDaniel P. Berrangé * void *data) \ 428a1c31486SDaniel P. Berrangé * { \ 429a1c31486SDaniel P. Berrangé * MachineClass *mc = MACHINE_CLASS(oc); \ 430a1c31486SDaniel P. Berrangé * MACHINE_VER_SYM(options, virt, __VA_ARGS__)(mc); \ 431a1c31486SDaniel P. Berrangé * mc->desc = "QEMU " MACHINE_VER_STR(__VA_ARGS__) " Virtual Machine"; \ 432a35f8577SDaniel P. Berrangé * MACHINE_VER_DEPRECATION(__VA_ARGS__); \ 433a1c31486SDaniel P. Berrangé * if (latest) { \ 434a1c31486SDaniel P. Berrangé * mc->alias = "virt"; \ 435a1c31486SDaniel P. Berrangé * } \ 436a1c31486SDaniel P. Berrangé * } \ 437a1c31486SDaniel P. Berrangé * static const TypeInfo MACHINE_VER_SYM(info, virt, __VA_ARGS__) = { \ 438a1c31486SDaniel P. Berrangé * .name = MACHINE_VER_TYPE_NAME("virt", __VA_ARGS__), \ 439a1c31486SDaniel P. Berrangé * .parent = TYPE_VIRT_MACHINE, \ 440a1c31486SDaniel P. Berrangé * .class_init = MACHINE_VER_SYM(class_init, virt, __VA_ARGS__), \ 441a1c31486SDaniel P. Berrangé * }; \ 442a1c31486SDaniel P. Berrangé * static void MACHINE_VER_SYM(register, virt, __VA_ARGS__)(void) \ 443a1c31486SDaniel P. Berrangé * { \ 444a35f8577SDaniel P. Berrangé * MACHINE_VER_DELETION(__VA_ARGS__); \ 445a1c31486SDaniel P. Berrangé * type_register_static(&MACHINE_VER_SYM(info, virt, __VA_ARGS__)); \ 446a1c31486SDaniel P. Berrangé * } \ 447a1c31486SDaniel P. Berrangé * type_init(MACHINE_VER_SYM(register, virt, __VA_ARGS__)); 448a1c31486SDaniel P. Berrangé * 449a1c31486SDaniel P. Berrangé * Following this, one (or more) helpers can be added for 450a1c31486SDaniel P. Berrangé * whichever scenarios need to be catered for with a machine: 451a1c31486SDaniel P. Berrangé * 452a1c31486SDaniel P. Berrangé * // Normal 2 digit, marked as latest e.g. 'virt-9.0' 453a1c31486SDaniel P. Berrangé * #define DEFINE_VIRT_MACHINE_LATEST(major, minor) \ 454a1c31486SDaniel P. Berrangé * DEFINE_VIRT_MACHINE_IMPL(true, major, minor) 455a1c31486SDaniel P. Berrangé * 456a1c31486SDaniel P. Berrangé * // Normal 2 digit e.g. 'virt-9.0' 457a1c31486SDaniel P. Berrangé * #define DEFINE_VIRT_MACHINE(major, minor) \ 458a1c31486SDaniel P. Berrangé * DEFINE_VIRT_MACHINE_IMPL(false, major, minor) 459a1c31486SDaniel P. Berrangé * 460a1c31486SDaniel P. Berrangé * // Bugfix 3 digit e.g. 'virt-9.0.1' 461a1c31486SDaniel P. Berrangé * #define DEFINE_VIRT_MACHINE_BUGFIX(major, minor, micro) \ 462a1c31486SDaniel P. Berrangé * DEFINE_VIRT_MACHINE_IMPL(false, major, minor, micro) 463a1c31486SDaniel P. Berrangé * 464a1c31486SDaniel P. Berrangé * // Tagged 2 digit e.g. 'virt-9.0-extra' 465a1c31486SDaniel P. Berrangé * #define DEFINE_VIRT_MACHINE_TAGGED(major, minor, tag) \ 466a1c31486SDaniel P. Berrangé * DEFINE_VIRT_MACHINE_IMPL(false, major, minor, _, tag) 467a1c31486SDaniel P. Berrangé * 468a1c31486SDaniel P. Berrangé * // Tagged bugfix 2 digit e.g. 'virt-9.0.1-extra' 469a1c31486SDaniel P. Berrangé * #define DEFINE_VIRT_MACHINE_TAGGED(major, minor, micro, tag) \ 470a1c31486SDaniel P. Berrangé * DEFINE_VIRT_MACHINE_IMPL(false, major, minor, micro, _, tag) 471a1c31486SDaniel P. Berrangé */ 472a1c31486SDaniel P. Berrangé 473a1c31486SDaniel P. Berrangé /* 474a1c31486SDaniel P. Berrangé * Helper for dispatching different macros based on how 475a1c31486SDaniel P. Berrangé * many __VA_ARGS__ are passed. Supports 1 to 5 variadic 476a1c31486SDaniel P. Berrangé * arguments, with the called target able to be prefixed 477a1c31486SDaniel P. Berrangé * with 0 or more fixed arguments too. To be called thus: 478a1c31486SDaniel P. Berrangé * 479a1c31486SDaniel P. Berrangé * _MACHINE_VER_PICK(__VA_ARGS, 480a1c31486SDaniel P. Berrangé * MACRO_MATCHING_5_ARGS, 481a1c31486SDaniel P. Berrangé * MACRO_MATCHING_4_ARGS, 482a1c31486SDaniel P. Berrangé * MACRO_MATCHING_3_ARGS, 483a1c31486SDaniel P. Berrangé * MACRO_MATCHING_2_ARGS, 484a1c31486SDaniel P. Berrangé * MACRO_MATCHING_1_ARG) (FIXED-ARG-1, 485a1c31486SDaniel P. Berrangé * ..., 486a1c31486SDaniel P. Berrangé * FIXED-ARG-N, 487a1c31486SDaniel P. Berrangé * __VA_ARGS__) 488a1c31486SDaniel P. Berrangé */ 489a1c31486SDaniel P. Berrangé #define _MACHINE_VER_PICK(x1, x2, x3, x4, x5, x6, ...) x6 490a1c31486SDaniel P. Berrangé 491a1c31486SDaniel P. Berrangé /* 492a1c31486SDaniel P. Berrangé * Construct a human targeted machine version string. 493a1c31486SDaniel P. Berrangé * 494a1c31486SDaniel P. Berrangé * Can be invoked with various signatures 495a1c31486SDaniel P. Berrangé * 496a1c31486SDaniel P. Berrangé * MACHINE_VER_STR(sym, prefix, major, minor) 497a1c31486SDaniel P. Berrangé * MACHINE_VER_STR(sym, prefix, major, minor, micro) 498a1c31486SDaniel P. Berrangé * MACHINE_VER_STR(sym, prefix, major, minor, _, tag) 499a1c31486SDaniel P. Berrangé * MACHINE_VER_STR(sym, prefix, major, minor, micro, _, tag) 500a1c31486SDaniel P. Berrangé * 501a1c31486SDaniel P. Berrangé * Respectively emitting symbols with the format 502a1c31486SDaniel P. Berrangé * 503a1c31486SDaniel P. Berrangé * "{major}.{minor}" 504a1c31486SDaniel P. Berrangé * "{major}.{minor}-{tag}" 505a1c31486SDaniel P. Berrangé * "{major}.{minor}.{micro}" 506a1c31486SDaniel P. Berrangé * "{major}.{minor}.{micro}-{tag}" 507a1c31486SDaniel P. Berrangé */ 508a1c31486SDaniel P. Berrangé #define _MACHINE_VER_STR2(major, minor) \ 509a1c31486SDaniel P. Berrangé #major "." #minor 510a1c31486SDaniel P. Berrangé 511a1c31486SDaniel P. Berrangé #define _MACHINE_VER_STR3(major, minor, micro) \ 512a1c31486SDaniel P. Berrangé #major "." #minor "." #micro 513a1c31486SDaniel P. Berrangé 514a1c31486SDaniel P. Berrangé #define _MACHINE_VER_STR4(major, minor, _unused_, tag) \ 515a1c31486SDaniel P. Berrangé #major "." #minor "-" #tag 516a1c31486SDaniel P. Berrangé 517a1c31486SDaniel P. Berrangé #define _MACHINE_VER_STR5(major, minor, micro, _unused_, tag) \ 518a1c31486SDaniel P. Berrangé #major "." #minor "." #micro "-" #tag 519a1c31486SDaniel P. Berrangé 520a1c31486SDaniel P. Berrangé #define MACHINE_VER_STR(...) \ 521a1c31486SDaniel P. Berrangé _MACHINE_VER_PICK(__VA_ARGS__, \ 522a1c31486SDaniel P. Berrangé _MACHINE_VER_STR5, \ 523a1c31486SDaniel P. Berrangé _MACHINE_VER_STR4, \ 524a1c31486SDaniel P. Berrangé _MACHINE_VER_STR3, \ 525a1c31486SDaniel P. Berrangé _MACHINE_VER_STR2) (__VA_ARGS__) 526a1c31486SDaniel P. Berrangé 527a1c31486SDaniel P. Berrangé 528a1c31486SDaniel P. Berrangé /* 529a1c31486SDaniel P. Berrangé * Construct a QAPI type name for a versioned machine 530a1c31486SDaniel P. Berrangé * type 531a1c31486SDaniel P. Berrangé * 532a1c31486SDaniel P. Berrangé * Can be invoked with various signatures 533a1c31486SDaniel P. Berrangé * 534a1c31486SDaniel P. Berrangé * MACHINE_VER_TYPE_NAME(prefix, major, minor) 535a1c31486SDaniel P. Berrangé * MACHINE_VER_TYPE_NAME(prefix, major, minor, micro) 536a1c31486SDaniel P. Berrangé * MACHINE_VER_TYPE_NAME(prefix, major, minor, _, tag) 537a1c31486SDaniel P. Berrangé * MACHINE_VER_TYPE_NAME(prefix, major, minor, micro, _, tag) 538a1c31486SDaniel P. Berrangé * 539a1c31486SDaniel P. Berrangé * Respectively emitting symbols with the format 540a1c31486SDaniel P. Berrangé * 541a1c31486SDaniel P. Berrangé * "{prefix}-{major}.{minor}" 542a1c31486SDaniel P. Berrangé * "{prefix}-{major}.{minor}.{micro}" 543a1c31486SDaniel P. Berrangé * "{prefix}-{major}.{minor}-{tag}" 544a1c31486SDaniel P. Berrangé * "{prefix}-{major}.{minor}.{micro}-{tag}" 545a1c31486SDaniel P. Berrangé */ 546a1c31486SDaniel P. Berrangé #define _MACHINE_VER_TYPE_NAME2(prefix, major, minor) \ 547a1c31486SDaniel P. Berrangé prefix "-" #major "." #minor TYPE_MACHINE_SUFFIX 548a1c31486SDaniel P. Berrangé 549a1c31486SDaniel P. Berrangé #define _MACHINE_VER_TYPE_NAME3(prefix, major, minor, micro) \ 550a1c31486SDaniel P. Berrangé prefix "-" #major "." #minor "." #micro TYPE_MACHINE_SUFFIX 551a1c31486SDaniel P. Berrangé 552a1c31486SDaniel P. Berrangé #define _MACHINE_VER_TYPE_NAME4(prefix, major, minor, _unused_, tag) \ 553a1c31486SDaniel P. Berrangé prefix "-" #major "." #minor "-" #tag TYPE_MACHINE_SUFFIX 554a1c31486SDaniel P. Berrangé 555a1c31486SDaniel P. Berrangé #define _MACHINE_VER_TYPE_NAME5(prefix, major, minor, micro, _unused_, tag) \ 556a1c31486SDaniel P. Berrangé prefix "-" #major "." #minor "." #micro "-" #tag TYPE_MACHINE_SUFFIX 557a1c31486SDaniel P. Berrangé 558a1c31486SDaniel P. Berrangé #define MACHINE_VER_TYPE_NAME(prefix, ...) \ 559a1c31486SDaniel P. Berrangé _MACHINE_VER_PICK(__VA_ARGS__, \ 560a1c31486SDaniel P. Berrangé _MACHINE_VER_TYPE_NAME5, \ 561a1c31486SDaniel P. Berrangé _MACHINE_VER_TYPE_NAME4, \ 562a1c31486SDaniel P. Berrangé _MACHINE_VER_TYPE_NAME3, \ 563a1c31486SDaniel P. Berrangé _MACHINE_VER_TYPE_NAME2) (prefix, __VA_ARGS__) 564a1c31486SDaniel P. Berrangé 565a1c31486SDaniel P. Berrangé /* 566a1c31486SDaniel P. Berrangé * Construct a name for a versioned machine type that is 567a1c31486SDaniel P. Berrangé * suitable for use as a C symbol (function/variable/etc). 568a1c31486SDaniel P. Berrangé * 569a1c31486SDaniel P. Berrangé * Can be invoked with various signatures 570a1c31486SDaniel P. Berrangé * 571a1c31486SDaniel P. Berrangé * MACHINE_VER_SYM(sym, prefix, major, minor) 572a1c31486SDaniel P. Berrangé * MACHINE_VER_SYM(sym, prefix, major, minor, micro) 573a1c31486SDaniel P. Berrangé * MACHINE_VER_SYM(sym, prefix, major, minor, _, tag) 574a1c31486SDaniel P. Berrangé * MACHINE_VER_SYM(sym, prefix, major, minor, micro, _, tag) 575a1c31486SDaniel P. Berrangé * 576a1c31486SDaniel P. Berrangé * Respectively emitting symbols with the format 577a1c31486SDaniel P. Berrangé * 578a1c31486SDaniel P. Berrangé * {prefix}_machine_{major}_{minor}_{sym} 579a1c31486SDaniel P. Berrangé * {prefix}_machine_{major}_{minor}_{micro}_{sym} 580a1c31486SDaniel P. Berrangé * {prefix}_machine_{major}_{minor}_{tag}_{sym} 581a1c31486SDaniel P. Berrangé * {prefix}_machine_{major}_{minor}_{micro}_{tag}_{sym} 582a1c31486SDaniel P. Berrangé */ 583a1c31486SDaniel P. Berrangé #define _MACHINE_VER_SYM2(sym, prefix, major, minor) \ 584a1c31486SDaniel P. Berrangé prefix ## _machine_ ## major ## _ ## minor ## _ ## sym 585a1c31486SDaniel P. Berrangé 586a1c31486SDaniel P. Berrangé #define _MACHINE_VER_SYM3(sym, prefix, major, minor, micro) \ 587a1c31486SDaniel P. Berrangé prefix ## _machine_ ## major ## _ ## minor ## _ ## micro ## _ ## sym 588a1c31486SDaniel P. Berrangé 589a1c31486SDaniel P. Berrangé #define _MACHINE_VER_SYM4(sym, prefix, major, minor, _unused_, tag) \ 590a1c31486SDaniel P. Berrangé prefix ## _machine_ ## major ## _ ## minor ## _ ## tag ## _ ## sym 591a1c31486SDaniel P. Berrangé 592a1c31486SDaniel P. Berrangé #define _MACHINE_VER_SYM5(sym, prefix, major, minor, micro, _unused_, tag) \ 593a1c31486SDaniel P. Berrangé prefix ## _machine_ ## major ## _ ## minor ## _ ## micro ## _ ## tag ## _ ## sym 594a1c31486SDaniel P. Berrangé 595a1c31486SDaniel P. Berrangé #define MACHINE_VER_SYM(sym, prefix, ...) \ 596a1c31486SDaniel P. Berrangé _MACHINE_VER_PICK(__VA_ARGS__, \ 597a1c31486SDaniel P. Berrangé _MACHINE_VER_SYM5, \ 598a1c31486SDaniel P. Berrangé _MACHINE_VER_SYM4, \ 599a1c31486SDaniel P. Berrangé _MACHINE_VER_SYM3, \ 600a1c31486SDaniel P. Berrangé _MACHINE_VER_SYM2) (sym, prefix, __VA_ARGS__) 601a1c31486SDaniel P. Berrangé 602a1c31486SDaniel P. Berrangé 603a35f8577SDaniel P. Berrangé /* 604a35f8577SDaniel P. Berrangé * How many years/major releases for each phase 605a35f8577SDaniel P. Berrangé * of the life cycle. Assumes use of versioning 606a35f8577SDaniel P. Berrangé * scheme where major is bumped each year 607a35f8577SDaniel P. Berrangé */ 608a35f8577SDaniel P. Berrangé #define MACHINE_VER_DELETION_MAJOR 6 609a35f8577SDaniel P. Berrangé #define MACHINE_VER_DEPRECATION_MAJOR 3 610a35f8577SDaniel P. Berrangé 611a35f8577SDaniel P. Berrangé /* 612a35f8577SDaniel P. Berrangé * Expands to a static string containing a deprecation 613a35f8577SDaniel P. Berrangé * message for a versioned machine type 614a35f8577SDaniel P. Berrangé */ 615a35f8577SDaniel P. Berrangé #define MACHINE_VER_DEPRECATION_MSG \ 616a35f8577SDaniel P. Berrangé "machines more than " stringify(MACHINE_VER_DEPRECATION_MAJOR) \ 617a35f8577SDaniel P. Berrangé " years old are subject to deletion after " \ 618a35f8577SDaniel P. Berrangé stringify(MACHINE_VER_DELETION_MAJOR) " years" 619a35f8577SDaniel P. Berrangé 620a35f8577SDaniel P. Berrangé #define _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) \ 621a35f8577SDaniel P. Berrangé (((QEMU_VERSION_MAJOR - major) > cutoff) || \ 622a35f8577SDaniel P. Berrangé (((QEMU_VERSION_MAJOR - major) == cutoff) && \ 623a35f8577SDaniel P. Berrangé (QEMU_VERSION_MINOR - minor) >= 0)) 624a35f8577SDaniel P. Berrangé 625a35f8577SDaniel P. Berrangé #define _MACHINE_VER_IS_EXPIRED2(cutoff, major, minor) \ 626a35f8577SDaniel P. Berrangé _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) 627a35f8577SDaniel P. Berrangé #define _MACHINE_VER_IS_EXPIRED3(cutoff, major, minor, micro) \ 628a35f8577SDaniel P. Berrangé _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) 629a35f8577SDaniel P. Berrangé #define _MACHINE_VER_IS_EXPIRED4(cutoff, major, minor, _unused, tag) \ 630a35f8577SDaniel P. Berrangé _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) 631a35f8577SDaniel P. Berrangé #define _MACHINE_VER_IS_EXPIRED5(cutoff, major, minor, micro, _unused, tag) \ 632a35f8577SDaniel P. Berrangé _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) 633a35f8577SDaniel P. Berrangé 634a35f8577SDaniel P. Berrangé #define _MACHINE_IS_EXPIRED(cutoff, ...) \ 635a35f8577SDaniel P. Berrangé _MACHINE_VER_PICK(__VA_ARGS__, \ 636a35f8577SDaniel P. Berrangé _MACHINE_VER_IS_EXPIRED5, \ 637a35f8577SDaniel P. Berrangé _MACHINE_VER_IS_EXPIRED4, \ 638a35f8577SDaniel P. Berrangé _MACHINE_VER_IS_EXPIRED3, \ 639a35f8577SDaniel P. Berrangé _MACHINE_VER_IS_EXPIRED2) (cutoff, __VA_ARGS__) 640a35f8577SDaniel P. Berrangé 641a35f8577SDaniel P. Berrangé /* 642a35f8577SDaniel P. Berrangé * Evaluates true when a machine type with (major, minor) 643a35f8577SDaniel P. Berrangé * or (major, minor, micro) version should be considered 644a35f8577SDaniel P. Berrangé * deprecated based on the current versioned machine type 645a35f8577SDaniel P. Berrangé * lifecycle rules 646a35f8577SDaniel P. Berrangé */ 647a35f8577SDaniel P. Berrangé #define MACHINE_VER_IS_DEPRECATED(...) \ 648a35f8577SDaniel P. Berrangé _MACHINE_IS_EXPIRED(MACHINE_VER_DEPRECATION_MAJOR, __VA_ARGS__) 649a35f8577SDaniel P. Berrangé 650a35f8577SDaniel P. Berrangé /* 651a35f8577SDaniel P. Berrangé * Evaluates true when a machine type with (major, minor) 652a35f8577SDaniel P. Berrangé * or (major, minor, micro) version should be considered 653a35f8577SDaniel P. Berrangé * for deletion based on the current versioned machine type 654a35f8577SDaniel P. Berrangé * lifecycle rules 655a35f8577SDaniel P. Berrangé */ 656a35f8577SDaniel P. Berrangé #define MACHINE_VER_SHOULD_DELETE(...) \ 657a35f8577SDaniel P. Berrangé _MACHINE_IS_EXPIRED(MACHINE_VER_DELETION_MAJOR, __VA_ARGS__) 658a35f8577SDaniel P. Berrangé 659a35f8577SDaniel P. Berrangé /* 660a35f8577SDaniel P. Berrangé * Sets the deprecation reason for a versioned machine based 661a35f8577SDaniel P. Berrangé * on its age 662a35f8577SDaniel P. Berrangé * 663a35f8577SDaniel P. Berrangé * This must be unconditionally used in the _class_init 664a35f8577SDaniel P. Berrangé * function for all machine types which support versioning. 665a35f8577SDaniel P. Berrangé * 666a35f8577SDaniel P. Berrangé * Initially it will effectively be a no-op, but after a 667a35f8577SDaniel P. Berrangé * suitable period of time has passed, it will set the 668a35f8577SDaniel P. Berrangé * 'deprecation_reason' field on the machine, to warn users 669a35f8577SDaniel P. Berrangé * about forthcoming removal. 670a35f8577SDaniel P. Berrangé */ 671a35f8577SDaniel P. Berrangé #define MACHINE_VER_DEPRECATION(...) \ 672a35f8577SDaniel P. Berrangé do { \ 673a35f8577SDaniel P. Berrangé if (MACHINE_VER_IS_DEPRECATED(__VA_ARGS__)) { \ 674a35f8577SDaniel P. Berrangé mc->deprecation_reason = MACHINE_VER_DEPRECATION_MSG; \ 675a35f8577SDaniel P. Berrangé } \ 676a35f8577SDaniel P. Berrangé } while (0) 677a35f8577SDaniel P. Berrangé 678a35f8577SDaniel P. Berrangé /* 679a35f8577SDaniel P. Berrangé * Prevents registration of a versioned machined based on 680a35f8577SDaniel P. Berrangé * its age 681a35f8577SDaniel P. Berrangé * 682a35f8577SDaniel P. Berrangé * This must be unconditionally used in the register 683a35f8577SDaniel P. Berrangé * method for all machine types which support versioning. 684a35f8577SDaniel P. Berrangé * 685a35f8577SDaniel P. Berrangé * Inijtially it will effectively be a no-op, but after a 686a35f8577SDaniel P. Berrangé * suitable period of time has passed, it will cause 687a35f8577SDaniel P. Berrangé * execution of the method to return, avoiding registration 688a35f8577SDaniel P. Berrangé * of the machine 689*c9fd2d9aSDaniel P. Berrangé * 690*c9fd2d9aSDaniel P. Berrangé * The new deprecation and deletion policy for versioned 691*c9fd2d9aSDaniel P. Berrangé * machine types was introduced in QEMU 9.1.0. 692*c9fd2d9aSDaniel P. Berrangé * 693*c9fd2d9aSDaniel P. Berrangé * Under the new policy a number of old machine types (any 694*c9fd2d9aSDaniel P. Berrangé * prior to 2.12) would be liable for immediate deletion 695*c9fd2d9aSDaniel P. Berrangé * which would be a violation of our historical deprecation 696*c9fd2d9aSDaniel P. Berrangé * and removal policy 697*c9fd2d9aSDaniel P. Berrangé * 698*c9fd2d9aSDaniel P. Berrangé * Thus deletions are temporarily gated on existance of 699*c9fd2d9aSDaniel P. Berrangé * the env variable "QEMU_DELETE_MACHINES" / QEMU version 700*c9fd2d9aSDaniel P. Berrangé * number >= 10.1.0. This gate can be deleted in the 10.1.0 701*c9fd2d9aSDaniel P. Berrangé * dev cycle 702a35f8577SDaniel P. Berrangé */ 703a35f8577SDaniel P. Berrangé #define MACHINE_VER_DELETION(...) \ 704a35f8577SDaniel P. Berrangé do { \ 705a35f8577SDaniel P. Berrangé if (MACHINE_VER_SHOULD_DELETE(__VA_ARGS__)) { \ 706*c9fd2d9aSDaniel P. Berrangé if (getenv("QEMU_DELETE_MACHINES") || \ 707*c9fd2d9aSDaniel P. Berrangé QEMU_VERSION_MAJOR > 10 || (QEMU_VERSION_MAJOR == 10 && \ 708*c9fd2d9aSDaniel P. Berrangé QEMU_VERSION_MINOR >= 1)) { \ 709a35f8577SDaniel P. Berrangé return; \ 710a35f8577SDaniel P. Berrangé } \ 711*c9fd2d9aSDaniel P. Berrangé } \ 712a35f8577SDaniel P. Berrangé } while (0) 713a35f8577SDaniel P. Berrangé 714ed0b6de3SEduardo Habkost #define DEFINE_MACHINE(namestr, machine_initfn) \ 715ed0b6de3SEduardo Habkost static void machine_initfn##_class_init(ObjectClass *oc, void *data) \ 716ed0b6de3SEduardo Habkost { \ 717ed0b6de3SEduardo Habkost MachineClass *mc = MACHINE_CLASS(oc); \ 718ed0b6de3SEduardo Habkost machine_initfn(mc); \ 719ed0b6de3SEduardo Habkost } \ 720ed0b6de3SEduardo Habkost static const TypeInfo machine_initfn##_typeinfo = { \ 721ed0b6de3SEduardo Habkost .name = MACHINE_TYPE_NAME(namestr), \ 722ed0b6de3SEduardo Habkost .parent = TYPE_MACHINE, \ 723ed0b6de3SEduardo Habkost .class_init = machine_initfn##_class_init, \ 724ed0b6de3SEduardo Habkost }; \ 725ed0b6de3SEduardo Habkost static void machine_initfn##_register_types(void) \ 726ed0b6de3SEduardo Habkost { \ 727ed0b6de3SEduardo Habkost type_register_static(&machine_initfn##_typeinfo); \ 728ed0b6de3SEduardo Habkost } \ 7290e6aac87SEduardo Habkost type_init(machine_initfn##_register_types) 730ed0b6de3SEduardo Habkost 73185fa9acdSPaolo Bonzini extern GlobalProperty hw_compat_9_0[]; 73285fa9acdSPaolo Bonzini extern const size_t hw_compat_9_0_len; 73385fa9acdSPaolo Bonzini 7342b10a676SCornelia Huck extern GlobalProperty hw_compat_8_2[]; 7352b10a676SCornelia Huck extern const size_t hw_compat_8_2_len; 7362b10a676SCornelia Huck 73795f5c89eSCornelia Huck extern GlobalProperty hw_compat_8_1[]; 73895f5c89eSCornelia Huck extern const size_t hw_compat_8_1_len; 73995f5c89eSCornelia Huck 7400259dd3eSCornelia Huck extern GlobalProperty hw_compat_8_0[]; 7410259dd3eSCornelia Huck extern const size_t hw_compat_8_0_len; 7420259dd3eSCornelia Huck 743db723c80SCornelia Huck extern GlobalProperty hw_compat_7_2[]; 744db723c80SCornelia Huck extern const size_t hw_compat_7_2_len; 745db723c80SCornelia Huck 746f514e147SCornelia Huck extern GlobalProperty hw_compat_7_1[]; 747f514e147SCornelia Huck extern const size_t hw_compat_7_1_len; 748f514e147SCornelia Huck 7490ca70366SCornelia Huck extern GlobalProperty hw_compat_7_0[]; 7500ca70366SCornelia Huck extern const size_t hw_compat_7_0_len; 7510ca70366SCornelia Huck 75201854af2SCornelia Huck extern GlobalProperty hw_compat_6_2[]; 75301854af2SCornelia Huck extern const size_t hw_compat_6_2_len; 75401854af2SCornelia Huck 75552e64f5bSYanan Wang extern GlobalProperty hw_compat_6_1[]; 75652e64f5bSYanan Wang extern const size_t hw_compat_6_1_len; 75752e64f5bSYanan Wang 758da7e13c0SCornelia Huck extern GlobalProperty hw_compat_6_0[]; 759da7e13c0SCornelia Huck extern const size_t hw_compat_6_0_len; 760da7e13c0SCornelia Huck 761576a00bdSCornelia Huck extern GlobalProperty hw_compat_5_2[]; 762576a00bdSCornelia Huck extern const size_t hw_compat_5_2_len; 763576a00bdSCornelia Huck 7643ff3c5d3SCornelia Huck extern GlobalProperty hw_compat_5_1[]; 7653ff3c5d3SCornelia Huck extern const size_t hw_compat_5_1_len; 7663ff3c5d3SCornelia Huck 767541aaa1dSCornelia Huck extern GlobalProperty hw_compat_5_0[]; 768541aaa1dSCornelia Huck extern const size_t hw_compat_5_0_len; 769541aaa1dSCornelia Huck 7705f258577SEvgeny Yakovlev extern GlobalProperty hw_compat_4_2[]; 7715f258577SEvgeny Yakovlev extern const size_t hw_compat_4_2_len; 7725f258577SEvgeny Yakovlev 7739aec2e52SCornelia Huck extern GlobalProperty hw_compat_4_1[]; 7749aec2e52SCornelia Huck extern const size_t hw_compat_4_1_len; 7759aec2e52SCornelia Huck 7769bf2650bSCornelia Huck extern GlobalProperty hw_compat_4_0[]; 7779bf2650bSCornelia Huck extern const size_t hw_compat_4_0_len; 7789bf2650bSCornelia Huck 779abd93cc7SMarc-André Lureau extern GlobalProperty hw_compat_3_1[]; 780abd93cc7SMarc-André Lureau extern const size_t hw_compat_3_1_len; 781abd93cc7SMarc-André Lureau 782ddb3235dSMarc-André Lureau extern GlobalProperty hw_compat_3_0[]; 783ddb3235dSMarc-André Lureau extern const size_t hw_compat_3_0_len; 784ddb3235dSMarc-André Lureau 7850d47310bSMarc-André Lureau extern GlobalProperty hw_compat_2_12[]; 7860d47310bSMarc-André Lureau extern const size_t hw_compat_2_12_len; 7870d47310bSMarc-André Lureau 78843df70a9SMarc-André Lureau extern GlobalProperty hw_compat_2_11[]; 78943df70a9SMarc-André Lureau extern const size_t hw_compat_2_11_len; 79043df70a9SMarc-André Lureau 791503224f4SMarc-André Lureau extern GlobalProperty hw_compat_2_10[]; 792503224f4SMarc-André Lureau extern const size_t hw_compat_2_10_len; 793503224f4SMarc-André Lureau 7943e803152SMarc-André Lureau extern GlobalProperty hw_compat_2_9[]; 7953e803152SMarc-André Lureau extern const size_t hw_compat_2_9_len; 7963e803152SMarc-André Lureau 797edc24ccdSMarc-André Lureau extern GlobalProperty hw_compat_2_8[]; 798edc24ccdSMarc-André Lureau extern const size_t hw_compat_2_8_len; 799edc24ccdSMarc-André Lureau 8005a995064SMarc-André Lureau extern GlobalProperty hw_compat_2_7[]; 8015a995064SMarc-André Lureau extern const size_t hw_compat_2_7_len; 8025a995064SMarc-André Lureau 803ff8f261fSMarc-André Lureau extern GlobalProperty hw_compat_2_6[]; 804ff8f261fSMarc-André Lureau extern const size_t hw_compat_2_6_len; 805ff8f261fSMarc-André Lureau 806fe759610SMarc-André Lureau extern GlobalProperty hw_compat_2_5[]; 807fe759610SMarc-André Lureau extern const size_t hw_compat_2_5_len; 808fe759610SMarc-André Lureau 8092f99b9c2SMarc-André Lureau extern GlobalProperty hw_compat_2_4[]; 8102f99b9c2SMarc-André Lureau extern const size_t hw_compat_2_4_len; 8112f99b9c2SMarc-André Lureau 8128995dd90SMarc-André Lureau extern GlobalProperty hw_compat_2_3[]; 8138995dd90SMarc-André Lureau extern const size_t hw_compat_2_3_len; 8148995dd90SMarc-André Lureau 8151c30044eSMarc-André Lureau extern GlobalProperty hw_compat_2_2[]; 8161c30044eSMarc-André Lureau extern const size_t hw_compat_2_2_len; 8171c30044eSMarc-André Lureau 818c4fc5695SMarc-André Lureau extern GlobalProperty hw_compat_2_1[]; 819c4fc5695SMarc-André Lureau extern const size_t hw_compat_2_1_len; 820c4fc5695SMarc-André Lureau 8210d09e41aSPaolo Bonzini #endif 822