It looks like that you cannot create a brand new VM with virsh unless you already have a working XML file.

I have just installed all the needed bits for QEMU-KVM to work, and need now to create my very first VM.

How to?

Hint: I don't have graphics!

  • Hey, just revisiting some questions. How did you get on with this? Nov 11, 2016 at 16:11
  • I solved the problem by checking the man pages and the official QEMU and KVM web sites and a number of tests and tries. I have been asking to manually do everything, instead I've got answers on how to do it with 3rd party applications. I am almost finished and will publish my working solutions also here asap.
    – EnzoR
    Dec 9, 2016 at 15:29
  • 1
    @I_GNU_it_all_along Yours is the only meaningful answer/comment I've got so far.
    – EnzoR
    Nov 14, 2017 at 8:22
  • 1
    Thanks a lot. Sorry I couldn't be more help with the manual install. Nov 15, 2017 at 10:10
  • 1
    @I_GNU_it_all_along I found that thing of pre-cooked XML file really annoying. I don't think I am a stupid ape if I want to understand. The problem with libvrtd-based stuff is that there's too little documentation and everyone seems pretty comfortable with a black-box approach. Thanks a lot.
    – EnzoR
    Nov 15, 2017 at 13:26

2 Answers 2


There is quite a good walkthrough here. Essentially the tool you're wanting to use is virt-install, which you should already have if you have installed everything needed for QEMU-KVM. Here's the most relevant section.

6. Creating a new Guest VM using virt-install

virt-install tool is used to create the VM. This tool can be used in both interactive or non-interactive mode.

In the following example, I passed all the required values to create an VM as command line parameters to the virt-install command.

# virt-install \
-n myRHELVM1 \
--description "Test VM with RHEL 6" \
--os-type=Linux \
--os-variant=rhel6 \
--ram=2048 \
--vcpus=2 \
--disk path=/var/lib/libvirt/images/myRHELVM1.img,bus=virtio,size=10 \
--graphics none \
--cdrom /var/rhel-server-6.5-x86_64-dvd.iso \
--network bridge:br0

In the above virt-install command the parameters have the following meaning:

  • n: Name of your virtual machine

  • description: Some valid description about your VM. For example: Application server, database server, web server, etc.

  • os-type: OS type can be Linux, Solaris, Unix or Windows.

  • os-variant: Distribution type for the above os-type. For example, for linux, it can be rhel6, centos6, ubuntu14, suse11, fedora6 , etc.

    For windows, this can be win2k, win2k8, win8, win7

  • ram: Memory for the VM in MB

  • vcpu: Total number of virtual CPUs for the VM.

  • disk path=/var/lib/libvirt/images/myRHELVM1.img,bus=virtio,size=10: Path where the VM image files is stored. Size in GB. In this example, this VM image file is 10GB.

  • graphics none: This instructs virt-install to use a text console on VM serial port instead of graphical VNC window. If you have the xmanager set up, then you can ignore this parameter.

  • cdrom: Indicates the location of installation image. You can specify the NFS or http installation location (instead of –-cdrom). For example: --location=http://.com/pub/rhel6/x86_64/*

  • network bridge:br0: This example uses bridged adapter br0. It is also possible to create your own network on any specific port instead of bridged adapter.

    If you want to use the NAT then use something like below for the network parameter with the virtual network name known as VMnetwork1. All the network configuration files are located under /etc/libvirt/qemu/networks/ for the virtual machines. For example:

    –-network network=VMnetwork1

  • 17
    It's rather strange how this isn't mentioned in most documentations, but rather they assume that you already have a working VM, when you're probably reading the tutorial precisely because you don't. Anyway, thanks. :)
    – Teekin
    May 31, 2018 at 15:06
  • 1
    inspired by this I try to run an ubuntu 21.04 machine. Running the command I and up in a new machine and .qcow2 image being created. But the actual result is a blinkin cursor inside my console below Connected to domain 'ubuntu_2104' Escape character is ^] (Ctrl + ]). This message stands between me and actually mastering cli libvirt/KVM/qemu since a long time. I have never been able to find a structured tutorial or manual or guide to get started practically unfortunately. It seem sthere is a class of people who know how it works and another class who do not. Missing is the bridge between.
    – vrms
    Feb 11, 2022 at 12:56
  • @vrms I have the same problem (that's how I came to this and many other questions. I haven't had time to try any of the solutions, but the general gotcha seems that you have to make sure to set up something listening to console input on the other end in the VM - precisely zero of this information is in any of the tutorials I have seen. In fact, I have followed the one from ubuntu.com's very own website and as soon as I rebooted the machine that was basically what happened. It is very frustrating how some simple gotchas can be arcane knowledge sometimes. Mar 21, 2022 at 17:26
  • @htmlcoderexe I actually came across VM's in LXD lately. As I was familiar with LXD containers I gave it a shot and was pleasantly surprised. Probaly I am about to switch over. I have no idea though how the ambitions are compared to what kvm/libvirt/qemu ist able to do.
    – vrms
    Mar 22, 2022 at 18:50

There is a GUI tool available in the repositories called virt-manager. You can start it on your local PC and manage remote libvirtd instances over plain SSH just like they were local.

You can create and edit libvirt machines using a GUI and also view the screen (remote desktop) of these instances which is a very convenient way of remotely managing libvirt machines. You can also have multiple remote hosts, so this is a all-on-one solution for managing local and remote libvirt qemu instances.

# apt-get install virt-manager (Debian)
# yum install virt-manager (Fedora)
# emerge virt-manager (Gentoo)
# pkg_add virt-manager (OpenBSD)
  • 2
    My idea is to use cli for scripting and automation. Good hint, though.
    – EnzoR
    Jul 30, 2021 at 12:26
  • The question actually askes about creating a VM from the shell. That said, Virt Manager puts stuff in Virt Manager default locations. Not so helpful if you want a portable set-up say on a USB.
    – will
    Jun 4 at 14:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .