Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can qemu be used from the container? #11

Closed
ykoehler opened this issue Mar 17, 2017 · 11 comments
Closed

can qemu be used from the container? #11

ykoehler opened this issue Mar 17, 2017 · 11 comments

Comments

@ykoehler
Copy link

I was unable to get the command "runqemu qemux86 ramfs" to work.

Is there a way to get it supported?

@rewitt1
Copy link
Contributor

rewitt1 commented Mar 17, 2017

Hi Yannick,

I'm assuming you are getting an error saying it can't create a tap device? There are a couple of ways around this if you're on Linux. But assuming you are using a new enough version of poky/oe-core, runqemu should support "slirp" which would even work if using MacOS or Windows. And it is the simplest to try.

Try the command below and see if it works:

runqemu qemux86 ramfs slirp nographic

The slirp argument says to use usermode networking which doesn't need a tap device. The nographic will prevent an error from SDL saying it can't connect to the display, and cause the output to just go to your console.

If this works, let us know. And if you have more issues please ask. Because these kind of questions we'll try to answer in the wiki as well.

@ykoehler
Copy link
Author

ykoehler@yk-z620 ~/HPE-Aruba-ap-unified/poky $ build.sh "TEMPLATECONF=meta-uap/conf source oe-init-build-env && runqemu qemux86 ramfs slirp nographic"
latest: Pulling from hpe-aruba-ap-unified/poky-container
Digest: sha256:d5198553c2efa98c4fa1f94d74258bdacc6e17973c2b9af9938d0d4771183562
Status: Image is up to date for hub.docker.hpecorp.net/hpe-aruba-ap-unified/poky-container:latest

Shell environment set up for builds.

You can now run 'bitbake '

runqemu - INFO - Assuming MACHINE = qemux86
runqemu - INFO - Running MACHINE=qemux86 bitbake -e...
runqemu - INFO - MACHINE: qemux86
runqemu - INFO - DEPLOY_DIR_IMAGE: /workdir/build/tmp/deploy/images/qemux86
runqemu - INFO - Running ls -t /workdir/build/tmp/deploy/images/qemux86/*.qemuboot.conf...
runqemu - INFO - CONFFILE: /workdir/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86-20170317182653.qemuboot.conf
Traceback (most recent call last):
File "/workdir/scripts/runqemu", line 1019, in
ret = main()
File "/workdir/scripts/runqemu", line 1007, in main
config.check_and_set()
File "/workdir/scripts/runqemu", line 545, in check_and_set
check_tun()
File "/workdir/scripts/runqemu", line 102, in check_tun
raise Exception("TUN control device %s is unavailable; you may need to enable TUN (e.g. sudo modprobe tun)" % dev_tun)
Exception: TUN control device /dev/net/tun is unavailable; you may need to enable TUN (e.g. sudo modprobe tun)

It seems that runqemu call "check_tun" even if I specify the slirp option.

@bavery22
Copy link
Contributor

bavery22 commented Mar 17, 2017 via email

@rewitt1
Copy link
Contributor

rewitt1 commented Mar 20, 2017

Yannick,

Which version of poky are you based on? There are ways we could get it to work, but before I suggest something, I want to make sure I can try and verify it works.

@ykoehler
Copy link
Author

So, did some small digging, it works for you because you probably have the tun module loaded on your host. I do not, as such, whenever I try to launch qemu it says that the /dev/net/tun device is missing, because the runqemu script calls check_tun even if you specify to use slirp. I edited the script to comment out this sanity check_tun function and now I am able to get this working within docker.

@ykoehler
Copy link
Author

ykoehler commented Mar 20, 2017 via email

@bavery22
Copy link
Contributor

bavery22 commented Mar 21, 2017 via email

@hossein1100
Copy link

Hi
Im trying to run windows10 to my android phon by qemu system x86_64 headlees in termux
But i get this error:
qemu-system-x86_64: Slirp: Failed to send packet, ret: -1

Enyone can help me plz?
Screenshot_۲۰۲۱۰۸۰۳-۲۲۲۶۵۲_Termux

@Dexus
Copy link

Dexus commented Jan 27, 2022

Note if you add --device=/dev/tun to your docker run your should be able to remove slirp from the command

@DavidAntliff
Copy link

Note if you add --device=/dev/tun to your docker run your should be able to remove slirp from the command

I think it's --device=/dev/net/tun for some systems?

Also, setting up the tap interface requires root access in the container, via sudo, but pokyuser in the container isn't able to use sudo, so I'm not sure where that leaves us.

@lgrosz
Copy link

lgrosz commented Apr 1, 2023

I am having the same issue at @DavidAntliff , I get prompted for the password for pokyuser

user@host$ docker run --rm -it -v $(pwd):$(pwd) --device /dev/net/tun crops/poky --workdir=$(pwd)
pokyuser@e95ea229390b:/home/logan/projects/yocto_crops$ cd poky/
pokyuser@e95ea229390b:/home/logan/projects/yocto_crops/poky$ source oe-init-build-env 

### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-full-cmdline
    core-image-sato
    core-image-weston
    meta-toolchain
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86-64'.

Other commonly useful commands are:
 - 'devtool' and 'recipetool' handle common recipe tasks
 - 'bitbake-layers' handles common layer tasks
 - 'oe-pkgdata-util' handles common target package tasks
pokyuser@e95ea229390b:/home/logan/projects/yocto_crops/poky/build$ run qemu
bash: run: command not found
pokyuser@e95ea229390b:/home/logan/projects/yocto_crops/poky/build$ renqemu
bash: renqemu: command not found
pokyuser@e95ea229390b:/home/logan/projects/yocto_crops/poky/build$ runqemu
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [/home/logan/projects/yocto_crops/poky/build/tmp/deploy/images/qemux86-64/bzImage]
MACHINE: [qemux86-64]
FSTYPE: [ext4]
ROOTFS: [/home/logan/projects/yocto_crops/poky/build/tmp/deploy/images/qemux86-64/core-image-weston-qemux86-64-20230401065337.rootfs.ext4]
CONFFILE: [/home/logan/projects/yocto_crops/poky/build/tmp/deploy/images/qemux86-64/core-image-weston-qemux86-64-20230401065337.qemuboot.conf]

runqemu - INFO - Setting up tap interface under sudo
[sudo] password for pokyuser:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants