Difference between revisions of "Talk:QEMU"

From ArchWiki
Jump to: navigation, search
m (needed Tap networking with QEMU scripts a rewrite?: rm closed discussion)
(Kexec Hackery When Using a Real Partition: new section)
(11 intermediate revisions by 3 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)
  
== Removing sections for EOL versions of Windows ==
+
== Creating bridge manually ==
  
I think we should remove the instructions/sections for versions of Windows that are not supported by Microsoft anymore/are considered end-of-life. [[QEMU#Windows-specific_notes]] still has sections for Windows 95 through Windows 2000. Microsoft stopped supporting Windows 2000 in 2010. I think we should keep anything that is generally applicable to Windows XP (and recent) from those sections and get rid of the rest of it.
+
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)
  
Does anyone object?<br>
+
: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.
-- [[User:Jstjohn|Jstjohn]] ([[User talk:Jstjohn|talk]]) 08:29, 13 June 2013 (UTC)
+
: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.
: I think it's fine to remove everything before XP, after all this is not Windows chronicle... So +1 from me.
+
: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]]) 15:35, 13 June 2013 (UTC)
+
:-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 18:24, 5 September 2013 (UTC)
::Go for it, I'd also be curious to know how much information in the article is duplicating http://wiki.qemu.org/ which would be bad according to [[Help:Style#Hypertext metaphor]].  
+
::-- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 11:31, 15 June 2013 (UTC)
+
:::I've just removed that old information. I agree that it would be good for someone to go through QEMU's wiki and eliminate any duplicated information.
+
:::-- [[User:Jstjohn|Jstjohn]] ([[User talk:Jstjohn|talk]]) 01:03, 18 June 2013 (UTC)
+
::::http://wiki.qemu.org/ isn't very verbose, [http://wiki.qemu.org/Documentation/Networking/NAT many instructions] are not for Arch and it may contain outdated information (last edit on most pages 1-2 years back), so I think deduplication is not necessary.
+
::::http://en.wikibooks.org/wiki/QEMU is much more verbose, but the same as above applies, so I think deduplication is not necessary in this case either.
+
::::-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:57, 22 July 2013 (UTC)
+
  
== qemu-* vs qemu-system-*? ==
+
== Preparing an (Arch) Linux guest  ==
  
What's the difference between qemu-* and qemu-system-*? So far, I haven't seen too much of a difference, except for a quite noticeable difference in filesize:
+
adding the virtio modules to use virtual devices doesn't appear to be necessary as of the VM I built this week(Jul 26, 2013). Kernel 3.9.9-1
 +
[[User:Surlyjake|Surlyjake]] ([[User talk:Surlyjake|talk]]) 03:42, 27 July 2013 (UTC)
  
{{bc|
+
:In newer kernel versions (I think since 3.4) the kernel modules are loaded automatically. I'd still keep the section as it is for now, linux-lts is still at 3.0. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 21:09, 20 August 2013 (UTC)
# ls -l $(which qemu{-system,}-x86_64);
+
-rwxr-xr-x 1 root root 4793008 Jun  8 02:14 /usr/bin/qemu-system-x86_64
+
-rwxr-xr-x 1 root root 2406208 Jun  8 02:14 /usr/bin/qemu-x86_64
+
}}
+
  
: Next time please add a signature after your post by typing four tildes ({{ic|<nowiki>~~~~</nowiki>}}). Thanks.
+
::{{Pkg|linux-lts}} is now on the 3.10 series.
: There have been some changes recently and the wiki page isn't yet fully updated. I guess that the old {{ic|qemu}} binary has been replaced by {{ic|qemu-system-*}} depending on architecture and {{ic|qemu-*}} binary is used internally. See qemu(1) for more details.
+
::-- [[User:Jstjohn|Jstjohn]] ([[User talk:Jstjohn|talk]]) 16:51, 23 September 2013 (UTC)
: -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 09:47, 16 July 2013 (UTC)
+
  
::I've done some more research on this: {{ic|qemu-system-*}} binaries emulate full virtual machine (that's currently described in [[QEMU]], some time ago {{ic|qemu}} was used for this purpose), whereas {{ic|qemu-*}} binaries allow executing statically linked binaries for different architecture than the host system. You can even [http://www.gentoo.org/proj/en/base/embedded/handbook/?part=1&chap=5 chroot] into different-architecture system emulating even dynamically linked binaries. Perhaps some mention of this could be added to [[QEMU]]. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 20:54, 22 July 2013 (UTC)
+
==  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)
  
== Creating bridge manually ==
+
: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)
  
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)
+
::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)
  
== Preparing an (Arch) Linux guest  ==
+
== Kexec Hackery When Using a Real Partition ==
  
adding the virtio modules to use virtual devices doesn't appear to be necessary as of the VM I built this week(Jul 26, 2013). Kernel 3.9.9-1
+
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.
[[User:Surlyjake|Surlyjake]] ([[User talk:Surlyjake|talk]]) 03:42, 27 July 2013 (UTC)
+
 
 +
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.
 +
 
 +
Adaptation from said post:
 +
 
 +
# pacman -S kexec-tools
 +
# pacman -R systemd-sysvcompat
 +
 
 +
{{hc|1=/tmp/init|2=
 +
#!/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. [[User:BrainwreckedTech|BrainwreckedTech]] ([[User talk:BrainwreckedTech|talk]]) 21:23, 14 January 2014 (UTC)

Revision as of 21:23, 14 January 2014

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)

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)

Preparing an (Arch) Linux guest

adding the virtio modules to use virtual devices doesn't appear to be necessary as of the VM I built this week(Jul 26, 2013). Kernel 3.9.9-1 Surlyjake (talk) 03:42, 27 July 2013 (UTC)

In newer kernel versions (I think since 3.4) the kernel modules are loaded automatically. I'd still keep the section as it is for now, linux-lts is still at 3.0. -- Lahwaacz (talk) 21:09, 20 August 2013 (UTC)
linux-lts is now on the 3.10 series.
-- Jstjohn (talk) 16:51, 23 September 2013 (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)