[RFC PATCH 1/2] node_device_conf: virNodeDeviceGetSCSITargetCaps: fix memory leak

2024-03-27 Thread Marc Hartmayer
eDevices (node_device_udev.c:1691) ==9104==by 0xBF639B5: nodeStateInitializeEnumerate (node_device_udev.c:2009) ==9104==by 0x49BDBFD: virThreadHelper (virthread.c:256) ==9104==by 0x5242069: start_thread (in /usr/lib64/libc.so.6) Signed-off-by: Marc Hartmayer --- src/conf/node_device_con

[RFC PATCT 2/2] TODO virNodeDeviceUpdateCaps: checks missing?

2024-03-27 Thread Marc Hartmayer
I'm not familiar with the code so I cannot decide if ignoring the return values is a bug or not. At least, it looks awkward and should be annotated. Signed-off-by: Marc Hartmayer --- src/conf/node_device_conf.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src

[RFC PATCH 0/2] One memory leak fix and one question

2024-03-27 Thread Marc Hartmayer
Marc Hartmayer (2): node_device_conf: virNodeDeviceGetSCSITargetCaps: fix memory leak TODO virNodeDeviceUpdateCaps: checks missing? src/conf/node_device_conf.c | 37 - 1 file changed, 16 insertions(+), 21 deletions(-) -- 2.34.1

Re: [PATCH 2/3] nodedev: immediate update of active config on udev add

2024-03-27 Thread Marc Hartmayer
vice() already schedules an > mdevctl update thread to be run after this function (udevAddOneDevice()) > is called for a mediated device. So after this patch, a new udev event > for a mediated device would result in the udev thread querying mdevctl > immediately and then also spawnin

Re: [RFC PATCH 1/2] node_device_conf: virNodeDeviceGetSCSITargetCaps: fix memory leak

2024-03-28 Thread Marc Hartmayer
On Thu, Mar 28, 2024 at 03:55 PM +0100, Ján Tomko wrote: > On a Wednesday in 2024, Marc Hartmayer wrote: >>Make sure the old value in `scsi_target->wwpn` is free'd before replacing it. >>While at it, simplify the code. >> > > "While at it" usuall

Re: [RFC PATCT 2/2] TODO virNodeDeviceUpdateCaps: checks missing?

2024-03-28 Thread Marc Hartmayer
On Thu, Mar 28, 2024 at 04:00 PM +0100, Ján Tomko wrote: > On a Wednesday in 2024, Marc Hartmayer wrote: >>I'm not familiar with the code so I cannot decide if ignoring the return >>values >>is a bug or not. At least, it looks awkward and should be annotated. >>

Re: [RFC PATCT 2/2] TODO virNodeDeviceUpdateCaps: checks missing?

2024-04-03 Thread Marc Hartmayer
On Thu, Mar 28, 2024 at 04:53 PM +0100, "Marc Hartmayer" wrote: > On Thu, Mar 28, 2024 at 04:00 PM +0100, Ján Tomko wrote: >> On a Wednesday in 2024, Marc Hartmayer wrote: >>>I'm not familiar with the code so I cannot decide if ignoring the return >>&

[PATCH v1] node_device_conf: virNodeDeviceGetSCSITargetCaps: fix memory leak

2024-04-03 Thread Marc Hartmayer
) ==9104==by 0xBF639B5: nodeStateInitializeEnumerate (node_device_udev.c:2009) ==9104==by 0x49BDBFD: virThreadHelper (virthread.c:256) ==9104==by 0x5242069: start_thread (in /usr/lib64/libc.so.6) Signed-off-by: Marc Hartmayer --- src/conf/node_device_conf.c | 5 - 1 file ch

[RFC PATCH v1 0/5] node_device_udev: small improvements

2024-04-03 Thread Marc Hartmayer
The first patch fixes a resource leak, the other patches are small improvements and locking improvements. Marc Hartmayer (5): node_device_udev: Remove the timeout if the data is disposed node_device_udev: Test for mdevctlTimeout != -1 node_device_udev: Add comments about locking

[RFC PATCH v1 3/5] node_device_udev: Add comments about locking

2024-04-03 Thread Marc Hartmayer
caller of `nodeDeviceUpdateMediatedDevices` must hold this lock. Currently, that's not the case. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node_device/node_device_udev.c b/

[RFC PATCH v1 5/5] node_device_udev: Rename `th` to `udevThread`

2024-04-03 Thread Marc Hartmayer
The new thread name makes it easier to understand the purpose of the thread. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device

[RFC PATCH v1 2/5] node_device_udev: Test for mdevctlTimeout != -1

2024-04-03 Thread Marc Hartmayer
It is done a little differently everywhere in libvirt, but most common is to test for != -1. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device

[RFC PATCH v1 4/5] node_device_udev: Take lock if driver->privateData is modified

2024-04-03 Thread Marc Hartmayer
Since @driver->privateData is modified take the lock. Question: In theory we could take the udevEventData->mdevctlLock? Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/node_

[RFC PATCH v1 1/5] node_device_udev: Remove the timeout if the data is disposed

2024-04-03 Thread Marc Hartmayer
Remove the timeout when the udevEventData is disposed, analogous to priv->watch. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c in

Re: [RFC PATCH v1 5/5] node_device_udev: Rename `th` to `udevThread`

2024-04-03 Thread Marc Hartmayer
On Wed, Apr 03, 2024 at 04:03 PM +0200, Marc Hartmayer wrote: > The new thread name makes it easier to understand the purpose of the thread. > > Signed-off-by: Marc Hartmayer > --- > src/node_device/node_device_udev.c | 14 +++--- > 1 file changed, 7 insertio

Re: [RFC PATCH 1/2] node_device_conf: virNodeDeviceGetSCSITargetCaps: fix memory leak

2024-04-09 Thread Marc Hartmayer
On Thu, Mar 28, 2024 at 03:55 PM +0100, Ján Tomko wrote: > On a Wednesday in 2024, Marc Hartmayer wrote: >>Make sure the old value in `scsi_target->wwpn` is free'd before replacing it. >>While at it, simplify the code. >> > > "While at it" usuall

Re: [RFC PATCH 1/2] node_device_conf: virNodeDeviceGetSCSITargetCaps: fix memory leak

2024-04-10 Thread Marc Hartmayer
On Wed, Apr 10, 2024 at 09:42 AM +0200, Ján Tomko wrote: > On a Tuesday in 2024, Marc Hartmayer wrote: >>On Thu, Mar 28, 2024 at 03:55 PM +0100, Ján Tomko wrote: >>> On a Wednesday in 2024, Marc Hartmayer wrote: >>>>Make sure the old value in `scsi_target->

Re: [RFC PATCH v1 4/5] node_device_udev: Take lock if driver->privateData is modified

2024-04-12 Thread Marc Hartmayer
On Thu, Apr 11, 2024 at 05:50 PM +0200, Boris Fiuczynski wrote: > Reviewed-by: Boris Fiuczynski > > On 4/3/24 16:03, Marc Hartmayer wrote: >> Since @driver->privateData is modified take the lock. >> >> Question: In theory we could take the udevEventData->mdevc

[RFC PATCH v1 00/15] node_dev_udev: use workerpool and improve nodedev events

2024-04-12 Thread Marc Hartmayer
diate update of active config on udev add nodedev: reset active config data on udev remove event Marc Hartmayer (12): node_device_udev: Set @def to NULL node_device_udev: Remove the timeout if the data is disposed node_device_udev: Test for mdevctlTimeout != -1 node_device_udev: Add comment

[RFC PATCH v1 01/15] nodedev: fix mdev add udev event data handling

2024-04-12 Thread Marc Hartmayer
object will only copy invalid data. Instead copying the defined config data will store valid data into the newly added node object. Signed-off-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Reviewed-by: Marc Hartmayer Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 2

[RFC PATCH v1 02/15] node_device_udev: Set @def to NULL

2024-04-12 Thread Marc Hartmayer
@def to NULL after the ownership has moved. While at it, add comments to other code places why @def is set to NULL. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 4 src/test/test_driver.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff

[RFC PATCH v1 04/15] nodedev: reset active config data on udev remove event

2024-04-12 Thread Marc Hartmayer
From: Boris Fiuczynski When a mdev device is destroyed or stopped the udev remove event handling needs to reset the active config data of the node object representing a persisted mdev. Reviewed-by: Marc Hartmayer Signed-off-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src

[RFC PATCH v1 05/15] node_device_udev: Remove the timeout if the data is disposed

2024-04-12 Thread Marc Hartmayer
Remove the timeout when the udevEventData is disposed, analogous to priv->watch. Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node_device/node_device_udev.c b/src/node_dev

[RFC PATCH v1 06/15] node_device_udev: Test for mdevctlTimeout != -1

2024-04-12 Thread Marc Hartmayer
It is done a little differently everywhere in libvirt, but most common is to test for != -1. Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node_device

[RFC PATCH v1 07/15] node_device_udev: Add comments about locking

2024-04-12 Thread Marc Hartmayer
Commit a99d876a0f58 ("node_device: Use automatic mutex management") replaced the locking mechanism and accidentally removed the comment with the reason why the lock is taken. Restore this comment and add a new comment about the lock. Reviewed-by: Boris Fiuczynski Signed-off-by: Marc

[RFC PATCH v1 09/15] node_device_udev: Add prefix `udev` for udev related data

2024-04-12 Thread Marc Hartmayer
The new names make it easier to understand the purpose of the data. Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 48 +++--- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/node_device

[RFC PATCH v1 03/15] nodedev: immediate update of active config on udev add

2024-04-12 Thread Marc Hartmayer
this change, scheduleMdevctlUpdate call is already called in `udevAddOneDevice` and can therefore be removed in `udevHandleOneDevice`. Signed-off-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 22 +- 1 file changed, 13 insertions

[RFC PATCH v1 08/15] node_device_udev: Take lock if `driver->privateData` is modified

2024-04-12 Thread Marc Hartmayer
Since @driver->privateData is modified take the lock. Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_dev

[RFC PATCH v1 11/15] node_device_udev: Use `stateShutdownPrepare` and `stateShutdownWait`

2024-04-12 Thread Marc Hartmayer
Use the proper driver functions for the node state shutdown preparation and wait. In the next patch, these functions will be extended. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 54 +++--- 1 file changed, 42 insertions(+), 12 deletions

[RFC PATCH v1 15/15] node_device_udev: Make the code easier to read

2024-04-12 Thread Marc Hartmayer
There is only one case where force is true, therefore let's inline that case. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 25 +++-- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/node_device/node_device_udev.c

[RFC PATCH v1 12/15] node_device_udev: Use a worker pool for processing the udev events

2024-04-12 Thread Marc Hartmayer
the code + improve error reporting + improve naming - e.g. rename more udevXXX functions? Signed-off-by: Marc Hartmayer --- src/node_device/node_device_driver.h | 2 +- src/node_device/node_device_driver.c | 6 +- src/node_device/node_device_udev.c | 295 +++ 3 file

[RFC PATCH v1 13/15] node_device_udev: Call `nodeDeviceUpdateMediatedDevices` directly

2024-04-12 Thread Marc Hartmayer
evice` and `udevRemoveOneDeviceSysPath` are only called by the worker pool threads therefore it's possible to call the `nodeDeviceUpdateMediatedDevices` directly without blocking the udev thread. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 16 +++- 1

[RFC PATCH v1 10/15] node_device_udev: Inline `udevRemoveOneDevice`

2024-04-12 Thread Marc Hartmayer
Inline `udevRemoveOneDevice` as it's used only once. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c

[RFC PATCH v1 14/15] node_device_udev: Don't take `mdevctl` lock for querying `mdevctl list`

2024-04-12 Thread Marc Hartmayer
There is no reason to serialize the `mdevctl list` calls. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 9282afdd3241

Re: [RFC PATCH v1 01/15] nodedev: fix mdev add udev event data handling

2024-04-12 Thread Marc Hartmayer
On Fri, Apr 12, 2024 at 03:36 PM +0200, Marc Hartmayer wrote: > From: Boris Fiuczynski > > Two situations will trigger an udev add event: > 1) the mdev is created when started (transient) or > 2) the mdev was defined and is started > In case 1 there is no node object exis

Re: [RFC PATCH v1 03/15] nodedev: immediate update of active config on udev add

2024-04-19 Thread Marc Hartmayer
On Thu, Apr 18, 2024 at 09:47 AM -0500, Jonathon Jongsma wrote: > On 4/12/24 8:36 AM, Marc Hartmayer wrote: >> From: Boris Fiuczynski >> >> When an udev add event occurs the mdev active config data requires an >> update via mdevctl as the udev does not contain all

Re: [RFC PATCH v1 04/15] nodedev: reset active config data on udev remove event

2024-04-19 Thread Marc Hartmayer
On Thu, Apr 18, 2024 at 10:03 AM -0500, Jonathon Jongsma wrote: > On 4/12/24 8:36 AM, Marc Hartmayer wrote: >> From: Boris Fiuczynski >> >> When a mdev device is destroyed or stopped the udev remove event >> handling needs to reset the active config data of the no

Re: [RFC PATCH v1 07/15] node_device_udev: Add comments about locking

2024-04-19 Thread Marc Hartmayer
On Thu, Apr 18, 2024 at 11:18 AM -0500, Jonathon Jongsma wrote: > On 4/12/24 8:36 AM, Marc Hartmayer wrote: >> Commit a99d876a0f58 ("node_device: Use automatic mutex management") replaced >> the >> locking mechanism and accidentally removed the comment with th

Re: [RFC PATCH v1 08/15] node_device_udev: Take lock if `driver->privateData` is modified

2024-04-19 Thread Marc Hartmayer
On Thu, Apr 18, 2024 at 01:48 PM -0500, Jonathon Jongsma wrote: > On 4/12/24 8:36 AM, Marc Hartmayer wrote: >> Since @driver->privateData is modified take the lock. >> […snip…] >>* signal if that event never comes */ >> -scheduleM

Re: [RFC PATCH v1 11/15] node_device_udev: Use `stateShutdownPrepare` and `stateShutdownWait`

2024-04-19 Thread Marc Hartmayer
On Thu, Apr 18, 2024 at 05:01 PM -0500, Jonathon Jongsma wrote: > On 4/12/24 8:36 AM, Marc Hartmayer wrote: >> Use the proper driver functions for the node state shutdown preparation and >> wait. In the next patch, these functions will be extended. >> >> Si

Re: [RFC PATCH v1 12/15] node_device_udev: Use a worker pool for processing the udev events

2024-04-19 Thread Marc Hartmayer
On Thu, Apr 18, 2024 at 05:19 PM -0500, Jonathon Jongsma wrote: > On 4/12/24 8:36 AM, Marc Hartmayer wrote: >> Use a worker pool for processing the udev events and the initialization >> instead >> of a separate initThread and a mdevctl-thread. This has the large advanta

[PATCH v1 01/20] nodedev: fix mdev add udev event data handling

2024-04-19 Thread Marc Hartmayer
object will only copy invalid data. Instead copying the defined config data will store valid data into the newly added node object. Signed-off-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Reviewed-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 2 +- 1 file changed, 1

[PATCH v1 00/20] node_dev_udev: use workerpool and improve nodedev events

2024-04-19 Thread Marc Hartmayer
te of active config on udev add nodedev: reset active config data on udev remove event Marc Hartmayer (17): node_device_udev: Set @def to NULL node_device_udev: Remove the timeout if the data is disposed node_device_udev: Test for mdevctlTimeout != -1 node_device_udev: Don't take `mdevc

[PATCH v1 02/20] node_device_udev: Set @def to NULL

2024-04-19 Thread Marc Hartmayer
@def to NULL after the ownership has moved. While at it, add comments to other code places why @def is set to NULL. Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 4 src/test/test_driver.c | 3 ++- 2 files changed, 6

[PATCH v1 03/20] nodedev: immediate update of active config on udev add

2024-04-19 Thread Marc Hartmayer
this change, scheduleMdevctlUpdate call is already called in `udevAddOneDevice` and can therefore be removed in `udevHandleOneDevice`. Reviewed-by: Jonathon Jongsma Signed-off-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 23

[PATCH v1 06/20] node_device_udev: Test for mdevctlTimeout != -1

2024-04-19 Thread Marc Hartmayer
It is done a little differently everywhere in libvirt, but most common is to test for != -1. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff

[PATCH v1 04/20] nodedev: reset active config data on udev remove event

2024-04-19 Thread Marc Hartmayer
From: Boris Fiuczynski When a mdev device is destroyed or stopped the udev remove event handling needs to reset the active config data of the node object representing a persisted mdev. Reviewed-by: Marc Hartmayer Reviewed-by: Jonathon Jongsma Signed-off-by: Boris Fiuczynski --- src

[PATCH v1 05/20] node_device_udev: Remove the timeout if the data is disposed

2024-04-19 Thread Marc Hartmayer
Remove the timeout when the udevEventData is disposed, analogous to priv->watch. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node_dev

[PATCH v1 10/20] node_device_udev: Inline `udevRemoveOneDevice`

2024-04-19 Thread Marc Hartmayer
Inline `udevRemoveOneDevice` as it's used only once. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/node_d

[PATCH v1 08/20] node_device_udev: Take lock if `driver->privateData` is modified

2024-04-19 Thread Marc Hartmayer
Since @driver->privateData is modified take the lock. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/node_dev

[PATCH v1 11/20] node_device_udev: Move responsibility to release `(init|udev)Thread` to `udevEventDataDispose`

2024-04-19 Thread Marc Hartmayer
Everything is released in `udevEventDataDispose` except for the threads, change this as this makes the code easier to read as it can be simplified a little. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions

[PATCH v1 07/20] node_device_udev: Don't take `mdevctlLock` for `mdevctl list` and add comments about locking

2024-04-19 Thread Marc Hartmayer
er valid or maybe it never was. Therefore, let's remove this lock and add a comment to `mdevCtl` what it protects. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/node_device/node_device_

[PATCH v1 12/20] node_device_udev: Fix leak of mdevctlLock, udevThreadCond, and mdevCtlMonitors

2024-04-19 Thread Marc Hartmayer
Even if `priv->udev_monitor` was never initialized, the mdevctlLock, udevThread were. Therefore let's match the order of releasing the resources the order of allocating the resources in `nodeStateInitialize`. In addition, use `g_steal_pointer` in `g_list_free_full`. Signed-off-by: Marc H

[PATCH v1 09/20] node_device_udev: Add prefix `udev` for udev related data

2024-04-19 Thread Marc Hartmayer
The new names make it easier to understand the purpose of the data. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 48 +++--- 1 file changed, 24 insertions(+), 24 deletions(-) diff

[PATCH v1 13/20] node_device_udev: Introduce and use `stateShutdownPrepare` and `stateShutdownWait`

2024-04-19 Thread Marc Hartmayer
these functions will be extended. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 84 ++ 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 1638a71

[PATCH v1 14/20] node_device_udev: nodeStateShutdownPrepare: Disconnect the signals explicitly

2024-04-19 Thread Marc Hartmayer
. [1] https://docs.gtk.org/gobject/signals.html#memory-management-of-signal-handlers Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index a3006

[PATCH v1 16/20] node_device_udev: Use a worker pool for processing events and emitting nodedev event

2024-04-19 Thread Marc Hartmayer
" and emitting the libvirt nodedev events. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 244 + 1 file changed, 179 insertions(+), 65 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index e4

[PATCH v1 18/20] node_device_udev: Make the code easier to read

2024-04-19 Thread Marc Hartmayer
There is only one case where force is true, therefore let's inline that case. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 25 +++-- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/node_device/node_device_udev.c

[PATCH v1 15/20] node_device_udev: Pass the driver state as parameter in preparation for the next commit

2024-04-19 Thread Marc Hartmayer
It's better practice for all functions called by the threads to pass the driver via parameter and not global variables. Easier to test and cleaner. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_driver.h | 2 +- src/node_device/node_device_driver.c | 6 +-- src/node_d

[PATCH v1 19/20] node_device_udev: Add support for `g_autoptr` to `udevEventData`

2024-04-19 Thread Marc Hartmayer
Use this feature in `udevEventDataNew`. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 0b255952a9f9

[PATCH v1 17/20] node_device_udev: Call `nodeDeviceUpdateMediatedDevices` directly

2024-04-19 Thread Marc Hartmayer
evice` and `udevRemoveOneDeviceSysPath` are only called by the worker pool threads therefore it's possible to call the `nodeDeviceUpdateMediatedDevices` directly without blocking the udev thread. Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 16 +++- 1

[PATCH v1 20/20] node_device_udev: Pass the `udevEventData` via parameter and use refcounting

2024-04-19 Thread Marc Hartmayer
Instead of accessing the global `driver` object pass the `udevEventData` as parameter to the thread handler and watch callback. This has the advantage that: 1. proper refcounting 2. easier to read and test Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 14

Re: [PATCH v1 16/20] node_device_udev: Use a worker pool for processing events and emitting nodedev event

2024-04-19 Thread Marc Hartmayer
On Fri, Apr 19, 2024 at 04:49 PM +0200, Marc Hartmayer wrote: > Use a worker pool for processing the events (e.g. udev, mdevctl config > changes) > and the initialization instead of a separate initThread and a mdevctl-thread. > This has the large advantage that we can leverage the

Re: [PATCH v1 16/20] node_device_udev: Use a worker pool for processing events and emitting nodedev event

2024-04-22 Thread Marc Hartmayer
On Fri, Apr 19, 2024 at 04:49 PM +0200, Marc Hartmayer wrote: > Use a worker pool for processing the events (e.g. udev, mdevctl config > changes) > and the initialization instead of a separate initThread and a mdevctl-thread. > This has the large advantage that we can leverage the

Re: [PATCH v1 15/20] node_device_udev: Pass the driver state as parameter in preparation for the next commit

2024-04-23 Thread Marc Hartmayer
On Fri, Apr 19, 2024 at 02:23 PM -0500, Jonathon Jongsma wrote: > On 4/19/24 9:49 AM, Marc Hartmayer wrote: >> It's better practice for all functions called by the threads to pass the >> driver >> via parameter and not global variables. Easier to te

Re: [PATCH v1 17/20] node_device_udev: Call `nodeDeviceUpdateMediatedDevices` directly

2024-04-23 Thread Marc Hartmayer
On Mon, Apr 22, 2024 at 05:43 PM +0200, Boris Fiuczynski wrote: > This could be quashed with patch 3 but I am also fine with this if you > do not want to spend the effort. > > Reviewed-by: Boris Fiuczynski Will squash it. […snip] -- Kind regards / Beste Grüße Marc Ha

Re: [PATCH v1 15/20] node_device_udev: Pass the driver state as parameter in preparation for the next commit

2024-04-23 Thread Marc Hartmayer
On Tue, Apr 23, 2024 at 09:10 AM +0100, Daniel P. Berrangé wrote: > On Tue, Apr 23, 2024 at 10:03:35AM +0200, Marc Hartmayer wrote: >> On Fri, Apr 19, 2024 at 02:23 PM -0500, Jonathon Jongsma >> wrote: >> > On 4/19/24 9:49 AM, Marc Hartmayer wrote: >> >> It

Re: [PATCH v1 15/20] node_device_udev: Pass the driver state as parameter in preparation for the next commit

2024-04-23 Thread Marc Hartmayer
On Tue, Apr 23, 2024 at 10:06 AM +0100, Daniel P. Berrangé wrote: > On Tue, Apr 23, 2024 at 10:46:14AM +0200, Marc Hartmayer wrote: >> On Tue, Apr 23, 2024 at 09:10 AM +0100, Daniel P. Berrangé >> wrote: >> > On Tue, Apr 23, 2024 at 10:03:35AM +0200, Marc Hartmayer wro

[PATCH v2 01/20] nodedev: fix mdev add udev event data handling

2024-04-23 Thread Marc Hartmayer
object will only copy invalid data. Instead copying the defined config data will store valid data into the newly added node object. Signed-off-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Reviewed-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 2 +- 1 file changed, 1

[PATCH v2 00/20] node_dev_udev: use workerpool and improve nodedev events

2024-04-23 Thread Marc Hartmayer
of active config on udev events nodedev: reset active config data on udev remove event Marc Hartmayer (17): node_device_udev: Set @def to NULL node_device_udev: Remove the timeout if the data is disposed node_device_udev: Test for mdevctlTimeout != -1 node_device_udev: Don't tak

[PATCH v2 05/20] node_device_udev: Remove the timeout if the data is disposed

2024-04-23 Thread Marc Hartmayer
Remove the timeout when the udevEventData is disposed, analogous to priv->watch. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node_dev

[PATCH v2 07/20] node_device_udev: Don't take `mdevctlLock` for `mdevctl list` and add comments about locking

2024-04-23 Thread Marc Hartmayer
er valid or maybe it never was. Therefore, let's remove this lock and add a comment to `mdevCtl` what it protects. Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 6 ++ 1 file changed, 2 insertions(+), 4

[PATCH v2 02/20] node_device_udev: Set @def to NULL

2024-04-23 Thread Marc Hartmayer
@def to NULL after the ownership has moved. While at it, add comments to other code places why @def is set to NULL. Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 4 src/test/test_driver.c | 3 ++- 2 files changed, 6

[PATCH v2 06/20] node_device_udev: Test for mdevctlTimeout != -1

2024-04-23 Thread Marc Hartmayer
It is done a little differently everywhere in libvirt, but most common is to test for != -1. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff

[PATCH v2 04/20] nodedev: reset active config data on udev remove event

2024-04-23 Thread Marc Hartmayer
From: Boris Fiuczynski When a mdev device is destroyed or stopped the udev remove event handling needs to reset the active config data of the node object representing a persisted mdev. Reviewed-by: Marc Hartmayer Reviewed-by: Jonathon Jongsma Signed-off-by: Boris Fiuczynski --- src

[PATCH v2 08/20] node_device_udev: Take lock if `driver->privateData` is modified

2024-04-23 Thread Marc Hartmayer
Since @driver->privateData is modified take the lock. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node_device/node_device_udev.c

[PATCH v2 03/20] nodedev: immediate update of active config on udev events

2024-04-23 Thread Marc Hartmayer
usage reliable. After this change, scheduleMdevctlUpdate call is already called in `udevAddOneDevice` and can therefore be removed in `udevHandleOneDevice`. Signed-off-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 30 +++--- 1

[PATCH v2 11/20] node_device_udev: Move responsibility to release `(init|udev)Thread` to `udevEventDataDispose`

2024-04-23 Thread Marc Hartmayer
Everything is released in `udevEventDataDispose` except for the threads, change this as this makes the code easier to read as it can be simplified a little. Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 14

[PATCH v2 10/20] node_device_udev: Inline `udevRemoveOneDevice`

2024-04-23 Thread Marc Hartmayer
Inline `udevRemoveOneDevice` as it's used only once. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/node_d

[PATCH v2 14/20] node_device_udev: nodeStateShutdownPrepare: Disconnect the signals explicitly

2024-04-23 Thread Marc Hartmayer
. [1] https://docs.gtk.org/gobject/signals.html#memory-management-of-signal-handlers Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/node_devi

[PATCH v2 13/20] node_device_udev: Introduce and use `stateShutdownPrepare` and `stateShutdownWait`

2024-04-23 Thread Marc Hartmayer
these functions will be extended. Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 84 ++ 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/src/node_device/node_device_udev.c

[PATCH v2 12/20] node_device_udev: Fix leak of mdevctlLock, udevThreadCond, and mdevCtlMonitors

2024-04-23 Thread Marc Hartmayer
Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 9aab4340fa2d..906b

[PATCH v2 09/20] node_device_udev: Add prefix `udev` for udev related data

2024-04-23 Thread Marc Hartmayer
The new names make it easier to understand the purpose of the data. Reviewed-by: Boris Fiuczynski Reviewed-by: Jonathon Jongsma Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 48 +++--- 1 file changed, 24 insertions(+), 24 deletions(-) diff

[PATCH v2 20/20] node_device_udev: remove incorrect G_GNUC_UNUSED

2024-04-23 Thread Marc Hartmayer
Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 14d44d5bcd0e..cc725997a39e 100644 --- a/src/node_device/node_device_udev.c +++ b

[PATCH v2 15/20] node_device_udev: Pass the driver state as parameter in preparation for the next commit

2024-04-23 Thread Marc Hartmayer
It's better practice for all functions called by the threads to pass the driver via parameter and not global variables. Easier to test and cleaner. Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_driver.h | 2 +-

[PATCH v2 18/20] node_device_udev: Add support for `g_autoptr` to `udevEventData`

2024-04-23 Thread Marc Hartmayer
Use this feature in `udevEventDataNew`. Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src

[PATCH v2 17/20] node_device_udev: Make the code easier to read

2024-04-23 Thread Marc Hartmayer
There is only one case where force is true, therefore let's inline that case. Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_udev.c | 25 +++-- 1 file changed, 11 insertions(+), 14 dele

[PATCH v2 16/20] node_device_udev: Use a worker pool for processing events and emitting nodedev event

2024-04-23 Thread Marc Hartmayer
" and emitting the libvirt nodedev events. Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer --- src/node_device/node_device_driver.c | 9 +- src/node_device/node_device_udev.c | 241 +++ src/test/test_driver.c |

[PATCH v2 19/20] node_device_udev: Pass the `udevEventData` via parameter and use refcounting

2024-04-23 Thread Marc Hartmayer
Instead of accessing the global `driver` object pass the `udevEventData` as parameter to the thread handler and watch callback. This has the advantage that: 1. proper refcounting 2. easier to read and test Reviewed-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Signed-off-by: Marc Hartmayer

Re: [PATCH v1 16/20] node_device_udev: Use a worker pool for processing events and emitting nodedev event

2024-04-26 Thread Marc Hartmayer
On Fri, Apr 19, 2024 at 04:49 PM +0200, Marc Hartmayer wrote: > Use a worker pool for processing the events (e.g. udev, mdevctl config > changes) > and the initialization instead of a separate initThread and a mdevctl-thread. > This has the large advantage that we can leverage the

Re: [PATCH v2 00/20] node_dev_udev: use workerpool and improve nodedev events

2024-06-13 Thread Marc Hartmayer
On Tue, Apr 23, 2024 at 08:08 PM +0200, Marc Hartmayer wrote: > When an udev event occurs for a mediated device (mdev) the mdev config data > requires an update via mdevctl as the udev event does not contain all config > data. This update needs to occur immediately and to be finished b

Re: [PATCH v2 00/20] node_dev_udev: use workerpool and improve nodedev events

2024-06-19 Thread Marc Hartmayer
On Tue, Jun 18, 2024 at 08:59 AM -0500, Jonathon Jongsma wrote: > On 6/18/24 6:33 AM, Boris Fiuczynski wrote: >> On 6/13/24 11:14 PM, Jonathon Jongsma wrote: >>> On 6/13/24 6:13 AM, Marc Hartmayer wrote: >>>> On Tue, Apr 23, 2024 at 08:08 PM +0200, Marc Hartmayer &