I like QEMU and I like to use it directly from the CLI to run tests with virtual machines : these helpers save me typing time.
download .qemu-helpers.rc
and source it after checking in your current bash shell or in your ~/.bashrc
.
quick call to qemu-system-x86_64
with a few default parameters that can naturally (for the most part) be overridden by the command line.
-serial mon:stdio
avoids an unfortunate Ctrl-C.
qemu
function andqemu
alias cannot coexist. this latter is commented/deactivated in favor of the function.
this helper executes qemu-system-x86_64
with the parameters stored in the qemu.cfg
configuration file (if present and executable) and the parameters passed on the command line (which supplement or overwrite those previously defined in the configuration file or in the function).
symbolic link can be used for qemu.cfg
configuration file (eg. multiple settings).
chmod +x qemu.cfg
to activate the configuration and chmod -x qemu.cfg
to deactivate it.
qemu
function andqemu
alias cannot coexist.
this helper allows you to create a new image (qcow2 if not specified) based on a previous one, whose format will be automatically detected. it stops if the base image supplied is not read-only.
qemu-img create -b previous next
will run/usr/bin/qemu-img create -b previous -F qcow2 -f qcow2 next
ifprevious
base is a qcow2 file (magic stringQFI\xfb
) and/usr/bin/qemu-img create -b previous -F raw -f qcow2 next
otherwise.
this helper displays base images (eg. dependencies) in tree form, highlighting those that are not read-only.
this helper makes it easy to find the usb port where a smartphone is plugged in, so that it can be fully transferred to the virtual machine.