为什么 libvirt“用户模式网络”不在启动时启动?

为什么 libvirt“用户模式网络”不在启动时启动?

运行 Ubuntu 16.04,默认情况下,virbr0 接口不会在启动时启动,这意味着我必须使用以下命令手动启动它:

$ sudo virsh net-start default

这也许不是什么大问题,而且我知道如何解决这个问题,但是以下命令的输出表明 virbr0 已配置为自动启动:

$ virsh  net-list --all
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 default              active     yes           yes

有人能指点下一步该看哪里来帮助调试吗?

更新:

启动后在 /var/log/syslog 中看到的一些选定的行对我没有帮助,但可能对某些人有意义:

systemd-udevd[368]: Could not generate persistent MAC address for virbr0: No such file or directory
NetworkManager[862]: <info>  [1508409794.6955] device added (path: /sys/devices/virtual/net/virbr0, iface: virbr0): no ifupdown configuration found.
NetworkManager[862]: <info>  [1508409794.6956] device added (path: /sys/devices/virtual/net/virbr0-nic, iface: virbr0-nic): no ifupdown configuration found.
NetworkManager[862]: <info>  [1508409794.7711] device (virbr0-nic): state change: unmanaged -> unavailable (reason 'connection-assumed') [10 20 41]
NetworkManager[862]: <info>  [1508409794.7725] device (virbr0-nic): state change: unavailable -> disconnected (reason 'none') [20 30 0]
NetworkManager[862]: <info>  [1508409796.0723] device (virbr0): state change: unmanaged -> unavailable (reason 'connection-assumed') [10 20 41] 
avahi-daemon[847]: Registering new address record for 192.168.122.1 on virbr0.IPv4.
NetworkManager[862]: <info>  [1508409796.0734] device (virbr0): state change: unavailable -> disconnected (reason 'connection-assumed') [20 30 41]
NetworkManager[862]: <info>  [1508409796.0739] device (virbr0): Activation: starting connection 'virbr0' (6a02deba-6a45-44f3-8c7d-92bb6f8c287b)
. . .                                                                                       
NetworkManager[862]: <info>  [1508409796.0829] device (virbr0): Activation: successful, device activated.
NetworkManager[862]: <info>  [1508409796.0833] device (virbr0-nic): state change: secondaries -> activated (reason 'none') [90 100 0]
nm-dispatcher: req:5 'up' [virbr0]: new request (2 scripts)                        
nm-dispatcher: req:5 'up' [virbr0]: start running ordered scripts...               
NetworkManager[862]: <info>  [1508409796.0877] device (virbr0-nic): Activation: successful, device activated.
nm-dispatcher: req:6 'up' [virbr0-nic]: new request (2 scripts)                    
nm-dispatcher: req:6 'up' [virbr0-nic]: start running ordered scripts...           
avahi-daemon[847]: Interface virbr0.IPv4 no longer relevant for mDNS.              
avahi-daemon[847]: Leaving mDNS multicast group on interface virbr0.IPv4 with address 192.168.122.1.
kernel: [   11.827450] virbr0: port 1(virbr0-nic) entered disabled state           
NetworkManager[862]: <info>  [1508409796.4151] device (virbr0): state change: activated -> unmanaged (reason 'connection-assumed') [100 10 41]
avahi-daemon[847]: Withdrawing address record for 192.168.122.1 on virbr0.         
nm-dispatcher: req:7 'down' [virbr0]: new request (2 scripts)                      
nm-dispatcher: req:7 'down' [virbr0]: start running ordered scripts...             
kernel: [   13.245387] device virbr0-nic left promiscuous mode                     
kernel: [   13.245390] virbr0: port 1(virbr0-nic) entered disabled state           
NetworkManager[862]: <info>  [1508409797.8565] device (virbr0-nic): state change: activated -> unmanaged (reason 'unmanaged') [100 10 3]
NetworkManager[862]: <info>  [1508409797.8565] device (virbr0): bridge port virbr0-nic was detached
NetworkManager[862]: <info>  [1508409797.8566] device (virbr0-nic): released from master device virbr0
NetworkManager[862]: <info>  [1508409797.8620] devices removed (path: /sys/devices/virtual/net/virbr0-nic, iface: virbr0-nic)
nm-dispatcher: req:8 'down' [virbr0-nic]: new request (2 scripts)                  
nm-dispatcher: req:8 'down' [virbr0-nic]: start running ordered scripts...         
NetworkManager[862]: <info>  [1508409797.8990] devices removed (path: /sys/devices/virtual/net/virbr0, iface: virbr0)

看起来有点像 virbr0 在启动期间被启用然后再次被禁用。

答案1

libvirtd如果网络标记为自动启动,则它应该在启动时立即启动。因此请检查是否libvirtd.service设置为在启动时自动启动。

另外,在您的第二条virsh命令中,您省略了sudo,因此有可能/很可能您正在连接到不同的libvirtd实例 - 以您的用户帐户运行的实例,而不是特权实例libvirtd。因此,请务必尝试sudo virsh net-list --all,如果没有显示自动启动,则运行sudo virsh net-autostart default

答案2

根据我的经验,libvirt 不会在启动时启动,您需要手动启动它。或者您需要创建一个脚本以通过 systemctl 在启动时启动 libvirt

相关内容