diff mbox series

[10/13] microvm/acpi: add rtc

Message ID 20200319080117.7725-11-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series microvm: add acpi support | expand

Commit Message

Gerd Hoffmann March 19, 2020, 8:01 a.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/i386/microvm.h | 3 +++
 hw/i386/acpi-build.c      | 3 +++
 hw/i386/microvm.c         | 5 ++---
 3 files changed, 8 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h
index da2852a70195..53b2457db752 100644
--- a/include/hw/i386/microvm.h
+++ b/include/hw/i386/microvm.h
@@ -57,6 +57,9 @@  typedef struct {
     bool option_roms;
     bool auto_kernel_cmdline;
 
+    /* built-in devices */
+    ISADevice *rtc_state;
+
     /* Machine state */
     bool kernel_cmdline_fixed;
     Notifier machine_done;
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 80844db24d6b..928e0ee2deeb 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2815,6 +2815,9 @@  build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,
     build_dbg_aml(dsdt);
 
     sb_scope = aml_scope("_SB");
+    if (mms->rtc_state) {
+        aml_append(sb_scope, build_rtc_device_aml());
+    }
     acpi_dsdt_add_fw_cfg(sb_scope, OBJECT(x86ms->fw_cfg));
     acpi_dsdt_add_virtio(sb_scope);
     aml_append(dsdt, sb_scope);
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index fd753764fc10..748f9826fb0e 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -101,7 +101,6 @@  static void microvm_devices_init(MicrovmMachineState *mms)
 {
     X86MachineState *x86ms = X86_MACHINE(mms);
     ISABus *isa_bus;
-    ISADevice *rtc_state;
     GSIState *gsi_state;
     int i;
 
@@ -155,8 +154,8 @@  static void microvm_devices_init(MicrovmMachineState *mms)
 
     if (mms->rtc == ON_OFF_AUTO_ON ||
         (mms->rtc == ON_OFF_AUTO_AUTO && !kvm_enabled())) {
-        rtc_state = mc146818_rtc_init(isa_bus, 2000, NULL);
-        microvm_set_rtc(mms, rtc_state);
+        mms->rtc_state = mc146818_rtc_init(isa_bus, 2000, NULL);
+        microvm_set_rtc(mms, mms->rtc_state);
     }
 
     if (mms->isa_serial) {