Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to run qemu-kvm from the login text console (Solved)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
nlsa8z6zoz7lyih3ap
Guru
Guru


Joined: 25 Sep 2007
Posts: 373
Location: Canada

PostPosted: Thu May 22, 2014 4:31 pm    Post subject: How to run qemu-kvm from the login text console (Solved) Reply with quote

I wish to run a qemu-kvm guest gentoo vm in a gentoo host, from the login console of the host, with no graphics at all.

Currently I am trying to open it from the shell with this script:
Code:
#/bin/sh
exec qemu-kvm -nographic \
        -cpu host -smp 8\
         -drive file=gentoo.img,if=virtio \
         -drive file=gentoosdab.img,if=virtio    \
         -net nic -net user,hostname=GentooVM, -net user,smb=/sdc/owner/video/ \
        -m 16000m \
        -name "GentooVM" \
        "$@"


NOTE: This virtual machine runs fine from within any host graphical window manager when I use the following script to start it:
Code:
#/bin/sh
exec qemu-kvm \
        -cpu host -smp 8\
         -drive file=gentoo.img,if=virtio \
         -drive file=gentoosdab.img,if=virtio    \
         -net nic -net user,hostname=GentooVM, -net user,smb=/sdc/owner/video/ \
         -usbdevice tablet \
        -m 16000m \
        -vga vmware \
       -monitor stdio     \
        -name "GentooVM" \
        "$@"


Does anyone know how this can be done?


Last edited by nlsa8z6zoz7lyih3ap on Sat May 24, 2014 10:56 pm; edited 1 time in total
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1730

PostPosted: Thu May 22, 2014 6:02 pm    Post subject: Reply with quote

' -nographic` is everything you need to make it run as headless node. Why you think something is wrong? VM crashes? you face error message?
Maybe you just want to enable serial console removing # from line
#s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt100
in /etc/inittab on your guest system (a realy neat trick with headless node, qemu binds terminal to guest's serial port when you run it with -nographic)
or perhaps you have to find your vm with nmap and then connect with ssh.
Or not, since you seem to be running networking in user mode, your host system can't even see your guest. Use tap device to make your vm visible from host (and I think user mode ofers the lowest performance you can get from qemu networking)

Oh, one more thing that looks weird and might couse problems: you define virtual graphic card and request headless node. I'm not sure if those 2 can work with each other.
Back to top
View user's profile Send private message
nlsa8z6zoz7lyih3ap
Guru
Guru


Joined: 25 Sep 2007
Posts: 373
Location: Canada

PostPosted: Fri May 23, 2014 10:42 pm    Post subject: Reply with quote

Thanks for the reply. This sounds like it is trying to accomplish what I want.

Quote:
Maybe you just want to enable serial console removing # from line
#s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt100
in /etc/inittab on your guest system (a realy neat trick with headless node, qemu binds terminal to guest's serial port when you run it with -nographic)


However when I do so at the login text console, I get the error message

Quote:
kvm [job number] :vcpu0 unhandled rdmsr:0x0011021

Any ideas on how I should proceed?

I appreciate your suggestions. I found that getting qemu-kvm to work in graphics mode from with a window manager is quiet easy,
but that getting it to work from the login console is taking me to territory that I understand very poorly, so any suggestions are greatly appreciated.
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Sat May 24, 2014 1:59 am    Post subject: Reply with quote

nlsa8z6zoz7lyih3ap wrote:
..taking me to territory that I understand very poorly, so any suggestions are greatly appreciated.

I don't use qemu, but if I were in your position, I'd get in touch with their IRC channel. According to /topic #qemu on freenode, the official channel is on irc.oftc.net so I'd login there and /join #qemu. I'd also post to their mailing-list after browsing the wiki.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1730

PostPosted: Sat May 24, 2014 12:26 pm    Post subject: Reply with quote

I usualy run qemu from terminal emulater, so I switched to real tty to test it, and it still works just as well as in lxterm.

Anyway, I puleld (roughly) your params into my launcher, and I don't really see any problems there.

Quote:
./test.sh test vn0
starting machine test with command
qemu-kvm -m 1025 -drive file=starter.img -name GentooVM -cpu host -vga vmware -monitor stdio -nographic -net nic,macaddr=DE:AD:BE:EF:56:5A,vlan=1 -net tap,ifname=test-1,script=no,downscript=no,vlan=1
QEMU 1.5.3 monitor - type 'help' for more information
(qemu)

This is localhost.unknown_domain (Linux x86_64 3.10.25-aufs) 14:06:50 # yep. gotta fix this part. :oops:

localhost login: root (automatic login)

Last login: Sat May 24 14:03:51 CEST 2014 on ttyS0
localhost ~ # ls
unknown command: 'ls'
(qemu)

-monitor stdio screwes up serial console, but it's rather a minor issue

Things I leave not tested:
*virtio driver for disk (my test image doesn't support it, I want to run some performance tests first )
*usbdevice
Also, my launcher handles network differently.
Back to top
View user's profile Send private message
nlsa8z6zoz7lyih3ap
Guru
Guru


Joined: 25 Sep 2007
Posts: 373
Location: Canada

PostPosted: Sat May 24, 2014 10:55 pm    Post subject: Reply with quote

Thanks to everyone for their help.

It all works just fine now from the login text serial console using the script

Code:
#/bin/sh
exec qemu-kvm \
        -cpu host -smp 8\
        -nographic \
         -drive file=gentoo.img,if=virtio \
         -drive file=gentoosdab.img,if=virtio    \
         -net nic -net user,hostname=GentooVM, -net user,smb=/sdc/owner/video/ \
         -usbdevice tablet \
        -m 16000m \
        -vga vmware \
        -name "GentooVM" \ the boot had failed, and to give up
        "$@"


To run it from with a window manager I just remove the line "-nographic"

I am not at all sure that there was a problem anyway or if I gave up before the boot process had completed.
(Added in Edit: There was a problem:- Since the grub output does not show, the boot process hung without booting until I added a timeout to the grub.cfg)

I'll tell you why I did, so that someone else does not fall for the same mistake as myself.
(1) The error message kvm [job number] :vcpu0 unhandled rdmsr:0x0011021 led me (falsely to believe that the boot process had failed and to give up.)
Research using google leads me to believe that this message should be ignored.

(2) None of the normal boot messages from grub showed for me on the serial console. I therefore set the timeout in grub to 1 (it had been infinity before)
With the timeout set to 1, I saw the spurious error message, nothing from grub, none of the normal messages that I usually see while booting,
and then the login screen for the virtual machine.
After that everything worked flawlessly.

Thanks to everyone for their responses. That it worked for others is what encouraged me not to give up.

And of course
Quote:
-nographic` is everything you need to make it run as headless node. Why you think something is wrong? VM crashes? you face error message?
Maybe you just want to enable serial console removing # from line
#s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt100


was also crucial.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum