[Qemu-devel] [PATCH 22/24] qdev-properties.c: separate core from the code used only by qemu-system-*

2012-11-09 Thread Eduardo Habkost
This separates the qdev properties code in two parts:
 - qdev-properties.c, that contains most of the qdev properties code;
 - qdev-properties-system.c for code specific for qemu-system-*,
   containing:
   - Property types: drive, chr, netdev, vlan, that depend on code that
 won't be included on *-user
   - qemu_add_globals(), that depends on qemu-config.o.

This change should help on two things:
 - Allowing DeviceState to be used by *-user without pulling
   dependencies that are specific for qemu-system-*;
 - Writing qdev unit tests without pulling too many dependencies.

The copyright/license header for the new file is directly copied from
qdev-properties.c.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
[imammedo: keep qdev_get_child_bus() in hw/qdev.c]
[imammedo: put qdev_set_nic_properties() in hw/qdev-properties-system.c]
Signed-off-by: Igor Mammedov imamm...@redhat.com
[ehabkost: updated the qdev_init_gpio_in() code on qdev-system.c to current
 version]
[ehabkost: added copyright/license information to new qdev*-system.c files]
Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Yes, there is changelog data before the --- mark, but I believe that
in this case they are important to indicate authorship and the scope of
the Signed-off-by lines (so they need to get into the git commit
message).

Detailed changelog:

Changes v1 (ehabkost) - v2 (imammedo):
 - keep qdev_get_child_bus() in hw/qdev.c
 - put qdev_set_nic_properties() in hw/qdev-properties-system.c

Changes v2 - v3 (ehabkost):
 - updated the qdev_init_gpio_in() code on qdev-system.c to current
   version

Changes v3 - v4 (ehabkost):
 - Added copyright/license information to qdev-properties-system.c
   (based on copyright/license of qdev-properties.c)
 - Whitespace change at the end of qdev-properties.c
 - Don't create qdev-system.c, now we can keep the qdev.c code as-is
   as the qdev.c dependencies were reduced
 - Rewrite patch description
---
 hw/Makefile.objs|   1 +
 hw/qdev-properties-system.c | 371 
 hw/qdev-properties.c| 321 +-
 hw/qdev-properties.h|   1 +
 hw/qdev.c   |  13 --
 5 files changed, 374 insertions(+), 333 deletions(-)
 create mode 100644 hw/qdev-properties-system.c

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index af4ab0c..4833b90 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -182,6 +182,7 @@ common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
 # xen backend driver support
diff --git a/hw/qdev-properties-system.c b/hw/qdev-properties-system.c
new file mode 100644
index 000..d7ea4e3
--- /dev/null
+++ b/hw/qdev-properties-system.c
@@ -0,0 +1,371 @@
+/*
+ * qdev property parsing and global properties
+ * (parts specific for qemu-system-*)
+ *
+ * Copyright (c) 2009-2010 Gerd Hoffmann kra...@redhat.com
+ * Copyright (c) 2009 Christoph Egger christoph.eg...@amd.com
+ * Copyright (c) 2009-2010 Blue Swirl blauwir...@gmail.com
+ * Copyright (c) 2009 Juan Quintela quint...@redhat.com
+ * Copyright (c) 2010 Michael S. Tsirkin m...@redhat.com
+ * Copyright (c) 2010,2012 Stefan Weil w...@mail.berlios.de
+ * Copyright (c) 2010-2012 Markus Armbruster arm...@redhat.com
+ * Copyright (c) 2010 Kevin Wolf kw...@redhat.com
+ * Copyright (c) 2010 Isaku Yamahata yamah...@valinux.co.jp
+ * Copyright (c) 2011 David 'Digit' Turner di...@google.com
+ * Copyright (c) 2011-2012 Amit Shah amit.s...@redhat.com
+ * Copyright (c) 2011 Kusanagi Kouichi sl...@ac.auone-net.jp
+ * Copyright (c) 2011-2012 Anthony Liguori aligu...@us.ibm.com
+ * Copyright (c) 2011 Donald Dutile ddut...@redhat.com
+ * Copyright (c) 2011-2012 Jan Kiszka jan.kis...@siemens.com
+ * Copyright (c) 2011-2012 Paolo Bonzini pbonz...@redhat.com
+ * Copyright (c) 2012 Stefan Hajnoczi stefa...@linux.vnet.ibm.com
+ * Copyright (c) 2012 dunrong huang riegama...@gmail.com
+ * Copyright (c) 2012 Michael Roth mdr...@linux.vnet.ibm.com
+ * Copyright (c) 2012 Anthony PERARD anthony.per...@citrix.com
+ * Copyright (c) 2012 Christian Borntraeger borntrae...@de.ibm.com
+ * Copyright (c) 2012 Zhi Yong Wu wu...@linux.vnet.ibm.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include net.h
+#include qdev.h
+#include qerror.h
+#include blockdev.h
+#include hw/block-common.h
+#include net/hub.h
+#include qapi/qapi-visit-core.h
+
+static void get_pointer(Object *obj, Visitor *v, Property *prop,
+const char *(*print)(void *ptr),
+const char *name, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+void **ptr = qdev_get_prop_ptr(dev, prop);
+char *p;
+
+p = (char *) (*ptr ? print(*ptr) 

[Qemu-devel] [PATCH 22/24] qdev-properties.c: separate core from the code used only by qemu-system-*

2012-11-09 Thread Eduardo Habkost
This separates the qdev properties code in two parts:
 - qdev-properties.c, that contains most of the qdev properties code;
 - qdev-properties-system.c for code specific for qemu-system-*,
   containing:
   - Property types: drive, chr, netdev, vlan, that depend on code that
 won't be included on *-user
   - qemu_add_globals(), that depends on qemu-config.o.

This change should help on two things:
 - Allowing DeviceState to be used by *-user without pulling
   dependencies that are specific for qemu-system-*;
 - Writing qdev unit tests without pulling too many dependencies.

The copyright/license header for the new file is directly copied from
qdev-properties.c.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
[imammedo: keep qdev_get_child_bus() in hw/qdev.c]
[imammedo: put qdev_set_nic_properties() in hw/qdev-properties-system.c]
Signed-off-by: Igor Mammedov imamm...@redhat.com
[ehabkost: updated the qdev_init_gpio_in() code on qdev-system.c to current
 version]
[ehabkost: added copyright/license information to new qdev*-system.c files]
Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Yes, there is changelog data before the --- mark, but I believe that
in this case they are important to indicate authorship and the scope of
the Signed-off-by lines (so they need to get into the git commit
message).

Detailed changelog:

Changes v1 (ehabkost) - v2 (imammedo):
 - keep qdev_get_child_bus() in hw/qdev.c
 - put qdev_set_nic_properties() in hw/qdev-properties-system.c

Changes v2 - v3 (ehabkost):
 - updated the qdev_init_gpio_in() code on qdev-system.c to current
   version

Changes v3 - v4 (ehabkost):
 - Added copyright/license information to qdev-properties-system.c
   (based on copyright/license of qdev-properties.c)
 - Whitespace change at the end of qdev-properties.c
 - Don't create qdev-system.c, now we can keep the qdev.c code as-is
   as the qdev.c dependencies were reduced
 - Rewrite patch description
---
 hw/Makefile.objs|   1 +
 hw/qdev-properties-system.c | 371 
 hw/qdev-properties.c| 321 +-
 hw/qdev-properties.h|   1 +
 hw/qdev.c   |  13 --
 5 files changed, 374 insertions(+), 333 deletions(-)
 create mode 100644 hw/qdev-properties-system.c

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index af4ab0c..4833b90 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -182,6 +182,7 @@ common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
 # xen backend driver support
diff --git a/hw/qdev-properties-system.c b/hw/qdev-properties-system.c
new file mode 100644
index 000..d7ea4e3
--- /dev/null
+++ b/hw/qdev-properties-system.c
@@ -0,0 +1,371 @@
+/*
+ * qdev property parsing and global properties
+ * (parts specific for qemu-system-*)
+ *
+ * Copyright (c) 2009-2010 Gerd Hoffmann kra...@redhat.com
+ * Copyright (c) 2009 Christoph Egger christoph.eg...@amd.com
+ * Copyright (c) 2009-2010 Blue Swirl blauwir...@gmail.com
+ * Copyright (c) 2009 Juan Quintela quint...@redhat.com
+ * Copyright (c) 2010 Michael S. Tsirkin m...@redhat.com
+ * Copyright (c) 2010,2012 Stefan Weil w...@mail.berlios.de
+ * Copyright (c) 2010-2012 Markus Armbruster arm...@redhat.com
+ * Copyright (c) 2010 Kevin Wolf kw...@redhat.com
+ * Copyright (c) 2010 Isaku Yamahata yamah...@valinux.co.jp
+ * Copyright (c) 2011 David 'Digit' Turner di...@google.com
+ * Copyright (c) 2011-2012 Amit Shah amit.s...@redhat.com
+ * Copyright (c) 2011 Kusanagi Kouichi sl...@ac.auone-net.jp
+ * Copyright (c) 2011-2012 Anthony Liguori aligu...@us.ibm.com
+ * Copyright (c) 2011 Donald Dutile ddut...@redhat.com
+ * Copyright (c) 2011-2012 Jan Kiszka jan.kis...@siemens.com
+ * Copyright (c) 2011-2012 Paolo Bonzini pbonz...@redhat.com
+ * Copyright (c) 2012 Stefan Hajnoczi stefa...@linux.vnet.ibm.com
+ * Copyright (c) 2012 dunrong huang riegama...@gmail.com
+ * Copyright (c) 2012 Michael Roth mdr...@linux.vnet.ibm.com
+ * Copyright (c) 2012 Anthony PERARD anthony.per...@citrix.com
+ * Copyright (c) 2012 Christian Borntraeger borntrae...@de.ibm.com
+ * Copyright (c) 2012 Zhi Yong Wu wu...@linux.vnet.ibm.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include net.h
+#include qdev.h
+#include qerror.h
+#include blockdev.h
+#include hw/block-common.h
+#include net/hub.h
+#include qapi/qapi-visit-core.h
+
+static void get_pointer(Object *obj, Visitor *v, Property *prop,
+const char *(*print)(void *ptr),
+const char *name, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+void **ptr = qdev_get_prop_ptr(dev, prop);
+char *p;
+
+p = (char *) (*ptr ? print(*ptr) 

[Qemu-devel] [PATCH 22/24] qdev-properties.c: separate core from the code used only by qemu-system-*

2012-10-23 Thread Eduardo Habkost
This separates the qdev properties code in two parts:
 - qdev-properties.c, that contains most of the qdev properties code;
 - qdev-properties-system.c for code specific for qemu-system-*,
   containing:
   - Property types: drive, chr, netdev, vlan, that depend on code that
 won't be included on *-user
   - qemu_add_globals(), that depends on qemu-config.o.

This change should help on two things:
 - Allowing DeviceState to be used by *-user without pulling
   dependencies that are specific for qemu-system-*;
 - Writing qdev unit tests without pulling too many dependencies.

The copyright/license header for the new file is directly copied from
qdev-properties.c.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
[imammedo: keep qdev_get_child_bus() in hw/qdev.c]
[imammedo: put qdev_set_nic_properties() in hw/qdev-properties-system.c]
Signed-off-by: Igor Mammedov imamm...@redhat.com
[ehabkost: updated the qdev_init_gpio_in() code on qdev-system.c to current
 version]
[ehabkost: added copyright/license information to new qdev*-system.c files]
Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Yes, there is changelog data before the --- mark, but I believe that
in this case they are important to indicate authorship and the scope of
the Signed-off-by lines (so they need to get into the git commit
message).

Detailed changelog:

Changes v1 (ehabkost) - v2 (imammedo):
 - keep qdev_get_child_bus() in hw/qdev.c
 - put qdev_set_nic_properties() in hw/qdev-properties-system.c

Changes v2 - v3 (ehabkost):
 - updated the qdev_init_gpio_in() code on qdev-system.c to current
   version

Changes v3 - v4 (ehabkost):
 - Added copyright/license information to qdev-properties-system.c
   (based on copyright/license of qdev-properties.c)
 - Whitespace change at the end of qdev-properties.c
 - Don't create qdev-system.c, now we can keep the qdev.c code as-is
   as the qdev.c dependencies were reduced
 - Rewrite patch description
---
 hw/Makefile.objs|   1 +
 hw/qdev-properties-system.c | 371 
 hw/qdev-properties.c| 321 +-
 hw/qdev-properties.h|   1 +
 hw/qdev.c   |  13 --
 5 files changed, 374 insertions(+), 333 deletions(-)
 create mode 100644 hw/qdev-properties-system.c

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index af4ab0c..4833b90 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -182,6 +182,7 @@ common-obj-y += bt.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o qdev-monitor.o
+common-obj-y += qdev-properties-system.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 
 # xen backend driver support
diff --git a/hw/qdev-properties-system.c b/hw/qdev-properties-system.c
new file mode 100644
index 000..d7ea4e3
--- /dev/null
+++ b/hw/qdev-properties-system.c
@@ -0,0 +1,371 @@
+/*
+ * qdev property parsing and global properties
+ * (parts specific for qemu-system-*)
+ *
+ * Copyright (c) 2009-2010 Gerd Hoffmann kra...@redhat.com
+ * Copyright (c) 2009 Christoph Egger christoph.eg...@amd.com
+ * Copyright (c) 2009-2010 Blue Swirl blauwir...@gmail.com
+ * Copyright (c) 2009 Juan Quintela quint...@redhat.com
+ * Copyright (c) 2010 Michael S. Tsirkin m...@redhat.com
+ * Copyright (c) 2010,2012 Stefan Weil w...@mail.berlios.de
+ * Copyright (c) 2010-2012 Markus Armbruster arm...@redhat.com
+ * Copyright (c) 2010 Kevin Wolf kw...@redhat.com
+ * Copyright (c) 2010 Isaku Yamahata yamah...@valinux.co.jp
+ * Copyright (c) 2011 David 'Digit' Turner di...@google.com
+ * Copyright (c) 2011-2012 Amit Shah amit.s...@redhat.com
+ * Copyright (c) 2011 Kusanagi Kouichi sl...@ac.auone-net.jp
+ * Copyright (c) 2011-2012 Anthony Liguori aligu...@us.ibm.com
+ * Copyright (c) 2011 Donald Dutile ddut...@redhat.com
+ * Copyright (c) 2011-2012 Jan Kiszka jan.kis...@siemens.com
+ * Copyright (c) 2011-2012 Paolo Bonzini pbonz...@redhat.com
+ * Copyright (c) 2012 Stefan Hajnoczi stefa...@linux.vnet.ibm.com
+ * Copyright (c) 2012 dunrong huang riegama...@gmail.com
+ * Copyright (c) 2012 Michael Roth mdr...@linux.vnet.ibm.com
+ * Copyright (c) 2012 Anthony PERARD anthony.per...@citrix.com
+ * Copyright (c) 2012 Christian Borntraeger borntrae...@de.ibm.com
+ * Copyright (c) 2012 Zhi Yong Wu wu...@linux.vnet.ibm.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include net.h
+#include qdev.h
+#include qerror.h
+#include blockdev.h
+#include hw/block-common.h
+#include net/hub.h
+#include qapi/qapi-visit-core.h
+
+static void get_pointer(Object *obj, Visitor *v, Property *prop,
+const char *(*print)(void *ptr),
+const char *name, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+void **ptr = qdev_get_prop_ptr(dev, prop);
+char *p;
+
+p = (char *) (*ptr ? print(*ptr)