[pve-devel] [PATCH common] support for udev-systemd-style physical interface names (like enp3s0)

Alexey Kuzmin al.m.kuzmin at gmail.com
Mon May 9 17:53:16 CEST 2016


You may use net.ifnames kernel boot parameter to switch back to legacy 
interface names. Thus no need to patch PVE code


On May 9, 2016 6:23:25 PM Igor Vlasenko <ivlasenko at gmail.com> wrote:

> I am trying to port PVE to run under ALT Linux (rpm based platform)
> that runs udev+systemd. It has another name convention for
> network interface names: instead of eth0, eth1...
> they are called enp3s0, enp3s6, ...
>
> The patch enables PVE to run properly on any system with
> systemd-style network interface names.
>
>
> Signed-off-by: Igor Vlasenko <viy at altlinux.org>
> ---
>  src/PVE/INotify.pm | 8 ++++----
>  src/PVE/Network.pm | 6 +++---
>  2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
> index 74a0fe1..06c5aa5 100644
> --- a/src/PVE/INotify.pm
> +++ b/src/PVE/INotify.pm
> @@ -800,7 +800,7 @@ sub __read_etc_network_interfaces {
>
>      if ($proc_net_dev) {
>      while (defined ($line = <$proc_net_dev>)) {
> -        if ($line =~ m/^\s*(eth\d+):.*/) {
> +        if ($line =~ m/^\s*(eth\d+|enp\d+s\d+):.*/) {
>          $ifaces->{$1}->{exists} = 1;
>          }
>      }
> @@ -973,7 +973,7 @@ sub __read_etc_network_interfaces {
>          $ifaces->{$1}->{exists} = 0;
>          $d->{exists} = 0;
>          }
> -    } elsif ($iface =~ m/^eth\d+$/) {
> +    } elsif ($iface =~ m/^(?:eth\d+|enp\d+s\d+)$/) {
>          if (!$d->{ovs_type}) {
>          $d->{type} = 'eth';
>          } elsif ($d->{ovs_type} eq 'OVSPort') {
> @@ -1200,7 +1200,7 @@ sub __write_etc_network_interfaces {
>          $d->{type} eq 'OVSBond') {
>          my $brname = $used_ports->{$iface};
>          if (!$brname || !$ifaces->{$brname}) {
> -        if ($iface =~ /^eth/) {
> +        if ($iface =~ /^(?:eth|enp)/) {
>              $ifaces->{$iface} = { type => 'eth',
>                        exists => 1,
>                        method => 'manual',
> @@ -1289,7 +1289,7 @@ NETWORKDOC
>      my $pri;
>      if ($iface eq 'lo') {
>          $pri = $if_type_hash->{loopback};
> -    } elsif ($iface =~ m/^eth\d+$/) {
> +    } elsif ($iface =~ m/^(?:eth\d+|enp\d+s\d+)$/) {
>          $pri = $if_type_hash->{eth} + $child;
>      } elsif ($iface =~ m/^bond\d+$/) {
>          $pri = $if_type_hash->{bond} + $child;
> diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
> index bda2067..81c2e77 100644
> --- a/src/PVE/Network.pm
> +++ b/src/PVE/Network.pm
> @@ -131,10 +131,10 @@ my $parse_tap_device_name = sub {
>
>      my ($vmid, $devid);
>
> -    if ($iface =~ m/^tap(\d+)i(\d+)$/) {
> +    if ($iface =~ m/^tap(\d+)i(\d+(?:s\d+)?)$/) {
>      $vmid = $1;
>      $devid = $2;
> -    } elsif ($iface =~ m/^veth(\d+)i(\d+)$/) {
> +    } elsif ($iface =~ m/^veth(\d+)i(\d+(?:s\d+)?)$/) {
>      $vmid = $1;
>      $devid = $2;
>      } else {
> @@ -439,7 +439,7 @@ sub activate_bridge_vlan {
>
>      my @ifaces = ();
>      my $dir = "/sys/class/net/$bridge/brif";
> -    PVE::Tools::dir_glob_foreach($dir, '((eth|bond)\d+(\.\d+)?)', sub {
> +    PVE::Tools::dir_glob_foreach($dir,
> '((eth\d+|enp\d+s\d+|bond\d+)(\.\d+)?)', sub {
>          push @ifaces, $_[0];
>      });
>
> --
> 2.6.5
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel





More information about the pve-devel mailing list