Re: [PATCH 01/13] tools: Fix vshControl declaration and initialization

2023-08-03 Thread Olaf Hering
Thu, 3 Aug 2023 21:38:02 +0200 Michal Prívozník : > it looks like we're using { 0 } everywhere else so that's why I went with it. I was under the impression {} is valid. But apparently it is not, so I learned something new today: "ISO C forbids empty initializer braces". Olaf

Re: [PATCH 01/13] tools: Fix vshControl declaration and initialization

2023-08-03 Thread Michal Prívozník
On 8/3/23 19:53, Olaf Hering wrote: > Thu, 3 Aug 2023 12:36:08 +0200 Michal Privoznik : > >> +vshControl _ctl = { 0 }; > > I see this often, instead of a simple 'type variable = {};', > and wonder what that zero is doing here? That's C23 standard:

Re: [PATCH 01/13] tools: Fix vshControl declaration and initialization

2023-08-03 Thread Olaf Hering
Thu, 3 Aug 2023 12:36:08 +0200 Michal Privoznik : > +vshControl _ctl = { 0 }; I see this often, instead of a simple 'type variable = {};', and wonder what that zero is doing here? Olaf pgpesWu2O0JH7.pgp Description: Digitale Signatur von OpenPGP

Re: [PATCH 08/13] securityselinuxhelper: Use g_new0() instead of malloc()+memset() combo

2023-08-03 Thread Michal Prívozník
On 8/3/23 13:29, Claudio Fontana wrote: > On 8/3/23 12:36, Michal Privoznik wrote: >> Inside of securityselinuxhelper we still use malloc() + >> memset(.., 0, ...) combo. Convert it to g_new0(). >> >> Signed-off-by: Michal Privoznik > > I don't think it is a good idea to mix Glib g_new, g_free

Re: [PATCH 0/2] libvirt-guests: small improvments

2023-08-03 Thread Jim Fehlig
On 8/3/23 05:52, Martin Kletzander wrote: On Wed, Aug 02, 2023 at 01:40:16PM -0600, Jim Fehlig wrote: On 8/1/23 08:11, Martin Kletzander wrote: On Mon, Jul 31, 2023 at 05:06:44PM -0600, Jim Fehlig wrote: The first patch is trivial. I suppose the second is debatable. If I build libvirt with

Re: [PATCH 04/13] qemu: Don't reuse variable in processSerialChangedEvent()

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > When a VSERPORT_CHANGE event is processed, we firstly do a little > detour and try to detect whether the event is coming from guest > agent. If so, we notify threads that are currently talking to the > agent about this fact. Then we proceed with usual

Re: [PATCH 13/13] lib: Prefer sizeof(variable) instead of sizeof(type) in memset

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > If one of previous commits taught us something, it's that: > sizeof(variable) and sizeof(type) are not the same. Especially > because for live enough code the type might change (e.g. as we > use autoptr more). And since we don't get any warnings when an >

Re: [PATCH 12/13] lib: Finish using struct zero initializer manually

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > There are some cases left after previous commit which were not > picked up by coccinelle. Mostly, becuase the spatch was not > generic enough. We are left with cases like: two variables > declared on one line, a variable declared in #ifdef-s (there are >

Re: [PATCH 11/13] lib: use struct zero initializer instead of memset

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > This is a more concise approach and guarantees there is > no time window where the struct is uninitialized. > > Generated using the following semantic patch: > > @@ > type T; > identifier X; > @@ > - T X; > + T X = { 0 }; > ... when

Re: [PATCH 0/2] libvirt-guests: small improvments

2023-08-03 Thread Martin Kletzander
On Wed, Aug 02, 2023 at 01:40:16PM -0600, Jim Fehlig wrote: On 8/1/23 08:11, Martin Kletzander wrote: On Mon, Jul 31, 2023 at 05:06:44PM -0600, Jim Fehlig wrote: The first patch is trivial. I suppose the second is debatable. If I build libvirt with -Dremote_default_mode=legacy but deploy

Re: [PATCH 10/13] virnetdaemon.c: Use struct zero initializer instead of memset

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > Ideally, these would be fixed by coccinelle (see next commit), > but because of various reasons they aren't. Fix them manually. > > Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana > --- > src/rpc/virnetdaemon.c | 7 ++- > 1 file

Re: [PATCH 09/13] virnetclient: Update comment about memset()

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > Instead of suggesting to zero structs out using memset() we > should suggest initializing structs with zero initializer. > > Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana > --- > src/rpc/virnetclient.c | 4 ++-- > 1 file changed, 2

Re: [PATCH 08/13] securityselinuxhelper: Use g_new0() instead of malloc()+memset() combo

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > Inside of securityselinuxhelper we still use malloc() + > memset(.., 0, ...) combo. Convert it to g_new0(). > > Signed-off-by: Michal Privoznik I don't think it is a good idea to mix Glib g_new, g_free etc with malloc, calloc, free. If you go with

Re: [PATCH 07/13] virnetlink: Drop unused variable from virNetlinkCommand()

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > The fds variable inside of virNetlinkCommand() is not used > really. It's passed to memset() (hence compilers do not > complain), but that's about it. Drop it. > > Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana > --- >

Re: [PATCH 06/13] virfirewalld: Drop useless memset() in virFirewallDApplyRule()

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > This is a residue of v6.8.0-rc1~100. The error variable inside of > virFirewallDApplyRule() is already initialized to NULL. There's > no need to memset() it to zero again. > > Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana > --- >

Re: [PATCH 05/13] remote_driver: Drop explicit memset() in remoteAuthSASL()

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > Inside of remoteAuthSASL() the sargs variable is already > initialized to zero during declaration. There's no need to > memset() it again as it's unused in between it's declaration and > said memset(). > > Signed-off-by: Michal Privoznik Reviewed-by:

Re: [PATCH 02/13] virt-aa-helper: Use struct zero initializer instead of memset

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > This is similar to the previous commit, except this is for a > different type (vahControl) and also fixes the case where _ctl is > passed not initialized to vah_error() (via ctl pointer so that's > probably why compilers don't complain). > >

Re: [PATCH 01/13] tools: Fix vshControl declaration and initialization

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > Both virsh and virt-admin have vshControl typed variables and > also pointers to these variables. In both cases these are > declared on a single line. Do the following: > > 1) break declaration into two lines, > 2) use struct zero initializer for

Re: [PATCH 03/13] Decrease scope of some variables

2023-08-03 Thread Claudio Fontana
On 8/3/23 12:36, Michal Privoznik wrote: > There are couple of variables that are declared at function > beginning but then used solely within a block (either for() loop > or if() statement). And just before their use they are zeroed > explicitly using memset(). Decrease their scope, use struct

[PATCH 08/13] securityselinuxhelper: Use g_new0() instead of malloc()+memset() combo

2023-08-03 Thread Michal Privoznik
Inside of securityselinuxhelper we still use malloc() + memset(.., 0, ...) combo. Convert it to g_new0(). Signed-off-by: Michal Privoznik --- tests/securityselinuxhelper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/securityselinuxhelper.c

[PATCH 02/13] virt-aa-helper: Use struct zero initializer instead of memset

2023-08-03 Thread Michal Privoznik
This is similar to the previous commit, except this is for a different type (vahControl) and also fixes the case where _ctl is passed not initialized to vah_error() (via ctl pointer so that's probably why compilers don't complain). Signed-off-by: Michal Privoznik ---

[PATCH 13/13] lib: Prefer sizeof(variable) instead of sizeof(type) in memset

2023-08-03 Thread Michal Privoznik
If one of previous commits taught us something, it's that: sizeof(variable) and sizeof(type) are not the same. Especially because for live enough code the type might change (e.g. as we use autoptr more). And since we don't get any warnings when an incorrect length is passed to memset() it is easy

[PATCH 10/13] virnetdaemon.c: Use struct zero initializer instead of memset

2023-08-03 Thread Michal Privoznik
Ideally, these would be fixed by coccinelle (see next commit), but because of various reasons they aren't. Fix them manually. Signed-off-by: Michal Privoznik --- src/rpc/virnetdaemon.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/rpc/virnetdaemon.c

[PATCH 11/13] lib: use struct zero initializer instead of memset

2023-08-03 Thread Michal Privoznik
This is a more concise approach and guarantees there is no time window where the struct is uninitialized. Generated using the following semantic patch: @@ type T; identifier X; @@ - T X; + T X = { 0 }; ... when exists ( - memset(, 0, sizeof(X)); | - memset(, 0,

[PATCH 09/13] virnetclient: Update comment about memset()

2023-08-03 Thread Michal Privoznik
Instead of suggesting to zero structs out using memset() we should suggest initializing structs with zero initializer. Signed-off-by: Michal Privoznik --- src/rpc/virnetclient.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/virnetclient.c

[PATCH 12/13] lib: Finish using struct zero initializer manually

2023-08-03 Thread Michal Privoznik
There are some cases left after previous commit which were not picked up by coccinelle. Mostly, becuase the spatch was not generic enough. We are left with cases like: two variables declared on one line, a variable declared in #ifdef-s (there are notoriously difficult for coccinelle), arrays,

[PATCH 07/13] virnetlink: Drop unused variable from virNetlinkCommand()

2023-08-03 Thread Michal Privoznik
The fds variable inside of virNetlinkCommand() is not used really. It's passed to memset() (hence compilers do not complain), but that's about it. Drop it. Signed-off-by: Michal Privoznik --- src/util/virnetlink.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/util/virnetlink.c

[PATCH 05/13] remote_driver: Drop explicit memset() in remoteAuthSASL()

2023-08-03 Thread Michal Privoznik
Inside of remoteAuthSASL() the sargs variable is already initialized to zero during declaration. There's no need to memset() it again as it's unused in between it's declaration and said memset(). Signed-off-by: Michal Privoznik --- src/remote/remote_driver.c | 1 - 1 file changed, 1 deletion(-)

[PATCH 06/13] virfirewalld: Drop useless memset() in virFirewallDApplyRule()

2023-08-03 Thread Michal Privoznik
This is a residue of v6.8.0-rc1~100. The error variable inside of virFirewallDApplyRule() is already initialized to NULL. There's no need to memset() it to zero again. Signed-off-by: Michal Privoznik --- src/util/virfirewalld.c | 2 -- 1 file changed, 2 deletions(-) diff --git

[PATCH 03/13] Decrease scope of some variables

2023-08-03 Thread Michal Privoznik
There are couple of variables that are declared at function beginning but then used solely within a block (either for() loop or if() statement). And just before their use they are zeroed explicitly using memset(). Decrease their scope, use struct zero initializer and drop explicit memset().

[PATCH 04/13] qemu: Don't reuse variable in processSerialChangedEvent()

2023-08-03 Thread Michal Privoznik
When a VSERPORT_CHANGE event is processed, we firstly do a little detour and try to detect whether the event is coming from guest agent. If so, we notify threads that are currently talking to the agent about this fact. Then we proceed with usual event processing (BeginJob(), update domain def,

[PATCH 01/13] tools: Fix vshControl declaration and initialization

2023-08-03 Thread Michal Privoznik
Both virsh and virt-admin have vshControl typed variables and also pointers to these variables. In both cases these are declared on a single line. Do the following: 1) break declaration into two lines, 2) use struct zero initializer for vshControl and virshControl/vshAdmControl structs,

[PATCH 00/13] Use struct zero initializer instead of memset

2023-08-03 Thread Michal Privoznik
This was inspired by Martin's comment here: https://listman.redhat.com/archives/libvir-list/2023-July/241007.html It has sent me down a rabbit hole. But hey, it helped me to identify some needless memset()-s, unused variables, problematic code patterns. Michal Prívozník (13): tools: Fix

Re: [libvirt PATCH 5/5] qemu: Implement support for vDPA block devices

2023-08-03 Thread Stefano Garzarella
On Wed, Aug 2, 2023 at 10:33 PM Jonathon Jongsma wrote: > On 7/24/23 8:05 AM, Peter Krempa wrote: [...] > > > > I've also noticed that using 'qcow2' format for the device doesn't work: > > > > error: internal error: process exited while connecting to monitor: > > 2023-07-24T12:54:15.818631Z