[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] Assigning qemu process to cgroups

I had a go at writing a patch, but I think it's possible already
without any patch.

After launch you can get the PID of the qemu subprocess:
  guestfs_get_pid (g);
  --> returns PID

You can use Linux to map this to a list of thread IDs:
  ls /proc/$PID/task/
  --> returns a list of thread IDs

[Yes, this is potentially racy, but in reality qemu has already
started up fully after guestfs_launch returns and is almost quiescent
when you're not issuing commands.]

Then you can assign the threads to the cgroup:

  for tid in $(ls -1 /proc/$PID/task); do
    echo $tid > /cgroup/blkio/$group/tasks

This is more cumbersome if you're using guestfish instead of some
scripting language, and it's difficult if you want to port to
non-Linux, but should work in the common case AFAICS.  I've not tried
it though ...


Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]