* [PATCH] qemu*.conf: Add slirp support for all qemu machines @ 2016-11-28 20:11 Randy Witt 2016-11-29 6:21 ` Robert Yang 0 siblings, 1 reply; 4+ messages in thread From: Randy Witt @ 2016-11-28 20:11 UTC (permalink / raw) To: openembedded-core This patch also moves the "-net user" part out of the config and into runqemu. This is done because the "-net user" portion isn't machine specific, and it contains what ports to forward. [ YOCTO #7887 ] Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> --- meta/conf/machine/include/qemuboot-mips.inc | 1 + meta/conf/machine/include/qemuboot-x86.inc | 2 +- meta/conf/machine/qemuarm.conf | 1 + meta/conf/machine/qemuarm64.conf | 2 +- meta/conf/machine/qemuppc.conf | 1 + scripts/runqemu | 7 ++++++- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/meta/conf/machine/include/qemuboot-mips.inc b/meta/conf/machine/include/qemuboot-mips.inc index 0c60cf2..c85dc86 100644 --- a/meta/conf/machine/include/qemuboot-mips.inc +++ b/meta/conf/machine/include/qemuboot-mips.inc @@ -6,3 +6,4 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyS0 console=tty" # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy QB_OPT_APPEND = "-vga cirrus -show-cursor -usb -usbdevice tablet -device virtio-rng-pci" QB_SYSTEM_NAME = "qemu-system-${TUNE_ARCH}" +QB_SLIRP_OPT = "-device virtio-net-pci,netdev=net0" diff --git a/meta/conf/machine/include/qemuboot-x86.inc b/meta/conf/machine/include/qemuboot-x86.inc index 0870294..cc31dab 100644 --- a/meta/conf/machine/include/qemuboot-x86.inc +++ b/meta/conf/machine/include/qemuboot-x86.inc @@ -13,4 +13,4 @@ QB_AUDIO_OPT = "-soundhw ac97,es1370" QB_KERNEL_CMDLINE_APPEND = "vga=0 uvesafb.mode_option=640x480-32 oprofile.timer=1 uvesafb.task_timeout=-1" # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy QB_OPT_APPEND = "-vga vmware -show-cursor -usb -usbdevice tablet -device virtio-rng-pci" -QB_SLIRP_OPT = "-net nic,model=e1000 -net user,hostfwd=tcp::2222-:22" +QB_SLIRP_OPT = "-device virtio-net-pci,netdev=net0" diff --git a/meta/conf/machine/qemuarm.conf b/meta/conf/machine/qemuarm.conf index 17402ef..974657b 100644 --- a/meta/conf/machine/qemuarm.conf +++ b/meta/conf/machine/qemuarm.conf @@ -18,3 +18,4 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty" QB_OPT_APPEND = "-show-cursor -usb -usbdevice tablet -device virtio-rng-pci" PREFERRED_VERSION_linux-yocto ??= "4.8%" QB_DTB = "${@base_version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}" +QB_SLIRP_OPT = "-device virtio-net-pci,netdev=net0" diff --git a/meta/conf/machine/qemuarm64.conf b/meta/conf/machine/qemuarm64.conf index df2010c..ebd360e 100644 --- a/meta/conf/machine/qemuarm64.conf +++ b/meta/conf/machine/qemuarm64.conf @@ -18,7 +18,7 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,38400" # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy QB_OPT_APPEND = "-show-cursor -device virtio-rng-pci -monitor null" QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no -device virtio-net-device,netdev=net0,mac=@MAC@" -QB_SLIRP_OPT = "-netdev user,id=net0 -device virtio-net-device,netdev=net0" +QB_SLIRP_OPT = "-device virtio-net-device,netdev=net0" QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0" QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon" QB_TCPSERIAL_OPT = " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon" diff --git a/meta/conf/machine/qemuppc.conf b/meta/conf/machine/qemuppc.conf index 8703c20..4711751 100644 --- a/meta/conf/machine/qemuppc.conf +++ b/meta/conf/machine/qemuppc.conf @@ -19,3 +19,4 @@ QB_KERNEL_CMDLINE_APPEND = "console=tty console=ttyS0" # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy QB_OPT_APPEND = "-show-cursor -usb -usbdevice tablet -device virtio-rng-pci" QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no -device virtio-net-pci,netdev=net0,mac=@MAC@" +QB_SLIRP_OPT = "-device virtio-net-pci,netdev=net0" diff --git a/scripts/runqemu b/scripts/runqemu index af25423..faab522 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -730,7 +730,12 @@ class BaseConfig(object): if self.fstype == 'nfs': self.setup_nfs() self.kernel_cmdline_script += ' ip=dhcp' - self.set('NETWORK_CMD', self.get('QB_SLIRP_OPT')) + network_cmd = self.get('QB_SLIRP_OPT') + + # The network device created in qemuboot.conf is expected to be + # id=net0 + network_cmd += ' -netdev user,id=net0,hostfwd=tcp::2222-:22' + self.set('NETWORK_CMD', network_cmd) def setup_tap(self): """Setup tap""" -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] qemu*.conf: Add slirp support for all qemu machines 2016-11-28 20:11 [PATCH] qemu*.conf: Add slirp support for all qemu machines Randy Witt @ 2016-11-29 6:21 ` Robert Yang 2016-11-29 18:24 ` Randy Witt 0 siblings, 1 reply; 4+ messages in thread From: Robert Yang @ 2016-11-29 6:21 UTC (permalink / raw) To: Randy Witt, openembedded-core On 11/29/2016 04:11 AM, Randy Witt wrote: > This patch also moves the "-net user" part out of the config and > into runqemu. This is done because the "-net user" portion isn't > machine specific, and it contains what ports to forward. > > [ YOCTO #7887 ] > > Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> > --- > meta/conf/machine/include/qemuboot-mips.inc | 1 + > meta/conf/machine/include/qemuboot-x86.inc | 2 +- > meta/conf/machine/qemuarm.conf | 1 + > meta/conf/machine/qemuarm64.conf | 2 +- > meta/conf/machine/qemuppc.conf | 1 + > scripts/runqemu | 7 ++++++- > 6 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/meta/conf/machine/include/qemuboot-mips.inc b/meta/conf/machine/include/qemuboot-mips.inc > index 0c60cf2..c85dc86 100644 > --- a/meta/conf/machine/include/qemuboot-mips.inc > +++ b/meta/conf/machine/include/qemuboot-mips.inc > @@ -6,3 +6,4 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyS0 console=tty" > # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy > QB_OPT_APPEND = "-vga cirrus -show-cursor -usb -usbdevice tablet -device virtio-rng-pci" > QB_SYSTEM_NAME = "qemu-system-${TUNE_ARCH}" > +QB_SLIRP_OPT = "-device virtio-net-pci,netdev=net0" > diff --git a/meta/conf/machine/include/qemuboot-x86.inc b/meta/conf/machine/include/qemuboot-x86.inc > index 0870294..cc31dab 100644 > --- a/meta/conf/machine/include/qemuboot-x86.inc > +++ b/meta/conf/machine/include/qemuboot-x86.inc > @@ -13,4 +13,4 @@ QB_AUDIO_OPT = "-soundhw ac97,es1370" > QB_KERNEL_CMDLINE_APPEND = "vga=0 uvesafb.mode_option=640x480-32 oprofile.timer=1 uvesafb.task_timeout=-1" > # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy > QB_OPT_APPEND = "-vga vmware -show-cursor -usb -usbdevice tablet -device virtio-rng-pci" > -QB_SLIRP_OPT = "-net nic,model=e1000 -net user,hostfwd=tcp::2222-:22" > +QB_SLIRP_OPT = "-device virtio-net-pci,netdev=net0" > diff --git a/meta/conf/machine/qemuarm.conf b/meta/conf/machine/qemuarm.conf > index 17402ef..974657b 100644 > --- a/meta/conf/machine/qemuarm.conf > +++ b/meta/conf/machine/qemuarm.conf > @@ -18,3 +18,4 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty" > QB_OPT_APPEND = "-show-cursor -usb -usbdevice tablet -device virtio-rng-pci" > PREFERRED_VERSION_linux-yocto ??= "4.8%" > QB_DTB = "${@base_version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}" > +QB_SLIRP_OPT = "-device virtio-net-pci,netdev=net0" > diff --git a/meta/conf/machine/qemuarm64.conf b/meta/conf/machine/qemuarm64.conf > index df2010c..ebd360e 100644 > --- a/meta/conf/machine/qemuarm64.conf > +++ b/meta/conf/machine/qemuarm64.conf > @@ -18,7 +18,7 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,38400" > # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy > QB_OPT_APPEND = "-show-cursor -device virtio-rng-pci -monitor null" > QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no -device virtio-net-device,netdev=net0,mac=@MAC@" > -QB_SLIRP_OPT = "-netdev user,id=net0 -device virtio-net-device,netdev=net0" > +QB_SLIRP_OPT = "-device virtio-net-device,netdev=net0" > QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0" > QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon" > QB_TCPSERIAL_OPT = " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon" > diff --git a/meta/conf/machine/qemuppc.conf b/meta/conf/machine/qemuppc.conf > index 8703c20..4711751 100644 > --- a/meta/conf/machine/qemuppc.conf > +++ b/meta/conf/machine/qemuppc.conf > @@ -19,3 +19,4 @@ QB_KERNEL_CMDLINE_APPEND = "console=tty console=ttyS0" > # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy > QB_OPT_APPEND = "-show-cursor -usb -usbdevice tablet -device virtio-rng-pci" > QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no -device virtio-net-pci,netdev=net0,mac=@MAC@" > +QB_SLIRP_OPT = "-device virtio-net-pci,netdev=net0" > diff --git a/scripts/runqemu b/scripts/runqemu > index af25423..faab522 100755 > --- a/scripts/runqemu > +++ b/scripts/runqemu > @@ -730,7 +730,12 @@ class BaseConfig(object): > if self.fstype == 'nfs': > self.setup_nfs() > self.kernel_cmdline_script += ' ip=dhcp' > - self.set('NETWORK_CMD', self.get('QB_SLIRP_OPT')) > + network_cmd = self.get('QB_SLIRP_OPT') > + > + # The network device created in qemuboot.conf is expected to be > + # id=net0 > + network_cmd += ' -netdev user,id=net0,hostfwd=tcp::2222-:22' Hi Randy, This doesn't work when more than one qemu is running since the port will be conflicted. And since all of the QB_SLIRP_OPT are the same, so I'd like to set it as a default value in runqemu, just like what we do for QB_TAP_OPT. And if we break them into two parts: "-device virtio-net-device,netdev=net0" and "-netdev user,id=net0,hostfwd=tcp::2222-:22" Then there is no way for user to override the second part, and we can't call the first part as a "QB_SLIRP_OPT" since it is only part of them, so I won't break them into 2, and if the user defines QB_SLIRP_OPT in there bsp conf file, then it will be replaced totally. I will send a new patch for fixing this, and will add you in the CC list. // Robert > + self.set('NETWORK_CMD', network_cmd) > > def setup_tap(self): > """Setup tap""" > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] qemu*.conf: Add slirp support for all qemu machines 2016-11-29 6:21 ` Robert Yang @ 2016-11-29 18:24 ` Randy Witt 2016-11-30 2:00 ` Robert Yang 0 siblings, 1 reply; 4+ messages in thread From: Randy Witt @ 2016-11-29 18:24 UTC (permalink / raw) To: Robert Yang, openembedded-core > > "-device virtio-net-device,netdev=net0" and > "-netdev user,id=net0,hostfwd=tcp::2222-:22" > > Then there is no way for user to override the second part, and we can't > call the first part as a "QB_SLIRP_OPT" since it is only part of them, > so I won't break them into 2, and if the user defines QB_SLIRP_OPT > in there bsp conf file, then it will be replaced totally. > I'm aware that this will only work for one instance, but currently it doesn't work at all and it blocks a high priority bug. The only way to make it 100% work, would be to have qemu do the binding of the port to a dynamic one and then the user queries it after. Otherwise there is always a window where another process could bind to the port. I don't think the bsp should be in the business of choosing which ports to forward. And if it is, then it should be a separate option in the qemuboot.conf, with just the "-netdev user" part because otherwise the user will always have to modify qemuboot.conf just to forward different ports. It makes more sense to let the user do something like "runqemu slirp=22,65,..." and then return back the actual port used in the forwarding. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] qemu*.conf: Add slirp support for all qemu machines 2016-11-29 18:24 ` Randy Witt @ 2016-11-30 2:00 ` Robert Yang 0 siblings, 0 replies; 4+ messages in thread From: Robert Yang @ 2016-11-30 2:00 UTC (permalink / raw) To: Randy Witt, openembedded-core On 11/30/2016 02:24 AM, Randy Witt wrote: > >> >> "-device virtio-net-device,netdev=net0" and >> "-netdev user,id=net0,hostfwd=tcp::2222-:22" >> >> Then there is no way for user to override the second part, and we can't >> call the first part as a "QB_SLIRP_OPT" since it is only part of them, >> so I won't break them into 2, and if the user defines QB_SLIRP_OPT >> in there bsp conf file, then it will be replaced totally. >> > > I'm aware that this will only work for one instance, but currently it doesn't > work at all and it blocks a high priority bug. The only way to make it 100% > work, would be to have qemu do the binding of the port to a dynamic one and then > the user queries it after. Otherwise there is always a window where another > process could bind to the port. We can check whether the port is free and use another one if not, we've already done similar things in runqemu-export-rootfs for nfs, please see: http://lists.openembedded.org/pipermail/openembedded-core/2016-November/129376.html // Robert > > I don't think the bsp should be in the business of choosing which ports to > forward. And if it is, then it should be a separate option in the qemuboot.conf, > with just the "-netdev user" part because otherwise the user will always have to > modify qemuboot.conf just to forward different ports. > > It makes more sense to let the user do something like "runqemu slirp=22,65,..." > and then return back the actual port used in the forwarding. > > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-30 2:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-11-28 20:11 [PATCH] qemu*.conf: Add slirp support for all qemu machines Randy Witt 2016-11-29 6:21 ` Robert Yang 2016-11-29 18:24 ` Randy Witt 2016-11-30 2:00 ` Robert Yang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox