Posts tagged qemu

proxmox: qemu-img convert

posted on 2016-06-11 10:33

In proxmox you sometimes want to convert images from one type to another.

available types

QCOW2 (KVM, Xen)    qcow2
QED   (KVM)         qed
raw                 raw
VDI   (VirtualBox)  vdi
VHD   (Hyper-V)     vpc
VMDK  (VMware)      vmdk
RBD   (ceph)        rbd


qemu-img convert -p -f raw -O qcow2 vm-100-disk-1.raw vm-100-disk-1.qcow2

-f is the first image format, -O the second. Look at the manpage to guess why -f is called -f.

-p shows the progress, which is really nice.

What about .ova images?

.ova is just a combined format:

0 root@ssg 12:13:25 /home/sjas/wrk/gns3 # file GNS3\ VM.ova 
GNS3 VM.ova: POSIX tar archive (GNU)
0 root@ssg 12:16:20 /home/sjas/wrk/gns3 # tar tf GNS3\ VM.ova 
GNS3 VM.ovf
GNS3 VM-disk1.vmdk
GNS3 VM-disk2.vmdk

So simply untar it and convert the diskfile(s):

tar xvf GNS3\ VM.ova

.ovf is the config file, vmdk's are disk images:

0 root@ssg 12:18:57 /home/sjas/wrk/gns3 # head -10 GNS3\ VM.ovf
<?xml version="1.0"?>
<Envelope ovf:version="1.0" xml:lang="en-US" xmlns="" xmlns:ovf="" xmlns:rasd="" xmlns:vssd="" xmlns:xsi="" xmlns:vbox="">
    <File ovf:href="GNS3 VM-disk1.vmdk" ovf:id="file1"/>
    <File ovf:href="GNS3 VM-disk2.vmdk" ovf:id="file2"/>
    <Info>List of the virtual disks used in the package</Info>
    <Disk ovf:capacity="20971520000" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="" vbox:uuid="ef66f138-bc76-4bcf-a57a-c9dc3f5aad10"/>
    <Disk ovf:capacity="104857600000" ovf:diskId="vmdisk2" ovf:fileRef="file2" ovf:format="" vbox:uuid="1e01a454-630d-452a-bb1f-1e784ab57d7b"/>
0 root@ssg 12:19:06 /home/sjas/wrk/gns3 #

Newer qemu version can run .vmdk's directly, but .qcow2 FTW, so here we go:

0 root@ssg 12:20:52 /home/sjas/wrk/gns3 # qemu-img convert -p -f vmdk -O qcow2 GNS3\ VM-disk1.vmdk GNS3\ VM-disk1.qcow2; qemu-img convert -p -f vmdk -O qcow2 GNS3\ VM-disk2.vmdk GNS3\ VM-disk2.qcow2
0 root@ssg 12:23:35 /home/sjas/wrk/gns3 #

To show which formats your qemu version supports:

qemu-img -h | grep formats

Most of this came into existence when I needed to refamliarize myself with libvirt again, which may be handled by another post eventually. For now the images will do and we are almost finished here.

Last mention is, virt-convert should be able to do above things in single step plus convert the .ovf to libvirt format, too.

Virtualization types

posted on 2015-06-27 18:57:55

For a more abstract view, there exist different perspectives on virtualization.

This post intends to give a practical overview on these and the currently available technologies. Keep in mind this is also work in progress and will get additional content in the future, by then this message will be removed.

First perspective: virtualization classes

hardware emulation

A piece of hardware emulates another piece of hardware, such that no distinction seems to exist.

The virtualization software makes sure, all hardware (CPU, chipset, I/O, ...) instructions from the host cpu are translated for the guest. Such that a completely different set of hardware seems to be present.

That way, with a big hit on performance, different architectures than the one being provided by the host system can be made available. I.e. MIPS / ARM / SPARC on x86.

The guest OS runs natively without changes.


hardware virtualization

CPU emulation will not take place, just chipset and other hardware gets emulated. Some CPU instructions may be altered though, but no hardware emulation takes place, CPU-wise.

This yields way better performance than hardware emulation does, but you usually have to stick with one kind of architecture.



No hardware emulation takes place, but the host offers an API for hardware access to the guests.

Different architectures will NOT run.

Guest operating systems may may need the have their kernels patched, such that this API can be used. Xen has different operating modes, depending on the degree of paravirtualization being used.


  • XEN
  • VMWare vSphere (device drivers are partly paravirtualized, in the past this was also the case with CPU's)
  • KVM (see virtio drivers)

Note: KVM is not just a pure Paravirtualizator, it just also provides paravirtualized drivers along with virtualized ones. Also it also uses qemu under the hood for hardware emulation.

operating-system-level virtualization

No hardware emulation takes place, and the operating system kernel is shared.

Software: (native)

Software: (patched kernel needed, thus only backported changes = bad.)

  • Linux : Parallels Virtuozzo, OpenVZ, VServer

custom kernels or not?

Just leave these technologies needing kernel patches alone, here's why I guess this is the better choice:

The same development will eventually take place, like it happened with KVM vs. Xen. All major linux distributions chose KVM as primary virtualization technique once a solution (read: KVM) was present within the mainline kernel. Xen was dropped. I'd be astonished if this were different with OpenVZ vs. LXC.

LXC just got fresh support in Proxmox, and will likely supersede Virtuozzo in the future. (But that's just an educated guess of mine.)

difference between docker und i.e. LXC

Currently there is a lot of fuss about docker for 'app virtualization'. docker used to use LXC as a backend, but nowadays they develop their own lib/userland tool called libcontainer for managing the OS functions such that their product will run.

Google's lmctfy development ('let me contain that for you'), which has got the same scope as docker, is currently stalled according to the github project readme:

lmctfy is currently stalled as we migrate the core concepts to libcontainer and build a standard container management library that can be used by many projects.

second perspective: virtualization types

type 1: baremetal

Where you have minimal OS, acting as a hypervisor and virtual machine manager, and most interaction flows directly between VM and processor, without passing the HV OS.

type 2

A regular OS like any linux distribution, a Windows variant or Mac OSX is used, and your virtualization software is installed there.

All system calls have to pass the emulated/virtualized hardware which is provided through the host OS. All calls will have to pass through the host OS / the Hypervisor.


This is simply all the container stuff, where a guest OS is running as another process (-tree) is running within the host OS.

background 1: hardware-supported virtualization features

Hardware virtualization purely through sofware is costly and slow. Processors nowadays usually provide instruction set extensions like VT-x (Intel), VIA TV (VIA) or AMD-V (AMD), depending on the manufacturer.

These implement an access control specifically for virtualization, along to the rings we will talk about in a minute.

With VT-x there basically exist two modes:

  • VMX Root Operation
  • VMX non Root Operation

Hypervisors run in VMX Root Op mode. VM's do not.
If non-root-op stuff is run in ring 0 (see below) by a VM, the Hypervisor can catch this instructions since he runs in root-op-mode, basically implementing trapping.

Prior to this, binary code was passed to the HV from the VM and translated on the fly for security reasons. But with extra instructions, this of course takes place much faster.

To further speed things up, there also exist hardware implemenations for 'Nested Paging' / SLAT (second level address translation). These are called EPT ('Extended Page Tables', Intel) or RVI ('Rapid Virtual Indexing', AMD) and make 'shadow page table' management via the hardware possible. That way usually MMU (memory mapping unit of the cpu) intensive work loads can be sped up.

Also maybe you have to have turned on these CPU virtualization features on in the BIOS, too, if your hypervisor is slow as hell. It can be the case, that the mainboard has these deactivated by default (for whatever a reason).

If you really want to know more theoretical stuff about this, head over here at VMWware. To just have the 'light' version, try VirtualBox' technical background section in its manual here.

background 2: kernel protection rings / privilege levels

These are separations such that processes within a certain ring can just execute a subset of the processor instructions of the processes being present in the lower ring. For going lower, a kind of API is provided, via interrupts, and context switches are necessary for transitions.

Rings can be implemented in purely in software (slow), but nowadays hardware (instructions within the processor, way faster, see above, google 'binary translation') is used for this.

First an overview, which ring permits which level of hardware enforced access in protected mode on an x86 cpu: (There exist some more modes, of course. ;))

  • ring 0: kernel
  • ring 1: device drivers
  • ring 2: device drivers
  • ring 3: applications

Another term for the rings is hierarchical protection domains. They are mechanisms to secure execution of hardware-level instructions in the processor.

I.e. processes running in ring 0 have direct memory access, and do not have to use virtual memory where the RAM access would be limited for security reasons.

According to the virtualbox manual usually only 0 and 3 are used usually. But virtualbox also happens to use ring 1 for security reasons. See the aforementioned manual for more information how this takes place.

When ring protection is coupled to certain processor modes, it is basically the known differentiation between kernel- and userspace.

Depending on the ring the guest operates mostly in, the virtualization classification is also different, and that is why this part here was included into the post initially.

This blog covers .csv, .htaccess, .pfx, .vmx, /etc/crypttab, /etc/network/interfaces, /etc/sudoers, /proc, 10.04, 14.04, 16.04, AS, ASA, ControlPanel, DS1054Z, GPT, HWR, Hyper-V, IPSEC, KVM, LSI, LVM, LXC, MBR, MTU, MegaCli, PHP, PKI, PS1, R, RAID, S.M.A.R.T., SNMP, SSD, SSL, TLS, TRIM, VEEAM, VMware, VServer, VirtualBox, Virtuozzo, XenServer, acpi, adaptec, algorithm, ansible, apache, apache2.4, apachebench, apple, applet, arcconf, arch, architecture, areca, arping, asa, asdm, autoconf, awk, backup, bandit, bar, bash, benchmarking, binding, bitrate, blackarmor, blockdev, blowfish, bochs, bond, bonding, booknotes, bootable, bsd, btrfs, buffer, c-states, cache, caching, ccl, centos, certificate, certtool, cgdisk, cheatsheet, chrome, chroot, cisco, clamav, cli, clp, clush, cluster, cmd, coleslaw, colorscheme, common lisp, configuration management, console, container, containers, controller, cron, cryptsetup, csync2, cu, cups, cygwin, d-states, database, date, db2, dcfldd, dcim, dd, debian, debug, debugger, debugging, decimal, desktop, df, dhclient, dhcp, diff, dig, display manager, dm-crypt, dmesg, dmidecode, dns, docker, dos, drivers, dtrace, dtrace4linux, du, dynamictracing, e2fsck, eBPF, ebook, efi, egrep, emacs, encoding, env, error, ess, esx, esxcli, esxi, ethtool, evil, expect, exportfs, factory reset, factory_reset, factoryreset, fail2ban, fakeroot, fbsd, fdisk, fedora, file, files, filesystem, find, fio, firewall, firmware, fish, flashrom, forensics, free, freebsd, freedos, fritzbox, fsck, fstrim, ftp, ftps, g-states, gentoo, ghostscript, git, git-filter-branch, gitbucket, github, gitolite, global, gnutls, gradle, grep, grml, grub, grub2, guacamole, hardware, haskell, hdd, hdparm, hellowor, hex, hexdump, history, howto, htop, htpasswd, http, httpd, https, i3, icmp, ifenslave, iftop, iis, imagemagick, imap, imaps, init, innoDB, innodb, inodes, intel, ioncube, ios, iostat, ip, iperf, iphone, ipmi, ipmitool, iproute2, ipsec, iptables, ipv6, irc, irssi, iw, iwconfig, iwlist, iwlwifi, jailbreak, jails, java, javascript, javaws, js, juniper, junit, kali, kde, kemp, kernel, keyremap, kill, kpartx, krypton, lacp, lamp, languages, ldap, ldapsearch, less, leviathan, liero, lightning, links, linux, linuxin3months, lisp, list, livedisk, lmctfy, loadbalancing, locale, log, logrotate, looback, loopback, losetup, lsblk, lsi, lsof, lsusb, lsyncd, luks, lvextend, lvm, lvm2, lvreduce, lxc, lxde, macbook, macro, magento, mailclient, mailing, mailq, make-jpkg, manpages, markdown, mbr, mdadm, megacli, micro sd, microsoft, minicom, mkfs, mktemp, mod_pagespeed, mod_proxy, modbus, modprobe, mount, mouse, movement, mpstat, multitasking, myISAM, mysql, mysql 5.7, mysql workbench, mysqlcheck, mysqldump, nagios, nas, nat, nc, netfilter, networking, nfs, nginx, nmap, nocaps, nodejs, numberingsystem, numbers, od, onyx, opcode-cache, openVZ, openlierox, openssl, openvpn, openvswitch, openwrt, oracle linux, org-mode, os, oscilloscope, overview, parallel, parameter expansion, parted, partitioning, passwd, patch, pct, pdf, performance, pfsense, php, php7, phpmyadmin, pi, pidgin, pidstat, pins, pkill, plasma, plesk, plugin, posix, postfix, postfixadmin, postgres, postgresql, poudriere, powershell, preview, profiling, prompt, proxmox, ps, puppet, pv, pveam, pvecm, pvesm, pvresize, python, python3, qemu, qemu-img, qm, qmrestore, quicklisp, quickshare, r, racktables, raid, raspberry pi, raspberrypi, raspbian, rbpi, rdp, redhat, redirect, registry, requirements, resize2fs, rewrite, rewrites, rhel, rigol, roccat, routing, rs0485, rs232, rsync, s-states, s_client, samba, sar, sata, sbcl, scite, scp, screen, scripting, seafile, seagate, security, sed, serial, serial port, setup, sftp, sg300, shell, shopware, shortcuts, showmount, signals, slattach, slip, slow-query-log, smbclient, snmpget, snmpwalk, software RAID, software raid, softwareraid, sophos, spacemacs, spam, specification, speedport, spi, sqlite, squid, ssd, ssh, ssh-add, sshd, ssl, stats, storage, strace, stronswan, su, submodules, subzone, sudo, sudoers, sup, swaks, swap, switch, switching, synaptics, synergy, sysfs, systemd, systemtap, tar, tcpdump, tcsh, tee, telnet, terminal, terminator, testdisk, testing, throughput, tmux, todo, tomcat, top, tput, trafficshaping, ttl, tuning, tunnel, tunneling, typo3, uboot, ubuntu, ubuntu 16.04, ubuntu16.04, udev, uefi, ulimit, uname, unetbootin, unit testing, upstart, uptime, usb, usbstick, utf8, utm, utm 220, ux305, vcs, vgchange, vim, vimdiff, virtualbox, virtualization, visual studio code, vlan, vmstat, vmware, vnc, vncviewer, voltage, vpn, vsphere, vzdump, w, w701, wakeonlan, wargames, web, webdav, weechat, wget, whois, wicd, wifi, windowmanager, windows, wine, wireshark, wpa, wpa_passphrase, wpa_supplicant, x11vnc, x2x, xfce, xfreerdp, xmodem, xterm, xxd, yum, zones, zsh

Unless otherwise credited all material Creative Commons License by sjas