[libvirt] [PATCH 2/9] remove duplicate *SetCloseExec and *SetNonBlock functions

Jim Meyering jim at meyering.net
Tue Feb 3 16:06:33 UTC 2009


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> On Mon, Feb 02, 2009 at 06:08:15PM +0100, Jim Meyering wrote:
>> From: Jim Meyering <meyering at redhat.com>
>>
>> * src/qemu_driver.c: Use virSetCloseExec and virSetNonBlock,
>> rather than qemuSet* functions.  Suggested by Daniel P. Berrange.
>> * src/util.c (virSetCloseExec): Compile unconditionally.
>> * src/util.h (virSetCloseExec): Declare
>>
>> diff --git a/qemud/Makefile.am b/qemud/Makefile.am
>> index a0c161a..372b931 100644
>> --- a/qemud/Makefile.am
>> +++ b/qemud/Makefile.am
>> @@ -107,6 +107,7 @@ libvirtd_LDADD =					\
>>  if ! WITH_DRIVER_MODULES
>>  if WITH_QEMU
>>  libvirtd_LDADD += ../src/libvirt_driver_qemu.la
>> +libvirtd_LDADD += ../src/libvirt_util.la
>>  endif
>
>
> This is not required. All the functions in util.c are provided
> in the libvirt.so, and exported with LIBVIRT_PRIVATE_X_X_X
> tag.
>
> This patch is missing the change to libvirt_private.sym to
> actually add the virSetCloseExec function though.

Ah. forgot about that.
Done.

>> @@ -182,10 +182,7 @@ int virSetNonBlock(int fd) {
>>      return 0;
>>  }
>>
>> -
>> -#ifndef WIN32
>> -
>> -static int virSetCloseExec(int fd) {
>> +int virSetCloseExec(int fd) {
>>      int flags;
>>      if ((flags = fcntl(fd, F_GETFD)) < 0)
>>          return -1;
>> @@ -195,6 +192,8 @@ static int virSetCloseExec(int fd) {
>>      return 0;
>>  }
>>
>> +#ifndef WIN32
>> +
>>  static int
>>  __virExec(virConnectPtr conn,
>>            const char *const*argv,
>
> Why this change ?  AFAIK, there is no close-on-exec flag in Win32,
> since it doesn't have any concept of exec(). The QEMU driver isn't
> built on Win32, so we shouldn't need to expose virSetCloseExec
> there anyway.

Looked like it'd be portable enough to compile even there,
plus the general preference to avoid ifdef'd code in libraries.
I've read up a little and see that there really is no point,
so have put it back.




More information about the libvir-list mailing list