diff options
author | Adrian Freihofer <adrian.freihofer@siemens.com> | 2020-03-17 16:26:50 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-03-21 22:39:00 +0000 |
commit | 2f6a47c4d4dc24135b69ed01e193740c24f269e8 (patch) | |
tree | 713860175fe4e0bf660aacd816d68cc15d36422c /scripts/runqemu | |
parent | 8afdc80989e19c17c43959ecbeb5a59b85a0bc1f (diff) | |
download | poky-2f6a47c4d4dc24135b69ed01e193740c24f269e8.tar.gz |
runqemu: support multiple NICs
Emulating more than one network interface with runqemu is a bit tricky,
but possible. For example, the following leads to an emulated device with
eth0 and eth1:
QB_NETWORK_DEVICE_prepend = " \
-device virtio-net-device,mac=52:54:00:12:34:03 \
"
or
QB_NETWORK_DEVICE_append = " \
-device virtio-net-pci,mac=52:54:00:12:34:03 \
"
When booting Qemu with two NICs, the kernel does not know which
interface the specified ip=192.168.7.... command line argument
should be applied. This delays the boot process for a very long
time and a guest wihtout IP configuration.
This add two new configuraton parameters to runqemu:
QB_CMDLINE_IP_SLIRP and QB_CMDLINE_IP_TAP to explicitely specify the ip=
kernel command line arguments for tap and slirp mode.
Note: Simply adding "::eth0" broke some builds on the Yocto autobuilder.
(From OE-Core rev: 59bfdc331c1494c05ab38804b281878a1f571f6d)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-x | scripts/runqemu | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index dd0aa4b28f..6f24093d77 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
@@ -185,6 +185,8 @@ class BaseConfig(object): | |||
185 | self.vmtypes = ('hddimg', 'iso') | 185 | self.vmtypes = ('hddimg', 'iso') |
186 | self.fsinfo = {} | 186 | self.fsinfo = {} |
187 | self.network_device = "-device e1000,netdev=net0,mac=@MAC@" | 187 | self.network_device = "-device e1000,netdev=net0,mac=@MAC@" |
188 | self.cmdline_ip_slirp = "ip=dhcp" | ||
189 | self.cmdline_ip_tap = "ip=192.168.7.@CLIENT@::192.168.7.@GATEWAY@:255.255.255.0" | ||
188 | # Use different mac section for tap and slirp to avoid | 190 | # Use different mac section for tap and slirp to avoid |
189 | # conflicts, e.g., when one is running with tap, the other is | 191 | # conflicts, e.g., when one is running with tap, the other is |
190 | # running with slirp. | 192 | # running with slirp. |
@@ -1032,7 +1034,9 @@ class BaseConfig(object): | |||
1032 | 1034 | ||
1033 | if self.fstype == 'nfs': | 1035 | if self.fstype == 'nfs': |
1034 | self.setup_nfs() | 1036 | self.setup_nfs() |
1035 | self.kernel_cmdline_script += ' ip=dhcp' | 1037 | netconf = " " + self.cmdline_ip_slirp |
1038 | logger.info("Network configuration:%s", netconf) | ||
1039 | self.kernel_cmdline_script += netconf | ||
1036 | # Port mapping | 1040 | # Port mapping |
1037 | hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23" | 1041 | hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23" |
1038 | qb_slirp_opt_default = "-netdev user,id=net0%s,tftp=%s" % (hostfwd, self.get('DEPLOY_DIR_IMAGE')) | 1042 | qb_slirp_opt_default = "-netdev user,id=net0%s,tftp=%s" % (hostfwd, self.get('DEPLOY_DIR_IMAGE')) |
@@ -1147,9 +1151,11 @@ class BaseConfig(object): | |||
1147 | client = gateway + 1 | 1151 | client = gateway + 1 |
1148 | if self.fstype == 'nfs': | 1152 | if self.fstype == 'nfs': |
1149 | self.setup_nfs() | 1153 | self.setup_nfs() |
1150 | netconf = "192.168.7.%s::192.168.7.%s:255.255.255.0" % (client, gateway) | 1154 | netconf = " " + self.cmdline_ip_tap |
1151 | logger.info("Network configuration: %s", netconf) | 1155 | netconf = netconf.replace('@CLIENT@', str(client)) |
1152 | self.kernel_cmdline_script += " ip=%s" % netconf | 1156 | netconf = netconf.replace('@GATEWAY@', str(gateway)) |
1157 | logger.info("Network configuration:%s", netconf) | ||
1158 | self.kernel_cmdline_script += netconf | ||
1153 | mac = "%s%02x" % (self.mac_tap, client) | 1159 | mac = "%s%02x" % (self.mac_tap, client) |
1154 | qb_tap_opt = self.get('QB_TAP_OPT') | 1160 | qb_tap_opt = self.get('QB_TAP_OPT') |
1155 | if qb_tap_opt: | 1161 | if qb_tap_opt: |
@@ -1171,8 +1177,10 @@ class BaseConfig(object): | |||
1171 | if self.net_bridge: | 1177 | if self.net_bridge: |
1172 | self.setup_net_bridge() | 1178 | self.setup_net_bridge() |
1173 | elif self.slirp_enabled: | 1179 | elif self.slirp_enabled: |
1180 | self.cmdline_ip_slirp = self.get('QB_CMDLINE_IP_SLIRP') or self.cmdline_ip_slirp | ||
1174 | self.setup_slirp() | 1181 | self.setup_slirp() |
1175 | else: | 1182 | else: |
1183 | self.cmdline_ip_tap = self.get('QB_CMDLINE_IP_TAP') or self.cmdline_ip_tap | ||
1176 | self.setup_tap() | 1184 | self.setup_tap() |
1177 | 1185 | ||
1178 | def setup_rootfs(self): | 1186 | def setup_rootfs(self): |