Re: [Qemu-devel] [Qemu-trivial] [PATCH] misc: Use g_assert_not_reached for code which is expected to be unreachable

2013-07-27 Thread Michael Tokarev
25.07.2013 20:21, Stefan Weil wrote:
 The macro g_assert_not_reached is a better self documenting replacement
 for assert(0) or assert(false).

Thanks, applied to the trivial patches queue.

/mjt



Re: [Qemu-devel] [Qemu-trivial] [PATCH] target-mips: Remove assignment to a variable which is never used

2013-07-27 Thread Michael Tokarev
26.07.2013 00:10, Stefan Weil wrote:
 This assignment causes a compiler warning for compilations with the compiler
 option -Wunused-but-set-variable (which is included with -Wextra).
 
 Removing it allows using -Wextra for QEMU code without suppressing too many
 extra warnings.

Thanks, applied to the trivial patches queue.

/mjt



[Qemu-devel] [PULL trivial 07/11] linux-user: correct argument number for sys_mremap and sys_splice

2013-07-27 Thread Michael Tokarev
From: Petar Jovanovic petar.jovano...@imgtec.com

sys_mremap missed 5th argument (new_address), which caused examples that
remap to a specific address to fail.
sys_splice missed 5th and 6th argument which caused different examples to
fail.
This change has an effect on MIPS target only.

Signed-off-by: Petar Jovanovic petar.jovano...@imgtec.com
Reviewed-by: Peter Maydell peter.mayd...@linaro.org
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 linux-user/main.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 5309117..03859bc 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1920,7 +1920,7 @@ static const uint8_t mips_syscall_args[] = {
MIPS_SYS(sys_sched_get_priority_min, 1)
MIPS_SYS(sys_sched_rr_get_interval, 2)  /* 4165 */
MIPS_SYS(sys_nanosleep, 2)
-   MIPS_SYS(sys_mremap , 4)
+   MIPS_SYS(sys_mremap , 5)
MIPS_SYS(sys_accept , 3)
MIPS_SYS(sys_bind   , 3)
MIPS_SYS(sys_connect, 3)/* 4170 */
@@ -2057,7 +2057,7 @@ static const uint8_t mips_syscall_args[] = {
MIPS_SYS(sys_pselect6, 6)
MIPS_SYS(sys_ppoll, 5)
MIPS_SYS(sys_unshare, 1)
-   MIPS_SYS(sys_splice, 4)
+   MIPS_SYS(sys_splice, 6)
MIPS_SYS(sys_sync_file_range, 7) /* 4305 */
MIPS_SYS(sys_tee, 4)
MIPS_SYS(sys_vmsplice, 4)
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 01/11] aes: Remove unused code (NDEBUG, u16)

2013-07-27 Thread Michael Tokarev
From: Stefan Weil s...@weilnetz.de

The current code includes assert.h very early (from qemu-common.h),
so the definition of NDEBUG was without any effect.

In the initial version from 2004, NDEBUG was used to disable the assertions.
Those assertions are not in time critical code, so it is no longer
reasonable to disable them and the definition of NDEBUG can be removed.

Type u16 is also unused and therefore does not need a type definition.

Signed-off-by: Stefan Weil s...@weilnetz.de
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 util/aes.c |5 -
 1 file changed, 5 deletions(-)

diff --git a/util/aes.c b/util/aes.c
index 91e97fa..4b4d88e 100644
--- a/util/aes.c
+++ b/util/aes.c
@@ -30,12 +30,7 @@
 #include qemu-common.h
 #include qemu/aes.h
 
-#ifndef NDEBUG
-#define NDEBUG
-#endif
-
 typedef uint32_t u32;
-typedef uint16_t u16;
 typedef uint8_t u8;
 
 /* This controls loop-unrolling in aes_core.c */
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 11/11] target-mips: Remove assignment to a variable which is never used

2013-07-27 Thread Michael Tokarev
From: Stefan Weil s...@weilnetz.de

This assignment causes a compiler warning for compilations with the compiler
option -Wunused-but-set-variable (which is included with -Wextra).

Removing it allows using -Wextra for QEMU code without suppressing too many
extra warnings.

Signed-off-by: Stefan Weil s...@weilnetz.de
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 target-mips/op_helper.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 5cf1c3f..b828375 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -1735,7 +1735,6 @@ target_ulong helper_evpe(CPUMIPSState *env)
 void helper_fork(target_ulong arg1, target_ulong arg2)
 {
 // arg1 = rt, arg2 = rs
-arg1 = 0;
 // TODO: store to TC register
 }
 
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 02/11] timer: make timers_state static

2013-07-27 Thread Michael Tokarev
From: Liu Ping Fan qemul...@gmail.com

Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com
Reviewed-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 cpus.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index ca6b886..0f65e76 100644
--- a/cpus.c
+++ b/cpus.c
@@ -112,7 +112,7 @@ typedef struct TimersState {
 int64_t dummy;
 } TimersState;
 
-TimersState timers_state;
+static TimersState timers_state;
 
 /* Return the virtual CPU time, based on the instruction counter.  */
 int64_t cpu_get_icount(void)
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 00/11] trivial patches for 2013-07-27

2013-07-27 Thread Michael Tokarev
We collected a few more trivial patches this week, including a compile
failure fix for 32bit builds by Stefan Weil.

Please pull.

The following changes since commit 200a06397f5d3e982028fd78b25b420507ade021:

  Merge remote-tracking branch 'afaerber/tags/qom-cpu-for-anthony' into staging 
(2013-07-26 17:53:19 -0500)

are available in the git repository at:


  git://git.corpit.ru/qemu.git trivial-patches

for you to fetch changes up to 6c86f405efd6532b58ad1b607cc9f11e856ef5ca:

  target-mips: Remove assignment to a variable which is never used (2013-07-27 
11:22:54 +0400)


Liu Ping Fan (1):
  timer: make timers_state static

Petar Jovanovic (1):
  linux-user: correct argument number for sys_mremap and sys_splice

Ramkumar Ramachandra (1):
  qemu-options: mention C-a h in the -nographic doc

Stefan Weil (8):
  aes: Remove unused code (NDEBUG, u16)
  hw/9pfs: Fix potential memory leak and avoid reuse of freed memory
  exec: Remove env from list of poisoned names
  watchdog: Remove break after exit
  PPC: dbdma: macio: Fix format specifiers (build regression)
  misc: Fix new typos in comments and strings
  misc: Use g_assert_not_reached for code which is expected to be 
unreachable
  target-mips: Remove assignment to a variable which is never used

 block/vhdx.h   |2 +-
 blockdev.c |2 +-
 cpus.c |2 +-
 docs/rdma.txt  |2 +-
 hw/9pfs/virtio-9p-proxy.c  |2 ++
 hw/ide/macio.c |9 +
 hw/net/vmxnet3.c   |   16 
 hw/net/vmxnet_tx_pkt.c |2 +-
 hw/usb/hcd-ehci.c  |8 
 hw/virtio/virtio-balloon.c |4 ++--
 hw/watchdog/watchdog.c |1 -
 hw/xen/xen_pt.c|3 ++-
 include/exec/poison.h  |1 -
 linux-user/main.c  |4 ++--
 migration-rdma.c   |4 ++--
 net/eth.c  |2 +-
 qdev-monitor.c |4 ++--
 qemu-options.hx|3 ++-
 target-arm/helper.c|2 +-
 target-mips/op_helper.c|1 -
 tests/test-qmp-input-visitor.c |2 +-
 tests/test-qmp-output-visitor.c|4 ++--
 tests/test-visitor-serialization.c |8 
 util/aes.c |5 -
 24 files changed, 45 insertions(+), 48 deletions(-)



[Qemu-devel] [PULL trivial 04/11] exec: Remove env from list of poisoned names

2013-07-27 Thread Michael Tokarev
From: Stefan Weil s...@weilnetz.de

The global variable env was removed some time ago, so this name may be
used without any restriction now.

Signed-off-by: Stefan Weil s...@weilnetz.de
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 include/exec/poison.h |1 -
 1 file changed, 1 deletion(-)

diff --git a/include/exec/poison.h b/include/exec/poison.h
index 2341a75..a4b1eca 100644
--- a/include/exec/poison.h
+++ b/include/exec/poison.h
@@ -36,7 +36,6 @@
 #pragma GCC poison TARGET_PAGE_ALIGN
 
 #pragma GCC poison CPUArchState
-#pragma GCC poison env
 
 #pragma GCC poison lduw_phys
 #pragma GCC poison ldl_phys
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 08/11] misc: Fix new typos in comments and strings

2013-07-27 Thread Michael Tokarev
From: Stefan Weil s...@weilnetz.de

All these typos were found by codespell.

sould - should
emperical - empirical
intialization - initialization
successfuly - successfully
gaurantee - guarantee

Fix also another error (before before) in the same context.

Signed-off-by: Stefan Weil s...@weilnetz.de
Reviewed-by: Peter Maydell peter.mayd...@linaro.org
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 block/vhdx.h   |2 +-
 docs/rdma.txt  |2 +-
 hw/virtio/virtio-balloon.c |4 ++--
 hw/xen/xen_pt.c|3 ++-
 migration-rdma.c   |4 ++--
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/block/vhdx.h b/block/vhdx.h
index c3b64c6..fb687ed 100644
--- a/block/vhdx.h
+++ b/block/vhdx.h
@@ -168,7 +168,7 @@ typedef struct QEMU_PACKED VHDXLogEntryHeader {
vhdx_header.  If not found in
vhdx_header, it is invalid */
 uint64_tflushed_file_offset;/* see spec for full details - this
-   sould be vhdx file size in bytes */
+   should be vhdx file size in bytes */
 uint64_tlast_file_offset;   /* size in bytes that all allocated
file structures fit into */
 } VHDXLogEntryHeader;
diff --git a/docs/rdma.txt b/docs/rdma.txt
index 45d1c8a..8d1e003 100644
--- a/docs/rdma.txt
+++ b/docs/rdma.txt
@@ -199,7 +199,7 @@ Version #1 requires that all server implementations of the 
protocol must
 check this field and register all requests found in the array of commands 
located
 in the data portion and return an equal number of results in the response.
 The maximum number of repeats is hard-coded to 4096. This is a conservative
-limit based on the maximum size of a SEND message along with emperical
+limit based on the maximum size of a SEND message along with empirical
 observations on the maximum future benefit of simultaneous page registrations.
 
 The 'type' field has 12 different command values:
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 3fa72a9..337cfa5 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -53,8 +53,8 @@ static const char *balloon_stat_names[] = {
 /*
  * reset_stats - Mark all items in the stats array as unset
  *
- * This function needs to be called at device intialization and before
- * before updating to a set of newly-generated stats.  This will ensure that no
+ * This function needs to be called at device initialization and before
+ * updating to a set of newly-generated stats.  This will ensure that no
  * stale values stick around in case the guest reports a subset of the 
supported
  * statistics.
  */
diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index d7ee774..d15a729 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -756,7 +756,8 @@ static int xen_pt_initfn(PCIDevice *d)
 out:
 memory_listener_register(s-memory_listener, address_space_memory);
 memory_listener_register(s-io_listener, address_space_io);
-XEN_PT_LOG(d, Real physical device %02x:%02x.%d registered 
successfuly!\n,
+XEN_PT_LOG(d,
+   Real physical device %02x:%02x.%d registered successfully!\n,
s-hostaddr.bus, s-hostaddr.slot, s-hostaddr.function);
 
 return 0;
diff --git a/migration-rdma.c b/migration-rdma.c
index d044830..4828738 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -2494,7 +2494,7 @@ static int qemu_rdma_close(void *opaque)
  *@size == 0 :
  *A 'hint' or 'advice' that means that we wish to speculatively
  *and asynchronously unregister this memory. In this case, there is no
- *gaurantee that the unregister will actually happen, for example,
+ *guarantee that the unregister will actually happen, for example,
  *if the memory is being actively transmitted. Additionally, the memory
  *may be re-registered at any future time if a write within the same
  *chunk was requested again, even if you attempted to unregister it
@@ -2570,7 +2570,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, void 
*opaque,
 qemu_rdma_signal_unregister(rdma, index, chunk, 0);
 
 /*
- * TODO: Synchronous, gauranteed unregistration (should not occur 
during
+ * TODO: Synchronous, guaranteed unregistration (should not occur 
during
  * fast-path). Otherwise, unregisters will process on the next call to
  * qemu_rdma_drain_cq()
 if (size  0) {
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 09/11] qemu-options: mention C-a h in the -nographic doc

2013-07-27 Thread Michael Tokarev
From: Ramkumar Ramachandra artag...@gmail.com

Otherwise, a new user will be wondering how to switch between the
console and monitor.

Cc: Anthony Liguori aligu...@us.ibm.com
Cc: Stefan Hajnoczi stefa...@redhat.com
Cc: Markus Armbruster arm...@redhat.com
Cc: Marcelo Tosatti mtosa...@redhat.com
Cc: Peter Maydell peter.mayd...@linaro.org
Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 qemu-options.hx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 2dbfd42..25ecb55 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -844,7 +844,8 @@ you can totally disable graphical output so that QEMU is a 
simple
 command line application. The emulated serial port is redirected on
 the console and muxed with the monitor (unless redirected elsewhere
 explicitly). Therefore, you can still use QEMU to debug a Linux kernel
-with a serial console.
+with a serial console.  Use @key{C-a h} for help on switching between
+the console and monitor.
 ETEXI
 
 DEF(curses, 0, QEMU_OPTION_curses,
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 06/11] PPC: dbdma: macio: Fix format specifiers (build regression)

2013-07-27 Thread Michael Tokarev
From: Stefan Weil s...@weilnetz.de

Fix a number of warnings for 32 bit builds (tested on MingW and Linux):

  CChw/ide/macio.o
qemu/hw/ide/macio.c: In function 'pmac_ide_atapi_transfer_cb':
qemu/hw/ide/macio.c:134:9: error: format '%lx' expects argument of type 'long 
unsigned int', but argument 3 has type 'hwaddr' [-Werror=format]
qemu/hw/ide/macio.c: In function 'pmac_ide_transfer_cb':
qemu/hw/ide/macio.c:215:5: error: format '%ld' expects argument of type 'long 
int', but argument 5 has type 'int64_t' [-Werror=format]
qemu/hw/ide/macio.c:222:9: error: format '%lx' expects argument of type 'long 
unsigned int', but argument 3 has type 'hwaddr' [-Werror=format]
qemu/hw/ide/macio.c:264:9: error: format '%lx' expects argument of type 'long 
unsigned int', but argument 3 has type 'hwaddr' [-Werror=format]
cc1: all warnings being treated as errors
make: *** [hw/ide/macio.o] Error 1

Signed-off-by: Stefan Weil s...@weilnetz.de
Acked-by: Alexander Graf ag...@suse.de
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 hw/ide/macio.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index 38ad924..ef4ba2b 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -131,7 +131,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int 
ret)
 int sector_num = (s-lba  2) + (s-io_buffer_index  9);
 int nsector = io-len  9;
 
-MACIO_DPRINTF(precopying unaligned %d bytes to %#lx\n,
+MACIO_DPRINTF(precopying unaligned %d bytes to %# HWADDR_PRIx \n,
   unaligned, io-addr + io-len - unaligned);
 
 bdrv_read(s-bs, sector_num + nsector, io-remainder, 1);
@@ -212,14 +212,15 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
 s-nsector -= n;
 }
 
-MACIO_DPRINTF(remainder: %d io-len: %d nsector: %d sector_num: %ld\n,
+MACIO_DPRINTF(remainder: %d io-len: %d nsector: %d 
+  sector_num: % PRId64 \n,
   io-remainder_len, io-len, s-nsector, sector_num);
 if (io-remainder_len  io-len) {
 /* guest wants the rest of its previous transfer */
 int remainder_len = MIN(io-remainder_len, io-len);
 uint8_t *p = io-remainder[0x200 - remainder_len];
 
-MACIO_DPRINTF(copying remainder %d bytes at %#lx\n,
+MACIO_DPRINTF(copying remainder %d bytes at %# HWADDR_PRIx \n,
   remainder_len, io-addr);
 
 switch (s-dma_cmd) {
@@ -261,7 +262,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
 if (unaligned) {
 int nsector = io-len  9;
 
-MACIO_DPRINTF(precopying unaligned %d bytes to %#lx\n,
+MACIO_DPRINTF(precopying unaligned %d bytes to %# HWADDR_PRIx \n,
   unaligned, io-addr + io-len - unaligned);
 
 switch (s-dma_cmd) {
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 03/11] hw/9pfs: Fix potential memory leak and avoid reuse of freed memory

2013-07-27 Thread Michael Tokarev
From: Stefan Weil s...@weilnetz.de

The leak was reported by cppcheck.

Function proxy_init also calls g_free for ctx-fs_root.
Avoid reuse of this memory by setting ctx-fs_root to NULL.

Signed-off-by: Stefan Weil s...@weilnetz.de
Reviewed-by: M. Mohan Kumar mo...@in.ibm.com
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 hw/9pfs/virtio-9p-proxy.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 8ba2959..5f44bb7 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -1153,10 +1153,12 @@ static int proxy_init(FsContext *ctx)
 sock_id = atoi(ctx-fs_root);
 if (sock_id  0) {
 fprintf(stderr, socket descriptor not initialized\n);
+g_free(proxy);
 return -1;
 }
 }
 g_free(ctx-fs_root);
+ctx-fs_root = NULL;
 
 proxy-in_iovec.iov_base  = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
 proxy-in_iovec.iov_len   = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
-- 
1.7.10.4




[Qemu-devel] [PULL trivial 10/11] misc: Use g_assert_not_reached for code which is expected to be unreachable

2013-07-27 Thread Michael Tokarev
From: Stefan Weil s...@weilnetz.de

The macro g_assert_not_reached is a better self documenting replacement
for assert(0) or assert(false).

Signed-off-by: Stefan Weil s...@weilnetz.de
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 blockdev.c |2 +-
 hw/net/vmxnet3.c   |   16 
 hw/net/vmxnet_tx_pkt.c |2 +-
 hw/usb/hcd-ehci.c  |8 
 net/eth.c  |2 +-
 qdev-monitor.c |4 ++--
 target-arm/helper.c|2 +-
 tests/test-qmp-input-visitor.c |2 +-
 tests/test-qmp-output-visitor.c|4 ++--
 tests/test-visitor-serialization.c |8 
 10 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 4534864..7879e85 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1029,7 +1029,7 @@ static void abort_prepare(BlkTransactionState *common, 
Error **errp)
 
 static void abort_commit(BlkTransactionState *common)
 {
-assert(false); /* this action never succeeds */
+g_assert_not_reached(); /* this action never succeeds */
 }
 
 static const BdrvActionOps actions[] = {
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index b39ff08..0f3c58c 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -528,7 +528,7 @@ vmxnet3_setup_tx_offloads(VMXNET3State *s)
 break;
 
 default:
-assert(false);
+g_assert_not_reached();
 return false;
 }
 
@@ -575,7 +575,7 @@ vmxnet3_on_tx_done_update_stats(VMXNET3State *s, int qidx,
 stats-ucastBytesTxOK += tot_len;
 break;
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 if (s-offload_mode == VMXNET3_OM_TSO) {
@@ -599,7 +599,7 @@ vmxnet3_on_tx_done_update_stats(VMXNET3State *s, int qidx,
 break;
 
 default:
-assert(false);
+g_assert_not_reached();
 }
 }
 
@@ -634,7 +634,7 @@ vmxnet3_on_rx_done_update_stats(VMXNET3State *s,
 stats-ucastBytesRxOK += tot_len;
 break;
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 if (tot_len  s-mtu) {
@@ -643,7 +643,7 @@ vmxnet3_on_rx_done_update_stats(VMXNET3State *s,
 }
 break;
 default:
-assert(false);
+g_assert_not_reached();
 }
 }
 
@@ -1106,7 +1106,7 @@ vmxnet3_io_bar0_read(void *opaque, hwaddr addr, unsigned 
size)
 {
 if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_IMR,
 VMXNET3_MAX_INTRS, VMXNET3_REG_ALIGN)) {
-assert(false);
+g_assert_not_reached();
 }
 
 VMW_CBPRN(BAR0 unknown read [% PRIx64 ], size %d, addr, size);
@@ -1651,7 +1651,7 @@ vmxnet3_io_bar1_write(void *opaque,
 case VMXNET3_REG_ICR:
 VMW_CBPRN(Write BAR1 [VMXNET3_REG_ICR] = % PRIx64 , size %d,
   val, size);
-assert(false);
+g_assert_not_reached();
 break;
 
 /* Event Cause Register */
@@ -1801,7 +1801,7 @@ vmxnet3_rx_filter_may_indicate(VMXNET3State *s, const 
void *data,
 break;
 
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return true;
diff --git a/hw/net/vmxnet_tx_pkt.c b/hw/net/vmxnet_tx_pkt.c
index fc01e4d..f7344c4 100644
--- a/hw/net/vmxnet_tx_pkt.c
+++ b/hw/net/vmxnet_tx_pkt.c
@@ -287,7 +287,7 @@ void vmxnet_tx_pkt_build_vheader(struct VmxnetTxPkt *pkt, 
bool tso_enable,
 break;
 
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 if (csum_enable) {
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 67e4b24..010a0d0 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -1357,7 +1357,7 @@ static void ehci_execute_complete(EHCIQueue *q)
 default:
 /* should not be triggerable */
 fprintf(stderr, USB invalid response %d\n, p-packet.status);
-assert(0);
+g_assert_not_reached();
 break;
 }
 
@@ -2142,7 +2142,7 @@ static void ehci_advance_state(EHCIState *ehci, int async)
 default:
 fprintf(stderr, Bad state!\n);
 again = -1;
-assert(0);
+g_assert_not_reached();
 break;
 }
 
@@ -2206,7 +2206,7 @@ static void ehci_advance_async_state(EHCIState *ehci)
 /* this should only be due to a developer mistake */
 fprintf(stderr, ehci: Bad asynchronous state %d. 
 Resetting to active\n, ehci-astate);
-assert(0);
+g_assert_not_reached();
 }
 }
 
@@ -2256,7 +2256,7 @@ static void ehci_advance_periodic_state(EHCIState *ehci)
 /* this should only be due to a developer mistake */
 fprintf(stderr, ehci: Bad periodic state %d. 
 Resetting to active\n, ehci-pstate);
-assert(0);
+g_assert_not_reached();
 }
 }
 
diff --git a/net/eth.c b/net/eth.c
index 1d7494d..7c61132 100644
--- a/net/eth.c

[Qemu-devel] [PULL trivial 05/11] watchdog: Remove break after exit

2013-07-27 Thread Michael Tokarev
From: Stefan Weil s...@weilnetz.de

This was dead code.

Signed-off-by: Stefan Weil s...@weilnetz.de
Reviewed-by: Andreas Färber afaer...@suse.de
Signed-off-by: Michael Tokarev m...@tls.msk.ru
---
 hw/watchdog/watchdog.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index cb4e1f9..387962e 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -128,7 +128,6 @@ void watchdog_perform_action(void)
 case WDT_POWEROFF:  /* same as 'quit' command in monitor */
 watchdog_mon_event(poweroff);
 exit(0);
-break;
 
 case WDT_PAUSE: /* same as 'stop' command in monitor */
 watchdog_mon_event(pause);
-- 
1.7.10.4




Re: [Qemu-devel] vm performance degradation after kvm live migration or save-restore with ETP enabled

2013-07-27 Thread Zhanghaoyu (A)
 hi all,
 
 I met similar problem to these, while performing live migration or 
 save-restore test on the kvm platform (qemu:1.4.0, host:suse11sp2, 
 guest:suse11sp2), running tele-communication software suite in guest, 
 https://lists.gnu.org/archive/html/qemu-devel/2013-05/msg00098.html
 http://comments.gmane.org/gmane.comp.emulators.kvm.devel/102506
 http://thread.gmane.org/gmane.comp.emulators.kvm.devel/100592
 https://bugzilla.kernel.org/show_bug.cgi?id=58771
 
 After live migration or virsh restore [savefile], one process's CPU 
 utilization went up by about 30%, resulted in throughput degradation 
 of this process.
 
 If EPT disabled, this problem gone.
 
 I suspect that kvm hypervisor has business with this problem.
 Based on above suspect, I want to find the two adjacent versions of 
 kvm-kmod which triggers this problem or not (e.g. 2.6.39, 3.0-rc1), 
 and analyze the differences between this two versions, or apply the 
 patches between this two versions by bisection method, finally find the key 
 patches.
 
 Any better ideas?
 
 Thanks,
 Zhang Haoyu

I've attempted to duplicate this on a number of machines that are as similar 
to yours as I am able to get my hands on, and so far have not been able to see 
any performance degradation. And from what I've read in the above links, huge 
pages do not seem to be part of the problem.

So, if you are in a position to bisect the kernel changes, that would probably 
be the best avenue to pursue in my opinion.

Bruce

I found the first bad commit([612819c3c6e67bac8fceaa7cc402f13b1b63f7e4] KVM: 
propagate fault r/w information to gup(), allow read-only memory) which 
triggers this problem 
by git bisecting the kvm kernel (download from 
https://git.kernel.org/pub/scm/virt/kvm/kvm.git) changes.

And, 
git log 612819c3c6e67bac8fceaa7cc402f13b1b63f7e4 -n 1 -p  
612819c3c6e67bac8fceaa7cc402f13b1b63f7e4.log
git diff 
612819c3c6e67bac8fceaa7cc402f13b1b63f7e4~1..612819c3c6e67bac8fceaa7cc402f13b1b63f7e4
  612819c3c6e67bac8fceaa7cc402f13b1b63f7e4.diff

Then, I diffed 612819c3c6e67bac8fceaa7cc402f13b1b63f7e4.log and 
612819c3c6e67bac8fceaa7cc402f13b1b63f7e4.diff, 
came to a conclusion that all of the differences between 
612819c3c6e67bac8fceaa7cc402f13b1b63f7e4~1 and 
612819c3c6e67bac8fceaa7cc402f13b1b63f7e4
are contributed by no other than 612819c3c6e67bac8fceaa7cc402f13b1b63f7e4, so 
this commit is the peace-breaker which directly or indirectly causes the 
degradation.

Does the map_writable flag passed to mmu_set_spte() function have effect on 
PTE's PAT flag or increase the VMEXITs induced by that guest tried to write 
read-only memory?

Thanks,
Zhang Haoyu





Re: [Qemu-devel] ioport: qemu-system-sparc64 currently broken

2013-07-27 Thread Paolo Bonzini
Il 27/07/2013 00:21, Mark Cave-Ayland ha scritto:
 I suspect that there may be multiple breakages here (as HEAD blows up
 differently with a trap failure), but this is definitely the start of
 the chain.

Yes, the fixes so far are the following:

commit 2b8fbcd87007a170a9778ec6645c06f543977067
commit 5519ad0c245860526e8d269e1cd20fe239447736
commit e11ef3d184c88a316f48ba2472dcb2937d9fa24b
commit 547e9201c52629eef71b0eb8cb48dacc50bcf759
commit e7342aa39b3193473ded24cbf2233930665796e9

but something else remains.

I'll try to debug it during the hard freeze period.

Paolo



[Qemu-devel] [PATCH qom-next for-1.6 1/2] ds1225y: Drop bogus qdev field from NvRamState

2013-07-27 Thread Andreas Färber
It is not a device, and the field is not used from code either.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/nvram/ds1225y.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c
index fa218ce..cca6f43 100644
--- a/hw/nvram/ds1225y.c
+++ b/hw/nvram/ds1225y.c
@@ -26,7 +26,6 @@
 #include trace.h
 
 typedef struct {
-DeviceState qdev;
 MemoryRegion iomem;
 uint32_t chip_size;
 char *filename;
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 2/2] ds1225y: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/nvram/ds1225y.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c
index cca6f43..f9a700b 100644
--- a/hw/nvram/ds1225y.c
+++ b/hw/nvram/ds1225y.c
@@ -104,14 +104,19 @@ static const VMStateDescription vmstate_nvram = {
 }
 };
 
+#define TYPE_DS1225Y ds1225y
+#define DS1225Y(obj) OBJECT_CHECK(SysBusNvRamState, (obj), TYPE_DS1225Y)
+
 typedef struct {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 NvRamState nvram;
 } SysBusNvRamState;
 
 static int nvram_sysbus_initfn(SysBusDevice *dev)
 {
-NvRamState *s = FROM_SYSBUS(SysBusNvRamState, dev)-nvram;
+SysBusNvRamState *sys = DS1225Y(dev);
+NvRamState *s = sys-nvram;
 FILE *file;
 
 s-contents = g_malloc0(s-chip_size);
@@ -151,7 +156,7 @@ static void nvram_sysbus_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo nvram_sysbus_info = {
-.name  = ds1225y,
+.name  = TYPE_DS1225Y,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(SysBusNvRamState),
 .class_init= nvram_sysbus_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 06/11] milkymist-minimac2: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/milkymist-minimac2.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/hw/net/milkymist-minimac2.c b/hw/net/milkymist-minimac2.c
index becd26c..1e92379 100644
--- a/hw/net/milkymist-minimac2.c
+++ b/hw/net/milkymist-minimac2.c
@@ -90,8 +90,13 @@ struct MilkymistMinimac2MdioState {
 };
 typedef struct MilkymistMinimac2MdioState MilkymistMinimac2MdioState;
 
+#define TYPE_MILKYMIST_MINIMAC2 milkymist-minimac2
+#define MILKYMIST_MINIMAC2(obj) \
+OBJECT_CHECK(MilkymistMinimac2State, (obj), TYPE_MILKYMIST_MINIMAC2)
+
 struct MilkymistMinimac2State {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 NICState *nic;
 NICConf conf;
 char *phy_model;
@@ -429,8 +434,7 @@ static void minimac2_cleanup(NetClientState *nc)
 
 static void milkymist_minimac2_reset(DeviceState *d)
 {
-MilkymistMinimac2State *s =
-container_of(d, MilkymistMinimac2State, busdev.qdev);
+MilkymistMinimac2State *s = MILKYMIST_MINIMAC2(d);
 int i;
 
 for (i = 0; i  R_MAX; i++) {
@@ -453,17 +457,18 @@ static NetClientInfo net_milkymist_minimac2_info = {
 .cleanup = minimac2_cleanup,
 };
 
-static int milkymist_minimac2_init(SysBusDevice *dev)
+static int milkymist_minimac2_init(SysBusDevice *sbd)
 {
-MilkymistMinimac2State *s = FROM_SYSBUS(typeof(*s), dev);
+DeviceState *dev = DEVICE(sbd);
+MilkymistMinimac2State *s = MILKYMIST_MINIMAC2(dev);
 size_t buffers_size = TARGET_PAGE_ALIGN(3 * MINIMAC2_BUFFER_SIZE);
 
-sysbus_init_irq(dev, s-rx_irq);
-sysbus_init_irq(dev, s-tx_irq);
+sysbus_init_irq(sbd, s-rx_irq);
+sysbus_init_irq(sbd, s-tx_irq);
 
 memory_region_init_io(s-regs_region, OBJECT(dev), minimac2_ops, s,
   milkymist-minimac2, R_MAX * 4);
-sysbus_init_mmio(dev, s-regs_region);
+sysbus_init_mmio(sbd, s-regs_region);
 
 /* register buffers memory */
 memory_region_init_ram(s-buffers, OBJECT(dev), 
milkymist-minimac2.buffers,
@@ -473,11 +478,11 @@ static int milkymist_minimac2_init(SysBusDevice *dev)
 s-rx1_buf = s-rx0_buf + MINIMAC2_BUFFER_SIZE;
 s-tx_buf = s-rx1_buf + MINIMAC2_BUFFER_SIZE;
 
-sysbus_init_mmio(dev, s-buffers);
+sysbus_init_mmio(sbd, s-buffers);
 
 qemu_macaddr_default_if_unset(s-conf.macaddr);
 s-nic = qemu_new_nic(net_milkymist_minimac2_info, s-conf,
-  object_get_typename(OBJECT(dev)), dev-qdev.id, s);
+  object_get_typename(OBJECT(dev)), dev-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);
 
 return 0;
@@ -532,7 +537,7 @@ static void milkymist_minimac2_class_init(ObjectClass 
*klass, void *data)
 }
 
 static const TypeInfo milkymist_minimac2_info = {
-.name  = milkymist-minimac2,
+.name  = TYPE_MILKYMIST_MINIMAC2,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(MilkymistMinimac2State),
 .class_init= milkymist_minimac2_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 11/11] xilinx_ethlite: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/xilinx_ethlite.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
index 2afc91a..3a2a6c2 100644
--- a/hw/net/xilinx_ethlite.c
+++ b/hw/net/xilinx_ethlite.c
@@ -47,9 +47,14 @@
 #define CTRL_P 0x2
 #define CTRL_S 0x1
 
+#define TYPE_XILINX_ETHLITE xlnx.xps-ethernetlite
+#define XILINX_ETHLITE(obj) \
+OBJECT_CHECK(struct xlx_ethlite, (obj), TYPE_XILINX_ETHLITE)
+
 struct xlx_ethlite
 {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion mmio;
 qemu_irq irq;
 NICState *nic;
@@ -214,20 +219,21 @@ static NetClientInfo net_xilinx_ethlite_info = {
 .cleanup = eth_cleanup,
 };
 
-static int xilinx_ethlite_init(SysBusDevice *dev)
+static int xilinx_ethlite_init(SysBusDevice *sbd)
 {
-struct xlx_ethlite *s = FROM_SYSBUS(typeof (*s), dev);
+DeviceState *dev = DEVICE(sbd);
+struct xlx_ethlite *s = XILINX_ETHLITE(dev);
 
-sysbus_init_irq(dev, s-irq);
+sysbus_init_irq(sbd, s-irq);
 s-rxbuf = 0;
 
 memory_region_init_io(s-mmio, OBJECT(s), eth_ops, s,
   xlnx.xps-ethernetlite, R_MAX * 4);
-sysbus_init_mmio(dev, s-mmio);
+sysbus_init_mmio(sbd, s-mmio);
 
 qemu_macaddr_default_if_unset(s-conf.macaddr);
 s-nic = qemu_new_nic(net_xilinx_ethlite_info, s-conf,
-  object_get_typename(OBJECT(dev)), dev-qdev.id, s);
+  object_get_typename(OBJECT(dev)), dev-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);
 return 0;
 }
@@ -249,7 +255,7 @@ static void xilinx_ethlite_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo xilinx_ethlite_info = {
-.name  = xlnx.xps-ethernetlite,
+.name  = TYPE_XILINX_ETHLITE,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(struct xlx_ethlite),
 .class_init= xilinx_ethlite_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6] ppc: QOM cast cleanups

2013-07-27 Thread Andreas Färber
Hello,

This series eliminates FROM_SYSBUS() in hw/ppc/.

Regards,
Andreas

Cc: Hu Tao hu...@cn.fujitsu.com

Andreas Färber (1):
  ppce500_spin: QOM cast cleanup

 hw/ppc/ppce500_spin.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6] ppce500_spin: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Introduce type constant and use QOM cast.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/ppc/ppce500_spin.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c
index 11b7de2..78b23fa 100644
--- a/hw/ppc/ppce500_spin.c
+++ b/hw/ppc/ppce500_spin.c
@@ -42,8 +42,12 @@ typedef struct spin_info {
 uint64_t reserved;
 } QEMU_PACKED SpinInfo;
 
-typedef struct spin_state {
-SysBusDevice busdev;
+#define TYPE_E500_SPIN e500-spin
+#define E500_SPIN(obj) OBJECT_CHECK(SpinState, (obj), TYPE_E500_SPIN)
+
+typedef struct SpinState {
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 SpinInfo spin[MAX_CPUS];
 } SpinState;
@@ -187,9 +191,7 @@ static const MemoryRegionOps spin_rw_ops = {
 
 static int ppce500_spin_initfn(SysBusDevice *dev)
 {
-SpinState *s;
-
-s = FROM_SYSBUS(SpinState, SYS_BUS_DEVICE(dev));
+SpinState *s = E500_SPIN(dev);
 
 memory_region_init_io(s-iomem, OBJECT(s), spin_rw_ops, s,
   e500 spin pv device, sizeof(SpinInfo) * MAX_CPUS);
@@ -208,7 +210,7 @@ static void ppce500_spin_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo ppce500_spin_info = {
-.name  = e500-spin,
+.name  = TYPE_E500_SPIN,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(SpinState),
 .class_init= ppce500_spin_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 04/11] lan9118: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/lan9118.c | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index 3323f48..2c838f6 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -170,8 +170,12 @@ static const VMStateDescription vmstate_lan9118_packet = {
 }
 };
 
+#define TYPE_LAN9118 lan9118
+#define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118)
+
 typedef struct {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 NICState *nic;
 NICConf conf;
 qemu_irq irq;
@@ -401,7 +405,8 @@ static void phy_reset(lan9118_state *s)
 
 static void lan9118_reset(DeviceState *d)
 {
-lan9118_state *s = FROM_SYSBUS(lan9118_state, SYS_BUS_DEVICE(d));
+lan9118_state *s = LAN9118(d);
+
 s-irq_cfg = (IRQ_TYPE | IRQ_POL);
 s-int_sts = 0;
 s-int_en = 0;
@@ -1053,7 +1058,7 @@ static void lan9118_writel(void *opaque, hwaddr offset,
 case CSR_HW_CFG:
 if (val  1) {
 /* SRST */
-lan9118_reset(s-busdev.qdev);
+lan9118_reset(DEVICE(s));
 } else {
 s-hw_cfg = (val  0x003f300) | (s-hw_cfg  0x4);
 }
@@ -1320,9 +1325,10 @@ static NetClientInfo net_lan9118_info = {
 .link_status_changed = lan9118_set_link,
 };
 
-static int lan9118_init1(SysBusDevice *dev)
+static int lan9118_init1(SysBusDevice *sbd)
 {
-lan9118_state *s = FROM_SYSBUS(lan9118_state, dev);
+DeviceState *dev = DEVICE(sbd);
+lan9118_state *s = LAN9118(dev);
 QEMUBH *bh;
 int i;
 const MemoryRegionOps *mem_ops =
@@ -1330,12 +1336,12 @@ static int lan9118_init1(SysBusDevice *dev)
 
 memory_region_init_io(s-mmio, OBJECT(dev), mem_ops, s,
   lan9118-mmio, 0x100);
-sysbus_init_mmio(dev, s-mmio);
-sysbus_init_irq(dev, s-irq);
+sysbus_init_mmio(sbd, s-mmio);
+sysbus_init_irq(sbd, s-irq);
 qemu_macaddr_default_if_unset(s-conf.macaddr);
 
 s-nic = qemu_new_nic(net_lan9118_info, s-conf,
-  object_get_typename(OBJECT(dev)), dev-qdev.id, s);
+  object_get_typename(OBJECT(dev)), dev-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);
 s-eeprom[0] = 0xa5;
 for (i = 0; i  6; i++) {
@@ -1370,7 +1376,7 @@ static void lan9118_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo lan9118_info = {
-.name  = lan9118,
+.name  = TYPE_LAN9118,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(lan9118_state),
 .class_init= lan9118_class_init,
@@ -1389,7 +1395,7 @@ void lan9118_init(NICInfo *nd, uint32_t base, qemu_irq 
irq)
 SysBusDevice *s;
 
 qemu_check_nic_model(nd, lan9118);
-dev = qdev_create(NULL, lan9118);
+dev = qdev_create(NULL, TYPE_LAN9118);
 qdev_set_nic_properties(dev, nd);
 qdev_init_nofail(dev);
 s = SYS_BUS_DEVICE(dev);
-- 
1.8.1.4




Re: [Qemu-devel] [Xen-devel] Cirrus VGA slow screen update, show blank screen last 13s or so for windows XP guest

2013-07-27 Thread Pasi Kärkkäinen
On Fri, Jul 26, 2013 at 12:19:16PM +0200, Gerd Hoffmann wrote:
 
 Maybe the xen guys did some optimizations in qemu-dm which where not
 merged upstream.  Try asking @ xen-devel.
 

Yeah, xen qemu-dm must have some optimization for cirrus that isn't in upstream 
qemu. 

 Beside that the standard vga usually is the better choice anyway as it
 supports more video memory and higher resolutions than cirrus.
 

One of the reasons to use emulated Cirrus is that there's a KMS driver for it.
Is there one for the emulated stdvga adapter? 

-- Pasi




[Qemu-devel] [PATCH qom-next for-1.6 10/11] xgmac: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Introduce type constant and use QOM casts and typedef consistently.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/xgmac.c | 46 ++
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
index 997a5b5..9384fa0 100644
--- a/hw/net/xgmac.c
+++ b/hw/net/xgmac.c
@@ -135,8 +135,12 @@ typedef struct RxTxStats {
 uint64_t rx_mcast;
 } RxTxStats;
 
+#define TYPE_XGMAC xgmac
+#define XGMAC(obj) OBJECT_CHECK(XgmacState, (obj), TYPE_XGMAC)
+
 typedef struct XgmacState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 qemu_irq sbd_irq;
 qemu_irq pmt_irq;
@@ -173,14 +177,14 @@ static const VMStateDescription vmstate_xgmac = {
 }
 };
 
-static void xgmac_read_desc(struct XgmacState *s, struct desc *d, int rx)
+static void xgmac_read_desc(XgmacState *s, struct desc *d, int rx)
 {
 uint32_t addr = rx ? s-regs[DMA_CUR_RX_DESC_ADDR] :
 s-regs[DMA_CUR_TX_DESC_ADDR];
 cpu_physical_memory_read(addr, d, sizeof(*d));
 }
 
-static void xgmac_write_desc(struct XgmacState *s, struct desc *d, int rx)
+static void xgmac_write_desc(XgmacState *s, struct desc *d, int rx)
 {
 int reg = rx ? DMA_CUR_RX_DESC_ADDR : DMA_CUR_TX_DESC_ADDR;
 uint32_t addr = s-regs[reg];
@@ -195,7 +199,7 @@ static void xgmac_write_desc(struct XgmacState *s, struct 
desc *d, int rx)
 cpu_physical_memory_write(addr, d, sizeof(*d));
 }
 
-static void xgmac_enet_send(struct XgmacState *s)
+static void xgmac_enet_send(XgmacState *s)
 {
 struct desc bd;
 int frame_size;
@@ -246,7 +250,7 @@ static void xgmac_enet_send(struct XgmacState *s)
 }
 }
 
-static void enet_update_irq(struct XgmacState *s)
+static void enet_update_irq(XgmacState *s)
 {
 int stat = s-regs[DMA_STATUS]  s-regs[DMA_INTR_ENA];
 qemu_set_irq(s-sbd_irq, !!stat);
@@ -254,7 +258,7 @@ static void enet_update_irq(struct XgmacState *s)
 
 static uint64_t enet_read(void *opaque, hwaddr addr, unsigned size)
 {
-struct XgmacState *s = opaque;
+XgmacState *s = opaque;
 uint64_t r = 0;
 addr = 2;
 
@@ -274,7 +278,7 @@ static uint64_t enet_read(void *opaque, hwaddr addr, 
unsigned size)
 static void enet_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
 {
-struct XgmacState *s = opaque;
+XgmacState *s = opaque;
 
 addr = 2;
 switch (addr) {
@@ -310,7 +314,7 @@ static const MemoryRegionOps enet_mem_ops = {
 
 static int eth_can_rx(NetClientState *nc)
 {
-struct XgmacState *s = qemu_get_nic_opaque(nc);
+XgmacState *s = qemu_get_nic_opaque(nc);
 
 /* RX enabled?  */
 return s-regs[DMA_CONTROL]  DMA_CONTROL_SR;
@@ -318,7 +322,7 @@ static int eth_can_rx(NetClientState *nc)
 
 static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size)
 {
-struct XgmacState *s = qemu_get_nic_opaque(nc);
+XgmacState *s = qemu_get_nic_opaque(nc);
 static const unsigned char sa_bcast[6] = {0xff, 0xff, 0xff,
   0xff, 0xff, 0xff};
 int unicast, broadcast, multicast;
@@ -366,7 +370,8 @@ out:
 
 static void eth_cleanup(NetClientState *nc)
 {
-struct XgmacState *s = qemu_get_nic_opaque(nc);
+XgmacState *s = qemu_get_nic_opaque(nc);
+
 s-nic = NULL;
 }
 
@@ -378,20 +383,21 @@ static NetClientInfo net_xgmac_enet_info = {
 .cleanup = eth_cleanup,
 };
 
-static int xgmac_enet_init(SysBusDevice *dev)
+static int xgmac_enet_init(SysBusDevice *sbd)
 {
-struct XgmacState *s = FROM_SYSBUS(typeof(*s), dev);
+DeviceState *dev = DEVICE(sbd);
+XgmacState *s = XGMAC(dev);
 
 memory_region_init_io(s-iomem, OBJECT(s), enet_mem_ops, s,
   xgmac, 0x1000);
-sysbus_init_mmio(dev, s-iomem);
-sysbus_init_irq(dev, s-sbd_irq);
-sysbus_init_irq(dev, s-pmt_irq);
-sysbus_init_irq(dev, s-mci_irq);
+sysbus_init_mmio(sbd, s-iomem);
+sysbus_init_irq(sbd, s-sbd_irq);
+sysbus_init_irq(sbd, s-pmt_irq);
+sysbus_init_irq(sbd, s-mci_irq);
 
 qemu_macaddr_default_if_unset(s-conf.macaddr);
 s-nic = qemu_new_nic(net_xgmac_enet_info, s-conf,
-  object_get_typename(OBJECT(dev)), dev-qdev.id, s);
+  object_get_typename(OBJECT(dev)), dev-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);
 
 s-regs[XGMAC_ADDR_HIGH(0)] = (s-conf.macaddr.a[5]  8) |
@@ -405,7 +411,7 @@ static int xgmac_enet_init(SysBusDevice *dev)
 }
 
 static Property xgmac_properties[] = {
-DEFINE_NIC_PROPERTIES(struct XgmacState, conf),
+DEFINE_NIC_PROPERTIES(XgmacState, conf),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -420,9 +426,9 @@ static void xgmac_enet_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo xgmac_enet_info = {
-.name  = xgmac,
+.name  = TYPE_XGMAC,
 .parent= TYPE_SYS_BUS_DEVICE,
-.instance_size = 

[Qemu-devel] [PATCH qom-next for-1.6 09/11] stellaris_enet: NetClientInfo::cleanup fixes

2013-07-27 Thread Andreas Färber
Drop freeing stellaris_enet_state - that is done by QOM later on unref.

Both MemoryRegion init and savevm registration happen in SysBusDevice
initfn currently, so move them into an unrealizefn for now.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/stellaris_enet.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
index 6194e33..9dd77f7 100644
--- a/hw/net/stellaris_enet.c
+++ b/hw/net/stellaris_enet.c
@@ -391,11 +391,7 @@ static void stellaris_enet_cleanup(NetClientState *nc)
 {
 stellaris_enet_state *s = qemu_get_nic_opaque(nc);
 
-unregister_savevm(DEVICE(s), stellaris_enet, s);
-
-memory_region_destroy(s-mmio);
-
-g_free(s);
+s-nic = NULL;
 }
 
 static NetClientInfo net_stellaris_enet_info = {
@@ -427,6 +423,15 @@ static int stellaris_enet_init(SysBusDevice *sbd)
 return 0;
 }
 
+static void stellaris_enet_unrealize(DeviceState *dev, Error **errp)
+{
+stellaris_enet_state *s = STELLARIS_ENET(dev);
+
+unregister_savevm(DEVICE(s), stellaris_enet, s);
+
+memory_region_destroy(s-mmio);
+}
+
 static Property stellaris_enet_properties[] = {
 DEFINE_NIC_PROPERTIES(stellaris_enet_state, conf),
 DEFINE_PROP_END_OF_LIST(),
@@ -438,6 +443,7 @@ static void stellaris_enet_class_init(ObjectClass *klass, 
void *data)
 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
 k-init = stellaris_enet_init;
+dc-unrealize = stellaris_enet_unrealize;
 dc-props = stellaris_enet_properties;
 }
 
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 2/6] sun4m: QOM cast cleanup for AFXState

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sparc/sun4m.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index eb3b11b..e5c6881 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -612,8 +612,12 @@ static const TypeInfo idreg_info = {
 .class_init= idreg_class_init,
 };
 
+#define TYPE_TCX_AFX tcx_afx
+#define TCX_AFX(obj) OBJECT_CHECK(AFXState, (obj), TYPE_TCX_AFX)
+
 typedef struct AFXState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion mem;
 } AFXState;
 
@@ -623,7 +627,7 @@ static void afx_init(hwaddr addr)
 DeviceState *dev;
 SysBusDevice *s;
 
-dev = qdev_create(NULL, tcx_afx);
+dev = qdev_create(NULL, TYPE_TCX_AFX);
 qdev_init_nofail(dev);
 s = SYS_BUS_DEVICE(dev);
 
@@ -632,7 +636,7 @@ static void afx_init(hwaddr addr)
 
 static int afx_init1(SysBusDevice *dev)
 {
-AFXState *s = FROM_SYSBUS(AFXState, dev);
+AFXState *s = TCX_AFX(dev);
 
 memory_region_init_ram(s-mem, OBJECT(s), sun4m.afx, 4);
 vmstate_register_ram_global(s-mem);
@@ -648,7 +652,7 @@ static void afx_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo afx_info = {
-.name  = tcx_afx,
+.name  = TYPE_TCX_AFX,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(AFXState),
 .class_init= afx_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 0/6] sparc: QOM cast cleanups

2013-07-27 Thread Andreas Färber
Hello,

This series eliminates FROM_SYSBUS() in hw/sparc/ and hw/sparc64/.

Regards,
Andreas

Cc: Hu Tao hu...@cn.fujitsu.com

Andreas Färber (6):
  sun4m: QOM cast cleanup for IDRegState
  sun4m: QOM cast cleanup for AFXState
  sun4m: QOM cast cleanup for PROMState
  sun4m: QOM cast cleanup for RamDevice
  sun4u: QOM cast cleanup for PROMState
  sun4u: QOM cast cleanup for RamDevice

 hw/sparc/sun4m.c   | 54 --
 hw/sparc64/sun4u.c | 29 ++---
 2 files changed, 54 insertions(+), 29 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 4/6] sun4m: QOM cast cleanup for RamDevice

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sparc/sun4m.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index b943a07..942ca37 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -739,9 +739,12 @@ static const TypeInfo prom_info = {
 .class_init= prom_class_init,
 };
 
-typedef struct RamDevice
-{
-SysBusDevice busdev;
+#define TYPE_SUN4M_MEMORY memory
+#define SUN4M_RAM(obj) OBJECT_CHECK(RamDevice, (obj), TYPE_SUN4M_MEMORY)
+
+typedef struct RamDevice {
+SysBusDevice parent_obj;
+
 MemoryRegion ram;
 uint64_t size;
 } RamDevice;
@@ -749,7 +752,7 @@ typedef struct RamDevice
 /* System RAM */
 static int ram_init1(SysBusDevice *dev)
 {
-RamDevice *d = FROM_SYSBUS(RamDevice, dev);
+RamDevice *d = SUN4M_RAM(dev);
 
 memory_region_init_ram(d-ram, OBJECT(d), sun4m.ram, d-size);
 vmstate_register_ram_global(d-ram);
@@ -775,7 +778,7 @@ static void ram_init(hwaddr addr, ram_addr_t RAM_size,
 dev = qdev_create(NULL, memory);
 s = SYS_BUS_DEVICE(dev);
 
-d = FROM_SYSBUS(RamDevice, s);
+d = SUN4M_RAM(dev);
 d-size = RAM_size;
 qdev_init_nofail(dev);
 
@@ -797,7 +800,7 @@ static void ram_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo ram_info = {
-.name  = memory,
+.name  = TYPE_SUN4M_MEMORY,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(RamDevice),
 .class_init= ram_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 1/6] sun4m: QOM cast cleanup for IDRegState

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sparc/sun4m.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 5c7bd31..eb3b11b 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -559,6 +559,9 @@ static void tcx_init(hwaddr addr, int vram_size, int width,
 }
 
 /* NCR89C100/MACIO Internal ID register */
+
+#define TYPE_MACIO_ID_REGISTER macio_idreg
+
 static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
 
 static void idreg_init(hwaddr addr)
@@ -566,7 +569,7 @@ static void idreg_init(hwaddr addr)
 DeviceState *dev;
 SysBusDevice *s;
 
-dev = qdev_create(NULL, macio_idreg);
+dev = qdev_create(NULL, TYPE_MACIO_ID_REGISTER);
 qdev_init_nofail(dev);
 s = SYS_BUS_DEVICE(dev);
 
@@ -574,14 +577,18 @@ static void idreg_init(hwaddr addr)
 cpu_physical_memory_write_rom(addr, idreg_data, sizeof(idreg_data));
 }
 
+#define MACIO_ID_REGISTER(obj) \
+OBJECT_CHECK(IDRegState, (obj), TYPE_MACIO_ID_REGISTER)
+
 typedef struct IDRegState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion mem;
 } IDRegState;
 
 static int idreg_init1(SysBusDevice *dev)
 {
-IDRegState *s = FROM_SYSBUS(IDRegState, dev);
+IDRegState *s = MACIO_ID_REGISTER(dev);
 
 memory_region_init_ram(s-mem, OBJECT(s),
sun4m.idreg, sizeof(idreg_data));
@@ -599,7 +606,7 @@ static void idreg_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo idreg_info = {
-.name  = macio_idreg,
+.name  = TYPE_MACIO_ID_REGISTER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(IDRegState),
 .class_init= idreg_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 6/6] sun4u: QOM cast cleanup for RamDevice

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sparc64/sun4u.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 9568028..a7214a3 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -714,9 +714,12 @@ static const TypeInfo prom_info = {
 };
 
 
-typedef struct RamDevice
-{
-SysBusDevice busdev;
+#define TYPE_SUN4U_MEMORY memory
+#define SUN4U_RAM(obj) OBJECT_CHECK(RamDevice, (obj), TYPE_SUN4U_MEMORY)
+
+typedef struct RamDevice {
+SysBusDevice parent_obj;
+
 MemoryRegion ram;
 uint64_t size;
 } RamDevice;
@@ -724,7 +727,7 @@ typedef struct RamDevice
 /* System RAM */
 static int ram_init1(SysBusDevice *dev)
 {
-RamDevice *d = FROM_SYSBUS(RamDevice, dev);
+RamDevice *d = SUN4U_RAM(dev);
 
 memory_region_init_ram(d-ram, OBJECT(d), sun4u.ram, d-size);
 vmstate_register_ram_global(d-ram);
@@ -739,10 +742,10 @@ static void ram_init(hwaddr addr, ram_addr_t RAM_size)
 RamDevice *d;
 
 /* allocate RAM */
-dev = qdev_create(NULL, memory);
+dev = qdev_create(NULL, TYPE_SUN4U_MEMORY);
 s = SYS_BUS_DEVICE(dev);
 
-d = FROM_SYSBUS(RamDevice, s);
+d = SUN4U_RAM(dev);
 d-size = RAM_size;
 qdev_init_nofail(dev);
 
@@ -764,7 +767,7 @@ static void ram_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo ram_info = {
-.name  = memory,
+.name  = TYPE_SUN4U_MEMORY,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(RamDevice),
 .class_init= ram_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 5/6] sun4u: QOM cast cleanup for PROMState

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sparc64/sun4u.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 34a5e73..9568028 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -632,8 +632,12 @@ static const TypeInfo ebus_info = {
 .class_init= ebus_class_init,
 };
 
+#define TYPE_OPENPROM openprom
+#define OPENPROM(obj) OBJECT_CHECK(PROMState, (obj), TYPE_OPENPROM)
+
 typedef struct PROMState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion prom;
 } PROMState;
 
@@ -651,7 +655,7 @@ static void prom_init(hwaddr addr, const char *bios_name)
 char *filename;
 int ret;
 
-dev = qdev_create(NULL, openprom);
+dev = qdev_create(NULL, TYPE_OPENPROM);
 qdev_init_nofail(dev);
 s = SYS_BUS_DEVICE(dev);
 
@@ -680,7 +684,7 @@ static void prom_init(hwaddr addr, const char *bios_name)
 
 static int prom_init1(SysBusDevice *dev)
 {
-PROMState *s = FROM_SYSBUS(PROMState, dev);
+PROMState *s = OPENPROM(dev);
 
 memory_region_init_ram(s-prom, OBJECT(s), sun4u.prom, PROM_SIZE_MAX);
 vmstate_register_ram_global(s-prom);
@@ -703,7 +707,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo prom_info = {
-.name  = openprom,
+.name  = TYPE_OPENPROM,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(PROMState),
 .class_init= prom_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 1/3] milkymist-memcard: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sd/milkymist-memcard.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
index f69775c..42613b3 100644
--- a/hw/sd/milkymist-memcard.c
+++ b/hw/sd/milkymist-memcard.c
@@ -58,8 +58,13 @@ enum {
 R_MAX
 };
 
+#define TYPE_MILKYMIST_MEMCARD milkymist-memcard
+#define MILKYMIST_MEMCARD(obj) \
+OBJECT_CHECK(MilkymistMemcardState, (obj), TYPE_MILKYMIST_MEMCARD)
+
 struct MilkymistMemcardState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion regs_region;
 SDState *card;
 
@@ -231,8 +236,7 @@ static const MemoryRegionOps memcard_mmio_ops = {
 
 static void milkymist_memcard_reset(DeviceState *d)
 {
-MilkymistMemcardState *s =
-container_of(d, MilkymistMemcardState, busdev.qdev);
+MilkymistMemcardState *s = MILKYMIST_MEMCARD(d);
 int i;
 
 s-command_write_ptr = 0;
@@ -246,7 +250,7 @@ static void milkymist_memcard_reset(DeviceState *d)
 
 static int milkymist_memcard_init(SysBusDevice *dev)
 {
-MilkymistMemcardState *s = FROM_SYSBUS(typeof(*s), dev);
+MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev);
 DriveInfo *dinfo;
 
 dinfo = drive_get_next(IF_SD);
@@ -289,7 +293,7 @@ static void milkymist_memcard_class_init(ObjectClass 
*klass, void *data)
 }
 
 static const TypeInfo milkymist_memcard_info = {
-.name  = milkymist-memcard,
+.name  = TYPE_MILKYMIST_MEMCARD,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(MilkymistMemcardState),
 .class_init= milkymist_memcard_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 3/6] sun4m: QOM cast cleanup for PROMState

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sparc/sun4m.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index e5c6881..b943a07 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -658,8 +658,12 @@ static const TypeInfo afx_info = {
 .class_init= afx_class_init,
 };
 
+#define TYPE_OPENPROM openprom
+#define OPENPROM(obj) OBJECT_CHECK(PROMState, (obj), TYPE_OPENPROM)
+
 typedef struct PROMState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion prom;
 } PROMState;
 
@@ -677,7 +681,7 @@ static void prom_init(hwaddr addr, const char *bios_name)
 char *filename;
 int ret;
 
-dev = qdev_create(NULL, openprom);
+dev = qdev_create(NULL, TYPE_OPENPROM);
 qdev_init_nofail(dev);
 s = SYS_BUS_DEVICE(dev);
 
@@ -706,7 +710,7 @@ static void prom_init(hwaddr addr, const char *bios_name)
 
 static int prom_init1(SysBusDevice *dev)
 {
-PROMState *s = FROM_SYSBUS(PROMState, dev);
+PROMState *s = OPENPROM(dev);
 
 memory_region_init_ram(s-prom, OBJECT(s), sun4m.prom, PROM_SIZE_MAX);
 vmstate_register_ram_global(s-prom);
@@ -729,7 +733,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo prom_info = {
-.name  = openprom,
+.name  = TYPE_OPENPROM,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(PROMState),
 .class_init= prom_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 2/3] pl181: Rename pl181_state to PL181State

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sd/pl181.c | 56 
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c
index f5eb1e4..dc08595 100644
--- a/hw/sd/pl181.c
+++ b/hw/sd/pl181.c
@@ -22,7 +22,7 @@ do { printf(pl181:  fmt , ## __VA_ARGS__); } while (0)
 
 #define PL181_FIFO_LEN 16
 
-typedef struct {
+typedef struct PL181State {
 SysBusDevice busdev;
 MemoryRegion iomem;
 SDState *card;
@@ -50,29 +50,29 @@ typedef struct {
 qemu_irq irq[2];
 /* GPIO outputs for 'card is readonly' and 'card inserted' */
 qemu_irq cardstatus[2];
-} pl181_state;
+} PL181State;
 
 static const VMStateDescription vmstate_pl181 = {
 .name = pl181,
 .version_id = 1,
 .minimum_version_id = 1,
 .fields = (VMStateField[]) {
-VMSTATE_UINT32(clock, pl181_state),
-VMSTATE_UINT32(power, pl181_state),
-VMSTATE_UINT32(cmdarg, pl181_state),
-VMSTATE_UINT32(cmd, pl181_state),
-VMSTATE_UINT32(datatimer, pl181_state),
-VMSTATE_UINT32(datalength, pl181_state),
-VMSTATE_UINT32(respcmd, pl181_state),
-VMSTATE_UINT32_ARRAY(response, pl181_state, 4),
-VMSTATE_UINT32(datactrl, pl181_state),
-VMSTATE_UINT32(datacnt, pl181_state),
-VMSTATE_UINT32(status, pl181_state),
-VMSTATE_UINT32_ARRAY(mask, pl181_state, 2),
-VMSTATE_INT32(fifo_pos, pl181_state),
-VMSTATE_INT32(fifo_len, pl181_state),
-VMSTATE_INT32(linux_hack, pl181_state),
-VMSTATE_UINT32_ARRAY(fifo, pl181_state, PL181_FIFO_LEN),
+VMSTATE_UINT32(clock, PL181State),
+VMSTATE_UINT32(power, PL181State),
+VMSTATE_UINT32(cmdarg, PL181State),
+VMSTATE_UINT32(cmd, PL181State),
+VMSTATE_UINT32(datatimer, PL181State),
+VMSTATE_UINT32(datalength, PL181State),
+VMSTATE_UINT32(respcmd, PL181State),
+VMSTATE_UINT32_ARRAY(response, PL181State, 4),
+VMSTATE_UINT32(datactrl, PL181State),
+VMSTATE_UINT32(datacnt, PL181State),
+VMSTATE_UINT32(status, PL181State),
+VMSTATE_UINT32_ARRAY(mask, PL181State, 2),
+VMSTATE_INT32(fifo_pos, PL181State),
+VMSTATE_INT32(fifo_len, PL181State),
+VMSTATE_INT32(linux_hack, PL181State),
+VMSTATE_UINT32_ARRAY(fifo, PL181State, PL181_FIFO_LEN),
 VMSTATE_END_OF_LIST()
 }
 };
@@ -125,7 +125,7 @@ static const VMStateDescription vmstate_pl181 = {
 static const unsigned char pl181_id[] =
 { 0x81, 0x11, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 };
 
-static void pl181_update(pl181_state *s)
+static void pl181_update(PL181State *s)
 {
 int i;
 for (i = 0; i  2; i++) {
@@ -133,7 +133,7 @@ static void pl181_update(pl181_state *s)
 }
 }
 
-static void pl181_fifo_push(pl181_state *s, uint32_t value)
+static void pl181_fifo_push(PL181State *s, uint32_t value)
 {
 int n;
 
@@ -147,7 +147,7 @@ static void pl181_fifo_push(pl181_state *s, uint32_t value)
 DPRINTF(FIFO push %08x\n, (int)value);
 }
 
-static uint32_t pl181_fifo_pop(pl181_state *s)
+static uint32_t pl181_fifo_pop(PL181State *s)
 {
 uint32_t value;
 
@@ -162,7 +162,7 @@ static uint32_t pl181_fifo_pop(pl181_state *s)
 return value;
 }
 
-static void pl181_send_command(pl181_state *s)
+static void pl181_send_command(PL181State *s)
 {
 SDRequest request;
 uint8_t response[16];
@@ -207,7 +207,7 @@ error:
the FIFO holding 32-bit words and the card taking data in single byte
chunks.  FIFO bytes are transferred in little-endian order.  */
 
-static void pl181_fifo_run(pl181_state *s)
+static void pl181_fifo_run(PL181State *s)
 {
 uint32_t bits;
 uint32_t value = 0;
@@ -288,7 +288,7 @@ static void pl181_fifo_run(pl181_state *s)
 static uint64_t pl181_read(void *opaque, hwaddr offset,
unsigned size)
 {
-pl181_state *s = (pl181_state *)opaque;
+PL181State *s = (PL181State *)opaque;
 uint32_t tmp;
 
 if (offset = 0xfe0  offset  0x1000) {
@@ -372,7 +372,7 @@ static uint64_t pl181_read(void *opaque, hwaddr offset,
 static void pl181_write(void *opaque, hwaddr offset,
 uint64_t value, unsigned size)
 {
-pl181_state *s = (pl181_state *)opaque;
+PL181State *s = (PL181State *)opaque;
 
 switch (offset) {
 case 0x00: /* Power */
@@ -449,7 +449,7 @@ static const MemoryRegionOps pl181_ops = {
 
 static void pl181_reset(DeviceState *d)
 {
-pl181_state *s = DO_UPCAST(pl181_state, busdev.qdev, d);
+PL181State *s = DO_UPCAST(PL181State, busdev.qdev, d);
 
 s-power = 0;
 s-cmdarg = 0;
@@ -476,7 +476,7 @@ static void pl181_reset(DeviceState *d)
 
 static int pl181_init(SysBusDevice *dev)
 {
-pl181_state *s = FROM_SYSBUS(pl181_state, dev);
+PL181State *s = FROM_SYSBUS(PL181State, dev);
 DriveInfo *dinfo;
 
 memory_region_init_io(s-iomem, OBJECT(s), pl181_ops, s, pl181, 
0x1000);
@@ -503,7 

[Qemu-devel] [PATCH qom-next for-1.6 0/3] sd: QOM cast cleanups

2013-07-27 Thread Andreas Färber
Hello,

This series eliminates FROM_SYSBUS() in hw/sd/.

Regards,
Andreas

Cc: Hu Tao hu...@cn.fujitsu.com

Andreas Färber (3):
  milkymist-memcard: QOM cast cleanup
  pl181: Rename pl181_state to PL181State
  pl181: QOM cast cleanup

 hw/sd/milkymist-memcard.c | 14 +
 hw/sd/pl181.c | 75 +--
 2 files changed, 49 insertions(+), 40 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 3/3] pl181: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/sd/pl181.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c
index dc08595..03875bf 100644
--- a/hw/sd/pl181.c
+++ b/hw/sd/pl181.c
@@ -22,8 +22,12 @@ do { printf(pl181:  fmt , ## __VA_ARGS__); } while (0)
 
 #define PL181_FIFO_LEN 16
 
+#define TYPE_PL181 pl181
+#define PL181(obj) OBJECT_CHECK(PL181State, (obj), TYPE_PL181)
+
 typedef struct PL181State {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 SDState *card;
 uint32_t clock;
@@ -449,7 +453,7 @@ static const MemoryRegionOps pl181_ops = {
 
 static void pl181_reset(DeviceState *d)
 {
-PL181State *s = DO_UPCAST(PL181State, busdev.qdev, d);
+PL181State *s = PL181(d);
 
 s-power = 0;
 s-cmdarg = 0;
@@ -474,16 +478,17 @@ static void pl181_reset(DeviceState *d)
 sd_set_cb(s-card, s-cardstatus[0], s-cardstatus[1]);
 }
 
-static int pl181_init(SysBusDevice *dev)
+static int pl181_init(SysBusDevice *sbd)
 {
-PL181State *s = FROM_SYSBUS(PL181State, dev);
+DeviceState *dev = DEVICE(sbd);
+PL181State *s = PL181(dev);
 DriveInfo *dinfo;
 
 memory_region_init_io(s-iomem, OBJECT(s), pl181_ops, s, pl181, 
0x1000);
-sysbus_init_mmio(dev, s-iomem);
-sysbus_init_irq(dev, s-irq[0]);
-sysbus_init_irq(dev, s-irq[1]);
-qdev_init_gpio_out(s-busdev.qdev, s-cardstatus, 2);
+sysbus_init_mmio(sbd, s-iomem);
+sysbus_init_irq(sbd, s-irq[0]);
+sysbus_init_irq(sbd, s-irq[1]);
+qdev_init_gpio_out(dev, s-cardstatus, 2);
 dinfo = drive_get_next(IF_SD);
 s-card = sd_init(dinfo ? dinfo-bdrv : NULL, false);
 return 0;
@@ -501,7 +506,7 @@ static void pl181_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo pl181_info = {
-.name  = pl181,
+.name  = TYPE_PL181,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(PL181State),
 .class_init= pl181_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 2/3] pl022: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/ssi/pl022.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
index d33534e..fd479ef 100644
--- a/hw/ssi/pl022.c
+++ b/hw/ssi/pl022.c
@@ -39,8 +39,12 @@ do { fprintf(stderr, pl022: error:  fmt , ## 
__VA_ARGS__);} while (0)
 #define PL022_INT_RX  0x04
 #define PL022_INT_TX  0x08
 
+#define TYPE_PL022 pl022
+#define PL022(obj) OBJECT_CHECK(PL022State, (obj), TYPE_PL022)
+
 typedef struct PL022State {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 uint32_t cr0;
 uint32_t cr1;
@@ -273,16 +277,17 @@ static const VMStateDescription vmstate_pl022 = {
 }
 };
 
-static int pl022_init(SysBusDevice *dev)
+static int pl022_init(SysBusDevice *sbd)
 {
-PL022State *s = FROM_SYSBUS(PL022State, dev);
+DeviceState *dev = DEVICE(sbd);
+PL022State *s = PL022(dev);
 
 memory_region_init_io(s-iomem, OBJECT(s), pl022_ops, s, pl022, 
0x1000);
-sysbus_init_mmio(dev, s-iomem);
-sysbus_init_irq(dev, s-irq);
-s-ssi = ssi_create_bus(dev-qdev, ssi);
+sysbus_init_mmio(sbd, s-iomem);
+sysbus_init_irq(sbd, s-irq);
+s-ssi = ssi_create_bus(dev, ssi);
 pl022_reset(s);
-vmstate_register(dev-qdev, -1, vmstate_pl022, s);
+vmstate_register(dev, -1, vmstate_pl022, s);
 return 0;
 }
 
@@ -294,7 +299,7 @@ static void pl022_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo pl022_info = {
-.name  = pl022,
+.name  = TYPE_PL022,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(PL022State),
 .class_init= pl022_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 1/3] pl022: Rename pl022_state to PL022State

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/ssi/pl022.c | 72 +-
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
index 711a0c1..d33534e 100644
--- a/hw/ssi/pl022.c
+++ b/hw/ssi/pl022.c
@@ -39,7 +39,7 @@ do { fprintf(stderr, pl022: error:  fmt , ## __VA_ARGS__);} 
while (0)
 #define PL022_INT_RX  0x04
 #define PL022_INT_TX  0x08
 
-typedef struct {
+typedef struct PL022State {
 SysBusDevice busdev;
 MemoryRegion iomem;
 uint32_t cr0;
@@ -58,12 +58,12 @@ typedef struct {
 uint16_t rx_fifo[8];
 qemu_irq irq;
 SSIBus *ssi;
-} pl022_state;
+} PL022State;
 
 static const unsigned char pl022_id[8] =
   { 0x22, 0x10, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 };
 
-static void pl022_update(pl022_state *s)
+static void pl022_update(PL022State *s)
 {
 s-sr = 0;
 if (s-tx_fifo_len == 0)
@@ -85,7 +85,7 @@ static void pl022_update(pl022_state *s)
 qemu_set_irq(s-irq, (s-is  s-im) != 0);
 }
 
-static void pl022_xfer(pl022_state *s)
+static void pl022_xfer(PL022State *s)
 {
 int i;
 int o;
@@ -133,7 +133,7 @@ static void pl022_xfer(pl022_state *s)
 static uint64_t pl022_read(void *opaque, hwaddr offset,
unsigned size)
 {
-pl022_state *s = (pl022_state *)opaque;
+PL022State *s = (PL022State *)opaque;
 int val;
 
 if (offset = 0xfe0  offset  0x1000) {
@@ -177,7 +177,7 @@ static uint64_t pl022_read(void *opaque, hwaddr offset,
 static void pl022_write(void *opaque, hwaddr offset,
 uint64_t value, unsigned size)
 {
-pl022_state *s = (pl022_state *)opaque;
+PL022State *s = (PL022State *)opaque;
 
 switch (offset) {
 case 0x00: /* CR0 */
@@ -221,7 +221,7 @@ static void pl022_write(void *opaque, hwaddr offset,
 }
 }
 
-static void pl022_reset(pl022_state *s)
+static void pl022_reset(PL022State *s)
 {
 s-rx_fifo_len = 0;
 s-tx_fifo_len = 0;
@@ -242,40 +242,40 @@ static const VMStateDescription vmstate_pl022 = {
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
 .fields  = (VMStateField[]) {
-VMSTATE_UINT32(cr0, pl022_state),
-VMSTATE_UINT32(cr1, pl022_state),
-VMSTATE_UINT32(bitmask, pl022_state),
-VMSTATE_UINT32(sr, pl022_state),
-VMSTATE_UINT32(cpsr, pl022_state),
-VMSTATE_UINT32(is, pl022_state),
-VMSTATE_UINT32(im, pl022_state),
-VMSTATE_INT32(tx_fifo_head, pl022_state),
-VMSTATE_INT32(rx_fifo_head, pl022_state),
-VMSTATE_INT32(tx_fifo_len, pl022_state),
-VMSTATE_INT32(rx_fifo_len, pl022_state),
-VMSTATE_UINT16(tx_fifo[0], pl022_state),
-VMSTATE_UINT16(rx_fifo[0], pl022_state),
-VMSTATE_UINT16(tx_fifo[1], pl022_state),
-VMSTATE_UINT16(rx_fifo[1], pl022_state),
-VMSTATE_UINT16(tx_fifo[2], pl022_state),
-VMSTATE_UINT16(rx_fifo[2], pl022_state),
-VMSTATE_UINT16(tx_fifo[3], pl022_state),
-VMSTATE_UINT16(rx_fifo[3], pl022_state),
-VMSTATE_UINT16(tx_fifo[4], pl022_state),
-VMSTATE_UINT16(rx_fifo[4], pl022_state),
-VMSTATE_UINT16(tx_fifo[5], pl022_state),
-VMSTATE_UINT16(rx_fifo[5], pl022_state),
-VMSTATE_UINT16(tx_fifo[6], pl022_state),
-VMSTATE_UINT16(rx_fifo[6], pl022_state),
-VMSTATE_UINT16(tx_fifo[7], pl022_state),
-VMSTATE_UINT16(rx_fifo[7], pl022_state),
+VMSTATE_UINT32(cr0, PL022State),
+VMSTATE_UINT32(cr1, PL022State),
+VMSTATE_UINT32(bitmask, PL022State),
+VMSTATE_UINT32(sr, PL022State),
+VMSTATE_UINT32(cpsr, PL022State),
+VMSTATE_UINT32(is, PL022State),
+VMSTATE_UINT32(im, PL022State),
+VMSTATE_INT32(tx_fifo_head, PL022State),
+VMSTATE_INT32(rx_fifo_head, PL022State),
+VMSTATE_INT32(tx_fifo_len, PL022State),
+VMSTATE_INT32(rx_fifo_len, PL022State),
+VMSTATE_UINT16(tx_fifo[0], PL022State),
+VMSTATE_UINT16(rx_fifo[0], PL022State),
+VMSTATE_UINT16(tx_fifo[1], PL022State),
+VMSTATE_UINT16(rx_fifo[1], PL022State),
+VMSTATE_UINT16(tx_fifo[2], PL022State),
+VMSTATE_UINT16(rx_fifo[2], PL022State),
+VMSTATE_UINT16(tx_fifo[3], PL022State),
+VMSTATE_UINT16(rx_fifo[3], PL022State),
+VMSTATE_UINT16(tx_fifo[4], PL022State),
+VMSTATE_UINT16(rx_fifo[4], PL022State),
+VMSTATE_UINT16(tx_fifo[5], PL022State),
+VMSTATE_UINT16(rx_fifo[5], PL022State),
+VMSTATE_UINT16(tx_fifo[6], PL022State),
+VMSTATE_UINT16(rx_fifo[6], PL022State),
+VMSTATE_UINT16(tx_fifo[7], PL022State),
+VMSTATE_UINT16(rx_fifo[7], PL022State),
 VMSTATE_END_OF_LIST()
 }
 };
 
 static int pl022_init(SysBusDevice *dev)
 {
-pl022_state *s = FROM_SYSBUS(pl022_state, dev);
+PL022State *s = FROM_SYSBUS(PL022State, dev);
 
 memory_region_init_io(s-iomem, OBJECT(s), 

[Qemu-devel] [PATCH qom-next for-1.6 01/11] cadence_gem: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/cadence_gem.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index ac929cb..4a355bb 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -315,8 +315,12 @@ static inline void rx_desc_set_length(unsigned *desc, 
unsigned len)
 desc[1] |= len;
 }
 
-typedef struct {
-SysBusDevice busdev;
+#define TYPE_CADENCE_GEM cadence_gem
+#define GEM(obj) OBJECT_CHECK(GemState, (obj), TYPE_CADENCE_GEM)
+
+typedef struct GemState {
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 NICState *nic;
 NICConf conf;
@@ -945,7 +949,7 @@ static void gem_phy_reset(GemState *s)
 
 static void gem_reset(DeviceState *d)
 {
-GemState *s = FROM_SYSBUS(GemState, SYS_BUS_DEVICE(d));
+GemState *s = GEM(d);
 
 DB_PRINT(\n);
 
@@ -1155,22 +1159,22 @@ static NetClientInfo net_gem_info = {
 .link_status_changed = gem_set_link,
 };
 
-static int gem_init(SysBusDevice *dev)
+static int gem_init(SysBusDevice *sbd)
 {
-GemState *s;
+DeviceState *dev = DEVICE(sbd);
+GemState *s = GEM(dev);
 
 DB_PRINT(\n);
 
-s = FROM_SYSBUS(GemState, dev);
 gem_init_register_masks(s);
 memory_region_init_io(s-iomem, OBJECT(s), gem_ops, s,
   enet, sizeof(s-regs));
-sysbus_init_mmio(dev, s-iomem);
-sysbus_init_irq(dev, s-irq);
+sysbus_init_mmio(sbd, s-iomem);
+sysbus_init_irq(sbd, s-irq);
 qemu_macaddr_default_if_unset(s-conf.macaddr);
 
 s-nic = qemu_new_nic(net_gem_info, s-conf,
-object_get_typename(OBJECT(dev)), dev-qdev.id, s);
+object_get_typename(OBJECT(dev)), dev-id, s);
 
 return 0;
 }
@@ -1206,10 +1210,10 @@ static void gem_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo gem_info = {
-.class_init = gem_class_init,
-.name  = cadence_gem,
+.name  = TYPE_CADENCE_GEM,
 .parent = TYPE_SYS_BUS_DEVICE,
 .instance_size  = sizeof(GemState),
+.class_init = gem_class_init,
 };
 
 static void gem_register_types(void)
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 0/2] nvram: QOM cast cleanups

2013-07-27 Thread Andreas Färber
Hello,

This series eliminates FROM_SYSBUS() in hw/nvram/.

Regards,
Andreas

Cc: Hu Tao hu...@cn.fujitsu.com

Andreas Färber (2):
  ds1225y: Drop bogus qdev field from NvRamState
  ds1225y: QOM cast cleanup

 hw/nvram/ds1225y.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 3/3] xilinx_spi: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/ssi/xilinx_spi.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c
index 7a9fd81..d44caae 100644
--- a/hw/ssi/xilinx_spi.c
+++ b/hw/ssi/xilinx_spi.c
@@ -73,8 +73,12 @@
 
 #define FIFO_CAPACITY 256
 
+#define TYPE_XILINX_SPI xlnx.xps-spi
+#define XILINX_SPI(obj) OBJECT_CHECK(XilinxSPI, (obj), TYPE_XILINX_SPI)
+
 typedef struct XilinxSPI {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion mmio;
 
 qemu_irq irq;
@@ -109,7 +113,7 @@ static void rxfifo_reset(XilinxSPI *s)
 
 static void xlx_spi_update_cs(XilinxSPI *s)
 {
-   int i;
+int i;
 
 for (i = 0; i  s-num_cs; ++i) {
 qemu_set_irq(s-cs_lines[i], !(~s-regs[R_SPISSR]  1  i));
@@ -154,7 +158,7 @@ static void xlx_spi_do_reset(XilinxSPI *s)
 
 static void xlx_spi_reset(DeviceState *d)
 {
-xlx_spi_do_reset(DO_UPCAST(XilinxSPI, busdev.qdev, d));
+xlx_spi_do_reset(XILINX_SPI(d));
 }
 
 static inline int spi_master_enabled(XilinxSPI *s)
@@ -314,25 +318,26 @@ static const MemoryRegionOps spi_ops = {
 }
 };
 
-static int xilinx_spi_init(SysBusDevice *dev)
+static int xilinx_spi_init(SysBusDevice *sbd)
 {
+DeviceState *dev = DEVICE(sbd);
+XilinxSPI *s = XILINX_SPI(dev);
 int i;
-XilinxSPI *s = FROM_SYSBUS(typeof(*s), dev);
 
 DB_PRINT(\n);
 
-s-spi = ssi_create_bus(dev-qdev, spi);
+s-spi = ssi_create_bus(dev, spi);
 
-sysbus_init_irq(dev, s-irq);
+sysbus_init_irq(sbd, s-irq);
 s-cs_lines = g_new(qemu_irq, s-num_cs);
-ssi_auto_connect_slaves(DEVICE(s), s-cs_lines, s-spi);
+ssi_auto_connect_slaves(dev, s-cs_lines, s-spi);
 for (i = 0; i  s-num_cs; ++i) {
-sysbus_init_irq(dev, s-cs_lines[i]);
+sysbus_init_irq(sbd, s-cs_lines[i]);
 }
 
 memory_region_init_io(s-mmio, OBJECT(s), spi_ops, s,
   xilinx-spi, R_MAX * 4);
-sysbus_init_mmio(dev, s-mmio);
+sysbus_init_mmio(sbd, s-mmio);
 
 s-irqline = -1;
 
@@ -372,7 +377,7 @@ static void xilinx_spi_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo xilinx_spi_info = {
-.name   = xlnx.xps-spi,
+.name   = TYPE_XILINX_SPI,
 .parent = TYPE_SYS_BUS_DEVICE,
 .instance_size  = sizeof(XilinxSPI),
 .class_init = xilinx_spi_class_init,
-- 
1.8.1.4




Re: [Qemu-devel] Cirrus VGA slow screen update, show blank screen last 13s or so for windows XP guest

2013-07-27 Thread Gonglei (Arei)

 -Original Message-
 From: Andreas Färber [mailto:afaer...@suse.de]
 Sent: Friday, July 26, 2013 6:28 PM
 To: Gerd Hoffmann; Gonglei (Arei)
 Cc: Anthony Liguori; Hanweidong; Luonengjun; qemu-devel@nongnu.org;
 Huangweidong (Hardware); xen-de...@lists.xen.org
 Subject: Re: [Qemu-devel] Cirrus VGA slow screen update, show blank screen
 last 13s or so for windows XP guest
 
 Am 26.07.2013 12:19, schrieb Gerd Hoffmann:
  On 07/26/13 12:02, Andreas Färber wrote:
  Am 26.07.2013 08:41, schrieb Gonglei (Arei):
  -Original Message-
  From: Anthony Liguori [mailto:anth...@codemonkey.ws]
  Sent: Friday, July 26, 2013 11:21 AM
  To: Gonglei (Arei)
  Cc: qemu-devel@nongnu.org; xen-de...@lists.xen.org; Hanweidong;
  Luonengjun; Huangweidong (Hardware)
  Subject: Re: [Qemu-devel] Cirrus VGA slow screen update, show blank
 screen
  last 13s or so for windows XP guest
 
   On Thu, Jul 25, 2013 at 10:08 PM, Gonglei (Arei)
  arei.gong...@huawei.com wrote:
  3. Why does the traditional qemu has no blank screen problem on cirrus
 VGA
  emulation ?
 
  This is one of the few cases where TCG is actually faster than KVM or
  Xen.  In TCG, an MMIO exit is converted to a function call.  OTOH,
  even with KVM, an MMIO exit is at least a couples thousand cycles.
  It's worse with Xen because dom0 has to be scheduled.
 
  Perhaps I did not express clearly what I mean at #3.
  I don't understand why the qemu-dm(qemu-0.10.2) works well
  but the upstream qemu(begin with qemu-0.14) is not for the
  same windows XP guest image in cirrus vga emulation. Does
  the cirrus vga emulation have some differences between
  qemu-dm and unstream qemu ?
 
  I don't know about qemu-dm, but QEMU switched from a home-grown pixel
  handling to pixman library sometime around 1.4. CC'ing Gerd.
 
  0.14 != 1.4 ;)
 
 Oops! In that case, Gonglei, try to reproduce the issue with upstream
 0.10 and use git-bisect to find out when things got slower between
 v0.10.2..v0.14.0. It would be unrealistic to expect us to remember all
 Cirrus-related changes from 2-4 years ago. ;)

On KVM:
I reproduced the issues that the VNC client show blank screen when Windows XP 
guest booting up 
from qemu-kvm-0.11.0 to latest qemu-1.5.1. I wanted to test qemu-kvm-0.10, but 
I didn't 
know the right command on it. The command beginning with qemu-kvm-0.11.0 is:
./qemu-system-x86_64 -name winXP -m 2048 -smp 2 -drive 
file=/mnt/sdd/image/winxp_sp3_32_2U_cn -vnc 0.0.0.0:2 -vga cirrus

Hoping to help, thanks!

-Gonglei

 
 Andreas
 
 --
 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg


[Qemu-devel] [PATCH qom-next for-1.6 08/11] stellaris_enet: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/stellaris_enet.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
index aac7c76..6194e33 100644
--- a/hw/net/stellaris_enet.c
+++ b/hw/net/stellaris_enet.c
@@ -42,8 +42,13 @@ do { fprintf(stderr, stellaris_enet: error:  fmt , ## 
__VA_ARGS__);} while (0)
 #define SE_TCTL_CRC 0x04
 #define SE_TCTL_DUPLEX  0x08
 
+#define TYPE_STELLARIS_ENET stellaris_enet
+#define STELLARIS_ENET(obj) \
+OBJECT_CHECK(stellaris_enet_state, (obj), TYPE_STELLARIS_ENET)
+
 typedef struct {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 uint32_t ris;
 uint32_t im;
 uint32_t rctl;
@@ -386,7 +391,7 @@ static void stellaris_enet_cleanup(NetClientState *nc)
 {
 stellaris_enet_state *s = qemu_get_nic_opaque(nc);
 
-unregister_savevm(s-busdev.qdev, stellaris_enet, s);
+unregister_savevm(DEVICE(s), stellaris_enet, s);
 
 memory_region_destroy(s-mmio);
 
@@ -401,22 +406,23 @@ static NetClientInfo net_stellaris_enet_info = {
 .cleanup = stellaris_enet_cleanup,
 };
 
-static int stellaris_enet_init(SysBusDevice *dev)
+static int stellaris_enet_init(SysBusDevice *sbd)
 {
-stellaris_enet_state *s = FROM_SYSBUS(stellaris_enet_state, dev);
+DeviceState *dev = DEVICE(sbd);
+stellaris_enet_state *s = STELLARIS_ENET(dev);
 
 memory_region_init_io(s-mmio, OBJECT(s), stellaris_enet_ops, s,
   stellaris_enet, 0x1000);
-sysbus_init_mmio(dev, s-mmio);
-sysbus_init_irq(dev, s-irq);
+sysbus_init_mmio(sbd, s-mmio);
+sysbus_init_irq(sbd, s-irq);
 qemu_macaddr_default_if_unset(s-conf.macaddr);
 
 s-nic = qemu_new_nic(net_stellaris_enet_info, s-conf,
-  object_get_typename(OBJECT(dev)), dev-qdev.id, s);
+  object_get_typename(OBJECT(dev)), dev-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);
 
 stellaris_enet_reset(s);
-register_savevm(s-busdev.qdev, stellaris_enet, -1, 1,
+register_savevm(dev, stellaris_enet, -1, 1,
 stellaris_enet_save, stellaris_enet_load, s);
 return 0;
 }
@@ -436,7 +442,7 @@ static void stellaris_enet_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo stellaris_enet_info = {
-.name  = stellaris_enet,
+.name  = TYPE_STELLARIS_ENET,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(stellaris_enet_state),
 .class_init= stellaris_enet_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 0/3] ssi: QOM cast cleanups

2013-07-27 Thread Andreas Färber
Hello,

This series eliminates FROM_SYSBUS() in hw/ssi/.

Regards,
Andreas

Cc: Hu Tao hu...@cn.fujitsu.com

Andreas Färber (3):
  pl022: Rename pl022_state to PL022State
  pl022: QOM cast cleanup
  xilinx_spi: QOM cast cleanup

 hw/ssi/pl022.c  | 91 -
 hw/ssi/xilinx_spi.c | 27 +---
 2 files changed, 64 insertions(+), 54 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 05/11] lance: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/lance.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/hw/net/lance.c b/hw/net/lance.c
index 98bcdfc..cf86ba1 100644
--- a/hw/net/lance.c
+++ b/hw/net/lance.c
@@ -43,8 +43,13 @@
 #include pcnet.h
 #include trace.h
 
+#define TYPE_LANCE lance
+#define SYSBUS_PCNET(obj) \
+OBJECT_CHECK(SysBusPCNetState, (obj), TYPE_LANCE)
+
 typedef struct {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 PCNetState state;
 } SysBusPCNetState;
 
@@ -112,28 +117,29 @@ static const VMStateDescription vmstate_lance = {
 }
 };
 
-static int lance_init(SysBusDevice *dev)
+static int lance_init(SysBusDevice *sbd)
 {
-SysBusPCNetState *d = FROM_SYSBUS(SysBusPCNetState, dev);
+DeviceState *dev = DEVICE(sbd);
+SysBusPCNetState *d = SYSBUS_PCNET(dev);
 PCNetState *s = d-state;
 
 memory_region_init_io(s-mmio, OBJECT(d), lance_mem_ops, d,
   lance-mmio, 4);
 
-qdev_init_gpio_in(dev-qdev, parent_lance_reset, 1);
+qdev_init_gpio_in(dev, parent_lance_reset, 1);
 
-sysbus_init_mmio(dev, s-mmio);
+sysbus_init_mmio(sbd, s-mmio);
 
-sysbus_init_irq(dev, s-irq);
+sysbus_init_irq(sbd, s-irq);
 
 s-phys_mem_read = ledma_memory_read;
 s-phys_mem_write = ledma_memory_write;
-return pcnet_common_init(dev-qdev, s, net_lance_info);
+return pcnet_common_init(dev, s, net_lance_info);
 }
 
 static void lance_reset(DeviceState *dev)
 {
-SysBusPCNetState *d = DO_UPCAST(SysBusPCNetState, busdev.qdev, dev);
+SysBusPCNetState *d = SYSBUS_PCNET(dev);
 
 pcnet_h_reset(d-state);
 }
@@ -157,7 +163,7 @@ static void lance_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo lance_info = {
-.name  = lance,
+.name  = TYPE_LANCE,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(SysBusPCNetState),
 .class_init= lance_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 00/11] net: QOM cast cleanups

2013-07-27 Thread Andreas Färber
Hello,

This series eliminates FROM_SYSBUS() in hw/net/.

Regards,
Andreas

Cc: Hu Tao hu...@cn.fujitsu.com

Andreas Färber (11):
  cadence_gem: QOM cast cleanup
  etraxfs_eth: QOM cast cleanup
  etraxfs_eth: Rename fs_eth to ETRAXFSEthState
  lan9118: QOM cast cleanup
  lance: QOM cast cleanup
  milkymist-minimac2: QOM cast cleanup
  smc91c111: QOM cast cleanup
  stellaris_enet: QOM cast cleanup
  stellaris_enet: NetClientInfo::cleanup fixes
  xgmac: QOM cast cleanup
  xilinx_ethlite: QOM cast cleanup

 hw/net/cadence_gem.c| 26 ++---
 hw/net/etraxfs_eth.c| 45 
 hw/net/lan9118.c| 26 +++--
 hw/net/lance.c  | 24 ++-
 hw/net/milkymist-minimac2.c | 27 +++---
 hw/net/smc91c111.c  | 30 ++---
 hw/net/stellaris_enet.c | 38 -
 hw/net/xgmac.c  | 46 +
 hw/net/xilinx_ethlite.c | 20 +---
 9 files changed, 170 insertions(+), 112 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 02/11] etraxfs_eth: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/etraxfs_eth.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
index ab9a215..71b4fb8 100644
--- a/hw/net/etraxfs_eth.c
+++ b/hw/net/etraxfs_eth.c
@@ -322,9 +322,14 @@ static void mdio_cycle(struct qemu_mdio *bus)
 #define R_STAT  0x0b
 #define FS_ETH_MAX_REGS  0x17
 
+#define TYPE_ETRAX_FS_ETH etraxfs-eth
+#define ETRAX_FS_ETH(obj) \
+OBJECT_CHECK(struct fs_eth, (obj), TYPE_ETRAX_FS_ETH)
+
 struct fs_eth
 {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion mmio;
 NICState *nic;
 NICConf conf;
@@ -599,7 +604,7 @@ static NetClientInfo net_etraxfs_info = {
 
 static int fs_eth_init(SysBusDevice *dev)
 {
-struct fs_eth *s = FROM_SYSBUS(typeof(*s), dev);
+struct fs_eth *s = ETRAX_FS_ETH(dev);
 
 if (!s-dma_out || !s-dma_in) {
 hw_error(Unconnected ETRAX-FS Ethernet MAC.\n);
@@ -643,7 +648,7 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo etraxfs_eth_info = {
-.name  = etraxfs-eth,
+.name  = TYPE_ETRAX_FS_ETH,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(struct fs_eth),
 .class_init= etraxfs_eth_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 03/11] etraxfs_eth: Rename fs_eth to ETRAXFSEthState

2013-07-27 Thread Andreas Färber
Also add a typedef.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/etraxfs_eth.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
index 71b4fb8..b1febec 100644
--- a/hw/net/etraxfs_eth.c
+++ b/hw/net/etraxfs_eth.c
@@ -324,9 +324,9 @@ static void mdio_cycle(struct qemu_mdio *bus)
 
 #define TYPE_ETRAX_FS_ETH etraxfs-eth
 #define ETRAX_FS_ETH(obj) \
-OBJECT_CHECK(struct fs_eth, (obj), TYPE_ETRAX_FS_ETH)
+OBJECT_CHECK(ETRAXFSEthState, (obj), TYPE_ETRAX_FS_ETH)
 
-struct fs_eth
+typedef struct ETRAXFSEthState
 {
 SysBusDevice parent_obj;
 
@@ -354,9 +354,9 @@ struct fs_eth
 
 /* PHY. */
 struct qemu_phy phy;
-};
+} ETRAXFSEthState;
 
-static void eth_validate_duplex(struct fs_eth *eth)
+static void eth_validate_duplex(ETRAXFSEthState *eth)
 {
 struct qemu_phy *phy;
 unsigned int phy_duplex;
@@ -387,7 +387,7 @@ static void eth_validate_duplex(struct fs_eth *eth)
 static uint64_t
 eth_read(void *opaque, hwaddr addr, unsigned int size)
 {
-struct fs_eth *eth = opaque;
+ETRAXFSEthState *eth = opaque;
 uint32_t r = 0;
 
 addr = 2;
@@ -404,7 +404,7 @@ eth_read(void *opaque, hwaddr addr, unsigned int size)
 return r;
 }
 
-static void eth_update_ma(struct fs_eth *eth, int ma)
+static void eth_update_ma(ETRAXFSEthState *eth, int ma)
 {
 int reg;
 int i = 0;
@@ -433,7 +433,7 @@ static void
 eth_write(void *opaque, hwaddr addr,
   uint64_t val64, unsigned int size)
 {
-struct fs_eth *eth = opaque;
+ETRAXFSEthState *eth = opaque;
 uint32_t value = val64;
 
 addr = 2;
@@ -477,7 +477,7 @@ eth_write(void *opaque, hwaddr addr,
 /* The ETRAX FS has a groupt address table (GAT) which works like a k=1 bloom
filter dropping group addresses we have not joined.The filter has 64
bits (m). The has function is a simple nible xor of the group addr.*/
-static int eth_match_groupaddr(struct fs_eth *eth, const unsigned char *sa)
+static int eth_match_groupaddr(ETRAXFSEthState *eth, const unsigned char *sa)
 {
 unsigned int hsh;
 int m_individual = eth-regs[RW_REC_CTRL]  4;
@@ -528,7 +528,7 @@ static int eth_can_receive(NetClientState *nc)
 static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 {
 unsigned char sa_bcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-struct fs_eth *eth = qemu_get_nic_opaque(nc);
+ETRAXFSEthState *eth = qemu_get_nic_opaque(nc);
 int use_ma0 = eth-regs[RW_REC_CTRL]  1;
 int use_ma1 = eth-regs[RW_REC_CTRL]  2;
 int r_bcast = eth-regs[RW_REC_CTRL]  8;
@@ -552,12 +552,12 @@ static ssize_t eth_receive(NetClientState *nc, const 
uint8_t *buf, size_t size)
 /* FIXME: Find another way to pass on the fake csum.  */
 etraxfs_dmac_input(eth-dma_in, (void *)buf, size + 4, 1);
 
-return size;
+return size;
 }
 
 static int eth_tx_push(void *opaque, unsigned char *buf, int len, bool eop)
 {
-struct fs_eth *eth = opaque;
+ETRAXFSEthState *eth = opaque;
 
 D(printf(%s buf=%p len=%d\n, __func__, buf, len));
 qemu_send_packet(qemu_get_queue(eth-nic), buf, len);
@@ -566,7 +566,7 @@ static int eth_tx_push(void *opaque, unsigned char *buf, 
int len, bool eop)
 
 static void eth_set_link(NetClientState *nc)
 {
-struct fs_eth *eth = qemu_get_nic_opaque(nc);
+ETRAXFSEthState *eth = qemu_get_nic_opaque(nc);
 D(printf(%s %d\n, __func__, nc-link_down));
 eth-phy.link = !nc-link_down;
 }
@@ -583,7 +583,7 @@ static const MemoryRegionOps eth_ops = {
 
 static void eth_cleanup(NetClientState *nc)
 {
-struct fs_eth *eth = qemu_get_nic_opaque(nc);
+ETRAXFSEthState *eth = qemu_get_nic_opaque(nc);
 
 /* Disconnect the client.  */
 eth-dma_out-client.push = NULL;
@@ -604,7 +604,7 @@ static NetClientInfo net_etraxfs_info = {
 
 static int fs_eth_init(SysBusDevice *dev)
 {
-struct fs_eth *s = ETRAX_FS_ETH(dev);
+ETRAXFSEthState *s = ETRAX_FS_ETH(dev);
 
 if (!s-dma_out || !s-dma_in) {
 hw_error(Unconnected ETRAX-FS Ethernet MAC.\n);
@@ -631,10 +631,10 @@ static int fs_eth_init(SysBusDevice *dev)
 }
 
 static Property etraxfs_eth_properties[] = {
-DEFINE_PROP_UINT32(phyaddr, struct fs_eth, phyaddr, 1),
-DEFINE_PROP_PTR(dma_out, struct fs_eth, vdma_out),
-DEFINE_PROP_PTR(dma_in, struct fs_eth, vdma_in),
-DEFINE_NIC_PROPERTIES(struct fs_eth, conf),
+DEFINE_PROP_UINT32(phyaddr, ETRAXFSEthState, phyaddr, 1),
+DEFINE_PROP_PTR(dma_out, ETRAXFSEthState, vdma_out),
+DEFINE_PROP_PTR(dma_in, ETRAXFSEthState, vdma_in),
+DEFINE_NIC_PROPERTIES(ETRAXFSEthState, conf),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -650,7 +650,7 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void 
*data)
 static const TypeInfo etraxfs_eth_info = {
 .name  = TYPE_ETRAX_FS_ETH,
 .parent= TYPE_SYS_BUS_DEVICE,
-.instance_size = sizeof(struct fs_eth),
+

[Qemu-devel] [PATCH qom-next for-1.6 07/11] smc91c111: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/net/smc91c111.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
index c49e37a..f5963e2 100644
--- a/hw/net/smc91c111.c
+++ b/hw/net/smc91c111.c
@@ -16,8 +16,12 @@
 /* Number of 2k memory pages available.  */
 #define NUM_PACKETS 4
 
+#define TYPE_SMC91C111 smc91c111
+#define SMC91C111(obj) OBJECT_CHECK(smc91c111_state, (obj), TYPE_SMC91C111)
+
 typedef struct {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 NICState *nic;
 NICConf conf;
 uint16_t tcr;
@@ -254,7 +258,8 @@ static void smc91c111_queue_tx(smc91c111_state *s, int 
packet)
 
 static void smc91c111_reset(DeviceState *dev)
 {
-smc91c111_state *s = FROM_SYSBUS(smc91c111_state, SYS_BUS_DEVICE(dev));
+smc91c111_state *s = SMC91C111(dev);
+
 s-bank = 0;
 s-tx_fifo_len = 0;
 s-tx_fifo_done_len = 0;
@@ -302,8 +307,9 @@ static void smc91c111_writeb(void *opaque, hwaddr offset,
 return;
 case 5:
 SET_HIGH(rcr, value);
-if (s-rcr  RCR_SOFT_RST)
-smc91c111_reset(s-busdev.qdev);
+if (s-rcr  RCR_SOFT_RST) {
+smc91c111_reset(DEVICE(s));
+}
 return;
 case 10: case 11: /* RPCR */
 /* Ignored */
@@ -744,16 +750,18 @@ static NetClientInfo net_smc91c111_info = {
 .cleanup = smc91c111_cleanup,
 };
 
-static int smc91c111_init1(SysBusDevice *dev)
+static int smc91c111_init1(SysBusDevice *sbd)
 {
-smc91c111_state *s = FROM_SYSBUS(smc91c111_state, dev);
+DeviceState *dev = DEVICE(sbd);
+smc91c111_state *s = SMC91C111(dev);
+
 memory_region_init_io(s-mmio, OBJECT(s), smc91c111_mem_ops, s,
   smc91c111-mmio, 16);
-sysbus_init_mmio(dev, s-mmio);
-sysbus_init_irq(dev, s-irq);
+sysbus_init_mmio(sbd, s-mmio);
+sysbus_init_irq(sbd, s-irq);
 qemu_macaddr_default_if_unset(s-conf.macaddr);
 s-nic = qemu_new_nic(net_smc91c111_info, s-conf,
-  object_get_typename(OBJECT(dev)), dev-qdev.id, s);
+  object_get_typename(OBJECT(dev)), dev-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);
 /* ??? Save/restore.  */
 return 0;
@@ -776,7 +784,7 @@ static void smc91c111_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo smc91c111_info = {
-.name  = smc91c111,
+.name  = TYPE_SMC91C111,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(smc91c111_state),
 .class_init= smc91c111_class_init,
@@ -795,7 +803,7 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq 
irq)
 SysBusDevice *s;
 
 qemu_check_nic_model(nd, smc91c111);
-dev = qdev_create(NULL, smc91c111);
+dev = qdev_create(NULL, TYPE_SMC91C111);
 qdev_set_nic_properties(dev, nd);
 qdev_init_nofail(dev);
 s = SYS_BUS_DEVICE(dev);
-- 
1.8.1.4




Re: [Qemu-devel] ioport: qemu-system-sparc64 currently broken

2013-07-27 Thread Mark Cave-Ayland

On 27/07/13 09:55, Paolo Bonzini wrote:


Il 27/07/2013 00:21, Mark Cave-Ayland ha scritto:

I suspect that there may be multiple breakages here (as HEAD blows up
differently with a trap failure), but this is definitely the start of
the chain.


Yes, the fixes so far are the following:

commit 2b8fbcd87007a170a9778ec6645c06f543977067
commit 5519ad0c245860526e8d269e1cd20fe239447736
commit e11ef3d184c88a316f48ba2472dcb2937d9fa24b
commit 547e9201c52629eef71b0eb8cb48dacc50bcf759
commit e7342aa39b3193473ded24cbf2233930665796e9

but something else remains.

I'll try to debug it during the hard freeze period.


Thanks Paolo - let me know if there's any further information you need.


ATB,

Mark.



[Qemu-devel] [PATCH qom-next for-1.6 00/20] timer: QOM cast cleanups

2013-07-27 Thread Andreas Färber
Hello,

This series eliminates FROM_SYSBUS() in hw/timer/.

Regards,
Andreas

Cc: Hu Tao hu...@cn.fujitsu.com

Andreas Färber (20):
  arm_timer: Rename sp804_state to SP804State
  arm_timer: QOM cast cleanup for SP804State
  arm_timer: QOM cast cleanup for icp_pit_state
  cadence_ttc: QOM cast cleanup
  etraxfs_timer: Rename etrax_timer to ETRAXTimerState
  etraxfs_timer: QOM cast cleanup
  exynos4210_mct: QOM cast cleanup
  exynos4210_pwm: QOM cast cleanup
  exynos4210_rtc: QOM cast cleanup
  grlib_gptimer: QOM cast cleanup
  lm32_timer: QOM cast cleanup
  m48t59: QOM cast cleanup for M48t59SysBusState
  milkymist-sysctl: QOM cast cleanup
  pl031: Rename pl031_state to PL031State
  pl031: QOM cast cleanup
  puv3_ost: QOM cast cleanup
  pxa2xx_timer: QOM cast cleanup
  slavio_timer: QOM cast cleanup
  tusb6010: QOM cast cleanup
  xilinx_timer: QOM cast cleanup

 hw/timer/arm_timer.c| 48 +++--
 hw/timer/cadence_ttc.c  | 13 
 hw/timer/etraxfs_timer.c| 35 +++--
 hw/timer/exynos4210_mct.c   | 13 
 hw/timer/exynos4210_pwm.c   | 12 
 hw/timer/exynos4210_rtc.c   | 13 
 hw/timer/grlib_gptimer.c| 13 
 hw/timer/lm32_timer.c   | 12 
 hw/timer/m48t59.c   | 16 +--
 hw/timer/milkymist-sysctl.c | 14 -
 hw/timer/pl031.c| 44 ++---
 hw/timer/puv3_ost.c | 12 
 hw/timer/pxa2xx_timer.c | 38 ---
 hw/timer/slavio_timer.c | 13 
 hw/timer/tusb6010.c | 26 ++--
 hw/timer/xilinx_timer.c | 11 ---
 include/hw/timer/m48t59.h   |  3 +++
 17 files changed, 215 insertions(+), 121 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 03/20] arm_timer: QOM cast cleanup for icp_pit_state

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/arm_timer.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
index 8d95743..acfea59 100644
--- a/hw/timer/arm_timer.c
+++ b/hw/timer/arm_timer.c
@@ -298,8 +298,13 @@ static int sp804_init(SysBusDevice *sbd)
 
 /* Integrator/CP timer module.  */
 
+#define TYPE_INTEGRATOR_PIT integrator_pit
+#define INTEGRATOR_PIT(obj) \
+OBJECT_CHECK(icp_pit_state, (obj), TYPE_INTEGRATOR_PIT)
+
 typedef struct {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 arm_timer_state *timer[3];
 } icp_pit_state;
@@ -341,7 +346,7 @@ static const MemoryRegionOps icp_pit_ops = {
 
 static int icp_pit_init(SysBusDevice *dev)
 {
-icp_pit_state *s = FROM_SYSBUS(icp_pit_state, dev);
+icp_pit_state *s = INTEGRATOR_PIT(dev);
 
 /* Timer 0 runs at the system clock speed (40MHz).  */
 s-timer[0] = arm_timer_init(4000);
@@ -369,7 +374,7 @@ static void icp_pit_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo icp_pit_info = {
-.name  = integrator_pit,
+.name  = TYPE_INTEGRATOR_PIT,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(icp_pit_state),
 .class_init= icp_pit_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 07/20] exynos4210_mct: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/exynos4210_mct.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
index 28ebe5d..a8009a4 100644
--- a/hw/timer/exynos4210_mct.c
+++ b/hw/timer/exynos4210_mct.c
@@ -240,8 +240,13 @@ typedef struct {
 
 } Exynos4210MCTLT;
 
+#define TYPE_EXYNOS4210_MCT exynos4210.mct
+#define EXYNOS4210_MCT(obj) \
+OBJECT_CHECK(Exynos4210MCTState, (obj), TYPE_EXYNOS4210_MCT)
+
 typedef struct Exynos4210MCTState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 
 /* Registers */
@@ -955,7 +960,7 @@ static void exynos4210_mct_update_freq(Exynos4210MCTState 
*s)
 /* set defaul_timer values for all fields */
 static void exynos4210_mct_reset(DeviceState *d)
 {
-Exynos4210MCTState *s = (Exynos4210MCTState *)d;
+Exynos4210MCTState *s = EXYNOS4210_MCT(d);
 uint32_t i;
 
 s-reg_mct_cfg = 0;
@@ -1424,7 +1429,7 @@ static const MemoryRegionOps exynos4210_mct_ops = {
 static int exynos4210_mct_init(SysBusDevice *dev)
 {
 int i;
-Exynos4210MCTState *s = FROM_SYSBUS(Exynos4210MCTState, dev);
+Exynos4210MCTState *s = EXYNOS4210_MCT(dev);
 QEMUBH *bh[2];
 
 /* Global timer */
@@ -1467,7 +1472,7 @@ static void exynos4210_mct_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo exynos4210_mct_info = {
-.name  = exynos4210.mct,
+.name  = TYPE_EXYNOS4210_MCT,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(Exynos4210MCTState),
 .class_init= exynos4210_mct_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 09/20] exynos4210_rtc: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/exynos4210_rtc.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/timer/exynos4210_rtc.c b/hw/timer/exynos4210_rtc.c
index 7fca071..3f2c8c5 100644
--- a/hw/timer/exynos4210_rtc.c
+++ b/hw/timer/exynos4210_rtc.c
@@ -79,8 +79,13 @@
 
 #define RTC_BASE_FREQ   32768
 
+#define TYPE_EXYNOS4210_RTC exynos4210.rtc
+#define EXYNOS4210_RTC(obj) \
+OBJECT_CHECK(Exynos4210RTCState, (obj), TYPE_EXYNOS4210_RTC)
+
 typedef struct Exynos4210RTCState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 
 /* registers */
@@ -507,7 +512,7 @@ static void exynos4210_rtc_write(void *opaque, hwaddr 
offset,
  */
 static void exynos4210_rtc_reset(DeviceState *d)
 {
-Exynos4210RTCState *s = (Exynos4210RTCState *)d;
+Exynos4210RTCState *s = EXYNOS4210_RTC(d);
 
 qemu_get_timedate(s-current_tm, 0);
 
@@ -544,7 +549,7 @@ static const MemoryRegionOps exynos4210_rtc_ops = {
  */
 static int exynos4210_rtc_init(SysBusDevice *dev)
 {
-Exynos4210RTCState *s = FROM_SYSBUS(Exynos4210RTCState, dev);
+Exynos4210RTCState *s = EXYNOS4210_RTC(dev);
 QEMUBH *bh;
 
 bh = qemu_bh_new(exynos4210_rtc_tick, s);
@@ -577,7 +582,7 @@ static void exynos4210_rtc_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo exynos4210_rtc_info = {
-.name  = exynos4210.rtc,
+.name  = TYPE_EXYNOS4210_RTC,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(Exynos4210RTCState),
 .class_init= exynos4210_rtc_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 02/20] arm_timer: QOM cast cleanup for SP804State

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/arm_timer.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
index 25e8890..8d95743 100644
--- a/hw/timer/arm_timer.c
+++ b/hw/timer/arm_timer.c
@@ -179,8 +179,12 @@ static arm_timer_state *arm_timer_init(uint32_t freq)
  * 
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0271d/index.html
 */
 
+#define TYPE_SP804 sp804
+#define SP804(obj) OBJECT_CHECK(SP804State, (obj), TYPE_SP804)
+
 typedef struct SP804State {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 arm_timer_state *timer[2];
 uint32_t freq0, freq1;
@@ -273,21 +277,22 @@ static const VMStateDescription vmstate_sp804 = {
 }
 };
 
-static int sp804_init(SysBusDevice *dev)
+static int sp804_init(SysBusDevice *sbd)
 {
-SP804State *s = FROM_SYSBUS(SP804State, dev);
+DeviceState *dev = DEVICE(sbd);
+SP804State *s = SP804(dev);
 qemu_irq *qi;
 
 qi = qemu_allocate_irqs(sp804_set_irq, s, 2);
-sysbus_init_irq(dev, s-irq);
+sysbus_init_irq(sbd, s-irq);
 s-timer[0] = arm_timer_init(s-freq0);
 s-timer[1] = arm_timer_init(s-freq1);
 s-timer[0]-irq = qi[0];
 s-timer[1]-irq = qi[1];
 memory_region_init_io(s-iomem, OBJECT(s), sp804_ops, s,
   sp804, 0x1000);
-sysbus_init_mmio(dev, s-iomem);
-vmstate_register(dev-qdev, -1, vmstate_sp804, s);
+sysbus_init_mmio(sbd, s-iomem);
+vmstate_register(dev, -1, vmstate_sp804, s);
 return 0;
 }
 
@@ -386,7 +391,7 @@ static void sp804_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo sp804_info = {
-.name  = sp804,
+.name  = TYPE_SP804,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(SP804State),
 .class_init= sp804_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 04/20] cadence_ttc: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/cadence_ttc.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c
index a861049..888f9ce 100644
--- a/hw/timer/cadence_ttc.c
+++ b/hw/timer/cadence_ttc.c
@@ -64,8 +64,13 @@ typedef struct {
 qemu_irq irq;
 } CadenceTimerState;
 
-typedef struct {
-SysBusDevice busdev;
+#define TYPE_CADENCE_TTC cadence_ttc
+#define CADENCE_TTC(obj) \
+OBJECT_CHECK(CadenceTTCState, (obj), TYPE_CADENCE_TTC)
+
+typedef struct CadenceTTCState {
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 CadenceTimerState timer[3];
 } CadenceTTCState;
@@ -401,7 +406,7 @@ static void cadence_timer_init(uint32_t freq, 
CadenceTimerState *s)
 
 static int cadence_ttc_init(SysBusDevice *dev)
 {
-CadenceTTCState *s = FROM_SYSBUS(CadenceTTCState, dev);
+CadenceTTCState *s = CADENCE_TTC(dev);
 int i;
 
 for (i = 0; i  3; ++i) {
@@ -476,7 +481,7 @@ static void cadence_ttc_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo cadence_ttc_info = {
-.name  = cadence_ttc,
+.name  = TYPE_CADENCE_TTC,
 .parent = TYPE_SYS_BUS_DEVICE,
 .instance_size  = sizeof(CadenceTTCState),
 .class_init = cadence_ttc_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 08/20] exynos4210_pwm: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/exynos4210_pwm.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
index 8fa0bb2..a52f0f6 100644
--- a/hw/timer/exynos4210_pwm.c
+++ b/hw/timer/exynos4210_pwm.c
@@ -97,9 +97,13 @@ typedef struct {
 
 } Exynos4210PWM;
 
+#define TYPE_EXYNOS4210_PWM exynos4210.pwm
+#define EXYNOS4210_PWM(obj) \
+OBJECT_CHECK(Exynos4210PWMState, (obj), TYPE_EXYNOS4210_PWM)
 
 typedef struct Exynos4210PWMState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 
 uint32_treg_tcfg[2];
@@ -352,7 +356,7 @@ static void exynos4210_pwm_write(void *opaque, hwaddr 
offset,
  */
 static void exynos4210_pwm_reset(DeviceState *d)
 {
-Exynos4210PWMState *s = (Exynos4210PWMState *)d;
+Exynos4210PWMState *s = EXYNOS4210_PWM(d);
 int i;
 s-reg_tcfg[0] = 0x0101;
 s-reg_tcfg[1] = 0x0;
@@ -378,7 +382,7 @@ static const MemoryRegionOps exynos4210_pwm_ops = {
  */
 static int exynos4210_pwm_init(SysBusDevice *dev)
 {
-Exynos4210PWMState *s = FROM_SYSBUS(Exynos4210PWMState, dev);
+Exynos4210PWMState *s = EXYNOS4210_PWM(dev);
 int i;
 QEMUBH *bh;
 
@@ -408,7 +412,7 @@ static void exynos4210_pwm_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo exynos4210_pwm_info = {
-.name  = exynos4210.pwm,
+.name  = TYPE_EXYNOS4210_PWM,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(Exynos4210PWMState),
 .class_init= exynos4210_pwm_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 15/20] pl031: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/pl031.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c
index e705a69..d5e2f3e 100644
--- a/hw/timer/pl031.c
+++ b/hw/timer/pl031.c
@@ -33,8 +33,12 @@ do { printf(pl031:  fmt , ## __VA_ARGS__); } while (0)
 #define RTC_MIS 0x18/* Masked interrupt status register */
 #define RTC_ICR 0x1c/* Interrupt clear register */
 
+#define TYPE_PL031 pl031
+#define PL031(obj) OBJECT_CHECK(PL031State, (obj), TYPE_PL031)
+
 typedef struct PL031State {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 QEMUTimer *timer;
 qemu_irq irq;
@@ -189,7 +193,7 @@ static const MemoryRegionOps pl031_ops = {
 
 static int pl031_init(SysBusDevice *dev)
 {
-PL031State *s = FROM_SYSBUS(PL031State, dev);
+PL031State *s = PL031(dev);
 struct tm tm;
 
 memory_region_init_io(s-iomem, OBJECT(s), pl031_ops, s, pl031, 
0x1000);
@@ -251,7 +255,7 @@ static void pl031_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo pl031_info = {
-.name  = pl031,
+.name  = TYPE_PL031,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(PL031State),
 .class_init= pl031_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 01/20] arm_timer: Rename sp804_state to SP804State

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/arm_timer.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
index 798a8da..25e8890 100644
--- a/hw/timer/arm_timer.c
+++ b/hw/timer/arm_timer.c
@@ -179,14 +179,14 @@ static arm_timer_state *arm_timer_init(uint32_t freq)
  * 
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0271d/index.html
 */
 
-typedef struct {
+typedef struct SP804State {
 SysBusDevice busdev;
 MemoryRegion iomem;
 arm_timer_state *timer[2];
 uint32_t freq0, freq1;
 int level[2];
 qemu_irq irq;
-} sp804_state;
+} SP804State;
 
 static const uint8_t sp804_ids[] = {
 /* Timer ID */
@@ -198,7 +198,7 @@ static const uint8_t sp804_ids[] = {
 /* Merge the IRQs from the two component devices.  */
 static void sp804_set_irq(void *opaque, int irq, int level)
 {
-sp804_state *s = (sp804_state *)opaque;
+SP804State *s = (SP804State *)opaque;
 
 s-level[irq] = level;
 qemu_set_irq(s-irq, s-level[0] || s-level[1]);
@@ -207,7 +207,7 @@ static void sp804_set_irq(void *opaque, int irq, int level)
 static uint64_t sp804_read(void *opaque, hwaddr offset,
unsigned size)
 {
-sp804_state *s = (sp804_state *)opaque;
+SP804State *s = (SP804State *)opaque;
 
 if (offset  0x20) {
 return arm_timer_read(s-timer[0], offset);
@@ -239,7 +239,7 @@ static uint64_t sp804_read(void *opaque, hwaddr offset,
 static void sp804_write(void *opaque, hwaddr offset,
 uint64_t value, unsigned size)
 {
-sp804_state *s = (sp804_state *)opaque;
+SP804State *s = (SP804State *)opaque;
 
 if (offset  0x20) {
 arm_timer_write(s-timer[0], offset, value);
@@ -268,14 +268,14 @@ static const VMStateDescription vmstate_sp804 = {
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
 .fields  = (VMStateField[]) {
-VMSTATE_INT32_ARRAY(level, sp804_state, 2),
+VMSTATE_INT32_ARRAY(level, SP804State, 2),
 VMSTATE_END_OF_LIST()
 }
 };
 
 static int sp804_init(SysBusDevice *dev)
 {
-sp804_state *s = FROM_SYSBUS(sp804_state, dev);
+SP804State *s = FROM_SYSBUS(SP804State, dev);
 qemu_irq *qi;
 
 qi = qemu_allocate_irqs(sp804_set_irq, s, 2);
@@ -371,8 +371,8 @@ static const TypeInfo icp_pit_info = {
 };
 
 static Property sp804_properties[] = {
-DEFINE_PROP_UINT32(freq0, sp804_state, freq0, 100),
-DEFINE_PROP_UINT32(freq1, sp804_state, freq1, 100),
+DEFINE_PROP_UINT32(freq0, SP804State, freq0, 100),
+DEFINE_PROP_UINT32(freq1, SP804State, freq1, 100),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -388,7 +388,7 @@ static void sp804_class_init(ObjectClass *klass, void *data)
 static const TypeInfo sp804_info = {
 .name  = sp804,
 .parent= TYPE_SYS_BUS_DEVICE,
-.instance_size = sizeof(sp804_state),
+.instance_size = sizeof(SP804State),
 .class_init= sp804_class_init,
 };
 
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 19/20] tusb6010: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/tusb6010.c | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/hw/timer/tusb6010.c b/hw/timer/tusb6010.c
index 47b6809..c48ecf8 100644
--- a/hw/timer/tusb6010.c
+++ b/hw/timer/tusb6010.c
@@ -26,8 +26,12 @@
 #include hw/devices.h
 #include hw/sysbus.h
 
+#define TYPE_TUSB6010 tusb6010
+#define TUSB(obj) OBJECT_CHECK(TUSBState, (obj), TYPE_TUSB6010)
+
 typedef struct TUSBState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem[2];
 qemu_irq irq;
 MUSBState *musb;
@@ -740,7 +744,7 @@ static void tusb6010_irq(void *opaque, int source, int 
level)
 
 static void tusb6010_reset(DeviceState *dev)
 {
-TUSBState *s = FROM_SYSBUS(TUSBState, SYS_BUS_DEVICE(dev));
+TUSBState *s = TUSB(dev);
 int i;
 
 s-test_reset = TUSB_PROD_TEST_RESET_VAL;
@@ -774,18 +778,20 @@ static void tusb6010_reset(DeviceState *dev)
 musb_reset(s-musb);
 }
 
-static int tusb6010_init(SysBusDevice *dev)
+static int tusb6010_init(SysBusDevice *sbd)
 {
-TUSBState *s = FROM_SYSBUS(TUSBState, dev);
+DeviceState *dev = DEVICE(sbd);
+TUSBState *s = TUSB(dev);
+
 s-otg_timer = qemu_new_timer_ns(vm_clock, tusb_otg_tick, s);
 s-pwr_timer = qemu_new_timer_ns(vm_clock, tusb_power_tick, s);
 memory_region_init_io(s-iomem[1], OBJECT(s), tusb_async_ops, s,
   tusb-async, UINT32_MAX);
-sysbus_init_mmio(dev, s-iomem[0]);
-sysbus_init_mmio(dev, s-iomem[1]);
-sysbus_init_irq(dev, s-irq);
-qdev_init_gpio_in(dev-qdev, tusb6010_irq, musb_irq_max + 1);
-s-musb = musb_init(dev-qdev, 1);
+sysbus_init_mmio(sbd, s-iomem[0]);
+sysbus_init_mmio(sbd, s-iomem[1]);
+sysbus_init_irq(sbd, s-irq);
+qdev_init_gpio_in(dev, tusb6010_irq, musb_irq_max + 1);
+s-musb = musb_init(dev, 1);
 return 0;
 }
 
@@ -799,7 +805,7 @@ static void tusb6010_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo tusb6010_info = {
-.name  = tusb6010,
+.name  = TYPE_TUSB6010,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(TUSBState),
 .class_init= tusb6010_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 10/20] grlib_gptimer: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/grlib_gptimer.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c
index 37ba47d..7c1055a 100644
--- a/hw/timer/grlib_gptimer.c
+++ b/hw/timer/grlib_gptimer.c
@@ -50,6 +50,10 @@
 #define COUNTER_RELOAD_OFFSET 0x04
 #define TIMER_BASE0x10
 
+#define TYPE_GRLIB_GPTIMER grlib,gptimer
+#define GRLIB_GPTIMER(obj) \
+OBJECT_CHECK(GPTimerUnit, (obj), TYPE_GRLIB_GPTIMER)
+
 typedef struct GPTimer GPTimer;
 typedef struct GPTimerUnit GPTimerUnit;
 
@@ -68,7 +72,8 @@ struct GPTimer {
 };
 
 struct GPTimerUnit {
-SysBusDevice  busdev;
+SysBusDevice  parent_obj;
+
 MemoryRegion iomem;
 
 uint32_t nr_timers; /* Number of timers available */
@@ -314,7 +319,7 @@ static const MemoryRegionOps grlib_gptimer_ops = {
 
 static void grlib_gptimer_reset(DeviceState *d)
 {
-GPTimerUnit *unit = container_of(d, GPTimerUnit, busdev.qdev);
+GPTimerUnit *unit = GRLIB_GPTIMER(d);
 int  i= 0;
 
 assert(unit != NULL);
@@ -343,7 +348,7 @@ static void grlib_gptimer_reset(DeviceState *d)
 
 static int grlib_gptimer_init(SysBusDevice *dev)
 {
-GPTimerUnit  *unit = FROM_SYSBUS(typeof(*unit), dev);
+GPTimerUnit  *unit = GRLIB_GPTIMER(dev);
 unsigned int  i;
 
 assert(unit-nr_timers  0);
@@ -391,7 +396,7 @@ static void grlib_gptimer_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo grlib_gptimer_info = {
-.name  = grlib,gptimer,
+.name  = TYPE_GRLIB_GPTIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(GPTimerUnit),
 .class_init= grlib_gptimer_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 11/20] lm32_timer: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/lm32_timer.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/timer/lm32_timer.c b/hw/timer/lm32_timer.c
index 016dade..986e6a1 100644
--- a/hw/timer/lm32_timer.c
+++ b/hw/timer/lm32_timer.c
@@ -50,8 +50,12 @@ enum {
 CR_STOP  = (1  3),
 };
 
+#define TYPE_LM32_TIMER lm32-timer
+#define LM32_TIMER(obj) OBJECT_CHECK(LM32TimerState, (obj), TYPE_LM32_TIMER)
+
 struct LM32TimerState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 
 QEMUBH *bh;
@@ -161,7 +165,7 @@ static void timer_hit(void *opaque)
 
 static void timer_reset(DeviceState *d)
 {
-LM32TimerState *s = container_of(d, LM32TimerState, busdev.qdev);
+LM32TimerState *s = LM32_TIMER(d);
 int i;
 
 for (i = 0; i  R_MAX; i++) {
@@ -172,7 +176,7 @@ static void timer_reset(DeviceState *d)
 
 static int lm32_timer_init(SysBusDevice *dev)
 {
-LM32TimerState *s = FROM_SYSBUS(typeof(*s), dev);
+LM32TimerState *s = LM32_TIMER(dev);
 
 sysbus_init_irq(dev, s-irq);
 
@@ -217,7 +221,7 @@ static void lm32_timer_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo lm32_timer_info = {
-.name  = lm32-timer,
+.name  = TYPE_LM32_TIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(LM32TimerState),
 .class_init= lm32_timer_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 13/20] milkymist-sysctl: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/milkymist-sysctl.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/timer/milkymist-sysctl.c b/hw/timer/milkymist-sysctl.c
index 5009394..94246e5 100644
--- a/hw/timer/milkymist-sysctl.c
+++ b/hw/timer/milkymist-sysctl.c
@@ -57,8 +57,13 @@ enum {
 R_MAX
 };
 
+#define TYPE_MILKYMIST_SYSCTL milkymist-sysctl
+#define MILKYMIST_SYSCTL(obj) \
+OBJECT_CHECK(MilkymistSysctlState, (obj), TYPE_MILKYMIST_SYSCTL)
+
 struct MilkymistSysctlState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion regs_region;
 
 QEMUBH *bh0;
@@ -246,8 +251,7 @@ static void timer1_hit(void *opaque)
 
 static void milkymist_sysctl_reset(DeviceState *d)
 {
-MilkymistSysctlState *s =
-container_of(d, MilkymistSysctlState, busdev.qdev);
+MilkymistSysctlState *s = MILKYMIST_SYSCTL(d);
 int i;
 
 for (i = 0; i  R_MAX; i++) {
@@ -267,7 +271,7 @@ static void milkymist_sysctl_reset(DeviceState *d)
 
 static int milkymist_sysctl_init(SysBusDevice *dev)
 {
-MilkymistSysctlState *s = FROM_SYSBUS(typeof(*s), dev);
+MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev);
 
 sysbus_init_irq(dev, s-gpio_irq);
 sysbus_init_irq(dev, s-timer0_irq);
@@ -324,7 +328,7 @@ static void milkymist_sysctl_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo milkymist_sysctl_info = {
-.name  = milkymist-sysctl,
+.name  = TYPE_MILKYMIST_SYSCTL,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(MilkymistSysctlState),
 .class_init= milkymist_sysctl_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 18/20] slavio_timer: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/slavio_timer.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c
index 7f844d7..33e8f6c 100644
--- a/hw/timer/slavio_timer.c
+++ b/hw/timer/slavio_timer.c
@@ -54,8 +54,13 @@ typedef struct CPUTimerState {
 uint64_t limit;
 } CPUTimerState;
 
+#define TYPE_SLAVIO_TIMER slavio_timer
+#define SLAVIO_TIMER(obj) \
+OBJECT_CHECK(SLAVIO_TIMERState, (obj), TYPE_SLAVIO_TIMER)
+
 typedef struct SLAVIO_TIMERState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 uint32_t num_cpus;
 uint32_t cputimer_mode;
 CPUTimerState cputimer[MAX_CPUS + 1];
@@ -354,7 +359,7 @@ static const VMStateDescription vmstate_slavio_timer = {
 
 static void slavio_timer_reset(DeviceState *d)
 {
-SLAVIO_TIMERState *s = container_of(d, SLAVIO_TIMERState, busdev.qdev);
+SLAVIO_TIMERState *s = SLAVIO_TIMER(d);
 unsigned int i;
 CPUTimerState *curr_timer;
 
@@ -375,7 +380,7 @@ static void slavio_timer_reset(DeviceState *d)
 
 static int slavio_timer_init1(SysBusDevice *dev)
 {
-SLAVIO_TIMERState *s = FROM_SYSBUS(SLAVIO_TIMERState, dev);
+SLAVIO_TIMERState *s = SLAVIO_TIMER(dev);
 QEMUBH *bh;
 unsigned int i;
 TimerContext *tc;
@@ -421,7 +426,7 @@ static void slavio_timer_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo slavio_timer_info = {
-.name  = slavio_timer,
+.name  = TYPE_SLAVIO_TIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(SLAVIO_TIMERState),
 .class_init= slavio_timer_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 05/20] etraxfs_timer: Rename etrax_timer to ETRAXTimerState

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/etraxfs_timer.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
index 6dd1072..7e9807d 100644
--- a/hw/timer/etraxfs_timer.c
+++ b/hw/timer/etraxfs_timer.c
@@ -42,7 +42,7 @@
 #define R_INTR0x50
 #define R_MASKED_INTR 0x54
 
-struct etrax_timer {
+typedef struct ETRAXTimerState {
 SysBusDevice busdev;
 MemoryRegion mmio;
 qemu_irq irq;
@@ -72,12 +72,12 @@ struct etrax_timer {
 uint32_t rw_ack_intr;
 uint32_t r_intr;
 uint32_t r_masked_intr;
-};
+} ETRAXTimerState;
 
 static uint64_t
 timer_read(void *opaque, hwaddr addr, unsigned int size)
 {
-struct etrax_timer *t = opaque;
+ETRAXTimerState *t = opaque;
 uint32_t r = 0;
 
 switch (addr) {
@@ -103,7 +103,7 @@ timer_read(void *opaque, hwaddr addr, unsigned int size)
 return r;
 }
 
-static void update_ctrl(struct etrax_timer *t, int tnum)
+static void update_ctrl(ETRAXTimerState *t, int tnum)
 {
 unsigned int op;
 unsigned int freq;
@@ -167,7 +167,7 @@ static void update_ctrl(struct etrax_timer *t, int tnum)
 }
 }
 
-static void timer_update_irq(struct etrax_timer *t)
+static void timer_update_irq(ETRAXTimerState *t)
 {
 t-r_intr = ~(t-rw_ack_intr);
 t-r_masked_intr = t-r_intr  t-rw_intr_mask;
@@ -178,21 +178,21 @@ static void timer_update_irq(struct etrax_timer *t)
 
 static void timer0_hit(void *opaque)
 {
-struct etrax_timer *t = opaque;
+ETRAXTimerState *t = opaque;
 t-r_intr |= 1;
 timer_update_irq(t);
 }
 
 static void timer1_hit(void *opaque)
 {
-struct etrax_timer *t = opaque;
+ETRAXTimerState *t = opaque;
 t-r_intr |= 2;
 timer_update_irq(t);
 }
 
 static void watchdog_hit(void *opaque)
 {
-struct etrax_timer *t = opaque;
+ETRAXTimerState *t = opaque;
 if (t-wd_hits == 0) {
 /* real hw gives a single tick before reseting but we are
a bit friendlier to compensate for our slower execution.  */
@@ -206,7 +206,7 @@ static void watchdog_hit(void *opaque)
 t-wd_hits++;
 }
 
-static inline void timer_watchdog_update(struct etrax_timer *t, uint32_t value)
+static inline void timer_watchdog_update(ETRAXTimerState *t, uint32_t value)
 {
 unsigned int wd_en = t-rw_wd_ctrl  (1  8);
 unsigned int wd_key = t-rw_wd_ctrl  9;
@@ -245,7 +245,7 @@ static void
 timer_write(void *opaque, hwaddr addr,
 uint64_t val64, unsigned int size)
 {
-struct etrax_timer *t = opaque;
+ETRAXTimerState *t = opaque;
 uint32_t value = val64;
 
 switch (addr)
@@ -298,7 +298,7 @@ static const MemoryRegionOps timer_ops = {
 
 static void etraxfs_timer_reset(void *opaque)
 {
-struct etrax_timer *t = opaque;
+ETRAXTimerState *t = opaque;
 
 ptimer_stop(t-ptimer_t0);
 ptimer_stop(t-ptimer_t1);
@@ -311,7 +311,7 @@ static void etraxfs_timer_reset(void *opaque)
 
 static int etraxfs_timer_init(SysBusDevice *dev)
 {
-struct etrax_timer *t = FROM_SYSBUS(typeof (*t), dev);
+ETRAXTimerState *t = FROM_SYSBUS(typeof (*t), dev);
 
 t-bh_t0 = qemu_bh_new(timer0_hit, t);
 t-bh_t1 = qemu_bh_new(timer1_hit, t);
@@ -340,7 +340,7 @@ static void etraxfs_timer_class_init(ObjectClass *klass, 
void *data)
 static const TypeInfo etraxfs_timer_info = {
 .name  = etraxfs,timer,
 .parent= TYPE_SYS_BUS_DEVICE,
-.instance_size = sizeof (struct etrax_timer),
+.instance_size = sizeof(ETRAXTimerState),
 .class_init= etraxfs_timer_class_init,
 };
 
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 12/20] m48t59: QOM cast cleanup for M48t59SysBusState

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/m48t59.c | 16 ++--
 include/hw/timer/m48t59.h |  3 +++
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index be3490b..0cc9e5b 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -83,8 +83,12 @@ typedef struct M48t59ISAState {
 MemoryRegion io;
 } M48t59ISAState;
 
+#define SYSBUS_M48T59(obj) \
+OBJECT_CHECK(M48t59SysBusState, (obj), TYPE_SYSBUS_M48T59)
+
 typedef struct M48t59SysBusState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 M48t59State state;
 MemoryRegion io;
 } M48t59SysBusState;
@@ -621,7 +625,7 @@ static void m48t59_reset_isa(DeviceState *d)
 
 static void m48t59_reset_sysbus(DeviceState *d)
 {
-M48t59SysBusState *sys = container_of(d, M48t59SysBusState, busdev.qdev);
+M48t59SysBusState *sys = SYSBUS_M48T59(d);
 M48t59State *NVRAM = sys-state;
 
 m48t59_reset_common(NVRAM);
@@ -646,13 +650,13 @@ M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base,
 M48t59SysBusState *d;
 M48t59State *state;
 
-dev = qdev_create(NULL, m48t59);
+dev = qdev_create(NULL, TYPE_SYSBUS_M48T59);
 qdev_prop_set_uint32(dev, model, model);
 qdev_prop_set_uint32(dev, size, size);
 qdev_prop_set_uint32(dev, io_base, io_base);
 qdev_init_nofail(dev);
 s = SYS_BUS_DEVICE(dev);
-d = FROM_SYSBUS(M48t59SysBusState, s);
+d = SYSBUS_M48T59(dev);
 state = d-state;
 sysbus_connect_irq(s, 0, IRQ);
 memory_region_init_io(d-io, OBJECT(d), m48t59_io_ops, state,
@@ -716,7 +720,7 @@ static void m48t59_isa_realize(DeviceState *dev, Error 
**errp)
 
 static int m48t59_init1(SysBusDevice *dev)
 {
-M48t59SysBusState *d = FROM_SYSBUS(M48t59SysBusState, dev);
+M48t59SysBusState *d = SYSBUS_M48T59(dev);
 M48t59State *s = d-state;
 Error *err = NULL;
 
@@ -776,7 +780,7 @@ static void m48t59_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo m48t59_info = {
-.name  = m48t59,
+.name  = TYPE_SYSBUS_M48T59,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(M48t59SysBusState),
 .class_init= m48t59_class_init,
diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h
index 59337fa..8217522 100644
--- a/include/hw/timer/m48t59.h
+++ b/include/hw/timer/m48t59.h
@@ -21,6 +21,9 @@ int PPC_NVRAM_set_params (nvram_t *nvram, uint16_t NVRAM_size,
   uint32_t initrd_image, uint32_t initrd_size,
   uint32_t NVRAM_image,
   int width, int height, int depth);
+
+#define TYPE_SYSBUS_M48T59 m48t59
+
 typedef struct M48t59State M48t59State;
 
 void m48t59_write (void *private, uint32_t addr, uint32_t val);
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 06/20] etraxfs_timer: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/etraxfs_timer.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
index 7e9807d..a38d9e4 100644
--- a/hw/timer/etraxfs_timer.c
+++ b/hw/timer/etraxfs_timer.c
@@ -42,8 +42,13 @@
 #define R_INTR0x50
 #define R_MASKED_INTR 0x54
 
+#define TYPE_ETRAX_FS_TIMER etraxfs,timer
+#define ETRAX_TIMER(obj) \
+OBJECT_CHECK(ETRAXTimerState, (obj), TYPE_ETRAX_FS_TIMER)
+
 typedef struct ETRAXTimerState {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion mmio;
 qemu_irq irq;
 qemu_irq nmi;
@@ -311,7 +316,7 @@ static void etraxfs_timer_reset(void *opaque)
 
 static int etraxfs_timer_init(SysBusDevice *dev)
 {
-ETRAXTimerState *t = FROM_SYSBUS(typeof (*t), dev);
+ETRAXTimerState *t = ETRAX_TIMER(dev);
 
 t-bh_t0 = qemu_bh_new(timer0_hit, t);
 t-bh_t1 = qemu_bh_new(timer1_hit, t);
@@ -338,7 +343,7 @@ static void etraxfs_timer_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo etraxfs_timer_info = {
-.name  = etraxfs,timer,
+.name  = TYPE_ETRAX_FS_TIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(ETRAXTimerState),
 .class_init= etraxfs_timer_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 20/20] xilinx_timer: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/xilinx_timer.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c
index ee53834..5f2c902 100644
--- a/hw/timer/xilinx_timer.c
+++ b/hw/timer/xilinx_timer.c
@@ -57,9 +57,14 @@ struct xlx_timer
 uint32_t regs[R_MAX];
 };
 
+#define TYPE_XILINX_TIMER xlnx.xps-timer
+#define XILINX_TIMER(obj) \
+OBJECT_CHECK(struct timerblock, (obj), TYPE_XILINX_TIMER)
+
 struct timerblock
 {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion mmio;
 qemu_irq irq;
 uint8_t one_timer_only;
@@ -200,7 +205,7 @@ static void timer_hit(void *opaque)
 
 static int xilinx_timer_init(SysBusDevice *dev)
 {
-struct timerblock *t = FROM_SYSBUS(typeof (*t), dev);
+struct timerblock *t = XILINX_TIMER(dev);
 unsigned int i;
 
 /* All timers share a single irq line.  */
@@ -241,7 +246,7 @@ static void xilinx_timer_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo xilinx_timer_info = {
-.name  = xlnx.xps-timer,
+.name  = TYPE_XILINX_TIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(struct timerblock),
 .class_init= xilinx_timer_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 17/20] pxa2xx_timer: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/pxa2xx_timer.c | 38 +++---
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c
index 4d28719..ff63fa6 100644
--- a/hw/timer/pxa2xx_timer.c
+++ b/hw/timer/pxa2xx_timer.c
@@ -60,6 +60,10 @@ static int pxa2xx_timer4_freq[8] = {
 [5 ... 7] = 0,
 };
 
+#define TYPE_PXA2XX_TIMER pxa2xx-timer
+#define PXA2XX_TIMER(obj) \
+OBJECT_CHECK(PXA2xxTimerInfo, (obj), TYPE_PXA2XX_TIMER)
+
 typedef struct PXA2xxTimerInfo PXA2xxTimerInfo;
 
 typedef struct {
@@ -80,7 +84,8 @@ typedef struct {
 } PXA2xxTimer4;
 
 struct PXA2xxTimerInfo {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 uint32_t flags;
 
@@ -429,10 +434,9 @@ static int pxa25x_timer_post_load(void *opaque, int 
version_id)
 
 static int pxa2xx_timer_init(SysBusDevice *dev)
 {
+PXA2xxTimerInfo *s = PXA2XX_TIMER(dev);
 int i;
-PXA2xxTimerInfo *s;
 
-s = FROM_SYSBUS(PXA2xxTimerInfo, dev);
 s-irq_enabled = 0;
 s-oldclock = 0;
 s-clock = 0;
@@ -527,18 +531,15 @@ static const VMStateDescription vmstate_pxa2xx_timer_regs 
= {
 static Property pxa25x_timer_dev_properties[] = {
 DEFINE_PROP_UINT32(freq, PXA2xxTimerInfo, freq, PXA25X_FREQ),
 DEFINE_PROP_BIT(tm4, PXA2xxTimerInfo, flags,
-PXA2XX_TIMER_HAVE_TM4, false),
+PXA2XX_TIMER_HAVE_TM4, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
 static void pxa25x_timer_dev_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
-SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-k-init = pxa2xx_timer_init;
 dc-desc = PXA25x timer;
-dc-vmsd = vmstate_pxa2xx_timer_regs;
 dc-props = pxa25x_timer_dev_properties;
 }
 
@@ -552,18 +553,15 @@ static const TypeInfo pxa25x_timer_dev_info = {
 static Property pxa27x_timer_dev_properties[] = {
 DEFINE_PROP_UINT32(freq, PXA2xxTimerInfo, freq, PXA27X_FREQ),
 DEFINE_PROP_BIT(tm4, PXA2xxTimerInfo, flags,
-PXA2XX_TIMER_HAVE_TM4, true),
+PXA2XX_TIMER_HAVE_TM4, true),
 DEFINE_PROP_END_OF_LIST(),
 };
 
 static void pxa27x_timer_dev_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
-SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-k-init = pxa2xx_timer_init;
 dc-desc = PXA27x timer;
-dc-vmsd = vmstate_pxa2xx_timer_regs;
 dc-props = pxa27x_timer_dev_properties;
 }
 
@@ -574,8 +572,26 @@ static const TypeInfo pxa27x_timer_dev_info = {
 .class_init= pxa27x_timer_dev_class_init,
 };
 
+static void pxa2xx_timer_class_init(ObjectClass *oc, void *data)
+{
+DeviceClass *dc = DEVICE_CLASS(oc);
+SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc);
+
+sdc-init = pxa2xx_timer_init;
+dc-vmsd = vmstate_pxa2xx_timer_regs;
+}
+
+static const TypeInfo pxa2xx_timer_type_info = {
+.name  = TYPE_PXA2XX_TIMER,
+.parent= TYPE_SYS_BUS_DEVICE,
+.instance_size = sizeof(PXA2xxTimerInfo),
+.abstract  = true,
+.class_init= pxa2xx_timer_class_init,
+};
+
 static void pxa2xx_timer_register_types(void)
 {
+type_register_static(pxa2xx_timer_type_info);
 type_register_static(pxa25x_timer_dev_info);
 type_register_static(pxa27x_timer_dev_info);
 }
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 16/20] puv3_ost: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/puv3_ost.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/timer/puv3_ost.c b/hw/timer/puv3_ost.c
index 63f2c9f..4bd2b76 100644
--- a/hw/timer/puv3_ost.c
+++ b/hw/timer/puv3_ost.c
@@ -14,9 +14,13 @@
 #undef DEBUG_PUV3
 #include hw/unicore32/puv3.h
 
+#define TYPE_PUV3_OST puv3_ost
+#define PUV3_OST(obj) OBJECT_CHECK(PUV3OSTState, (obj), TYPE_PUV3_OST)
+
 /* puv3 ostimer implementation. */
-typedef struct {
-SysBusDevice busdev;
+typedef struct PUV3OSTState {
+SysBusDevice parent_obj;
+
 MemoryRegion iomem;
 QEMUBH *bh;
 qemu_irq irq;
@@ -109,7 +113,7 @@ static void puv3_ost_tick(void *opaque)
 
 static int puv3_ost_init(SysBusDevice *dev)
 {
-PUV3OSTState *s = FROM_SYSBUS(PUV3OSTState, dev);
+PUV3OSTState *s = PUV3_OST(dev);
 
 s-reg_OIER = 0;
 s-reg_OSSR = 0;
@@ -137,7 +141,7 @@ static void puv3_ost_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo puv3_ost_info = {
-.name = puv3_ost,
+.name = TYPE_PUV3_OST,
 .parent = TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(PUV3OSTState),
 .class_init = puv3_ost_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 14/20] pl031: Rename pl031_state to PL031State

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/pl031.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c
index 3ce6ed8..e705a69 100644
--- a/hw/timer/pl031.c
+++ b/hw/timer/pl031.c
@@ -33,7 +33,7 @@ do { printf(pl031:  fmt , ## __VA_ARGS__); } while (0)
 #define RTC_MIS 0x18/* Masked interrupt status register */
 #define RTC_ICR 0x1c/* Interrupt clear register */
 
-typedef struct {
+typedef struct PL031State {
 SysBusDevice busdev;
 MemoryRegion iomem;
 QEMUTimer *timer;
@@ -51,34 +51,34 @@ typedef struct {
 uint32_t cr;
 uint32_t im;
 uint32_t is;
-} pl031_state;
+} PL031State;
 
 static const unsigned char pl031_id[] = {
 0x31, 0x10, 0x14, 0x00, /* Device ID*/
 0x0d, 0xf0, 0x05, 0xb1  /* Cell ID  */
 };
 
-static void pl031_update(pl031_state *s)
+static void pl031_update(PL031State *s)
 {
 qemu_set_irq(s-irq, s-is  s-im);
 }
 
 static void pl031_interrupt(void * opaque)
 {
-pl031_state *s = (pl031_state *)opaque;
+PL031State *s = (PL031State *)opaque;
 
 s-is = 1;
 DPRINTF(Alarm raised\n);
 pl031_update(s);
 }
 
-static uint32_t pl031_get_count(pl031_state *s)
+static uint32_t pl031_get_count(PL031State *s)
 {
 int64_t now = qemu_get_clock_ns(rtc_clock);
 return s-tick_offset + now / get_ticks_per_sec();
 }
 
-static void pl031_set_alarm(pl031_state *s)
+static void pl031_set_alarm(PL031State *s)
 {
 uint32_t ticks;
 
@@ -98,7 +98,7 @@ static void pl031_set_alarm(pl031_state *s)
 static uint64_t pl031_read(void *opaque, hwaddr offset,
unsigned size)
 {
-pl031_state *s = (pl031_state *)opaque;
+PL031State *s = (PL031State *)opaque;
 
 if (offset = 0xfe0offset  0x1000)
 return pl031_id[(offset - 0xfe0)  2];
@@ -136,7 +136,7 @@ static uint64_t pl031_read(void *opaque, hwaddr offset,
 static void pl031_write(void * opaque, hwaddr offset,
 uint64_t value, unsigned size)
 {
-pl031_state *s = (pl031_state *)opaque;
+PL031State *s = (PL031State *)opaque;
 
 
 switch (offset) {
@@ -189,7 +189,7 @@ static const MemoryRegionOps pl031_ops = {
 
 static int pl031_init(SysBusDevice *dev)
 {
-pl031_state *s = FROM_SYSBUS(pl031_state, dev);
+PL031State *s = FROM_SYSBUS(PL031State, dev);
 struct tm tm;
 
 memory_region_init_io(s-iomem, OBJECT(s), pl031_ops, s, pl031, 
0x1000);
@@ -205,7 +205,7 @@ static int pl031_init(SysBusDevice *dev)
 
 static void pl031_pre_save(void *opaque)
 {
-pl031_state *s = opaque;
+PL031State *s = opaque;
 
 /* tick_offset is base_time - rtc_clock base time.  Instead, we want to
  * store the base time relative to the vm_clock for 
backwards-compatibility.  */
@@ -215,7 +215,7 @@ static void pl031_pre_save(void *opaque)
 
 static int pl031_post_load(void *opaque, int version_id)
 {
-pl031_state *s = opaque;
+PL031State *s = opaque;
 
 int64_t delta = qemu_get_clock_ns(rtc_clock) - qemu_get_clock_ns(vm_clock);
 s-tick_offset = s-tick_offset_vmstate - delta / get_ticks_per_sec();
@@ -230,12 +230,12 @@ static const VMStateDescription vmstate_pl031 = {
 .pre_save = pl031_pre_save,
 .post_load = pl031_post_load,
 .fields = (VMStateField[]) {
-VMSTATE_UINT32(tick_offset_vmstate, pl031_state),
-VMSTATE_UINT32(mr, pl031_state),
-VMSTATE_UINT32(lr, pl031_state),
-VMSTATE_UINT32(cr, pl031_state),
-VMSTATE_UINT32(im, pl031_state),
-VMSTATE_UINT32(is, pl031_state),
+VMSTATE_UINT32(tick_offset_vmstate, PL031State),
+VMSTATE_UINT32(mr, PL031State),
+VMSTATE_UINT32(lr, PL031State),
+VMSTATE_UINT32(cr, PL031State),
+VMSTATE_UINT32(im, PL031State),
+VMSTATE_UINT32(is, PL031State),
 VMSTATE_END_OF_LIST()
 }
 };
@@ -253,7 +253,7 @@ static void pl031_class_init(ObjectClass *klass, void *data)
 static const TypeInfo pl031_info = {
 .name  = pl031,
 .parent= TYPE_SYS_BUS_DEVICE,
-.instance_size = sizeof(pl031_state),
+.instance_size = sizeof(PL031State),
 .class_init= pl031_class_init,
 };
 
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH qom-next for-1.6 15/29] pxa2xx: QOM'ify PXA2xxI2CState

2013-07-27 Thread Andreas Färber
Am 24.07.2013 09:48, schrieb Andreas Färber:
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  hw/arm/pxa2xx.c | 26 +-
  1 file changed, 17 insertions(+), 9 deletions(-)
 
 diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
 index 6548338..ab145ee 100644
 --- a/hw/arm/pxa2xx.c
 +++ b/hw/arm/pxa2xx.c
 @@ -1224,8 +1224,15 @@ typedef struct {
  PXA2xxI2CState *host;
  } PXA2xxI2CSlaveState;
  
 +#define TYPE_PXA2XX_I2C pxa2xx_i2c
 +#define PXA2XX_I2C(obj) \
 +OBJECT_CHECK(PXA2xxI2CState, (obj), TYPE_PXA2XX_I2C)
 +
  struct PXA2xxI2CState {
 -SysBusDevice busdev;
 +/* private */
 +SysBusDevice parent_obj;
 +/* public */
 +
  MemoryRegion iomem;
  PXA2xxI2CSlaveState *slave;
  i2c_bus *bus;
 @@ -1473,7 +1480,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
  SysBusDevice *i2c_dev;
  PXA2xxI2CState *s;
  
 -i2c_dev = SYS_BUS_DEVICE(qdev_create(NULL, pxa2xx_i2c));
 +i2c_dev = SYS_BUS_DEVICE(qdev_create(NULL, TYPE_PXA2XX_I2C));
  qdev_prop_set_uint32(i2c_dev-qdev, size, region_size + 1);
  qdev_prop_set_uint32(i2c_dev-qdev, offset, base  region_size);
  
 @@ -1482,7 +1489,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
  sysbus_mmio_map(i2c_dev, 0, base  ~region_size);
  sysbus_connect_irq(i2c_dev, 0, irq);
  
 -s = FROM_SYSBUS(PXA2xxI2CState, i2c_dev);
 +s = PXA2XX_I2C(i2c_dev);
  /* FIXME: Should the slave device really be on a separate bus?  */
  dev = i2c_create_slave(i2c_init_bus(NULL, dummy), pxa2xx-i2c-slave, 
 0);
  s-slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, I2C_SLAVE(dev));
[snip]

Needs the following addition.

Andreas

diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index ab145ee..ec3ac58 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1480,11 +1480,12 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
 SysBusDevice *i2c_dev;
 PXA2xxI2CState *s;

-i2c_dev = SYS_BUS_DEVICE(qdev_create(NULL, TYPE_PXA2XX_I2C));
-qdev_prop_set_uint32(i2c_dev-qdev, size, region_size + 1);
-qdev_prop_set_uint32(i2c_dev-qdev, offset, base  region_size);
+dev = qdev_create(NULL, TYPE_PXA2XX_I2C);
+i2c_dev = SYS_BUS_DEVICE(dev);
+qdev_prop_set_uint32(dev, size, region_size + 1);
+qdev_prop_set_uint32(dev, offset, base  region_size);

-qdev_init_nofail(i2c_dev-qdev);
+qdev_init_nofail(dev);

 sysbus_mmio_map(i2c_dev, 0, base  ~region_size);
 sysbus_connect_irq(i2c_dev, 0, irq);


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH qom-next for-1.6 20/29] stellaris: QOM'ify gptm_state

2013-07-27 Thread Andreas Färber
Am 24.07.2013 09:48, schrieb Andreas Färber:
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  hw/arm/stellaris.c | 13 +
  1 file changed, 9 insertions(+), 4 deletions(-)
 
 diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
 index a2b6b17..1c69bcf 100644
 --- a/hw/arm/stellaris.c
 +++ b/hw/arm/stellaris.c
 @@ -43,8 +43,13 @@ typedef const struct {
  
  /* General purpose timer module.  */
  
 +#define TYPE_STELLARIS_GPTM stellaris-gptm
 +#define STELLARIS_GPTM(obj) \
 +OBJECT_CHECK(gptm_state, (obj), TYPE_STELLARIS_GPTM)
 +
  typedef struct gptm_state {
 -SysBusDevice busdev;
 +SysBusDevice parent_obj;
 +
  MemoryRegion iomem;
  uint32_t config;
  uint32_t mode[2];
 @@ -302,7 +307,7 @@ static const VMStateDescription vmstate_stellaris_gptm = {
  
  static int stellaris_gptm_init(SysBusDevice *dev)
  {
 -gptm_state *s = FROM_SYSBUS(gptm_state, dev);
 +gptm_state *s = STELLARIS_GPTM(dev);
  
  sysbus_init_irq(dev, s-irq);
  qdev_init_gpio_out(dev-qdev, s-trigger, 1);
[snip]

Needs the following addition.

Andreas

diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 27205d0..79f6b4e 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -305,21 +305,22 @@ static const VMStateDescription
vmstate_stellaris_gptm = {
 }
 };

-static int stellaris_gptm_init(SysBusDevice *dev)
+static int stellaris_gptm_init(SysBusDevice *sbd)
 {
+DeviceState *dev = DEVICE(sbd);
 gptm_state *s = STELLARIS_GPTM(dev);

-sysbus_init_irq(dev, s-irq);
-qdev_init_gpio_out(dev-qdev, s-trigger, 1);
+sysbus_init_irq(sbd, s-irq);
+qdev_init_gpio_out(dev, s-trigger, 1);

 memory_region_init_io(s-iomem, OBJECT(s), gptm_ops, s,
   gptm, 0x1000);
-sysbus_init_mmio(dev, s-iomem);
+sysbus_init_mmio(sbd, s-iomem);

 s-opaque[0] = s-opaque[1] = s;
 s-timer[0] = qemu_new_timer_ns(vm_clock, gptm_tick, s-opaque[0]);
 s-timer[1] = qemu_new_timer_ns(vm_clock, gptm_tick, s-opaque[1]);
-vmstate_register(dev-qdev, -1, vmstate_stellaris_gptm, s);
+vmstate_register(dev, -1, vmstate_stellaris_gptm, s);
 return 0;
 }




-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH qom-next for-1.6 02/11] etraxfs_eth: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Am 27.07.2013 12:44, schrieb Andreas Färber:
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  hw/net/etraxfs_eth.c | 11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)
 
 diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
 index ab9a215..71b4fb8 100644
 --- a/hw/net/etraxfs_eth.c
 +++ b/hw/net/etraxfs_eth.c
 @@ -322,9 +322,14 @@ static void mdio_cycle(struct qemu_mdio *bus)
  #define R_STAT  0x0b
  #define FS_ETH_MAX_REGS  0x17
  
 +#define TYPE_ETRAX_FS_ETH etraxfs-eth
 +#define ETRAX_FS_ETH(obj) \
 +OBJECT_CHECK(struct fs_eth, (obj), TYPE_ETRAX_FS_ETH)
 +
  struct fs_eth
  {
 -SysBusDevice busdev;
 +SysBusDevice parent_obj;
 +
  MemoryRegion mmio;
  NICState *nic;
  NICConf conf;
 @@ -599,7 +604,7 @@ static NetClientInfo net_etraxfs_info = {
  
  static int fs_eth_init(SysBusDevice *dev)
  {
 -struct fs_eth *s = FROM_SYSBUS(typeof(*s), dev);
 +struct fs_eth *s = ETRAX_FS_ETH(dev);
  
  if (!s-dma_out || !s-dma_in) {
  hw_error(Unconnected ETRAX-FS Ethernet MAC.\n);
[snip]

Needs the following addition.

Andreas

diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
index b1febec..78ebbbc 100644
--- a/hw/net/etraxfs_eth.c
+++ b/hw/net/etraxfs_eth.c
@@ -602,8 +602,9 @@ static NetClientInfo net_etraxfs_info = {
 .link_status_changed = eth_set_link,
 };

-static int fs_eth_init(SysBusDevice *dev)
+static int fs_eth_init(SysBusDevice *sbd)
 {
+DeviceState *dev = DEVICE(sbd);
 ETRAXFSEthState *s = ETRAX_FS_ETH(dev);

 if (!s-dma_out || !s-dma_in) {
@@ -617,11 +618,11 @@ static int fs_eth_init(SysBusDevice *dev)

 memory_region_init_io(s-mmio, OBJECT(dev), eth_ops, s,
   etraxfs-eth, 0x5c);
-sysbus_init_mmio(dev, s-mmio);
+sysbus_init_mmio(sbd, s-mmio);

 qemu_macaddr_default_if_unset(s-conf.macaddr);
 s-nic = qemu_new_nic(net_etraxfs_info, s-conf,
-  object_get_typename(OBJECT(s)), dev-qdev.id, s);
+  object_get_typename(OBJECT(s)), dev-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);




-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH qom-next for-1.6 06/29] musicpal: QOM'ify musicpal_lcd_state

2013-07-27 Thread Jan Kiszka
On 2013-07-27 16:10, Andreas Färber wrote:
 Am 24.07.2013 09:48, schrieb Andreas Färber:
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  hw/arm/musicpal.c | 15 +++
  1 file changed, 11 insertions(+), 4 deletions(-)

 diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
 index 293ab26..e7efed9 100644
 --- a/hw/arm/musicpal.c
 +++ b/hw/arm/musicpal.c
 @@ -461,8 +461,15 @@ static const TypeInfo mv88w8618_eth_info = {
  
  #define MP_LCD_TEXTCOLOR0xe0e0ff /* RRGGBB */
  
 +#define TYPE_MUSICPAL_LCD musicpal_lcd
 +#define MUSICPAL_LCD(obj) \
 +OBJECT_CHECK(musicpal_lcd_state, (obj), TYPE_MUSICPAL_LCD)
 +
  typedef struct musicpal_lcd_state {
 -SysBusDevice busdev;
 +/* private */
 +SysBusDevice parent_obj;
 +/* public */
 +
  MemoryRegion iomem;
  uint32_t brightness;
  uint32_t mode;
 @@ -615,7 +622,7 @@ static const GraphicHwOps musicpal_gfx_ops = {
  
  static int musicpal_lcd_init(SysBusDevice *dev)
  {
 -musicpal_lcd_state *s = FROM_SYSBUS(musicpal_lcd_state, dev);
 +musicpal_lcd_state *s = MUSICPAL_LCD(dev);
  
  s-brightness = 7;
  
 [snip]
 
 Needs the following addition:
 
 diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
 index 6065051..9174b87 100644
 --- a/hw/arm/musicpal.c
 +++ b/hw/arm/musicpal.c
 @@ -621,20 +621,21 @@ static const GraphicHwOps musicpal_gfx_ops = {
  .gfx_update  = lcd_refresh,
  };
 
 -static int musicpal_lcd_init(SysBusDevice *dev)
 +static int musicpal_lcd_init(SysBusDevice *sbd)
  {
 +DeviceState *dev = DEVICE(sbd);
  musicpal_lcd_state *s = MUSICPAL_LCD(dev);
 
  s-brightness = 7;
 
  memory_region_init_io(s-iomem, OBJECT(s), musicpal_lcd_ops, s,
musicpal-lcd, MP_LCD_SIZE);
 -sysbus_init_mmio(dev, s-iomem);
 +sysbus_init_mmio(sbd, s-iomem);
 
 -s-con = graphic_console_init(DEVICE(dev), musicpal_gfx_ops, s);
 +s-con = graphic_console_init(dev, musicpal_gfx_ops, s);
  qemu_console_resize(s-con, 128*3, 64*3);
 
 -qdev_init_gpio_in(dev-qdev, musicpal_lcd_gpio_brigthness_in, 3);
 +qdev_init_gpio_in(dev, musicpal_lcd_gpio_brigthness_in, 3);
 
  return 0;
  }
 
 

Didn't find the time to look at this yet. But do you have images to test
the musicpal?

Jan



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH qom-next for-1.6 04/29] integratorcp: QOM'ify icp_pic_state

2013-07-27 Thread Andreas Färber
Am 24.07.2013 09:47, schrieb Andreas Färber:
 diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
 index 58f4ed7..af31007 100644
 --- a/hw/arm/integratorcp.c
 +++ b/hw/arm/integratorcp.c
[...]
 @@ -376,7 +382,7 @@ static const MemoryRegionOps icp_pic_ops = {
  
  static int icp_pic_init(SysBusDevice *dev)
  {
 -icp_pic_state *s = FROM_SYSBUS(icp_pic_state, dev);
 +icp_pic_state *s = INTEGRATOR_PIC(dev);
  
  qdev_init_gpio_in(dev-qdev, icp_pic_set_irq, 32);
  sysbus_init_irq(dev, s-parent_irq);
[snip]

Needs the following addition for -qdev.

Andreas

diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index af31007..d518188 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -380,16 +380,17 @@ static const MemoryRegionOps icp_pic_ops = {
 .endianness = DEVICE_NATIVE_ENDIAN,
 };

-static int icp_pic_init(SysBusDevice *dev)
+static int icp_pic_init(SysBusDevice *sbd)
 {
+DeviceState *dev = DEVICE(sbd);
 icp_pic_state *s = INTEGRATOR_PIC(dev);

-qdev_init_gpio_in(dev-qdev, icp_pic_set_irq, 32);
-sysbus_init_irq(dev, s-parent_irq);
-sysbus_init_irq(dev, s-parent_fiq);
+qdev_init_gpio_in(dev, icp_pic_set_irq, 32);
+sysbus_init_irq(sbd, s-parent_irq);
+sysbus_init_irq(sbd, s-parent_fiq);
 memory_region_init_io(s-iomem, OBJECT(s), icp_pic_ops, s,
   icp-pic, 0x0080);
-sysbus_init_mmio(dev, s-iomem);
+sysbus_init_mmio(sbd, s-iomem);
 return 0;
 }



-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH qom-next for-1.6 05/29] musicpal: QOM'ify mv88w8618_eth_state

2013-07-27 Thread Andreas Färber
Am 24.07.2013 09:48, schrieb Andreas Färber:
 Introduce type constant and use QOM casts.
 
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  hw/arm/musicpal.c | 13 ++---
  1 file changed, 10 insertions(+), 3 deletions(-)
 
 diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
 index b06d442..293ab26 100644
 --- a/hw/arm/musicpal.c
 +++ b/hw/arm/musicpal.c
 @@ -146,8 +146,15 @@ typedef struct mv88w8618_rx_desc {
  uint32_t next;
  } mv88w8618_rx_desc;
  
 +#define TYPE_MV88W8618_ETH mv88w8618_eth
 +#define MV88W8618_ETH(obj) \
 +OBJECT_CHECK(mv88w8618_eth_state, (obj), TYPE_MV88W8618_ETH)
 +
  typedef struct mv88w8618_eth_state {
 -SysBusDevice busdev;
 +/* private */
 +SysBusDevice parent_obj;
 +/* public */
 +
  MemoryRegion iomem;
  qemu_irq irq;
  uint32_t smir;
 @@ -384,7 +391,7 @@ static NetClientInfo net_mv88w8618_info = {
  
  static int mv88w8618_eth_init(SysBusDevice *dev)
  {
 -mv88w8618_eth_state *s = FROM_SYSBUS(mv88w8618_eth_state, dev);
 +mv88w8618_eth_state *s = MV88W8618_ETH(dev);
  
  sysbus_init_irq(dev, s-irq);
  s-nic = qemu_new_nic(net_mv88w8618_info, s-conf,
[snip]

Needs the following addition.

Andreas

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 6e8eb5d..6065051 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -389,16 +389,17 @@ static NetClientInfo net_mv88w8618_info = {
 .cleanup = eth_cleanup,
 };

-static int mv88w8618_eth_init(SysBusDevice *dev)
+static int mv88w8618_eth_init(SysBusDevice *sbd)
 {
+DeviceState *dev = DEVICE(sbd);
 mv88w8618_eth_state *s = MV88W8618_ETH(dev);

-sysbus_init_irq(dev, s-irq);
+sysbus_init_irq(sbd, s-irq);
 s-nic = qemu_new_nic(net_mv88w8618_info, s-conf,
-  object_get_typename(OBJECT(dev)),
dev-qdev.id, s);
+  object_get_typename(OBJECT(dev)), dev-id, s);
 memory_region_init_io(s-iomem, OBJECT(s), mv88w8618_eth_ops, s,
   mv88w8618-eth, MP_ETH_SIZE);
-sysbus_init_mmio(dev, s-iomem);
+sysbus_init_mmio(sbd, s-iomem);
 return 0;
 }


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH qom-next for-1.6 19/29] spitz: QOM'ify SpitzKeyboardState

2013-07-27 Thread Andreas Färber
Am 24.07.2013 09:48, schrieb Andreas Färber:
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  hw/arm/spitz.c | 17 ++---
  1 file changed, 10 insertions(+), 7 deletions(-)
 
 diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
 index 0bf5c5c..70f23b3 100644
 --- a/hw/arm/spitz.c
 +++ b/hw/arm/spitz.c
 @@ -215,8 +215,13 @@ static const int spitz_gpiomap[5] = {
  SPITZ_GPIO_SWA, SPITZ_GPIO_SWB,
  };
  
 +#define TYPE_SPITZ_KEYBOARD spitz-keyboard
 +#define SPITZ_KEYBOARD(obj) \
 +OBJECT_CHECK(SpitzKeyboardState, (obj), TYPE_SPITZ_KEYBOARD)
 +
  typedef struct {
 -SysBusDevice busdev;
 +SysBusDevice parent_obj;
 +
  qemu_irq sense[SPITZ_KEY_SENSE_NUM];
  qemu_irq gpiomap[5];
  int keymap[0x80];
 @@ -461,8 +466,8 @@ static void spitz_keyboard_register(PXA2xxState *cpu)
  DeviceState *dev;
  SpitzKeyboardState *s;
  
 -dev = sysbus_create_simple(spitz-keyboard, -1, NULL);
 -s = FROM_SYSBUS(SpitzKeyboardState, SYS_BUS_DEVICE(dev));
 +dev = sysbus_create_simple(TYPE_SPITZ_KEYBOARD, -1, NULL);
 +s = SPITZ_KEYBOARD(dev);
  
  for (i = 0; i  SPITZ_KEY_SENSE_NUM; i ++)
  qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(cpu-gpio, 
 spitz_gpio_key_sense[i]));
 @@ -487,11 +492,9 @@ static void spitz_keyboard_register(PXA2xxState *cpu)
  
  static int spitz_keyboard_init(SysBusDevice *dev)
  {
 -SpitzKeyboardState *s;
 +SpitzKeyboardState *s = SPITZ_KEYBOARD(dev);
  int i, j;
  
 -s = FROM_SYSBUS(SpitzKeyboardState, dev);
 -
  for (i = 0; i  0x80; i ++)
  s-keymap[i] = -1;
  for (i = 0; i  SPITZ_KEY_SENSE_NUM + 1; i ++)
[snip]

Needs the following addition.

Andreas

diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index 70f23b3..34f9582 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -490,8 +490,9 @@ static void spitz_keyboard_register(PXA2xxState *cpu)
 qemu_add_kbd_event_handler(spitz_keyboard_handler, s);
 }

-static int spitz_keyboard_init(SysBusDevice *dev)
+static int spitz_keyboard_init(SysBusDevice *sbd)
 {
+DeviceState *dev = DEVICE(sbd);
 SpitzKeyboardState *s = SPITZ_KEYBOARD(dev);
 int i, j;

@@ -505,8 +506,8 @@ static int spitz_keyboard_init(SysBusDevice *dev)
 spitz_keyboard_pre_map(s);

 s-kbdtimer = qemu_new_timer_ns(vm_clock, spitz_keyboard_tick, s);
-qdev_init_gpio_in(dev-qdev, spitz_keyboard_strobe,
SPITZ_KEY_STROBE_NUM);
-qdev_init_gpio_out(dev-qdev, s-sense, SPITZ_KEY_SENSE_NUM);
+qdev_init_gpio_in(dev, spitz_keyboard_strobe, SPITZ_KEY_STROBE_NUM);
+qdev_init_gpio_out(dev, s-sense, SPITZ_KEY_SENSE_NUM);

 return 0;
 }



-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH 2/9] tests: Use qapi-schema-test.json as schema parser test

2013-07-27 Thread Markus Armbruster
Eric Blake ebl...@redhat.com writes:

 On 07/26/2013 06:39 AM, Markus Armbruster wrote:
 Signed-off-by: Markus Armbruster arm...@redhat.com
 ---
  qapi-schema-test.json | 53 -
  tests/Makefile  |  8 ++---
  tests/qapi-schema/qapi-schema-test.exit |  1 +
  tests/qapi-schema/qapi-schema-test.json | 53
 +

 You don't have git rename detection turned on?  You get a more compact
 listing of file renames if you do:
 git config diff.renames true

Now I do.

 I just modified http://wiki.qemu.org/Contribute/SubmitAPatch to mention
 this tip.

Good move.

  tests/qapi-schema/qapi-schema-test.out  | 19 
  5 files changed, 77 insertions(+), 57 deletions(-)
  delete mode 100644 qapi-schema-test.json
  create mode 100644 tests/qapi-schema/qapi-schema-test.err
  create mode 100644 tests/qapi-schema/qapi-schema-test.exit
  create mode 100644 tests/qapi-schema/qapi-schema-test.json
  create mode 100644 tests/qapi-schema/qapi-schema-test.out

 Reviewed-by: Eric Blake ebl...@redhat.com

Thanks!



[Qemu-devel] [PATCH for-1.6] target-mips: do not raise exceptions when accessing invalid memory

2013-07-27 Thread Hervé Poussineau
c658b94f6e8c206c59d02aa6fbac285b86b53d2c (cpu: Turn cpu_unassigned_access()
into a CPUState hook) made MIPS raise exceptions when accessing
invalid memory for data, by unconditionally calling CPUState unassigned hook.

While this seems to be the right behaviour, this breaks a lot of guests
(Linux on Malta, NetBSD on Magnum...) which try to access not emulated devices
and crash because they don't handle the data load/store exception.

Revert to previous behaviour by not handling the !is_exec case in MIPS CPU hook.

Signed-off-by: Hervé Poussineau hpous...@reactos.org
---

Another solution would be to add a big dummy memory regions on all MIPS boards
to catch memory accesses and not raise an exception. However, this means that
each MIPS board will have its own unassigned memory handler, different from the
global QEMU one.

---
 target-mips/op_helper.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 5cf1c3f..94f1692 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -2156,7 +2156,8 @@ void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr,
 if (is_exec) {
 helper_raise_exception(env, EXCP_IBE);
 } else {
-helper_raise_exception(env, EXCP_DBE);
+qemu_log_mask(LOG_UNIMP, should raise DBE exception 
+  due to accessing memory at % HWADDR_PRIx \n, addr);
 }
 }
 #endif /* !CONFIG_USER_ONLY */
-- 
1.7.10.4




Re: [Qemu-devel] [PATCH for-1.6] target-mips: do not raise exceptions when accessing invalid memory

2013-07-27 Thread Andreas Färber
Am 27.07.2013 18:18, schrieb Hervé Poussineau:
 c658b94f6e8c206c59d02aa6fbac285b86b53d2c (cpu: Turn cpu_unassigned_access()
 into a CPUState hook) made MIPS raise exceptions when accessing
 invalid memory for data, by unconditionally calling CPUState unassigned hook.
 
 While this seems to be the right behaviour, this breaks a lot of guests
 (Linux on Malta, NetBSD on Magnum...) which try to access not emulated devices
 and crash because they don't handle the data load/store exception.
 
 Revert to previous behaviour by not handling the !is_exec case in MIPS CPU 
 hook.
 
 Signed-off-by: Hervé Poussineau hpous...@reactos.org

So before my refactoring the following targets called it in files...

alpha: cputlb.c and memory.c
microblaze: memory.c
mips: cputlb.c
sparc: cputlb.c and memory.c

... and now all four call it in both places, breaking mips.

The proposed solution looks acceptable to me, but I am no mips expert;
CC'ing Aurélien, Stefan and some Imagination guys.

As a reminder, 1.6-rc0 is due on Monday.

 ---
 
 Another solution would be to add a big dummy memory regions on all MIPS boards
 to catch memory accesses and not raise an exception. However, this means that
 each MIPS board will have its own unassigned memory handler, different from 
 the
 global QEMU one.

sparc uses the empty_slot device to catch accesses to devices that we
are not yet emulating IIUC. I.e., empty_slot_init(addr, size).

Peter/Edgar, can you double-check whether calling the unassigned_access
handler from cputlb.c rather than cpu_abort()ing is OK for microblaze?

Thanks,
Andreas

 ---
  target-mips/op_helper.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
 index 5cf1c3f..94f1692 100644
 --- a/target-mips/op_helper.c
 +++ b/target-mips/op_helper.c
 @@ -2156,7 +2156,8 @@ void mips_cpu_unassigned_access(CPUState *cs, hwaddr 
 addr,
  if (is_exec) {
  helper_raise_exception(env, EXCP_IBE);
  } else {
 -helper_raise_exception(env, EXCP_DBE);
 +qemu_log_mask(LOG_UNIMP, should raise DBE exception 
 +  due to accessing memory at % HWADDR_PRIx \n, addr);
  }
  }
  #endif /* !CONFIG_USER_ONLY */
 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH v2 7/9] qapi.py: Fix diagnosing non-objects at a schema's top-level

2013-07-27 Thread Markus Armbruster
Report syntax error instead of crashing.

Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 scripts/qapi.py   | 10 ++
 tests/qapi-schema/non-objects.err |  2 +-
 tests/qapi-schema/quoted-structural-chars.err |  2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 12fb29a..75fc282 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -64,7 +64,7 @@ class QAPISchema:
 self.accept()
 
 while self.tok != None:
-self.exprs.append(self.get_expr())
+self.exprs.append(self.get_expr(False))
 
 def accept(self):
 while True:
@@ -117,7 +117,7 @@ class QAPISchema:
 if self.tok != ':':
 raise QAPISchemaError(self, 'Expected :')
 self.accept()
-expr[key] = self.get_expr()
+expr[key] = self.get_expr(True)
 if self.tok == '}':
 self.accept()
 return expr
@@ -135,7 +135,7 @@ class QAPISchema:
 if not self.tok in [ '{', '[', ' ]:
 raise QAPISchemaError(self, 'Expected {, [, ] or string')
 while True:
-expr.append(self.get_expr())
+expr.append(self.get_expr(True))
 if self.tok == ']':
 self.accept()
 return expr
@@ -143,7 +143,9 @@ class QAPISchema:
 raise QAPISchemaError(self, 'Expected , or ]')
 self.accept()
 
-def get_expr(self):
+def get_expr(self, nested):
+if self.tok != '{' and not nested:
+raise QAPISchemaError(self, 'Expected {')
 if self.tok == '{':
 self.accept()
 expr = self.get_members()
diff --git a/tests/qapi-schema/non-objects.err 
b/tests/qapi-schema/non-objects.err
index 48c849d..a6c2dc2 100644
--- a/tests/qapi-schema/non-objects.err
+++ b/tests/qapi-schema/non-objects.err
@@ -1 +1 @@
-Crashed: type 'exceptions.AttributeError'
+stdin:1:1: Expected {
diff --git a/tests/qapi-schema/quoted-structural-chars.err 
b/tests/qapi-schema/quoted-structural-chars.err
index 48c849d..a6c2dc2 100644
--- a/tests/qapi-schema/quoted-structural-chars.err
+++ b/tests/qapi-schema/quoted-structural-chars.err
@@ -1 +1 @@
-Crashed: type 'exceptions.AttributeError'
+stdin:1:1: Expected {
-- 
1.7.11.7




[Qemu-devel] [PATCH v2 8/9] qapi.py: Rename expr_eval to expr in parse_schema()

2013-07-27 Thread Markus Armbruster
Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 scripts/qapi.py | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 75fc282..f64b7b2 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -168,15 +168,15 @@ def parse_schema(fp):
 
 exprs = []
 
-for expr_eval in schema.exprs:
-if expr_eval.has_key('enum'):
-add_enum(expr_eval['enum'])
-elif expr_eval.has_key('union'):
-add_union(expr_eval)
-add_enum('%sKind' % expr_eval['union'])
-elif expr_eval.has_key('type'):
-add_struct(expr_eval)
-exprs.append(expr_eval)
+for expr in schema.exprs:
+if expr.has_key('enum'):
+add_enum(expr['enum'])
+elif expr.has_key('union'):
+add_union(expr)
+add_enum('%sKind' % expr['union'])
+elif expr.has_key('type'):
+add_struct(expr)
+exprs.append(expr)
 
 return exprs
 
-- 
1.7.11.7




[Qemu-devel] [PATCH v2 3/9] qapi.py: Restructure lexer and parser

2013-07-27 Thread Markus Armbruster
The parser has a rather unorthodox structure:

Until EOF:

Read a section:

Generator function get_expr() yields one section after the
other, as a string.  An unindented, non-empty line that
isn't a comment starts a new section.

Lexing:

Split section into a list of tokens (strings), with help
of generator function tokenize().

Parsing:

Parse the first expression from the list of tokens, with
parse(), throw away any remaining tokens.

In parse_schema(): record value of an enum, union or
struct key (if any) in the appropriate global table,
append expression to the list of expressions.

Return list of expressions.

Known issues:

(1) Indentation is significant, unlike in real JSON.

(2) Neither lexer nor parser have any idea of source positions.  Error
reporting is hard, let's go shopping.

(3) The one error we bother to detect, we report via raise.

(4) The lexer silently ignores invalid characters.

(5) If everything in a section gets ignored, the parser crashes.

(6) The lexer treats a string containing a structural character exactly
like the structural character.

(7) Tokens trailing the first expression in a section are silently
ignored.

(8) The parser accepts any token in place of a colon.

(9) The parser treats comma as optional.

(10) parse() crashes on unexpected EOF.

(11) parse_schema() crashes when a section's expression isn't a JSON
object.

Replace this piece of original art by a thoroughly unoriginal design.
Takes care of (1), (2), (5), (6) and (7), and lays the groundwork for
addressing the others.  Generated source files remain unchanged.

Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 scripts/qapi.py| 163 +
 tests/qapi-schema/indented-expr.out|   2 +-
 tests/qapi-schema/missing-colon.out|   4 +-
 tests/qapi-schema/quoted-structural-chars.err  |   1 +
 tests/qapi-schema/quoted-structural-chars.exit |   2 +-
 tests/qapi-schema/quoted-structural-chars.out  |   3 -
 6 files changed, 88 insertions(+), 87 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 38c808e..58e315b 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -2,9 +2,11 @@
 # QAPI helper library
 #
 # Copyright IBM, Corp. 2011
+# Copyright (c) 2013 Red Hat Inc.
 #
 # Authors:
 #  Anthony Liguori aligu...@us.ibm.com
+#  Markus Armbruster arm...@redhat.com
 #
 # This work is licensed under the terms of the GNU GPLv2.
 # See the COPYING.LIB file in the top-level directory.
@@ -32,91 +34,92 @@ builtin_type_qtypes = {
 'uint64':   'QTYPE_QINT',
 }
 
-def tokenize(data):
-while len(data):
-ch = data[0]
-data = data[1:]
-if ch in ['{', '}', ':', ',', '[', ']']:
-yield ch
-elif ch in ' \n':
-None
-elif ch == ':
-string = ''
-esc = False
-while True:
-if (data == ''):
-raise Exception(Mismatched quotes)
-ch = data[0]
-data = data[1:]
-if esc:
-string += ch
-esc = False
-elif ch == \\:
-esc = True
-elif ch == ':
-break
-else:
-string += ch
-yield string
-
-def parse(tokens):
-if tokens[0] == '{':
-ret = OrderedDict()
-tokens = tokens[1:]
-while tokens[0] != '}':
-key = tokens[0]
-tokens = tokens[1:]
-
-tokens = tokens[1:] # :
-
-value, tokens = parse(tokens)
-
-if tokens[0] == ',':
-tokens = tokens[1:]
-
-ret[key] = value
-tokens = tokens[1:]
-return ret, tokens
-elif tokens[0] == '[':
-ret = []
-tokens = tokens[1:]
-while tokens[0] != ']':
-value, tokens = parse(tokens)
-if tokens[0] == ',':
-tokens = tokens[1:]
-ret.append(value)
-tokens = tokens[1:]
-return ret, tokens
-else:
-return tokens[0], tokens[1:]
-
-def evaluate(string):
-return parse(map(lambda x: x, tokenize(string)))[0]
-
-def get_expr(fp):
-expr = ''
-
-for line in fp:
-if line.startswith('#') or line == '\n':
-continue
-
-if line.startswith(' '):
-expr += line
-elif expr:
-yield expr
-expr = line
+class QAPISchema:
+
+def __init__(self, fp):
+self.fp = fp
+self.src = fp.read()
+if self.src == '' or self.src[-1] != '\n':
+self.src += '\n'
+self.cursor = 0
+self.exprs = []
+self.accept()
+
+while self.tok != None:
+

[Qemu-devel] [PATCH v2 9/9] qapi.py: Permit comments starting anywhere on the line

2013-07-27 Thread Markus Armbruster
Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 scripts/qapi.py | 3 +--
 tests/qapi-schema/comments.err  | 1 -
 tests/qapi-schema/comments.exit | 2 +-
 tests/qapi-schema/comments.out  | 3 +++
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index f64b7b2..0ebea94 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -68,13 +68,12 @@ class QAPISchema:
 
 def accept(self):
 while True:
-bol = self.cursor == 0 or self.src[self.cursor-1] == '\n'
 self.tok = self.src[self.cursor]
 self.pos = self.cursor
 self.cursor += 1
 self.val = None
 
-if self.tok == '#' and bol:
+if self.tok == '#':
 self.cursor = self.src.find('\n', self.cursor)
 elif self.tok in ['{', '}', ':', ',', '[', ']']:
 return
diff --git a/tests/qapi-schema/comments.err b/tests/qapi-schema/comments.err
index 4a82b26..e69de29 100644
--- a/tests/qapi-schema/comments.err
+++ b/tests/qapi-schema/comments.err
@@ -1 +0,0 @@
-stdin:2:33: Stray #
diff --git a/tests/qapi-schema/comments.exit b/tests/qapi-schema/comments.exit
index d00491f..573541a 100644
--- a/tests/qapi-schema/comments.exit
+++ b/tests/qapi-schema/comments.exit
@@ -1 +1 @@
-1
+0
diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
index e69de29..e3bd904 100644
--- a/tests/qapi-schema/comments.out
+++ b/tests/qapi-schema/comments.out
@@ -0,0 +1,3 @@
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
+['Status']
+[]
-- 
1.7.11.7




[Qemu-devel] [PATCH v2 2/9] tests: Use qapi-schema-test.json as schema parser test

2013-07-27 Thread Markus Armbruster
Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 tests/Makefile|  8 
 tests/qapi-schema/qapi-schema-test.exit   |  1 +
 .../qapi-schema/qapi-schema-test.json |  0
 tests/qapi-schema/qapi-schema-test.out| 19 +++
 4 files changed, 24 insertions(+), 4 deletions(-)
 create mode 100644 tests/qapi-schema/qapi-schema-test.err
 create mode 100644 tests/qapi-schema/qapi-schema-test.exit
 rename qapi-schema-test.json = tests/qapi-schema/qapi-schema-test.json (100%)
 create mode 100644 tests/qapi-schema/qapi-schema-test.out

diff --git a/tests/Makefile b/tests/Makefile
index ddb957c..d044908 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -87,7 +87,7 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
 comments.json empty.json funny-char.json indented-expr.json \
 missing-colon.json missing-comma-list.json \
 missing-comma-object.json non-objects.json \
-quoted-structural-chars.json \
+qapi-schema-test.json quoted-structural-chars.json \
 trailing-comma-list.json trailing-comma-object.json \
 unclosed-list.json unclosed-object.json unclosed-string.json)
 
@@ -125,13 +125,13 @@ tests/test-cutils$(EXESUF): tests/test-cutils.o 
util/cutils.o
 tests/test-int128$(EXESUF): tests/test-int128.o
 
 tests/test-qapi-types.c tests/test-qapi-types.h :\
-$(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
+$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json 
$(SRC_PATH)/scripts/qapi-types.py
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py 
$(gen-out-type) -o tests -p test-  $,   GEN   $@)
 tests/test-qapi-visit.c tests/test-qapi-visit.h :\
-$(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py
+$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json 
$(SRC_PATH)/scripts/qapi-visit.py
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py 
$(gen-out-type) -o tests -p test-  $,   GEN   $@)
 tests/test-qmp-commands.h tests/test-qmp-marshal.c :\
-$(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py
+$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json 
$(SRC_PATH)/scripts/qapi-commands.py
$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py 
$(gen-out-type) -o tests -p test-  $,   GEN   $@)
 
 tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o 
$(test-qapi-obj-y) libqemuutil.a libqemustub.a
diff --git a/tests/qapi-schema/qapi-schema-test.err 
b/tests/qapi-schema/qapi-schema-test.err
new file mode 100644
index 000..e69de29
diff --git a/tests/qapi-schema/qapi-schema-test.exit 
b/tests/qapi-schema/qapi-schema-test.exit
new file mode 100644
index 000..573541a
--- /dev/null
+++ b/tests/qapi-schema/qapi-schema-test.exit
@@ -0,0 +1 @@
+0
diff --git a/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
similarity index 100%
rename from qapi-schema-test.json
rename to tests/qapi-schema/qapi-schema-test.json
diff --git a/tests/qapi-schema/qapi-schema-test.out 
b/tests/qapi-schema/qapi-schema-test.out
new file mode 100644
index 000..fb00344
--- /dev/null
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -0,0 +1,19 @@
+[OrderedDict([('enum', 'EnumOne'), ('data', ['value1', 'value2', 'value3'])]),
+ OrderedDict([('type', 'NestedEnumsOne'), ('data', OrderedDict([('enum1', 
'EnumOne'), ('*enum2', 'EnumOne'), ('enum3', 'EnumOne'), ('*enum4', 
'EnumOne')]))]),
+ OrderedDict([('type', 'UserDefOne'), ('data', OrderedDict([('integer', 
'int'), ('string', 'str'), ('*enum1', 'EnumOne')]))]),
+ OrderedDict([('type', 'UserDefTwo'), ('data', OrderedDict([('string', 'str'), 
('dict', OrderedDict([('string', 'str'), ('dict', OrderedDict([('userdef', 
'UserDefOne'), ('string', 'str')])), ('*dict2', OrderedDict([('userdef', 
'UserDefOne'), ('string', 'str')]))]))]))]),
+ OrderedDict([('type', 'UserDefNested'), ('data', OrderedDict([('string0', 
'str'), ('dict1', OrderedDict([('string1', 'str'), ('dict2', 
OrderedDict([('userdef1', 'UserDefOne'), ('string2', 'str')])), ('*dict3', 
OrderedDict([('userdef2', 'UserDefOne'), ('string3', 'str')]))]))]))]),
+ OrderedDict([('type', 'UserDefA'), ('data', OrderedDict([('boolean', 
'bool')]))]),
+ OrderedDict([('type', 'UserDefB'), ('data', OrderedDict([('integer', 
'int')]))]),
+ OrderedDict([('union', 'UserDefUnion'), ('data', OrderedDict([('a', 
'UserDefA'), ('b', 'UserDefB')]))]),
+ OrderedDict([('union', 'UserDefNativeListUnion'), ('data', 
OrderedDict([('integer', ['int']), ('s8', ['int8']), ('s16', ['int16']), 
('s32', ['int32']), ('s64', ['int64']), ('u8', ['uint8']), ('u16', ['uint16']), 
('u32', ['uint32']), ('u64', ['uint64']), ('number', ['number']), ('boolean', 
['bool']), ('string', ['str'])]))]),
+ OrderedDict([('command', 'user_def_cmd'), ('data', OrderedDict())]),
+ OrderedDict([('command', 'user_def_cmd1'), ('data', 

[Qemu-devel] [PATCH v2 5/9] qapi.py: Reject invalid characters in schema file

2013-07-27 Thread Markus Armbruster
Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 scripts/qapi.py   | 2 ++
 tests/qapi-schema/comments.err| 1 +
 tests/qapi-schema/comments.exit   | 2 +-
 tests/qapi-schema/comments.out| 3 ---
 tests/qapi-schema/funny-char.err  | 1 +
 tests/qapi-schema/funny-char.exit | 2 +-
 tests/qapi-schema/funny-char.out  | 3 ---
 7 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 342d16c..0b48a1e 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -101,6 +101,8 @@ class QAPISchema:
 if self.cursor == len(self.src):
 self.tok = None
 return
+elif not self.tok.isspace():
+raise QAPISchemaError(self, 'Stray %s' % self.tok)
 
 def get_members(self):
 expr = OrderedDict()
diff --git a/tests/qapi-schema/comments.err b/tests/qapi-schema/comments.err
index e69de29..4a82b26 100644
--- a/tests/qapi-schema/comments.err
+++ b/tests/qapi-schema/comments.err
@@ -0,0 +1 @@
+stdin:2:33: Stray #
diff --git a/tests/qapi-schema/comments.exit b/tests/qapi-schema/comments.exit
index 573541a..d00491f 100644
--- a/tests/qapi-schema/comments.exit
+++ b/tests/qapi-schema/comments.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
index e3bd904..e69de29 100644
--- a/tests/qapi-schema/comments.out
+++ b/tests/qapi-schema/comments.out
@@ -1,3 +0,0 @@
-[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
-['Status']
-[]
diff --git a/tests/qapi-schema/funny-char.err b/tests/qapi-schema/funny-char.err
index e69de29..d3dd293 100644
--- a/tests/qapi-schema/funny-char.err
+++ b/tests/qapi-schema/funny-char.err
@@ -0,0 +1 @@
+stdin:2:36: Stray ;
diff --git a/tests/qapi-schema/funny-char.exit 
b/tests/qapi-schema/funny-char.exit
index 573541a..d00491f 100644
--- a/tests/qapi-schema/funny-char.exit
+++ b/tests/qapi-schema/funny-char.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/funny-char.out b/tests/qapi-schema/funny-char.out
index e3bd904..e69de29 100644
--- a/tests/qapi-schema/funny-char.out
+++ b/tests/qapi-schema/funny-char.out
@@ -1,3 +0,0 @@
-[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
-['Status']
-[]
-- 
1.7.11.7




Re: [Qemu-devel] [PATCH for-1.6] target-mips: do not raise exceptions when accessing invalid memory

2013-07-27 Thread Peter Maydell
On 27 July 2013 17:18, Hervé Poussineau hpous...@reactos.org wrote:
 Another solution would be to add a big dummy memory regions on all MIPS boards
 to catch memory accesses and not raise an exception. However, this means that
 each MIPS board will have its own unassigned memory handler, different from 
 the
 global QEMU one.

Better would be to at least provide fake RAZ/WI implementations of
devices for the boards, rather than making the dummy region cover
the whole of the address space. Not 1.6 material, though.

-- PMM



Re: [Qemu-devel] [PATCH qom-next for-1.6 4/4] pl041: QOM'ify

2013-07-27 Thread Andreas Färber
Am 26.07.2013 10:52, schrieb Hu Tao:
 On Wed, Jul 24, 2013 at 10:35:54AM +0200, Andreas Färber wrote:
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  hw/audio/pl041.c | 45 +
  1 file changed, 25 insertions(+), 20 deletions(-)
 
 Reviewed-by: Hu Tao hu...@cn.fujitsu.com

Split this one up in two steps - rename and casts - as done for later
patches.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH v2 0/9] Our QAPI parser is a hack, replace it

2013-07-27 Thread Markus Armbruster
If you think I'm exaggerating, check out the list of issues in PATCH
3/9.

v2:
* Straightforward rebase
* A few more tests in 1/9, in part suggested by Eric

Markus Armbruster (9):
  tests: QAPI schema parser tests
  tests: Use qapi-schema-test.json as schema parser test
  qapi.py: Restructure lexer and parser
  qapi.py: Decent syntax error reporting
  qapi.py: Reject invalid characters in schema file
  qapi.py: Fix schema parser to check syntax systematically
  qapi.py: Fix diagnosing non-objects at a schema's top-level
  qapi.py: Rename expr_eval to expr in parse_schema()
  qapi.py: Permit comments starting anywhere on the line

 configure  |   2 +-
 scripts/qapi.py| 227 +
 tests/Makefile |  30 ++-
 tests/qapi-schema/comments.exit|   1 +
 tests/qapi-schema/comments.json|   4 +
 tests/qapi-schema/comments.out |   3 +
 tests/qapi-schema/empty.exit   |   1 +
 tests/qapi-schema/empty.out|   3 +
 tests/qapi-schema/funny-char.err   |   1 +
 tests/qapi-schema/funny-char.exit  |   1 +
 tests/qapi-schema/funny-char.json  |   2 +
 tests/qapi-schema/indented-expr.exit   |   1 +
 tests/qapi-schema/indented-expr.json   |   2 +
 tests/qapi-schema/indented-expr.out|   3 +
 tests/qapi-schema/missing-colon.err|   1 +
 tests/qapi-schema/missing-colon.exit   |   1 +
 tests/qapi-schema/missing-colon.json   |   2 +
 tests/qapi-schema/missing-comma-list.err   |   1 +
 tests/qapi-schema/missing-comma-list.exit  |   1 +
 tests/qapi-schema/missing-comma-list.json  |   2 +
 tests/qapi-schema/missing-comma-object.err |   1 +
 tests/qapi-schema/missing-comma-object.exit|   1 +
 tests/qapi-schema/missing-comma-object.json|   2 +
 tests/qapi-schema/non-objects.err  |   1 +
 tests/qapi-schema/non-objects.exit |   1 +
 tests/qapi-schema/non-objects.json |   2 +
 tests/qapi-schema/qapi-schema-test.exit|   1 +
 .../qapi-schema/qapi-schema-test.json  |   0
 tests/qapi-schema/qapi-schema-test.out |  19 ++
 tests/qapi-schema/quoted-structural-chars.err  |   1 +
 tests/qapi-schema/quoted-structural-chars.exit |   1 +
 tests/qapi-schema/quoted-structural-chars.json |   1 +
 tests/qapi-schema/test-qapi.py |  27 +++
 tests/qapi-schema/trailing-comma-list.err  |   1 +
 tests/qapi-schema/trailing-comma-list.exit |   1 +
 tests/qapi-schema/trailing-comma-list.json |   2 +
 tests/qapi-schema/trailing-comma-object.err|   1 +
 tests/qapi-schema/trailing-comma-object.exit   |   1 +
 tests/qapi-schema/trailing-comma-object.json   |   2 +
 tests/qapi-schema/unclosed-list.err|   1 +
 tests/qapi-schema/unclosed-list.exit   |   1 +
 tests/qapi-schema/unclosed-list.json   |   1 +
 tests/qapi-schema/unclosed-object.err  |   1 +
 tests/qapi-schema/unclosed-object.exit |   1 +
 tests/qapi-schema/unclosed-object.json |   1 +
 tests/qapi-schema/unclosed-string.err  |   1 +
 tests/qapi-schema/unclosed-string.exit |   1 +
 tests/qapi-schema/unclosed-string.json |   2 +
 48 files changed, 271 insertions(+), 94 deletions(-)
 create mode 100644 tests/qapi-schema/comments.err
 create mode 100644 tests/qapi-schema/comments.exit
 create mode 100644 tests/qapi-schema/comments.json
 create mode 100644 tests/qapi-schema/comments.out
 create mode 100644 tests/qapi-schema/empty.err
 create mode 100644 tests/qapi-schema/empty.exit
 create mode 100644 tests/qapi-schema/empty.json
 create mode 100644 tests/qapi-schema/empty.out
 create mode 100644 tests/qapi-schema/funny-char.err
 create mode 100644 tests/qapi-schema/funny-char.exit
 create mode 100644 tests/qapi-schema/funny-char.json
 create mode 100644 tests/qapi-schema/funny-char.out
 create mode 100644 tests/qapi-schema/indented-expr.err
 create mode 100644 tests/qapi-schema/indented-expr.exit
 create mode 100644 tests/qapi-schema/indented-expr.json
 create mode 100644 tests/qapi-schema/indented-expr.out
 create mode 100644 tests/qapi-schema/missing-colon.err
 create mode 100644 tests/qapi-schema/missing-colon.exit
 create mode 100644 tests/qapi-schema/missing-colon.json
 create mode 100644 tests/qapi-schema/missing-colon.out
 create mode 100644 tests/qapi-schema/missing-comma-list.err
 create mode 100644 tests/qapi-schema/missing-comma-list.exit
 create mode 100644 tests/qapi-schema/missing-comma-list.json
 create mode 100644 tests/qapi-schema/missing-comma-list.out
 create mode 100644 tests/qapi-schema/missing-comma-object.err
 create mode 100644 

[Qemu-devel] [PATCH v2 1/9] tests: QAPI schema parser tests

2013-07-27 Thread Markus Armbruster
The parser handles erroneous input badly.  To be improved shortly.

Signed-off-by: Markus Armbruster arm...@redhat.com
---
 configure  |  2 +-
 tests/Makefile | 24 ++--
 tests/qapi-schema/comments.exit|  1 +
 tests/qapi-schema/comments.json|  4 
 tests/qapi-schema/comments.out |  3 +++
 tests/qapi-schema/empty.exit   |  1 +
 tests/qapi-schema/empty.out|  3 +++
 tests/qapi-schema/funny-char.exit  |  1 +
 tests/qapi-schema/funny-char.json  |  2 ++
 tests/qapi-schema/funny-char.out   |  3 +++
 tests/qapi-schema/indented-expr.exit   |  1 +
 tests/qapi-schema/indented-expr.json   |  2 ++
 tests/qapi-schema/indented-expr.out|  3 +++
 tests/qapi-schema/missing-colon.exit   |  1 +
 tests/qapi-schema/missing-colon.json   |  2 ++
 tests/qapi-schema/missing-colon.out|  3 +++
 tests/qapi-schema/missing-comma-list.exit  |  1 +
 tests/qapi-schema/missing-comma-list.json  |  2 ++
 tests/qapi-schema/missing-comma-list.out   |  3 +++
 tests/qapi-schema/missing-comma-object.exit|  1 +
 tests/qapi-schema/missing-comma-object.json|  2 ++
 tests/qapi-schema/missing-comma-object.out |  3 +++
 tests/qapi-schema/non-objects.err  |  1 +
 tests/qapi-schema/non-objects.exit |  1 +
 tests/qapi-schema/non-objects.json |  2 ++
 tests/qapi-schema/quoted-structural-chars.exit |  1 +
 tests/qapi-schema/quoted-structural-chars.json |  1 +
 tests/qapi-schema/quoted-structural-chars.out  |  3 +++
 tests/qapi-schema/test-qapi.py | 25 +
 tests/qapi-schema/trailing-comma-list.exit |  1 +
 tests/qapi-schema/trailing-comma-list.json |  2 ++
 tests/qapi-schema/trailing-comma-list.out  |  3 +++
 tests/qapi-schema/trailing-comma-object.exit   |  1 +
 tests/qapi-schema/trailing-comma-object.json   |  2 ++
 tests/qapi-schema/trailing-comma-object.out|  3 +++
 tests/qapi-schema/unclosed-list.err|  1 +
 tests/qapi-schema/unclosed-list.exit   |  1 +
 tests/qapi-schema/unclosed-list.json   |  1 +
 tests/qapi-schema/unclosed-object.err  |  1 +
 tests/qapi-schema/unclosed-object.exit |  1 +
 tests/qapi-schema/unclosed-object.json |  1 +
 tests/qapi-schema/unclosed-string.err  |  1 +
 tests/qapi-schema/unclosed-string.exit |  1 +
 tests/qapi-schema/unclosed-string.json |  2 ++
 44 files changed, 121 insertions(+), 3 deletions(-)
 create mode 100644 tests/qapi-schema/comments.err
 create mode 100644 tests/qapi-schema/comments.exit
 create mode 100644 tests/qapi-schema/comments.json
 create mode 100644 tests/qapi-schema/comments.out
 create mode 100644 tests/qapi-schema/empty.err
 create mode 100644 tests/qapi-schema/empty.exit
 create mode 100644 tests/qapi-schema/empty.json
 create mode 100644 tests/qapi-schema/empty.out
 create mode 100644 tests/qapi-schema/funny-char.err
 create mode 100644 tests/qapi-schema/funny-char.exit
 create mode 100644 tests/qapi-schema/funny-char.json
 create mode 100644 tests/qapi-schema/funny-char.out
 create mode 100644 tests/qapi-schema/indented-expr.err
 create mode 100644 tests/qapi-schema/indented-expr.exit
 create mode 100644 tests/qapi-schema/indented-expr.json
 create mode 100644 tests/qapi-schema/indented-expr.out
 create mode 100644 tests/qapi-schema/missing-colon.err
 create mode 100644 tests/qapi-schema/missing-colon.exit
 create mode 100644 tests/qapi-schema/missing-colon.json
 create mode 100644 tests/qapi-schema/missing-colon.out
 create mode 100644 tests/qapi-schema/missing-comma-list.err
 create mode 100644 tests/qapi-schema/missing-comma-list.exit
 create mode 100644 tests/qapi-schema/missing-comma-list.json
 create mode 100644 tests/qapi-schema/missing-comma-list.out
 create mode 100644 tests/qapi-schema/missing-comma-object.err
 create mode 100644 tests/qapi-schema/missing-comma-object.exit
 create mode 100644 tests/qapi-schema/missing-comma-object.json
 create mode 100644 tests/qapi-schema/missing-comma-object.out
 create mode 100644 tests/qapi-schema/non-objects.err
 create mode 100644 tests/qapi-schema/non-objects.exit
 create mode 100644 tests/qapi-schema/non-objects.json
 create mode 100644 tests/qapi-schema/non-objects.out
 create mode 100644 tests/qapi-schema/quoted-structural-chars.err
 create mode 100644 tests/qapi-schema/quoted-structural-chars.exit
 create mode 100644 tests/qapi-schema/quoted-structural-chars.json
 create mode 100644 tests/qapi-schema/quoted-structural-chars.out
 create mode 100644 tests/qapi-schema/test-qapi.py
 create mode 100644 tests/qapi-schema/trailing-comma-list.err
 create mode 100644 tests/qapi-schema/trailing-comma-list.exit
 create mode 100644 tests/qapi-schema/trailing-comma-list.json
 create mode 100644 

Re: [Qemu-devel] [PATCH qom-next for-1.6 7/8] pl110: QOM'ify pl110, pl110_versatile and pl111

2013-07-27 Thread Andreas Färber
Am 26.07.2013 14:40, schrieb Andreas Färber:
 Am 26.07.2013 04:58, schrieb Hu Tao:
 Would it be better to explicitly set PL110 version? I know PL110 is 0,
 but it's not like a normal variable which is always good to be
 initialized to 0, assuming a version number is bad. (This is not a problem
 of this patch)
 
 Sure, I can add such a no-op line. Thanks for your watchful review!

Squashed the attached patch, that should address it.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
diff --git a/hw/display/pl110.c b/hw/display/pl110.c
index c774e46..58a8ff1 100644
--- a/hw/display/pl110.c
+++ b/hw/display/pl110.c
@@ -457,7 +457,7 @@ static const GraphicHwOps pl110_gfx_ops = {
 .gfx_update  = pl110_update_display,
 };
 
-static int pl110_init(SysBusDevice *sbd)
+static int pl110_initfn(SysBusDevice *sbd)
 {
 DeviceState *dev = DEVICE(sbd);
 PL110State *s = PL110(dev);
@@ -470,6 +470,13 @@ static int pl110_init(SysBusDevice *sbd)
 return 0;
 }
 
+static void pl110_init(Object *obj)
+{
+PL110State *s = PL110(obj);
+
+s-version = PL110;
+}
+
 static void pl110_versatile_init(Object *obj)
 {
 PL110State *s = PL110(obj);
@@ -489,7 +496,7 @@ static void pl110_class_init(ObjectClass *klass, void *data)
 DeviceClass *dc = DEVICE_CLASS(klass);
 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-k-init = pl110_init;
+k-init = pl110_initfn;
 dc-no_user = 1;
 dc-vmsd = vmstate_pl110;
 }
@@ -498,6 +505,7 @@ static const TypeInfo pl110_info = {
 .name  = TYPE_PL110,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(PL110State),
+.instance_init = pl110_init,
 .class_init= pl110_class_init,
 };
 


[Qemu-devel] [PATCH v2 6/9] qapi.py: Fix schema parser to check syntax systematically

2013-07-27 Thread Markus Armbruster
Fixes at least the following parser bugs:

* accepts any token in place of a colon

* treats comma as optional

* crashes when closing braces or brackets are missing

Signed-off-by: Markus Armbruster arm...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 scripts/qapi.py  | 40 +---
 tests/qapi-schema/missing-colon.err  |  1 +
 tests/qapi-schema/missing-colon.exit |  2 +-
 tests/qapi-schema/missing-colon.out  |  3 ---
 tests/qapi-schema/missing-comma-list.err |  1 +
 tests/qapi-schema/missing-comma-list.exit|  2 +-
 tests/qapi-schema/missing-comma-list.out |  3 ---
 tests/qapi-schema/missing-comma-object.err   |  1 +
 tests/qapi-schema/missing-comma-object.exit  |  2 +-
 tests/qapi-schema/missing-comma-object.out   |  3 ---
 tests/qapi-schema/trailing-comma-list.err|  1 +
 tests/qapi-schema/trailing-comma-list.exit   |  2 +-
 tests/qapi-schema/trailing-comma-list.out|  3 ---
 tests/qapi-schema/trailing-comma-object.err  |  1 +
 tests/qapi-schema/trailing-comma-object.exit |  2 +-
 tests/qapi-schema/trailing-comma-object.out  |  3 ---
 tests/qapi-schema/unclosed-list.err  |  2 +-
 tests/qapi-schema/unclosed-object.err|  2 +-
 18 files changed, 42 insertions(+), 32 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 0b48a1e..12fb29a 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -106,24 +106,42 @@ class QAPISchema:
 
 def get_members(self):
 expr = OrderedDict()
-while self.tok != '}':
+if self.tok == '}':
+self.accept()
+return expr
+if self.tok != ':
+raise QAPISchemaError(self, 'Expected string or }')
+while True:
 key = self.val
 self.accept()
-self.accept()# :
+if self.tok != ':':
+raise QAPISchemaError(self, 'Expected :')
+self.accept()
 expr[key] = self.get_expr()
-if self.tok == ',':
+if self.tok == '}':
 self.accept()
-self.accept()
-return expr
+return expr
+if self.tok != ',':
+raise QAPISchemaError(self, 'Expected , or }')
+self.accept()
+if self.tok != ':
+raise QAPISchemaError(self, 'Expected string')
 
 def get_values(self):
 expr = []
-while self.tok != ']':
+if self.tok == ']':
+self.accept()
+return expr
+if not self.tok in [ '{', '[', ' ]:
+raise QAPISchemaError(self, 'Expected {, [, ] or string')
+while True:
 expr.append(self.get_expr())
-if self.tok == ',':
+if self.tok == ']':
 self.accept()
-self.accept()
-return expr
+return expr
+if self.tok != ',':
+raise QAPISchemaError(self, 'Expected , or ]')
+self.accept()
 
 def get_expr(self):
 if self.tok == '{':
@@ -132,9 +150,11 @@ class QAPISchema:
 elif self.tok == '[':
 self.accept()
 expr = self.get_values()
-else:
+elif self.tok == ':
 expr = self.val
 self.accept()
+else:
+raise QAPISchemaError(self, 'Expected {, [ or string')
 return expr
 
 def parse_schema(fp):
diff --git a/tests/qapi-schema/missing-colon.err 
b/tests/qapi-schema/missing-colon.err
index e69de29..9f2a355 100644
--- a/tests/qapi-schema/missing-colon.err
+++ b/tests/qapi-schema/missing-colon.err
@@ -0,0 +1 @@
+stdin:1:10: Expected :
diff --git a/tests/qapi-schema/missing-colon.exit 
b/tests/qapi-schema/missing-colon.exit
index 573541a..d00491f 100644
--- a/tests/qapi-schema/missing-colon.exit
+++ b/tests/qapi-schema/missing-colon.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/missing-colon.out 
b/tests/qapi-schema/missing-colon.out
index e67068c..e69de29 100644
--- a/tests/qapi-schema/missing-colon.out
+++ b/tests/qapi-schema/missing-colon.out
@@ -1,3 +0,0 @@
-[OrderedDict([('enum', None), ('data', ['good', 'bad', 'ugly'])])]
-[None]
-[]
diff --git a/tests/qapi-schema/missing-comma-list.err 
b/tests/qapi-schema/missing-comma-list.err
index e69de29..4fe0700 100644
--- a/tests/qapi-schema/missing-comma-list.err
+++ b/tests/qapi-schema/missing-comma-list.err
@@ -0,0 +1 @@
+stdin:2:20: Expected , or ]
diff --git a/tests/qapi-schema/missing-comma-list.exit 
b/tests/qapi-schema/missing-comma-list.exit
index 573541a..d00491f 100644
--- a/tests/qapi-schema/missing-comma-list.exit
+++ b/tests/qapi-schema/missing-comma-list.exit
@@ -1 +1 @@
-0
+1
diff --git a/tests/qapi-schema/missing-comma-list.out 
b/tests/qapi-schema/missing-comma-list.out
index e3bd904..e69de29 100644
--- a/tests/qapi-schema/missing-comma-list.out
+++ b/tests/qapi-schema/missing-comma-list.out
@@ -1,3 +0,0 @@
-[OrderedDict([('enum', 

Re: [Qemu-devel] [PATCH qom-next for-1.6 06/29] musicpal: QOM'ify musicpal_lcd_state

2013-07-27 Thread Andreas Färber
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 27.07.2013 16:33, schrieb Jan Kiszka:
 On 2013-07-27 16:10, Andreas Färber wrote:
 Needs the following addition:
 
 diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index
 6065051..9174b87 100644 --- a/hw/arm/musicpal.c +++
 b/hw/arm/musicpal.c @@ -621,20 +621,21 @@ static const
 GraphicHwOps musicpal_gfx_ops = { .gfx_update  = lcd_refresh, };
 
 -static int musicpal_lcd_init(SysBusDevice *dev) +static int
 musicpal_lcd_init(SysBusDevice *sbd) { +DeviceState *dev =
 DEVICE(sbd); musicpal_lcd_state *s = MUSICPAL_LCD(dev);
 
 s-brightness = 7;
 
 memory_region_init_io(s-iomem, OBJECT(s), musicpal_lcd_ops,
 s, musicpal-lcd, MP_LCD_SIZE); -sysbus_init_mmio(dev,
 s-iomem); +sysbus_init_mmio(sbd, s-iomem);
 
 -s-con = graphic_console_init(DEVICE(dev),
 musicpal_gfx_ops, s); +s-con = graphic_console_init(dev,
 musicpal_gfx_ops, s); qemu_console_resize(s-con, 128*3, 64*3);
 
 -qdev_init_gpio_in(dev-qdev,
 musicpal_lcd_gpio_brigthness_in, 3); +qdev_init_gpio_in(dev,
 musicpal_lcd_gpio_brigthness_in, 3);

brightness FWIW, but won't change it here. CC'ing Mr. codespell.

 
 return 0; }
 
 
 
 Didn't find the time to look at this yet. But do you have images to
 test the musicpal?

No, unfortunately I don't have any for the musicpal. I am relying on
make check and the few test images I have around, as well as trivially
being able to fix any breakage during Hard Freeze.

In this case it looked like a 1:1 relation between type and struct,
which should make the conversion unproblematic. (The not-so-trivial
cases have multiple device names in the subject.)

My latest WIP is on git://github.com/afaerber/qemu-cpu.git
qom-devices; if booting your favorite machine does not immediately
assert() then it should be OK. (ppc/s390x/arm KVM devices are still
being tested)

Andreas

- -- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (GNU/Linux)

iQIcBAEBAgAGBQJR8+gIAAoJEPou0S0+fgE/QoQP/iOLNR4wFRZ5pBkZi2B/Nif6
Tszu86cOqrDvFnFRf1fcN3sYtieKzzq2iUOaVBh8LDWr0SFsWWf3NeCOWLUpr30p
dGMIjkgIdyojmPZiqvwme1MbW8D/pCz0IADlRYlZghwkGqV/iTClOCPqgf+e4Tj8
wi2aoeBk7IHTWfmMdOqnjNeQjM/a68vEQw48gLDqPa0p+eySvFAA8P0mdlRcatub
gvoRwME3PhmjQ13qOuWw+rEHlYFokZackF++cAigM9P7Fms108a49fYaj744d3m5
A0DBqm0aV+zrdnZPZjBvOFqb4h6UO2K2i9eSyxqS0FihI3UBKjlSkzwLcKUg3iDS
9diGV1y9SruLUyestGrrQhwMG/FacZ/kWPh6vi63BrlUQlkzjfEOBa14ABYib2cS
J/QX/f+h760mEorQlF2KubeLEpTQeHlD8edtJrM1T87G57CQGCUlnJjr8zIMMXd7
IOE81yaxOp9TNz+nKZiPncoJzTJjmlS59lcgCjuU9v6185o5b7hs4ya5+Rdx2Zqr
CitjVZuJmevn5zlgJunKrT/fbVrAuflULzB5BvzL+bVZltu/tHbkXgq1adQKg7ba
AUbHnHu+Gnw1fVhye9jOVzDO6ZKbIXqbgLAb925V9lD/iGPDPOQd9Awm7zE87Y1U
lkBdP+qRIZSXWZh8pwKV
=4Ye0
-END PGP SIGNATURE-



Re: [Qemu-devel] [PATCH qom-next for-1.6 06/29] musicpal: QOM'ify musicpal_lcd_state

2013-07-27 Thread Andreas Färber
Am 24.07.2013 09:48, schrieb Andreas Färber:
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  hw/arm/musicpal.c | 15 +++
  1 file changed, 11 insertions(+), 4 deletions(-)
 
 diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
 index 293ab26..e7efed9 100644
 --- a/hw/arm/musicpal.c
 +++ b/hw/arm/musicpal.c
 @@ -461,8 +461,15 @@ static const TypeInfo mv88w8618_eth_info = {
  
  #define MP_LCD_TEXTCOLOR0xe0e0ff /* RRGGBB */
  
 +#define TYPE_MUSICPAL_LCD musicpal_lcd
 +#define MUSICPAL_LCD(obj) \
 +OBJECT_CHECK(musicpal_lcd_state, (obj), TYPE_MUSICPAL_LCD)
 +
  typedef struct musicpal_lcd_state {
 -SysBusDevice busdev;
 +/* private */
 +SysBusDevice parent_obj;
 +/* public */
 +
  MemoryRegion iomem;
  uint32_t brightness;
  uint32_t mode;
 @@ -615,7 +622,7 @@ static const GraphicHwOps musicpal_gfx_ops = {
  
  static int musicpal_lcd_init(SysBusDevice *dev)
  {
 -musicpal_lcd_state *s = FROM_SYSBUS(musicpal_lcd_state, dev);
 +musicpal_lcd_state *s = MUSICPAL_LCD(dev);
  
  s-brightness = 7;
  
[snip]

Needs the following addition:

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 6065051..9174b87 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -621,20 +621,21 @@ static const GraphicHwOps musicpal_gfx_ops = {
 .gfx_update  = lcd_refresh,
 };

-static int musicpal_lcd_init(SysBusDevice *dev)
+static int musicpal_lcd_init(SysBusDevice *sbd)
 {
+DeviceState *dev = DEVICE(sbd);
 musicpal_lcd_state *s = MUSICPAL_LCD(dev);

 s-brightness = 7;

 memory_region_init_io(s-iomem, OBJECT(s), musicpal_lcd_ops, s,
   musicpal-lcd, MP_LCD_SIZE);
-sysbus_init_mmio(dev, s-iomem);
+sysbus_init_mmio(sbd, s-iomem);

-s-con = graphic_console_init(DEVICE(dev), musicpal_gfx_ops, s);
+s-con = graphic_console_init(dev, musicpal_gfx_ops, s);
 qemu_console_resize(s-con, 128*3, 64*3);

-qdev_init_gpio_in(dev-qdev, musicpal_lcd_gpio_brigthness_in, 3);
+qdev_init_gpio_in(dev, musicpal_lcd_gpio_brigthness_in, 3);

 return 0;
 }


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH qom-next for-1.6 01/11] sysbus: Drop FROM_SYSBUS()

2013-07-27 Thread Andreas Färber
As a replacement, use your own macro based on OBJECT_CHECK().

Signed-off-by: Andreas Färber afaer...@suse.de
---
 include/hw/sysbus.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index 8c17165..fbfc066 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -55,9 +55,6 @@ struct SysBusDevice {
 pio_addr_t pio[QDEV_MAX_PIO];
 };
 
-/* Macros to compensate for lack of type inheritance in C.  */
-#define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
-
 void *sysbus_new(void);
 void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
 MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH for-1.6] target-mips: do not raise exceptions when accessing invalid memory

2013-07-27 Thread Andreas Färber
Am 27.07.2013 21:37, schrieb Stefan Weil:
 Am 27.07.2013 19:43, schrieb Peter Maydell:
 On 27 July 2013 17:18, Hervé Poussineau hpous...@reactos.org wrote:
 Another solution would be to add a big dummy memory regions on all MIPS 
 boards
 to catch memory accesses and not raise an exception. However, this means 
 that
 each MIPS board will have its own unassigned memory handler, different from 
 the
 global QEMU one.
 Better would be to at least provide fake RAZ/WI implementations of
 devices for the boards, rather than making the dummy region cover
 the whole of the address space. Not 1.6 material, though.
 
 I prefer keeping the correct code for target-mips/op_helper.c
 and adding either the big dummy memory regions or fake
 device implementations (both with TODO comments) for 1.6.

The problem I see with that is, so far no one has stepped up with a list
of what memory ranges / devices we are talking about.

The simplest for 1.6 might be to re-add an #ifndef TARGET_MIPS around
the refactored call to restore old behavior.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH qom-next for-1.6 09/11] mips_malta: QOM cast cleanup

2013-07-27 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/mips/mips_malta.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index dad58c0..e932fdc 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -79,8 +79,12 @@ typedef struct {
 SerialState *uart;
 } MaltaFPGAState;
 
+#define TYPE_MIPS_MALTA mips-malta
+#define MIPS_MALTA(obj) OBJECT_CHECK(MaltaState, (obj), TYPE_MIPS_MALTA)
+
 typedef struct {
-SysBusDevice busdev;
+SysBusDevice parent_obj;
+
 qemu_irq *i8259;
 } MaltaState;
 
@@ -808,8 +812,8 @@ void mips_malta_init(QEMUMachineInitArgs *args)
 int fl_sectors = bios_size  16;
 int be;
 
-DeviceState *dev = qdev_create(NULL, mips-malta);
-MaltaState *s = DO_UPCAST(MaltaState, busdev.qdev, dev);
+DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
+MaltaState *s = MIPS_MALTA(dev);
 
 qdev_init_nofail(dev);
 
@@ -1004,7 +1008,7 @@ static void mips_malta_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo mips_malta_device = {
-.name  = mips-malta,
+.name  = TYPE_MIPS_MALTA,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(MaltaState),
 .class_init= mips_malta_class_init,
-- 
1.8.1.4




[Qemu-devel] [PATCH qom-next for-1.6 00/11] sysbus: QOM cast cleanups -- plus outlook

2013-07-27 Thread Andreas Färber
Hello,

This series finally eliminates the FROM_SYSBUS() macro.
It goes on to fix remaining -qdev field accesses (less work than I thought).

I've been pushing out device patches ASAP to give them maximum review hours,
now here follows the rationale why I made this effort:

i) Murphy's Law

When there's two ways to write a device and one is considered obsolete,
someone at some point will apply a new device using FROM_SYSBUS().

ii) Broken Window theory

If we let devices languish in an obsolete state, then someone will refuse to
update their device patch, pointing that it is no worse than in-tree devices.
(Ignoring that it makes it even more work for others to convert, who don't
know the code and how to best name the new macros.)

iii) Why for-1.6?

Once the Hard Freeze is lifted, traditionally we will see submaintainers
quickly flushing their queues, with arm-devs.next, ppc-next and others
potentially adding devices using FROM_SYSBUS() or other deprecated constructs.

Applying these cleanups for v1.6-rc0 will lead to build failures for most
obsolete constructs and thereby more fairly distributing the work of rebasing
and/or bouncing patches among submaintainers.

Experience shows that posting such touch-all series to the list and waiting
for weeks does not give each device/target test coverage by reviewers;
having it in qemu.git and -rcX will more likely uncover bugs through testing.
In most cases only initialization and reset will be affected, so we should see
failures immediately. Fixing bugs should be trivial, and I am around to do so.

Bleading-edge version tree available for testing here:
git://github.com/afaerber/qemu-cpu.git qom-devices
https://github.com/afaerber/qemu-cpu/commits/qom-devices

iv) What's up next?

Many preceding SysBusDevice conversion patches grew a DeviceState *dev variable
to prepare for conversion to QOM realize: dev variable and sbd argument will
simply switch place, avoiding variable renaming along with functional changes.

Loved by some, loathed by others, SysBusDevices are the simplest because
no initialization/unintialization really happens at bus level (there is no bus).

PCIDevice and others with multiple levels of initfn are waiting on proposals
under discussion of how to efficiently call the parent's method implementation.
I plan to submit a RFC inspired by Peter C.'s work for ISA/CPU/virtio.

Implementing QOM CPU topologies for x86, s390x and arm SoCs requires recursive
realization - offloading that to QOM infrastructure won't make it into 1.6.
So all devices being worked on still need to manually realize their children
where they qdev_init()ed them before, violating the same ordering constraints
Paolo brought up for the infrastructure-based approach. Feedback appreciated.

Embedding busses still faces challenges wrt device ID and VMState to be solved.

Peter M. has an RFC for how to allow embedding structs while shielding fields.

A script to inspect the QOM tree similar to qtree may come increasingly handy
the more we think about devices not on a bus or actually using the composition
model we've been building up for ACPI or qtests.

qtests will come very handy the more devices we touch. Having each machine
covered by some test would be a start, having each non-default device covered
even better, and be it no-op to exercise instantiation, hot-add/remove a bonus.

Probably many other QOM TODOs not on my mind right now. :-)

Regards,
Andreas

Cc: Anthony Liguori anth...@codemonkey.ws
Cc: Hu Tao hu...@cn.fujitsu.com
Cc: Peter Crosthwaite peter.crosthwa...@xilinx.com
Cc: Paolo Bonzini pbonz...@redhat.com
Cc: Peter Maydell peter.mayd...@linaro.org

Andreas Färber (11):
  sysbus: Drop FROM_SYSBUS()
  sysbus: Remove unused sysbus_new() prototype
  exynos4210_i2c: QOM cast cleanup
  opencores_eth: QOM cast cleanup
  mipsnet: QOM cast cleanup
  kvmvapic: QOM cast cleanup
  kvm/ioapic: QOM cast cleanup
  ioapic: QOM cast cleanup
  mips_malta: QOM cast cleanup
  spapr_pci: QOM cast cleanup
  sysbus: QOM parent field cleanup for SysBusDevice

 hw/i2c/exynos4210_i2c.c | 12 +++-
 hw/i386/kvm/ioapic.c|  4 ++--
 hw/i386/kvmvapic.c  |  4 ++--
 hw/intc/ioapic.c|  2 +-
 hw/mips/mips_malta.c| 12 
 hw/net/mipsnet.c| 20 
 hw/net/opencores_eth.c  | 24 +++-
 hw/ppc/spapr_pci.c  |  7 ---
 include/hw/sysbus.h |  9 -
 9 files changed, 55 insertions(+), 39 deletions(-)

-- 
1.8.1.4




  1   2   >