官方API The virtualization API

LIBVIRT IS:
  • A toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes), see our project goals for details.

  • Free software available under the GNU Lesser General Public License.

  • A long term stable C API

  • A set of bindings for common languages

  • CIM provider for the DMTF virtualization schema

  • QMF agent for the AMQP/QPid messaging system

  • technical meritocracy, in which participants gain influence over a project through recognition of their contributions.

Libvirt FAQ

WHAT IS LIBVIRT?

Libvirt is collection of software that provides a convenient way to manage virtual machines and other virtualization functionality, such as storage and network interface management. These software pieces include an API library, a daemon (libvirtd), and a command line utility (virsh).

An primary goal of libvirt is to provide a single way to manage multiple different virtualization providers/hypervisors. For example, the command ‘virsh list –all’ can be used to list the existing virtual machines for any supported hypervisor (KVM, Xen, VMWare ESX, etc.) No need to learn the hypervisor specific tools!

 

I HEARD SOMEONE SAY THEY ‘USE LIBVIRT’. WHAT DO THEY MEAN?

When people say they ‘use libvirt’, this usually means that they manage virtual machines using tools such as ‘virsh’, ‘virt-manager’, or ‘virt-install’, which are all built around libvirt functionality. They likely DO NOT directly use tools like ‘xm’ for Xen, or the qemu/qemu-kvm binary.

HOW DO I KNOW IF I AM USING LIBVIRT?

You are using libvirt if you manage virtual machines using virsh, virt-manager, or virt-install (pretty much any virtualization tool that starts with virt-*).

If you are using hypervisor specific tools like ‘xm’, ‘qemu-kvm’, etc. directly, you probably are not using libvirt.

If you have virtual machines on your existing machine and you are using libvirt, ‘virsh list –all’ (usually run as root) should show something.

http://wiki.libvirt.org/page/FAQ#Libvirt_FAQ

Example domain XML config

QEMU emulated guest on x86_64

<domain type='qemu'>
  <name>QEmu-fedora-i686</name>
  <uuid>c7a5fdbd-cdaf-9455-926a-d65c16db1809</uuid>

KVM hardware accelerated guest on i686

<domain type='kvm'>
  <name>demo2</name>
  <uuid>4dea24b3-1d52-d8f3-2516-782e98a23fa0</uuid>

其他reference:

http://qinlong.blog.51cto.com/1130504/335112

Libvirt是一个软件集合,便于使用者管理虚拟机和其他虚拟化功能,比如存储和网络接口管理等等。这些软件包括一个API库、一个 daemon(libvirtd)和一个命令行工具(virsh)。Libvirt的主要目标是:提供一种单一的方式管理多种不同的虚拟化提供方式和 hypervisor。比如,命令行“virsh list — all”可以列出所有任何支持的、基于hypervisor的虚拟机,这就避免学习、使用不同hypervisor的特定工具。
“使用libvirt”,意味着使用virsh、virt-manager、virt-install等工具管理虚拟机,这些工具都是围绕着libvirt开发的。人们不再直接使用基于XEN的xm、或是qemu【注1】/qemu-kvm【注2】等二进制工具。

注1: QEMU 是一种处理器模拟器,依赖于动态二进制翻译机制,在易于移植至新的主机CPU架构的同时,还要获得合理的速度响应。除提供CPU模拟之外,它还提供了一系 列设备模型,允许它运行多种未经修改的客户操作系统;因此QEMU可以被看做一个宿主虚拟机监控软件。它还提供了加速模式,以支持(供kernel code的)二进制翻译和原生执行(供user code)的混合方式,这与VMware Workstation和Microsoft VirtualPC相同。
QEMU 也可以用作纯用户级处理的CPU模拟,在这种运作模式下,它类似于Valgrind。
QEMU有一个特有的可移植×××,虚拟机可以运行在任何PC之上,即使用户只有有限的权限,而且没有管理员访问权限也没有关系,这让“USB优盘上的PC”这一概念变得可行。也有类似的应用,比如MojoPac,但是它们需要管理员权限才能运行。
注2: KVM,Kernel-based Virtual machine 。KVM是一种Linux下的kernel虚拟化基础结构,它自身无法进行任何模拟。需要用户空间的程序使用/dev/kvm接口来设置客户虚拟机的地址空间,像其输入I/O,并将其视频显示映射至主机。QEMU自0.10.0之后可以使用KVM。

 

这个project 挺有意思:

XEN, KVM, Libvirt and IPTables

http://cooker.wbitt.com/index.php/XEN,_KVM,_Libvirt_and_IPTables

https://www.youtube.com/watch?v=WXCo3KOCu8o&list=PLF537D9621ECE72E3