xref: /openbmc/qemu/hw/i386/microvm.c (revision 5de5b99b)
1 /*
2  * Copyright (c) 2018 Intel Corporation
3  * Copyright (c) 2019 Red Hat, Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2 or later, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "qemu/osdep.h"
19 #include "qemu/error-report.h"
20 #include "qemu/cutils.h"
21 #include "qemu/units.h"
22 #include "qapi/error.h"
23 #include "qapi/visitor.h"
24 #include "qapi/qapi-visit-common.h"
25 #include "sysemu/sysemu.h"
26 #include "sysemu/cpus.h"
27 #include "sysemu/numa.h"
28 #include "sysemu/reset.h"
29 #include "sysemu/runstate.h"
30 #include "acpi-microvm.h"
31 
32 #include "hw/loader.h"
33 #include "hw/irq.h"
34 #include "hw/kvm/clock.h"
35 #include "hw/i386/microvm.h"
36 #include "hw/i386/x86.h"
37 #include "target/i386/cpu.h"
38 #include "hw/intc/i8259.h"
39 #include "hw/timer/i8254.h"
40 #include "hw/rtc/mc146818rtc.h"
41 #include "hw/char/serial.h"
42 #include "hw/display/ramfb.h"
43 #include "hw/i386/topology.h"
44 #include "hw/i386/e820_memory_layout.h"
45 #include "hw/i386/fw_cfg.h"
46 #include "hw/virtio/virtio-mmio.h"
47 #include "hw/acpi/acpi.h"
48 #include "hw/acpi/generic_event_device.h"
49 
50 #include "cpu.h"
51 #include "elf.h"
52 #include "kvm_i386.h"
53 #include "hw/xen/start_info.h"
54 
55 #define MICROVM_QBOOT_FILENAME "qboot.rom"
56 #define MICROVM_BIOS_FILENAME  "bios-microvm.bin"
57 
58 static void microvm_set_rtc(MicrovmMachineState *mms, ISADevice *s)
59 {
60     X86MachineState *x86ms = X86_MACHINE(mms);
61     int val;
62 
63     val = MIN(x86ms->below_4g_mem_size / KiB, 640);
64     rtc_set_memory(s, 0x15, val);
65     rtc_set_memory(s, 0x16, val >> 8);
66     /* extended memory (next 64MiB) */
67     if (x86ms->below_4g_mem_size > 1 * MiB) {
68         val = (x86ms->below_4g_mem_size - 1 * MiB) / KiB;
69     } else {
70         val = 0;
71     }
72     if (val > 65535) {
73         val = 65535;
74     }
75     rtc_set_memory(s, 0x17, val);
76     rtc_set_memory(s, 0x18, val >> 8);
77     rtc_set_memory(s, 0x30, val);
78     rtc_set_memory(s, 0x31, val >> 8);
79     /* memory between 16MiB and 4GiB */
80     if (x86ms->below_4g_mem_size > 16 * MiB) {
81         val = (x86ms->below_4g_mem_size - 16 * MiB) / (64 * KiB);
82     } else {
83         val = 0;
84     }
85     if (val > 65535) {
86         val = 65535;
87     }
88     rtc_set_memory(s, 0x34, val);
89     rtc_set_memory(s, 0x35, val >> 8);
90     /* memory above 4GiB */
91     val = x86ms->above_4g_mem_size / 65536;
92     rtc_set_memory(s, 0x5b, val);
93     rtc_set_memory(s, 0x5c, val >> 8);
94     rtc_set_memory(s, 0x5d, val >> 16);
95 }
96 
97 static void microvm_gsi_handler(void *opaque, int n, int level)
98 {
99     GSIState *s = opaque;
100 
101     qemu_set_irq(s->ioapic_irq[n], level);
102 }
103 
104 static void microvm_devices_init(MicrovmMachineState *mms)
105 {
106     X86MachineState *x86ms = X86_MACHINE(mms);
107     ISABus *isa_bus;
108     ISADevice *rtc_state;
109     GSIState *gsi_state;
110     int i;
111 
112     /* Core components */
113 
114     gsi_state = g_malloc0(sizeof(*gsi_state));
115     if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) {
116         x86ms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
117     } else {
118         x86ms->gsi = qemu_allocate_irqs(microvm_gsi_handler,
119                                         gsi_state, GSI_NUM_PINS);
120     }
121 
122     isa_bus = isa_bus_new(NULL, get_system_memory(), get_system_io(),
123                           &error_abort);
124     isa_bus_irqs(isa_bus, x86ms->gsi);
125 
126     ioapic_init_gsi(gsi_state, "machine");
127 
128     kvmclock_create();
129 
130     mms->virtio_irq_base = x86_machine_is_acpi_enabled(x86ms) ? 16 : 5;
131     for (i = 0; i < VIRTIO_NUM_TRANSPORTS; i++) {
132         sysbus_create_simple("virtio-mmio",
133                              VIRTIO_MMIO_BASE + i * 512,
134                              x86ms->gsi[mms->virtio_irq_base + i]);
135     }
136 
137     /* Optional and legacy devices */
138     if (x86_machine_is_acpi_enabled(x86ms)) {
139         DeviceState *dev = qdev_new(TYPE_ACPI_GED_X86);
140         qdev_prop_set_uint32(dev, "ged-event", ACPI_GED_PWR_DOWN_EVT);
141         sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, GED_MMIO_BASE);
142         /* sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, GED_MMIO_BASE_MEMHP); */
143         sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, GED_MMIO_BASE_REGS);
144         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
145                            x86ms->gsi[GED_MMIO_IRQ]);
146         sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
147         x86ms->acpi_dev = HOTPLUG_HANDLER(dev);
148     }
149 
150     if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) {
151         qemu_irq *i8259;
152 
153         i8259 = i8259_init(isa_bus, x86_allocate_cpu_irq());
154         for (i = 0; i < ISA_NUM_IRQS; i++) {
155             gsi_state->i8259_irq[i] = i8259[i];
156         }
157         g_free(i8259);
158     }
159 
160     if (mms->pit == ON_OFF_AUTO_ON || mms->pit == ON_OFF_AUTO_AUTO) {
161         if (kvm_pit_in_kernel()) {
162             kvm_pit_init(isa_bus, 0x40);
163         } else {
164             i8254_pit_init(isa_bus, 0x40, 0, NULL);
165         }
166     }
167 
168     if (mms->rtc == ON_OFF_AUTO_ON ||
169         (mms->rtc == ON_OFF_AUTO_AUTO && !kvm_enabled())) {
170         rtc_state = mc146818_rtc_init(isa_bus, 2000, NULL);
171         microvm_set_rtc(mms, rtc_state);
172     }
173 
174     if (mms->isa_serial) {
175         serial_hds_isa_init(isa_bus, 0, 1);
176     }
177 
178     if (bios_name == NULL) {
179         bios_name = x86_machine_is_acpi_enabled(x86ms)
180             ? MICROVM_BIOS_FILENAME
181             : MICROVM_QBOOT_FILENAME;
182     }
183     x86_bios_rom_init(get_system_memory(), true);
184 }
185 
186 static void microvm_memory_init(MicrovmMachineState *mms)
187 {
188     MachineState *machine = MACHINE(mms);
189     X86MachineState *x86ms = X86_MACHINE(mms);
190     MemoryRegion *ram_below_4g, *ram_above_4g;
191     MemoryRegion *system_memory = get_system_memory();
192     FWCfgState *fw_cfg;
193     ram_addr_t lowmem = 0xc0000000; /* 3G */
194     int i;
195 
196     if (machine->ram_size > lowmem) {
197         x86ms->above_4g_mem_size = machine->ram_size - lowmem;
198         x86ms->below_4g_mem_size = lowmem;
199     } else {
200         x86ms->above_4g_mem_size = 0;
201         x86ms->below_4g_mem_size = machine->ram_size;
202     }
203 
204     ram_below_4g = g_malloc(sizeof(*ram_below_4g));
205     memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", machine->ram,
206                              0, x86ms->below_4g_mem_size);
207     memory_region_add_subregion(system_memory, 0, ram_below_4g);
208 
209     e820_add_entry(0, x86ms->below_4g_mem_size, E820_RAM);
210 
211     if (x86ms->above_4g_mem_size > 0) {
212         ram_above_4g = g_malloc(sizeof(*ram_above_4g));
213         memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g",
214                                  machine->ram,
215                                  x86ms->below_4g_mem_size,
216                                  x86ms->above_4g_mem_size);
217         memory_region_add_subregion(system_memory, 0x100000000ULL,
218                                     ram_above_4g);
219         e820_add_entry(0x100000000ULL, x86ms->above_4g_mem_size, E820_RAM);
220     }
221 
222     fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
223                                 &address_space_memory);
224 
225     fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, machine->smp.cpus);
226     fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, machine->smp.max_cpus);
227     fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
228     fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
229     fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
230                      &e820_reserve, sizeof(e820_reserve));
231     fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
232                     sizeof(struct e820_entry) * e820_get_num_entries());
233 
234     rom_set_fw(fw_cfg);
235 
236     if (machine->kernel_filename != NULL) {
237         x86_load_linux(x86ms, fw_cfg, 0, true, true);
238     }
239 
240     if (mms->option_roms) {
241         for (i = 0; i < nb_option_roms; i++) {
242             rom_add_option(option_rom[i].name, option_rom[i].bootindex);
243         }
244     }
245 
246     x86ms->fw_cfg = fw_cfg;
247     x86ms->ioapic_as = &address_space_memory;
248 }
249 
250 static gchar *microvm_get_mmio_cmdline(gchar *name, uint32_t virtio_irq_base)
251 {
252     gchar *cmdline;
253     gchar *separator;
254     long int index;
255     int ret;
256 
257     separator = g_strrstr(name, ".");
258     if (!separator) {
259         return NULL;
260     }
261 
262     if (qemu_strtol(separator + 1, NULL, 10, &index) != 0) {
263         return NULL;
264     }
265 
266     cmdline = g_malloc0(VIRTIO_CMDLINE_MAXLEN);
267     ret = g_snprintf(cmdline, VIRTIO_CMDLINE_MAXLEN,
268                      " virtio_mmio.device=512@0x%lx:%ld",
269                      VIRTIO_MMIO_BASE + index * 512,
270                      virtio_irq_base + index);
271     if (ret < 0 || ret >= VIRTIO_CMDLINE_MAXLEN) {
272         g_free(cmdline);
273         return NULL;
274     }
275 
276     return cmdline;
277 }
278 
279 static void microvm_fix_kernel_cmdline(MachineState *machine)
280 {
281     X86MachineState *x86ms = X86_MACHINE(machine);
282     MicrovmMachineState *mms = MICROVM_MACHINE(machine);
283     BusState *bus;
284     BusChild *kid;
285     char *cmdline;
286 
287     /*
288      * Find MMIO transports with attached devices, and add them to the kernel
289      * command line.
290      *
291      * Yes, this is a hack, but one that heavily improves the UX without
292      * introducing any significant issues.
293      */
294     cmdline = g_strdup(machine->kernel_cmdline);
295     bus = sysbus_get_default();
296     QTAILQ_FOREACH(kid, &bus->children, sibling) {
297         DeviceState *dev = kid->child;
298         ObjectClass *class = object_get_class(OBJECT(dev));
299 
300         if (class == object_class_by_name(TYPE_VIRTIO_MMIO)) {
301             VirtIOMMIOProxy *mmio = VIRTIO_MMIO(OBJECT(dev));
302             VirtioBusState *mmio_virtio_bus = &mmio->bus;
303             BusState *mmio_bus = &mmio_virtio_bus->parent_obj;
304 
305             if (!QTAILQ_EMPTY(&mmio_bus->children)) {
306                 gchar *mmio_cmdline = microvm_get_mmio_cmdline
307                     (mmio_bus->name, mms->virtio_irq_base);
308                 if (mmio_cmdline) {
309                     char *newcmd = g_strjoin(NULL, cmdline, mmio_cmdline, NULL);
310                     g_free(mmio_cmdline);
311                     g_free(cmdline);
312                     cmdline = newcmd;
313                 }
314             }
315         }
316     }
317 
318     fw_cfg_modify_i32(x86ms->fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(cmdline) + 1);
319     fw_cfg_modify_string(x86ms->fw_cfg, FW_CFG_CMDLINE_DATA, cmdline);
320 
321     g_free(cmdline);
322 }
323 
324 static void microvm_device_pre_plug_cb(HotplugHandler *hotplug_dev,
325                                        DeviceState *dev, Error **errp)
326 {
327     x86_cpu_pre_plug(hotplug_dev, dev, errp);
328 }
329 
330 static void microvm_device_plug_cb(HotplugHandler *hotplug_dev,
331                                    DeviceState *dev, Error **errp)
332 {
333     x86_cpu_plug(hotplug_dev, dev, errp);
334 }
335 
336 static void microvm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
337                                              DeviceState *dev, Error **errp)
338 {
339     error_setg(errp, "unplug not supported by microvm");
340 }
341 
342 static void microvm_device_unplug_cb(HotplugHandler *hotplug_dev,
343                                      DeviceState *dev, Error **errp)
344 {
345     error_setg(errp, "unplug not supported by microvm");
346 }
347 
348 static HotplugHandler *microvm_get_hotplug_handler(MachineState *machine,
349                                                    DeviceState *dev)
350 {
351     if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
352         return HOTPLUG_HANDLER(machine);
353     }
354     return NULL;
355 }
356 
357 static void microvm_machine_state_init(MachineState *machine)
358 {
359     MicrovmMachineState *mms = MICROVM_MACHINE(machine);
360     X86MachineState *x86ms = X86_MACHINE(machine);
361     Error *local_err = NULL;
362 
363     microvm_memory_init(mms);
364 
365     x86_cpus_init(x86ms, CPU_VERSION_LATEST);
366     if (local_err) {
367         error_report_err(local_err);
368         exit(1);
369     }
370 
371     microvm_devices_init(mms);
372 }
373 
374 static void microvm_machine_reset(MachineState *machine)
375 {
376     MicrovmMachineState *mms = MICROVM_MACHINE(machine);
377     CPUState *cs;
378     X86CPU *cpu;
379 
380     if (!x86_machine_is_acpi_enabled(X86_MACHINE(machine)) &&
381         machine->kernel_filename != NULL &&
382         mms->auto_kernel_cmdline && !mms->kernel_cmdline_fixed) {
383         microvm_fix_kernel_cmdline(machine);
384         mms->kernel_cmdline_fixed = true;
385     }
386 
387     qemu_devices_reset();
388 
389     CPU_FOREACH(cs) {
390         cpu = X86_CPU(cs);
391 
392         if (cpu->apic_state) {
393             device_legacy_reset(cpu->apic_state);
394         }
395     }
396 }
397 
398 static void microvm_machine_get_pic(Object *obj, Visitor *v, const char *name,
399                                     void *opaque, Error **errp)
400 {
401     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
402     OnOffAuto pic = mms->pic;
403 
404     visit_type_OnOffAuto(v, name, &pic, errp);
405 }
406 
407 static void microvm_machine_set_pic(Object *obj, Visitor *v, const char *name,
408                                     void *opaque, Error **errp)
409 {
410     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
411 
412     visit_type_OnOffAuto(v, name, &mms->pic, errp);
413 }
414 
415 static void microvm_machine_get_pit(Object *obj, Visitor *v, const char *name,
416                                     void *opaque, Error **errp)
417 {
418     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
419     OnOffAuto pit = mms->pit;
420 
421     visit_type_OnOffAuto(v, name, &pit, errp);
422 }
423 
424 static void microvm_machine_set_pit(Object *obj, Visitor *v, const char *name,
425                                     void *opaque, Error **errp)
426 {
427     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
428 
429     visit_type_OnOffAuto(v, name, &mms->pit, errp);
430 }
431 
432 static void microvm_machine_get_rtc(Object *obj, Visitor *v, const char *name,
433                                     void *opaque, Error **errp)
434 {
435     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
436     OnOffAuto rtc = mms->rtc;
437 
438     visit_type_OnOffAuto(v, name, &rtc, errp);
439 }
440 
441 static void microvm_machine_set_rtc(Object *obj, Visitor *v, const char *name,
442                                     void *opaque, Error **errp)
443 {
444     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
445 
446     visit_type_OnOffAuto(v, name, &mms->rtc, errp);
447 }
448 
449 static bool microvm_machine_get_isa_serial(Object *obj, Error **errp)
450 {
451     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
452 
453     return mms->isa_serial;
454 }
455 
456 static void microvm_machine_set_isa_serial(Object *obj, bool value,
457                                            Error **errp)
458 {
459     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
460 
461     mms->isa_serial = value;
462 }
463 
464 static bool microvm_machine_get_option_roms(Object *obj, Error **errp)
465 {
466     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
467 
468     return mms->option_roms;
469 }
470 
471 static void microvm_machine_set_option_roms(Object *obj, bool value,
472                                             Error **errp)
473 {
474     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
475 
476     mms->option_roms = value;
477 }
478 
479 static bool microvm_machine_get_auto_kernel_cmdline(Object *obj, Error **errp)
480 {
481     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
482 
483     return mms->auto_kernel_cmdline;
484 }
485 
486 static void microvm_machine_set_auto_kernel_cmdline(Object *obj, bool value,
487                                                     Error **errp)
488 {
489     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
490 
491     mms->auto_kernel_cmdline = value;
492 }
493 
494 static void microvm_machine_done(Notifier *notifier, void *data)
495 {
496     MicrovmMachineState *mms = container_of(notifier, MicrovmMachineState,
497                                             machine_done);
498 
499     acpi_setup_microvm(mms);
500 }
501 
502 static void microvm_powerdown_req(Notifier *notifier, void *data)
503 {
504     MicrovmMachineState *mms = container_of(notifier, MicrovmMachineState,
505                                             powerdown_req);
506     X86MachineState *x86ms = X86_MACHINE(mms);
507 
508     if (x86ms->acpi_dev) {
509         Object *obj = OBJECT(x86ms->acpi_dev);
510         AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
511         adevc->send_event(ACPI_DEVICE_IF(x86ms->acpi_dev),
512                           ACPI_POWER_DOWN_STATUS);
513     }
514 }
515 
516 static void microvm_machine_initfn(Object *obj)
517 {
518     MicrovmMachineState *mms = MICROVM_MACHINE(obj);
519 
520     /* Configuration */
521     mms->pic = ON_OFF_AUTO_AUTO;
522     mms->pit = ON_OFF_AUTO_AUTO;
523     mms->rtc = ON_OFF_AUTO_AUTO;
524     mms->isa_serial = true;
525     mms->option_roms = true;
526     mms->auto_kernel_cmdline = true;
527 
528     /* State */
529     mms->kernel_cmdline_fixed = false;
530 
531     mms->machine_done.notify = microvm_machine_done;
532     qemu_add_machine_init_done_notifier(&mms->machine_done);
533     mms->powerdown_req.notify = microvm_powerdown_req;
534     qemu_register_powerdown_notifier(&mms->powerdown_req);
535 }
536 
537 static void microvm_class_init(ObjectClass *oc, void *data)
538 {
539     MachineClass *mc = MACHINE_CLASS(oc);
540     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
541 
542     mc->init = microvm_machine_state_init;
543 
544     mc->family = "microvm_i386";
545     mc->desc = "microvm (i386)";
546     mc->units_per_default_bus = 1;
547     mc->no_floppy = 1;
548     mc->max_cpus = 288;
549     mc->has_hotpluggable_cpus = false;
550     mc->auto_enable_numa_with_memhp = false;
551     mc->auto_enable_numa_with_memdev = false;
552     mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
553     mc->nvdimm_supported = false;
554     mc->default_ram_id = "microvm.ram";
555 
556     /* Avoid relying too much on kernel components */
557     mc->default_kernel_irqchip_split = true;
558 
559     /* Machine class handlers */
560     mc->reset = microvm_machine_reset;
561 
562     /* hotplug (for cpu coldplug) */
563     mc->get_hotplug_handler = microvm_get_hotplug_handler;
564     hc->pre_plug = microvm_device_pre_plug_cb;
565     hc->plug = microvm_device_plug_cb;
566     hc->unplug_request = microvm_device_unplug_request_cb;
567     hc->unplug = microvm_device_unplug_cb;
568 
569     object_class_property_add(oc, MICROVM_MACHINE_PIC, "OnOffAuto",
570                               microvm_machine_get_pic,
571                               microvm_machine_set_pic,
572                               NULL, NULL);
573     object_class_property_set_description(oc, MICROVM_MACHINE_PIC,
574         "Enable i8259 PIC");
575 
576     object_class_property_add(oc, MICROVM_MACHINE_PIT, "OnOffAuto",
577                               microvm_machine_get_pit,
578                               microvm_machine_set_pit,
579                               NULL, NULL);
580     object_class_property_set_description(oc, MICROVM_MACHINE_PIT,
581         "Enable i8254 PIT");
582 
583     object_class_property_add(oc, MICROVM_MACHINE_RTC, "OnOffAuto",
584                               microvm_machine_get_rtc,
585                               microvm_machine_set_rtc,
586                               NULL, NULL);
587     object_class_property_set_description(oc, MICROVM_MACHINE_RTC,
588         "Enable MC146818 RTC");
589 
590     object_class_property_add_bool(oc, MICROVM_MACHINE_ISA_SERIAL,
591                                    microvm_machine_get_isa_serial,
592                                    microvm_machine_set_isa_serial);
593     object_class_property_set_description(oc, MICROVM_MACHINE_ISA_SERIAL,
594         "Set off to disable the instantiation an ISA serial port");
595 
596     object_class_property_add_bool(oc, MICROVM_MACHINE_OPTION_ROMS,
597                                    microvm_machine_get_option_roms,
598                                    microvm_machine_set_option_roms);
599     object_class_property_set_description(oc, MICROVM_MACHINE_OPTION_ROMS,
600         "Set off to disable loading option ROMs");
601 
602     object_class_property_add_bool(oc, MICROVM_MACHINE_AUTO_KERNEL_CMDLINE,
603                                    microvm_machine_get_auto_kernel_cmdline,
604                                    microvm_machine_set_auto_kernel_cmdline);
605     object_class_property_set_description(oc,
606         MICROVM_MACHINE_AUTO_KERNEL_CMDLINE,
607         "Set off to disable adding virtio-mmio devices to the kernel cmdline");
608 
609     machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE);
610 }
611 
612 static const TypeInfo microvm_machine_info = {
613     .name          = TYPE_MICROVM_MACHINE,
614     .parent        = TYPE_X86_MACHINE,
615     .instance_size = sizeof(MicrovmMachineState),
616     .instance_init = microvm_machine_initfn,
617     .class_size    = sizeof(MicrovmMachineClass),
618     .class_init    = microvm_class_init,
619     .interfaces = (InterfaceInfo[]) {
620          { TYPE_HOTPLUG_HANDLER },
621          { }
622     },
623 };
624 
625 static void microvm_machine_init(void)
626 {
627     type_register_static(&microvm_machine_info);
628 }
629 type_init(microvm_machine_init);
630