Modify memory_global_dirty_log_start() and memory_global_dirty_log_stop()
to also take an Error** parameter and report the error in the callers.
Aside from error reporting, there should be no functional changes.
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Paul Durrant <paul@xen.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
include/exec/memory.h | 12 ++++++++----
hw/i386/xen/xen-hvm.c | 8 ++++----
hw/vfio/common.c | 6 ++++--
hw/virtio/vhost.c | 4 ++--
migration/dirtyrate.c | 24 ++++++++++++++++++++----
migration/ram.c | 27 +++++++++++++++++++++++----
system/memory.c | 37 +++++++++++++++++++++++++------------
7 files changed, 86 insertions(+), 32 deletions(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 177be23db709d8bab9cebfe6acbae57611073327..b348070dc8f17b3505196d3a92d8cfb2171b640f 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -998,8 +998,9 @@ struct MemoryListener {
* active at that time.
*
* @listener: The #MemoryListener.
+ * @errp: pointer to Error*, to store an error if it happens.
*/
- void (*log_global_start)(MemoryListener *listener);
+ void (*log_global_start)(MemoryListener *listener, Error **errp);
/**
* @log_global_stop:
@@ -1009,8 +1010,9 @@ struct MemoryListener {
* the address space.
*
* @listener: The #MemoryListener.
+ * @errp: pointer to Error*, to store an error if it happens.
*/
- void (*log_global_stop)(MemoryListener *listener);
+ void (*log_global_stop)(MemoryListener *listener, Error **errp);
/**
* @log_global_after_sync:
@@ -2567,15 +2569,17 @@ void memory_listener_unregister(MemoryListener *listener);
* memory_global_dirty_log_start: begin dirty logging for all regions
*
* @flags: purpose of starting dirty log, migration or dirty rate
+ * @errp: pointer to Error*, to store an error if it happens.
*/
-void memory_global_dirty_log_start(unsigned int flags);
+void memory_global_dirty_log_start(unsigned int flags, Error **errp);
/**
* memory_global_dirty_log_stop: end dirty logging for all regions
*
* @flags: purpose of stopping dirty log, migration or dirty rate
+ * @errp: pointer to Error*, to store an error if it happens.
*/
-void memory_global_dirty_log_stop(unsigned int flags);
+void memory_global_dirty_log_stop(unsigned int flags, Error **errp);
void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled);
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index f42621e6742552035122ea58092c91c3458338ff..d9c80416343b71311389563c7bdaa748829ada29 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -446,14 +446,14 @@ static void xen_log_sync(MemoryListener *listener, MemoryRegionSection *section)
int128_get64(section->size));
}
-static void xen_log_global_start(MemoryListener *listener)
+static void xen_log_global_start(MemoryListener *listener, Error **errp)
{
if (xen_enabled()) {
xen_in_migration = true;
}
}
-static void xen_log_global_stop(MemoryListener *listener)
+static void xen_log_global_stop(MemoryListener *listener, Error **errp)
{
xen_in_migration = false;
}
@@ -653,9 +653,9 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
void qmp_xen_set_global_dirty_log(bool enable, Error **errp)
{
if (enable) {
- memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION);
+ memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, errp);
} else {
- memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION);
+ memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION, errp);
}
}
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 059bfdc07a85e2eb908df828c1f42104d683e911..45af5c675584e1931dfba3b4f78469cc4c00014e 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1075,7 +1075,8 @@ out:
return ret;
}
-static void vfio_listener_log_global_start(MemoryListener *listener)
+static void vfio_listener_log_global_start(MemoryListener *listener,
+ Error **errp)
{
VFIOContainerBase *bcontainer = container_of(listener, VFIOContainerBase,
listener);
@@ -1094,7 +1095,8 @@ static void vfio_listener_log_global_start(MemoryListener *listener)
}
}
-static void vfio_listener_log_global_stop(MemoryListener *listener)
+static void vfio_listener_log_global_stop(MemoryListener *listener,
+ Error **errp)
{
VFIOContainerBase *bcontainer = container_of(listener, VFIOContainerBase,
listener);
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 2c9ac794680ea9b65eba6cc22e70cf141e90aa73..970f5951cc0b2113f91a3c640e27add5752b2944 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1044,7 +1044,7 @@ check_dev_state:
return r;
}
-static void vhost_log_global_start(MemoryListener *listener)
+static void vhost_log_global_start(MemoryListener *listener, Error **errp)
{
int r;
@@ -1054,7 +1054,7 @@ static void vhost_log_global_start(MemoryListener *listener)
}
}
-static void vhost_log_global_stop(MemoryListener *listener)
+static void vhost_log_global_stop(MemoryListener *listener, Error **errp)
{
int r;
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 1d2e85746fb7b10eb7f149976970f9a92125af8a..443acab7a7efbd6e9c94883363e1a827a3538292 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -90,13 +90,19 @@ static int64_t do_calculate_dirtyrate(DirtyPageRecord dirty_pages,
void global_dirty_log_change(unsigned int flag, bool start)
{
+ Error *local_err = NULL;
+
bql_lock();
if (start) {
- memory_global_dirty_log_start(flag);
+ memory_global_dirty_log_start(flag, &local_err);
} else {
- memory_global_dirty_log_stop(flag);
+ memory_global_dirty_log_stop(flag, &local_err);
}
bql_unlock();
+
+ if (local_err) {
+ error_report_err(local_err);
+ }
}
/*
@@ -106,12 +112,18 @@ void global_dirty_log_change(unsigned int flag, bool start)
*/
static void global_dirty_log_sync(unsigned int flag, bool one_shot)
{
+ Error *local_err = NULL;
+
bql_lock();
memory_global_dirty_log_sync(false);
if (one_shot) {
- memory_global_dirty_log_stop(flag);
+ memory_global_dirty_log_stop(flag, &local_err);
}
bql_unlock();
+
+ if (local_err) {
+ error_report_err(local_err);
+ }
}
static DirtyPageRecord *vcpu_dirty_stat_alloc(VcpuStat *stat)
@@ -608,9 +620,13 @@ static void calculate_dirtyrate_dirty_bitmap(struct DirtyRateConfig config)
{
int64_t start_time;
DirtyPageRecord dirty_pages;
+ Error *local_err = NULL;
bql_lock();
- memory_global_dirty_log_start(GLOBAL_DIRTY_DIRTY_RATE);
+ memory_global_dirty_log_start(GLOBAL_DIRTY_DIRTY_RATE, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
/*
* 1'round of log sync may return all 1 bits with
diff --git a/migration/ram.c b/migration/ram.c
index 8dac9bac2fe8b8c19e102c771a7ef6e976252906..d86626bb1c704b2d3497b323a702ca6ca8939a79 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2391,6 +2391,7 @@ static void ram_save_cleanup(void *opaque)
{
RAMState **rsp = opaque;
RAMBlock *block;
+ Error *local_err = NULL;
/* We don't use dirty log with background snapshots */
if (!migrate_background_snapshot()) {
@@ -2403,7 +2404,10 @@ static void ram_save_cleanup(void *opaque)
* memory_global_dirty_log_stop will assert that
* memory_global_dirty_log_start/stop used in pairs
*/
- memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION);
+ memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
}
}
@@ -2800,13 +2804,18 @@ static void migration_bitmap_clear_discarded_pages(RAMState *rs)
static void ram_init_bitmaps(RAMState *rs)
{
+ Error *local_err = NULL;
+
qemu_mutex_lock_ramlist();
WITH_RCU_READ_LOCK_GUARD() {
ram_list_init_bitmaps();
/* We don't use dirty log with background snapshots */
if (!migrate_background_snapshot()) {
- memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION);
+ memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
migration_bitmap_sync_precopy(rs, false);
}
}
@@ -3450,6 +3459,8 @@ int colo_init_ram_cache(void)
void colo_incoming_start_dirty_log(void)
{
RAMBlock *block = NULL;
+ Error *local_err = NULL;
+
/* For memory_global_dirty_log_start below. */
bql_lock();
qemu_mutex_lock_ramlist();
@@ -3461,7 +3472,10 @@ void colo_incoming_start_dirty_log(void)
/* Discard this dirty bitmap record */
bitmap_zero(block->bmap, block->max_length >> TARGET_PAGE_BITS);
}
- memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION);
+ memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
}
ram_state->migration_dirty_pages = 0;
qemu_mutex_unlock_ramlist();
@@ -3472,8 +3486,13 @@ void colo_incoming_start_dirty_log(void)
void colo_release_ram_cache(void)
{
RAMBlock *block;
+ Error *local_err = NULL;
+
+ memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
- memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION);
RAMBLOCK_FOREACH_NOT_IGNORED(block) {
g_free(block->bmap);
block->bmap = NULL;
diff --git a/system/memory.c b/system/memory.c
index a229a79988fce2aa3cb77e3a130db4c694e8cd49..2fb9ef56e7302af120f6287e1beda7a181c9a349 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -2912,18 +2912,22 @@ void memory_global_after_dirty_log_sync(void)
*/
static unsigned int postponed_stop_flags;
static VMChangeStateEntry *vmstate_change;
-static void memory_global_dirty_log_stop_postponed_run(void);
+static void memory_global_dirty_log_stop_postponed_run(Error **errp);
-void memory_global_dirty_log_start(unsigned int flags)
+void memory_global_dirty_log_start(unsigned int flags, Error **errp)
{
unsigned int old_flags;
+ Error *local_err = NULL;
assert(flags && !(flags & (~GLOBAL_DIRTY_MASK)));
if (vmstate_change) {
/* If there is postponed stop(), operate on it first */
postponed_stop_flags &= ~flags;
- memory_global_dirty_log_stop_postponed_run();
+ memory_global_dirty_log_stop_postponed_run(&local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
}
flags &= ~global_dirty_tracking;
@@ -2936,14 +2940,14 @@ void memory_global_dirty_log_start(unsigned int flags)
trace_global_dirty_changed(global_dirty_tracking);
if (!old_flags) {
- MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
+ MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward, errp);
memory_region_transaction_begin();
memory_region_update_pending = true;
memory_region_transaction_commit();
}
}
-static void memory_global_dirty_log_do_stop(unsigned int flags)
+static void memory_global_dirty_log_do_stop(unsigned int flags, Error **errp)
{
assert(flags && !(flags & (~GLOBAL_DIRTY_MASK)));
assert((global_dirty_tracking & flags) == flags);
@@ -2955,7 +2959,7 @@ static void memory_global_dirty_log_do_stop(unsigned int flags)
memory_region_transaction_begin();
memory_region_update_pending = true;
memory_region_transaction_commit();
- MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
+ MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse, errp);
}
}
@@ -2963,14 +2967,14 @@ static void memory_global_dirty_log_do_stop(unsigned int flags)
* Execute the postponed dirty log stop operations if there is, then reset
* everything (including the flags and the vmstate change hook).
*/
-static void memory_global_dirty_log_stop_postponed_run(void)
+static void memory_global_dirty_log_stop_postponed_run(Error **errp)
{
/* This must be called with the vmstate handler registered */
assert(vmstate_change);
/* Note: postponed_stop_flags can be cleared in log start routine */
if (postponed_stop_flags) {
- memory_global_dirty_log_do_stop(postponed_stop_flags);
+ memory_global_dirty_log_do_stop(postponed_stop_flags, errp);
postponed_stop_flags = 0;
}
@@ -2981,12 +2985,17 @@ static void memory_global_dirty_log_stop_postponed_run(void)
static void memory_vm_change_state_handler(void *opaque, bool running,
RunState state)
{
+ Error *local_err = NULL;
+
if (running) {
- memory_global_dirty_log_stop_postponed_run();
+ memory_global_dirty_log_stop_postponed_run(&local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
}
}
-void memory_global_dirty_log_stop(unsigned int flags)
+void memory_global_dirty_log_stop(unsigned int flags, Error **errp)
{
if (!runstate_is_running()) {
/* Postpone the dirty log stop, e.g., to when VM starts again */
@@ -3001,7 +3010,7 @@ void memory_global_dirty_log_stop(unsigned int flags)
return;
}
- memory_global_dirty_log_do_stop(flags);
+ memory_global_dirty_log_do_stop(flags, errp);
}
static void listener_add_address_space(MemoryListener *listener,
@@ -3009,13 +3018,17 @@ static void listener_add_address_space(MemoryListener *listener,
{
FlatView *view;
FlatRange *fr;
+ Error *local_err = NULL;
if (listener->begin) {
listener->begin(listener);
}
if (global_dirty_tracking) {
if (listener->log_global_start) {
- listener->log_global_start(listener);
+ listener->log_global_start(listener, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
}
}
--
2.43.0
Hi Cédric, On 7/2/24 14:33, Cédric Le Goater wrote: > Modify memory_global_dirty_log_start() and memory_global_dirty_log_stop() > to also take an Error** parameter and report the error in the callers. > Aside from error reporting, there should be no functional changes. > > Cc: Stefano Stabellini <sstabellini@kernel.org> > Cc: Anthony Perard <anthony.perard@citrix.com> > Cc: Paul Durrant <paul@xen.org> > Cc: Michael S. Tsirkin <mst@redhat.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > Cc: David Hildenbrand <david@redhat.com> > Signed-off-by: Cédric Le Goater <clg@redhat.com> > --- > include/exec/memory.h | 12 ++++++++---- > hw/i386/xen/xen-hvm.c | 8 ++++---- > hw/vfio/common.c | 6 ++++-- > hw/virtio/vhost.c | 4 ++-- > migration/dirtyrate.c | 24 ++++++++++++++++++++---- > migration/ram.c | 27 +++++++++++++++++++++++---- > system/memory.c | 37 +++++++++++++++++++++++++------------ > 7 files changed, 86 insertions(+), 32 deletions(-) > > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 177be23db709d8bab9cebfe6acbae57611073327..b348070dc8f17b3505196d3a92d8cfb2171b640f 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -998,8 +998,9 @@ struct MemoryListener { > * active at that time. > * > * @listener: The #MemoryListener. > + * @errp: pointer to Error*, to store an error if it happens. > */ > - void (*log_global_start)(MemoryListener *listener); > + void (*log_global_start)(MemoryListener *listener, Error **errp); As documented in error.h, functions taking an Error** handle as last argument should return a boolean indicating failure... (multiple occurrences) > diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c > index 1d2e85746fb7b10eb7f149976970f9a92125af8a..443acab7a7efbd6e9c94883363e1a827a3538292 100644 > --- a/migration/dirtyrate.c > +++ b/migration/dirtyrate.c > @@ -90,13 +90,19 @@ static int64_t do_calculate_dirtyrate(DirtyPageRecord dirty_pages, > > void global_dirty_log_change(unsigned int flag, bool start) > { > + Error *local_err = NULL; > + > bql_lock(); > if (start) { > - memory_global_dirty_log_start(flag); > + memory_global_dirty_log_start(flag, &local_err); > } else { > - memory_global_dirty_log_stop(flag); > + memory_global_dirty_log_stop(flag, &local_err); > } > bql_unlock(); > + > + if (local_err) { ... that way we don't have to check the pointer. > + error_report_err(local_err); > + } > }
On Wed, Feb 07, 2024 at 02:33:36PM +0100, Cédric Le Goater wrote: > @@ -2936,14 +2940,14 @@ void memory_global_dirty_log_start(unsigned int flags) > trace_global_dirty_changed(global_dirty_tracking); > > if (!old_flags) { > - MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward); > + MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward, errp); > memory_region_transaction_begin(); > memory_region_update_pending = true; > memory_region_transaction_commit(); > } > } > > -static void memory_global_dirty_log_do_stop(unsigned int flags) > +static void memory_global_dirty_log_do_stop(unsigned int flags, Error **errp) > { > assert(flags && !(flags & (~GLOBAL_DIRTY_MASK))); > assert((global_dirty_tracking & flags) == flags); > @@ -2955,7 +2959,7 @@ static void memory_global_dirty_log_do_stop(unsigned int flags) > memory_region_transaction_begin(); > memory_region_update_pending = true; > memory_region_transaction_commit(); > - MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse); > + MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse, errp); > } > } I'm a little bit surprised to see that MEMORY_LISTENER_CALL_GLOBAL() already allows >2 args, with the ability to conditionally pass over errp with such oneliner change; even if all callers were only using 2 args before this patch.. Acked-by: Peter Xu <peterx@redhat.com> -- Peter Xu
On 2/8/24 06:48, Peter Xu wrote: > On Wed, Feb 07, 2024 at 02:33:36PM +0100, Cédric Le Goater wrote: >> @@ -2936,14 +2940,14 @@ void memory_global_dirty_log_start(unsigned int flags) >> trace_global_dirty_changed(global_dirty_tracking); >> >> if (!old_flags) { >> - MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward); >> + MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward, errp); >> memory_region_transaction_begin(); >> memory_region_update_pending = true; >> memory_region_transaction_commit(); >> } >> } >> >> -static void memory_global_dirty_log_do_stop(unsigned int flags) >> +static void memory_global_dirty_log_do_stop(unsigned int flags, Error **errp) >> { >> assert(flags && !(flags & (~GLOBAL_DIRTY_MASK))); >> assert((global_dirty_tracking & flags) == flags); >> @@ -2955,7 +2959,7 @@ static void memory_global_dirty_log_do_stop(unsigned int flags) >> memory_region_transaction_begin(); >> memory_region_update_pending = true; >> memory_region_transaction_commit(); >> - MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse); >> + MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse, errp); >> } >> } > > I'm a little bit surprised to see that MEMORY_LISTENER_CALL_GLOBAL() > already allows >2 args, with the ability to conditionally pass over errp > with such oneliner change; even if all callers were only using 2 args > before this patch.. yes. The proposal takes the easy path. Should we change all memory listener global handlers : begin commit log_global_after_sync log_global_start log_global_stop to take an extra Error **errp argument ? I think we should distinguish begin + commit handlers from the log_global_* with a new macro. In which case, we could also change the handler to return a bool and fail at the first error in MEMORY_LISTENER_CALL_GLOBAL(...). Thanks, C.
Hi Cedric, On 09/02/2024 12:14, Cédric Le Goater wrote: > External email: Use caution opening links or attachments > > > On 2/8/24 06:48, Peter Xu wrote: >> On Wed, Feb 07, 2024 at 02:33:36PM +0100, Cédric Le Goater wrote: >>> @@ -2936,14 +2940,14 @@ void memory_global_dirty_log_start(unsigned >>> int flags) >>> trace_global_dirty_changed(global_dirty_tracking); >>> >>> if (!old_flags) { >>> - MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward); >>> + MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward, errp); >>> memory_region_transaction_begin(); >>> memory_region_update_pending = true; >>> memory_region_transaction_commit(); >>> } >>> } >>> >>> -static void memory_global_dirty_log_do_stop(unsigned int flags) >>> +static void memory_global_dirty_log_do_stop(unsigned int flags, >>> Error **errp) >>> { >>> assert(flags && !(flags & (~GLOBAL_DIRTY_MASK))); >>> assert((global_dirty_tracking & flags) == flags); >>> @@ -2955,7 +2959,7 @@ static void >>> memory_global_dirty_log_do_stop(unsigned int flags) >>> memory_region_transaction_begin(); >>> memory_region_update_pending = true; >>> memory_region_transaction_commit(); >>> - MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse); >>> + MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse, errp); >>> } >>> } >> >> I'm a little bit surprised to see that MEMORY_LISTENER_CALL_GLOBAL() >> already allows >2 args, with the ability to conditionally pass over errp >> with such oneliner change; even if all callers were only using 2 args >> before this patch.. > yes. The proposal takes the easy path. > > Should we change all memory listener global handlers : > > begin > commit > log_global_after_sync > log_global_start > log_global_stop > > to take an extra Error **errp argument ? > > I think we should distinguish begin + commit handlers from the > log_global_* > with a new macro. In which case, we could also change the handler to > return > a bool and fail at the first error in MEMORY_LISTENER_CALL_GLOBAL(...). I think we must fail at first error in any case. Otherwise, if two handlers error and call error_setg() with errp, the second handler will assert IIUC.
On 2/12/24 09:43, Avihai Horon wrote: > Hi Cedric, > > On 09/02/2024 12:14, Cédric Le Goater wrote: >> External email: Use caution opening links or attachments >> >> >> On 2/8/24 06:48, Peter Xu wrote: >>> On Wed, Feb 07, 2024 at 02:33:36PM +0100, Cédric Le Goater wrote: >>>> @@ -2936,14 +2940,14 @@ void memory_global_dirty_log_start(unsigned int flags) >>>> trace_global_dirty_changed(global_dirty_tracking); >>>> >>>> if (!old_flags) { >>>> - MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward); >>>> + MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward, errp); >>>> memory_region_transaction_begin(); >>>> memory_region_update_pending = true; >>>> memory_region_transaction_commit(); >>>> } >>>> } >>>> >>>> -static void memory_global_dirty_log_do_stop(unsigned int flags) >>>> +static void memory_global_dirty_log_do_stop(unsigned int flags, Error **errp) >>>> { >>>> assert(flags && !(flags & (~GLOBAL_DIRTY_MASK))); >>>> assert((global_dirty_tracking & flags) == flags); >>>> @@ -2955,7 +2959,7 @@ static void memory_global_dirty_log_do_stop(unsigned int flags) >>>> memory_region_transaction_begin(); >>>> memory_region_update_pending = true; >>>> memory_region_transaction_commit(); >>>> - MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse); >>>> + MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse, errp); >>>> } >>>> } >>> >>> I'm a little bit surprised to see that MEMORY_LISTENER_CALL_GLOBAL() >>> already allows >2 args, with the ability to conditionally pass over errp >>> with such oneliner change; even if all callers were only using 2 args >>> before this patch.. >> yes. The proposal takes the easy path. >> >> Should we change all memory listener global handlers : >> >> begin >> commit >> log_global_after_sync >> log_global_start >> log_global_stop >> >> to take an extra Error **errp argument ? >> >> I think we should distinguish begin + commit handlers from the log_global_* >> with a new macro. In which case, we could also change the handler to return >> a bool and fail at the first error in MEMORY_LISTENER_CALL_GLOBAL(...). > > I think we must fail at first error in any case. Otherwise, if two handlers error and call error_setg() with errp, the second handler will assert IIUC. Good point. I will respin with a new MEMORY_LISTENER_CALL_GLOBAL_ERR macro exiting the loop at first error. Thanks, C.
© 2016 - 2024 Red Hat, Inc.