From nobody Sun May 5 21:03:59 2024 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; 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 1529062048363375.1392013371834; Fri, 15 Jun 2018 04:27:28 -0700 (PDT) Received: from localhost ([::1]:45958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmt2-0000qd-AQ for importer@patchew.org; Fri, 15 Jun 2018 07:27:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmqu-0007pE-MG for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmqt-0000if-Gt for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37026 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmqt-0000i0-DN; Fri, 15 Jun 2018 07:25:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02655402312B; Fri, 15 Jun 2018 11:25:11 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2241163AD5; Fri, 15 Jun 2018 11:25:09 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:49 +0200 Message-Id: <20180615112500.19854-2-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 11:25:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 11:25:11 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 01/12] pc-dimm: remove leftover "struct pc_dimms_capacity" 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Not needed anymore, let's drop it. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand --- hw/mem/pc-dimm.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 12da89d562..62b34a992e 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -27,11 +27,6 @@ #include "sysemu/numa.h" #include "trace.h" =20 -typedef struct pc_dimms_capacity { - uint64_t size; - Error **errp; -} pc_dimms_capacity; - void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine, uint64_t align, Error **errp) { --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062254019372.16082342896664; Fri, 15 Jun 2018 04:30:54 -0700 (PDT) Received: from localhost ([::1]:45981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmwP-00043B-8c for importer@patchew.org; Fri, 15 Jun 2018 07:30:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmqw-0007sL-T9 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmqv-0000lL-M2 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:14 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48818 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmqv-0000ks-Hb; Fri, 15 Jun 2018 07:25:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21787401EF39; Fri, 15 Jun 2018 11:25:13 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F59863AF6; Fri, 15 Jun 2018 11:25:11 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:50 +0200 Message-Id: <20180615112500.19854-3-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 11:25:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 11:25:13 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 02/12] pc: rename pc_dimm_(plug|unplug|...)* into pc_memory_(plug|unplug|...)* 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use a similar naming scheme as spapr. This way, we can go ahead and rename e.g. pc_dimm_memory_plug to pc_dimm_plug_plug, which avoids confusion. Signed-off-by: David Hildenbrand Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 622e49d6bc..f9250ffae7 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1674,8 +1674,8 @@ void ioapic_init_gsi(GSIState *gsi_state, const char = *parent_name) } } =20 -static void pc_dimm_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { HotplugHandlerClass *hhc; Error *local_err =3D NULL; @@ -1728,8 +1728,8 @@ out: error_propagate(errp, local_err); } =20 -static void pc_dimm_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_memory_unplug_request(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { HotplugHandlerClass *hhc; Error *local_err =3D NULL; @@ -1759,8 +1759,8 @@ out: error_propagate(errp, local_err); } =20 -static void pc_dimm_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void pc_memory_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); HotplugHandlerClass *hhc; @@ -2015,7 +2015,7 @@ static void pc_machine_device_plug_cb(HotplugHandler = *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_plug(hotplug_dev, dev, errp); + pc_memory_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_plug(hotplug_dev, dev, errp); } @@ -2025,7 +2025,7 @@ static void pc_machine_device_unplug_request_cb(Hotpl= ugHandler *hotplug_dev, DeviceState *dev, Error **= errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_unplug_request(hotplug_dev, dev, errp); + pc_memory_unplug_request(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_unplug_request_cb(hotplug_dev, dev, errp); } else { @@ -2038,7 +2038,7 @@ static void pc_machine_device_unplug_cb(HotplugHandle= r *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_unplug(hotplug_dev, dev, errp); + pc_memory_unplug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_unplug_cb(hotplug_dev, dev, errp); } else { --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062201668877.8099150504715; Fri, 15 Jun 2018 04:30:01 -0700 (PDT) Received: from localhost ([::1]:45973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmvY-0003Cx-VV for importer@patchew.org; Fri, 15 Jun 2018 07:30:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmqz-0007vE-BF for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmqy-0000n9-61 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38754 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmqy-0000mh-1F; Fri, 15 Jun 2018 07:25:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 907478D774; Fri, 15 Jun 2018 11:25:15 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE29863A51; Fri, 15 Jun 2018 11:25:13 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:51 +0200 Message-Id: <20180615112500.19854-4-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 11:25:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 11:25:15 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 03/12] pc-dimm: rename pc_dimm_memory_* to pc_dimm_* 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Let's rename it to make it look more consistent. Signed-off-by: David Hildenbrand Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 4 ++-- hw/mem/pc-dimm.c | 6 +++--- hw/ppc/spapr.c | 6 +++--- include/hw/mem/pc-dimm.h | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f9250ffae7..f23133facc 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1713,7 +1713,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_de= v, goto out; } =20 - pc_dimm_memory_plug(dev, MACHINE(pcms), align, &local_err); + pc_dimm_plug(dev, MACHINE(pcms), align, &local_err); if (local_err) { goto out; } @@ -1773,7 +1773,7 @@ static void pc_memory_unplug(HotplugHandler *hotplug_= dev, goto out; } =20 - pc_dimm_memory_unplug(dev, MACHINE(pcms)); + pc_dimm_unplug(dev, MACHINE(pcms)); object_unparent(OBJECT(dev)); =20 out: diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 62b34a992e..9e0c83e415 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -27,8 +27,8 @@ #include "sysemu/numa.h" #include "trace.h" =20 -void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine, - uint64_t align, Error **errp) +void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, + Error **errp) { int slot; PCDIMMDevice *dimm =3D PC_DIMM(dev); @@ -84,7 +84,7 @@ out: error_propagate(errp, local_err); } =20 -void pc_dimm_memory_unplug(DeviceState *dev, MachineState *machine) +void pc_dimm_unplug(DeviceState *dev, MachineState *machine) { PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f59999daac..3e5320020f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3153,7 +3153,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, align =3D memory_region_get_alignment(mr); size =3D memory_region_size(mr); =20 - pc_dimm_memory_plug(dev, MACHINE(ms), align, &local_err); + pc_dimm_plug(dev, MACHINE(ms), align, &local_err); if (local_err) { goto out; } @@ -3176,7 +3176,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, return; =20 out_unplug: - pc_dimm_memory_unplug(dev, MACHINE(ms)); + pc_dimm_unplug(dev, MACHINE(ms)); out: error_propagate(errp, local_err); } @@ -3328,7 +3328,7 @@ static void spapr_memory_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev) sPAPRMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); sPAPRDIMMState *ds =3D spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(= dev)); =20 - pc_dimm_memory_unplug(dev, MACHINE(hotplug_dev)); + pc_dimm_unplug(dev, MACHINE(hotplug_dev)); object_unparent(OBJECT(dev)); spapr_pending_dimm_unplugs_remove(spapr, ds); } diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 627c8601d9..860343d64f 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -78,7 +78,7 @@ typedef struct PCDIMMDeviceClass { =20 int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp); =20 -void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine, - uint64_t align, Error **errp); -void pc_dimm_memory_unplug(DeviceState *dev, MachineState *machine); +void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, + Error **errp); +void pc_dimm_unplug(DeviceState *dev, MachineState *machine); #endif --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062248438751.6337219385434; Fri, 15 Jun 2018 04:30:48 -0700 (PDT) Received: from localhost ([::1]:45979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmwJ-0003wM-KF for importer@patchew.org; Fri, 15 Jun 2018 07:30:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmr3-0007zT-JU for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmr0-0000p8-9u for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37036 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmr0-0000oW-6B; Fri, 15 Jun 2018 07:25:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB549402312B; Fri, 15 Jun 2018 11:25:17 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBA6363A51; Fri, 15 Jun 2018 11:25:15 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:52 +0200 Message-Id: <20180615112500.19854-5-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 11:25:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 11:25:17 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 04/12] pc-dimm: remove pc_dimm_get_free_slot() from header 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Not used outside of pc-dimm.c and there shouldn't be other users. If other devices ever have to also sue slots, this has to be factored out. Signed-off-by: David Hildenbrand Reviewed-by: Igor Mammedov --- hw/mem/pc-dimm.c | 4 +++- include/hw/mem/pc-dimm.h | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 9e0c83e415..7387963cf1 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -27,6 +27,8 @@ #include "sysemu/numa.h" #include "trace.h" =20 +static int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **e= rrp); + void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, Error **errp) { @@ -111,7 +113,7 @@ static int pc_dimm_slot2bitmap(Object *obj, void *opaqu= e) return 0; } =20 -int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp) +static int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **e= rrp) { unsigned long *bitmap; int slot =3D 0; diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 860343d64f..cf71247630 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -76,8 +76,6 @@ typedef struct PCDIMMDeviceClass { MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm); } PCDIMMDeviceClass; =20 -int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp); - void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, Error **errp); void pc_dimm_unplug(DeviceState *dev, MachineState *machine); --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062055706821.1252897274454; Fri, 15 Jun 2018 04:27:35 -0700 (PDT) Received: from localhost ([::1]:45959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmtC-00010A-Ud for importer@patchew.org; Fri, 15 Jun 2018 07:27:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmr3-0007zV-Ja for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmr2-0000qy-Ej for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38784 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmr2-0000qV-9A; Fri, 15 Jun 2018 07:25:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D89B38D774; Fri, 15 Jun 2018 11:25:19 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02E6963AD5; Fri, 15 Jun 2018 11:25:17 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:53 +0200 Message-Id: <20180615112500.19854-6-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 11:25:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 11:25:19 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 05/12] 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We can perform these checks before the device is actually realized. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand --- 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 f23133facc..2db032a6df 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 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062222669486.4966813898591; Fri, 15 Jun 2018 04:30:22 -0700 (PDT) Received: from localhost ([::1]:45974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmvu-0003Ut-07 for importer@patchew.org; Fri, 15 Jun 2018 07:30:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmr5-0007zh-IY for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmr4-0000sM-HF for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38794 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmr4-0000s2-Cg; Fri, 15 Jun 2018 07:25:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02D178D77D; Fri, 15 Jun 2018 11:25:22 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FC7563AF6; Fri, 15 Jun 2018 11:25:19 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:54 +0200 Message-Id: <20180615112500.19854-7-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 11:25:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 11:25:22 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 06/12] hostmem: drop error variable from host_memory_backend_get_memory() 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Unused, so let's remove it. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand --- backends/hostmem.c | 3 +-- hw/mem/nvdimm.c | 4 ++-- hw/mem/pc-dimm.c | 4 ++-- hw/misc/ivshmem.c | 3 +-- include/sysemu/hostmem.h | 3 +-- numa.c | 3 +-- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 3627e61584..4908946cd3 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -247,8 +247,7 @@ bool host_memory_backend_mr_inited(HostMemoryBackend *b= ackend) return memory_region_size(&backend->mr) !=3D 0; } =20 -MemoryRegion * -host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp) +MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend) { return host_memory_backend_mr_inited(backend) ? &backend->mr : NULL; } diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 4087aca25e..37e19044d6 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -105,7 +105,7 @@ static MemoryRegion *nvdimm_get_memory_region(PCDIMMDev= ice *dimm, Error **errp) =20 static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp) { - MemoryRegion *mr =3D host_memory_backend_get_memory(dimm->hostmem, err= p); + MemoryRegion *mr =3D host_memory_backend_get_memory(dimm->hostmem); NVDIMMDevice *nvdimm =3D NVDIMM(dimm); uint64_t align, pmem_size, size =3D memory_region_size(mr); =20 @@ -161,7 +161,7 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvdim= m, const void *buf, =20 memcpy(nvdimm->label_data + offset, buf, size); =20 - mr =3D host_memory_backend_get_memory(dimm->hostmem, &error_abort); + mr =3D host_memory_backend_get_memory(dimm->hostmem); backend_offset =3D memory_region_size(mr) - nvdimm->label_size + offse= t; memory_region_set_dirty(mr, backend_offset, size); } diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 7387963cf1..73f0eee4c7 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -226,12 +226,12 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMM= Device *dimm, Error **errp) return NULL; } =20 - return host_memory_backend_get_memory(dimm->hostmem, errp); + return host_memory_backend_get_memory(dimm->hostmem); } =20 static MemoryRegion *pc_dimm_get_vmstate_memory_region(PCDIMMDevice *dimm) { - return host_memory_backend_get_memory(dimm->hostmem, &error_abort); + return host_memory_backend_get_memory(dimm->hostmem); } =20 static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 16f03701b7..ee01c5e66b 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -909,8 +909,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Erro= r **errp) if (s->hostmem !=3D NULL) { IVSHMEM_DPRINTF("using hostmem\n"); =20 - s->ivshmem_bar2 =3D host_memory_backend_get_memory(s->hostmem, - &error_abort); + s->ivshmem_bar2 =3D host_memory_backend_get_memory(s->hostmem); } else { Chardev *chr =3D qemu_chr_fe_get_driver(&s->server_chr); assert(chr); diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 5beb0ef8ab..6e6bd2c1cb 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -62,8 +62,7 @@ struct HostMemoryBackend { }; =20 bool host_memory_backend_mr_inited(HostMemoryBackend *backend); -MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend, - Error **errp); +MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend); =20 void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mappe= d); bool host_memory_backend_is_mapped(HostMemoryBackend *backend); diff --git a/numa.c b/numa.c index 33572bfa74..94f758c757 100644 --- a/numa.c +++ b/numa.c @@ -523,8 +523,7 @@ void memory_region_allocate_system_memory(MemoryRegion = *mr, Object *owner, if (!backend) { continue; } - MemoryRegion *seg =3D host_memory_backend_get_memory(backend, - &error_fatal); + MemoryRegion *seg =3D host_memory_backend_get_memory(backend); =20 if (memory_region_is_mapped(seg)) { char *path =3D object_get_canonical_path_component(OBJECT(back= end)); --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062447126359.3002799246681; Fri, 15 Jun 2018 04:34:07 -0700 (PDT) Received: from localhost ([::1]:45998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmzW-0006S6-Ck for importer@patchew.org; Fri, 15 Jun 2018 07:34:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmrE-00088r-Db for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmrB-0000un-7R for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37050 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmrB-0000uh-1R; Fri, 15 Jun 2018 07:25:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9AE6A402312B; Fri, 15 Jun 2018 11:25:28 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3964E63A72; Fri, 15 Jun 2018 11:25:22 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:55 +0200 Message-Id: <20180615112500.19854-8-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 11:25:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 11:25:28 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 07/12] pc-dimm: merge get_(vmstate_)memory_region() 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Importantly, get_vmstate_memory_region() should also fail with a proper error if called before the device is realized. For a PCDIMM, both functions are to return the same thing, so share the implementation. All current users are called after the device has been realized, so we can expect the calls to succeed. Signed-off-by: David Hildenbrand --- hw/mem/pc-dimm.c | 13 +++++-------- include/hw/mem/pc-dimm.h | 3 ++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 73f0eee4c7..4ff39b59ef 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -35,7 +35,8 @@ void pc_dimm_plug(DeviceState *dev, MachineState *machine= , uint64_t align, int slot; PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm); + MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm, + &error_abort= ); Error *local_err =3D NULL; MemoryRegion *mr; uint64_t addr; @@ -90,7 +91,8 @@ void pc_dimm_unplug(DeviceState *dev, MachineState *machi= ne) { PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm); + MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm, + &error_abort= ); MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); =20 memory_device_unplug_region(machine, mr); @@ -229,11 +231,6 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMMD= evice *dimm, Error **errp) return host_memory_backend_get_memory(dimm->hostmem); } =20 -static MemoryRegion *pc_dimm_get_vmstate_memory_region(PCDIMMDevice *dimm) -{ - return host_memory_backend_get_memory(dimm->hostmem); -} - static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md) { const PCDIMMDevice *dimm =3D PC_DIMM(md); @@ -298,7 +295,7 @@ static void pc_dimm_class_init(ObjectClass *oc, void *d= ata) dc->desc =3D "DIMM memory module"; =20 ddc->get_memory_region =3D pc_dimm_get_memory_region; - ddc->get_vmstate_memory_region =3D pc_dimm_get_vmstate_memory_region; + ddc->get_vmstate_memory_region =3D pc_dimm_get_memory_region; =20 mdc->get_addr =3D pc_dimm_md_get_addr; /* for a dimm plugged_size =3D=3D region_size */ diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index cf71247630..5679a80465 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -73,7 +73,8 @@ typedef struct PCDIMMDeviceClass { /* public */ void (*realize)(PCDIMMDevice *dimm, Error **errp); MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm, Error **errp); - MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm); + MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm, + Error **errp); } PCDIMMDeviceClass; =20 void pc_dimm_plug(DeviceState *dev, MachineState *machine, uint64_t align, --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15290624238939.622902576520005; Fri, 15 Jun 2018 04:33:43 -0700 (PDT) Received: from localhost ([::1]:45995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmz0-00064n-26 for importer@patchew.org; Fri, 15 Jun 2018 07:33:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmrE-00088s-GU for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmrD-0000vu-KP for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38856 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmrD-0000vY-8f; Fri, 15 Jun 2018 07:25:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C03F3D9B99; Fri, 15 Jun 2018 11:25:30 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6B1E63A72; Fri, 15 Jun 2018 11:25:28 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:56 +0200 Message-Id: <20180615112500.19854-9-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 11:25:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 11:25:30 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 08/12] nvdimm: no need to overwrite get_vmstate_memory_region() 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Our parent class (PC_DIMM) provides exactly the same function. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand --- hw/mem/nvdimm.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 37e19044d6..df9716231f 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -166,11 +166,6 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvdi= mm, const void *buf, memory_region_set_dirty(mr, backend_offset, size); } =20 -static MemoryRegion *nvdimm_get_vmstate_memory_region(PCDIMMDevice *dimm) -{ - return host_memory_backend_get_memory(dimm->hostmem, &error_abort); -} - static void nvdimm_class_init(ObjectClass *oc, void *data) { PCDIMMDeviceClass *ddc =3D PC_DIMM_CLASS(oc); @@ -178,7 +173,6 @@ static void nvdimm_class_init(ObjectClass *oc, void *da= ta) =20 ddc->realize =3D nvdimm_realize; ddc->get_memory_region =3D nvdimm_get_memory_region; - ddc->get_vmstate_memory_region =3D nvdimm_get_vmstate_memory_region; =20 nvc->read_label_data =3D nvdimm_read_label_data; nvc->write_label_data =3D nvdimm_write_label_data; --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062426230638.785116902433; Fri, 15 Jun 2018 04:33:46 -0700 (PDT) Received: from localhost ([::1]:45997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmz9-0006AP-6O for importer@patchew.org; Fri, 15 Jun 2018 07:33:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmrG-00088y-JI for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmrF-0000x7-F9 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48844 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmrF-0000wi-9m; Fri, 15 Jun 2018 07:25:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DBA58401EF39; Fri, 15 Jun 2018 11:25:32 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0512E63A72; Fri, 15 Jun 2018 11:25:30 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:57 +0200 Message-Id: <20180615112500.19854-10-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 11:25:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 11:25:32 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 09/12] nvdimm: convert "unarmed" into a static property 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We don't allow to modify it after realization. So we can simply turn it into a static property. Signed-off-by: David Hildenbrand --- hw/mem/nvdimm.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index df9716231f..7260c9c6b1 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -64,36 +64,11 @@ out: error_propagate(errp, local_err); } =20 -static bool nvdimm_get_unarmed(Object *obj, Error **errp) -{ - NVDIMMDevice *nvdimm =3D NVDIMM(obj); - - return nvdimm->unarmed; -} - -static void nvdimm_set_unarmed(Object *obj, bool value, Error **errp) -{ - NVDIMMDevice *nvdimm =3D NVDIMM(obj); - Error *local_err =3D NULL; - - if (memory_region_size(&nvdimm->nvdimm_mr)) { - error_setg(&local_err, "cannot change property value"); - goto out; - } - - nvdimm->unarmed =3D value; - - out: - error_propagate(errp, local_err); -} - static void nvdimm_init(Object *obj) { object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "int", nvdimm_get_label_size, nvdimm_set_label_size, NULL, NULL, NULL); - object_property_add_bool(obj, NVDIMM_UNARMED_PROP, - nvdimm_get_unarmed, nvdimm_set_unarmed, NULL); } =20 static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) @@ -166,13 +141,20 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvd= imm, const void *buf, memory_region_set_dirty(mr, backend_offset, size); } =20 +static Property nvdimm_properties[] =3D { + DEFINE_PROP_BOOL(NVDIMM_UNARMED_PROP, NVDIMMDevice, unarmed, false), + DEFINE_PROP_END_OF_LIST(), +}; + static void nvdimm_class_init(ObjectClass *oc, void *data) { PCDIMMDeviceClass *ddc =3D PC_DIMM_CLASS(oc); NVDIMMClass *nvc =3D NVDIMM_CLASS(oc); + DeviceClass *dc =3D DEVICE_CLASS(oc); =20 ddc->realize =3D nvdimm_realize; ddc->get_memory_region =3D nvdimm_get_memory_region; + dc->props =3D nvdimm_properties; =20 nvc->read_label_data =3D nvdimm_read_label_data; nvc->write_label_data =3D nvdimm_write_label_data; --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062513032380.71972129936205; Fri, 15 Jun 2018 04:35:13 -0700 (PDT) Received: from localhost ([::1]:46001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTn0a-0007NS-9E for importer@patchew.org; Fri, 15 Jun 2018 07:35:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmrI-0008Ba-TX for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmrH-0000z2-OX for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48848 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmrH-0000yT-E2; Fri, 15 Jun 2018 07:25:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07192401CB89; Fri, 15 Jun 2018 11:25:35 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2453863AF6; Fri, 15 Jun 2018 11:25:33 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:58 +0200 Message-Id: <20180615112500.19854-11-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 11:25:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 11:25:35 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 10/12] nvdimm: convert "label-size" into a static property 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We don't allow to modify it after realization. So we can simply turn it into a static property. The value is now validated during realize(). Signed-off-by: David Hildenbrand --- hw/mem/nvdimm.c | 53 ++++++++----------------------------------------- 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 7260c9c6b1..d3e8a5bcbb 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -27,50 +27,6 @@ #include "qapi/visitor.h" #include "hw/mem/nvdimm.h" =20 -static void nvdimm_get_label_size(Object *obj, Visitor *v, const char *nam= e, - void *opaque, Error **errp) -{ - NVDIMMDevice *nvdimm =3D NVDIMM(obj); - uint64_t value =3D nvdimm->label_size; - - visit_type_size(v, name, &value, errp); -} - -static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *nam= e, - void *opaque, Error **errp) -{ - NVDIMMDevice *nvdimm =3D NVDIMM(obj); - Error *local_err =3D NULL; - uint64_t value; - - if (memory_region_size(&nvdimm->nvdimm_mr)) { - error_setg(&local_err, "cannot change property value"); - goto out; - } - - visit_type_size(v, name, &value, &local_err); - if (local_err) { - goto out; - } - if (value < MIN_NAMESPACE_LABEL_SIZE) { - error_setg(&local_err, "Property '%s.%s' (0x%" PRIx64 ") is requir= ed" - " at least 0x%lx", object_get_typename(obj), - name, value, MIN_NAMESPACE_LABEL_SIZE); - goto out; - } - - nvdimm->label_size =3D value; -out: - error_propagate(errp, local_err); -} - -static void nvdimm_init(Object *obj) -{ - object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "int", - nvdimm_get_label_size, nvdimm_set_label_size, NULL, - NULL, NULL); -} - static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) { NVDIMMDevice *nvdimm =3D NVDIMM(dimm); @@ -86,6 +42,13 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **e= rrp) =20 align =3D memory_region_get_alignment(mr); =20 + if (nvdimm->label_size && nvdimm->label_size < MIN_NAMESPACE_LABEL_SIZ= E) { + error_setg(errp, "the label-size (0x%" PRIx64 ") has to be " + "either 0 or at least 0x%lx", + nvdimm->label_size, MIN_NAMESPACE_LABEL_SIZE); + return; + } + pmem_size =3D size - nvdimm->label_size; nvdimm->label_data =3D memory_region_get_ram_ptr(mr) + pmem_size; pmem_size =3D QEMU_ALIGN_DOWN(pmem_size, align); @@ -143,6 +106,7 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvdim= m, const void *buf, =20 static Property nvdimm_properties[] =3D { DEFINE_PROP_BOOL(NVDIMM_UNARMED_PROP, NVDIMMDevice, unarmed, false), + DEFINE_PROP_UINT64(NVDIMM_LABEL_SIZE_PROP, NVDIMMDevice, label_size, 0= ), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -166,7 +130,6 @@ static TypeInfo nvdimm_info =3D { .class_size =3D sizeof(NVDIMMClass), .class_init =3D nvdimm_class_init, .instance_size =3D sizeof(NVDIMMDevice), - .instance_init =3D nvdimm_init, }; =20 static void nvdimm_register_types(void) --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062674692973.384028548978; Fri, 15 Jun 2018 04:37:54 -0700 (PDT) Received: from localhost ([::1]:46036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTn3B-0001An-UZ for importer@patchew.org; Fri, 15 Jun 2018 07:37:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmrK-0008Dv-Uv for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmrJ-000107-Q1 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:38 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48858 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmrJ-0000zs-JA; Fri, 15 Jun 2018 07:25:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24DAE4059FFD; Fri, 15 Jun 2018 11:25:37 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 437C063AD9; Fri, 15 Jun 2018 11:25:35 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:24:59 +0200 Message-Id: <20180615112500.19854-12-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 11:25:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 11:25:37 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 11/12] nvdimm: make get_memory_region() perform checks and initialization 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We might get a call to get_memory_region() before the device has been realized. We should return a consistent value, as the return value will e.g. later on be used in the pre_plug handler. To avoid duplicating too much code, factor the initialization and checks out into a helper function. Signed-off-by: David Hildenbrand --- hw/mem/nvdimm.c | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index d3e8a5bcbb..9048ce0b84 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -27,20 +27,19 @@ #include "qapi/visitor.h" #include "hw/mem/nvdimm.h" =20 -static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) +static void nvdimm_prepare_memory_region(NVDIMMDevice *nvdimm, Error **err= p) { - NVDIMMDevice *nvdimm =3D NVDIMM(dimm); - - return &nvdimm->nvdimm_mr; -} + PCDIMMDevice *dimm =3D PC_DIMM(nvdimm); + uint64_t align, pmem_size, size; + MemoryRegion *mr; =20 -static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp) -{ - MemoryRegion *mr =3D host_memory_backend_get_memory(dimm->hostmem); - NVDIMMDevice *nvdimm =3D NVDIMM(dimm); - uint64_t align, pmem_size, size =3D memory_region_size(mr); + if (!dimm->hostmem) { + error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property must be set"); + return; + } =20 - align =3D memory_region_get_alignment(mr); + g_assert(!memory_region_size(&nvdimm->nvdimm_mr)); + mr =3D host_memory_backend_get_memory(dimm->hostmem); =20 if (nvdimm->label_size && nvdimm->label_size < MIN_NAMESPACE_LABEL_SIZ= E) { error_setg(errp, "the label-size (0x%" PRIx64 ") has to be " @@ -49,6 +48,9 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **er= rp) return; } =20 + align =3D memory_region_get_alignment(mr); + size =3D memory_region_size(mr); + pmem_size =3D size - nvdimm->label_size; nvdimm->label_data =3D memory_region_get_ram_ptr(mr) + pmem_size; pmem_size =3D QEMU_ALIGN_DOWN(pmem_size, align); @@ -70,6 +72,31 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **e= rrp) nvdimm->nvdimm_mr.align =3D align; } =20 +static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) +{ + NVDIMMDevice *nvdimm =3D NVDIMM(dimm); + Error *local_err =3D NULL; + + if (!memory_region_size(&nvdimm->nvdimm_mr)) { + nvdimm_prepare_memory_region(nvdimm, &local_err); + } + + if (local_err) { + error_propagate(errp, local_err); + return NULL; + } + return &nvdimm->nvdimm_mr; +} + +static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp) +{ + NVDIMMDevice *nvdimm =3D NVDIMM(dimm); + + if (!memory_region_size(&nvdimm->nvdimm_mr)) { + nvdimm_prepare_memory_region(nvdimm, errp); + } +} + /* * the caller should check the input parameters before calling * label read/write functions. --=20 2.17.1 From nobody Sun May 5 21:03:59 2024 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; 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 1529062815230499.4035903839979; Fri, 15 Jun 2018 04:40:15 -0700 (PDT) Received: from localhost ([::1]:46049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTn5S-0003Cp-JL for importer@patchew.org; Fri, 15 Jun 2018 07:40:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTmrN-0008GT-Hu for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTmrL-00011q-RA for qemu-devel@nongnu.org; Fri, 15 Jun 2018 07:25:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37066 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTmrL-00011G-MC; Fri, 15 Jun 2018 07:25:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 414AC402312B; Fri, 15 Jun 2018 11:25:39 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6118363A72; Fri, 15 Jun 2018 11:25:37 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 13:25:00 +0200 Message-Id: <20180615112500.19854-13-david@redhat.com> In-Reply-To: <20180615112500.19854-1-david@redhat.com> References: <20180615112500.19854-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 11:25:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 11:25:39 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 12/12] pc-dimm: get_memory_region() will not fail after realize 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: Eduardo Habkost , "Michael S . Tsirkin" , Xiao Guangrong , David Hildenbrand , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Let's try to reduce error handling a bit. In the plug/unplug case, the device was realized and therefore we can assume that getting access to the memory region will not fail. For get_vmstate_memory_region() this is already handled that way. Document both cases. Signed-off-by: David Hildenbrand Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 7 +------ hw/mem/pc-dimm.c | 7 +------ hw/ppc/spapr.c | 12 ++---------- include/hw/mem/pc-dimm.h | 6 ++++-- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2db032a6df..f310040351 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1706,15 +1706,10 @@ static void pc_memory_plug(HotplugHandler *hotplug_= dev, PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr; + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); uint64_t align =3D TARGET_PAGE_SIZE; bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } - if (memory_region_get_alignment(mr) && pcmc->enforce_aligned_dimm) { align =3D memory_region_get_alignment(mr); } diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 4ff39b59ef..65843bc52a 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -37,15 +37,10 @@ void pc_dimm_plug(DeviceState *dev, MachineState *machi= ne, uint64_t align, PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm, &error_abort= ); + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); Error *local_err =3D NULL; - MemoryRegion *mr; uint64_t addr; =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } - addr =3D object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); if (local_err) { diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3e5320020f..6934abc21e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3142,14 +3142,10 @@ static void spapr_memory_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, sPAPRMachineState *ms =3D SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr; + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); uint64_t align, size, addr; uint32_t node; =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } align =3D memory_region_get_alignment(mr); size =3D memory_region_size(mr); =20 @@ -3340,16 +3336,12 @@ static void spapr_memory_unplug_request(HotplugHand= ler *hotplug_dev, Error *local_err =3D NULL; PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr; + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); uint32_t nr_lmbs; uint64_t size, addr_start, addr; int i; sPAPRDRConnector *drc; =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } size =3D memory_region_size(mr); nr_lmbs =3D size / SPAPR_MEMORY_BLOCK_SIZE; =20 diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 5679a80465..26ebb7d5e9 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -62,9 +62,11 @@ typedef struct PCDIMMDevice { * @realize: called after common dimm is realized so that the dimm based * devices get the chance to do specified operations. * @get_memory_region: returns #MemoryRegion associated with @dimm which - * is directly mapped into the physical address space of guest. + * is directly mapped into the physical address space of guest. Will not + * fail after the device was realized. * @get_vmstate_memory_region: returns #MemoryRegion which indicates the - * memory of @dimm should be kept during live migration. + * memory of @dimm should be kept during live migration. Will not fail + * after the device was realized. */ typedef struct PCDIMMDeviceClass { /* private */ --=20 2.17.1