From nobody Tue Nov 4 15:31: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 1530217428141945.4168891775433; Thu, 28 Jun 2018 13:23:48 -0700 (PDT) Received: from localhost ([::1]:38374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdSF-0005Oh-6x for importer@patchew.org; Thu, 28 Jun 2018 16:23:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAi-0007Hn-95 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAh-0000cJ-6P for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:40 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:35986) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAg-0000b0-VV for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:39 -0400 Received: by mail-wm0-x235.google.com with SMTP id u18-v6so10302528wmc.1 for ; Thu, 28 Jun 2018 13:05:38 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:37 -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=vxf6iVR65OjcO2by+2Ila130ohQCjQlQqsr0LhaLa0k=; b=nIOOQ3uJcZoDhJ6xvEp8V4ODzDCco0kyMrlHw+cjoalfXheJVw6tp+Lhg7r+JUhGmb ANqtgccmoflBnHqcW+Ae4Di2vR9e7QbBbTm+XSBg803abgkVrQpkKTVQR6jMRTYfofhr +Nl0gcjSCtWEyClgHeJadH/XXo34VL92gjm9bH+wLvse3mkWA81H04rNE/e80+S3nlAY F05zLESyMK9vx96+rS/9OaiWxGtbDQoJAHMdNsmI+ElarsG1a5MBiQVU9GcvnOXQEJ1S 0Fv5Cd5iXiC9OkJywV0TJHaL4cMivkkv00ftspZ+4dU1OXKfgc9pU870BnX5x7PFHh1F ptZg== 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=vxf6iVR65OjcO2by+2Ila130ohQCjQlQqsr0LhaLa0k=; b=hjhE6zqedrPC5OOEizOF0HtujorB10Ni7AzmYQsGy3aTvkTXlhsabqS3vaJG+ozPFE yFGTyH8HET4QWACteSwrkZjrW109gpXhUxDqtwGzeN1fjWGzSEA9KLgnEL/EazD1nY/m KAuMw2TVHXFCWiM+mx+8N6K/9OGmu8OtAvq8pKpCO2eFMDBEh1swXmtLZtaaWy3LM1Hz 6zuPxc64vMzLDVJQxeY+0s3uEGUFg8/xOGpSD5Wx84yHE//phvpDxKfDshFYSGXz9r1U 7PDcdkb0ceQHl0dUTYuTnSSKuk+LcCNtqXcKGMRTTu8pkZCNz5L42UFXEICw2Q/ssjhG aH7w== X-Gm-Message-State: APt69E1MC2U3wr1Pz9TZ+h19/tZJ+z2QbG55nvLhPqZbN2yf9/kxouPb NONqFZPEYi2x6LAWLk4GwezjhVYk X-Google-Smtp-Source: AAOMgpeBHXH0SAsp0SZiPoGtiSbkCtBYRHNHbWHy8KX1Ysmct0X0HtbMkNXemNs4QthLBQB/rCSYtg== X-Received: by 2002:a1c:d391:: with SMTP id k139-v6mr8870373wmg.45.1530216337653; Thu, 28 Jun 2018 13:05:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:34 +0200 Message-Id: <1530216310-52873-25-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:c09::235 Subject: [Qemu-devel] [PULL 24/60] 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: 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 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. Reviewed-by: David Gibson Reviewed-by: Igor Mammedov Signed-off-by: David Hildenbrand Message-Id: <20180619134141.29478-9-david@redhat.com> Signed-off-by: Paolo Bonzini --- 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 73f0eee..4ff39b5 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 cf71247..5679a80 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 1.8.3.1