/qemu_tools

Personal tools for qemu based kernel hacking

Primary LanguageShellGNU General Public License v2.0GPL-2.0

qemu_tools
==========

Set of simple tools for qemu usage.  Because these tools are made for kernel
hacking purpose, would not fit for general usecases.


NOTE
====

These tools are developed and tested on a 'Ubuntu 18.04 Server' host only.  May
not work well on other distributions.


Getting Started
===============

Below simple commands will give you a virtual machine with Ubuntu install
prompt.

    $ ./install.sh
    $ ./mkimg.sh 32G my.disk
    $ wget http://releases.ubuntu.com/18.04/ubuntu-18.04.3-live-server-amd64.iso
    $ sudo ./startvm.sh --graphic --cdrom ubuntu-18.04.3-live-server-amd64.iso my.disk

Above command install QEMU (line 1), create a 32GB-sized disk image (line 2),
get Ubuntu 18.04 installation image file (line 3), and finally start a VM with
the installation image and the disk image (line 4).  The Ubuntu 18.04
installation image file could be changed.  You could find and use the link by
yourself.

Once you finished the installation, you will have an OS installed disk image.
Or, you could simply get one from other people.  Then, you can boot it:

    $ sudo ./startvm.sh <disk image file>


install.sh
==========

`install.sh` fetches source code of qemu v5.2.0 and builds it.  It also
installs necessary packages.  Just type `./install.sh` on your command line.
Other tools in this repository would not work without that.


mkimg.sh
========

`mkimg.sh` makes a `qcow2` format disk image.  Usage is simple:

```
Usage: ./mkimg.sh <size> <image file path>
```

- `<size>`:	Size of the disk.  You may use 'G' for gibibytes.
		(e.g., 32G for 32 GiB)
- `<image file path>`:	Path to the disk file that will be generated.


startvm.sh
==========

`startvm.sh` creates new virtual machine using qemu-kvm.  It's usage is as
below:

```
Usage: ./startvm.sh [OPTIONS] <path to disk file> [<nr_cores> [<ram size>]]
  --graphic       start vm in graphic mode
  --curses        start vm in curses mode
  --sshport       port for ssh server
  --cdrom         cdrom image
```

`<nr_cores>`: Number of virtual CPUs for the virtual machine.
	      Defaults to 1/2 of host CPUs.
`<ram size>`: Size of ram for the virtual machine.  You can use 'G' or 'M'
	      suffix for Gibi-bytes and Mibi-bytes.
	      Defaults to 1/4 of host RAM.
`--graphic`:  Start the virtual machine in graphic mode.
`--curses`:   Start the virtual machine in curses mode.
`--sshport`:  The tool forward 22 port of the virtual machine to this port of
	      host machine.  If you want ssh connection to the virtual machine,
	      you may use this port.
	      Defaults to 2242.
`--cdrom`:    Start the virtual machine as specified cdrom image is inserted.
              For installation CD images, please refer to
              https://www.debian.org/releases/,
              http://releases.ubuntu.com or
              https://dl.fedoraproject.org/pub/fedora/linux/releases/
`--mon`:      Export qemu monitor to specified unix domain socket.
`--qmp`:      Export qmp to specified unix domain socket.
`--incoming`: Start VM as migration incoming mode waiting for specified socket.


Author
======

SeongJae Park <sj38.park@gmail.com>