Skip to contentSkip to conversation

tests/kvm: fix -net syntax for new qemu

PATCH In review Michael S. Tsirkin 3 participants 4 messages Sep 13, 2010 – Sep 14, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/kvm: fix -net syntax for new qemu

netdev option in new qemu is mutually exclusive with vlan. Only pass vlan if netdev option is missing.

---

client/tests/kvm/kvm_vm.py +3 -2
index bdc9aab..7e76ed5 100755
@@ -235,9 +235,10 @@ class VM:
             return cmd
 
         def add_nic(help, vlan, model=None, mac=None, netdev_id=None):
-            cmd = " -net nic,vlan=%d" % vlan
             if has_option(help, "netdev"):
-                cmd +=",netdev=%s" % netdev_id
+                cmd = " -net nic,netdev=%s" % netdev_id
+            else:
+                cmd = " -net nic,vlan=%d" % vlan
             if model: cmd += ",model=%s" % model
             if mac: cmd += ",macaddr='%s'" % mac
             return cmd
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Michael S. Tsirkin

netdev option in new qemu is mutually exclusive with vlan. Only pass vlan if netdev option is missing.

This fix looks good for me.

BTW, we try to produce three kinds of cmdline, possible combinations:

1. Old way:   -net nic,model=e1000,vlan=1 -net tap,vlan=1
2. Semi-new:  -device e1000,vlan=1        -net tap,vlan=1
3. Best way:  -netdev type=tap,id=netdev1 -device e1000,id=netdev1

If you think this is good, I'll sent a patch to upstream.

Quoted 19 lines

---

client/tests/kvm/kvm_vm.py +3 -2
index bdc9aab..7e76ed5 100755
@@ -235,9 +235,10 @@ class VM:
             return cmd
 
         def add_nic(help, vlan, model=None, mac=None, netdev_id=None):
-            cmd = " -net nic,vlan=%d" % vlan
             if has_option(help, "netdev"):
-                cmd +=",netdev=%s" % netdev_id
+                cmd = " -net nic,netdev=%s" % netdev_id
+            else:
+                cmd = " -net nic,vlan=%d" % vlan
             if model: cmd += ",model=%s" % model
             if mac: cmd += ",macaddr='%s'" % mac
             return cmd
#2 lore raw
Quoted 7 lines · Amos Kong
Quoted 4 lines · Michael S. Tsirkin

netdev option in new qemu is mutually exclusive with vlan. Only pass vlan if netdev option is missing.

This fix looks good for me.

Quoted 8 lines

BTW, we try to produce three kinds of cmdline, possible combinations:

1. Old way:   -net nic,model=e1000,vlan=1 -net tap,vlan=1
2. Semi-new:  -device e1000,vlan=1        -net tap,vlan=1
3. Best way:  -netdev type=tap,id=netdev1 -device e1000,id=netdev1

If you think this is good, I'll sent a patch to upstream.

I don't think we care about the Semi-new way.

Quoted 19 lines
Quoted 19 lines

---

client/tests/kvm/kvm_vm.py +3 -2
index bdc9aab..7e76ed5 100755
@@ -235,9 +235,10 @@ class VM:
             return cmd
 
         def add_nic(help, vlan, model=None, mac=None, netdev_id=None):
-            cmd = " -net nic,vlan=%d" % vlan
             if has_option(help, "netdev"):
-                cmd +=",netdev=%s" % netdev_id
+                cmd = " -net nic,netdev=%s" % netdev_id
+            else:
+                cmd = " -net nic,vlan=%d" % vlan
             if model: cmd += ",model=%s" % model
             if mac: cmd += ",macaddr='%s'" % mac
             return cmd
#3 lore raw
In reply to Michael S. Tsirkin
Quoted 2 lines · Michael S. Tsirkin

netdev option in new qemu is mutually exclusive with vlan. Only pass vlan if netdev option is missing.

Looks good to me, applied, thanks!

http://autotest.kernel.org/changeset/4783

Quoted 25 lines

---

client/tests/kvm/kvm_vm.py +3 -3
index bdc9aab..7e76ed5 100755
@@ -235,9 +235,10 @@ class VM:
             return cmd
 
         def add_nic(help, vlan, model=None, mac=None, netdev_id=None):
-            cmd = " -net nic,vlan=%d" % vlan
             if has_option(help, "netdev"):
-                cmd +=",netdev=%s" % netdev_id
+                cmd = " -net nic,netdev=%s" % netdev_id
+            else:
+                cmd = " -net nic,vlan=%d" % vlan
             if model: cmd += ",model=%s" % model
             if mac: cmd += ",macaddr='%s'" % mac
             return cmd
--

To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html