Bug 852984 - virsh start command will be hung with openvswitch network interface
virsh start command will be hung with openvswitch network interface
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.4
x86_64 Linux
high Severity high
: rc
: ---
Assigned To: Laine Stump
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-30 03:45 EDT by Alex Jia
Modified: 2013-02-21 02:22 EST (History)
6 users (show)

See Also:
Fixed In Version: libvirt-0.10.2-0rc1.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-21 02:22:36 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
backtrace of hung libvirtd (83.00 KB, text/plain)
2012-08-30 03:50 EDT, Alex Jia
no flags Details
backtrace of hung libvirtd (27.23 KB, text/plain)
2012-08-30 03:53 EDT, Alex Jia
no flags Details

  None (edit)
Description Alex Jia 2012-08-30 03:45:49 EDT
Description of problem:
To add openvswitch network interface into guest then just build ovs without ovs configuration, virsh start <guest> will be hang forever. 

Version-Release number of selected component (if applicable):

# rpm -q kernel libvirt qemu-kvm-rhev
kernel-2.6.32-288.el6.x86_64
libvirt-0.10.0-1.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.302.el6.x86_64

# ovs-vsctl --version
ovs-vsctl (Open vSwitch) 1.4.2
Compiled Aug 30 2012 10:58:29


How reproducible:
always

Steps to Reproduce:
1. To build ovs according to the following guide:

# wget http://openvswitch.org/releases/openvswitch-1.4.2.tar.gz
# tar zxvf openvswitch-1.4.2.tar.gz
# cd openvswitch-1.4.2
# ./boot.sh && % ./configure --prefix=/usr --localstatedir=/var
# make && make install
# ovs-vsctl --version

2. Don't need to do any ovs configuration, for example, you will see the following error:

# ovs-vsctl show
Aug 30 15:42:34|00001|stream_unix|ERR|/tmp/stream-unix.26185.0: connection to /var/run/openvswitch/db.sock failed: No such file or directory
Aug 30 15:42:34|00002|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory)

3. To define a virtual network like this:

# virsh net-dumpxml ovs-net
<network>
  <name>ovs-net</name>
  <uuid>6fa8aa9c-4a37-ded6-20c0-5c53786a5a4a</uuid>
  <forward mode='nat'/>
  <bridge name='ovsbr0' stp='on' delay='0' />
  <mac address='52:54:00:D0:D6:A3'/>
  <ip address='192.168.100.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.100.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>

4. To add openvswitch network interface into guest:

# virsh dumpxml foo
<domain type='kvm'>
  <name>foo</name>
  <uuid>492d9815-7eba-3d09-d857-63b1dc423ec7</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>524288</currentMemory>
  <vcpu placement='static'>5</vcpu>
  <os>
    <type arch='x86_64' machine='rhel6.2.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    ......
    </controller>
    <interface type='network'>
      <mac address='52:54:00:97:47:62'/>
      <source network='default'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='bridge'>
      <mac address='52:54:00:ca:b4:39'/>
      <source bridge='ovsbr0'/>
      <virtualport type='openvswitch'>
        <parameters interfaceid='3e092f81-7e82-fc95-47a1-8f5a5d3c389d'/>
      </virtualport>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>
    ......
  </devices>
</domain>

5. To start the guest

# virsh start foo

Actual results:
virsh start will be hang forever, and all of virsh commands also are hang.

Expected results:
Successfully start the guest.

Additional info:

# ps -ef | grep -E "[O|o]vs"
nobody   25598     1  0 15:20 ?        00:00:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --local=// --domain-needed --filterwin2k --pid-file=/var/run/libvirt/network/ovs-net.pid --conf-file= --except-interface lo --listen-address 192.168.100.1 --dhcp-range 192.168.100.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/ovs-net.leases --dhcp-lease-max=5885 --dhcp-no-override
root     26472 26293  0 15:48 ?        00:00:00 ovs-vsctl -- --may-exist add-port ovsbr0 vnet1
Comment 1 Alex Jia 2012-08-30 03:50:21 EDT
Created attachment 608065 [details]
backtrace of hung libvirtd
Comment 3 Alex Jia 2012-08-30 03:53:14 EDT
Created attachment 608066 [details]
backtrace of hung libvirtd
Comment 4 Daniel Veillard 2012-08-30 04:56:27 EDT
should be fixed upstream now,

commit 5e465df6be8bcb00f0b4bff831e91f4042fae272
Author: Kyle Mestery <kmestery@cisco.com>
Date:   Wed Aug 29 14:44:36 2012 -0400

    Fix a crash when using Open vSwitch virtual ports
    
    Fixup buffer usage when handling VLANs. Also fix the logic
    used to determine if the virNetDevVlanPtr is valid or not.
    Fixes crashes in the latest code when using Open vSwitch
    virtualports.
    
    Signed-off-by: Kyle Mestery <kmestery@cisco.com>
Comment 5 Daniel Veillard 2012-08-30 05:01:43 EDT
Ah, hum, no looking at the backtrace it's likely to be a different problem ...

Daniel
Comment 6 Alex Jia 2012-08-30 05:52:48 EDT
(In reply to comment #5)
> Ah, hum, no looking at the backtrace it's likely to be a different problem
> ...
> 
> Daniel

Yes, it's diffrent issue, so move the bug to 'NEW' again, I just simply configured ovs and also could meet this issue:

# ps -ef | grep --color -E "[O|o]vs"
nobody   23555     1  0 17:47 ?        00:00:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --local=// --domain-needed --filterwin2k --pid-file=/var/run/libvirt/network/ovs-net.pid --conf-file= --except-interface lo --listen-address 192.168.100.1 --dhcp-range 192.168.100.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/ovs-net.leases --dhcp-lease-max=5885 --dhcp-no-override
root     23581 21962  0 17:47 ?        00:00:00 ovs-vsctl -- --may-exist add-port ovsbr0 vnet0  -- set Interface vnet0 external-ids:attached-mac="52:54:00:79:50:4F" -- set Interface vnet0 external-ids:iface-id="9189f2ed-9aba-0e0f-35ad-83050282a3c7" -- set Interface vnet0 external-ids:vm-id="af57deb3-98a3-6cb7-b611-d63bcde2d7d5" -- set Interface vnet0 external-ids:iface-status=active
Comment 7 Laine Stump 2012-09-04 14:20:48 EDT
The problem is that, by default, ovs-vsctl will wait forever for ovs-vswitchd to respond, even if ovs-vswitchd isn't running.

The ovs-vsctl manpage recommends adding "--no-wait" to the ovs-vsctl commandline if you know that ovs-vswitchd isn't running, but of course we *don't* know that (and anyway, when I tested  --nowait just now, I found that it had absolutely no effect for the ovs-vsctl addport command).

An alternative is to set a timeout for the command with "--timeout=n" (all of this information is from the ovs-vsctl manpage). In this case, ovs-vsctl *will* exit with SIGALRM after the specified number of seconds. So the only trick is in figuring out the optimal setting for this - a shorter time means a greater likelyhood of false failure, but a longer time means a much longer stderr message in the logs. My preference is for longer messages, but greater reliability.
Comment 8 Laine Stump 2012-09-06 10:33:09 EDT
Pushed the following patch upstream:

commit 98e732fc34a47ad9dfdb64aa4207623ee4c1ebcd
Author: Laine Stump <laine@laine.org>
Date:   Tue Sep 4 15:26:29 2012 -0400

    network: prevent infinite hang if ovs-vswitchd isn't running
    
    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.
Comment 10 yanbing du 2012-09-20 06:55:22 EDT
Test with libvirt-0.10.2-0rc1.el6.x86_64, and the virsh command hang issue is fixed.
Following the steps in comment 0, when start guest, will get an error, but virsh will not hang.
# virsh start aaa
error: Failed to start domain aaa
error: Unable to add port vnet0 to OVS bridge ovsbr0: Operation not permitted

libvirtd.log
------
2012-09-20 10:08:16.957+0000: 22402: error : virCommandWait:2345 : internal error Child process (ovs-vsctl --timeout=5 -- --may-exist add-port ovsbr0 vnet0 -- set Interface vnet0 'external-ids:attached-mac="52:54:00:CA:B4:39"' -- set Interface vnet0 'external-ids:iface-id="3e092f81-7e82-fc95-47a1-8f5a5d3c389d"' -- set Interface vnet0 'external-ids:vm-id="59fa20eb-dfb1-7dc8-2158-7888dbbec13b"' -- set Interface vnet0 external-ids:iface-status=active) unexpected fatal signal 14: 2012-09-20T10:08:10Z|00002|stream_unix|ERR|/var/run/openvswitch/db.sock: connection failed (No such file or directory)
2012-09-20T10:08:10Z|00003|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory)
2012-09-20T10:08:11Z|00004|stream_unix|ERR|/var/run/openvswitch/db.sock: connection failed (No such file or directory)
2012-09-20T10:08:11Z|00005|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory)
2012-09-20T10:08:13Z|00006|stream_unix|ERR|/var/run/openvswitch/db.sock: connection failed (No such file or directory)
2012
2012-09-20 10:08:16.957+0000: 22402: error : virNetDevOpenvswitchAddPort:136 : Unable to add port vnet0 to OVS bridge ovsbr0: Operation not permitted
2012-09-20 10:08:17.007+0000: 22402: error : virCommandWait:2345 : internal error Child process (ovs-vsctl --timeout=5 -- --if-exists del-port) unexpected exit status 1: ovs-vsctl: 'del-port' command requires at least 1 arguments

2012-09-20 10:08:17.007+0000: 22402: error : virNetDevOpenvswitchRemovePort:173 : Unable to delete port (null) from OVS: Operation not permitted
------
Comment 11 errata-xmlrpc 2013-02-21 02:22:36 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0276.html

Note You need to log in before you can comment on or make changes to this bug.