From Libvirt Wiki
Revision as of 15:03, 6 April 2020 by Mprivozn (talk | contribs) (Done upstream as v6.2.0-40-g08071ec0f1)
Jump to: navigation, search

This page tracks introductory tasks for new libvirt contributors. Code cleanups, bugs, and small features are listed with difficulty ranging from trivial to intermediate.

Beginner tasks

These tasks are good first introductions to libvirt code. You will be required to get things building and make sure the test suite passes, but not necessarily need to understand the details of what libvirt is doing. Mostly these are following existing example changes that are already in the code. Contact the listed mentor with any questions

Move validation checks out of domain XML parsing

Mentor: Cole Robinson <>

The code that handles domain/VM XML parsing (virDomainDefParseXML in src/domain/domain_conf.c) has various validation checks sprinkled within it. Many of these checks should be moved out of the parse step and into virDomainDefPostParse, so they can be shared by various places in the code that build a domain definition without XML, such as converting from native vmware/virtualbox/xen formats.

Not all validation checks can or should be moved. You'll need to determine if the check is specific to the actual XML parsing, or is it general for all VM configurations. So anything that throws an error if it hits unexpected XML should not be moved.

Just a few of the candidates for moving to virDomainDefPostParse:

  • All the checks against dom->os.type and dom->virtType in virDomainInputDefParseXML should go into a virDomainInputDefValidate function
  • The error "tray is only valid for cdrom and floppy" in virDomainDiskDefParseXML
  • 'disk vendor' and 'disk product' errors in virDomainDiskDefParseXML
  • host->socket checks in virDomainStorageNetworkParseHost
  • all the option collision 'total and...' error messages in virDomainDiskDefIotuneParse
  • 'pci-root and pcie-root controllers should not' in virDomainControllerDefParseXML
  • PCI chassisNr, chassis, port, busNr, numaNode range checks in virDomainControllerDefParseXML
  • "Controllers must use the 'ccid' address type" in virDomainSmartcardDefParseXML
  • any 'not available' or 'valid only' errors in virDomainGraphicsListenDefParseXML
  • All the 'only supported' errors in virDomainVideoDefParseXML
  • size validation in virDomainMemoryTargetDefParseXML
  • 'must be in range' errors in virDomainDefParseBootXML
  • 'You must map the root user of container' in virDomainIdmapDefParseXML
  • 'duplicate blkio device path' error
  • 'Only one primary video device is supported' error

You can see an example commit here:;a=commitdiff;h=265e6924f569431d431981c4c0d8d68baf0fb2a2

Slightly-less-beginner tasks

These tasks are slightly more involved than the beginner tasks, but still don't require extensive libvirt knowledge. If any of the beginner tasks seem too simple, maybe try one of these. Talk with the listed mentor if you have questions.

Move default Input bus logic to PostParse handling

Mentor: Cole Robinson <>

Similar to what was started with default video model logic in these commits:

Break out the default bus setting logic from virDomainInputDefParseXML and move it to PostParse handling. Look for anything that sets a def->bus value in that function, it's grounds for removal

Add additional virsh command line completion functions

Mentor: Michal Privoznik <>

Completers are small functions that are called from the virsh command line tool whenever the user started typing something and hit TAB TAB. Their purpose is to offer list of strings that suit entered input. If there is only one item on the list then it's entered in automatically. For instance:

virsh # dom<TAB><TAB>
domblkerror         domblkstat          domcontrol          domfsinfo ..

virsh # start --domain <TAB><TAB>
fedora       fedora.i686  freebsd      gentoo ...

Additional functions are needed to improve other commands.

An example patch:

A series of example patches:

Bugs and feature requests from bugzilla (LibvirtFirstBug)

Some bugs in the libvirt bugzilla tracker are marked as good introductory bug reports or features for new contributors. These bugs have the 'LibvirtFirstBug' tag. Each bug report contains info and sample commits to point you in the right direction. You can open the list in your browser bugzilla here.

Failed to load RSS feed from Error parsing XML for RSS

Ongoing code transitions

GLib replacements

In 2019 libvirt began using GLib internally. We can use GLib APIs to drop some libvirt-specific code.

Path functions

Functions in virfile.c related to path handling can be replaced with g_path_* APIs. The callers should be made to invoke the GLib APIS directly.

XAttr / ACLs

Replace virfile.c XAttr and ACL handling with GFileAttribute APIs


The callers of the various virMutex, virThread, virCond, virOnce, etc APIs should be switched to use the GLib threading APIs.

g_autofree and g_autoptr usage

g_autofree is a feature provided by GLib and the C compiler which will free a variable when it goes out of scope. g_autoptr works similarly, but it will call a custom registred free function instead.

We are slowly converting the code to use these new patterns. Any variable that is allocated and free'd within a single function can likely be converted to use g_autofree or g_autoptr. Similarly, any usage of VIR_FREE under a cleanup: can likely be converted.

virObject to GObject conversions

Our internal virObject implementation can be relatively easily replaced with GLib's GObject.