From nobody Sun Nov 9 20:16:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552058861968570.1711938020653; Fri, 8 Mar 2019 07:27:41 -0800 (PST) Received: from localhost ([127.0.0.1]:45599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2HPN-0002LB-Qb for importer@patchew.org; Fri, 08 Mar 2019 10:27:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2HNR-0001Cm-AT for qemu-devel@nongnu.org; Fri, 08 Mar 2019 10:25:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2HNQ-0003YZ-6E for qemu-devel@nongnu.org; Fri, 08 Mar 2019 10:25:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35656) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2HNN-0003OP-L4; Fri, 08 Mar 2019 10:25:33 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9019C002962; Fri, 8 Mar 2019 15:25:32 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id C20785D704; Fri, 8 Mar 2019 15:25:29 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, imammedo@redhat.com, david@redhat.com, pbonzini@redhat.com, ehabkost@redhat.com, richard.henderson@linaro.org, sbhat@linux.ibm.com, philmd@redhat.com Date: Fri, 8 Mar 2019 16:25:10 +0100 Message-Id: <20190308152511.10882-2-eric.auger@redhat.com> In-Reply-To: <20190308152511.10882-1-eric.auger@redhat.com> References: <20190308152511.10882-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 08 Mar 2019 15:25:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 1/2] nvdimm: Rename AcpiNVDIMMState into NVDIMMState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As we intend to migrate the acpi_nvdimm_state into the base machine with a new dimms_state name, let's also rename the datatype. Signed-off-by: Eric Auger Suggested-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/acpi/nvdimm.c | 18 +++++++++--------- hw/i386/pc.c | 2 +- include/hw/i386/pc.h | 2 +- include/hw/mem/nvdimm.h | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index e53b2cb681..f73cfb9d90 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -382,7 +382,7 @@ nvdimm_build_structure_caps(GArray *structures, uint32_= t capabilities) nfit_caps->capabilities =3D cpu_to_le32(capabilities); } =20 -static GArray *nvdimm_build_device_structure(AcpiNVDIMMState *state) +static GArray *nvdimm_build_device_structure(NVDIMMState *state) { GSList *device_list =3D nvdimm_get_device_list(); GArray *structures =3D g_array_new(false, true /* clear */, 1); @@ -416,7 +416,7 @@ static void nvdimm_init_fit_buffer(NvdimmFitBuffer *fit= _buf) fit_buf->fit =3D g_array_new(false, true /* clear */, 1); } =20 -static void nvdimm_build_fit_buffer(AcpiNVDIMMState *state) +static void nvdimm_build_fit_buffer(NVDIMMState *state) { NvdimmFitBuffer *fit_buf =3D &state->fit_buf; =20 @@ -425,12 +425,12 @@ static void nvdimm_build_fit_buffer(AcpiNVDIMMState *= state) fit_buf->dirty =3D true; } =20 -void nvdimm_plug(AcpiNVDIMMState *state) +void nvdimm_plug(NVDIMMState *state) { nvdimm_build_fit_buffer(state); } =20 -static void nvdimm_build_nfit(AcpiNVDIMMState *state, GArray *table_offset= s, +static void nvdimm_build_nfit(NVDIMMState *state, GArray *table_offsets, GArray *table_data, BIOSLinker *linker) { NvdimmFitBuffer *fit_buf =3D &state->fit_buf; @@ -570,7 +570,7 @@ nvdimm_dsm_no_payload(uint32_t func_ret_status, hwaddr = dsm_mem_addr) #define NVDIMM_QEMU_RSVD_HANDLE_ROOT 0x10000 =20 /* Read FIT data, defined in docs/specs/acpi_nvdimm.txt. */ -static void nvdimm_dsm_func_read_fit(AcpiNVDIMMState *state, NvdimmDsmIn *= in, +static void nvdimm_dsm_func_read_fit(NVDIMMState *state, NvdimmDsmIn *in, hwaddr dsm_mem_addr) { NvdimmFitBuffer *fit_buf =3D &state->fit_buf; @@ -619,7 +619,7 @@ exit: } =20 static void -nvdimm_dsm_handle_reserved_root_method(AcpiNVDIMMState *state, +nvdimm_dsm_handle_reserved_root_method(NVDIMMState *state, NvdimmDsmIn *in, hwaddr dsm_mem_add= r) { switch (in->function) { @@ -863,7 +863,7 @@ nvdimm_dsm_read(void *opaque, hwaddr addr, unsigned siz= e) static void nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { - AcpiNVDIMMState *state =3D opaque; + NVDIMMState *state =3D opaque; NvdimmDsmIn *in; hwaddr dsm_mem_addr =3D val; =20 @@ -925,7 +925,7 @@ void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, D= eviceState *dev) } } =20 -void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *io, +void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io, FWCfgState *fw_cfg, Object *owner) { memory_region_init_io(&state->io_mr, owner, &nvdimm_dsm_ops, state, @@ -1319,7 +1319,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, } =20 void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, - BIOSLinker *linker, AcpiNVDIMMState *state, + BIOSLinker *linker, NVDIMMState *state, uint32_t ram_slots) { GSList *device_list; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 42128183e9..0338dbe9da 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2571,7 +2571,7 @@ static void pc_machine_set_nvdimm_persistence(Object = *obj, const char *value, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(obj); - AcpiNVDIMMState *nvdimm_state =3D &pcms->acpi_nvdimm_state; + NVDIMMState *nvdimm_state =3D &pcms->acpi_nvdimm_state; =20 if (strcmp(value, "cpu") =3D=3D 0) nvdimm_state->persistence =3D 3; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 54222a202d..94fb620d65 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -45,7 +45,7 @@ struct PCMachineState { OnOffAuto vmport; OnOffAuto smm; =20 - AcpiNVDIMMState acpi_nvdimm_state; + NVDIMMState acpi_nvdimm_state; =20 bool acpi_build_enabled; bool smbus_enabled; diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index c5c9b3c7f8..523a9b3d4a 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -123,7 +123,7 @@ struct NvdimmFitBuffer { }; typedef struct NvdimmFitBuffer NvdimmFitBuffer; =20 -struct AcpiNVDIMMState { +struct NVDIMMState { /* detect if NVDIMM support is enabled. */ bool is_enabled; =20 @@ -141,13 +141,13 @@ struct AcpiNVDIMMState { int32_t persistence; char *persistence_string; }; -typedef struct AcpiNVDIMMState AcpiNVDIMMState; +typedef struct NVDIMMState NVDIMMState; =20 -void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *io, +void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io, FWCfgState *fw_cfg, Object *owner); void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, - BIOSLinker *linker, AcpiNVDIMMState *state, + BIOSLinker *linker, NVDIMMState *state, uint32_t ram_slots); -void nvdimm_plug(AcpiNVDIMMState *state); +void nvdimm_plug(NVDIMMState *state); void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev); #endif --=20 2.20.1 From nobody Sun Nov 9 20:16:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155205885700260.316399345042214; Fri, 8 Mar 2019 07:27:37 -0800 (PST) Received: from localhost ([127.0.0.1]:45597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2HPJ-0002HP-Tm for importer@patchew.org; Fri, 08 Mar 2019 10:27:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2HNY-0001Hq-Ne for qemu-devel@nongnu.org; Fri, 08 Mar 2019 10:25:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2HNX-0003tk-6p for qemu-devel@nongnu.org; Fri, 08 Mar 2019 10:25:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2HNT-0003hK-GC; Fri, 08 Mar 2019 10:25:39 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A08CC883B8; Fri, 8 Mar 2019 15:25:38 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 294115D786; Fri, 8 Mar 2019 15:25:32 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, imammedo@redhat.com, david@redhat.com, pbonzini@redhat.com, ehabkost@redhat.com, richard.henderson@linaro.org, sbhat@linux.ibm.com, philmd@redhat.com Date: Fri, 8 Mar 2019 16:25:11 +0100 Message-Id: <20190308152511.10882-3-eric.auger@redhat.com> In-Reply-To: <20190308152511.10882-1-eric.auger@redhat.com> References: <20190308152511.10882-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 08 Mar 2019 15:25:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 2/2] machine: Move nvdimms state into struct MachineState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As NVDIMM support is looming for ARM and SPAPR, let's move the acpi_nvdimm_state to the generic machine struct instead of duplicating the same code in several machines. It is also renamed into nvdimms_state and becomes a pointer. nvdimm and nvdimm-persistence become generic machine options. They become guarded by a nvdimm_supported machine class member. We also add a description for those options. Signed-off-by: Eric Auger Suggested-by: Igor Mammedov --- v2 -> v3 - nvdimms_state becomes a pointer - add machine class nvdimm_supported v1 -> v2: - s/acpi_nvdimm_state/nvdimms_state - remove ms->nvdimms_state.is_enabled initialization to false. --- hw/core/machine.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 6 ++-- hw/i386/pc.c | 57 ++++---------------------------------- hw/i386/pc_piix.c | 4 +-- hw/i386/pc_q35.c | 4 +-- include/hw/boards.h | 2 ++ include/hw/i386/pc.h | 4 --- 7 files changed, 79 insertions(+), 63 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 766ca5899d..29a33194a9 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -22,6 +22,7 @@ #include "qemu/error-report.h" #include "sysemu/qtest.h" #include "hw/pci/pci.h" +#include "hw/mem/nvdimm.h" =20 GlobalProperty hw_compat_3_1[] =3D { { "pcie-root-port", "x-speed", "2_5" }, @@ -481,6 +482,47 @@ static void machine_set_memory_encryption(Object *obj,= const char *value, ms->memory_encryption =3D g_strdup(value); } =20 +static bool machine_get_nvdimm(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return ms->nvdimms_state->is_enabled; +} + +static void machine_set_nvdimm(Object *obj, bool value, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + ms->nvdimms_state->is_enabled =3D value; +} + +static char *machine_get_nvdimm_persistence(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return g_strdup(ms->nvdimms_state->persistence_string); +} + +static void machine_set_nvdimm_persistence(Object *obj, const char *value, + Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + NVDIMMState *nvdimms_state =3D ms->nvdimms_state; + + if (strcmp(value, "cpu") =3D=3D 0) { + nvdimms_state->persistence =3D 3; + } else if (strcmp(value, "mem-ctrl") =3D=3D 0) { + nvdimms_state->persistence =3D 2; + } else { + error_setg(errp, "-machine nvdimm-persistence=3D%s: unsupported op= tion", + value); + return; + } + + g_free(nvdimms_state->persistence_string); + nvdimms_state->persistence_string =3D g_strdup(value); +} + void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type) { strList *item =3D g_new0(strList, 1); @@ -791,6 +833,28 @@ static void machine_initfn(Object *obj) ms->mem_merge =3D true; ms->enable_graphics =3D true; =20 + if (mc->nvdimm_supported) { + ObjectClass *oc =3D OBJECT_CLASS(mc); + + ms->nvdimms_state =3D g_new0(NVDIMMState, 1); + object_class_property_add_bool(oc, "nvdimm", + machine_get_nvdimm, machine_set_nvd= imm, + &error_abort); + object_class_property_set_description(oc, "nvdimm", + "Set on/off to enable/disable= " + "NVDIMM instantiation", NULL); + + object_class_property_add_str(oc, "nvdimm-persistence", + machine_get_nvdimm_persistence, + machine_set_nvdimm_persistence, + &error_abort); + object_class_property_set_description(oc, "nvdimm-persistence", + "Set NVDIMM persistence" + "Valid values are cpu, mem-ct= rl", + NULL); + } + + /* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify =3D machine_init_notify; qemu_add_machine_init_done_notifier(&ms->sysbus_notifier); @@ -809,6 +873,7 @@ static void machine_finalize(Object *obj) g_free(ms->dt_compatible); g_free(ms->firmware); g_free(ms->device_memory); + g_free(ms->nvdimms_state); } =20 bool machine_usb(MachineState *machine) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9ecc96dcc7..416da318ae 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1867,7 +1867,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, aml_append(scope, method); } =20 - if (pcms->acpi_nvdimm_state.is_enabled) { + if (machine->nvdimms_state->is_enabled) { method =3D aml_method("_E04", 0, AML_NOTSERIALIZED); aml_append(method, aml_notify(aml_name("\\_SB.NVDR"), aml_int(0x80))); @@ -2704,9 +2704,9 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) build_dmar_q35(tables_blob, tables->linker); } } - if (pcms->acpi_nvdimm_state.is_enabled) { + if (machine->nvdimms_state->is_enabled) { nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, - &pcms->acpi_nvdimm_state, machine->ram_slots); + machine->nvdimms_state, machine->ram_slots); } =20 /* Add tables supplied by user (if any) */ diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0338dbe9da..71385cfac9 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2069,6 +2069,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, { const PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); const PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + const MachineState *ms =3D MACHINE(hotplug_dev); const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); const uint64_t legacy_align =3D TARGET_PAGE_SIZE; =20 @@ -2083,7 +2084,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, return; } =20 - if (is_nvdimm && !pcms->acpi_nvdimm_state.is_enabled) { + if (is_nvdimm && !ms->nvdimms_state->is_enabled) { error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"= ); return; } @@ -2097,6 +2098,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_de= v, { Error *local_err =3D NULL; PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); + MachineState *ms =3D MACHINE(hotplug_dev); bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 pc_dimm_plug(PC_DIMM(dev), MACHINE(pcms), &local_err); @@ -2105,7 +2107,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_de= v, } =20 if (is_nvdimm) { - nvdimm_plug(&pcms->acpi_nvdimm_state); + nvdimm_plug(ms->nvdimms_state); } =20 hotplug_handler_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &error_abor= t); @@ -2546,47 +2548,6 @@ static void pc_machine_set_smm(Object *obj, Visitor = *v, const char *name, visit_type_OnOffAuto(v, name, &pcms->smm, errp); } =20 -static bool pc_machine_get_nvdimm(Object *obj, Error **errp) -{ - PCMachineState *pcms =3D PC_MACHINE(obj); - - return pcms->acpi_nvdimm_state.is_enabled; -} - -static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp) -{ - PCMachineState *pcms =3D PC_MACHINE(obj); - - pcms->acpi_nvdimm_state.is_enabled =3D value; -} - -static char *pc_machine_get_nvdimm_persistence(Object *obj, Error **errp) -{ - PCMachineState *pcms =3D PC_MACHINE(obj); - - return g_strdup(pcms->acpi_nvdimm_state.persistence_string); -} - -static void pc_machine_set_nvdimm_persistence(Object *obj, const char *val= ue, - Error **errp) -{ - PCMachineState *pcms =3D PC_MACHINE(obj); - NVDIMMState *nvdimm_state =3D &pcms->acpi_nvdimm_state; - - if (strcmp(value, "cpu") =3D=3D 0) - nvdimm_state->persistence =3D 3; - else if (strcmp(value, "mem-ctrl") =3D=3D 0) - nvdimm_state->persistence =3D 2; - else { - error_setg(errp, "-machine nvdimm-persistence=3D%s: unsupported op= tion", - value); - return; - } - - g_free(nvdimm_state->persistence_string); - nvdimm_state->persistence_string =3D g_strdup(value); -} - static bool pc_machine_get_smbus(Object *obj, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(obj); @@ -2636,8 +2597,6 @@ static void pc_machine_initfn(Object *obj) pcms->max_ram_below_4g =3D 0; /* use default */ pcms->smm =3D ON_OFF_AUTO_AUTO; pcms->vmport =3D ON_OFF_AUTO_AUTO; - /* nvdimm is disabled on default. */ - pcms->acpi_nvdimm_state.is_enabled =3D false; /* acpi build is enabled by default if machine supports it */ pcms->acpi_build_enabled =3D PC_MACHINE_GET_CLASS(pcms)->has_acpi_buil= d; pcms->smbus_enabled =3D true; @@ -2774,6 +2733,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) hc->unplug =3D pc_machine_device_unplug_cb; nc->nmi_monitor_handler =3D x86_nmi; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; + mc->nvdimm_supported =3D true; =20 object_class_property_add(oc, PC_MACHINE_DEVMEM_REGION_SIZE, "int", pc_machine_get_device_memory_region_size, NULL, @@ -2798,13 +2758,6 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *data) object_class_property_set_description(oc, PC_MACHINE_VMPORT, "Enable vmport (pc & q35)", &error_abort); =20 - object_class_property_add_bool(oc, PC_MACHINE_NVDIMM, - pc_machine_get_nvdimm, pc_machine_set_nvdimm, &error_abort); - - object_class_property_add_str(oc, PC_MACHINE_NVDIMM_PERSIST, - pc_machine_get_nvdimm_persistence, - pc_machine_set_nvdimm_persistence, &error_abort); - object_class_property_add_bool(oc, PC_MACHINE_SMBUS, pc_machine_get_smbus, pc_machine_set_smbus, &error_abort); =20 diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 8770ecada9..8ad8e885c6 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -297,8 +297,8 @@ static void pc_init1(MachineState *machine, PC_MACHINE_ACPI_DEVICE_PROP, &error_abort= ); } =20 - if (pcms->acpi_nvdimm_state.is_enabled) { - nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, + if (machine->nvdimms_state->is_enabled) { + nvdimm_init_acpi_state(machine->nvdimms_state, system_io, pcms->fw_cfg, OBJECT(pcms)); } } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index cfb9043e12..372c6b73be 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -329,8 +329,8 @@ static void pc_q35_init(MachineState *machine) pc_vga_init(isa_bus, host_bus); pc_nic_init(pcmc, isa_bus, host_bus); =20 - if (pcms->acpi_nvdimm_state.is_enabled) { - nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, + if (machine->nvdimms_state->is_enabled) { + nvdimm_init_acpi_state(machine->nvdimms_state, system_io, pcms->fw_cfg, OBJECT(pcms)); } } diff --git a/include/hw/boards.h b/include/hw/boards.h index 9690c71a6d..e231860666 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -210,6 +210,7 @@ struct MachineClass { int nb_nodes, ram_addr_t size); bool ignore_boot_device_suffixes; bool smbus_no_migration_support; + bool nvdimm_supported; =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); @@ -272,6 +273,7 @@ struct MachineState { const char *cpu_type; AccelState *accelerator; CPUArchIdList *possible_cpus; + struct NVDIMMState *nvdimms_state; }; =20 #define DEFINE_MACHINE(namestr, machine_initfn) \ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 94fb620d65..263a6343ff 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -45,8 +45,6 @@ struct PCMachineState { OnOffAuto vmport; OnOffAuto smm; =20 - NVDIMMState acpi_nvdimm_state; - bool acpi_build_enabled; bool smbus_enabled; bool sata_enabled; @@ -74,8 +72,6 @@ struct PCMachineState { #define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" #define PC_MACHINE_VMPORT "vmport" #define PC_MACHINE_SMM "smm" -#define PC_MACHINE_NVDIMM "nvdimm" -#define PC_MACHINE_NVDIMM_PERSIST "nvdimm-persistence" #define PC_MACHINE_SMBUS "smbus" #define PC_MACHINE_SATA "sata" #define PC_MACHINE_PIT "pit" --=20 2.20.1