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 done 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 ... Rich. -- 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
Do I understand correctly, that libguestfs use qemu to work with drives? If I will try to use it, I think it solves my disk io problem. On 18 January 2011 02:18, Richard W.M. Jones <rjones@redhat.com> wrote:
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 done
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 ...
Rich.
-- 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
-- Nikita A Menkovich JID: menkovich@gmail.com Tel: +7 (921) 423-96-48
On Tue, Jan 18, 2011 at 07:47:18AM +0300, Nikita A Menkovich wrote:
Do I understand correctly, that libguestfs use qemu to work with drives? If I will try to use it, I think it solves my disk io problem.
qemu or KVM, depending on whichever is available / fastest. http://libguestfs.org/guestfs.3.html#architecture Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
participants (2)
-
Nikita A Menkovich -
Richard W.M. Jones