cros_vm: Use a smaller virtual network.
Currently, we are using 10.0.2.0/24 inside vm and this brings issue for vm
to connect to host servers which happen to have IP on 10.0.2.0/24 network.
As a first step, just use 10.0.2.0/27 inside vm so such issue will only
happens for host ip between 10.0.2.0 - 10.0.2.31. Also, vlan setup has
been removed since netdev put every nic on an isolated vlan and it doesn't
support vlan setup. I believe we don't have tests which depends on cros_vm
to run mutiple vm on same vlan so this shouldn't be a issue.
BUG=chromium:808045
TEST=manual - run cros_vm and check ifconfig inside vm.
Change-Id: I4fff7bf1ff531a9a0b8ffc9d434c0789ece2bdb0
Reviewed-on: https://chromium-review.googlesource.com/1020307
Commit-Ready: Lepton Wu <lepton@chromium.org>
Tested-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/scripts/cros_vm.py b/scripts/cros_vm.py
index 70563b1..a0c9a69 100644
--- a/scripts/cros_vm.py
+++ b/scripts/cros_vm.py
@@ -294,14 +294,9 @@
'-mon', 'chardev=control_pipe',
# Append 'check' to warn if the requested CPU is not fully supported.
'-cpu', self.qemu_cpu + ',check',
- # Qemu-vlans are used by qemu to separate out network traffic on the
- # slirp network bridge. qemu forwards traffic on a slirp vlan to all
- # ports conected on that vlan. By default, slirp ports are on vlan
- # 0. We explicitly set a vlan here so that another qemu VM using
- # slirp doesn't conflict with our network traffic.
- '-net', 'nic,model=virtio,vlan=%d' % self.ssh_port,
- '-net', 'user,hostfwd=tcp:127.0.0.1:%d-:22,vlan=%d'
- % (self.ssh_port, self.ssh_port),
+ '-device', 'virtio-net,netdev=eth0',
+ '-netdev', 'user,id=eth0,net=10.0.2.0/27,hostfwd=tcp:127.0.0.1:%d-:22'
+ % self.ssh_port,
'-drive', 'file=%s,index=0,media=disk,cache=unsafe,format=%s'
% (self.image_path, self.image_format),
]