Re: [PATCH 2/2] util: command: improve generic mass close of fds

2020-08-19 Thread Natanael Copa
On Wed, 19 Aug 2020 11:55:06 +0100 Daniel P. Berrangé wrote: > On Wed, Aug 19, 2020 at 12:03:41PM +0200, Natanael Copa wrote: > > Add a portable generic implementation of virMassClose as fallback on > > non-FreeBSD and non-glibc. > > > > This implementation uses pol

[PATCH 0/2] Fix a few deadlocks with musl libc

2020-08-19 Thread Natanael Copa
Fix a couple of deadlocks due to use of async-unsafe calls (malloc/free) after fork() and before exec(). They don't fix all theoretical problems but at least they make libvirt usable again with musl 1.2 on Alpine Linux. Natanael Copa (2): util: avoid free() when reset log after fork

[PATCH 1/2] util: avoid free() when reset log after fork

2020-08-19 Thread Natanael Copa
Doing malloc/free after fork is techincally not allowed in POSIX and deadlocks[1] with musl libc. [1]: https://gitlab.com/libvirt/libvirt/-/issues/52 Signed-off-by: Natanael Copa --- src/util/vircommand.c | 4 ++-- src/util/virlog.c | 44 +-- src

[PATCH 2/2] util: command: improve generic mass close of fds

2020-08-19 Thread Natanael Copa
Add a portable generic implementation of virMassClose as fallback on non-FreeBSD and non-glibc. This implementation uses poll(2) to look for open files to keep performance reasonable while not using any mallocs. This solves a deadlock with musl libc. Signed-off-by: Natanael Copa --- src/util

[libvirt] [PATCH] Fix underlinking of libvirt_driver_interface.so

2015-03-23 Thread Natanael Copa
Always add udev linker flags when WITH_UDEV is enabled to avoid underlinking. See commit 43dbcb15 (interface: always build all available backends) Signed-off-by: Natanael Copa --- src/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Makefile.am b/src

Re: [libvirt] [PATCH 1/2] util: introduce virDirRead wrapper for readdir

2014-04-21 Thread Natanael Copa
On Mon, 21 Apr 2014 16:05:28 -0600 Eric Blake wrote: > On 04/20/2014 05:53 AM, Natanael Copa wrote: ... > > +/* return 0 = success, 1 = end-of-dir and -1 = error */ > > This logic is a bit odd to reason about. I think 1 = success (returned > 1 entry), 0 = end-of-dir (succe

[libvirt] [PATCH 1/2] util: introduce virDirRead wrapper for readdir

2014-04-20 Thread Natanael Copa
Introduce a wrapper for readdir. This helps us make sure that we always set errno before calling readdir and it will make sure errors are properly logged. Signed-off-by: Natanael Copa --- src/util/virfile.c | 14 ++ src/util/virfile.h | 3 +++ 2 files changed, 17 insertions

[libvirt] [PATCH 2/2] nodeinfo: use virDirRead API

2014-04-20 Thread Natanael Copa
This makes sure that errno is reset before readdir is called, even if the loop does a 'continue'. This fixes issue with musl libc which sets errno on sscanf. The following 'continue' makes the errno be set before calling readdir. Signed-off-by: Natanael Copa ---

Re: [libvirt] [PATCH] nodeinfo: fix detection of physical memory on uclibc/musl libc

2014-04-15 Thread Natanael Copa
On Tue, 15 Apr 2014 12:30:47 +0100 "Daniel P. Berrange" wrote: > On Tue, Apr 15, 2014 at 01:26:27PM +0200, Natanael Copa wrote: > > On Tue, 15 Apr 2014 10:37:40 +0100 > > "Daniel P. Berrange" wrote: > > > > > On Tue, Apr 15, 2014 at 11:31:23A

Re: [libvirt] [PATCH] nodeinfo: fix detection of physical memory on uclibc/musl libc

2014-04-15 Thread Natanael Copa
On Tue, 15 Apr 2014 10:37:40 +0100 "Daniel P. Berrange" wrote: > On Tue, Apr 15, 2014 at 11:31:23AM +0200, Natanael Copa wrote: > > The gnulib's physmem_total will as a fallback report 64MB as total > > memory if sysconf(_SC_PHYS_PAGES) is unimplemented on linux. T

[libvirt] [PATCH] nodeinfo: fix detection of physical memory on uclibc/musl libc

2014-04-15 Thread Natanael Copa
s the total memory be correctly reported on musl libc and uclibc. Signed-off-by: Natanael Copa --- configure.ac | 2 +- src/nodeinfo.c | 22 -- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 52c50df..32a2e5a 100644

Re: [libvirt] [PATCH] nodeinfo: Make sure we always reset errno before calling readdir

2014-04-15 Thread Natanael Copa
On Thu, 10 Apr 2014 15:53:57 -0600 Eric Blake wrote: > On 04/10/2014 02:52 PM, Natanael Copa wrote: > > >>> I suppose we could use helper function to make it more readable: > >>> > > >> int virReaddir(DIR *dirp, struct dirent **ent) > >>

Re: [libvirt] [PATCH] nodeinfo: Make sure we always reset errno before calling readdir

2014-04-11 Thread Natanael Copa
On Thu, 10 Apr 2014 15:53:57 -0600 Eric Blake wrote: > On 04/10/2014 02:52 PM, Natanael Copa wrote: > > >>> I suppose we could use helper function to make it more readable: > >>> > > >> int virReaddir(DIR *dirp, struct dirent **ent) > >>

Re: [libvirt] [PATCH] nodeinfo: Make sure we always reset errno before calling readdir

2014-04-10 Thread Natanael Copa
On Thu, 10 Apr 2014 09:22:42 -0600 Eric Blake wrote: > On 04/10/2014 08:38 AM, Natanael Copa wrote: > > >>> -errno = 0; > >>> -while ((cpudirent = readdir(cpudir))) { > >>> +for (errno = 0; (cpudirent = readdir(cpudir)); errno = 0) { > &g

Re: [libvirt] [PATCH] nodeinfo: Make sure we always reset errno before calling readdir

2014-04-10 Thread Natanael Copa
On Thu, 10 Apr 2014 08:24:20 -0600 Eric Blake wrote: > On 04/10/2014 08:04 AM, Natanael Copa wrote: > > We must always reset errno to 0 even if we do 'continue'. > > > > This fixes runtime with musl libc which will set errno on sscanf. > > > > Sig

[libvirt] [PATCH] nodeinfo: Make sure we always reset errno before calling readdir

2014-04-10 Thread Natanael Copa
We must always reset errno to 0 even if we do 'continue'. This fixes runtime with musl libc which will set errno on sscanf. Signed-off-by: Natanael Copa --- src/nodeinfo.c | 15 +++ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/nodeinfo.c b/src/nodein

[libvirt] [PATCH v5 3/3] net: use structs for address and port ranges

2013-02-19 Thread Natanael Copa
We pass over the address/port start/end values many times so we put them in structs. Signed-off-by: Natanael Copa --- Skip this patch if there are doubts. src/conf/network_conf.c | 50 ++--- src/conf/network_conf.h | 13 +++- src/network

[libvirt] [PATCH v5 1/3] net: support set public ip range for forward mode nat

2013-02-19 Thread Natanael Copa
Support setting which public ip to use for NAT via attribute address in subelement in : ... ... This will construct an iptables line using: '-j SNAT --to-source -' instead of: '-j MASQUERADE' Signed-off-by: Natanael Copa --- docs/formatnetwork.html.i

[libvirt] [PATCH v5 2/3] net: add support for specifying port range for forward mode nat

2013-02-19 Thread Natanael Copa
Let users set the port range to be used for forward mode NAT: ... ... Signed-off-by: Natanael Copa --- docs/formatnetwork.html.in | 21 ++--- src/conf/network_conf.c | 56 +++-- src/conf/network_conf.h | 3

[libvirt] [PATCH v5 0/3] net: support set source address(es) and ports for NAT

2013-02-19 Thread Natanael Copa
f snprintf and avoid strings on stack - Add an optional 3rd patch that uses structs for addr and port ranges. Natanael Copa (3): net: support set public ip range for forward mode nat net: add support for specifying port range for forward mode nat net: use structs for address an

Re: [libvirt] [PATCH v4 2/2] net: add support for specifying port range for forward mode nat

2013-02-15 Thread Natanael Copa
On Fri, 15 Feb 2013 14:03:37 -0500 Laine Stump wrote: > On 02/11/2013 09:54 AM, Natanael Copa wrote: > > Let users set the port range to be used for forward mode NAT: > > > > ... > > > > > > > > > > ... > > diff

[libvirt] [PATCH v4 2/2] net: add support for specifying port range for forward mode nat

2013-02-11 Thread Natanael Copa
Let users set the port range to be used for forward mode NAT: ... ... Signed-off-by: Natanael Copa --- docs/formatnetwork.html.in | 21 ++--- src/conf/network_conf.c | 57 +++-- src/conf/network_conf.h | 3

[libvirt] [PATCH v4 1/2] net: support set public ip range for forward mode nat

2013-02-11 Thread Natanael Copa
Support setting which public ip to use for NAT via attribute address in subelement in : ... ... This will construct an iptables line using: '-j SNAT --to-source -' instead of: '-j MASQUERADE' Signed-off-by: Natanael Copa --- docs/formatnetwork.html.i

[libvirt] [PATCH v4 0/2] net: support set source address(es) and ports for NAT

2013-02-11 Thread Natanael Copa
Changes v4: - barf if 'end' attribute is missing in - update doc to tell how to properly set single address Natanael Copa (2): net: support set public ip range for forward mode nat net: add support for specifying port range for forward mode nat docs/formatnetwork.html

Re: [libvirt] [PATCH v2 2/4] net: support set public ip for forward mode nat

2013-02-11 Thread Natanael Copa
On Fri, 8 Feb 2013 17:25:11 + "Daniel P. Berrange" wrote: > On Mon, Feb 04, 2013 at 10:45:24AM +0100, Natanael Copa wrote: > > Support setting which public ip to use for NAT via attribute > > address in subelement in : > > > > ... > > > >

[libvirt] [PATCH v3 2/2] net: add support for specifying port range for forward mode nat

2013-02-11 Thread Natanael Copa
Let users set the port range to be used for forward mode NAT: ... ... Signed-off-by: Natanael Copa --- docs/formatnetwork.html.in | 21 ++--- src/conf/network_conf.c | 57 +++-- src/conf/network_conf.h | 3

[libvirt] [PATCH v3 1/2] net: support set public ip range for forward mode nat

2013-02-11 Thread Natanael Copa
Support setting which public ip to use for NAT via attribute address in subelement in : ... ... This will construct an iptables line using: '-j SNAT --to-source -' instead of: '-j MASQUERADE' Signed-off-by: Natanael Copa --- docs/formatnetwork.html.i

[libvirt] [PATCH v3 0/2] net: support set public ip for forward mode nat

2013-02-11 Thread Natanael Copa
Rebased patch[1]. Changes v3: - remove support for format, the 2/4 patch[2]. [1] http://www.redhat.com/archives/libvir-list/2013-February/msg00088.html [2] http://www.redhat.com/archives/libvir-list/2013-February/msg00090.html Natanael Copa (2): net: support set public ip range for forward

[libvirt] [PATCH v2 4/4] net: add support for specifying port range for forward mode nat

2013-02-04 Thread Natanael Copa
Let users set the port range to be used for forward mode NAT: ... ... Signed-off-by: Natanael Copa --- docs/formatnetwork.html.in | 15 -- src/conf/network_conf.c | 50 + src/conf/network_conf.h | 3

[libvirt] [PATCH v2 2/4] net: support set public ip for forward mode nat

2013-02-04 Thread Natanael Copa
Support setting which public ip to use for NAT via attribute address in subelement in : ... ... This will construct an iptables line using: '-j SNAT --to-source ' instead of: '-j MASQUERADE' Signed-off-by: Natanael Copa --- docs/formatnetwork.html.i

[libvirt] [PATCH v2 1/4] util: refactor iptables command construction into multiple steps

2013-02-04 Thread Natanael Copa
Instead of creating an iptables command in one shot, do it in steps so we can add conditional options like physdev and protocol. This removes code duplication while keeping existing behaviour. Signed-off-by: Natanael Copa --- This patch is unmodified since last time i sent it [1]. [1] https

[libvirt] [PATCH v2 0/4] net: support set source address(es) and ports for NAT

2013-02-04 Thread Natanael Copa
00140.html Natanael Copa (4): util: refactor iptables command construction into multiple steps net: support set public ip for forward mode nat net: support a public address range for forward mode nat net: add support for specifying port range for forward mode nat docs/formatnetwork.html

[libvirt] [PATCH v2 3/4] net: support a public address range for forward mode nat

2013-02-04 Thread Natanael Copa
Allow setting a range of public ip addresses to be used as source address for forward mode nat: ... ... Signed-off-by: Natanael Copa --- docs/formatnetwork.html.in | 13 src/conf/network_conf.c | 72 ++--- src/conf

[libvirt] [PATCH] net: support set public ip for forward mode nat

2012-12-04 Thread Natanael Copa
Support setting which public ip to use for NAT via attribute publicaddr. This will construct an iptables line using '-j SNAT --to-source ' instead of '-j MASQUERADE'. Signed-off-by: Natanael Copa --- This depends on previous sent iptables refactor patch. http://www.mail-arc

Re: [libvirt] [PATCH] util: refactor iptables command construction into multiple steps

2012-12-03 Thread Natanael Copa
On Thu, 22 Nov 2012 15:02:18 +0100 Natanael Copa wrote: > Instead of creating an iptables command in one shot, do it in steps > so we can add conditional options like physdev and protocol. > > This removes code duplication while keeping existing behaviour. > > Signed-off

Re: [libvirt] [PATCH] util: refactor iptables command construction into multiple steps

2012-11-22 Thread Natanael Copa
On Thu, 22 Nov 2012 15:02:18 +0100 Natanael Copa wrote: > Instead of creating an iptables command in one shot, do it in steps > so we can add conditional options like physdev and protocol. > > This removes code duplication while keeping existing behaviour. > > Signed-off

Re: [libvirt] [PATCH] build: trivial fix error: implicit declaration of function 'malloc'

2012-11-22 Thread Natanael Copa
On Thu, 22 Nov 2012 06:53:12 -0700 Eric Blake wrote: > On 11/22/2012 06:46 AM, Natanael Copa wrote: > >> If your headers are defining this in terms of malloc(), then IMHO, > >> the sched.h should be including stdlib.h on our behalf. IOW, I > >> think this is

[libvirt] [PATCH] util: refactor iptables command construction into multiple steps

2012-11-22 Thread Natanael Copa
Instead of creating an iptables command in one shot, do it in steps so we can add conditional options like physdev and protocol. This removes code duplication while keeping existing behaviour. Signed-off-by: Natanael Copa --- This started with me wanting to add support for setting the public

Re: [libvirt] [PATCH] build: trivial fix error: implicit declaration of function 'malloc'

2012-11-22 Thread Natanael Copa
On Thu, 22 Nov 2012 13:36:14 + "Daniel P. Berrange" wrote: > On Thu, Nov 22, 2012 at 01:28:08PM +0100, Natanael Copa wrote: > > Fixes this error when building with -Werror on Alpine Linux: ... > > --- a/src/util/processinfo.c > > +++ b/src/util/p

[libvirt] [PATCH] build: trivial fix error: implicit declaration of function 'malloc'

2012-11-22 Thread Natanael Copa
Fixes this error when building with -Werror on Alpine Linux: util/processinfo.c: In function 'virProcessInfoSetAffinity': util/processinfo.c:52:5: error: implicit declaration of function 'malloc' [-Werror=implicit-function-declaration] Signed-off-by: Natanael Copa --- sr