[pve-devel] [PATCH] fix hotplug ip configuration V3

Dietmar Maurer dietmar at proxmox.com
Mon Jun 29 17:45:53 CEST 2015


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