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

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


On 08/16/2011 02:14 PM, Eric Blake wrote:
> On 08/16/2011 12:07 PM, Stefan Berger wrote:
>> 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.
>
> Seems like a reasonable name.
>
>> 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?
>
> stat(1) is not universal, and while it is on both Linux and Cygwin, it 
> might not be present on some other platform that has a procfs that 
> does what we want.  It may be sufficient to just use 'test -h 
> /proc/pid/exe' to see if there is a symlink.
>
> Also, you'd need to wrap the test in a cache variable (to allow 
> overrides if we guessed wrong), as well as to skip the test (and 
> assume the worst or at least make some default guesses based on known 
> $host_os) when cross-compiling, since the existence of procfs on the 
> host machine says nothing about it being on the target machine.
>
Following the latter couldn't it just be handled during runtime altogether?

     Stefan




More information about the libvir-list mailing list