From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Alexander Graf <agraf@suse.de>, Rob Herring <robh@kernel.org>,
libvir-list@redhat.com, Richard Henderson <rth@twiddle.net>,
David Gibson <david@gibson.dropbear.id.au>,
Eric Blake <eblake@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
qemu-arm@nongnu.org,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Markus Armbruster <armbru@redhat.com>,
Artyom Tarasenko <atar4qemu@gmail.com>,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
Eduardo Habkost <ehabkost@redhat.com>,
Michael Walle <michael@walle.cc>, Thomas Huth <thuth@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Aleksandar Markovic <amarkovic@wavecomp.com>,
Aurelien Jarno <aurelien@aurel32.net>,
Alistair Francis <alistair@alistair23.me>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Laurent Vivier <lvivier@redhat.com>,
qemu-ppc@nongnu.org,
Xiao Guangrong <xiaoguangrong.eric@gmail.com>,
Max Filippov <jcmvbkbc@gmail.com>,
David Hildenbrand <david@redhat.com>
Subject: [Qemu-devel] [PULL v2 23/43] memory-device: forward errors in get_region_size()/get_plugged_size()
Date: Thu, 25 Oct 2018 10:32:41 -0300 [thread overview]
Message-ID: <20181025133301.16578-24-ehabkost@redhat.com> (raw)
In-Reply-To: <20181025133301.16578-1-ehabkost@redhat.com>
From: David Hildenbrand <david@redhat.com>
Let's properly forward the errors, so errors from get_region_size() /
get_plugged_size() can be handled.
Users right now call both functions after the device has been realized,
which is will never fail, so it is fine to continue using error_abort.
While at it, remove a leftover error check (suggested by Igor).
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20181005092024.14344-8-david@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/hw/mem/memory-device.h | 4 ++--
hw/mem/memory-device.c | 9 +++------
hw/mem/pc-dimm.c | 5 +++--
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
index 2853b084b5..f02b229837 100644
--- a/include/hw/mem/memory-device.h
+++ b/include/hw/mem/memory-device.h
@@ -33,8 +33,8 @@ typedef struct MemoryDeviceClass {
InterfaceClass parent_class;
uint64_t (*get_addr)(const MemoryDeviceState *md);
- uint64_t (*get_plugged_size)(const MemoryDeviceState *md);
- uint64_t (*get_region_size)(const MemoryDeviceState *md);
+ uint64_t (*get_plugged_size)(const MemoryDeviceState *md, Error **errp);
+ uint64_t (*get_region_size)(const MemoryDeviceState *md, Error **errp);
void (*fill_device_info)(const MemoryDeviceState *md,
MemoryDeviceInfo *info);
} MemoryDeviceClass;
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 87369ef2e1..c1e1b81cf2 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -60,7 +60,7 @@ static int memory_device_used_region_size(Object *obj, void *opaque)
const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(obj);
if (dev->realized) {
- *size += mdc->get_region_size(md);
+ *size += mdc->get_region_size(md, &error_abort);
}
}
@@ -167,10 +167,7 @@ uint64_t memory_device_get_free_addr(MachineState *ms, const uint64_t *hint,
uint64_t md_size, md_addr;
md_addr = mdc->get_addr(md);
- md_size = mdc->get_region_size(md);
- if (*errp) {
- goto out;
- }
+ md_size = mdc->get_region_size(md, &error_abort);
if (ranges_overlap(md_addr, md_size, new_addr, size)) {
if (hint) {
@@ -234,7 +231,7 @@ static int memory_device_plugged_size(Object *obj, void *opaque)
const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(obj);
if (dev->realized) {
- *size += mdc->get_plugged_size(md);
+ *size += mdc->get_plugged_size(md, &error_abort);
}
}
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index f46fb7ada2..130f78d0de 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -234,14 +234,15 @@ static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md)
return dimm->addr;
}
-static uint64_t pc_dimm_md_get_region_size(const MemoryDeviceState *md)
+static uint64_t pc_dimm_md_get_region_size(const MemoryDeviceState *md,
+ Error **errp)
{
/* dropping const here is fine as we don't touch the memory region */
PCDIMMDevice *dimm = PC_DIMM(md);
const PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(md);
MemoryRegion *mr;
- mr = ddc->get_memory_region(dimm, &error_abort);
+ mr = ddc->get_memory_region(dimm, errp);
if (!mr) {
return 0;
}
--
2.18.0.rc1.1.g3f1ff2140
next prev parent reply other threads:[~2018-10-25 13:36 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 13:32 [Qemu-devel] [PULL v2 00/43] Machine queue, 2018-10-25 Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 01/43] hostmem-file: fixed the memory leak while get pmem path Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 02/43] vl.c deprecate incorrect CPUs topology Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 03/43] vl:c: make sure that sockets are calculated correctly in '-smp X' case Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 04/43] trace-events: Fix copy/paste typo Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 05/43] hw/timer/sun4v-rtc: Convert from DPRINTF() macro to trace events Eduardo Habkost
2018-10-25 17:17 ` David Gibson
2018-10-26 8:27 ` Eduardo Habkost
2018-10-26 10:49 ` Philippe Mathieu-Daudé
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 06/43] hw/timer/sun4v-rtc: Use DeviceState::realize rather than SysBusDevice::init Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 07/43] hw/ssi/xilinx_spi: " Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 08/43] hw/sh4/sh_pci: " Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 09/43] hw/pci-host/bonito: " Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 10/43] hw/mips/gt64xxx_pci: Convert gt64120_reset() function into Device reset method Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 11/43] hw/mips/gt64xxx_pci: Mark as bridge device Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 12/43] hw/sparc64/niagara: Model the I/O Bridge with the 'unimplemented_device' Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 13/43] hw/alpha/typhoon: Remove unuseful code Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 14/43] hw/hppa/dino: " Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 15/43] hw/mips/malta: " Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 16/43] machine: fix a typo Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 17/43] memory-device: fix alignment error message Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 18/43] memory-device: fix error message when hinted address is too small Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 19/43] memory-device: improve "range conflicts" error message Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 20/43] pc-dimm: pass PCDIMMDevice to pc_dimm_.*plug Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 21/43] memory-device: use memory device terminology in error messages Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 22/43] memory-device: introduce separate config option Eduardo Habkost
2018-10-25 13:32 ` Eduardo Habkost [this message]
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 24/43] memory-device: document MemoryDeviceClass Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 25/43] memory-device: add and use memory_device_get_region_size() Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 26/43] memory-device: factor out get_memory_region() from pc-dimm Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 27/43] memory-device: drop get_region_size() Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 28/43] memory-device: add device class function set_addr() Eduardo Habkost
2018-10-25 13:32 ` [Qemu-devel] [PULL v2 29/43] memory-device: complete factoring out pre_plug handling Eduardo Habkost
2018-10-26 19:16 ` [Qemu-devel] [PULL v2 00/43] Machine queue, 2018-10-25 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181025133301.16578-24-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=agraf@suse.de \
--cc=alistair@alistair23.me \
--cc=amarkovic@wavecomp.com \
--cc=armbru@redhat.com \
--cc=atar4qemu@gmail.com \
--cc=aurelien@aurel32.net \
--cc=crosthwaite.peter@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=imammedo@redhat.com \
--cc=jasowang@redhat.com \
--cc=jcmvbkbc@gmail.com \
--cc=libvir-list@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=michael@walle.cc \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=robh@kernel.org \
--cc=rth@twiddle.net \
--cc=thuth@redhat.com \
--cc=xiaoguangrong.eric@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).