Como faço para que o ipv4 / inet funcione em um contêiner lxc de braço em execução no host intel?

0

Se você tentou criar um contêiner lxc armhf e um arm64 / aarch64 no meu sistema Intel de 64 bits.

Copiei o arquivo qemu relevante antes de iniciar o contêiner. /usr/bin/qemu-arm-static para arm e /usr/bin/qemu-aarch64-static para arm64.

Quando eu crio outro contêiner ubuntu baseado em intel, minha eth0 tem um endereço ipv4. (usando conexão em ponte)

Eu crio o container arm64 assim:

lxc launch ubuntu:15.04/arm64 arm64
cp /usr/bin/qemu-aarch64-static /usr/lib/lxd/containers/arm64/rootfs/usr/bin
lxc start arm64

Eu não fiz outras modificações.

No container arm64, o ifconfig é exibido:

eth0      Link encap:Ethernet  HWaddr 00:16:3e:e4:d2:de  
          inet6 addr: fe80::216:3eff:fee4:d2de/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2564 (2.5 KB)  TX bytes:578 (578.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tentando as coisas óbvias:

/etc/init.d/networking start

yeilds

[....] Starting networking (via systemctl): networking.serviceFailed to get D-Bus connection: No such file or directory
 failed!

ifup eth0 yields

/sbin/ifup: failed to open lockfile /run/network/.ifstate.lock: No such file or directory

ip addr yeilds

Cannot open netlink socket: Address family not supported by protocol

Address family not supported by protocol parece ser uma mensagem de erro comum ao executar várias ferramentas de rede diferentes - presumivelmente porque nenhum endereço ipv4 não é reconhecido.

similarmente cliente dhcp

root@ubuntu:/var/log# dhclient -v
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Error getting interfaces; Address family not supported by protocol
Can't get list of interfaces.

/etc/network/interfaces é

# The loopback network interface
auto lo
iface lo inet loopback

# Source interfaces
# Please check /etc/network/interfaces.d before changing this file
# as interfaces may have been defined in /etc/network/interfaces.d
# NOTE: the primary ethernet device is defined in
# /etc/network/interfaces.d/eth0
# See LP: #1262951

source /etc/network/interfaces.d/*.cfg

e o eth0.cfg é

# The primary network interface
auto eth0
iface eth0 inet dhcp

(por acaso, mudar para um ip estático não fez nenhuma diferença)

Comparado meu contêiner intel ao meu diretório arm / run é muito esparso contendo apenas lock e systemd (onde como em intel ele contém uma subpasta de rede entre muitas outras coisas)

Eu estou supondo que isso mostra (mas eu realmente não sei o que estou fazendo) que o systemd 'start up system' tem um problema e falhou ao iniciar um monte de serviços. journalctl retorna No journal files were found. e / var / log é bastante esparso contendo apenas: pt btmp dist-upgrade dpkg.log fsck landscape lastlog unattended-upgrades wtmp

Qualquer ajuda seria apreciada:)

Atualização:

Quando tento executar systemd-journald manualmente, obtenho:

qemu: Unsupported syscall: 278
qemu: Unsupported syscall: 74
qemu: Unsupported syscall: 74

Atualização:

usando mais recente a versão do qemu:

qemu-user-static (1:2.5+dfsg-5ubuntu10.4) to 1:2.6.1+dfsg-0~16.04

deste PPA link

melhorou muito as coisas. (mas ainda não há rede ipv4 ainda)

/ var / run agora está preenchido com diretórios esperados (incluindo rede)

journalctl agora funciona e retorna:

Aug 26 18:02:26 ubuntu systemd-journal[89]: Runtime journal is using 8.0M (max allowed 801.2M, trying to leave 1.1G free of 7.8G available <E2><86><92> current limit 801.2M).
Aug 26 18:02:26 ubuntu systemd-journal[89]: Runtime journal is using 8.0M (max allowed 801.2M, trying to leave 1.1G free of 7.8G available <E2><86><92> current limit 801.2M).
Aug 26 18:02:26 ubuntu systemd-journal[89]: Journal started
Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '1' to '/proc/sys/kernel/yama/ptrace_scope': Permission denied
Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '176' to '/proc/sys/kernel/sysrq': Permission denied
Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '1' to '/proc/sys/fs/protected_hardlinks': Permission denied
Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '4 4 1 7' to '/proc/sys/kernel/printk': Permission denied
Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '1' to '/proc/sys/kernel/kptr_restrict': Permission denied
Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '1' to '/proc/sys/fs/protected_symlinks': Permission denied
Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '32768' to '/proc/sys/vm/mmap_min_addr': Permission denied
Aug 26 18:02:27 ubuntu systemd-udevd[74]: error initializing netlink socket
Aug 26 18:02:27 ubuntu systemd-remount-fs[62]: /bin/mount for / exited with exit status 1.
Aug 26 18:02:27 ubuntu systemd-udevd[92]: error initializing netlink socket
Aug 26 18:02:27 ubuntu systemd[1]: Failed to reset devices.list on /system.slice/systemd-journal-flush.service: Operation not permitted
Aug 26 18:02:27 ubuntu systemd[1]: Starting Flush Journal to Persistent Storage...
Aug 26 18:02:27 ubuntu systemd[1]: Started Load/Save Random Seed.
Aug 26 18:02:27 ubuntu systemd-journal[89]: Forwarding to syslog missed 2 messages.
Aug 26 18:02:27 ubuntu systemd-remount-fs[62]: mount: can't find LABEL=cloudimg-rootfs
Aug 26 18:02:27 ubuntu systemd[1]: Started Various fixups to make systemd work better on Debian.
Aug 26 18:02:27 ubuntu mount[67]: mount: permission denied
Aug 26 18:02:27 ubuntu systemd-udevd[108]: error initializing netlink socket
Aug 26 18:02:27 ubuntu systemd[1]: systemd-udevd.service: main process exited, code=exited, status=3/NOTIMPLEMENTED
Aug 26 18:02:27 ubuntu systemd[1]: Failed to start udev Kernel Device Manager.
Aug 26 18:02:27 ubuntu systemd[1]: Unit systemd-udevd.service entered failed state.
Aug 26 18:02:27 ubuntu systemd[1]: systemd-udevd.service failed.
Aug 26 18:02:27 ubuntu systemd[1]: systemd-udevd.service has no holdoff time, scheduling restart.
Aug 26 18:02:27 ubuntu systemd[1]: systemd-udevd-kernel.socket failed to listen on sockets: Address family not supported by protocol
Aug 26 18:02:27 ubuntu systemd[1]: Failed to listen on udev Kernel Socket.
Aug 26 18:02:27 ubuntu systemd[1]: Starting udev Kernel Socket.

A linha de erro relevante parece ser Aug 26 18:02:27 ubuntu systemd-udevd[92]: error initializing netlink socket

Atualizar

Eu tentei executar ifup eth0 -v com o dhcp e uma configuração estática e as duas formas apresentaram um erro semelhante:

dhcp Error getting interfaces; Address family not supported by protocol

static Cannot open netlink socket: Address family not supported by protocol

    
por Tom 26.08.2016 / 19:00

2 respostas

0

Descobrimos que o qemu 2.6.1 não funcionava bem o suficiente para fazer com que a rede funcionasse em um contêiner de braço.

Eu apliquei os seguintes 3 patches ao qemu 2.6.1 (depois de executar apt get source qemu-user-static )

https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg06203.html
https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg06204.html
https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg06205.html

e reconstruir (usando debuild )

Em seguida, extraiu o recém-construído qemu-aarch64-static do arquivo deb e instalou no contêiner /usr/lib/lxd/container/$NAME/rootfs/usr/bin

As redes agora funcionam:

eth0      Link encap:Ethernet  HWaddr 00:16:3e:54:2e:7c  
          inet addr:10.0.4.110  Bcast:10.0.4.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe54:2e7c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:949 errors:0 dropped:0 overruns:0 frame:0
          TX packets:428 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1285688 (1.2 MB)  TX bytes:37196 (37.1 KB)
    
por Tom 29.08.2016 / 16:18
1

(Resposta devido à falta de reputação.)

Eu tive exatamente o mesmo problema. O contêiner lxc não obteve um endereço IPv4. A execução de dhclient eth0 -v resultou na mensagem de erro que, felizmente, me trouxe aqui

% bl0ck_qu0te%

Este tópico realmente salvou meu dia. Depois de construir um novo binário do qemu, posso fazer contêineres armhf unirem minha LAN com esse perfil padrão ( eno1 sendo a interface ethernet em minha máquina host):

name: default
config: {}
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: macvlan
    parent: eno1
    type: nic

Estou usando um qemu 2.7.0 binário que você pode compilar a partir do código-fonte e instalar em algum caminho <prefix> com

./configure --target-list=arm-linux-user --static --prefix=<prefix>
make
make install

Antes de iniciar um container armhf, é só pegar o novo qemu lá

lxc file push <prefix>/bin/qemu-arm <name>/usr/bin/qemu-arm-static

Outro efeito colateral interessante é que agora posso parar contêineres sem o sinal --force !

    
por pgorczak 15.12.2016 / 19:54