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 04/22] qdev: add vlan property
Date: Wed, 21 Oct 2009 15:25:25 +0200	[thread overview]
Message-ID: <1256131543-28416-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1256131543-28416-1-git-send-email-kraxel@redhat.com>


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev-properties.c |   39 +++++++++++++++++++++++++++++++++++++++
 hw/qdev.h            |    6 ++++++
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 76925c8..c9843a2 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -282,6 +282,40 @@ PropertyInfo qdev_prop_netdev = {
     .print = print_netdev,
 };
 
+/* --- vlan --- */
+
+static int parse_vlan(DeviceState *dev, Property *prop, const char *str)
+{
+    VLANState **ptr = qdev_get_prop_ptr(dev, prop);
+    int id;
+
+    if (sscanf(str, "%d", &id) != 1)
+        return -1;
+    *ptr = qemu_find_vlan(id, 1);
+    if (*ptr == NULL)
+        return -1;
+    return 0;
+}
+
+static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)
+{
+    VLANState **ptr = qdev_get_prop_ptr(dev, prop);
+
+    if (*ptr) {
+        return snprintf(dest, len, "%d", (*ptr)->id);
+    } else {
+        return snprintf(dest, len, "<null>");
+    }
+}
+
+PropertyInfo qdev_prop_vlan = {
+    .name  = "vlan",
+    .type  = PROP_TYPE_VLAN,
+    .size  = sizeof(VLANClientState*),
+    .parse = parse_vlan,
+    .print = print_vlan,
+};
+
 /* --- pointer --- */
 
 static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len)
@@ -496,6 +530,11 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *v
     qdev_prop_set(dev, name, &value, PROP_TYPE_NETDEV);
 }
 
+void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value)
+{
+    qdev_prop_set(dev, name, &value, PROP_TYPE_VLAN);
+}
+
 void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
 {
     qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR);
diff --git a/hw/qdev.h b/hw/qdev.h
index c0d59bc..c678ab2 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -80,6 +80,7 @@ enum PropertyType {
     PROP_TYPE_DRIVE,
     PROP_TYPE_CHR,
     PROP_TYPE_NETDEV,
+    PROP_TYPE_VLAN,
     PROP_TYPE_PTR,
 };
 
@@ -191,6 +192,8 @@ extern PropertyInfo qdev_prop_chr;
 extern PropertyInfo qdev_prop_ptr;
 extern PropertyInfo qdev_prop_macaddr;
 extern PropertyInfo qdev_prop_drive;
+extern PropertyInfo qdev_prop_netdev;
+extern PropertyInfo qdev_prop_vlan;
 extern PropertyInfo qdev_prop_pci_devfn;
 
 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
@@ -230,6 +233,8 @@ extern PropertyInfo qdev_prop_pci_devfn;
     DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
 #define DEFINE_PROP_NETDEV(_n, _s, _f)             \
     DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
+#define DEFINE_PROP_VLAN(_n, _s, _f)             \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
 #define DEFINE_PROP_DRIVE(_n, _s, _f)             \
     DEFINE_PROP(_n, _s, _f, qdev_prop_drive, DriveInfo*)
 #define DEFINE_PROP_MACADDR(_n, _s, _f)         \
@@ -249,6 +254,7 @@ void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
 void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
 void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
 void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value);
+void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value);
 void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value);
 void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
 /* FIXME: Remove opaque pointer properties.  */
-- 
1.6.2.5

  parent reply	other threads:[~2009-10-21 13:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 01/22] net: add macaddr type Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 02/22] qdev: mac addr property fixups Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 03/22] qdev: add netdev property Gerd Hoffmann
2009-10-21 13:25 ` Gerd Hoffmann [this message]
2009-10-21 13:25 ` [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 06/22] ne2k_isa: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 07/22] qdev: add qdev_prop_exists() Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 08/22] prepare pci nic init path for qdev property configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 09/22] ne2k_pci: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 10/22] e1000: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 11/22] pcnet: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 12/22] pcnet: split away lance.c (sparc32 code) Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 13/22] rtl8139: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 14/22] virtio: " Gerd Hoffmann
2009-10-28 14:07   ` [Qemu-devel] [PATCH] virtio-net: fix macaddr config regression Mark McLoughlin
2009-10-21 13:25 ` [Qemu-devel] [PATCH 15/22] eepro100: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 16/22] smc91c111: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 17/22] xilinx_ethlite: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 18/22] stellaris_enet: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 19/22] musicpal: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 20/22] zap DeviceState->nd Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 21/22] kill dead nic unplug code Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 22/22] pc.c: only load e1000 rom 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=1256131543-28416-5-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).