hw/vfio/ap: attribute constructor for cfg_chg_events_lock
RFC PATCH 1/1 hw/vfio/ap: attribute constructor for cfg_chg_events_lock
Created an attribute constructor for cfg_chg_events_lock for locking mechanism when storing event information for an AP configuration change event
--- hw/vfio/ap.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
hw/vfio/ap.c +5 -7
@@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent) cfg_chg_events =static QemuMutex cfg_chg_events_lock; +static void __attribute__((constructor))vfio_ap_global_init (void ) +{ +qemu_mutex_init (&cfg_chg_events_lock); +} + OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)static void vfio_ap_compute_needs_reset (VFIODevice *vdev)
@@ -230,13 +235,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)VFIOAPDevice *vapdev =VFIO_AP_DEVICE (dev);VFIODevice *vbasedev = &vapdev->vdev; -static bool lock_initialized; - -if (!lock_initialized) { -qemu_mutex_init (&cfg_chg_events_lock); - lock_initialized = true; - } -if (!vfio_device_get_name (vbasedev, errp)) {return ; }
Signature · 1 line
2.48.1
Quoted 15 lines · Rorie Reyes
Created an attribute constructor for
cfg_chg_events_lockfor locking mechanism when storing event information for an AP configuration change eventFixes fd03360215 ("Storing event information for an AP configuration change event")Signed-off-by Rorie Reyes <[email protected]>--- hw/vfio/ap.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)hw/vfio/ap.c +0
-0
hw/vfio/ap.c static QTAILQ_HEAD(, APConfigChgEvent) cfg_chg_events = · line 58
Quoted 7 lines
hw/vfio/ap.c +4
-0@@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent) cfg_chg_events =static QemuMutex cfg_chg_events_lock; +static void __attribute__((constructor))vfio_ap_global_init (void ) +{ +qemu_mutex_init (&cfg_chg_events_lock); +}
I wonder why we don't have a macro for this yet (there are many other spots in the code that initialize a mutex like this).
Anyway, for your patch:
Quoted 25 lines · Thomas Huth
Quoted 18 lines · Rorie Reyes
Created an attribute constructor for
cfg_chg_events_lockfor locking mechanism when storing event information for an AP configuration change eventFixes fd03360215 ("Storing event information for an AP configuration change event")Signed-off-by Rorie Reyes <[email protected]>---
hw/vfio/ap.c| 12 +++++-------1 file changed, 5 insertions(+), 7 deletions(-)hw/vfio/ap.c +0
-0@@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent)
cfg_chg_events=
static QemuMutexcfg_chg_events_lock;
+static void __attribute__((constructor))vfio_ap_global_init(void)hw/vfio/ap.c static QTAILQ_HEAD(, APConfigChgEvent) cfg_chg_events = · line 58
Quoted 3 lines
hw/vfio/ap.c +3
-0+{ + qemu_mutex_init(&cfg_chg_events_lock); +}I wonder why we don't have a macro for this yet (there are many other spots in the code that initialize a mutex like this).
Quoted 3 lines
Anyway, for your patch:
Reviewed-by Thomas Huth <[email protected]>
Thank you!
Quoted 30 lines · Rorie Reyes
Created an attribute constructor for
cfg_chg_events_lockfor locking mechanism when storing event information for an AP configuration change eventFixes fd03360215 ("Storing event information for an AP configuration change event")Signed-off-by Rorie Reyes <[email protected]>--- hw/vfio/ap.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)hw/vfio/ap.c +5
-0@@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent) cfg_chg_events =static QemuMutex cfg_chg_events_lock; +static void __attribute__((constructor))vfio_ap_global_init (void ) +{ +qemu_mutex_init (&cfg_chg_events_lock); +} + OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)static void vfio_ap_compute_needs_reset (VFIODevice *vdev)@@ -230,13 +235,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)VFIOAPDevice *vapdev =VFIO_AP_DEVICE (dev);VFIODevice *vbasedev = &vapdev->vdev;
hw/vfio/ap.c static void vfio_ap_realize(DeviceState *dev, Error **errp) · line 240
Quoted 10 lines
hw/vfio/ap.c +0
-7-static bool lock_initialized; - -if (!lock_initialized) { -qemu_mutex_init (&cfg_chg_events_lock); - lock_initialized = true; - } -if (!vfio_device_get_name (vbasedev, errp)) {return ; }
Applied to vfio-next.
Thanks,
C.
Quoted 43 lines · Cédric Le Goater
Quoted 37 lines · Rorie Reyes
Created an attribute constructor for
cfg_chg_events_lockfor locking mechanism when storing event information for an AP configuration change eventFixes fd03360215 ("Storing event information for an AP configuration change event")Signed-off-by Rorie Reyes <[email protected]>---
hw/vfio/ap.c| 12 +++++-------1 file changed, 5 insertions(+), 7 deletions(-)hw/vfio/ap.c +0
-0@@ -52,6 +52,11 @@ static QTAILQ_HEAD(, APConfigChgEvent)
cfg_chg_events=
static QemuMutexcfg_chg_events_lock;
+static void __attribute__((constructor))vfio_ap_global_init(void)hw/vfio/ap.c +4
-0+{ + qemu_mutex_init(&cfg_chg_events_lock); +} +
OBJECT_DECLARE_SIMPLE_TYPE(VFIOAPDevice, VFIO_AP_DEVICE)static voidvfio_ap_compute_needs_reset(VFIODevice *vdev)hw/vfio/ap.c +0
-6@@ -230,13 +235,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp) VFIOAPDevice *vapdev = VFIO_AP_DEVICE(dev); VFIODevice *vbasedev = &vapdev->vdev; - static bool lock_initialized; - - if (!lock_initialized) { - qemu_mutex_init(&cfg_chg_events_lock); - lock_initialized = true; - } - if (!vfio_device_get_name(vbasedev, errp)) { return;Quoted 1 line
}
Reviewed-by Cédric Le Goater <[email protected]>
Quoted 6 lines
Applied to vfio-next.
Thanks,
C.
Thank you!