]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Specify names for VM internal threads
authorSasha Levin <sasha.levin@oracle.com>
Wed, 24 Oct 2012 16:52:27 +0000 (12:52 -0400)
committerPekka Enberg <penberg@kernel.org>
Thu, 25 Oct 2012 06:48:00 +0000 (09:48 +0300)
Give threads a meaningful name. This makes debugging much easier, and
everything else much prettier.

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
[ penberg@kernel.org: specify vcpu names ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 files changed:
tools/kvm/builtin-run.c
tools/kvm/disk/core.c
tools/kvm/include/kvm/kvm.h
tools/kvm/ioeventfd.c
tools/kvm/kvm-ipc.c
tools/kvm/net/uip/tcp.c
tools/kvm/net/uip/udp.c
tools/kvm/ui/sdl.c
tools/kvm/ui/vnc.c
tools/kvm/util/threadpool.c
tools/kvm/virtio/blk.c
tools/kvm/virtio/net.c

index 709ed33bd7fdbb64f352629b09b4a8b9fb34add4..dec2e741d0a90d23d117014af1833190573a6dba 100644 (file)
@@ -171,7 +171,12 @@ static void handle_sigalrm(int sig, siginfo_t *si, void *uc)
 
 static void *kvm_cpu_thread(void *arg)
 {
-       current_kvm_cpu         = arg;
+       char name[16];
+
+       current_kvm_cpu = arg;
+
+       sprintf(name, "kvm-vcpu-%lu", current_kvm_cpu->cpu_id);
+       kvm__set_thread_name(name);
 
        if (kvm_cpu__start(current_kvm_cpu))
                goto panic_kvm;
index b313b284683278eec9a89ecf77334f7562256e83..dd59751ca112ed297884fc253673f48bb17e3738 100644 (file)
@@ -63,6 +63,8 @@ static void *disk_image__thread(void *param)
        int nr, i;
        u64 dummy;
 
+       kvm__set_thread_name("disk-image-io");
+
        while (read(disk->evt, &dummy, sizeof(dummy)) > 0) {
                nr = io_getevents(disk->ctx, 1, ARRAY_SIZE(event), event, &notime);
                for (i = 0; i < nr; i++)
index b4606565131b8ac607da9f27363ee0b75f9328ea..cf959eab6160bb29052e7a7460143da304894bac 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/types.h>
 #include <time.h>
 #include <signal.h>
+#include <sys/prctl.h>
 
 #define SIGKVMEXIT             (SIGRTMIN + 0)
 #define SIGKVMPAUSE            (SIGRTMIN + 1)
@@ -118,4 +119,9 @@ static inline void *guest_flat_to_host(struct kvm *kvm, unsigned long offset)
 
 bool kvm__supports_extension(struct kvm *kvm, unsigned int extension);
 
+static inline void kvm__set_thread_name(const char *name)
+{
+       prctl(PR_SET_NAME, name);
+}
+
 #endif /* KVM__KVM_H */
index a68d8d0d2db39ddde5237f89003b50af6290eca5..ff665d410ba5864bc80a0b4dfeb6f88035c1d473 100644 (file)
@@ -24,6 +24,8 @@ static void *ioeventfd__thread(void *param)
 {
        u64 tmp = 1;
 
+       kvm__set_thread_name("ioeventfd-worker");
+
        for (;;) {
                int nfds, i;
 
index d23edd271dc2b1294b5389fc417d5cf6214fe500..bdcc0d1f6b730829444e16dffed1b65a8eb51676 100644 (file)
@@ -260,6 +260,8 @@ static void *kvm_ipc__thread(void *param)
        struct epoll_event event;
        struct kvm *kvm = param;
 
+       kvm__set_thread_name("kvm-ipc");
+
        for (;;) {
                int nfds;
 
index 711a716422f1c155c60407e36d75ef58d00604a4..830aa3fd91a042e9a6b6747bd339304b06237cef 100644 (file)
@@ -1,5 +1,6 @@
 #include "kvm/uip.h"
 
+#include <kvm/kvm.h>
 #include <linux/virtio_net.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -176,6 +177,8 @@ static void *uip_tcp_socket_thread(void *p)
        int len, left, ret;
        u8 *payload, *pos;
 
+       kvm__set_thread_name("uip-tcp");
+
        sk = p;
 
        payload = malloc(UIP_MAX_TCP_PAYLOAD);
index d4518b2527bc1726cb12a2698e4453c74b97985f..5b6ec1c67c5c158bfe3e66d2e543d80cf58f4ed8 100644 (file)
@@ -1,5 +1,6 @@
 #include "kvm/uip.h"
 
+#include <kvm/kvm.h>
 #include <linux/virtio_net.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -160,6 +161,8 @@ static void *uip_udp_socket_thread(void *p)
        int nfds;
        int i;
 
+       kvm__set_thread_name("uip-udp");
+
        info = p;
 
        do {
index 172a12b768e404f3456e809d62ed2222e33bc50d..9994490022b6ae715cd4b7b88bed3b631b66bc99 100644 (file)
@@ -206,6 +206,8 @@ static void *sdl__thread(void *p)
        SDL_Event ev;
        Uint32 flags;
 
+       kvm__set_thread_name("kvm-sdl-worker");
+
        if (SDL_Init(SDL_INIT_VIDEO) != 0)
                die("Unable to initialize SDL");
 
index efdc0f42fb195a1edc44cb356f22673d16430450..12e4bd53fe0d812d0f9fa49c6e6e4593f7559fdc 100644 (file)
@@ -185,6 +185,8 @@ static void *vnc__thread(void *p)
        char argv[1][1] = {{0}};
        int argc = 1;
 
+       kvm__set_thread_name("kvm-vnc-worker");
+
        server = rfbGetScreen(&argc, (char **) argv, fb->width, fb->height, 8, 3, 4);
        server->frameBuffer             = fb->mem;
        server->alwaysShared            = TRUE;
index 85ac7e7383130ec47d3e4002075edcd797ffc4d4..a3638311e2e9dc3d9098fc5ab9f04a5569762818 100644 (file)
@@ -78,6 +78,8 @@ static void *thread_pool__threadfunc(void *param)
 {
        pthread_cleanup_push(thread_pool__threadfunc_cleanup, NULL);
 
+       kvm__set_thread_name("threadpool-worker");
+
        while (running) {
                struct thread_pool__job *curjob = NULL;
 
index cff38aa68948a1fb871c72688c9f55e2819fbbc4..f76342c9ab9100ae050e24c093f2cf68308ab0e0 100644 (file)
@@ -179,6 +179,8 @@ static void *virtio_blk_thread(void *dev)
        u64 data;
        int r;
 
+       kvm__set_thread_name("virtio-blk-io");
+
        while (1) {
                r = read(bdev->io_efd, &data, sizeof(u64));
                if (r < 0)
index d6d344a37d3332680fb08b51e15309688c8c28e2..ac429cc03a5224f5f6430998231d25088b0b62db 100644 (file)
@@ -79,6 +79,8 @@ static void *virtio_net_rx_thread(void *p)
        u16 head;
        int len;
 
+       kvm__set_thread_name("virtio-net-rx");
+
        kvm = ndev->kvm;
        vq = &ndev->vqs[VIRTIO_NET_RX_QUEUE];
 
@@ -115,6 +117,8 @@ static void *virtio_net_tx_thread(void *p)
        u16 head;
        int len;
 
+       kvm__set_thread_name("virtio-net-tx");
+
        kvm = ndev->kvm;
        vq = &ndev->vqs[VIRTIO_NET_TX_QUEUE];