From nobody Tue Nov 4 15:26:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15302177147061013.8904041794641; Thu, 28 Jun 2018 13:28:34 -0700 (PDT) Received: from localhost ([::1]:38400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdWs-0001BY-0D for importer@patchew.org; Thu, 28 Jun 2018 16:28:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAf-0007H6-G4 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAe-0000Xq-0d for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:37 -0400 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:42008) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAd-0000Vm-Po for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:35 -0400 Received: by mail-wr0-x22c.google.com with SMTP id p1-v6so6689122wrs.9 for ; Thu, 28 Jun 2018 13:05:35 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3sDzIljycktkXNbH2ZEzSM90tNHYtaUKt5pi1OAYcJw=; b=o6oqyXyoFfjXezbzJWHc+StrGW7SmXSQwDMOYB574XMh+qzX9kIi5wcb8xR+Nn/tVu pcEqz2WzYyBDUfAi9Ob18WhPiO1djDPHpVAKu+lyKmu8RfXcDq4SiZKPJRG6wxZbUWRI cD2tomGmb8u06hTf1Tn6kEL9j0h4rAw01nQNcb+FdMliqN0Y89IpCmW3EZcpLpF7GwAI lQ8CuYU2+4zp4fY+VxitugAtp44qtdcN+22PjPgs+WaZj9Pz3DBWNfIQwlyi7tvojCmK OuWxfIWiBkbauQZl3gm1cDr2CHQZn8IAtcJfZsqDPErTlK7clR4NqJYvobO8kPUggHAP YKew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3sDzIljycktkXNbH2ZEzSM90tNHYtaUKt5pi1OAYcJw=; b=DVy7iRovwEzWHUiEwoZ7Ka0bh8BVXyZmYQE3rzBXTWEiX6hzbQxpdKxeiCPNvh9O8U cKCJoA8wAx1TchRszM/+w4RjV1IcR2wBQYyBxyNoOUwhNGEQaACENE0qCfVNAW4WAicD uKcmqqEVgOmmC1BEWNlNfDMplLi5NSe+b33Kwu2I470OwE5kSQgiweYkoagslmi54fTM xuoFvwyAFn9f/EAnJI10rGK4a+tbcuXsQPQ+BwxNCdy4aVoEvM3gZDIu8S/bPEJAKBDF S0tJWrWN6a4Bsx4r+weC2L7fEWZOYbGiLbFqE3WcbQ6NCKircgano38TW+tZJHNSz7Zs DYkg== X-Gm-Message-State: APt69E3zKC8hQsjN++fEDXhyO9CP0/V87gULyLqlRmlT521L1ErEdraE wahp7C3zXlVOkehXmiUZTSPpcQOW X-Google-Smtp-Source: AAOMgpcTOJMvKNrallDyHLohXgXk9EL0wXZmd7zgc221Hl5D3wZWuEl0x9+ges7Eo3SljH10fH1lvg== X-Received: by 2002:adf:9d93:: with SMTP id p19-v6mr10149294wre.12.1530216334530; Thu, 28 Jun 2018 13:05:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:31 +0200 Message-Id: <1530216310-52873-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22c Subject: [Qemu-devel] [PULL 21/60] pc: factor out pc specific dimm checks into pc_memory_pre_plug() 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: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We can perform these checks before the device is actually realized. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-6-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f23133f..2db032a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1674,6 +1674,29 @@ void ioapic_init_gsi(GSIState *gsi_state, const char= *parent_name) } } =20 +static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, + Error **errp) +{ + const PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); + const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + + /* + * When -no-acpi is used with Q35 machine type, no ACPI is built, + * but pcms->acpi_dev is still created. Check !acpi_enabled in + * addition to cover this case. + */ + if (!pcms->acpi_dev || !acpi_enabled) { + error_setg(errp, + "memory hotplug is not enabled: missing acpi device or = acpi disabled"); + return; + } + + if (is_nvdimm && !pcms->acpi_nvdimm_state.is_enabled) { + error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"= ); + return; + } +} + static void pc_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1696,23 +1719,6 @@ static void pc_memory_plug(HotplugHandler *hotplug_d= ev, align =3D memory_region_get_alignment(mr); } =20 - /* - * When -no-acpi is used with Q35 machine type, no ACPI is built, - * but pcms->acpi_dev is still created. Check !acpi_enabled in - * addition to cover this case. - */ - if (!pcms->acpi_dev || !acpi_enabled) { - error_setg(&local_err, - "memory hotplug is not enabled: missing acpi device or = acpi disabled"); - goto out; - } - - if (is_nvdimm && !pcms->acpi_nvdimm_state.is_enabled) { - error_setg(&local_err, - "nvdimm is not enabled: missing 'nvdimm' in '-M'"); - goto out; - } - pc_dimm_plug(dev, MACHINE(pcms), align, &local_err); if (local_err) { goto out; @@ -2006,7 +2012,9 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + pc_memory_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_pre_plug(hotplug_dev, dev, errp); } } --=20 1.8.3.1