Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
QEMU is very slow
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
The_Document
Apprentice
Apprentice


Joined: 03 Feb 2018
Posts: 275

PostPosted: Sat Feb 24, 2018 7:05 am    Post subject: QEMU is very slow Reply with quote

I have installed QEMU with Aqemu and after experiencing its horrible slowness I thought I would try virtualbox. To my surprise virtualbox is way faster, note I have kernel setup properly with kv-amd loaded along with virtualization options enabled in kernel. WHAT can possibly be causing qemu to be so slow, VB is even faster in graphics performance than QEMU and QEMU is supposed to be faster than VB so there is without a doubt a misconfiguration here. What should I do to correct this?
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Feb 24, 2018 8:53 am    Post subject: Reply with quote

Did you forget option '-enable-kvm'?
Back to top
View user's profile Send private message
The_Document
Apprentice
Apprentice


Joined: 03 Feb 2018
Posts: 275

PostPosted: Sat Feb 24, 2018 1:45 pm    Post subject: Reply with quote

mike155 wrote:
Did you forget option '-enable-kvm'?


For which package?
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3135

PostPosted: Sat Feb 24, 2018 1:51 pm    Post subject: Reply with quote

Not for a package. For invocation, when you're tarting qemu.
How you start it? What is the full command line? What emulated hardware you use?
Back to top
View user's profile Send private message
The_Document
Apprentice
Apprentice


Joined: 03 Feb 2018
Posts: 275

PostPosted: Sat Feb 24, 2018 1:59 pm    Post subject: Reply with quote

szatox wrote:
Not for a package. For invocation, when you're tarting qemu.
How you start it? What is the full command line? What emulated hardware you use?


-enable-kvm wasen't included and also graphics options don't seem to be optimal here either (I don't know what is optimal) this is what aqemu uses:

Code:
/usr/bin/qemu-system-x86_64 \
    -monitor stdio \
    -soundhw hda \
    -machine accel=kvm \
    -m 1024 \
    -cdrom /home/zakhar/Documents/windows-install.iso \
    -hda /home/zakhar/.aqemu/Windows_7_x64_HDA.img \
    -boot once=d,menu=off \
    -net none \
    -rtc base=localtime \
    -name "Windows 7 x64"


I tried:

Code:
/usr/bin/qemu-system-x86_64 \
    -monitor stdio \
    -soundhw hda \
    -machine accel=kvm \
    -m 1024 \
    -cdrom /home/zakhar/Documents/windows-install.iso \
    -hda /home/zakhar/.aqemu/Windows_7_x64_HDA.img \
    -boot once=d,menu=off \
    -net none \
    -rtc base=localtime \
    -name "Windows 7 x64"
    -enable-kvm  <-----------------


here is lsmod to prove kvm-amd is loaded:
https://paste.pound-python.org/show/5ZSOQumzdVcEZs1IRFlJ/


but still SLOOW how to correct this?
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3135

PostPosted: Sat Feb 24, 2018 7:00 pm    Post subject: Reply with quote

Well, at this point you should have full performance your CPU offers (though some instruction sets won't be available inside your VM -> you have to enable them explicitly).
Also, you seem to run it with SDL graphic, which indeed is not the best one performance-wise. Consider switching graphics from default cirrus to qxl and replacing SDL console with SPICE.
Bonus point, not related to cpu or graphic performance, but still a thing you may want to improve: virtio does much better job than emulated IDE pulled in by the ancient syntax of "-hda <device image>"
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Sat Feb 24, 2018 7:17 pm    Post subject: Reply with quote

https://www.linux-kvm.org/page/Tuning_KVM
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Feb 24, 2018 7:22 pm    Post subject: Reply with quote

1) Is it just a typo? Or did you forget a backslash at the end of the line before '-enable-kvm'?
Code:
[...]
-boot once=d,menu=off \
-net none \
-rtc base=localtime \
-name "Windows 7 x64"       <-- missing backslash?
-enable-kvm

2) You should check in the QEMU Monitor that kvm is enabled: what is the output of 'info kvm'?

3) What exactly do you mean by 'slow'? Windows itself? A program you start? Disk I/O? Graphics?
Back to top
View user's profile Send private message
The_Document
Apprentice
Apprentice


Joined: 03 Feb 2018
Posts: 275

PostPosted: Sat Feb 24, 2018 8:05 pm    Post subject: Reply with quote

mike155 wrote:
1) Is it just a typo? Or did you forget a backslash at the end of the line before '-enable-kvm'?
Code:
[...]
-boot once=d,menu=off \
-net none \
-rtc base=localtime \
-name "Windows 7 x64"       <-- missing backslash?
-enable-kvm

2) You should check in the QEMU Monitor that kvm is enabled: what is the output of 'info kvm'?

3) What exactly do you mean by 'slow'? Windows itself? A program you start? Disk I/O? Graphics?


The issue with slowness would be booting from windows 10 installation iso, virtualbox starts installation process waaaayy sooner than qemu, also virtual box boots windows wayyy faster than qemu does.

Out put from qemu montior after running info kvm:
Code:
 
kvm support: enabled
(qemu)


Here is new qemu command line:

Code:
/usr/bin/qemu-system-x86_64 \
    -monitor stdio \
    -smp 1,threads=1 \
    -soundhw hda \
    -vga qxl \
    -machine accel=kvm \
    -m 1024 \
    -cdrom /home/zakhar/Documents/windows-install.iso \
    -drive file="/home/zakhar/.aqemu/Windows_7_x64_HDA.img",if=virtio \
    -boot once=d,menu=off \
    -net none \
    -rtc base=localtime \
    -name "Windows 7 x64" \
    -enable-kvm


Very slow and weird I don't know how to fix this issue, qemu is nicer to use since it scales the screen more nativly than VB does. I sincerely believe this is an issue with appropriate cpu flags not being issued. What should I do about the slowness issue qemu has?
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Feb 24, 2018 8:27 pm    Post subject: Reply with quote

KVM seems to work....

Two more things:

4) Add parameter '-cpu host'.

5) Look at Arch Wiki: QEMU / Troubleshooting / Virtual machine runs too slowly
Back to top
View user's profile Send private message
The_Document
Apprentice
Apprentice


Joined: 03 Feb 2018
Posts: 275

PostPosted: Sat Feb 24, 2018 8:36 pm    Post subject: Reply with quote

mike155 wrote:
KVM seems to work....

Two more things:

4) Add parameter '-cpu host'.

5) Look at Arch Wiki: QEMU / Troubleshooting / Virtual machine runs too slowly


It was of no help I tried this:

Code:
/usr/bin/qemu-system-x86_64 \
    -monitor stdio \
    -soundhw hda \
    -vga qxl \
    -machine accel=kvm,kvm_shadow_mem=1843200 \
    -m 1024 \
    -no-fd-bootchk \
    -cdrom /home/zakhar/Documents/windows-install.iso \
    -drive file="/home/zakhar/.aqemu/Windows_7_x64_HDA.img",if=virtio \
    -boot once=d,menu=off \
    -net none \
    -rtc base=localtime \
    -name "Windows 7 x64" \
    -enable-kvm \
    -cpu host


and this

Code:

/usr/bin/qemu-system-x86_64 \
    -monitor stdio \
    -soundhw hda \
    -vga qxl \
    -machine accel=kvm,kvm_shadow_mem=1843200 \
    -m 1024 \
    -no-fd-bootchk \
    -cdrom /home/zakhar/Documents/windows-install.iso \
    -drive file="/home/zakhar/.aqemu/Windows_7_x64_HDA.img",if=virtio \
    -boot once=d,menu=off \
    -net none \
    -rtc base=localtime \
    -name "Windows 7 x64" \
    -enable-kvm \
    -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time \
    -machine type=pc


Still too slow to use.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3135

PostPosted: Sat Feb 24, 2018 8:41 pm    Post subject: Reply with quote

I've just noticed you're trying to run windows there, on a VM with barely 1GB RAM.
Are you sure your VB doesn't work faster simply by using more resources?
Hell, does windows even booth with 1GB RAM those days?
Back to top
View user's profile Send private message
The_Document
Apprentice
Apprentice


Joined: 03 Feb 2018
Posts: 275

PostPosted: Sat Feb 24, 2018 8:47 pm    Post subject: Reply with quote

szatox wrote:
I've just noticed you're trying to run windows there, on a VM with barely 1GB RAM.
Are you sure your VB doesn't work faster simply by using more resources?
Hell, does windows even booth with 1GB RAM those days?


Gave VM 3GBs RAM was of no help. This issue is leading me to belive I need wine, but it shouldn't be unresolvable there should be something incorrect about this. Here are use flags for qemu:

https://paste.pound-python.org/show/md0bsm97FecuGFvbFbqL/
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Feb 24, 2018 9:09 pm    Post subject: Reply with quote

6) What happens if you remove parameter ',kvm_shadow_mem=1843200'? I've never seen that parameter before. I don't think it's wrong - but just to be sure...

7) Your image files are in your home directory. There's nothing wrong with that. But: is this a hard disk or a ssd? On my computer, /home is a NFS mount and that would give terrible results...

8 ) What does 'top' on you host system show when you start QEMU? 100% CPU load all the time?
Back to top
View user's profile Send private message
The_Document
Apprentice
Apprentice


Joined: 03 Feb 2018
Posts: 275

PostPosted: Sat Feb 24, 2018 11:09 pm    Post subject: Reply with quote

mike155 wrote:
6) What happens if you remove parameter ',kvm_shadow_mem=1843200'? I've never seen that parameter before. I don't think it's wrong - but just to be sure...

7) Your image files are in your home directory. There's nothing wrong with that. But: is this a hard disk or a ssd? On my computer, /home is a NFS mount and that would give terrible results...

8 ) What does 'top' on you host system show when you start QEMU? 100% CPU load all the time?


6. I tried without kvm_shadow many times, still slow

7. Im on an SSD

8. Most of the time not 1 core is utilized to its max, but not with VB, many cores are used beyong 75% with VB and it starts installing windows much faster than with qemu.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54236
Location: 56N 3W

PostPosted: Sat Feb 24, 2018 11:19 pm    Post subject: Reply with quote

The_Document,

Code:
-smp 1,threads=1
says to allocate a singe core anh single thread to the guest.
Is that the way you run VBox too?
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Feb 24, 2018 11:19 pm    Post subject: Reply with quote

Quote:
but not with VB, many cores are used beyong 75% with VB

... so what about QEMU parameters '-smp 2' or even '-smp 4' ?
Back to top
View user's profile Send private message
The_Document
Apprentice
Apprentice


Joined: 03 Feb 2018
Posts: 275

PostPosted: Sat Feb 24, 2018 11:36 pm    Post subject: Reply with quote

NeddySeagoon wrote:
The_Document,

Code:
-smp 1,threads=1
says to allocate a singe core anh single thread to the guest.
Is that the way you run VBox too?


No I didn't need to configure ANYTHING cpu wise with VB. Then I learned VB has processor settings too and VB is way faster than qemu on 1 core, so I increased the guest cores to 4 and it was EVEN FASTER. I ran qemu with:

Code:
/usr/bin/qemu-system-x86_64 \
    -monitor stdio \
    -soundhw hda \
    -vga qxl \
    -machine accel=kvm,kvm_shadow_mem=1843200 \
    -m 3072 \
    -no-fd-bootchk \
    -cdrom /home/zakhar/Documents/windows-install.iso \
    -drive file="/home/zakhar/.aqemu/Windows_7_x64_HDA.img",if=virtio \
    -boot once=d,menu=off \
    -net none \
    -rtc base=localtime \
    -name "Windows 7 x64" \
    -enable-kvm \
    -cpu host \
    -smp 4,threads=1


But qemu is still way too slow. Because my AMD cpu has no support for hyperthreading which is an Intel product, it can only support 1 thread per core . Really its real name is SMT but raising threads above 1 gives:
Code:
(qemu) qemu-system-x86_64: AMD CPU doesn't support hyperthreading. Please configure -smp options properly.

so I leave it 1 thread per core as it normally should be, at any rate its still SLOW and did not speed up. I would be VERY happy with VB but its main gripe would be its resolution scaling, which is abominable when compared to qemu, I should mention qemu has excellent screen scaling and if its full screen its virtually impossible to distinguish whether the OS is on a VM or not. Qemu is still very slooow.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia 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