Google Summer of Code 2022
Tags: gsoc, c
Google Summer of Code has come to an end with this week. It has been a relatively new experience for me and I will be sharing it in this post.
1 The goal
The goal was to write an API for querying the KVM statistics in libvirt for which QEMU already has a QMP command called “query-stats”.
2 The importance
Statistics are useful to developers (of libvirt and others) and users (of libvirt) alike. The more statistics, the better, and verbosity helps in that too. They are an important part of inspection and working on something involving libvirt, or it might help some hobbyist or enthusiast with whatever it is they want to accomplish. Regardless, they are bound to be of some use at some point, if not right now, and if QEMU is convenient enough to provide them, then why not parse them?
3 The work
This might come off as rude or unexpected but the work itself was nothing much really. Things were relatively easy to understand and most problems were caused by either my stupid schedule and my lack of basic common sense, and my clumsiness is always there to blame; the mentors always helped me with whatever I needed help with. I will continue to look after at least this part of the code and help in whatever way I can, even with other things in libvirt and surrounding projects, if possible.
4 Why even do it
I had been on a long break from programming (and IT tinkering) for around an year. This seemed like a very nice and relatively easier place to get started again and at the same time learn new stuff as well. I won’t lie that the stipend is not appealing for a freshman either.
I kept on piling up stupid amounts of side stuff to do alongside GSoC when I had my college to attend to as well. Things got pretty bad, I tried keeping up apperances everywhere but it was pretty obvious anyway.
6 What I learnt
- Well interacting in a mailing list was a first, always was curious and there was this mysterious air around it, turns out it is not exactly mysterious.
- My mentors were the best part of the project, learnt that kind people do, in fact, exist.
- How cover letter and commit messages are really important. This might seem obvious but it is still a learning experience in practice and a very important thing to keep in mind.
- How cool GLib is in preventing memory leaks and stuff. This was my first time working with it.
- How working on something is not always going to be fun and exciting but is still important.
- And most importantly, why taking up a lot of work in the middle of a student program and being a full time student is a very bad decision.
7 The mentors (and the organization)
They were the saving grace for my miserable condition. Super kind people and super patient as well, helped me whenever I had problems and never overlooked any part of their mentoring. They kept up with my pitiable schedule, although I was the one making excuses for it. They taught me a lot of stuff too that comes with working on a project like
libvirt. If I were to become an employee of a distinguished firm or a project, I would want to be like them for sure; cannot praise them enough as a mentee.
8 The patches
So far only the support for “query-stats” has been merged and implemented for querying the halt poll status for vCPUs.
8.1.1 qemu: add an API for “query-stats” QMP command
- qemu_monitor: add qemuMonitorQueryStats [GitLab]
- qemu_capabilities: add “query-stats” QMP command to the QEMU capabilities [GitLab]
- qemu_driver: use qemuMonitorQueryStats to extract halt poll time [GitLab]
8.2.1 qemu: add support for query-stats-schemas
First up is the basic API support for the “query-stats-schemas” QMP command and its usage to get vCPU and VM stats, they need some refinement.
- qemu_monitor: add qemuMonitorQueryStatsSchema
- qemu_capabilities: add “query-stats-schemas” QMP command to the QEMU capabilities
- qemu_domain: add statsSchema to qemuDomainObjPrivate
- qemu_monitor: add qemuMonitorGetStatsByQOMPath
- qemu_driver: add the vCPU stats by KVM to the current stats
- qemu_driver: add new stats worker qemuDomainGetStatsVm
8.2.2 add support for histograms as a virTypedParameterType
Next is the even more unrefined additon of histograms to virTypedParameterType to support histograms which were previously ignored.
- virtypedparam: add virHistogram as a virTypedParameterType
- add a global feature for supporting virHistogram
- virtypedparams: add VIR_TYPED_PARAM_HISTOGRAM_OKAY
- qemu_driver: add histograms to the stats
- remote: add virHistogram support for RPC as a virTypedParameterType
The commit messages for this set are more hideous than I initially thought.
9 What comes next
9.1 Stage 1 (with querying stats in libvirt)
A bunch of things really
- I have some tests for query-stats and query-stats-schemas that I shall post as soon as possible.
- Refining the current patches and getting them merged (and the tests mentioned above too).
- Some extensions like working with units and exponents provided by the schema to provide more verbose statistics.
- Keeping an eye on what changes are made with QMP or the relevant commands upstream (QEMU source).
9.2 Stage 2 (with libvirt)
Virtualisation is something I always wanted to learn about and while I learnt about a lot of things, I have barely even scratched the surface.
libvirt being an API collection for major hypervisors is a good starting point for learning about the data communicated between these cogs, so I shall keep on learning and contributing to it.
9.3 Stage 3 (with other projects)
QEMU piques my interest, but I barely know anything about virtualisation besides whatever I “worked” on. I shall learn more about it along with the surrounding projects before I go deep into the QEMU/KVM source. That definitely requires me to get rid of or complete all the tasks I have on my hands right now.
10 Final word
It was a learning experience, authough refreshing, the severity of my schedule made it frustrating; however, learning stuff beyond programming was nice. I could have gone for more “interesting” projects and maybe I would have had a good time with it but this was a good returning point; also helped me learn that life is not an amusement park and there are bound to be things that are going to be boring and someone has to do them. Besides this was not entirely boring, learnt new stuff. Maybe I will go back to programming and tinkering with stuff again after all.