`vagrant up`超时"等待域名获取IP地址..."

时间:2018-01-15 22:45:27

标签: vagrant qemu archlinux libvirt virsh

这似乎只有在我使用generic/arch框时才会发生。我已经尝试了几个ubuntu盒子,一切正常。

主机操作系统是Manjaro。

它冻结了输出:

 INFO interface: info: ==> default: Waiting for domain to get an IP address...                                                                   
==> default: Waiting for domain to get an IP address...
 INFO retryable: Retryable exception raised: #<Fog::Errors::TimeoutError: The specified wait_for timeout (2 seconds) was exceeded>

libvirt / virsh 3.10.0版 vagrant version 2.0.1

操作系统4.9.76-1-MANJARO

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "generic/arch"
end

以下是我认为相关输出来自VAGRANT_LOG=debug vagrant up

==> default: Creating shared folders metadata...                                                                                                               
 INFO warden: Calling IN action: #<VagrantPlugins::ProviderLibvirt::Action::CreateNetworks:0x0000560dfaea3450>                                                 
 INFO create_networks: Using vagrant-libvirt at 192.168.121.0/24 as the management network nat is the mode                                                     
DEBUG create_networks: In config found network type forwarded_port options {:guest=>22, :host=>2222, :host_ip=>"127.0.0.1", :id=>"ssh", :auto_correct=>true, :p
rotocol=>"tcp"}                                                                                                                                                
DEBUG create_networks: Searching for network with options {:iface_type=>:private_network, :network_name=>"vagrant-libvirt", :ip=>"192.168.121.0", :netmask=>"25
5.255.255.0", :dhcp_enabled=>true, :forward_mode=>"nat", :guest_ipv6=>"yes", :autostart=>false}                                                                
/home/eihli/.vagrant.d/gems/2.4.3/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/document.rb:44: warning: constant ::Fixnum is deprecated                              
DEBUG create_networks: looking up network with ip == 192.168.121.0                                                                                             
DEBUG create_networks: Checking that network name does not clash with ip                                                                                       
DEBUG create_networks: looking up network named vagrant-libvirt                                                                                                
DEBUG create_networks: generating name for bridge                                                                                                              
DEBUG create_networks: looking up bridge named virbr0                                                                                                          
DEBUG create_networks: looking up bridge named virbr1                                                                                                          
DEBUG create_networks: found available bridge name virbr1                                                          
DEBUG create_networks: created network                                                        
 INFO create_networks: Saving information about created network vagrant-libvirt, UUID=71c9f6dd-4b2d-48f2-a787-5a0439d2e587 to file /home/eihli/code/vagrant_te$
t/.vagrant/machines/default/libvirt/created_networks.                                                             
 INFO warden: Calling IN action: #<VagrantPlugins::ProviderLibvirt::Action::CreateNetworkInterfaces:0x0000560dfb42cae8>
 INFO create_network_interfaces: Using vagrant-libvirt at 192.168.121.0/24 as the management network nat is the mode                                           
DEBUG create_network_interfaces: In config found network type forwarded_port options {:guest=>22, :host=>2222, :host_ip=>"127.0.0.1", :id=>"ssh", :auto_correc$
=>true, :protocol=>"tcp"}                                                                                                                                      
DEBUG create_network_interfaces: Adapter not specified so found slot 0                                                                                         
DEBUG create_network_interfaces: Found network by name                                                                                                         
 INFO create_network_interfaces: Creating network interface eth0 connected to network vagrant-libvirt.                                                         
 INFO warden: Calling IN action: #<VagrantPlugins::ProviderLibvirt::Action::SetBootOrder:0x0000560dfb30af70>                                                  
 INFO warden: Calling IN action: #<VagrantPlugins::ProviderLibvirt::Action::StartDomain:0x0000560dfafc46e0>                                                    
 INFO interface: info: Starting domain.                                                                                                                        
 INFO interface: info: ==> default: Starting domain.                                                                                                           
==> default: Starting domain.                                                                                                                                  
 INFO warden: Calling IN action: #<VagrantPlugins::ProviderLibvirt::Action::WaitTillUp:0x0000560dfab82de8>
DEBUG wait_till_up: Searching for IP for MAC address: 52:54:00:62:61:1d                                     
 INFO interface: info: Waiting for domain to get an IP address...                                                        
 INFO interface: info: ==> default: Waiting for domain to get an IP address...                                                                   
==> default: Waiting for domain to get an IP address...  

我使用tshark -i virbr1检查过wireshark,但我没有得到任何输出。我不确定我应该听哪个设备,所以我也检查了tshark -i vnet0,我确实得到了一些输出,但没有看起来与DHCP有关。

以下是tshark -i vnet0

的输出
Capturing on 'vnet0'
1 0.000000000 fe80::fc54:ff:fe45:368d → ff02::fb     MDNS 201 Standard query response 0x0000 PTR, cache flush Ophelia.local AAAA, cache flush fe80::fc54:ff:fe45:368d
2 0.745989853 fe:54:00:45:36:8d → Spanning-tree-(for-bridges)_00 STP 52 Conf. TC + Root = 32768/0/52:54:00:78:b4:d1  Cost = 0  Port = 0x8002
3 1.599338528 fe80::fc54:ff:fe45:368d → ff02::2      ICMPv6 70 Router Solicitation from fe:54:00:45:36:8d
4 2.190388300 fe80::fc54:ff:fe45:368d → ff02::fb     MDNS 201 Standard query response 0x0000 PTR, cache flush Ophelia.local AAAA, cache flush fe80::fc54:ff:fe45:368d
5 2.666024617 fe:54:00:45:36:8d → Spanning-tree-(for-bridges)_00 STP 52 Conf. TC + Root = 32768/0/52:54:00:78:b4:d1  Cost = 0  Port = 0x8002
6 4.799357852 fe:54:00:45:36:8d → Spanning-tree-(for-bridges)_00 STP 52 Conf. TC + Root = 32768/0/52:54:00:78:b4:d1  Cost = 0  Port = 0x8002

以下是从dmesg -w到我vagrant up

ctrl-c的结果
[ 2048.355424] virbr1: port 2(vnet0) entered disabled state
[ 2048.358280] device vnet0 left promiscuous mode
[ 2048.358287] virbr1: port 2(vnet0) entered disabled state
[ 2048.578278] device virbr1-nic left promiscuous mode
[ 2048.578287] virbr1: port 1(virbr1-nic) entered disabled state
[ 2059.394512] virbr1: port 1(virbr1-nic) entered blocking state
[ 2059.394516] virbr1: port 1(virbr1-nic) entered disabled state
[ 2059.394598] device virbr1-nic entered promiscuous mode
[ 2059.532014] virbr1: port 1(virbr1-nic) entered blocking state
[ 2059.532017] virbr1: port 1(virbr1-nic) entered listening state
[ 2059.567010] virbr1: port 1(virbr1-nic) entered disabled state
[ 2059.694140] virbr1: port 2(vnet0) entered blocking state
[ 2059.694156] virbr1: port 2(vnet0) entered disabled state
[ 2059.694377] device vnet0 entered promiscuous mode
[ 2059.695080] virbr1: port 2(vnet0) entered blocking state
[ 2059.695083] virbr1: port 2(vnet0) entered listening state
[ 2061.871278] virbr1: port 2(vnet0) entered learning state
[ 2064.004553] virbr1: port 2(vnet0) entered forwarding state
[ 2064.004555] virbr1: topology change detected, propagating
[ 2065.750798] kvm [5143]: vcpu0, guest rIP: 0xffffffff86061ce6 unhandled rdmsr: 0x140
[ 2065.821598] kvm [5143]: vcpu1, guest rIP: 0xffffffff86061ce6 unhandled rdmsr: 0x140
[ 2065.861278] kvm: zapping shadow pages for mmio generation wraparound
[ 2065.863039] kvm: zapping shadow pages for mmio generation wraparound
[ 2066.017675] kvm [5143]: vcpu0, guest rIP: 0xffffffff86061ce6 unhandled rdmsr: 0x34
[ 2068.941350] virbr1: port 2(vnet0) entered disabled state
[ 2068.943507] device vnet0 left promiscuous mode
[ 2068.943511] virbr1: port 2(vnet0) entered disabled state
[ 2069.163524] device virbr1-nic left promiscuous mode
[ 2069.163532] virbr1: port 1(virbr1-nic) entered disabled state

以下是ip addr show的输出(除了这是我无法运行并且每次虚拟网络接口的数量增加时的无数次。

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
   valid_lft forever preferred_lft forever
2: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 3c:a9:f4:4c:7b:3c brd ff:ff:ff:ff:ff:ff
inet 10.7.74.120/18 brd 10.7.127.255 scope global dynamic noprefixroute wlp3s0
   valid_lft 599674sec preferred_lft 599674sec
inet6 fe80::3d00:e921:d2e6:d9d5/64 scope link noprefixroute 
   valid_lft forever preferred_lft forever
3: enp0s25: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 28:d2:44:17:62:46 brd ff:ff:ff:ff:ff:ff
34: virbr1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:ff:e1:a6 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.1/24 brd 192.168.121.255 scope global virbr1
   valid_lft forever preferred_lft forever
35: virbr1-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr1 state DOWN group default qlen 1000
link/ether 52:54:00:ff:e1:a6 brd ff:ff:ff:ff:ff:ff
36: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr1 state UNKNOWN group default qlen 1000
link/ether fe:54:00:81:4a:63 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fe81:4a63/64 scope link 
   valid_lft forever preferred_lft forever

2 个答案:

答案 0 :(得分:2)

由于您使用的是libvirt提供程序,因此您应该可以使用virt-manager检查虚拟机的状态。

答案的其余部分是根据两个假设写的,即我的系统与你的系统没那么不同,并且我使用vagrant-libvirt和generic / arch(v1.3.40)遇到了同样的问题

在virt-manager中打开VM,我发现系统无法检测到根文件系统,也引发了紧急shell。这是因为 generic / arch 框提供的initramfs-linux.img不包含QEMU / kvm使用的libvirt-provider使用的默认设置所必需的内核模块。

如果启动此框有点重要,您应该可以使用后备图像启动此框,因为它会发送更多模块。要使其无需干预即可重新启动,您可以运行sudo mkinitcpio -p linux以在guest虚拟机中添加缺少的模块。或者,您也可以在主机上将SCSI控制器从 Hypervisor Defaults 更改为 VirtIO SCSI (例如,使用virt-manager)。

对于一个更永久的解决方案(前面提到的任何内容都无法在vagrant destroy中生存下来),除了可能正在等待修复&#34;发布框或patching插件。

PS。最简单的解决方案可能是选择另一个方框(例如archlinux/archlinux)。

答案 1 :(得分:0)

就我而言,我使用过严格的iptables规则来阻止由Vagrant通过libvirt为虚拟网桥virbr*设置的NAT。

作为一个实验,我在启动Vagrant机器之前禁用了所有防火墙规则,并且该机器能够获取IP地址。