<div dir="ltr">Hi Doung,<div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 16, 2013 at 3:44 AM, Doug Goldstein <span dir="ltr"><<a href="mailto:cardoe@gentoo.org" target="_blank">cardoe@gentoo.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Oct 15, 2013 at 12:05 PM, Ryota Ozaki <<a href="mailto:ozaki.ryota@gmail.com">ozaki.ryota@gmail.com</a>> wrote:<br>


> This patch addresses the following warning output by libvirtd:<br>
>   warning : virProcessGetStartTime:843 : Process start time of<br>
>   pid XXXXX not available on this platform<br>
><br>
> For Mac OS X, we can use similar instructions to FreeBSD<br>
> to get the start time of a process. The difference between them<br>
> is struct kinfo_proc; kinfo_proc.ki_start is the start time<br>
> of a process for FreeBSD while kinfo_proc.kp_proc.p_starttime<br>
> for Mac OS X.<br>
><br>
> Note that this patch works for Lion and Mountain Lion, however,<br>
> doesn't work for Snow Leopard for some reason;<br>
> sysctlnametomib("kern.proc.pid", ...) fails on Snow Leopard with<br>
> the following error:<br>
>   error : virProcessGetStartTime:822 : Unable to get MIB of<br>
>   kern.proc.pid: No such file or directory<br>
><br>
> This is unexpected. man 3 sysctl of Snow Leopard says it<br>
> should work...<br>
><br>
> Anyway libvirtd is able to launch on Snow Leopard regardless of<br>
> the error.<br>
><br>
> Signed-off-by: Ryota Ozaki <<a href="mailto:ozaki.ryota@gmail.com">ozaki.ryota@gmail.com</a>><br>
> ---<br>
>  src/util/virprocess.c | 15 ++++++++++++---<br>
>  1 file changed, 12 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/src/util/virprocess.c b/src/util/virprocess.c<br>
> index 9fc3207..5a0ed0d 100644<br>
> --- a/src/util/virprocess.c<br>
> +++ b/src/util/virprocess.c<br>
> @@ -32,7 +32,7 @@<br>
>  #endif<br>
>  #include <sched.h><br>
><br>
> -#ifdef __FreeBSD__<br>
> +#if defined(__FreeBSD__) || defined(__APPLE__)<br>
>  # include <sys/param.h><br>
>  # include <sys/sysctl.h><br>
>  # include <sys/user.h><br>
> @@ -809,7 +809,7 @@ cleanup:<br>
>      VIR_FREE(buf);<br>
>      return ret;<br>
>  }<br>
> -#elif defined(__FreeBSD__)<br>
> +#elif defined(__FreeBSD__) || defined(__APPLE__)<br>
>  int virProcessGetStartTime(pid_t pid,<br>
>                             unsigned long long *timestamp)<br>
>  {<br>
> @@ -817,7 +817,12 @@ int virProcessGetStartTime(pid_t pid,<br>
>      int mib[4];<br>
>      size_t len = 4;<br>
><br>
> -    sysctlnametomib("kern.proc.pid", mib, &len);<br>
> +    /* FIXME: It doesn't work on Snow Leopard for some reason */<br>
> +    if (sysctlnametomib("kern.proc.pid", mib, &len) < 0) {<br>
> +        virReportSystemError(errno, "%s",<br>
> +                             _("Unable to get MIB of kern.proc.pid"));<br>
> +        return -1;<br>
> +    }<br>
><br>
>      len = sizeof(struct kinfo_proc);<br>
>      mib[3] = pid;<br>
> @@ -828,7 +833,11 @@ int virProcessGetStartTime(pid_t pid,<br>
>          return -1;<br>
>      }<br>
><br>
> +# if defined(__FreeBSD__)<br>
>      *timestamp = (unsigned long long)p.ki_start.tv_sec;<br>
> +# else<br>
> +    *timestamp = (unsigned long long)p.kp_proc.p_starttime.tv_sec;<br>
> +# endif<br>
><br>
>      return 0;<br>
><br>
> --<br>
> 1.8.4<br>
<br>
</div></div>I'm hesitant to ACK this because of the failure you mention on Snow<br>
Leopard. The last time we merged something in that broke Snow Leopard<br>
we got push back from the Homebrew guys so I'd rather let this bake a<br>
bit more and figure out where the Snow Leopard issue is. I'm in the<br>
process of installing Snow Leopard so I should have a chance to look<br>
at it. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Additionally, we'll want to test this on the FreeBSDs (finishing up<br>
installing a FreeBSD machine as well) since there is a behavior change<br>
for FreeBSD in this patch.<br></blockquote><div><br></div><div>Actually I tested the patch on Snow Leopard and FreeBSD 9.2 as well.</div><div>(I forgot I have an old iMac with SL when testing the previous patches.)</div>

<div>As mentioned in the commit log, for SL the patch has a problem but</div><div>libvirtd can start anyway. For FreeBSD, libvirtd with the patch also starts</div><div>with some errors happened in other codes. There seems to be no</div>

<div>regression on the two OSs.</div><div><br></div><div>Anyway your tests are of course welcome!</div><div>  ozaki-r<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<span class="HOEnZb"><font color="#888888"><br>
--<br>
Doug Goldstein<br>
</font></span></blockquote></div><br></div></div>