[libvirt] [PATCH] Remove & ban use of select() for waiting for I/O

Eric Blake eblake at redhat.com
Mon May 13 16:02:43 UTC 2013


On 05/13/2013 07:45 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Use of the select() system call is inherantly dangerous since
> applications will hit a buffer overrun if any FD number exceeds
> the size of the select set size (typically 1024). Replace the
> two uses of select() with poll() and use cfg.mk to ban any
> future use of select().
> 
> NB: This changes the phyp driver so that it uses an infinite
> timeout, instead of busy-waiting for 1ms at a time.
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---

> +++ b/cfg.mk
> @@ -444,6 +444,14 @@ sc_prohibit_nonreentrant:
>  	done ; \
>  	exit $$fail
>  
> +sc_prohibit_select:
> +	@fail=0 ;							\
> +	(prohibit="\\<select *\\("					\
> +	 halt="use poll(), not select()"				\
> +	 $(_sc_search_regexp)						\
> +	) || fail=1;							\
> +	exit $$fail

Overkill.  $(_sc_search_regexp) exits with non-zero status, so it is
sufficient to write:

+sc_prohibit_select:
+	@prohibit="\\<select *\\("				\
+	halt="use poll(), not select()"				\
+	 $(_sc_search_regexp)

> +++ b/src/util/virnetlink.c
> @@ -48,7 +48,7 @@
>  
>  #define VIR_FROM_THIS VIR_FROM_NET
>  
> -#define NETLINK_ACK_TIMEOUT_S  2
> +#define NETLINK_ACK_TIMEOUT_S  2*1000

Needs parenthesis.

ACK with those fixes.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130513/9d1b7896/attachment-0001.sig>


More information about the libvir-list mailing list