Comment 15 for bug 1982218

Revision history for this message
Nick Rosbrook (enr0n) wrote :

I have verified the fix using systemd 252.5-2ubuntu3.1 from lunar-proposed:

The VM and test networks are already configured on my system:

nr@six:/t/tmp.jTS3wdPdT3$ virsh list
 Id Name State
-----------------------------------
 9 clean-lunar-amd64 running

nr@six:/t/tmp.jTS3wdPdT3$ virsh net-list
 Name State Autostart Persistent
--------------------------------------------
 default active yes yes
 no-dhcp active no no

nr@six:/t/tmp.jTS3wdPdT3$ virsh net-dumpxml --network default
<network connections='2'>
  <name>default</name>
  <uuid>04260896-2701-422d-84e0-8e0df1122db3</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:bd:9f:3a'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>

nr@six:/t/tmp.jTS3wdPdT3$ virsh net-dumpxml --network no-dhcp
<network>
  <name>no-dhcp</name>
  <uuid>2c047740-caab-4c90-8421-70da6732a759</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr1' stp='on' delay='0'/>
  <mac address='52:54:00:ac:12:45'/>
  <ip address='172.16.1.1' netmask='255.255.0.0'>
  </ip>
</network>

Running the test case:

(Host)

nr@six:/t/tmp.jTS3wdPdT3$ virsh detach-interface clean-lunar-amd64 network
Interface detached successfully

(VM)

root@clean-lunar-amd64:/home/nr# apt-cache policy systemd
systemd:
  Installed: 252.5-2ubuntu3.1
  Candidate: 252.5-2ubuntu3.1
  Version table:
 *** 252.5-2ubuntu3.1 500
        500 http://security.ubuntu.com/ubuntu lunar-proposed/main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu lunar-proposed/main amd64 Packages
        100 /var/lib/dpkg/status
     252.5-2ubuntu3 500
        500 http://archive.ubuntu.com/ubuntu lunar/main amd64 Packages
root@clean-lunar-amd64:/home/nr# cat > /etc/systemd/network/10-dhcp.network << EOF
[Match]
Name=en*

[Network]
DHCP=yes
EOF
root@clean-lunar-amd64:/home/nr# systemctl restart systemd-networkd

(Host)

nr@six:/t/tmp.jTS3wdPdT3$ virsh attach-interface clean-lunar-amd64 network no-dhcp
Interface attached successfully

(VM)

root@clean-lunar-amd64:/home/nr# networkctl
IDX LINK TYPE OPERATIONAL SETUP
  1 lo loopback carrier unmanaged
  5 ens3 ether degraded configuring

2 links listed.
root@clean-lunar-amd64:/home/nr# /lib/systemd/systemd-networkd-wait-online --any --timeout=10
Timeout occurred while waiting for network connectivity.
root@clean-lunar-amd64:/home/nr# networkctl
IDX LINK TYPE OPERATIONAL SETUP
  1 lo loopback carrier unmanaged
  5 ens3 ether degraded configuring

2 links listed.

(Host)

nr@six:/t/tmp.jTS3wdPdT3$ virsh attach-interface clean-lunar-amd64 network default
Interface attached successfully

(VM)

root@clean-lunar-amd64:/home/nr# /lib/systemd/systemd-networkd-wait-online --any --timeout=0
root@clean-lunar-amd64:/home/nr# echo $?
0
root@clean-lunar-amd64:/home/nr# networkctl
IDX LINK TYPE OPERATIONAL SETUP
  1 lo loopback carrier unmanaged
  5 ens3 ether degraded configuring
  6 ens9 ether routable configured

3 links listed.