[pve-devel] [PATCH] fix hotplug ip configuration V3
Alexandre DERUMIER
aderumier at odiso.com
Mon Jun 29 18:32:37 CEST 2015
>>I am not sure if that always works. AFAIK the init process can be an arbitrary
>>name,
oh, ok, didn't known that
>>and that is why lxc-info calls a monitor command to get the PID?
I really don't known, don't have dig inside the lxc-info code
>>Also, your code opens/close many files. So I think the original approach
>>calling lxc-info is better for now.
Ok, I'll resend a v4 with previous code
>>And it is more efficient once we have perl bindings for LXC?
yes, sure.
----- Mail original -----
De: "dietmar" <dietmar at proxmox.com>
À: "aderumier" <aderumier at odiso.com>, "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Lundi 29 Juin 2015 17:45:53
Objet: Re: [pve-devel] [PATCH] fix hotplug ip configuration V3
I am not sure if that always works. AFAIK the init process can be an arbitrary
name,
and that is why lxc-info calls a monitor command to get the PID?
Also, your code opens/close many files. So I think the original approach
calling lxc-info is better for now. And it is more efficient once we
have perl bindings for LXC?
> +sub find_lxc_pid {
> + my ($vmid) = @_;
> +
> + my $res = undef;
> +
> + PVE::Tools::dir_glob_foreach('/proc', '\d+', sub {
> + my ($pid) = @_;
> +
> + my $cmdline = PVE::Tools::file_read_firstline("/proc/$pid/cmdline");
> + return if !$cmdline;
> +
> + if($cmdline =~ m/^init \[2\]/) {
> + my $line = PVE::Tools::file_read_firstline("/proc/$pid/cpuset");
> + $res = $pid if $line eq "/lxc/$vmid";
> + }
> + });
> + return $res;
> +}
More information about the pve-devel
mailing list