]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
network: prevent infinite hang if ovs-vswitchd isn't running
authorLaine Stump <laine@laine.org>
Tue, 4 Sep 2012 19:26:29 +0000 (15:26 -0400)
committerLaine Stump <laine@laine.org>
Wed, 5 Sep 2012 18:35:04 +0000 (14:35 -0400)
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=852984

If a network or interface is configured to use Open vSwitch, but
ovs-vswitchd (the Open vSwitch database service) isn't running, the
ovs-vsctl add-port/del-port commands will hang indefinitely rather
than returning an error. There is a --nowait option, but that appears
to have no effect on add-port and del-port commands, so instead we add
a --timeout=5 to the commands - they will retry for up to 5 seconds,
then fail if there is no response.

src/util/virnetdevopenvswitch.c

index 764f478a6a197948365309f4f5604d1aeee0522b..97b9d52c197ed1f38335e25973e199b44334808f 100644 (file)
@@ -105,7 +105,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
 
     cmd = virCommandNew(OVSVSCTL);
 
-    virCommandAddArgList(cmd, "--", "--may-exist", "add-port",
+    virCommandAddArgList(cmd, "--timeout=5", "--", "--may-exist", "add-port",
                         brname, ifname, NULL);
 
     if (virBufferUse(&buf) != 0)
@@ -166,7 +166,7 @@ int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const ch
     virCommandPtr cmd = NULL;
 
     cmd = virCommandNew(OVSVSCTL);
-    virCommandAddArgList(cmd, "--", "--if-exists", "del-port", ifname, NULL);
+    virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists", "del-port", ifname, NULL);
 
     if (virCommandRun(cmd, NULL) < 0) {
         virReportSystemError(VIR_ERR_INTERNAL_ERROR,