]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnetdevopenvswitch: Create OVS ports as transient
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 19 Apr 2024 13:45:48 +0000 (15:45 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 24 Apr 2024 11:13:07 +0000 (13:13 +0200)
Since OVS keeps desired state in a DB, upon sudden crash of the
host we may leave a port behind. There's no problem on VM
shutdown or NIC hotunplug as we call corresponding del-port
function (virNetDevOpenvswitchRemovePort()). But if the host
suddenly crashes we won't ever do that. What happens next, is
when OVS starts it finds desired state in its DB and creates a
stale port.

OVS added support for transient ports in v2.5.0 (Feb 2016) and
since its v2.9.0 it even installs a systemd service
(ovs-delete-transient-ports) that automatically deletes transient
ports on system startup. If we mark a port as transient then OVS
won't restore its state on restart after crash.

This change may render "--may-exist" argument redundant, but I'm
not sure about all the implications if it was removed. Let's keep
it for now.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/615
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/util/virnetdevopenvswitch.c

index f1765ae1c87cfe2de9369d19ce447e344ea11c39..e23f4c83b60c84b9085af083ee42b48865a66e08 100644 (file)
@@ -164,7 +164,9 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
 
     cmd = virNetDevOpenvswitchCreateCmd(&errbuf);
     virCommandAddArgList(cmd, "--", "--may-exist",
-                         "add-port", brname, ifname, NULL);
+                         "add-port", brname, ifname,
+                         "--", "set", "Port", ifname, "other_config:transient=true",
+                         NULL);
 
     virNetDevOpenvswitchConstructVlans(cmd, virtVlan);