Look Into Libvirt Osier Yang


Published on

China OpenStack User Group

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Look Into Libvirt Osier Yang

  1. 1.                  Look into libvirt                     Osier Yang  <jyang@redhat.com>
  2. 2. Status● First release on Dec 19 2005● 1.0.0 in two weeks. (Finally)● 25 maitainers/commiters.● 200 ~ 300 patches per release● Less than 300 APIs
  3. 3. Why libvirt?● Long term API/ABI/XML back-compact● Portable between various HVs● Hides complex interfaces of HV● Hides HVs API changes● Available on Linux, Solaris, Windows & OS-X● Secure access (TLS, SASL, SSH, PolicyKit)● Open, LGPLv2+ license
  4. 4. What libvirt manages● Domain● Virtual network● Host network interface● Node device● Storage pool/volume● Network filter● Secret
  5. 5. Supported hypervisors● QEMU/KVM● XEN: XenD, XenStored, XM, libxenlight● VMWare: ESX, GSX server, Workstation, Player● Linux container: LXC, OpenVZ● Test, Remote● UML, VirtualBox, Hyper-V, Parallels, etc
  6. 6. Virtual network● Nat (dnsmasq/Radvd, iptables)● Route● Isolated● Bridge (Open vSwitch, Macvtap)● Host network interface passthrough (SR-IOV VFs pool)
  7. 7. Host network interface● Based on netcf -> augeas● Enumerate● Management(ethernets, bonds, bridges, vlan interfaces)● Transaction support – revert/commit config changes● Report status (libnl, ioctl, sysfs)
  8. 8. Network filter● iptables● ebtables● Ip6tables● E.g. allow-incoming-ipv4 no-ip-multicast
  9. 9. Storage● pool, volume● fs (dir, fs, netfs)● scsi● Iscsi● Disk● lvm● mpath● sheepdog, rbd
  10. 10. Node device● Enumerate host devices● Backends (udev, HAL)● vHBA create/destroy
  11. 11. Secret● Encrypt storage● Can be used to encrypt a storage volume or domain disk● Only support qcow disks
  12. 12. Miscellaneous● Hooks (Daemon, QEMU, LXC, Migration)● Audit● Security (Selinux/Apparmor, sVirt)● Locking (libsanlock, POSIX fcntl)● Zero-conf (Avahi)● etc...
  13. 13. How to talk with QEMU● Monitor (HMP, QMP)● Guest agent monitor● Serial/Parrell console● Graphic console (vnc/spice)● Network
  14. 14. Domain APIs (libvirt.h)● Lifecyle (define/undefine, start/destroy, suspend/resume), list, lookup.● Save, restore, core dump, suspend, resume● Migration● Snapshot (Internal/External, Disk-only/ System checkpoint/VM state)● Guest resource management (memory, network, memory, cpu, NUMA tuning)
  15. 15. Domain APIs (libvirt.h)● Host device passthrough● Detach/reattach node devices● Async events● Node resource management (memory)● APIs based on guest agent (E.g. S3/S4)● Guest block/network I/O statistics● ...more...
  16. 16. libvirt architecture Node client libvirt-qemu public API Agent monitor qemu-kvm libvirtd monitor RPC remote $URIuri = “qemu://$hostname/system" Guest guest agent
  17. 17. The stack virshvirsh bindings SNMP AMQP ...... public API libvirtd KVM XEN ESX LXC UML ......Network Storage Iface nwfilter Secret Nodedevcgroup netcf iptables ebtables tc libnl lvm selinux sysfs udev HAL devmapiscsiadm ioctl libnuma numad sanlock qemu-img
  18. 18. Stuffs around● Language bindings (Python, Perl, Ruby, Jave, OCaml, C#, PHP)● Libvirt-snmp● Libvirt-qpid● Libvirt-cim● libvirt-glib (libvirt-glib, libvirt-gconf, libvirt- gobject)
  19. 19. Stuffs around● Virt-manager● virt-viewer● python-virtinst● Libosinfo● Libvirt-designer● Libvirt-sandbox● Gnome Boxes
  20. 20. Stuffs around● Virt-manager, virt-viewer● python-virtinst● Libosinfo● Libvirt-designer● Libvirt-sandbox● Gnome Boxes● Eucalyptus, openstack● Plugins for collectd, munin, Nagios, Zenoss
  21. 21. libguestfs● For accessing and modifying virtual machine (VM) disk images● View and edit files inside guests● Scripting changes to VM● Monitoring disk used/free statistics● P2V, V2V● Performing partial backups● Cloning VMs, etc..
  22. 22. How libguestfs works Appliance client qemu guestfsdlibguestfs Linux kernel Device or Disk image
  23. 23. virt-v2v● Convert VMs on XEN/ESX to RH virt stack● Support guests of RHEL, Fedora, Windows● Based on libguestfs and libvirt
  24. 24. How virt-v2v works● Shutdown guest on source host● Use libvirt to get domain XML config● Copy storage● Convert storage and modify XML● Use libvirt to define and start the domain on dest host
  25. 25. The conversion - RHEL/FC● Remove XEN/ESX specific stuffs (E.g. xenpv kernel/drivers, VMWare tools)● Install or update kernel, try best to let it support virtio● Update block and network drivers
  26. 26. Ongoing or TODO● Snapshot improvements● Storage driver improvements (glusterfs, job, inotify)● LXC driver improvements● Persistent vHBA● Migration with NPIV● Associate storage with domain● Improve device hotplug
  27. 27. Ongoing or TODO● Lifecycle events for all objects● Role based access control on all public APIs● Isolate QEMU process with Linux Container namespaces.● APIs to expose host/hyperviors capabilities● Etc...
  28. 28. http://libvirt.org  libvir­list@redhat.comlibvirt­user@redhat.com #virt on OFTC