qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] virtio-input: use fixed device config space size
Date: Mon, 15 Jun 2015 14:53:08 +0200	[thread overview]
Message-ID: <1434372788-18916-1-git-send-email-kraxel@redhat.com> (raw)

virtio-input doesn't support legacy, so config spice doesn't live in IO
address space (on virtio-pci) and size is not something we have to worry
about.  There is a full page (in mmio bar) available anyway.

Don't try to size it dynamically but simply use the full struct size
(136 bytes) unconditionally.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/input/virtio-input.c          | 14 +++++++-------
 include/hw/virtio/virtio-input.h |  1 -
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index c4f4b3c..c5c39fa 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -149,9 +149,9 @@ static void virtio_input_get_config(VirtIODevice *vdev, uint8_t *config_data)
     config = virtio_input_find_config(vinput, vinput->cfg_select,
                                       vinput->cfg_subsel);
     if (config) {
-        memcpy(config_data, config, vinput->cfg_size);
+        memcpy(config_data, config, sizeof(virtio_input_config));
     } else {
-        memset(config_data, 0, vinput->cfg_size);
+        memset(config_data, 0, sizeof(virtio_input_config));
     }
 }
 
@@ -206,6 +206,7 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp)
     VirtIOInput *vinput = VIRTIO_INPUT(dev);
     VirtIOInputConfig *cfg;
     Error *local_err = NULL;
+    uint32_t cfg_size = 0;
 
     if (vic->realize) {
         vic->realize(dev, &local_err);
@@ -219,15 +220,14 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp)
                               vinput->input.serial);
 
     QTAILQ_FOREACH(cfg, &vinput->cfg_list, node) {
-        if (vinput->cfg_size < cfg->config.size) {
-            vinput->cfg_size = cfg->config.size;
+        if (cfg_size < cfg->config.size) {
+            cfg_size = cfg->config.size;
         }
     }
-    vinput->cfg_size += 8;
-    assert(vinput->cfg_size <= sizeof(virtio_input_config));
+    assert(cfg_size + 8 <= sizeof(virtio_input_config));
 
     virtio_init(vdev, "virtio-input", VIRTIO_ID_INPUT,
-                vinput->cfg_size);
+                sizeof(virtio_input_config));
     vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt);
     vinput->sts = virtio_add_queue(vdev, 64, virtio_input_handle_sts);
 }
diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h
index 8134178..7b46e62 100644
--- a/include/hw/virtio/virtio-input.h
+++ b/include/hw/virtio/virtio-input.h
@@ -71,7 +71,6 @@ struct VirtIOInput {
     VirtIODevice                      parent_obj;
     uint8_t                           cfg_select;
     uint8_t                           cfg_subsel;
-    uint32_t                          cfg_size;
     QTAILQ_HEAD(, VirtIOInputConfig)  cfg_list;
     VirtQueue                         *evt, *sts;
     virtio_input_conf                 input;
-- 
1.8.3.1

             reply	other threads:[~2015-06-15 12:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 12:53 Gerd Hoffmann [this message]
2015-06-16  6:59 ` [Qemu-devel] [PATCH 1/2] virtio-input: use fixed device config space size Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434372788-18916-1-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).