This prevents multiple messages for the same type of device.

Suggested-by: Ingo Molnar <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
 tools/kvm/include/kvm/virtio-9p.h |    1 -
 tools/kvm/virtio/9p.c             |    6 ++++--
 tools/kvm/virtio/balloon.c        |    7 ++++---
 tools/kvm/virtio/blk.c            |    7 ++++---
 tools/kvm/virtio/console.c        |    8 +++++---
 tools/kvm/virtio/net.c            |    7 ++++---
 tools/kvm/virtio/rng.c            |    7 ++++---
 7 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/tools/kvm/include/kvm/virtio-9p.h 
b/tools/kvm/include/kvm/virtio-9p.h
index 07084c3..3096df2 100644
--- a/tools/kvm/include/kvm/virtio-9p.h
+++ b/tools/kvm/include/kvm/virtio-9p.h
@@ -45,7 +45,6 @@ struct p9_dev {
        struct virtio_pci       vpci;
 
        struct virtio_9p_config *config;
-       int                     compat_id;
        u32                     features;
 
        /* virtio queue */
diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c
index 22a2732..b9b92b8 100644
--- a/tools/kvm/virtio/9p.c
+++ b/tools/kvm/virtio/9p.c
@@ -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 "
diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c
index 0b79132..643392b 100644
--- a/tools/kvm/virtio/balloon.c
+++ b/tools/kvm/virtio/balloon.c
@@ -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 "
diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index c508123..272613b 100644
--- a/tools/kvm/virtio/blk.c
+++ b/tools/kvm/virtio/blk.c
@@ -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 "
diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c
index b880162..ef1ef0d 100644
--- a/tools/kvm/virtio/console.c
+++ b/tools/kvm/virtio/console.c
@@ -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 "
diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index b55725d..9c39a87 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -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 "
diff --git a/tools/kvm/virtio/rng.c b/tools/kvm/virtio/rng.c
index 02308c2..17cd492 100644
--- a/tools/kvm/virtio/rng.c
+++ b/tools/kvm/virtio/rng.c
@@ -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 "
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to