Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

[SOLVED] QEMU: working in guest system

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
9 posts • Page 1 of 1
Author
Message
umka69
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 124
Joined: Sun Mar 31, 2013 4:20 pm

[SOLVED] QEMU: working in guest system

  • Quote

Post by umka69 » Fri Sep 05, 2014 8:42 pm

Hi, company!
I've got working QEMU with KVM acceleration by the gentoo wiki manual.

Code: Select all

den ~ # cat GentooVM
#!/bin/sh
exec qemu-system-x86_64 -enable-kvm \
        -cpu host \
        -drive file=GentooVM.img,if=virtio \
        -net nic -net user,hostname=gentoovm \
        -m 256M \
        -monitor stdio \
        -name "Gentoo VM" \
        $@
The result of starting of the guest system seems good:

Code: Select all

den ~ #  ./GentooVM -boot d -cdrom install-amd64-minimal-20140828.iso
QEMU 2.0.0 monitor - type 'help' for more information
(qemu) VNC server running on `::1:5900'
How to connect by VNC to it?
I know nothing about it. Please help!
Last edited by umka69 on Mon Sep 08, 2014 11:59 am, edited 1 time in total.
Make a wish, this text is magic. :)
Top
eccerr0r
Watchman
Watchman
Posts: 10239
Joined: Thu Jul 01, 2004 6:51 pm
Location: almost Mile High in the USA
Contact:
Contact eccerr0r
Website

  • Quote

Post by eccerr0r » Fri Sep 05, 2014 9:28 pm

Looks like you have IPV6 enabled. ::1 is localhost like 127.0.0.1 is for ipv4.

vncviewer ::1:5900 (you will likely have to merge this separately, I don't recall if merging qemu also pulls in vncviewer.)

I don't know what security you set up however...

I've recently started using spice and libvirt for qemu. It makes setting up and accessing consoles of VMs almost too easy, and sound works too...
Top
vaxbrat
l33t
l33t
User avatar
Posts: 731
Joined: Wed Oct 05, 2005 3:59 am
Location: DC Burbs

seconded on libvirt

  • Quote

Post by vaxbrat » Sat Sep 06, 2014 2:31 am

I also use the virt-manager gui on top of that to make things really painless. Some grumble that it needlessly bloats the qemu command line, but gui's are good for handing over to the IT monkey who only knew Windows in a previous career. I do wish that someone would do a PyQT based gui instead of the mess that's currently under the hood.
Top
umka69
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 124
Joined: Sun Mar 31, 2013 4:20 pm

  • Quote

Post by umka69 » Sat Sep 06, 2014 7:51 pm

It is an output. Nothing happens.

Code: Select all

umka@den ~ $ vncviewer ::1:5900
TightVNC Viewer version 1.3.10

Usage: vncviewer [<OPTIONS>] [<HOST>][:<DISPLAY#>]
       vncviewer [<OPTIONS>] [<HOST>][::<PORT#>]
       vncviewer [<OPTIONS>] -listen [<DISPLAY#>]
       vncviewer -help

<OPTIONS> are standard Xt options, or:
        -via <GATEWAY>
        -shared (set by default)
        -noshared
        -viewonly
        -fullscreen
        -noraiseonbeep
        -passwd <PASSWD-FILENAME> (standard VNC authentication)
        -encodings <ENCODING-LIST> (e.g. "tight copyrect")
        -bgr233
        -owncmap
        -truecolour
        -depth <DEPTH>
        -compresslevel <COMPRESS-VALUE> (0..9: 0-fast, 9-best)
        -quality <JPEG-QUALITY-VALUE> (0..9: 0-low, 9-high)
        -nojpeg
        -nocursorshape
        -x11cursor
        -autopass

Option names may be abbreviated, e.g. -bgr instead of -bgr233.
See the manual page for more information.
Make a wish, this text is magic. :)
Top
miket
Guru
Guru
Posts: 513
Joined: Sat Apr 28, 2007 2:45 am
Location: Gainesville, FL, USA

Re: seconded on libvirt

  • Quote

Post by miket » Sat Sep 06, 2014 8:35 pm

vaxbrat wrote:I also use the virt-manager gui on top of that to make things really painless. Some grumble that it needlessly bloats the qemu command line, but gui's are good for handing over to the IT monkey who only knew Windows in a previous career. I do wish that someone would do a PyQT based gui instead of the mess that's currently under the hood.
Well, I do grumble that libvirt is too big and bloated, but there is another way. Check out AQemu (app-emulation/aqemu). Nice GUI configuration and startup using Qt; no libvirt baggage.
Top
umka69
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 124
Joined: Sun Mar 31, 2013 4:20 pm

  • Quote

Post by umka69 » Sat Sep 06, 2014 9:20 pm

Ok, i got your idea. Is there a way to use virtualization just with QEMU and KVM? I mean without aqemu, libvirt and so on.
My task is t to create something like LAMPs servers on etch virtual machine. I just need the way to install guest system.
Make a wish, this text is magic. :)
Top
SlashBeast
Retired Dev
Retired Dev
User avatar
Posts: 2922
Joined: Tue May 23, 2006 11:50 am
Contact:
Contact SlashBeast
Website

  • Quote

Post by SlashBeast » Sat Sep 06, 2014 10:07 pm

Hi,

I had the similar needs of use qemu/kvm but avoid all the libvirt and friends. You may want to check on this perly script I've wrote for this very purpose https://bitbucket.org/piotrkarbowski/vmninja
The readme should cover all your questions. It does also depends on qemu's bridge helper, so one need to configure /etc/qemu/bridge.conf first and provide it network access.

what it does is provide super-simple interface to qemu (start, stop, shutdown) and always spawn vnc + bind it to unix socket rather than TCP port. Later I either use ssvncviewer and connect to it locally or use socat as a unix-socket->ssh->tcp-port bridge.
Top
miket
Guru
Guru
Posts: 513
Joined: Sat Apr 28, 2007 2:45 am
Location: Gainesville, FL, USA

  • Quote

Post by miket » Sat Sep 06, 2014 11:15 pm

Actually, much of the time I don't use AQemu. I usually do it with bash scripts. Here is an example of one I use. It doesn't do the nice thing of reading the parameters from a file. There are some bash scripts I have that do use separate configuration files, but they're usually geared to some of my specialized setups.

This one starts a VM in a nice SDL window. Sorry, there's not much more documentation than the variable names. I edited out my own particular instance and path names. This VM instance starts without a bootloader, so here you can see an example of that.

Note that I have the VM images in a separate LVM partition mounted at /var/kvm. You can suit yourself.

Code: Select all

#!/bin/bash
# Start [fill in your host name here] on KVM

SERVER_NAME=[fill in a name]
#PIDFILE=/var/run/kvm/if_I_want_a_pid_file.pid
SMP='cores=2'
KERNEL=/var/kvm/myhost/boot/vmlinuz-gentoo-virtio
KERNEL_PARMS='root=/dev/vda5 fbcon=scrollback:128k video=vesafb vga=0x317 res=1280x1024 clock=pit'

NIC_MODEL=virtio
TAPNAME=tap_myhost
MACADDR=12:34:56:78:90:12

NET=( "tap,model=virtio,macaddr=${MACADDR},helper=/usr/libexec/qemu-bridge-helper" )

DRIVE=( 'if=virtio,file=/var/kvm/myhost/main.img' )

VGA=cirrus
SOUNDHW=hda
QEMU_AUDIO_DRV=alsa
#VNC=:1

#USBDEVICE=tablet

#CONSOLE='-curses'
#SCREEN_SESSION=vm_console
MONITOR=telnet::60001,server,nowait
ECHO_COMMAND=1


# You should not need to adjust these two:

KVM_EXEC='/usr/bin/qemu-system-x86_64 -enable-kvm'
SCREEN_EXEC=/usr/bin/screen

#
## END OF CONFIGURATION ##
#



NIC_MODEL="${NIC_MODEL:-virtio}"

CMD="$KVM_EXEC -name $SERVER_NAME"
for i in $(seq 0 $((${#DRIVE[@]} - 1)))
do
        CMD="$CMD -drive ${DRIVE[$i]}"
done

for i in $(seq 0 $((${#NET[@]} - 1)))
do
        setup="${NET[$i]}"
        hw_side=nic,vlan=$i
        sw_side="${setup%%,*},vlan=$i"
        setup="${setup#*,}"
        while [ -n "$setup" ]; do
                pair="${setup%%,*}"
                setup="${setup:${#pair} + 1}"
                var="${pair%%=*}"
                if [ 'macaddr' = "$var" -o 'model' = "$var" \
                        -o 'name' = "$var" -o 'addr' = "$var" ]; then
                        hw_side="$hw_side,$pair"
                else
                        sw_side="$sw_side,$pair"
                fi
        done
        CMD="$CMD -net $hw_side -net $sw_side"
done

if [ -n "$KERNEL" ]; then
        CMD="$CMD -kernel $KERNEL"
        if [ -n "$KERNEL_PARMS" ]; then
                CMD="$CMD -append "'\"'${KERNEL_PARMS}'\"'
        fi
fi

if [ -n "$PIDFILE" ]; then
        CMD="$CMD -pidfile $PIDFILE"
        piddir=`dirname "$PIDFILE"`
        if [ ! -d "$piddir" ]; then
                mkdir -p "$piddir"
        fi
fi

if [ -n "$SMP" ]; then
        CMD="$CMD -smp $SMP"
fi

if [ -n "$SOUNDHW" ]; then
        CMD="$CMD -soundhw "'\"'${SOUNDHW}'\"'
fi

if [ -n "$QEMU_AUDIO_DRV" ]; then
        # Grumble, grumble:  they need this passed in the environment
        CMD="QEMU_AUDIO_DRV='$QEMU_AUDIO_DRV' $CMD"
fi

if [ -n "$VGA" ]; then
        CMD="$CMD -vga $VGA"
fi

if [ -n "$CONSOLE" ]; then
        CMD="$CMD $CONSOLE"
fi

if [ -n "$MONITOR" ]; then
        CMD="$CMD -monitor $MONITOR"
fi

if [ -n "$VNC" ]; then
        CMD="$CMD -vnc $VNC"
fi

if [ -n "$USBDEVICE" ]; then
        CMD="$CMD -usbdevice $USBDEVICE"
fi

if [ -n "$SCREEN_SESSION" ]; then
        CMD="$SCREEN_EXEC -d -m -S "$SCREEN_SESSION" $CMD"
fi



if [ "$ECHO_COMMAND" -ne 0 ]; then
        echo $CMD
fi

eval $(eval "echo $CMD")
I hope you can get some good stuff out of it.
Top
szatox
Advocate
Advocate
Posts: 3858
Joined: Tue Aug 27, 2013 12:35 pm

  • Quote

Post by szatox » Sun Sep 07, 2014 8:36 pm

It seems that you can change a bunch of things telling qemu to replace some hardware it emulates.
Like, you can order an audio device. You can also order a video device you can connect to with spice or with vnc.
Default one doesn't support this. Nobody tells you not to change defaults though :D
Top
Post Reply

9 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic