Difference between revisions of "Talk:QEMU"

From ArchWiki
Jump to: navigation, search
(Remove edit log.)
(Using existing partition on GPT disk (with linear RAID or otherwise): new section)
 
(80 intermediate revisions by 25 users not shown)
Line 4: Line 4:
 
--[[User:Synchronicity|Synchronicity]] ([[User talk:Synchronicity|talk]]) 19:23, 9 May 2012 (UTC)
 
--[[User:Synchronicity|Synchronicity]] ([[User talk:Synchronicity|talk]]) 19:23, 9 May 2012 (UTC)
  
== thoughts / suggestions on networking nitty gritty section ==
+
:What about Windows installations then? [[User:Nesk|Nesk]] ([[User talk:Nesk|talk]]) 09:18, 4 October 2016 (UTC)
  
I followed the Beginner's Guide to installing Arch and setting up {{ic|/etc/rc.conf}}. I have also installed {{pkg|dnsmasq}}. When following the QEMU/KVM how-to I was unable to get my bridge interface to see the DHCP server of my modem until I amended my {{ic|/etc/rc.conf}} to include and bring up the loopback interface i.e.
+
== Creating bridge manually ==
{{bc|<nowiki>
+
lo="lo up"
+
eth0="eth0 up"
+
br0="dhcp"
+
INTERFACES=(lo eth0 br0)
+
gateway="default gw 192.168.0.1"
+
ROUTES=(gateway)
+
</nowiki>}}
+
  
As this is not part of the beginners {{ic|/etc/rc.conf}} it might help others that have got stuck with this part to read this and maybe considered, if correct, a useful addition to the how-to. It would be good to get confirmation from those-that-know if this is the best foot forward, so to speak.
+
I really don't know what to do with this section. I'd say it has been superseded by [[QEMU#Creating bridge using qemu-bridge-helper]] (available since qemu-1.1, we now have qemu-1.5) - or is someone still using this method? Perhaps link to https://en.wikibooks.org/wiki/QEMU/Networking#TAP_interfaces or http://wiki.qemu.org/Documentation/Networking/NAT is sufficient. What do you think? -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 20:42, 22 July 2013 (UTC)
  
Ed 17/05/10
+
:Actually, I've become a happy user of this method. I've written some scripts to easily create bridge interface, TAP interface, and combined with Xyne's [http://xyne.archlinux.ca/notes/network/dhcp_with_dns.html excellent scripts] to set up NAT and launch DHCP server, I have complete solution to easily manage multiple VMs on one (or even more) bridge.
 +
:My scripts are available on github: [https://github.com/lahwaacz/archlinux-dotfiles/blob/master/Scripts/qemu-launcher.sh], [https://github.com/lahwaacz/archlinux-dotfiles/blob/master/Scripts/qemu-tap-helper.sh], [https://github.com/lahwaacz/archlinux-dotfiles/blob/master/Scripts/qemu-mac-hasher.py] but I won't probably integrate them into the wiki, I'l just leave a note when I do some more testing.
 +
:The thing is, what to do with the current content? Personally I think that links to [https://en.wikibooks.org/wiki/QEMU/Networking#TAP_interfaces], [http://wiki.qemu.org/Documentation/Networking/NAT] and my scripts are sufficient (of course others are welcome). I'd also leave the note at the end to ''disable the firewall on the bridge'', I find it extremely useful.
 +
:-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 18:24, 5 September 2013 (UTC)
  
The networking configuration here relies on ifconfig, which is deprecated. It should be changes to use netcfg:
+
:I would not remove something that works still heh.--[[User:Webdawg|Webdawg]] ([[User talk:Webdawg|talk]]) 07:31, 17 July 2016 (UTC)
  
https://wiki.archlinux.org/index.php/Netcfg#Configuring_a_bridge_for_use_with_virtual_machines_.28VMs.29
+
== Starting QEMU virtual machines with systemd ==
 +
The custom systemd service script does not work. It always fails with {{ic|Failed at step EXEC spawning /usr/bin/qemu-{type}: No such file or directory}}. To Fix this modify the ExecStart command {{bc|1=ExecStart=/usr/bin/sh -c "/usr/bin/qemu-${type} -name %i -nographic ${args}"}}
 +
Also {{ic|echo 'system_powerdown' &#124; nc localhost 7101}} kills the VM immediatly. To fix this change the stop script. It simply checks each second if the main process is still running. {{bc|1=ExecStop=/usr/bin/sh -c "${haltcmd} && while [[ $(pidof qemu-${type} | grep $MAINPID) ]]; do sleep 1; done"}}
 +
{{ic|gnu-netcat}} does not work to connect to the monitor. You need to use {{ic|openbsd-netcat}}. -- [[User:Ant32|Ant32]] ([[User talk:Ant32|talk]]) 17:48, 5 September 2013 (UTC)
  
(The default configuration of netcfg works)
+
:The first problem related to starting the service seems rather strange - didn't you have typo error in your local {{ic|qemu@.service}} file (missing the dollar sign {{ic|$}} in {{ic|${type} }})?
 +
:The second problem is valid, systemd kills the main process when the ExecStop command exits (see {{ic|systemd.service(5)}}). If your workaround really works, it could be added to the wiki with a proper description.
 +
:-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 21:17, 7 September 2013 (UTC)
  
[[User:Zealjagannatha|Zealjagannatha]] ([[User talk:Zealjagannatha|talk]]) 01:20, 12 July 2012 (UTC)
+
::Relevant thread on systemd-devel mailing list: [http://lists.freedesktop.org/archives/systemd-devel/2013-September/012982.html] -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 00:00, 15 September 2013 (UTC)
  
== VDE networking ==
+
== Kexec Hackery When Using a Real Partition ==
  
The instructions provided for VDE networking did not work. Instead I did the following which ''did'' work:
+
After banging my head against a wall long enough and figuring out what {{ic|-kernel}} and {{ic|-initrd}} were really calling, I put a note above the appropriate section and mentioned two ways to use the guest's images.  (Otherwise, you'll have to worry if the host and guest images match.)  The first -- mount the partition(s) -- is more appropriate for "low-volume-handling" of VMs.  The second -- using kexec -- becomes more useful when you're juggling more than a few VMs.
  
{{bc|
+
I'm only mentioning this hack because (as of now) [[Kexec]] only mentions use for rebooting into another kernel, not switching out the kernel before the system is even up.  This hack comes from from https://digitalocean.uservoice.com/forums/136585-digitalocean/suggestions/2814988-give-option-to-use-the-droplet-s-own-bootloader- which has two suggestions.  The most recent, using systemd units by jkuan, doesn't work because jkuan tried to copy a {{ic|.target}} file into a {{ic|.service}} file and systemd wants {{ic|ExecStart}} in a {{ic|.service}} file.  The second one, replacing {{ic|/usr/bin/init}} by andrew_sparks, works for me on my Arch instance at DigitalOcean.
vde_switch -daemon
+
  
slirpvde --dhcp --daemon
+
Adaptation from said post:
}}
+
  
Then to start the VM with a connection to the network of the host:
+
# pacman -S kexec-tools
 +
# pacman -R systemd-sysvcompat
  
{{bc|1=
+
{{hc|1=/tmp/init|2=
kvm -net nic,macaddr=52:54:00:00:EE:03 -net vde whatever.qcow
+
#!/bin/sh
 +
 
 +
kexec --load /boot/vmlinuz-linux --initrd=/boot/initramfs-linux.img --append="root=/dev/sda init=/usr/lib/systemd/systemd" &&
 +
mount -o ro,remount / && kexec -e
 +
exec /usr/lib/systemd/systemd
 
}}
 
}}
  
The above method is also less invasive. Any support/objections to replacing the VDE networking instructions in the article with these? If the current instructions bring attention to features that the above method does not, how can they integrated?
+
# cd [/path/to/vm]/usr/bin
--[[User:AndreasBWagner|AndreasBWagner]] 22:02, 17 April 2011 (EDT)
+
# mv init init.dist
 +
# cp /tmp/init ./
 +
# chmod 755 init
 +
 
 +
I'm leaving this on the Talk page as I haven't even tried it out in QEMU myself.  Also, my eyes are about ready to pop out of my head, so I'm barring myself from figuring out the appropriate way to edit this in for the time being. [[User:BrainwreckedTech|BrainwreckedTech]] ([[User talk:BrainwreckedTech|talk]]) 21:23, 14 January 2014 (UTC)
 +
 
 +
== Replace -net with -netdev ==
 +
 
 +
The {{ic|-net}} option is deprecated and replaced by {{ic|-netdev}}. I think this article should be modified to reflect that.
 +
http://en.wikibooks.org/wiki/QEMU/Networking#cite_ref-1
 +
[[User:Axper|axper]] ([[User talk:Axper|talk]]) 18:12, 1 July 2014 (UTC)
 +
 
 +
== I'm rewriting the network section ==
 +
 
 +
https://wiki.archlinux.org/index.php/User:Axper/sandbox/qemu_network
 +
[[User:Axper|axper]] ([[User talk:Axper|talk]]) 20:07, 2 July 2014 (UTC)
 +
 
 +
::I think a lot of networking topics could be moved outside of the QEMU page. Many virtualization applications share the same basic principles with regards to networking, such as tun/tap creating, bridges, VDE, etc. There are a few networking schemes that are QEMU-specific, for example multicast sockets and {{ic|-net socket,...}}, and these could be mentioned on the QEMU page, although these are less reliable and rarely used in comparison to tap devices. We should also of course note the QEMU-specific command line options in the QEMU page, but for general concepts and commands independent of the virtualization applications, they could go on pages dedicated to the task. The best example is VDE, which is in no way limited to QEMU, yet it still doesn't have its own page on the Arch wiki.
 +
 
 +
::Incidentally, I'm planning on rewriting [[User Mode Linux]] (yes, I promise I will get around to it), which happens to share the "tap with bridge" and VDE concepts with QEMU. It would be nice if I could link to pages dedicated to those topics and only write UML-specific commands in the page, instead of duplicating a bunch of general information. I'm not familiar very familiar with Xen or LXC or Docker or the like, but I would suspect that they also share some networking infrastructure. We could possibly even create a category just for these types of pages, for example "Virtual Networking" or "Advanced Networking". [[User:EscapedNull|EscapedNull]] ([[User talk:EscapedNull|talk]]) 13:32, 19 February 2015 (UTC)
 +
 
 +
== -enable-kvm vs -machine type=pc,accel=kvm ==
 +
 
 +
The section [[QEMU#Enabling_KVM]] recommends {{ic|-enable-kvm}}, while [[QEMU#Virtual_machine_runs_too_slowly]] recommends {{ic|1=-machine type=pc,accel=kvm}}. Is there any difference between the two? Is one preferred over the other? Should we just link to the former section from the latter (and possibly move both command line switches to the same section)? [[User:EscapedNull|EscapedNull]] ([[User talk:EscapedNull|talk]]) 17:23, 18 January 2015 (UTC)
 +
 
 +
== virtio-gpu ==
 +
 
 +
Any tutorial on using the new virtio-gpu which is introduced in qemu-2.4 and kernel 4.2? [[User:Adam900710|Adam900710]] ([[User talk:Adam900710|talk]]) 02:44, 19 August 2015 (UTC)
 +
 
 +
:Should be "plug and play" with recent kernel and other packages: [https://www.kraxel.org/blog/2016/09/using-virtio-gpu-with-libvirt-and-spice/ article]. The article is about libvirt, but I've run Arch guest on Arch host successfully with qemu script. [[User:Nesk|Nesk]] ([[User talk:Nesk|talk]]) 09:24, 4 October 2016 (UTC)
 +
 
 +
== host only networking ==
 +
 
 +
I added a quick and easy method but it was deleted.  I found errors in what is here. Is it worth my time to correct them or will they be deleted? {{unsigned|16:39, 4 January 2016‎|Netskink}}
 +
 
 +
:You are welcome to make any corrections. Nobody can tell you if they will be kept or reverted beforehand, but if you're afraid to waste your time feel free to just point them out using an [[Help:Template|Article status templates|article status template]] (should be less time consuming). -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 22:28, 21 February 2016 (UTC)
 +
 
 +
== Windows 7 specific issues ==
 +
 
 +
I have noticed that for me, any attempts at installing Windows 7 using qemu with virt-manager as a frontend stalls on "Starting Windows." This is immediately after booting the computer for the first time. In Virt-manager, I am able to change the Display from QXL to Cirrus to fix the issue. I'm not sure if this applies to this page in particular, but if so, might be worth adding to the "Troubleshooting" section -- [[User:Ephreal|Ephreal]] ([[User talk:Ephreal|talk]]) 14:25, 10 August 2016 (UTC)
 +
 
 +
== <s>Loop setup using udisksctl</s> ==
 +
 
 +
Udisksctl is a handy tool to setup loop device. I put an additional section on mounting raw disk image using udisksctl. I know there is a link pointing to setting up udisks for loopback iso, but it's aimed at unpartitioned read only loop device, which doesn't need to be released. In contrast to iso device, raw disk image is writable. I've added udisksctl command to release the loop device to prevent disk image corruption. --
 +
[[User:Alive4ever|Alive4ever]] ([[User talk:Alive4ever|talk]]) 07:13, 17 August 2016 (UTC)
 +
 
 +
:So, then add a note to [[Udisks]] which handles raw devices. There's no use in duplicated information. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 12:29, 17 August 2016 (UTC)
 +
 
 +
::Via [https://wiki.archlinux.org/index.php?title=QEMU&diff=446866&oldid=446862] and [https://wiki.archlinux.org/index.php?title=Udisks&diff=446864&oldid=445683], closing. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 12:34, 17 August 2016 (UTC)
 +
 
 +
== Using existing partition on GPT disk (with linear RAID or otherwise) ==
  
:I'm not very acquainted with QEMU nor VDE, anyway I would suggest to add your code as an "Alternative method", so that people will be able to choose what they like best, and if the current code doesn't work any longer for anybody (maybe due to version upgrades?) it will be removed altogether. -- [[User:Kynikos|Kynikos]] 10:01, 18 April 2011 (EDT)
+
[https://wiki.archlinux.org/index.php/QEMU#Simulate_virtual_disk_with_MBR_using_linear_RAID Section on using existing partition] is pretty awesome, but it is MBR-specific. Can someone with enough knowledge create a similar section about GPT disk please?

Latest revision as of 09:28, 4 October 2016

Linear RAID

When I was updating the article yesterday, I had tried to fit the section about linear raid (boot a VM from a partition by prepending a MBR to it) into the article better. But I'm not sure the technique described is the right one at all. It looks like it works, but wouldn't it be easier to install a bootloader directly to the partition (e.g. syslinux)? Then the VM could be booted directly from the partition simply by using it as its virtual disk. --Synchronicity (talk) 19:23, 9 May 2012 (UTC)

What about Windows installations then? Nesk (talk) 09:18, 4 October 2016 (UTC)

Creating bridge manually

I really don't know what to do with this section. I'd say it has been superseded by QEMU#Creating bridge using qemu-bridge-helper (available since qemu-1.1, we now have qemu-1.5) - or is someone still using this method? Perhaps link to https://en.wikibooks.org/wiki/QEMU/Networking#TAP_interfaces or http://wiki.qemu.org/Documentation/Networking/NAT is sufficient. What do you think? -- Lahwaacz (talk) 20:42, 22 July 2013 (UTC)

Actually, I've become a happy user of this method. I've written some scripts to easily create bridge interface, TAP interface, and combined with Xyne's excellent scripts to set up NAT and launch DHCP server, I have complete solution to easily manage multiple VMs on one (or even more) bridge.
My scripts are available on github: [1], [2], [3] but I won't probably integrate them into the wiki, I'l just leave a note when I do some more testing.
The thing is, what to do with the current content? Personally I think that links to [4], [5] and my scripts are sufficient (of course others are welcome). I'd also leave the note at the end to disable the firewall on the bridge, I find it extremely useful.
-- Lahwaacz (talk) 18:24, 5 September 2013 (UTC)
I would not remove something that works still heh.--Webdawg (talk) 07:31, 17 July 2016 (UTC)

Starting QEMU virtual machines with systemd

The custom systemd service script does not work. It always fails with Failed at step EXEC spawning /usr/bin/qemu-{type}: No such file or directory. To Fix this modify the ExecStart command
ExecStart=/usr/bin/sh -c "/usr/bin/qemu-${type} -name %i -nographic ${args}"
Also echo 'system_powerdown' | nc localhost 7101 kills the VM immediatly. To fix this change the stop script. It simply checks each second if the main process is still running.
ExecStop=/usr/bin/sh -c "${haltcmd} && while [[ $(pidof qemu-${type} | grep $MAINPID) ]]; do sleep 1; done"

gnu-netcat does not work to connect to the monitor. You need to use openbsd-netcat. -- Ant32 (talk) 17:48, 5 September 2013 (UTC)

The first problem related to starting the service seems rather strange - didn't you have typo error in your local qemu@.service file (missing the dollar sign $ in ${type} )?
The second problem is valid, systemd kills the main process when the ExecStop command exits (see systemd.service(5)). If your workaround really works, it could be added to the wiki with a proper description.
-- Lahwaacz (talk) 21:17, 7 September 2013 (UTC)
Relevant thread on systemd-devel mailing list: [6] -- Lahwaacz (talk) 00:00, 15 September 2013 (UTC)

Kexec Hackery When Using a Real Partition

After banging my head against a wall long enough and figuring out what -kernel and -initrd were really calling, I put a note above the appropriate section and mentioned two ways to use the guest's images. (Otherwise, you'll have to worry if the host and guest images match.) The first -- mount the partition(s) -- is more appropriate for "low-volume-handling" of VMs. The second -- using kexec -- becomes more useful when you're juggling more than a few VMs.

I'm only mentioning this hack because (as of now) Kexec only mentions use for rebooting into another kernel, not switching out the kernel before the system is even up. This hack comes from from https://digitalocean.uservoice.com/forums/136585-digitalocean/suggestions/2814988-give-option-to-use-the-droplet-s-own-bootloader- which has two suggestions. The most recent, using systemd units by jkuan, doesn't work because jkuan tried to copy a .target file into a .service file and systemd wants ExecStart in a .service file. The second one, replacing /usr/bin/init by andrew_sparks, works for me on my Arch instance at DigitalOcean.

Adaptation from said post:

# pacman -S kexec-tools
# pacman -R systemd-sysvcompat
/tmp/init
#!/bin/sh

kexec --load /boot/vmlinuz-linux --initrd=/boot/initramfs-linux.img --append="root=/dev/sda init=/usr/lib/systemd/systemd" &&
mount -o ro,remount / && kexec -e
exec /usr/lib/systemd/systemd
# cd [/path/to/vm]/usr/bin
# mv init init.dist
# cp /tmp/init ./
# chmod 755 init

I'm leaving this on the Talk page as I haven't even tried it out in QEMU myself. Also, my eyes are about ready to pop out of my head, so I'm barring myself from figuring out the appropriate way to edit this in for the time being. BrainwreckedTech (talk) 21:23, 14 January 2014 (UTC)

Replace -net with -netdev

The -net option is deprecated and replaced by -netdev. I think this article should be modified to reflect that. http://en.wikibooks.org/wiki/QEMU/Networking#cite_ref-1 axper (talk) 18:12, 1 July 2014 (UTC)

I'm rewriting the network section

https://wiki.archlinux.org/index.php/User:Axper/sandbox/qemu_network axper (talk) 20:07, 2 July 2014 (UTC)

I think a lot of networking topics could be moved outside of the QEMU page. Many virtualization applications share the same basic principles with regards to networking, such as tun/tap creating, bridges, VDE, etc. There are a few networking schemes that are QEMU-specific, for example multicast sockets and -net socket,..., and these could be mentioned on the QEMU page, although these are less reliable and rarely used in comparison to tap devices. We should also of course note the QEMU-specific command line options in the QEMU page, but for general concepts and commands independent of the virtualization applications, they could go on pages dedicated to the task. The best example is VDE, which is in no way limited to QEMU, yet it still doesn't have its own page on the Arch wiki.
Incidentally, I'm planning on rewriting User Mode Linux (yes, I promise I will get around to it), which happens to share the "tap with bridge" and VDE concepts with QEMU. It would be nice if I could link to pages dedicated to those topics and only write UML-specific commands in the page, instead of duplicating a bunch of general information. I'm not familiar very familiar with Xen or LXC or Docker or the like, but I would suspect that they also share some networking infrastructure. We could possibly even create a category just for these types of pages, for example "Virtual Networking" or "Advanced Networking". EscapedNull (talk) 13:32, 19 February 2015 (UTC)

-enable-kvm vs -machine type=pc,accel=kvm

The section QEMU#Enabling_KVM recommends -enable-kvm, while QEMU#Virtual_machine_runs_too_slowly recommends -machine type=pc,accel=kvm. Is there any difference between the two? Is one preferred over the other? Should we just link to the former section from the latter (and possibly move both command line switches to the same section)? EscapedNull (talk) 17:23, 18 January 2015 (UTC)

virtio-gpu

Any tutorial on using the new virtio-gpu which is introduced in qemu-2.4 and kernel 4.2? Adam900710 (talk) 02:44, 19 August 2015 (UTC)

Should be "plug and play" with recent kernel and other packages: article. The article is about libvirt, but I've run Arch guest on Arch host successfully with qemu script. Nesk (talk) 09:24, 4 October 2016 (UTC)

host only networking

I added a quick and easy method but it was deleted. I found errors in what is here. Is it worth my time to correct them or will they be deleted? —This unsigned comment is by Netskink (talk) 16:39, 4 January 2016‎. Please sign your posts with ~~~~!

You are welcome to make any corrections. Nobody can tell you if they will be kept or reverted beforehand, but if you're afraid to waste your time feel free to just point them out using an Article status templates|article status template (should be less time consuming). -- Lahwaacz (talk) 22:28, 21 February 2016 (UTC)

Windows 7 specific issues

I have noticed that for me, any attempts at installing Windows 7 using qemu with virt-manager as a frontend stalls on "Starting Windows." This is immediately after booting the computer for the first time. In Virt-manager, I am able to change the Display from QXL to Cirrus to fix the issue. I'm not sure if this applies to this page in particular, but if so, might be worth adding to the "Troubleshooting" section -- Ephreal (talk) 14:25, 10 August 2016 (UTC)

Loop setup using udisksctl

Udisksctl is a handy tool to setup loop device. I put an additional section on mounting raw disk image using udisksctl. I know there is a link pointing to setting up udisks for loopback iso, but it's aimed at unpartitioned read only loop device, which doesn't need to be released. In contrast to iso device, raw disk image is writable. I've added udisksctl command to release the loop device to prevent disk image corruption. -- Alive4ever (talk) 07:13, 17 August 2016 (UTC)

So, then add a note to Udisks which handles raw devices. There's no use in duplicated information. -- Alad (talk) 12:29, 17 August 2016 (UTC)
Via [7] and [8], closing. -- Alad (talk) 12:34, 17 August 2016 (UTC)

Using existing partition on GPT disk (with linear RAID or otherwise)

Section on using existing partition is pretty awesome, but it is MBR-specific. Can someone with enough knowledge create a similar section about GPT disk please?