]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Use compat message per device instead of per instance
authorSasha Levin <levinsasha928@gmail.com>
Thu, 13 Oct 2011 09:32:41 +0000 (11:32 +0200)
committerPekka Enberg <penberg@kernel.org>
Thu, 13 Oct 2011 16:38:59 +0000 (19:38 +0300)
This prevents multiple messages for the same type of device.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/include/kvm/virtio-9p.h
tools/kvm/virtio/9p.c
tools/kvm/virtio/balloon.c
tools/kvm/virtio/blk.c
tools/kvm/virtio/console.c
tools/kvm/virtio/net.c
tools/kvm/virtio/rng.c

index 07084c3cd8267c2dc2b754fc7ca167d7f331da0c..3096df27c6466411b9015b848a88a617612e5221 100644 (file)
@@ -45,7 +45,6 @@ struct p9_dev {
        struct virtio_pci       vpci;
 
        struct virtio_9p_config *config;
-       int                     compat_id;
        u32                     features;
 
        /* virtio queue */
index 22a273219aff112c10467f15fbf1b3f3e4aa8753..b9b92b859e74bd1478b67417c407c0aabddcd4eb 100644 (file)
@@ -20,6 +20,7 @@
 #include <net/9p/9p.h>
 
 static LIST_HEAD(devs);
+static int compat_id = -1;
 
 /* Warning: Immediately use value returned from this function */
 static const char *rel_to_abs(struct p9_dev *p9dev,
@@ -1148,7 +1149,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
        struct virt_queue *queue;
        void *p;
 
-       compat__remove_message(p9dev->compat_id);
+       compat__remove_message(compat_id);
 
        queue                   = &p9dev->vqs[vq];
        queue->pfn              = pfn;
@@ -1247,7 +1248,8 @@ int virtio_9p__register(struct kvm *kvm, const char *root, const char *tag_name)
 
        list_add(&p9dev->list, &devs);
 
-       p9dev->compat_id = compat__add_message("virtio-9p device was not detected",
+       if (compat_id != -1)
+               compat_id = compat__add_message("virtio-9p device was not detected",
                                                "While you have requested a virtio-9p device, "
                                                "the guest kernel didn't seem to detect it.\n"
                                                "Please make sure that the kernel was compiled "
index 0b791328c113a15396add4d88a7b9d51a5a92703..643392bbd7a628501d8da3dc92556de6fd2a1d51 100644 (file)
@@ -44,12 +44,12 @@ struct bln_dev {
        u16                     stat_count;
        int                     stat_waitfd;
 
-       int                     compat_id;
        struct virtio_balloon_config config;
 };
 
 static struct bln_dev bdev;
 extern struct kvm *kvm;
+static int compat_id = -1;
 
 static bool virtio_bln_do_io_request(struct kvm *kvm, struct bln_dev *bdev, struct virt_queue *queue)
 {
@@ -226,7 +226,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
        struct virt_queue *queue;
        void *p;
 
-       compat__remove_message(bdev->compat_id);
+       compat__remove_message(compat_id);
 
        queue                   = &bdev->vqs[vq];
        queue->pfn              = pfn;
@@ -280,7 +280,8 @@ void virtio_bln__init(struct kvm *kvm)
                .get_size_vq            = get_size_vq,
        };
 
-       bdev.compat_id = compat__add_message("virtio-balloon device was not detected",
+       if (compat_id != -1)
+               compat_id = compat__add_message("virtio-balloon device was not detected",
                                                "While you have requested a virtio-balloon device, "
                                                "the guest kernel didn't seem to detect it.\n"
                                                "Please make sure that the kernel was compiled "
index c508123c9b0810ffba843ffa7c259332e79ebbb9..272613b445e71d3b479e8785bbf760e8d299d516 100644 (file)
@@ -44,7 +44,6 @@ struct blk_dev {
        struct virtio_pci               vpci;
        struct virtio_blk_config        blk_config;
        struct disk_image               *disk;
-       int                             compat_id;
        u32                             features;
 
        struct virt_queue               vqs[NUM_VIRT_QUEUES];
@@ -53,6 +52,7 @@ struct blk_dev {
 };
 
 static LIST_HEAD(bdevs);
+static int compat_id;
 
 static void virtio_blk_do_io_request(struct kvm *kvm, void *param)
 {
@@ -154,7 +154,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
        struct virt_queue *queue;
        void *p;
 
-       compat__remove_message(bdev->compat_id);
+       compat__remove_message(compat_id);
 
        queue                   = &bdev->vqs[vq];
        queue->pfn              = pfn;
@@ -220,7 +220,8 @@ void virtio_blk__init(struct kvm *kvm, struct disk_image *disk)
 
        list_add_tail(&bdev->list, &bdevs);
 
-       bdev->compat_id = compat__add_message("virtio-blk device was not detected",
+       if (compat_id != -1)
+               compat_id = compat__add_message("virtio-blk device was not detected",
                                                "While you have requested a virtio-blk device, "
                                                "the guest kernel didn't seem to detect it.\n"
                                                "Please make sure that the kernel was compiled "
index b8801622669b4565eac63a39e7abb6ffc9c6d548..ef1ef0d96f0913383dcd10377da305bb3f2ba283 100644 (file)
@@ -37,7 +37,6 @@ struct con_dev {
        struct virt_queue               vqs[VIRTIO_CONSOLE_NUM_QUEUES];
        struct virtio_console_config    config;
        u32                             features;
-       int                             compat_id;
 
        struct thread_pool__job         jobs[VIRTIO_CONSOLE_NUM_QUEUES];
 };
@@ -52,6 +51,8 @@ static struct con_dev cdev = {
        },
 };
 
+static int compat_id = -1;
+
 /*
  * Interrupts are injected for hvc0 only.
  */
@@ -137,7 +138,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
 
        assert(vq < VIRTIO_CONSOLE_NUM_QUEUES);
 
-       compat__remove_message(cdev.compat_id);
+       compat__remove_message(compat_id);
 
        queue                   = &cdev.vqs[vq];
        queue->pfn              = pfn;
@@ -188,7 +189,8 @@ void virtio_console__init(struct kvm *kvm)
                .get_size_vq            = get_size_vq,
        };
 
-       cdev.compat_id = compat__add_message("virtio-console device was not detected",
+       if (compat_id != -1)
+               compat_id = compat__add_message("virtio-console device was not detected",
                                                "While you have requested a virtio-console device, "
                                                "the guest kernel didn't seem to detect it.\n"
                                                "Please make sure that the kernel was compiled "
index b55725df9356b3554dd697a60e71d04721bed119..9c39a8784ec29aa1ed205f5036f4a58d4c56f69a 100644 (file)
@@ -48,7 +48,6 @@ struct net_dev {
        struct virt_queue               vqs[VIRTIO_NET_NUM_QUEUES];
        struct virtio_net_config        config;
        u32                             features;
-       int                             compat_id;
 
        pthread_t                       io_rx_thread;
        pthread_mutex_t                 io_rx_lock;
@@ -69,6 +68,7 @@ struct net_dev {
 };
 
 static LIST_HEAD(ndevs);
+static int compat_id = -1;
 
 static void *virtio_net_rx_thread(void *p)
 {
@@ -327,7 +327,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
        struct virt_queue *queue;
        void *p;
 
-       compat__remove_message(ndev->compat_id);
+       compat__remove_message(compat_id);
 
        queue                   = &ndev->vqs[vq];
        queue->pfn              = pfn;
@@ -413,7 +413,8 @@ void virtio_net__init(const struct virtio_net_params *params)
 
        virtio_net__io_thread_init(params->kvm, ndev);
 
-       ndev->compat_id = compat__add_message("virtio-net device was not detected",
+       if (compat_id != -1)
+               compat_id = compat__add_message("virtio-net device was not detected",
                                                "While you have requested a virtio-net device, "
                                                "the guest kernel didn't seem to detect it.\n"
                                                "Please make sure that the kernel was compiled "
index 02308c29606ef218bb1ed5b50275cbce218f8850..17cd49292a41b8c42064736342386ac411bb3f66 100644 (file)
@@ -33,7 +33,6 @@ struct rng_dev {
        struct virtio_pci       vpci;
 
        int                     fd;
-       int                     compat_id;
 
        /* virtio queue */
        struct virt_queue       vqs[NUM_VIRT_QUEUES];
@@ -41,6 +40,7 @@ struct rng_dev {
 };
 
 static LIST_HEAD(rdevs);
+static int compat_id = -1;
 
 static void set_config(struct kvm *kvm, void *dev, u8 data, u32 offset)
 {
@@ -97,7 +97,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
        struct rng_dev_job *job;
        void *p;
 
-       compat__remove_message(rdev->compat_id);
+       compat__remove_message(compat_id);
 
        queue                   = &rdev->vqs[vq];
        queue->pfn              = pfn;
@@ -164,7 +164,8 @@ void virtio_rng__init(struct kvm *kvm)
 
        list_add_tail(&rdev->list, &rdevs);
 
-       rdev->compat_id = compat__add_message("virtio-rng device was not detected",
+       if (compat_id != -1)
+               compat_id = compat__add_message("virtio-rng device was not detected",
                                                "While you have requested a virtio-rng device, "
                                                "the guest kernel didn't seem to detect it.\n"
                                                "Please make sure that the kernel was compiled "