Re: [libvirt] [PATCH] network: prevent infinite hang if ovs-vswitchd isn't running

2012-09-05 Thread Laine Stump
On 09/05/2012 02:28 PM, Kyle Mestery (kmestery) wrote:
> On Sep 5, 2012, at 1:24 PM, Laine Stump wrote:
>> 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.
>
> This looks good. I agree with your comments here around the 5 second
> timeout not being ideal, but being workable.

Thanks. I pushed it, but feel free to revisit if you come up with a
better solution. (I greatly dislike any hardcoded timeout and only use
them as a last resort).

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] network: prevent infinite hang if ovs-vswitchd isn't running

2012-09-05 Thread Kyle Mestery (kmestery)
On Sep 5, 2012, at 1:24 PM, Laine Stump wrote:
> 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.


This looks good. I agree with your comments here around the 5 second
timeout not being ideal, but being workable.

Acked-by: Kyle Mestery 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] network: prevent infinite hang if ovs-vswitchd isn't running

2012-09-05 Thread Laine Stump
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.
---

I'm not sure if 5 seconds is a reasonable timeout for this, but it
seems to work okay for me (in a very lightly loaded environment, but a
successful return is always effectively instantaneous...).
Unfortunately there doesn't seem to be another way to bound the wait
time of ovs-vsctl. :-(


 src/util/virnetdevopenvswitch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 764f478..97b9d52 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -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,
-- 
1.7.11.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list