FedoraForum.org - Fedora Support Forums and Community
Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2017
    Location
    toronto
    Posts
    35

    Who is using qemu/kvm for desktop virtualization?

    I noticed that there is not much conversation in the Fedora forums about qemu/kvm in the way of desktop emulation, so I figured I'd start a thread where we could exchange info, configs, and tweaks.


    Here's mine to start us off:

    Computer: HP ProDesk G3 - i7-7700, 8G ram, 250G SSD
    BIOS: VTd/VTx enabled
    Kernel Parameters: intel_iommu=on
    Host OS: F28/64, wm: awesome
    Guest OS: F28/64, wm: awesome


    Code:
    #!/bin/sh
    
    # Benchmarks:
    # glxgears: 340-370 fps
    # boot + shutdown: 10 secs
    
    time qemu-system-x86_64 \
    \
    -enable-kvm -cpu host \
    -drive format=raw,file=/home/user/Downloads/f28-64.img,if=virtio,aio=threads,cache.direct=on \
    -m 4G -smp 8,sockets=1,cores=8,threads=1 \
    -vga virtio -display gtk,gl=on \
    -machine accel=kvm,type=q35,kernel-irqchip=split \
    -device intel-iommu,intremap=on,device-iotlb=on,caching-mode=on \
    -fsdev local,security_model=passthrough,id=fsdev0,path=/home/user/share \
    -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare \
    -netdev user,id=vmnic -device virtio-net,netdev=vmnic \
    -soundhw hda -full-screen \
    $@
    
    # Run in snapshot mode, add: "--snapshot" to the command parameters.
    The bizarre thing is that the host seems to render glxgears at 4x less fps than the guest (60 fps).


    Anyone care to share or comment? I'm new to virtualization and could use some ideas.

  2. #2
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    2,899

    Re: Who is using qemu/kvm for desktop virtualization?

    The bizarre thing is that the host seems to render glxgears at 4x less fps than the guest (60 fps).
    It has probably synced to the display frame rate - I think glxgears does that by default.

    User error. Please replace user and try again

  3. #3
    Join Date
    Jul 2017
    Location
    toronto
    Posts
    35

    Re: Who is using qemu/kvm for desktop virtualization?

    Quote Originally Posted by ocratato
    It has probably synced to the display frame rate - I think glxgears does that by default.
    That crossed my mind as well. In any event, the gears seem to have some tearing in the vm. Also, when 3d acceleration is added certain things seem to have really big lag, such as selecting menu entries, so I had to shut that acceleration off.

    I added huge pages support. Here is the new config:
    Code:
    # Tells qemu that we'll be using pulse audio. Put in your ~/.bashrc file:
    export QEMU_AUDIO_DRV=pa
    
    time qemu-system-x86_64 \
    -enable-kvm -cpu host \
    -m 2048M -mem-prealloc -mem-path /dev/hugepages/f28 \
    -drive format=raw,file=/home/user/Downloads/f28-64.img,if=virtio,aio=native,cache.direct=on \
    -smp 8,sockets=1,cores=8,threads=1 \
    -device virtio-vga,virgl=on \
    -device virtio-serial-pci \
    -cdrom /home/user/Downloads/f28-dvd.iso -boot c \
    -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \
    -chardev spicevmc,id=spicechannel0,name=vdagent \
    -spice unix,addr=/tmp/vm_spice.socket,disable-ticketing \
    -machine accel=kvm,type=q35,kernel-irqchip=split \
    -device intel-iommu,intremap=on,caching-mode=on \
    -fsdev local,security_model=passthrough,id=fsdev0,path=/home/user/share \
    -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare \
    -balloon virtio \
    -soundhw hda \
    -sandbox on -daemonize $@
    
    # View the WM with:
    spicy --uri="spice+unix:///tmp/vm_spice.socket"

    The video is set up differently in the config. It seems that when I add the 'gl=on' to 'spice' as such:
    Code:
    -spice gl=on,unix,addr=/tmp/vm_spice.socket,disable-ticketing \
    ... that spice just opens to a blank screen. No error, but nothing displayed.

    I'd really like to get it working if anyone has ideas.

  4. #4
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    2,899

    Re: Who is using qemu/kvm for desktop virtualization?

    A question if I may:

    How are you intending to do backup and restore ?

    (I am contemplating setting up a test environment: I will set up a VM and then save it. Then each time I want to run a test I will load that copy, run the tests, and then abandon it. There will be quite a few of these images so they will need to be stored on an external drive.)

    User error. Please replace user and try again

  5. #5
    Join Date
    Jul 2017
    Location
    toronto
    Posts
    35

    Re: Who is using qemu/kvm for desktop virtualization?

    Quote Originally Posted by ocratato
    A question if I may:

    How are you intending to do backup and restore ?

    (I am contemplating setting up a test environment: I will set up a VM and then save it. Then each time I want to run a test I will load that copy, run the tests, and then abandon it. There will be quite a few of these images so they will need to be stored on an external drive.)
    Perhaps the 'qcow' format might be more suited for backup. You could take snapshots and save them or toss them. The saved copy would take much less space as it just saves the difference, I believe.

    I use the raw format as it's faster. With raw you can append '--snapshot' to the script, and it will not touch the original, nor will it save it. After, when you are done, you just toss it; like an Apple product. You could also just make a backup copy of the entire image file if you have the space. My image is about 20G, and I always have an extra copy; I've already used it a couple of times, too!

    virt-manager might be a decent gui program to get the job done as well. Or, if you run Gnome, then you could use 'boxes.'

  6. #6
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    2,899

    Re: Who is using qemu/kvm for desktop virtualization?

    Thanks.

    It seems I will have quite a few options to investigate.

    User error. Please replace user and try again

  7. #7
    Join Date
    Jul 2017
    Location
    toronto
    Posts
    35

    Re: Who is using qemu/kvm for desktop virtualization?

    Quote Originally Posted by ocratato
    Thanks.

    It seems I will have quite a few options to investigate.
    Yes, lots.

    Here is an excellent guide to start you off with qemu. It's Arch Linux, but the info applies to Fedora as well.

  8. #8
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    2,899

    Re: Who is using qemu/kvm for desktop virtualization?

    Quote Originally Posted by bedtime
    Yes, lots.

    Here is an excellent guide to start you off with qemu. It's Arch Linux, but the info applies to Fedora as well.
    Thanks, added to my bookmarks.

    I just wish I could dive in straight away, but I am too deep into my project at the moment to change course.
    I note that there is an "immutable" option - just what I need for doing repeatable testing.

    User error. Please replace user and try again

  9. #9
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    2,899

    Re: Who is using qemu/kvm for desktop virtualization?

    I am curious about how the mouse interacts with a VM.

    I understand how it works "normally", but I have some things in mind which are a bit different.

    The test programs I am intending to put into a VM are GUIs, and during the tests they grab the mouse and move it around to the various widgets.
    My question is: Can I have a separate mouse for the VM to use - and if so how do I use it from the host if I need to. Alternatively, what would happen if there was more than one VM running these tests ?

    User error. Please replace user and try again

  10. #10
    Join Date
    Jul 2017
    Location
    toronto
    Posts
    35

    Re: Who is using qemu/kvm for desktop virtualization?

    Quote Originally Posted by ocratato
    I am curious about how the mouse interacts with a VM.

    I understand how it works "normally", but I have some things in mind which are a bit different.

    The test programs I am intending to put into a VM are GUIs, and during the tests they grab the mouse and move it around to the various widgets.
    My question is: Can I have a separate mouse for the VM to use - and if so how do I use it from the host if I need to.
    Generally, the host and vm take turns using the mouse. Depending on what display driver you choose to use, there are shortcuts that can pass the mouse back to the host.

    If you wanted to use two mice, it could be done through the use of a pci passthrough (but it can get complicated, and strange stuff can happen if you're not careful):
    Here, if you're using virt-manager.
    Here, if you're using the qemu command by itself.

    Alternatively, what would happen if there was more than one VM running these tests ?
    If the VMs which you are running are all different, you'll be fine, so long as you have the memory to support it.

    If you want to run multiple instances of a particular VM, and if you are using a .raw image to run them all (I don't know about .qcow), you MUST make sure to run them with the parameter '--snapshot', else they will corrupt the image's filesystem as they all attempt to make changes to the same file image at the same time; and you won't be able to boot it. This has happened to me a few times. I was able to recover the image every time, but it wasn't particularly fun.

    In any event, make a backup of the image to be safe.

Similar Threads

  1. Replies: 0
    Last Post: 3rd May 2013, 03:55 PM
  2. Virtualization using Qemu
    By dsmyth in forum Guides & Solutions (Not For Questions)
    Replies: 0
    Last Post: 14th February 2010, 06:23 PM
  3. virtualization networking dhcp options kvm/qemu fc12
    By dug_hd_RK in forum Servers & Networking
    Replies: 0
    Last Post: 1st December 2009, 04:04 PM
  4. Virtualization - am I creating a kvm guest or qemu
    By bshack in forum Using Fedora
    Replies: 7
    Last Post: 23rd September 2009, 01:56 AM
  5. Fedora 10, Virtualization and the network (KVM qemu)
    By garmdba in forum Servers & Networking
    Replies: 7
    Last Post: 1st September 2009, 04:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •