Message ID | 20240117091559.144730-2-peterx@redhat.com |
---|---|
State | New |
Headers | show |
Series | intel_iommu: Reset vIOMMU after all the rest of devices | expand |
On 1/17/24 10:15, peterx@redhat.com wrote: > From: Peter Xu <peterx@redhat.com> > > Cleanup the code to use a single entrance on register reset hooks. > > Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Eric > --- > hw/core/reset.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/hw/core/reset.c b/hw/core/reset.c > index d3263b613e..8cf60b2b09 100644 > --- a/hw/core/reset.c > +++ b/hw/core/reset.c > @@ -39,23 +39,26 @@ typedef struct QEMUResetEntry { > static QTAILQ_HEAD(, QEMUResetEntry) reset_handlers = > QTAILQ_HEAD_INITIALIZER(reset_handlers); > > -void qemu_register_reset(QEMUResetHandler *func, void *opaque) > +static void qemu_register_reset_one(QEMUResetHandler *func, void *opaque, > + bool skip_snap) > { > QEMUResetEntry *re = g_new0(QEMUResetEntry, 1); > > re->func = func; > re->opaque = opaque; > + re->skip_on_snapshot_load = skip_snap; > QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); > } > > -void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaque) > +void qemu_register_reset(QEMUResetHandler *func, void *opaque) > { > - QEMUResetEntry *re = g_new0(QEMUResetEntry, 1); > + /* By default, do not skip during load of a snapshot */ > + qemu_register_reset_one(func, opaque, false); > +} > > - re->func = func; > - re->opaque = opaque; > - re->skip_on_snapshot_load = true; > - QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); > +void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaque) > +{ > + qemu_register_reset_one(func, opaque, true); > } > > void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
diff --git a/hw/core/reset.c b/hw/core/reset.c index d3263b613e..8cf60b2b09 100644 --- a/hw/core/reset.c +++ b/hw/core/reset.c @@ -39,23 +39,26 @@ typedef struct QEMUResetEntry { static QTAILQ_HEAD(, QEMUResetEntry) reset_handlers = QTAILQ_HEAD_INITIALIZER(reset_handlers); -void qemu_register_reset(QEMUResetHandler *func, void *opaque) +static void qemu_register_reset_one(QEMUResetHandler *func, void *opaque, + bool skip_snap) { QEMUResetEntry *re = g_new0(QEMUResetEntry, 1); re->func = func; re->opaque = opaque; + re->skip_on_snapshot_load = skip_snap; QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); } -void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaque) +void qemu_register_reset(QEMUResetHandler *func, void *opaque) { - QEMUResetEntry *re = g_new0(QEMUResetEntry, 1); + /* By default, do not skip during load of a snapshot */ + qemu_register_reset_one(func, opaque, false); +} - re->func = func; - re->opaque = opaque; - re->skip_on_snapshot_load = true; - QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); +void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaque) +{ + qemu_register_reset_one(func, opaque, true); } void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)