[PATCH] virNetDevOpenvswitchUpdateVlan: fix vlan tag update error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: tuqiang <tu.qiang35@xxxxxxxxxx>

We try to update vlan tag by running virsh update-device command,
libvirtd will report ovs-vsctl arguments error. Vlan tag update
funtion does't consider the xml with no vlan configured circumstances.

The steps to reproduce the problem:
1 define and start domain with its vlan configured as:
    <interface type='bridge'>
      <mac address='52:54:00:9e:bb:ac'/>
      <source bridge='ovs-br0'/>
      <vlan>
        <tag id='10'/>
      </vlan>
      <virtualport type='openvswitch'>
      </virtualport>
      <target dev='vnet4.0'/>
      <model type='virtio'/>
      <driver name='vhost'/>
    </interface>
2 define and run virsh update-device command with no vlan configured as:
    <interface type='bridge'>
      <mac address='52:54:00:9e:bb:ac'/>
      <source bridge='ovs-br0'/>
      <virtualport type='openvswitch'>
      </virtualport>
      <target dev='vnet4.0'/>
      <model type='virtio'/>
      <driver name='vhost'/>
    </interface>
   #virsh update-device dom-id novlan.xml
3 virsh command returned error, and we got an error in libvirtd.log:
  error : virCommandWait:2584 : internal error: exit status 1: ovs-vsctl: 'set' command requires at least 3 arguments
  . Child process (ovs-vsctl --timeout=5 -- --if-exists clear Port vnet4.0 tag -- --if-exists clear Port vnet4.0 trunk
  -- --if-exists clear Port vnet4.0 vlan_mode -- --if-exists set Port vnet4.0) unexpected
  error : virNetDevOpenvswitchUpdateVlan:540 : internal error: Unable to set vlan configuration on port vnet4.0

Signed-off-by: Tu Qiang <tu.qiang35@xxxxxxxxxx>
Signed-off-by: Yi Wang <wang.yi59@xxxxxxxxxx>
---
 src/util/virnetdevopenvswitch.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index bcdb7c4..227c040 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -605,8 +605,10 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname,
     virCommandAddArgList(cmd,
                          "--", "--if-exists", "clear", "Port", ifname, "tag",
                          "--", "--if-exists", "clear", "Port", ifname, "trunk",
-                         "--", "--if-exists", "clear", "Port", ifname, "vlan_mode",
-                         "--", "--if-exists", "set", "Port", ifname, NULL);
+                         "--", "--if-exists", "clear", "Port", ifname, "vlan_mode", NULL);
+
+	if (virtVlan && virtVlan->nTags > 0)
+		virCommandAddArgList(cmd, "--", "--if-exists", "set", "Port", ifname, NULL);
 
     virNetDevOpenvswitchConstructVlans(cmd, virtVlan);
 
-- 
1.8.3.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux