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>
Subject: [Qemu-devel] [PATCH 1/4] qdev: device capabilities
Date: Tue, 11 Aug 2009 11:20:24 +0200	[thread overview]
Message-ID: <1249982427-14481-1-git-send-email-kraxel@redhat.com> (raw)

This patch adds device capabilities to qdev devices.  This is the
core code, following patches will add the individual capabilities
and tag drivers.

The capabilities will be printed by '-device ?' and 'info qdm", so
users and management apps can use it.

Future plans:  I plan to use them to get rid off some hard-coded
lists in qemu by using capabilities instead: pci nic list, watchdog
list, maybe more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev.c |   19 ++++++++++++++++++-
 hw/qdev.h |    5 +++++
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index c1a7779..568d249 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -107,8 +107,11 @@ DeviceState *qdev_create(BusState *bus, const char *name)
 
 static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len)
 {
+    static const char *capname[] = {
+    };
+    const char *sep;
     int pos = 0;
-    int ret;
+    int ret,i;
 
     ret = snprintf(dest+pos, len-pos, "name \"%s\", bus %s",
                    info->name, info->bus_info->name);
@@ -125,6 +128,20 @@ static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len)
         ret = snprintf(dest+pos, len-pos, ", no-user");
         pos += MIN(len-pos,ret);
     }
+    if (info->caps) {
+        ret = snprintf(dest+pos, len-pos, ", caps \"");
+        pos += MIN(len-pos,ret);
+        sep = "";
+        for (i = 0; i < ARRAY_SIZE(capname); i++) {
+            if (!(info->caps & (1 << i)))
+                continue;
+            ret = snprintf(dest+pos, len-pos, "%s%s", sep, capname[i]);
+            pos += MIN(len-pos,ret);
+            sep = ",";
+        }
+        ret = snprintf(dest+pos, len-pos, "\"");
+        pos += MIN(len-pos,ret);
+    }
     return pos;
 }
 
diff --git a/hw/qdev.h b/hw/qdev.h
index 204c4e5..7beb756 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -102,6 +102,10 @@ typedef void (*qdev_initfn)(DeviceState *dev, DeviceInfo *info);
 typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
               int unit);
 
+enum DeviceCapBits {
+    dummy
+};
+
 struct DeviceInfo {
     const char *name;
     const char *alias;
@@ -109,6 +113,7 @@ struct DeviceInfo {
     size_t size;
     Property *props;
     int no_user;
+    uint32_t caps;
 
     /* Private to qdev / bus.  */
     qdev_initfn init;
-- 
1.6.2.5

             reply	other threads:[~2009-08-11  9:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-11  9:20 Gerd Hoffmann [this message]
2009-08-11  9:20 ` [Qemu-devel] [PATCH 2/4] qdev: add audio capability Gerd Hoffmann
2009-08-11  9:20 ` [Qemu-devel] [PATCH 3/4] qdev: add ethernet capability Gerd Hoffmann
2009-08-11  9:20 ` [Qemu-devel] [PATCH 4/4] qdev: add display capability Gerd Hoffmann
2009-08-11 13:42   ` Anthony Liguori
2009-08-11 14:17     ` Gerd Hoffmann
2009-08-11 15:57       ` Anthony Liguori
2009-08-11 16:28         ` Gerd Hoffmann

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=1249982427-14481-1-git-send-email-kraxel@redhat.com \
    --to=kraxel@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).