Differences between revisions 8 and 27 (spanning 19 versions)
Revision 8 as of 2006-02-16 23:38:00
Size: 2239
Editor: ?DavideViti
Comment: Added instruction for performing a floppy install
Revision 27 as of 2017-04-23 01:27:54
Size: 4579
Editor: PaulWise
Comment: use Debian manpages
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
#language en
Line 3: Line 4:
[http://fabrice.bellard.free.fr/qemu/ Official page]  * QEMU
  * Official page: [[http://wiki.qemu.org/Main_Page]]
  * IRC channel: [[irc:irc.freenode.net#qemu]]
  * Manpage: [[DebianMan:1/qemu|qemu]]
 * [[QEMU]] on this wiki.
Line 5: Line 10:
''#qemu'' IRC channel on ''irc.freenode.net''
Line 18: Line 22:
If you have CPU with virtualization support, you can use kvm, which
is faster than qemu but command-line compatible with it.
Line 21: Line 28:
 * install over serial console
 * network install
Line 37: Line 46:
$ qemu -user-net -cdrom mini.iso -hda hd_image.img -boot d $ qemu -redir tcp:5555:10.0.2.15:80 -cdrom mini.iso -hda hd_img.img -boot d
Line 39: Line 48:

qemu-0.8.1 does not need any net options, it defaults to user-mode networking;
with previous versions of qemu you might need to use "-net nic -net user" in order
to get user-mode networking working.

The ''redir'' option is useful for accessing to the http server inside the installer
which can be reached pointing your browser to http://localhost:5555
Line 44: Line 60:
 * "screendump" which can be used to take a screenshot of
 
the VM screen
 * "screendump" which can be used to take a screenshot of the VM screen
Line 47: Line 62:
 * "sendkey" is very useful when you want to switch to VT2 during
 
a g-i vession ("sendkey ctrl-alt-f2)
 * "sendkey" is very useful when you want to switch to VT2 during a g-i vession ("sendkey ctrl-alt-f2)
Line 50: Line 64:
 * "gdbserver" is useful for attaching gdb to a process running inside
 
the VM
 * "gdbserver" is useful for attaching gdb to a process running inside the VM
Line 53: Line 66:
 * "loadmem/savemem" used to save/restore the state of the VM, saves you alot
  of time when you have performed all the steps needed to reproduce a bug
 * "loadmem/savemem" used to save/restore the state of the VM, saves you a lot of time when you have performed all the steps needed to reproduce a bug

= Communicating with the VM =
You often need to copy file from the VM to the host (i.e. log files),
or you need to copy files from the host to the VM (i.e. some udebs).

There are various ways of achieving this; if you have an ssh client
inside the VM, for example, you can scp files from/to the host. When
you boot a (standard) g-i image, it takes a few steps before you can
have the ssh client into the VM, so you might find useful doing the following:

''wget'' can be used to copy files from your host (or somewhere on the net); note that the wget command is always included in the mini.iso

''netcat'' can be use to export files from the VM to the host: you first need open a listening connection on the host

{{{
  $ nc -l -p 1111 > vm.log
}}}

then, you can run the following command to export a file from the VM:

{{{
  # cat logfile.txt | nc IPADDR_HOST 1111
}}}

you should find the file vm.log on you host, with the content of logfile.txt
Obviously networking inside the VM has to up before being able to do this.

= network install =

You can use the built-in qemu tftp server to boot the netinst image:

{{{
$ qemu -hda hda.img -tftp ~/debian-installer/installer/build/dest/netboot -bootp /pxelinux.0 -boot n
}}}

In this case, you will need to to copy a bootrom from etherboot package to /usr/share/qemu.

= install over serial console =
you can easily test an installation over a serial console by passing the following
string at the boot prompt:

{{{
install console=ttyS0,9600,n8
}}}

you can then reach the serial console by pressing ctrl-alt-3
Line 57: Line 115:
To test an installation from the floppy images, you first need to grab [http://people.debian.org/~joeyh/d-i/images/daily/floppy/boot.img boot.img] and [http://people.debian.org/~joeyh/d-i/images/daily/floppy/root.img root.img]
Where Qemu still might have support for floppies,
the Linux kernel doesn't have any more.

To test an installation from the floppy images, you first need to grab [[https://d-i.debian.org/daily-images/amd64/daily/floppy/boot.img|boot.img]] and [[https://d-i.debian.org/daily-images/amd64/daily/floppy/root.img|root.img]]
Line 61: Line 123:
$ qemu -user-net -fda boot.img -hda hd_image.img -boot a $ qemu -fda boot.img -hda hd_image.img -boot a

Resources

Intro

Qemu can be used to simulate various hardware configurations and to easily test the debian installer in various conditions; it's great for testing "delicate" things like a partitioner, since disk devices are usually represented by files.

It can be used also to emulate other architectures: I tested amd64 and powerpc versions on the installer on my i386 host machine. At the moment (qemu-0.8.0) sparc and ARM are being worked on and have some basic support.

If you have CPU with virtualization support, you can use kvm, which is faster than qemu but command-line compatible with it.

Here some possible d-i boot configurations:

  • floppy installs
  • install over serial console
  • network install
  • installs from USB (??)
  • lowmem installs

Basic setup

First of all, you need to create a file which will acts as an hard disk for the virtual machine:

$ qemu-img create hd_img.img 500M

You can then download an iso image of the installer, or create one yourself; you can then run a g-i session by running the following command:

$ qemu -redir tcp:5555:10.0.2.15:80 -cdrom mini.iso -hda hd_img.img -boot d

qemu-0.8.1 does not need any net options, it defaults to user-mode networking; with previous versions of qemu you might need to use "-net nic -net user" in order to get user-mode networking working.

The redir option is useful for accessing to the http server inside the installer which can be reached pointing your browser to http://localhost:5555

Qemu monitor

Qemu has a "monitor" (ctrl-alt-2) which can be used to access various funcionalities such as:

  • "screendump" which can be used to take a screenshot of the VM screen
  • "sendkey" is very useful when you want to switch to VT2 during a g-i vession ("sendkey ctrl-alt-f2)
  • "gdbserver" is useful for attaching gdb to a process running inside the VM
  • "loadmem/savemem" used to save/restore the state of the VM, saves you a lot of time when you have performed all the steps needed to reproduce a bug

Communicating with the VM

You often need to copy file from the VM to the host (i.e. log files), or you need to copy files from the host to the VM (i.e. some udebs).

There are various ways of achieving this; if you have an ssh client inside the VM, for example, you can scp files from/to the host. When you boot a (standard) g-i image, it takes a few steps before you can have the ssh client into the VM, so you might find useful doing the following:

wget can be used to copy files from your host (or somewhere on the net); note that the wget command is always included in the mini.iso

netcat can be use to export files from the VM to the host: you first need open a listening connection on the host

  $ nc -l -p 1111 > vm.log

then, you can run the following command to export a file from the VM:

  # cat logfile.txt | nc IPADDR_HOST 1111

you should find the file vm.log on you host, with the content of logfile.txt Obviously networking inside the VM has to up before being able to do this.

network install

You can use the built-in qemu tftp server to boot the netinst image:

$ qemu -hda hda.img -tftp ~/debian-installer/installer/build/dest/netboot -bootp /pxelinux.0 -boot n 

In this case, you will need to to copy a bootrom from etherboot package to /usr/share/qemu.

install over serial console

you can easily test an installation over a serial console by passing the following string at the boot prompt:

install console=ttyS0,9600,n8

you can then reach the serial console by pressing ctrl-alt-3

Floppy install

Where Qemu still might have support for floppies, the Linux kernel doesn't have any more.

To test an installation from the floppy images, you first need to grab boot.img and root.img and use the files as if they were floppy disks:

$ qemu -fda boot.img -hda hd_image.img -boot a

once you're asked to insert the root disk, just switch to "monitor" (ctrl-alt-2) and

(qemu) change fda root.img

switch back to d-i (ctrl-alt-1) and press ENTER