[libvirt] main: fix some compilation issues on non-linux platforms

Stefan Berger stefanb at linux.vnet.ibm.com
Tue Aug 16 18:07:24 UTC 2011


On 08/16/2011 01:35 PM, Eric Blake wrote:
> On 08/16/2011 11:29 AM, Eric Blake wrote:
>>> +++ b/src/util/virpidfile.c
>>> @@ -213,6 +213,8 @@ int virPidFileReadPathIfAlive(const char *path,
>>> #ifdef __linux__
>>> if (virFileLinkPointsTo(procpath, binpath) == 0)
>>> *pid = -1;
>>> +#else
>>> + (void)binpath;
>>> #endif
>>
>> Here, I'd rather mark binpath as ATTRIBUTE_UNUSED than add the #else
>> preprocessor conditional. That is, ATTRIBUTE_UNUSED means only that the
>> variable might be unused, not that it can't be used (so used on linux,
>> unused otherwise qualifies).
>
> Food for a separate patch: I see no reason why virFileLinkPointsTo 
> won't work on cygwin.  That is, the fact that we used #ifdef __linux__ 
> is wrong, since cygwin also has a working /proc/pid/ file tree to 
> determine if an executable is still valid; we should instead be doing 
> #if PROCFS_AVAIL, along with some sort of configuration check that 
> accepts both linux and cygwin procfs (or at least whatever aspect of 
> procfs that we are relying on in this function).
>
I split this off and pushed the rest.
If procfs's are different, then maybe we should use #if 
PROCFS_PID_EXE_LINK_AVAIL here.
What is needed in this case seems to be that /proc/<pid>/exe is a 
symbolic link to the executable. This works in Linux and cygwin. Would 
testing via

stat /proc/<pid>/exe | sed -n 's/.*\(symbolic link\).*/\1/p'

be a valid test for this that works on all targeted platforms?

     Stefan




More information about the libvir-list mailing list