On 01/13/17 13:17 +0000, Stefan Hajnoczi wrote:
On Fri, Jan 13, 2017 at 07:56:51PM +0800, Haozhong Zhang wrote:
The missing of 'nvdimm' in the machine type option '-M' means NVDIMM
is disabled. QEMU should refuse to plug any NVDIMM device in this case
and report the misconfiguration.

Reported-by: Stefan Hajnoczi <stefa...@redhat.com>
Signed-off-by: Haozhong Zhang <haozhong.zh...@intel.com>
Message-Id: 20170112110928.GF4621@stefanha-x1.localdomain
Message-Id: 20170111093630.2088-1-stefa...@redhat.com
 hw/i386/pc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 25e8586..3907609 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1715,6 +1715,11 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,

     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
+        if (!pcms->acpi_nvdimm_state.is_enabled) {
+            error_setg(&local_err,
+                       "nvdimm is not enabled: missing 'nvdimm' in '-M'");
+            goto out;
+        }

A warning is definitely useful to notify users of a possible
configuration error.

If NVDIMM is plugged at boot time, QEMU with this patch will stop and report a
message like
   qemu-system-x86_64: -device nvdimm,...: nvdimm is not enabled: missing 
'nvdimm' in '-M'

If NVDIMM is plugged via 'device_add' command, QEMU with this patch will report 
a warning message
   nvdimm is not enabled: missing 'nvdimm' in '-M'
and continue to run w/o plugging this device.

I wonder what happens when you plug an NVDIMM into a motherboard where
the firmware lacks support.  Does it:
* Refuse to boot?
* Treat the DIMM as regular RAM?
* Boot but the DIMM will not be used by firmware and kernel?

Good question. Guangrong, any idea?


QEMU should act the same way as real hardware.


Reply via email to