[Qemu-devel] [PATCH 5/6] 9pfs-proxy: remove one half of redundrand code

2015-03-06 Thread Michael Tokarev
The 9pfs-proxy code is actually terrible: it does the same
things again and again, ignoring function arguments and
re-inventing the same values again, and a lot of code must
be consistent with each other.

In particular, lots of filesystem methods use common v9fs_request()
function and pass all method args together with pack string to it.
However, v9fs_request() just ignores this, pop the values out of
stack and sets pack string once more.  This is sort of absurd.

This patch removes per-request-type argument marshalling from
v9fs_request() and keeps it only in the individual request
handling methods.

What's left is to do something similar with receiving response,
v9fs_receive_response() function.

Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 275 +++---
 1 file changed, 14 insertions(+), 261 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index c187d31..aa9659a 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -291,22 +291,13 @@ static int v9fs_receive_status(V9fsProxy *proxy,
 /*
  * Proxy->header and proxy->request written to socket by QEMU process.
  * This request read by proxy helper process
- * returns 0 on success and -errno on error
+ * returns 0 on success and -1 (setting errno) on error
  */
 static int v9fs_request(V9fsProxy *proxy, int type,
 void *response, const char *fmt, ...)
 {
-dev_t rdev;
 va_list ap;
-int size = 0;
-int retval = 0, err;
-uint64_t offset;
-ProxyHeader header = { 0, 0};
-struct timespec spec[2];
-int flags, mode, uid, gid;
-V9fsString *name, *value;
-V9fsString *path, *oldpath;
-struct iovec *iovec = NULL, *reply = NULL;
+int retval, err;
 
 qemu_mutex_lock(&proxy->mutex);
 
@@ -315,218 +306,8 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 goto out;
 }
 
-iovec = &proxy->out_iovec;
-reply = &proxy->in_iovec;
 va_start(ap, fmt);
-switch (type) {
-case T_OPEN:
-path = va_arg(ap, V9fsString *);
-flags = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, flags);
-if (retval > 0) {
-header.size = retval;
-header.type = T_OPEN;
-}
-break;
-case T_CREATE:
-path = va_arg(ap, V9fsString *);
-flags = va_arg(ap, int);
-mode = va_arg(ap, int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path,
-flags, mode, uid, gid);
-if (retval > 0) {
-header.size = retval;
-header.type = T_CREATE;
-}
-break;
-case T_MKNOD:
-path = va_arg(ap, V9fsString *);
-mode = va_arg(ap, int);
-rdev = va_arg(ap, long int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddsdq",
-uid, gid, path, mode, rdev);
-if (retval > 0) {
-header.size = retval;
-header.type = T_MKNOD;
-}
-break;
-case T_MKDIR:
-path = va_arg(ap, V9fsString *);
-mode = va_arg(ap, int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddsd",
-uid, gid, path, mode);
-if (retval > 0) {
-header.size = retval;
-header.type = T_MKDIR;
-}
-break;
-case T_SYMLINK:
-oldpath = va_arg(ap, V9fsString *);
-path = va_arg(ap, V9fsString *);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddss",
-uid, gid, oldpath, path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_SYMLINK;
-}
-break;
-case T_LINK:
-oldpath = va_arg(ap, V9fsString *);
-path = va_arg(ap, V9fsString *);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ss",
-oldpath, path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_LINK;
-}
-break;
-case T_LSTAT:
-path = va_arg(ap, V9fsString *);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_LSTAT;
-}
-break;
-case T_READLINK:
-path = va_arg(ap, V9fsString *);
-size = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, size);
-if (retval > 0) {
-header.size = retval;
-header.type = T_READLINK;
-}
-break;
-case T_STATFS:
-path = va_arg(ap, V9fsStr

[Qemu-devel] [PATCH 6/6] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv

2015-03-06 Thread Michael Tokarev
Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index aa9659a..1b62e2a 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -436,7 +436,7 @@ static ssize_t proxy_preadv(FsContext *ctx, 
V9fsFidOpenState *fs,
 return preadv(fs->fd, iov, iovcnt, offset);
 #else
 int err = lseek(fs->fd, offset, SEEK_SET);
-if (err == -1) {
+if (err < 0)
 return err;
 } else {
 return readv(fs->fd, iov, iovcnt);
@@ -453,10 +453,8 @@ static ssize_t proxy_pwritev(FsContext *ctx, 
V9fsFidOpenState *fs,
 #ifdef CONFIG_PREADV
 ret = pwritev(fs->fd, iov, iovcnt, offset);
 #else
-int err = lseek(fs->fd, offset, SEEK_SET);
-if (err == -1) {
-return err;
-} else {
+ret = lseek(fs->fd, offset, SEEK_SET);
+if (ret >= 0) {
 ret = writev(fs->fd, iov, iovcnt);
 }
 #endif
-- 
2.1.4




[Qemu-devel] [PATCH 42/51] fix GCC 5.0.0 logical-not-parentheses warnings

2015-03-06 Thread Michael Tokarev
From: Radim Krčmář 

man gcc:
  Warn about logical not used on the left hand side operand of a
  comparison.  This option does not warn if the RHS operand is of a
  boolean type.

By preferring bool over int where sensible, but without modifying any
depending code, make GCC happy in cases like this,
  qemu-img.c: In function ‘compare_sectors’:
  qemu-img.c:992:39: error: logical not is only applied to the left hand
  side of comparison [-Werror=logical-not-parentheses]
   if (!!memcmp(buf1, buf2, 512) != res) {

hw/ide/core.c:1836 doesn't throw an error,
  assert(!!s->error == !!(s->status & ERR_STAT));
even thought the second operand is int (and first hunk of this patch has
a very similar case), maybe GCC developers still have a little faith in
C programmers.

Signed-off-by: Radim Krčmář 
Signed-off-by: Michael Tokarev 
---
 hw/net/virtio-net.c | 4 ++--
 kvm-all.c   | 2 +-
 qemu-img.c  | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 45da34a..9381867 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -120,8 +120,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t 
status)
 return;
 }
 
-if (!!n->vhost_started ==
-(virtio_net_started(n, status) && !nc->peer->link_down)) {
+if ((virtio_net_started(n, status) && !nc->peer->link_down) ==
+!!n->vhost_started) {
 return;
 }
 if (!n->vhost_started) {
diff --git a/kvm-all.c b/kvm-all.c
index 05a79c2..07ef62c 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -366,7 +366,7 @@ static void kvm_log_stop(MemoryListener *listener,
 }
 }
 
-static int kvm_set_migration_log(int enable)
+static int kvm_set_migration_log(bool enable)
 {
 KVMState *s = kvm_state;
 KVMSlot *mem;
diff --git a/qemu-img.c b/qemu-img.c
index 6d17755..5af6f45 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -976,7 +976,8 @@ static int is_allocated_sectors_min(const uint8_t *buf, int 
n, int *pnum,
 static int compare_sectors(const uint8_t *buf1, const uint8_t *buf2, int n,
 int *pnum)
 {
-int res, i;
+bool res;
+int i;
 
 if (n <= 0) {
 *pnum = 0;
-- 
2.1.4




[Qemu-devel] [PATCH 01/51] xen-pt: fix Negative array index read

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Coverity spot:
Function xen_pt_bar_offset_to_index() may return a negative
value (-1) which is used as an index to d->io_regions[] down
the line.

Let's pass index directly as an argument to
xen_pt_bar_reg_parse().

Signed-off-by: Gonglei 
Acked-by: Stefano Stabellini 
Signed-off-by: Michael Tokarev 
---
 hw/xen/xen_pt_config_init.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index de9a20f..710fe50 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -360,15 +360,13 @@ static uint64_t xen_pt_get_bar_size(PCIIORegion *r)
 }
 
 static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,
- XenPTRegInfo *reg)
+ int index)
 {
 PCIDevice *d = &s->dev;
 XenPTRegion *region = NULL;
 PCIIORegion *r;
-int index = 0;
 
 /* check 64bit BAR */
-index = xen_pt_bar_offset_to_index(reg->offset);
 if ((0 < index) && (index < PCI_ROM_SLOT)) {
 int type = s->real_device.io_regions[index - 1].type;
 
@@ -422,7 +420,7 @@ static int xen_pt_bar_reg_init(XenPCIPassthroughState *s, 
XenPTRegInfo *reg,
 }
 
 /* set BAR flag */
-s->bases[index].bar_flag = xen_pt_bar_reg_parse(s, reg);
+s->bases[index].bar_flag = xen_pt_bar_reg_parse(s, index);
 if (s->bases[index].bar_flag == XEN_PT_BAR_FLAG_UNUSED) {
 reg_field = XEN_PT_INVALID_REG;
 }
-- 
2.1.4




[Qemu-devel] [PATCH 51/51] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv

2015-03-06 Thread Michael Tokarev
Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index aa9659a..1b62e2a 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -436,7 +436,7 @@ static ssize_t proxy_preadv(FsContext *ctx, 
V9fsFidOpenState *fs,
 return preadv(fs->fd, iov, iovcnt, offset);
 #else
 int err = lseek(fs->fd, offset, SEEK_SET);
-if (err == -1) {
+if (err < 0)
 return err;
 } else {
 return readv(fs->fd, iov, iovcnt);
@@ -453,10 +453,8 @@ static ssize_t proxy_pwritev(FsContext *ctx, 
V9fsFidOpenState *fs,
 #ifdef CONFIG_PREADV
 ret = pwritev(fs->fd, iov, iovcnt, offset);
 #else
-int err = lseek(fs->fd, offset, SEEK_SET);
-if (err == -1) {
-return err;
-} else {
+ret = lseek(fs->fd, offset, SEEK_SET);
+if (ret >= 0) {
 ret = writev(fs->fd, iov, iovcnt);
 }
 #endif
-- 
2.1.4




[Qemu-devel] [PATCH 02/51] xen-pt: fix Out-of-bounds read

2015-03-06 Thread Michael Tokarev
From: Gonglei 

The array length of s->real_device.io_regions[] is
"PCI_NUM_REGIONS - 1".

Signed-off-by: Gonglei 
Acked-by: Stefano Stabellini 
Signed-off-by: Michael Tokarev 
---
 hw/xen/xen_pt_config_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index 710fe50..d99c22e 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -438,7 +438,7 @@ static int xen_pt_bar_reg_read(XenPCIPassthroughState *s, 
XenPTReg *cfg_entry,
 
 /* get BAR index */
 index = xen_pt_bar_offset_to_index(reg->offset);
-if (index < 0 || index >= PCI_NUM_REGIONS) {
+if (index < 0 || index >= PCI_NUM_REGIONS - 1) {
 XEN_PT_ERR(&s->dev, "Internal error: Invalid BAR index [%d].\n", 
index);
 return -1;
 }
-- 
2.1.4




[Qemu-devel] [PATCH 08/51] Add copyright and author after file split

2015-03-06 Thread Michael Tokarev
From: Stefan Berger 

Signed-off-by: Stefan Berger 
Reviewed-by:  Dr. David Alan Gilbert 
Signed-off-by: Michael Tokarev 
---
 migration/qemu-file-buf.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/migration/qemu-file-buf.c b/migration/qemu-file-buf.c
index e97e0bd..e56a8ad 100644
--- a/migration/qemu-file-buf.c
+++ b/migration/qemu-file-buf.c
@@ -2,6 +2,10 @@
  * QEMU System Emulator
  *
  * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2014 IBM Corp.
+ *
+ * Authors:
+ *  Stefan Berger 
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to 
deal
-- 
2.1.4




[Qemu-devel] [PATCH 41/51] migration: Fix coding style (whitespace issues)

2015-03-06 Thread Michael Tokarev
From: Stefan Weil 

* Remove trailing whitespace (fixes 9 errors from checkpatch.pl).
  One comment line was longer than 80 characters, so wrap it
  and fix a typo, too.
* Replace tabs by blanks (fixes 1 error).

Signed-off-by: Stefan Weil 
Reviewed-by: Dr. David Alan Gilbert 
Signed-off-by: Michael Tokarev 
---
 migration/rdma.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index 1989f61..801fd4f 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -703,7 +703,7 @@ static void qemu_rdma_dump_id(const char *who, struct 
ibv_context *verbs)
 verbs->device->ibdev_path,
 port.link_layer,
 (port.link_layer == IBV_LINK_LAYER_INFINIBAND) ? "Infiniband" :
- ((port.link_layer == IBV_LINK_LAYER_ETHERNET) 
+ ((port.link_layer == IBV_LINK_LAYER_ETHERNET)
 ? "Ethernet" : "Unknown"));
 }
 
@@ -738,7 +738,7 @@ static void qemu_rdma_dump_gid(const char *who, struct 
rdma_cm_id *id)
  * and validate what time of hardware it is.
  *
  * Unfortunately, this puts the user in a fix:
- * 
+ *
  *  If the source VM connects with an IPv4 address without knowing that the
  *  destination has bound to '[::]' the migration will unconditionally fail
  *  unless the management software is explicitly listening on the the IPv4
@@ -746,13 +746,13 @@ static void qemu_rdma_dump_gid(const char *who, struct 
rdma_cm_id *id)
  *
  *  If the source VM connects with an IPv6 address, then we're OK because we 
can
  *  throw an error on the source (and similarly on the destination).
- * 
+ *
  *  But in mixed environments, this will be broken for a while until it is 
fixed
  *  inside linux.
  *
  * We do provide a *tiny* bit of help in this function: We can list all of the
  * devices in the system and check to see if all the devices are RoCE or
- * Infiniband. 
+ * Infiniband.
  *
  * If we detect that we have a *pure* RoCE environment, then we can safely
  * thrown an error even if the management software has specified '[::]' as the
@@ -771,17 +771,17 @@ static int qemu_rdma_broken_ipv6_kernel(Error **errp, 
struct ibv_context *verbs)
 /* This bug only exists in linux, to our knowledge. */
 #ifdef CONFIG_LINUX
 
-/* 
+/*
  * Verbs are only NULL if management has bound to '[::]'.
- * 
+ *
  * Let's iterate through all the devices and see if there any pure IB
  * devices (non-ethernet).
- * 
+ *
  * If not, then we can safely proceed with the migration.
  * Otherwise, there are no guarantees until the bug is fixed in linux.
  */
 if (!verbs) {
-   int num_devices, x;
+int num_devices, x;
 struct ibv_device ** dev_list = ibv_get_device_list(&num_devices);
 bool roce_found = false;
 bool ib_found = false;
@@ -826,8 +826,8 @@ static int qemu_rdma_broken_ipv6_kernel(Error **errp, 
struct ibv_context *verbs)
 
 /*
  * If we have a verbs context, that means that some other than '[::]' was
- * used by the management software for binding. In which case we can 
actually 
- * warn the user about a potential broken kernel;
+ * used by the management software for binding. In which case we can
+ * actually warn the user about a potentially broken kernel.
  */
 
 /* IB ports start with 1, not 0 */
-- 
2.1.4




[Qemu-devel] [PATCH 17/51] vfio: Remove superfluous '\n' around error_report()

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 hw/vfio/common.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 9db7d8d..84dca91 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -201,7 +201,7 @@ static int vfio_dma_unmap(VFIOContainer *container,
 };
 
 if (ioctl(container->fd, VFIO_IOMMU_UNMAP_DMA, &unmap)) {
-error_report("VFIO_UNMAP_DMA: %d\n", -errno);
+error_report("VFIO_UNMAP_DMA: %d", -errno);
 return -errno;
 }
 
@@ -234,7 +234,7 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr 
iova,
 return 0;
 }
 
-error_report("VFIO_MAP_DMA: %d\n", -errno);
+error_report("VFIO_MAP_DMA: %d", -errno);
 return -errno;
 }
 
@@ -274,7 +274,7 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
  iotlb->translated_addr,
  &xlat, &len, iotlb->perm & IOMMU_WO);
 if (!memory_region_is_ram(mr)) {
-error_report("iommu map to non memory area %"HWADDR_PRIx"\n",
+error_report("iommu map to non memory area %"HWADDR_PRIx"",
  xlat);
 return;
 }
@@ -283,7 +283,7 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
  * check that it did not truncate too much.
  */
 if (len & iotlb->addr_mask) {
-error_report("iommu has granularity incompatible with target AS\n");
+error_report("iommu has granularity incompatible with target AS");
 return;
 }
 
@@ -566,7 +566,7 @@ static void vfio_kvm_device_add_group(VFIOGroup *group)
 };
 
 if (kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd)) {
-error_report("Failed to create KVM VFIO device: %m\n");
+error_report("Failed to create KVM VFIO device: %m");
 return;
 }
 
-- 
2.1.4




[Qemu-devel] [PATCH 4/6] fsdev: introduce v9fs_vmarshal() and v9fs_vunmarshal()

2015-03-06 Thread Michael Tokarev
This splits existing functions which expects any argument
into pairs, second being one which accepts va_list, to
be used later.

Signed-off-by: Michael Tokarev 
---
 fsdev/virtio-9p-marshal.c | 38 --
 fsdev/virtio-9p-marshal.h |  6 ++
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c
index 20f308b..757a79a 100644
--- a/fsdev/virtio-9p-marshal.c
+++ b/fsdev/virtio-9p-marshal.c
@@ -108,15 +108,13 @@ ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t 
offset,
 return v9fs_packunpack((void *)src, in_sg, in_num, offset, size, 1);
 }
 
-ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
-   int bswap, const char *fmt, ...)
+ssize_t v9fs_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
+int bswap, const char *fmt, va_list ap)
 {
 int i;
-va_list ap;
 ssize_t copied = 0;
 size_t old_offset = offset;
 
-va_start(ap, fmt);
 for (i = 0; fmt[i]; i++) {
 switch (fmt[i]) {
 case 'b': {
@@ -212,20 +210,28 @@ ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, 
size_t offset,
 }
 offset += copied;
 }
-va_end(ap);
 
 return offset - old_offset;
 }
 
-ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
- int bswap, const char *fmt, ...)
+ssize_t v9fs_unmarshal(struct iovec *in_sg, int in_num, size_t offset,
+  int bswap, const char *fmt, ...)
 {
-int i;
+ssize_t ret;
 va_list ap;
+va_start(ap, fmt);
+ret = v9fs_vunmarshal(in_sg, in_num, offset, bswap, fmt, ap);
+va_end(ap);
+return ret;
+}
+
+ssize_t v9fs_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
+ int bswap, const char *fmt, va_list ap)
+{
+int i;
 ssize_t copied = 0;
 size_t old_offset = offset;
 
-va_start(ap, fmt);
 for (i = 0; fmt[i]; i++) {
 switch (fmt[i]) {
 case 'b': {
@@ -317,7 +323,19 @@ ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, 
size_t offset,
 }
 offset += copied;
 }
-va_end(ap);
 
 return offset - old_offset;
 }
+
+ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
+int bswap, const char *fmt, ...)
+{
+ssize_t ret;
+va_list ap;
+va_start(ap, fmt);
+ret = v9fs_vmarshal(in_sg, in_num, offset, bswap, fmt, ap);
+va_end(ap);
+return ret;
+}
+
+
diff --git a/fsdev/virtio-9p-marshal.h b/fsdev/virtio-9p-marshal.h
index 5df65a8..90d48ca 100644
--- a/fsdev/virtio-9p-marshal.h
+++ b/fsdev/virtio-9p-marshal.h
@@ -1,6 +1,8 @@
 #ifndef _QEMU_VIRTIO_9P_MARSHAL_H
 #define _QEMU_VIRTIO_9P_MARSHAL_H
 
+#include 
+
 typedef struct V9fsString
 {
 uint16_t size;
@@ -85,6 +87,10 @@ ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t 
offset,
   const void *src, size_t size);
 ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
int bswap, const char *fmt, ...);
+ssize_t v9fs_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
+int bswap, const char *fmt, va_list ap);
 ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
  int bswap, const char *fmt, ...);
+ssize_t v9fs_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
+  int bswap, const char *fmt, va_list ap);
 #endif
-- 
2.1.4




[Qemu-devel] [PATCH 39/51] disas/microblaze: Fix warnings caused by missing 'static' attribute

2015-03-06 Thread Michael Tokarev
From: Stefan Weil 

Warnings from the Sparse static analysis tool:

disas/microblaze.c:289:3: warning:
 symbol 'opcodes' was not declared. Should it be static?
disas/microblaze.c:570:6: warning:
 symbol 'register_prefix' was not declared. Should it be static?
disas/microblaze.c:571:6: warning:
 symbol 'special_register_prefix' was not declared. Should it be static?
disas/microblaze.c:572:6: warning:
 symbol 'fsl_register_prefix' was not declared. Should it be static?
disas/microblaze.c:573:6: warning:
 symbol 'pvr_register_prefix' was not declared. Should it be static?

Remove the unused variable special_register_prefix.
The variable pvr_register_prefix was unused, too, but can be used.
Add also 'const' where possible.

Signed-off-by: Stefan Weil 
Signed-off-by: Michael Tokarev 
---
 disas/microblaze.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/disas/microblaze.c b/disas/microblaze.c
index ec91af3..c14ab89 100644
--- a/disas/microblaze.c
+++ b/disas/microblaze.c
@@ -275,7 +275,7 @@ enum microblaze_instr_type {
 
 #define MAX_OPCODES 280
 
-struct op_code_struct {
+static struct op_code_struct {
   const char *name;
   short inst_type; /* registers and immediate values involved */
   short inst_offset_type; /* immediate vals offset from PC? (= 1 for branches) 
*/
@@ -567,10 +567,9 @@ struct op_code_struct {
 };
 
 /* prefix for register names */
-char register_prefix[] = "r";
-char special_register_prefix[] = "spr";
-char fsl_register_prefix[] = "rfsl";
-char pvr_register_prefix[] = "rpvr";
+static const char register_prefix[] = "r";
+static const char fsl_register_prefix[] = "rfsl";
+static const char pvr_register_prefix[] = "rpvr";
 
 
 /* #defines for valid immediate range */
@@ -738,7 +737,9 @@ get_field_special (long instr, struct op_code_struct * op)
default :
  {
if ( instr & IMM_MASK) >> IMM_LOW) ^ op->immval_mask) & 0xE000) == 
REG_PVR_MASK) {
-sprintf(tmpstr, "%spvr%d", register_prefix, (unsigned short)(((instr & 
IMM_MASK) >> IMM_LOW) ^ op->immval_mask) ^ REG_PVR_MASK);
+ sprintf(tmpstr, "%s%u", pvr_register_prefix,
+ (unsigned short)(((instr & IMM_MASK) >> IMM_LOW) ^
+  op->immval_mask) ^ REG_PVR_MASK);
 return(strdup(tmpstr));
} else {
 strcpy(spr, "pc");
-- 
2.1.4




[Qemu-devel] [Bug 1429313] [NEW] qemu-user doesn't block target signals on entry to signal hanlder.

2015-03-06 Thread Timothy Baldwin
Public bug reported:

Upon entry to a target signal handler the function
process_pending_signals in linux-user/signal.c block the appropriate
host signals, but signals already received and queued by Qemu are not
blocked. If multiple signals arrive in quick succession this results
incorrect recursion in the target signal handler.

The attached test case my be run as:

$ (sleep 2 ; echo) | qemu-i386 ./a.out
.. Recursion in signal handler!
qemu: uncaught target signal 6 (Aborted) - core dumped

** Affects: qemu
 Importance: Undecided
 Status: New

** Attachment added: "Testcase"
   https://bugs.launchpad.net/bugs/1429313/+attachment/4336774/+files/sigtest.c

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1429313

Title:
  qemu-user doesn't block target signals on entry to signal hanlder.

Status in QEMU:
  New

Bug description:
  Upon entry to a target signal handler the function
  process_pending_signals in linux-user/signal.c block the appropriate
  host signals, but signals already received and queued by Qemu are not
  blocked. If multiple signals arrive in quick succession this results
  incorrect recursion in the target signal handler.

  The attached test case my be run as:

  $ (sleep 2 ; echo) | qemu-i386 ./a.out
  .. Recursion in signal handler!
  qemu: uncaught target signal 6 (Aborted) - core dumped

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1429313/+subscriptions



[Qemu-devel] [PATCH 50/51] 9pfs-proxy: remove one half of redundrand code

2015-03-06 Thread Michael Tokarev
The 9pfs-proxy code is actually terrible: it does the same
things again and again, ignoring function arguments and
re-inventing the same values again, and a lot of code must
be consistent with each other.

In particular, lots of filesystem methods use common v9fs_request()
function and pass all method args together with pack string to it.
However, v9fs_request() just ignores this, pop the values out of
stack and sets pack string once more.  This is sort of absurd.

This patch removes per-request-type argument marshalling from
v9fs_request() and keeps it only in the individual request
handling methods.

What's left is to do something similar with receiving response,
v9fs_receive_response() function.

Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 275 +++---
 1 file changed, 14 insertions(+), 261 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index c187d31..aa9659a 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -291,22 +291,13 @@ static int v9fs_receive_status(V9fsProxy *proxy,
 /*
  * Proxy->header and proxy->request written to socket by QEMU process.
  * This request read by proxy helper process
- * returns 0 on success and -errno on error
+ * returns 0 on success and -1 (setting errno) on error
  */
 static int v9fs_request(V9fsProxy *proxy, int type,
 void *response, const char *fmt, ...)
 {
-dev_t rdev;
 va_list ap;
-int size = 0;
-int retval = 0, err;
-uint64_t offset;
-ProxyHeader header = { 0, 0};
-struct timespec spec[2];
-int flags, mode, uid, gid;
-V9fsString *name, *value;
-V9fsString *path, *oldpath;
-struct iovec *iovec = NULL, *reply = NULL;
+int retval, err;
 
 qemu_mutex_lock(&proxy->mutex);
 
@@ -315,218 +306,8 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 goto out;
 }
 
-iovec = &proxy->out_iovec;
-reply = &proxy->in_iovec;
 va_start(ap, fmt);
-switch (type) {
-case T_OPEN:
-path = va_arg(ap, V9fsString *);
-flags = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, flags);
-if (retval > 0) {
-header.size = retval;
-header.type = T_OPEN;
-}
-break;
-case T_CREATE:
-path = va_arg(ap, V9fsString *);
-flags = va_arg(ap, int);
-mode = va_arg(ap, int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path,
-flags, mode, uid, gid);
-if (retval > 0) {
-header.size = retval;
-header.type = T_CREATE;
-}
-break;
-case T_MKNOD:
-path = va_arg(ap, V9fsString *);
-mode = va_arg(ap, int);
-rdev = va_arg(ap, long int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddsdq",
-uid, gid, path, mode, rdev);
-if (retval > 0) {
-header.size = retval;
-header.type = T_MKNOD;
-}
-break;
-case T_MKDIR:
-path = va_arg(ap, V9fsString *);
-mode = va_arg(ap, int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddsd",
-uid, gid, path, mode);
-if (retval > 0) {
-header.size = retval;
-header.type = T_MKDIR;
-}
-break;
-case T_SYMLINK:
-oldpath = va_arg(ap, V9fsString *);
-path = va_arg(ap, V9fsString *);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddss",
-uid, gid, oldpath, path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_SYMLINK;
-}
-break;
-case T_LINK:
-oldpath = va_arg(ap, V9fsString *);
-path = va_arg(ap, V9fsString *);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ss",
-oldpath, path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_LINK;
-}
-break;
-case T_LSTAT:
-path = va_arg(ap, V9fsString *);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_LSTAT;
-}
-break;
-case T_READLINK:
-path = va_arg(ap, V9fsString *);
-size = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, size);
-if (retval > 0) {
-header.size = retval;
-header.type = T_READLINK;
-}
-break;
-case T_STATFS:
-path = va_arg(ap, V9fsStr

[Qemu-devel] [PATCH 22/51] ui: Removed unused functions

2015-03-06 Thread Michael Tokarev
From: Thomas Huth 

Remove qemu_console_displaystate(), qemu_remove_kbd_event_handler(),
qemu_different_endianness_pixelformat() and cpkey(), since they are
completely unused.

Signed-off-by: Thomas Huth 
Reviewed-by: Gerd Hoffmann 
Signed-off-by: Michael Tokarev 
---
 include/ui/console.h |  3 ---
 ui/console.c | 12 
 ui/d3des.c   |  9 -
 ui/d3des.h   |  6 --
 ui/input-legacy.c|  6 --
 5 files changed, 36 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 0f97d86..6e5a867 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -36,7 +36,6 @@ typedef struct QEMUPutLEDEntry QEMUPutLEDEntry;
 
 QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func,
 void *opaque);
-void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry);
 QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
 void *opaque, int absolute,
 const char *name);
@@ -194,7 +193,6 @@ DisplaySurface *qemu_create_displaysurface_guestmem(int 
width, int height,
 pixman_format_code_t 
format,
 int linesize,
 uint64_t addr);
-PixelFormat qemu_different_endianness_pixelformat(int bpp);
 PixelFormat qemu_default_pixelformat(int bpp);
 
 DisplaySurface *qemu_create_displaysurface(int width, int height);
@@ -322,7 +320,6 @@ void qemu_console_resize(QemuConsole *con, int width, int 
height);
 void qemu_console_copy(QemuConsole *con, int src_x, int src_y,
int dst_x, int dst_y, int w, int h);
 DisplaySurface *qemu_console_surface(QemuConsole *con);
-DisplayState *qemu_console_displaystate(QemuConsole *console);
 
 /* sdl.c */
 void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
diff --git a/ui/console.c b/ui/console.c
index 87574a7..87af6b5 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2005,18 +2005,6 @@ DisplaySurface *qemu_console_surface(QemuConsole 
*console)
 return console->surface;
 }
 
-DisplayState *qemu_console_displaystate(QemuConsole *console)
-{
-return console->ds;
-}
-
-PixelFormat qemu_different_endianness_pixelformat(int bpp)
-{
-pixman_format_code_t fmt = qemu_default_pixman_format(bpp, false);
-PixelFormat pf = qemu_pixelformat_from_pixman(fmt);
-return pf;
-}
-
 PixelFormat qemu_default_pixelformat(int bpp)
 {
 pixman_format_code_t fmt = qemu_default_pixman_format(bpp, true);
diff --git a/ui/d3des.c b/ui/d3des.c
index 60c840e..5bc99b8 100644
--- a/ui/d3des.c
+++ b/ui/d3des.c
@@ -121,15 +121,6 @@ static void cookey(register unsigned long *raw1)
return;
}
 
-void cpkey(register unsigned long *into)
-{
-   register unsigned long *from, *endp;
-
-   from = KnL, endp = &KnL[32];
-   while( from < endp ) *into++ = *from++;
-   return;
-   }
-
 void usekey(register unsigned long *from)
 {
register unsigned long *to, *endp;
diff --git a/ui/d3des.h b/ui/d3des.h
index 70cb6b5..773667e 100644
--- a/ui/d3des.h
+++ b/ui/d3des.h
@@ -36,12 +36,6 @@ void usekey(unsigned long *);
  * Loads the internal key register with the data in cookedkey.
  */
 
-void cpkey(unsigned long *);
-/*cookedkey[32]
- * Copies the contents of the internal key register into the storage
- * located at &cookedkey[0].
- */
-
 void des(unsigned char *, unsigned char *);
 /* from[8]   to[8]
  * Encrypts/Decrypts (according to the key currently loaded in the
diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index a698a34..2d4ca19 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -143,12 +143,6 @@ QEMUPutKbdEntry 
*qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
 return entry;
 }
 
-void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry)
-{
-qemu_input_handler_unregister(entry->s);
-g_free(entry);
-}
-
 static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
 {
-- 
2.1.4




[Qemu-devel] [PATCH 48/51] 9pfs-proxy: rename a few local variables for consistency

2015-03-06 Thread Michael Tokarev
All functions which deal with v9fs_request() use `retval'
variable to hold result of the request (except some which
use this value for other purposes too), but 3 use different
name (ret or err).  Rename these 3 for consistency.
There's no actual code changes.

Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index bd764be..c187d31 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -980,7 +980,7 @@ static int proxy_renameat(FsContext *ctx, V9fsPath *olddir,
   const char *old_name, V9fsPath *newdir,
   const char *new_name)
 {
-int ret;
+int retval;
 V9fsString old_full_name, new_full_name;
 
 v9fs_string_init(&old_full_name);
@@ -989,30 +989,30 @@ static int proxy_renameat(FsContext *ctx, V9fsPath 
*olddir,
 v9fs_string_sprintf(&old_full_name, "%s/%s", olddir->data, old_name);
 v9fs_string_sprintf(&new_full_name, "%s/%s", newdir->data, new_name);
 
-ret = proxy_rename(ctx, old_full_name.data, new_full_name.data);
+retval = proxy_rename(ctx, old_full_name.data, new_full_name.data);
 v9fs_string_free(&old_full_name);
 v9fs_string_free(&new_full_name);
-return ret;
+return retval;
 }
 
 static int proxy_unlinkat(FsContext *ctx, V9fsPath *dir,
   const char *name, int flags)
 {
-int ret;
+int retval;
 V9fsString fullname;
 v9fs_string_init(&fullname);
 
 v9fs_string_sprintf(&fullname, "%s/%s", dir->data, name);
-ret = proxy_remove(ctx, fullname.data);
+retval = proxy_remove(ctx, fullname.data);
 v9fs_string_free(&fullname);
 
-return ret;
+return retval;
 }
 
 static int proxy_ioc_getversion(FsContext *fs_ctx, V9fsPath *path,
 mode_t st_mode, uint64_t *st_gen)
 {
-int err;
+int retval;
 
 /* Do not try to open special files like device nodes, fifos etc
  * we can get fd for regular files and directories only
@@ -1021,8 +1021,8 @@ static int proxy_ioc_getversion(FsContext *fs_ctx, 
V9fsPath *path,
 errno = ENOTTY;
 return -1;
 }
-err = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, "s", path);
-return err;
+retval = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, "s", path);
+return retval;
 }
 
 static int connect_namedsocket(const char *path)
-- 
2.1.4




[Qemu-devel] [PATCH 45/51] 9pfs: remove useless return

2015-03-06 Thread Michael Tokarev
Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-local.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c
index a183eee..d05c917 100644
--- a/hw/9pfs/virtio-9p-local.c
+++ b/hw/9pfs/virtio-9p-local.c
@@ -332,7 +332,6 @@ static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath 
*fs_path,
 tsize = read(fd, (void *)buf, bufsz);
 } while (tsize == -1 && errno == EINTR);
 close(fd);
-return tsize;
 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
 buffer = rpath(fs_ctx, path);
-- 
2.1.4




[Qemu-devel] [PATCH 18/51] xtensa: Remove superfluous '\n' around error_report()

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 hw/xtensa/sim.c|  2 +-
 hw/xtensa/xtfpga.c | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c
index 37ea9ae..328d209 100644
--- a/hw/xtensa/sim.c
+++ b/hw/xtensa/sim.c
@@ -64,7 +64,7 @@ static void xtensa_sim_init(MachineState *machine)
 for (n = 0; n < smp_cpus; n++) {
 cpu = cpu_xtensa_init(cpu_model);
 if (cpu == NULL) {
-error_report("unable to find CPU definition '%s'\n",
+error_report("unable to find CPU definition '%s'",
  cpu_model);
 exit(EXIT_FAILURE);
 }
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index e5a6bba..bb90eb2 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -190,7 +190,7 @@ static void lx_init(const LxBoardDesc *board, MachineState 
*machine)
 for (n = 0; n < smp_cpus; n++) {
 cpu = cpu_xtensa_init(cpu_model);
 if (cpu == NULL) {
-error_report("unable to find CPU definition '%s'\n",
+error_report("unable to find CPU definition '%s'",
  cpu_model);
 exit(EXIT_FAILURE);
 }
@@ -235,7 +235,7 @@ static void lx_init(const LxBoardDesc *board, MachineState 
*machine)
 board->flash_size / board->flash_sector_size,
 4, 0x, 0x, 0x, 0x, be);
 if (flash == NULL) {
-error_report("unable to mount pflash\n");
+error_report("unable to mount pflash");
 exit(EXIT_FAILURE);
 }
 }
@@ -287,7 +287,7 @@ static void lx_init(const LxBoardDesc *board, MachineState 
*machine)
 uint32_t dtb_addr = tswap32(cur_lowmem);
 
 if (!fdt) {
-error_report("could not load DTB '%s'\n", dtb_filename);
+error_report("could not load DTB '%s'", dtb_filename);
 exit(EXIT_FAILURE);
 }
 
@@ -307,7 +307,7 @@ static void lx_init(const LxBoardDesc *board, MachineState 
*machine)
   lowmem_end - cur_lowmem);
 }
 if (initrd_size < 0) {
-error_report("could not load initrd '%s'\n", initrd_filename);
+error_report("could not load initrd '%s'", initrd_filename);
 exit(EXIT_FAILURE);
 }
 initrd_location.start = tswap32(cur_lowmem);
@@ -333,7 +333,7 @@ static void lx_init(const LxBoardDesc *board, MachineState 
*machine)
 if (success > 0 && is_linux) {
 entry_point = ep;
 } else {
-error_report("could not load kernel '%s'\n",
+error_report("could not load kernel '%s'",
  kernel_filename);
 exit(EXIT_FAILURE);
 }
-- 
2.1.4




[Qemu-devel] [PATCH 23/51] ui/vnc: Remove vnc_stop_worker_thread()

2015-03-06 Thread Michael Tokarev
From: Thomas Huth 

This function is not used anymore, let's remove it.

Signed-off-by: Thomas Huth 
Reviewed-by: Gerd Hoffmann 
Signed-off-by: Michael Tokarev 
---
 ui/vnc-jobs.c | 13 -
 ui/vnc-jobs.h |  1 -
 2 files changed, 14 deletions(-)

diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
index 68f3d77..c8ee203 100644
--- a/ui/vnc-jobs.c
+++ b/ui/vnc-jobs.c
@@ -342,16 +342,3 @@ void vnc_start_worker_thread(void)
QEMU_THREAD_DETACHED);
 queue = q; /* Set global queue */
 }
-
-void vnc_stop_worker_thread(void)
-{
-if (!vnc_worker_thread_running())
-return ;
-
-/* Remove all jobs and wake up the thread */
-vnc_lock_queue(queue);
-queue->exit = true;
-vnc_unlock_queue(queue);
-vnc_jobs_clear(NULL);
-qemu_cond_broadcast(&queue->cond);
-}
diff --git a/ui/vnc-jobs.h b/ui/vnc-jobs.h
index 31da103..044bf9f 100644
--- a/ui/vnc-jobs.h
+++ b/ui/vnc-jobs.h
@@ -40,7 +40,6 @@ void vnc_jobs_join(VncState *vs);
 
 void vnc_jobs_consume_buffer(VncState *vs);
 void vnc_start_worker_thread(void);
-void vnc_stop_worker_thread(void);
 
 /* Locks */
 static inline int vnc_trylock_display(VncDisplay *vd)
-- 
2.1.4




[Qemu-devel] [PATCH] rocker: fix clang compiler errors

2015-03-06 Thread David Ahern
Consolidate all forward typedef declarations to rocker.h.

Signed-off-by: David Ahern 
Acked-by: Scott Feldman 
---
 hw/net/rocker/rocker.c|  4 ++--
 hw/net/rocker/rocker.h|  7 +++
 hw/net/rocker/rocker_desc.c   | 10 --
 hw/net/rocker/rocker_desc.h   |  4 
 hw/net/rocker/rocker_fp.c |  4 ++--
 hw/net/rocker/rocker_fp.h |  2 --
 hw/net/rocker/rocker_of_dpa.h |  3 ---
 hw/net/rocker/rocker_world.c  |  6 ++
 hw/net/rocker/rocker_world.h  |  7 ++-
 9 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 41052750a434..de0f7b96c54e 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -32,7 +32,7 @@
 #include "rocker_world.h"
 #include "rocker_of_dpa.h"
 
-typedef struct rocker {
+struct rocker {
 /* private */
 PCIDevice parent_obj;
 /* public */
@@ -65,7 +65,7 @@ typedef struct rocker {
 World *world_dflt;
 
 QLIST_ENTRY(rocker) next;
-} Rocker;
+};
 
 #define ROCKER "rocker"
 
diff --git a/hw/net/rocker/rocker.h b/hw/net/rocker/rocker.h
index 656d7226746b..b3310b61ebc2 100644
--- a/hw/net/rocker/rocker.h
+++ b/hw/net/rocker/rocker.h
@@ -21,8 +21,6 @@
 
 #include "qemu/sockets.h"
 
-#include "rocker_world.h"
-
 #if defined(DEBUG_ROCKER)
 #  define DPRINTF(fmt, ...) \
 do {   \
@@ -68,11 +66,12 @@ static inline bool ipv6_addr_is_multicast(const Ipv6Addr 
*addr)
 return (addr->addr32[0] & htonl(0xFF00)) == htonl(0xFF00);
 }
 
-typedef struct world World;
 typedef struct rocker Rocker;
+typedef struct world World;
+typedef struct desc_info DescInfo;
+typedef struct desc_ring DescRing;
 
 Rocker *rocker_find(const char *name);
-World *rocker_get_world(Rocker *r, enum rocker_world_type type);
 uint32_t rocker_fp_ports(Rocker *r);
 int rocker_event_link_changed(Rocker *r, uint32_t pport, bool link_up);
 int rocker_event_mac_vlan_seen(Rocker *r, uint32_t pport, uint8_t *addr,
diff --git a/hw/net/rocker/rocker_desc.c b/hw/net/rocker/rocker_desc.c
index 0a6dfae63b26..9d896fe470d8 100644
--- a/hw/net/rocker/rocker_desc.c
+++ b/hw/net/rocker/rocker_desc.c
@@ -22,9 +22,7 @@
 #include "rocker_hw.h"
 #include "rocker_desc.h"
 
-typedef struct desc_info DescInfo;
-
-typedef struct desc_ring {
+struct desc_ring {
 hwaddr base_addr;
 uint32_t size;
 uint32_t head;
@@ -36,14 +34,14 @@ typedef struct desc_ring {
 int index;
 desc_ring_consume *consume;
 unsigned msix_vector;
-} DescRing;
+};
 
-typedef struct desc_info {
+struct desc_info {
 DescRing *ring;
 RockerDesc desc;
 char *buf;
 size_t buf_size;
-} DescInfo;
+};
 
 uint16_t desc_buf_size(DescInfo *info)
 {
diff --git a/hw/net/rocker/rocker_desc.h b/hw/net/rocker/rocker_desc.h
index 0b57ba75275e..d4041f5c4c58 100644
--- a/hw/net/rocker/rocker_desc.h
+++ b/hw/net/rocker/rocker_desc.h
@@ -20,10 +20,6 @@
 
 #include "rocker_hw.h"
 
-typedef struct rocker Rocker;
-typedef struct desc_ring DescRing;
-typedef struct desc_info DescInfo;
-
 typedef int (desc_ring_consume)(Rocker *r, DescInfo *info);
 
 uint16_t desc_buf_size(DescInfo *info);
diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c
index 75513309f9a3..2f1e3b348a52 100644
--- a/hw/net/rocker/rocker_fp.c
+++ b/hw/net/rocker/rocker_fp.c
@@ -26,7 +26,7 @@ enum duplex {
 DUPLEX_FULL
 };
 
-typedef struct fp_port {
+struct fp_port {
 Rocker *r;
 World *world;
 unsigned int index;
@@ -39,7 +39,7 @@ typedef struct fp_port {
 uint8_t learning;
 NICState *nic;
 NICConf conf;
-} FpPort;
+};
 
 bool fp_port_get_link_up(FpPort *port)
 {
diff --git a/hw/net/rocker/rocker_fp.h b/hw/net/rocker/rocker_fp.h
index eb67c64abeec..a5f28f120d5a 100644
--- a/hw/net/rocker/rocker_fp.h
+++ b/hw/net/rocker/rocker_fp.h
@@ -22,9 +22,7 @@
 
 #define ROCKER_FP_PORTS_MAX 62
 
-typedef struct rocker Rocker;
 typedef struct fp_port FpPort;
-typedef struct world World;
 
 int fp_port_eg(FpPort *port, const struct iovec *iov, int iovcnt);
 
diff --git a/hw/net/rocker/rocker_of_dpa.h b/hw/net/rocker/rocker_of_dpa.h
index 0af479085fa7..f3f6d77807a6 100644
--- a/hw/net/rocker/rocker_of_dpa.h
+++ b/hw/net/rocker/rocker_of_dpa.h
@@ -17,9 +17,6 @@
 #ifndef _ROCKER_OF_DPA_H_
 #define _ROCKER_OF_DPA_H_
 
-typedef struct rocker Rocker;
-typedef struct world World;
-
 World *of_dpa_world_alloc(Rocker *r);
 
 #endif /* _ROCKER_OF_DPA_H_ */
diff --git a/hw/net/rocker/rocker_world.c b/hw/net/rocker/rocker_world.c
index a21829071fbc..b991e871d3b6 100644
--- a/hw/net/rocker/rocker_world.c
+++ b/hw/net/rocker/rocker_world.c
@@ -19,13 +19,11 @@
 #include "rocker.h"
 #include "rocker_world.h"
 
-typedef struct rocker Rocker;
-
-typedef struct world {
+struct world {
 Rocker *r;
 enum rocker_world_type type;
 WorldOps *ops;
-} World;
+};
 
 ssize_t world_ingress(World *world, uint32_t pport,
   const struct iovec *iov, int iovcnt)
diff --git a/hw

Re: [Qemu-devel] E5-2620v2 - emulation stop error

2015-03-06 Thread Andrey Korolyov
On Fri, Mar 6, 2015 at 7:57 PM, Bandan Das  wrote:
> Andrey Korolyov  writes:
>
>> On Fri, Mar 6, 2015 at 1:14 AM, Andrey Korolyov  wrote:
>>> Hello,
>>>
>>> recently I`ve got a couple of shiny new Intel 2620v2s for future
>>> replacement of the E5-2620v1, but I experienced relatively many events
>>> with emulation errors, all traces looks simular to the one below. I am
>>> running qemu-2.1 on x86 on top of 3.10 branch for testing purposes but
>>> can switch to some other versions if necessary. Most of crashes
>>> happened during reboot cycle or at the end of ACPI-based shutdown
>>> action, if this can help. I have zero clues of what can introduce such
>>> a mess inside same processor family using identical software, as
>>> 2620v1 has no simular problem ever. Please let me know if there can be
>>> some side measures for making entire story more clear.
>>>
>>> Thanks!
>>>
>>> KVM internal error. Suberror: 2
>>> extra data[0]: 80d1
>>> extra data[1]: 8b0d
>>> EAX=0003 EBX= ECX= EDX=
>>> ESI= EDI= EBP= ESP=6cd4
>>> EIP=d3f9 EFL=00010202 [---] CPL=0 II=0 A20=1 SMM=0 HLT=0
>>> ES =   9300
>>> CS =f000 000f  9b00
>>> SS =   9300
>>> DS =   9300
>>> FS =   9300
>>> GS =   9300
>>> LDT=   8200
>>> TR =   8b00
>>> GDT= 000f6e98 0037
>>> IDT=  03ff
>>> CR0=0010 CR2= CR3= CR4=
>>> DR0= DR1= DR2=
>>> DR3=
>>> DR6=0ff0 DR7=0400
>>> EFER=
>>> Code=48 18 67 8c 00 8c d1 8e d9 66 5a 66 58 66 5d 66 c3 cd 02 cb 
>>> 10 cb cd 13 cb cd 15 cb cd 16 cb cd 18 cb cd 19 cb cd 1c cb fa fc 66
>>> b8 00 e0 00 00 8e
>>
>>
>> It turns out that those errors are introduced by APICv, which gets
>> enabled due to different feature set. If anyone is interested in
>> reproducing/fixing this exactly on 3.10, it takes about one hundred of
>> migrations/power state changes for an issue to appear, guest OS can be
>> Linux or Win.
>
> Are you able to reproduce this on a more recent upstream kernel as well ?
>
> Bandan

I`ll go through test cycle with 3.18 and 2603v2 around tomorrow and
follow up with any reproduceable results.



[Qemu-devel] [PATCH 49/51] fsdev: introduce v9fs_vmarshal() and v9fs_vunmarshal()

2015-03-06 Thread Michael Tokarev
This splits existing functions which expects any argument
into pairs, second being one which accepts va_list, to
be used later.

Signed-off-by: Michael Tokarev 
---
 fsdev/virtio-9p-marshal.c | 38 --
 fsdev/virtio-9p-marshal.h |  6 ++
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c
index 20f308b..757a79a 100644
--- a/fsdev/virtio-9p-marshal.c
+++ b/fsdev/virtio-9p-marshal.c
@@ -108,15 +108,13 @@ ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t 
offset,
 return v9fs_packunpack((void *)src, in_sg, in_num, offset, size, 1);
 }
 
-ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
-   int bswap, const char *fmt, ...)
+ssize_t v9fs_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
+int bswap, const char *fmt, va_list ap)
 {
 int i;
-va_list ap;
 ssize_t copied = 0;
 size_t old_offset = offset;
 
-va_start(ap, fmt);
 for (i = 0; fmt[i]; i++) {
 switch (fmt[i]) {
 case 'b': {
@@ -212,20 +210,28 @@ ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, 
size_t offset,
 }
 offset += copied;
 }
-va_end(ap);
 
 return offset - old_offset;
 }
 
-ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
- int bswap, const char *fmt, ...)
+ssize_t v9fs_unmarshal(struct iovec *in_sg, int in_num, size_t offset,
+  int bswap, const char *fmt, ...)
 {
-int i;
+ssize_t ret;
 va_list ap;
+va_start(ap, fmt);
+ret = v9fs_vunmarshal(in_sg, in_num, offset, bswap, fmt, ap);
+va_end(ap);
+return ret;
+}
+
+ssize_t v9fs_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
+ int bswap, const char *fmt, va_list ap)
+{
+int i;
 ssize_t copied = 0;
 size_t old_offset = offset;
 
-va_start(ap, fmt);
 for (i = 0; fmt[i]; i++) {
 switch (fmt[i]) {
 case 'b': {
@@ -317,7 +323,19 @@ ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, 
size_t offset,
 }
 offset += copied;
 }
-va_end(ap);
 
 return offset - old_offset;
 }
+
+ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
+int bswap, const char *fmt, ...)
+{
+ssize_t ret;
+va_list ap;
+va_start(ap, fmt);
+ret = v9fs_vmarshal(in_sg, in_num, offset, bswap, fmt, ap);
+va_end(ap);
+return ret;
+}
+
+
diff --git a/fsdev/virtio-9p-marshal.h b/fsdev/virtio-9p-marshal.h
index 5df65a8..90d48ca 100644
--- a/fsdev/virtio-9p-marshal.h
+++ b/fsdev/virtio-9p-marshal.h
@@ -1,6 +1,8 @@
 #ifndef _QEMU_VIRTIO_9P_MARSHAL_H
 #define _QEMU_VIRTIO_9P_MARSHAL_H
 
+#include 
+
 typedef struct V9fsString
 {
 uint16_t size;
@@ -85,6 +87,10 @@ ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t 
offset,
   const void *src, size_t size);
 ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
int bswap, const char *fmt, ...);
+ssize_t v9fs_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
+int bswap, const char *fmt, va_list ap);
 ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
  int bswap, const char *fmt, ...);
+ssize_t v9fs_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
+  int bswap, const char *fmt, va_list ap);
 #endif
-- 
2.1.4




[Qemu-devel] [PATCH 06/51] qemu-options: fix/document -incoming options

2015-03-06 Thread Michael Tokarev
Signed-off-by: Michael Tokarev 
---
 qemu-options.hx | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index ee4b223..303d13c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3195,12 +3195,30 @@ Set TB size.
 ETEXI
 
 DEF("incoming", HAS_ARG, QEMU_OPTION_incoming, \
-"-incoming p prepare for incoming migration, listen on port p\n",
+"-incoming tcp:[host]:port[,to=maxport][,ipv4][,ipv6]\n" \
+"-incoming rdma:host:port[,ipv4][,ipv6]\n" \
+"-incoming unix:socketpath\n" \
+"prepare for incoming migration, listen on\n" \
+"specified protocol and socket address\n" \
+"-incoming fd:fd\n" \
+"-incoming exec:cmdline\n" \
+"accept incoming migration on given file descriptor\n" \
+"or from given external command\n",
 QEMU_ARCH_ALL)
 STEXI
-@item -incoming @var{port}
+@item -incoming tcp:[@var{host}]:@var{port}[,to=@var{maxport}][,ipv4][,ipv6]
+@item -incoming rdma:@var{host}:@var{port}[,ipv4][,ipv6]
 @findex -incoming
-Prepare for incoming migration, listen on @var{port}.
+Prepare for incoming migration, listen on a given tcp port.
+
+@item -incoming unix:@var{socketpath}
+Prepare for incoming migration, listen on a given unix socket.
+
+@item -incoming fd:@var{fd}
+Accept incoming migration from a given filedescriptor.
+
+@item -incoming exec:@var{cmdline}
+Accept incoming migration as an output from specified external command.
 ETEXI
 
 DEF("nodefaults", 0, QEMU_OPTION_nodefaults, \
-- 
2.1.4




[Qemu-devel] [PATCH 27/51] qemu-char: add cyrillic key 'numerosign' to Russian keymap

2015-03-06 Thread Michael Tokarev
From: Wang Xin 

numero sign is the number sign key of Russian keyboard layout, we
get this key with 'shift + 3'. It's missing in current Russian keymap file,
this patch fixes it.
As number sign does not exsit in Russian keyboard layout[1][2], this
patch also removes the 'numbersign' from Russian keymap.

[1] http://en.wikipedia.org/wiki/Keyboard_layout#Russian
[2] http://kbd-intl.narod.ru/english/layouts

Signed-off-by: Wang Xin 
Signed-off-by: Gonglei 
Signed-off-by: Michael Tokarev 
---
 pc-bios/keymaps/ru | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pc-bios/keymaps/ru b/pc-bios/keymaps/ru
index b3e7d24..8f652d5 100644
--- a/pc-bios/keymaps/ru
+++ b/pc-bios/keymaps/ru
@@ -4,7 +4,7 @@ map 0x419
 exclam 0x02 shift
 at 0x03 shift
 quotedbl 0x03 shift altgr
-numbersign 0x04 shift
+numerosign 0x04 shift
 dollar 0x05 shift
 asterisk 0x05 shift altgr
 percent 0x06 shift
-- 
2.1.4




[Qemu-devel] [PATCH 46/51] 9pfs-proxy: simplify v9fs_request() a bit

2015-03-06 Thread Michael Tokarev
This simplifies code in v9fs_request() a bit by replacing several
ifs with a common variable check and rearranging error/cleanup
code a bit.

Signet-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 48 ---
 1 file changed, 20 insertions(+), 28 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 59c7445..f252fe4 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -299,7 +299,7 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 dev_t rdev;
 va_list ap;
 int size = 0;
-int retval = 0;
+int retval = 0, err;
 uint64_t offset;
 ProxyHeader header = { 0, 0};
 struct timespec spec[2];
@@ -310,10 +310,11 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 
 qemu_mutex_lock(&proxy->mutex);
 
-if (proxy->sockfd == -1) {
+if (proxy->sockfd < 0) {
 retval = -EIO;
-goto err_out;
+goto out;
 }
+
 iovec = &proxy->out_iovec;
 reply = &proxy->in_iovec;
 va_start(ap, fmt);
@@ -529,15 +530,15 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 va_end(ap);
 
 if (retval < 0) {
-goto err_out;
+goto out;
 }
 
 /* marshal the header details */
 proxy_marshal(iovec, 0, "dd", header.type, header.size);
 header.size += PROXY_HDR_SZ;
 
-retval = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
-if (retval != header.size) {
+err = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
+if (err != header.size) {
 goto close_error;
 }
 
@@ -548,9 +549,7 @@ static int v9fs_request(V9fsProxy *proxy, int type,
  * A file descriptor is returned as response for
  * T_OPEN,T_CREATE on success
  */
-if (v9fs_receivefd(proxy->sockfd, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receivefd(proxy->sockfd, &retval);
 break;
 case T_MKNOD:
 case T_MKDIR:
@@ -564,41 +563,34 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 case T_REMOVE:
 case T_LSETXATTR:
 case T_LREMOVEXATTR:
-if (v9fs_receive_status(proxy, reply, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receive_status(proxy, reply, &retval);
 break;
 case T_LSTAT:
 case T_READLINK:
 case T_STATFS:
 case T_GETVERSION:
-if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
-goto close_error;
-}
+err = v9fs_receive_response(proxy, type, &retval, response);
 break;
 case T_LGETXATTR:
 case T_LLISTXATTR:
 if (!size) {
-if (v9fs_receive_status(proxy, reply, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receive_status(proxy, reply, &retval);
 } else {
-if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
-goto close_error;
-}
+err = v9fs_receive_response(proxy, type, &retval, response);
 }
 break;
 }
 
-err_out:
-qemu_mutex_unlock(&proxy->mutex);
-return retval;
-
+if (err < 0) {
 close_error:
-close(proxy->sockfd);
-proxy->sockfd = -1;
+close(proxy->sockfd);
+proxy->sockfd = -1;
+retval = -EIO;
+}
+
+out:
 qemu_mutex_unlock(&proxy->mutex);
-return -EIO;
+return retval;
 }
 
 static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat 
*stbuf)
-- 
2.1.4




[Qemu-devel] [PATCH 04/51] memsave: Improve and disambiguate error message

2015-03-06 Thread Michael Tokarev
From: Borislav Petkov 

When requesting a size which cannot be read, the error message shows
a different address which is misleading to the user and it looks like
something's wrong with the address parsing. This is because the input
@addr variable is incremented in the memory dumping loop:

(qemu) memsave 0x8418069c 0xb0 mem
Invalid addr 0x849ffe9c specified

Fix that by saving the original address and size and use them in the
error message:

(qemu) memsave 0x8418069c 0xb0 mem
Invalid addr 0x8418069c/size 11534336 specified

Signed-off-by: Borislav Petkov 
Signed-off-by: Michael Tokarev 
---
 cpus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 0fac143..1ce90a1 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1474,6 +1474,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char 
*filename,
 uint32_t l;
 CPUState *cpu;
 uint8_t buf[1024];
+int64_t orig_addr = addr, orig_size = size;
 
 if (!has_cpu) {
 cpu_index = 0;
@@ -1497,7 +1498,8 @@ void qmp_memsave(int64_t addr, int64_t size, const char 
*filename,
 if (l > size)
 l = size;
 if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) {
-error_setg(errp, "Invalid addr 0x%016" PRIx64 "specified", addr);
+error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRId64
+ " specified", orig_addr, orig_size);
 goto exit;
 }
 if (fwrite(buf, 1, l, f) != l) {
-- 
2.1.4




[Qemu-devel] [PATCH 32/51] sysbus: fix memory leak

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Signed-off-by: Michael Tokarev 
---
 hw/core/sysbus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 84af593..b53c351 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -91,6 +91,8 @@ bool sysbus_has_irq(SysBusDevice *dev, int n)
 ObjectProperty *r;
 
 r = object_property_find(OBJECT(dev), prop, NULL);
+g_free(prop);
+
 return (r != NULL);
 }
 
-- 
2.1.4




Re: [Qemu-devel] clang warnings too noisy

2015-03-06 Thread Peter Maydell
On 7 March 2015 at 04:06, Stefan Hajnoczi  wrote:
> Hi Peter,
> You are rejecting pull requests that produce warnings under clang.
>
> clang 3.5.0 on Fedora 21 produces so much noise that it's extremely
> tedious and error-prone to try finding relevant new warnings.
>
> Are you using a different clang version which produces fewer warnings?

I use the stock clangs for OSX 10.9.5 and Ubuntu trusty:
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix

> Is anyone working on making QEMU build cleanly under clang?  Under gcc
> people regularly submit patches to keep the build clean (e.g. recent
> gcc 5 fixes).

Yes, I have been working on making QEMU build cleanly under clang,
why do you think I've been rejecting pulls which add warnings and
submitting patches which fix existing warnings?
It currently builds totally cleanly on the clang I use. I have my
config set up with -Werror now and would like to keep it that way.

(The OSX build has warnings about deprecated audio APIs still but
is otherwise clean.)

> Currently I'm not happy wrangling with clang when very few people seem
> to use it or care enough to make QEMU build cleanly.
>
> Examples of noise produced by clang:
>
> 1. It complains about glib headers:
> In file included from /home/stefanha/qemu/include/net/eth.h:32:
> In file included from /home/stefanha/qemu/include/qemu/iov.h:17:
> In file included from /home/stefanha/qemu/include/qemu-common.h:43:
> In file included from /home/stefanha/qemu/include/glib-compat.h:19:
> In file included from /usr/include/glib-2.0/glib.h:50:
> In file included from /usr/include/glib-2.0/glib/ghash.h:33:
> In file included from /usr/include/glib-2.0/glib/glist.h:32:
> /usr/include/glib-2.0/glib/gmem.h:76:78: warning: unknown attribute
> '__alloc_size__' ignored [-Wunknown-attributes]
> gpointer g_malloc (gsize n_bytes) __attribute__((__malloc__))
> __attribute__((__alloc_size__(1)));
>  ^
> /usr/include/glib-2.0/glib/gmem.h:78:79: warning: unknown attribute
> '__alloc_size__' ignored [-Wunknown-attributes]

I think this is a glib bug...

> 2. It complains about the 'return !strcmp(s, "?") || !strcmp(s,
> "help")' in qemu-common.h:
> /home/stefanha/qemu/include/qemu-common.h:150:1916: warning: array
> index 3 is past the end of the array (which contains 2 elements)
> [-Warray-bounds]
> return !__extension__ ({ size_t __s1_len, __s2_len;
> (__builtin_constant_p (s) && __builtin_constant_p ("?") && (__s1_len =
> strlen (s), __s2_len = strlen ("?"), (!((size_t)(const void *)((s) +
> 1) - (size_t)(const void *)(s) == 1) || __s1_len >= 4) &&
> (!((size_t)(const void *)(("?") + 1) - (size_t)(const void *)("?") ==
> 1) || __s2_len >= 4)) ? __builtin_strcmp (s, "?") :
> (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) -
> (size_t)(const void *)(s) == 1) && (__s1_len = strlen (s), __s1_len <
> 4) ? (__builtin_constant_p ("?") && ((size_t)(const void *)(("?") + 1)
> - (size_t)(const void *)("?") == 1) ? __builtin_strcmp (s, "?") : ...
>
> 3. It complains about unused -I paths:
> clang: warning: argument unused during compilation: '-I 
> /home/stefanha/qemu/tcg'
> clang: warning: argument unused during compilation: '-I
> /home/stefanha/qemu/tcg/i386'
> clang: warning: argument unused during compilation: '-I
> /home/stefanha/qemu/linux-headers'

Are you sure 3 isn't because you're running clang under ccache?

-- PMM



[Qemu-devel] [PATCH 05/51] smbios: document cmdline options for smbios type 2-4, 17 structures

2015-03-06 Thread Michael Tokarev
From: "Gabriel L. Somlo" 

Signed-off-by: Gabriel Somlo 
Signed-off-by: Michael Tokarev 
---
 qemu-options.hx | 32 +---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 85ca3ad..ee4b223 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1364,11 +1364,25 @@ ETEXI
 DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
 "-smbios file=binary\n"
 "load SMBIOS entry from binary file\n"
-"-smbios 
type=0[,vendor=str][,version=str][,date=str][,release=%d.%d][,uefi=on|off]\n"
+"-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]\n"
+"  [,uefi=on|off]\n"
 "specify SMBIOS type 0 fields\n"
 "-smbios 
type=1[,manufacturer=str][,product=str][,version=str][,serial=str]\n"
 "  [,uuid=uuid][,sku=str][,family=str]\n"
-"specify SMBIOS type 1 fields\n", QEMU_ARCH_I386)
+"specify SMBIOS type 1 fields\n"
+"-smbios 
type=2[,manufacturer=str][,product=str][,version=str][,serial=str]\n"
+"  [,asset=str][,location=str]\n"
+"specify SMBIOS type 2 fields\n"
+"-smbios 
type=3[,manufacturer=str][,version=str][,serial=str][,asset=str]\n"
+"  [,sku=str]\n"
+"specify SMBIOS type 3 fields\n"
+"-smbios 
type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n"
+"  [,asset=str][,part=str]\n"
+"specify SMBIOS type 4 fields\n"
+"-smbios 
type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str]\n"
+"   [,asset=str][,part=str]\n"
+"specify SMBIOS type 17 fields\n",
+QEMU_ARCH_I386)
 STEXI
 @item -smbios file=@var{binary}
 @findex -smbios
@@ -1377,8 +1391,20 @@ Load SMBIOS entry from binary file.
 @item -smbios 
type=0[,vendor=@var{str}][,version=@var{str}][,date=@var{str}][,release=@var{%d.%d}][,uefi=on|off]
 Specify SMBIOS type 0 fields
 
-@item -smbios type=1[,manufacturer=@var{str}][,product=@var{str}] 
[,version=@var{str}][,serial=@var{str}][,uuid=@var{uuid}][,sku=@var{str}] 
[,family=@var{str}]
+@item -smbios 
type=1[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,uuid=@var{uuid}][,sku=@var{str}][,family=@var{str}]
 Specify SMBIOS type 1 fields
+
+@item -smbios 
type=2[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,location=@var{str}][,family=@var{str}]
+Specify SMBIOS type 2 fields
+
+@item -smbios 
type=3[,manufacturer=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,sku=@var{str}]
+Specify SMBIOS type 3 fields
+
+@item -smbios 
type=4[,sock_pfx=@var{str}][,manufacturer=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,part=@var{str}]
+Specify SMBIOS type 4 fields
+
+@item -smbios 
type=17[,loc_pfx=@var{str}][,bank=@var{str}][,manufacturer=@var{str}][,serial=@var{str}][,asset=@var{str}][,part=@var{str}]
+Specify SMBIOS type 17 fields
 ETEXI
 
 STEXI
-- 
2.1.4




[Qemu-devel] [PATCH 19/51] tpm: Remove superfluous '\n' around error_report()

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 hw/tpm/tpm_passthrough.c | 12 ++--
 tpm.c|  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 2bf3c6f..13ac1d2 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -126,7 +126,7 @@ static int tpm_passthrough_unix_tx_bufs(TPMPassthruState 
*tpm_pt,
 if (!tpm_pt->tpm_op_canceled ||
 (tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
 error_report("tpm_passthrough: error while transmitting data "
- "to TPM: %s (%i)\n",
+ "to TPM: %s (%i)",
  strerror(errno), errno);
 }
 goto err_exit;
@@ -139,14 +139,14 @@ static int tpm_passthrough_unix_tx_bufs(TPMPassthruState 
*tpm_pt,
 if (!tpm_pt->tpm_op_canceled ||
 (tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
 error_report("tpm_passthrough: error while reading data from "
- "TPM: %s (%i)\n",
+ "TPM: %s (%i)",
  strerror(errno), errno);
 }
 } else if (ret < sizeof(struct tpm_resp_hdr) ||
tpm_passthrough_get_size_from_buffer(out) != ret) {
 ret = -1;
 error_report("tpm_passthrough: received invalid response "
- "packet from TPM\n");
+ "packet from TPM");
 }
 
 err_exit:
@@ -282,7 +282,7 @@ static void tpm_passthrough_cancel_cmd(TPMBackend *tb)
 if (tpm_pt->cancel_fd >= 0) {
 n = write(tpm_pt->cancel_fd, "-", 1);
 if (n != 1) {
-error_report("Canceling TPM command failed: %s\n",
+error_report("Canceling TPM command failed: %s",
  strerror(errno));
 } else {
 tpm_pt->tpm_op_canceled = true;
@@ -413,13 +413,13 @@ static int tpm_passthrough_handle_device_opts(QemuOpts 
*opts, TPMBackend *tb)
 
 tpm_pt->tpm_fd = qemu_open(tpm_pt->tpm_dev, O_RDWR);
 if (tpm_pt->tpm_fd < 0) {
-error_report("Cannot access TPM device using '%s': %s\n",
+error_report("Cannot access TPM device using '%s': %s",
  tpm_pt->tpm_dev, strerror(errno));
 goto err_free_parameters;
 }
 
 if (tpm_passthrough_test_tpmdev(tpm_pt->tpm_fd)) {
-error_report("'%s' is not a TPM device.\n",
+error_report("'%s' is not a TPM device.",
  tpm_pt->tpm_dev);
 goto err_close_tpmdev;
 }
diff --git a/tpm.c b/tpm.c
index 4ffd9b9..963b7ee 100644
--- a/tpm.c
+++ b/tpm.c
@@ -134,7 +134,7 @@ static int configure_tpm(QemuOpts *opts)
 Error *local_err = NULL;
 
 if (!QLIST_EMPTY(&tpm_backends)) {
-error_report("Only one TPM is allowed.\n");
+error_report("Only one TPM is allowed.");
 return 1;
 }
 
-- 
2.1.4




[Qemu-devel] [PATCH 14/51] numa: remove superfluous '\n' around error_setg

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 numa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/numa.c b/numa.c
index 5634bf0..ffbec68 100644
--- a/numa.c
+++ b/numa.c
@@ -66,7 +66,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts 
*opts, Error **errp)
 
 if (nodenr >= MAX_NODES) {
 error_setg(errp, "Max number of NUMA nodes reached: %"
-   PRIu16 "\n", nodenr);
+   PRIu16 "", nodenr);
 return;
 }
 
@@ -85,7 +85,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts 
*opts, Error **errp)
 }
 
 if (node->has_mem && node->has_memdev) {
-error_setg(errp, "qemu: cannot specify both mem= and memdev=\n");
+error_setg(errp, "qemu: cannot specify both mem= and memdev=");
 return;
 }
 
@@ -94,7 +94,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts 
*opts, Error **errp)
 }
 if (node->has_memdev != have_memdevs) {
 error_setg(errp, "qemu: memdev option must be specified for either "
-   "all or no nodes\n");
+   "all or no nodes");
 return;
 }
 
-- 
2.1.4




[Qemu-devel] [PATCH 21/51] vhost: Remove superfluous '\n' around error_report()

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 hw/virtio/vhost-backend.c | 2 +-
 net/vhost-user.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index ff4f200..4d68a27 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -61,7 +61,7 @@ int vhost_set_backend_type(struct vhost_dev *dev, 
VhostBackendType backend_type)
 dev->vhost_ops = &user_ops;
 break;
 default:
-error_report("Unknown vhost backend type\n");
+error_report("Unknown vhost backend type");
 r = -1;
 }
 
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 24e050c..23babd6 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -122,12 +122,12 @@ static void net_vhost_user_event(void *opaque, int event)
 case CHR_EVENT_OPENED:
 vhost_user_start(s);
 net_vhost_link_down(s, false);
-error_report("chardev \"%s\" went up\n", s->chr->label);
+error_report("chardev \"%s\" went up", s->chr->label);
 break;
 case CHR_EVENT_CLOSED:
 net_vhost_link_down(s, true);
 vhost_user_stop(s);
-error_report("chardev \"%s\" went down\n", s->chr->label);
+error_report("chardev \"%s\" went down", s->chr->label);
 break;
 }
 }
-- 
2.1.4




[Qemu-devel] [PATCH 25/51] qapi-schema: Fix SpiceChannel docs

2015-03-06 Thread Michael Tokarev
From: Cole Robinson 

The value is called channel-type, not connection-type

Signed-off-by: Cole Robinson 
Reviewed-by: Eric Blake 
Signed-off-by: Michael Tokarev 
---
 qapi-schema.json | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index e16f8eb..8141f71 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -871,9 +871,9 @@
 # @connection-id: SPICE connection id number.  All channels with the same id
 # belong to the same SPICE session.
 #
-# @connection-type: SPICE channel type number.  "1" is the main control
-#   channel, filter for this one if you want to track spice
-#   sessions only
+# @channel-type: SPICE channel type number.  "1" is the main control
+#channel, filter for this one if you want to track spice
+#sessions only
 #
 # @channel-id: SPICE channel ID number.  Usually "0", might be different when
 #  multiple channels of the same type exist, such as multiple
-- 
2.1.4




[Qemu-devel] [PATCH 09/51] qerror.h: Swap definitions that were not in alphabetical order

2015-03-06 Thread Michael Tokarev
From: Alberto Garcia 

Signed-off-by: Alberto Garcia 
Reviewed-by: John Snow 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 include/qapi/qmp/qerror.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 986260f..57a62d4 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -37,12 +37,12 @@ void qerror_report_err(Error *err);
 #define QERR_BASE_NOT_FOUND \
 ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
 
-#define QERR_BLOCK_JOB_NOT_READY \
-ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be 
completed"
-
 #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
 ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not 
support feature '%s'"
 
+#define QERR_BLOCK_JOB_NOT_READY \
+ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be 
completed"
+
 #define QERR_BUS_NO_HOTPLUG \
 ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
 
-- 
2.1.4




Re: [Qemu-devel] [PATCH 3/3] 9pfs-proxy: remove one half of redundrand code

2015-03-06 Thread Michael Tokarev
07.03.2015 00:43, Michael Tokarev пишет:

> +retval = v9fs_marshal(&proxy->out_iovec, 1, PROXY_HDR_SZ, 0, fmt, ap);

This should be the new v9fs_vmarshal() ofcourse.

/mjt



[Qemu-devel] [PATCH 2/3] fsdev: introduce v9fs_vmarshal() and v9fs_vunmarshal()

2015-03-06 Thread Michael Tokarev
This splits existing functions which expects any argument
into pairs, second being one which accepts va_list, to
be used later.

Signed-off-by: Michael Tokarev 
---
 fsdev/virtio-9p-marshal.c | 38 --
 fsdev/virtio-9p-marshal.h |  6 ++
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c
index 20f308b..757a79a 100644
--- a/fsdev/virtio-9p-marshal.c
+++ b/fsdev/virtio-9p-marshal.c
@@ -108,15 +108,13 @@ ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t 
offset,
 return v9fs_packunpack((void *)src, in_sg, in_num, offset, size, 1);
 }
 
-ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
-   int bswap, const char *fmt, ...)
+ssize_t v9fs_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
+int bswap, const char *fmt, va_list ap)
 {
 int i;
-va_list ap;
 ssize_t copied = 0;
 size_t old_offset = offset;
 
-va_start(ap, fmt);
 for (i = 0; fmt[i]; i++) {
 switch (fmt[i]) {
 case 'b': {
@@ -212,20 +210,28 @@ ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, 
size_t offset,
 }
 offset += copied;
 }
-va_end(ap);
 
 return offset - old_offset;
 }
 
-ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
- int bswap, const char *fmt, ...)
+ssize_t v9fs_unmarshal(struct iovec *in_sg, int in_num, size_t offset,
+  int bswap, const char *fmt, ...)
 {
-int i;
+ssize_t ret;
 va_list ap;
+va_start(ap, fmt);
+ret = v9fs_vunmarshal(in_sg, in_num, offset, bswap, fmt, ap);
+va_end(ap);
+return ret;
+}
+
+ssize_t v9fs_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
+ int bswap, const char *fmt, va_list ap)
+{
+int i;
 ssize_t copied = 0;
 size_t old_offset = offset;
 
-va_start(ap, fmt);
 for (i = 0; fmt[i]; i++) {
 switch (fmt[i]) {
 case 'b': {
@@ -317,7 +323,19 @@ ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, 
size_t offset,
 }
 offset += copied;
 }
-va_end(ap);
 
 return offset - old_offset;
 }
+
+ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
+int bswap, const char *fmt, ...)
+{
+ssize_t ret;
+va_list ap;
+va_start(ap, fmt);
+ret = v9fs_vmarshal(in_sg, in_num, offset, bswap, fmt, ap);
+va_end(ap);
+return ret;
+}
+
+
diff --git a/fsdev/virtio-9p-marshal.h b/fsdev/virtio-9p-marshal.h
index 5df65a8..90d48ca 100644
--- a/fsdev/virtio-9p-marshal.h
+++ b/fsdev/virtio-9p-marshal.h
@@ -1,6 +1,8 @@
 #ifndef _QEMU_VIRTIO_9P_MARSHAL_H
 #define _QEMU_VIRTIO_9P_MARSHAL_H
 
+#include 
+
 typedef struct V9fsString
 {
 uint16_t size;
@@ -85,6 +87,10 @@ ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t 
offset,
   const void *src, size_t size);
 ssize_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
int bswap, const char *fmt, ...);
+ssize_t v9fs_vunmarshal(struct iovec *out_sg, int out_num, size_t offset,
+int bswap, const char *fmt, va_list ap);
 ssize_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset,
  int bswap, const char *fmt, ...);
+ssize_t v9fs_vmarshal(struct iovec *in_sg, int in_num, size_t offset,
+  int bswap, const char *fmt, va_list ap);
 #endif
-- 
2.1.4




[Qemu-devel] [PATCH 1/3] 9pfs-proxy: simplify error handling

2015-03-06 Thread Michael Tokarev
All filesystem methods that call common v9fs_request() function
also convert return value to errno.  Move this conversion to the
common function and remove redundand error handling in methods.

I didn't remove local `retval' variable in simple functions to
keep the code consistent.

Also, proxy_truncate() seem to prefer zero successful return
instead of returning whatever the helper returned, maybe this
should be changed.

This also removes (harmless) double call to v9fs_string_free()
in proxy_mkdir(), and renames local variables in some functions
for consistency.

Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 142 --
 1 file changed, 35 insertions(+), 107 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 0904130..13064b6 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -291,7 +291,7 @@ static int v9fs_receive_status(V9fsProxy *proxy,
 /*
  * Proxy->header and proxy->request written to socket by QEMU process.
  * This request read by proxy helper process
- * returns 0 on success and -errno on error
+ * returns 0 on success and -1 (setting errno) on error
  */
 static int v9fs_request(V9fsProxy *proxy, int type,
 void *response, const char *fmt, ...)
@@ -299,7 +299,7 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 dev_t rdev;
 va_list ap;
 int size = 0;
-int retval = 0;
+int retval, err;
 uint64_t offset;
 ProxyHeader header = { 0, 0};
 struct timespec spec[2];
@@ -310,10 +310,11 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 
 qemu_mutex_lock(&proxy->mutex);
 
-if (proxy->sockfd == -1) {
+if (proxy->sockfd < 0) {
 retval = -EIO;
-goto err_out;
+goto out;
 }
+
 iovec = &proxy->out_iovec;
 reply = &proxy->in_iovec;
 va_start(ap, fmt);
@@ -529,15 +530,15 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 va_end(ap);
 
 if (retval < 0) {
-goto err_out;
+goto out;
 }
 
 /* marshal the header details */
 proxy_marshal(iovec, 0, "dd", header.type, header.size);
 header.size += PROXY_HDR_SZ;
 
-retval = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
-if (retval != header.size) {
+err = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
+if (err != header.size) {
 goto close_error;
 }
 
@@ -548,9 +549,7 @@ static int v9fs_request(V9fsProxy *proxy, int type,
  * A file descriptor is returned as response for
  * T_OPEN,T_CREATE on success
  */
-if (v9fs_receivefd(proxy->sockfd, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receivefd(proxy->sockfd, &retval);
 break;
 case T_MKNOD:
 case T_MKDIR:
@@ -564,51 +563,44 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 case T_REMOVE:
 case T_LSETXATTR:
 case T_LREMOVEXATTR:
-if (v9fs_receive_status(proxy, reply, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receive_status(proxy, reply, &retval);
 break;
 case T_LSTAT:
 case T_READLINK:
 case T_STATFS:
 case T_GETVERSION:
-if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
-goto close_error;
-}
+err = v9fs_receive_response(proxy, type, &retval, response);
 break;
 case T_LGETXATTR:
 case T_LLISTXATTR:
 if (!size) {
-if (v9fs_receive_status(proxy, reply, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receive_status(proxy, reply, &retval);
 } else {
-if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
-goto close_error;
-}
+err = v9fs_receive_response(proxy, type, &retval, response);
 }
 break;
 }
 
-err_out:
-qemu_mutex_unlock(&proxy->mutex);
-return retval;
-
+if (err < 0) {
 close_error:
-close(proxy->sockfd);
-proxy->sockfd = -1;
+close(proxy->sockfd);
+proxy->sockfd = -1;
+retval = -EIO;
+}
+
+out:
+if (retval < 0) {
+errno = -retval;
+retval = -1;
+}
 qemu_mutex_unlock(&proxy->mutex);
-return -EIO;
+return retval;
 }
 
 static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat 
*stbuf)
 {
 int retval;
 retval = v9fs_request(fs_ctx->private, T_LSTAT, stbuf, "s", fs_path);
-if (retval < 0) {
-errno = -retval;
-return -1;
-}
 return retval;
 }
 
@@ -619,7 +611,6 @@ static ssize_t proxy_readlink(FsContext *fs_ctx, V9fsPath 
*fs_path,
 retval = v9fs_request(fs_ctx->private, T_READLINK, buf, "sd",
   fs_path, bufsz);
 if (retval < 0) {
-errno = -retval;
 return -1;
 }
 return strlen(buf);
@@ -639,10 +630,6 @@ static int p

[Qemu-devel] [PATCH 3/3] 9pfs-proxy: remove one half of redundrand code

2015-03-06 Thread Michael Tokarev
The 9pfs-proxy code is actually terrible: it does the same
things again and again, ignoring function arguments and
re-inventing the same values again, and a lot of code must
be consistent with each other.

In particular, lots of filesystem methods use common v9fs_request()
function and pass all method args together with pack string to it.
However, v9fs_request() just ignores this, pop the values out of
stack and sets pack string once more.  This is sort of absurd.

This patch removes per-request-type argument marshalling from
v9fs_request() and keeps it only in the individual request
handling methods.

It also removes method-switch from response receiving and moves
the response/fd/status receiving decision also to the individual
request handling methods.

What's left is to do something similar with receiving response,
v9fs_receive_response() function.

Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 275 +++---
 1 file changed, 14 insertions(+), 261 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 13064b6..3dbd568 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -296,17 +296,8 @@ static int v9fs_receive_status(V9fsProxy *proxy,
 static int v9fs_request(V9fsProxy *proxy, int type,
 void *response, const char *fmt, ...)
 {
-dev_t rdev;
 va_list ap;
-int size = 0;
 int retval, err;
-uint64_t offset;
-ProxyHeader header = { 0, 0};
-struct timespec spec[2];
-int flags, mode, uid, gid;
-V9fsString *name, *value;
-V9fsString *path, *oldpath;
-struct iovec *iovec = NULL, *reply = NULL;
 
 qemu_mutex_lock(&proxy->mutex);
 
@@ -315,218 +306,8 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 goto out;
 }
 
-iovec = &proxy->out_iovec;
-reply = &proxy->in_iovec;
 va_start(ap, fmt);
-switch (type) {
-case T_OPEN:
-path = va_arg(ap, V9fsString *);
-flags = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, flags);
-if (retval > 0) {
-header.size = retval;
-header.type = T_OPEN;
-}
-break;
-case T_CREATE:
-path = va_arg(ap, V9fsString *);
-flags = va_arg(ap, int);
-mode = va_arg(ap, int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path,
-flags, mode, uid, gid);
-if (retval > 0) {
-header.size = retval;
-header.type = T_CREATE;
-}
-break;
-case T_MKNOD:
-path = va_arg(ap, V9fsString *);
-mode = va_arg(ap, int);
-rdev = va_arg(ap, long int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddsdq",
-uid, gid, path, mode, rdev);
-if (retval > 0) {
-header.size = retval;
-header.type = T_MKNOD;
-}
-break;
-case T_MKDIR:
-path = va_arg(ap, V9fsString *);
-mode = va_arg(ap, int);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddsd",
-uid, gid, path, mode);
-if (retval > 0) {
-header.size = retval;
-header.type = T_MKDIR;
-}
-break;
-case T_SYMLINK:
-oldpath = va_arg(ap, V9fsString *);
-path = va_arg(ap, V9fsString *);
-uid = va_arg(ap, int);
-gid = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddss",
-uid, gid, oldpath, path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_SYMLINK;
-}
-break;
-case T_LINK:
-oldpath = va_arg(ap, V9fsString *);
-path = va_arg(ap, V9fsString *);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ss",
-oldpath, path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_LINK;
-}
-break;
-case T_LSTAT:
-path = va_arg(ap, V9fsString *);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path);
-if (retval > 0) {
-header.size = retval;
-header.type = T_LSTAT;
-}
-break;
-case T_READLINK:
-path = va_arg(ap, V9fsString *);
-size = va_arg(ap, int);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, size);
-if (retval > 0) {
-header.size = retval;
-header.type = T_READLINK;
-}
-break;
-case T_STATFS:
-path = va_arg(ap, V9fsString *);
-retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path);
-if (retval > 0) {

[Qemu-devel] [PATCH v3 0/3] RFC: 9pfs-proxy: simplify/cleanup

2015-03-06 Thread Michael Tokarev
Try to make the code a bit less ugly.  First by moving
errno = -retval to a common place, and second by simplifying
common place a lot.  What's left is v9fs_receive_response().

V3: merge several small patches into larger ones,
drop trivial stuff

Michael Tokarev (3):
  9pfs-proxy: simplify error handling
  fsdev: introduce v9fs_vmarshal() and v9fs_vunmarshal()
  9pfs-proxy: remove one half of redundrand code

 fsdev/virtio-9p-marshal.c |  38 +++--
 fsdev/virtio-9p-marshal.h |   6 +
 hw/9pfs/virtio-9p-proxy.c | 405 +-
 3 files changed, 77 insertions(+), 372 deletions(-)

-- 
2.1.4




[Qemu-devel] [PATCH 26/51] qemu-char: add cyrillic characters 'numerosign' to VNC keysyms

2015-03-06 Thread Michael Tokarev
From: Wang Xin 

This patch adds missing cyrillic character 'numerosign' to the VNC
keysym table, it's needed by Russian keyboard. And I get the keysym from
'', the current keysym table in Qemu was generated from
it.

Signed-off-by: Wang xin 
Signed-off-by: Gonglei 
Signed-off-by: Michael Tokarev 
---
 ui/vnc_keysym.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ui/vnc_keysym.h b/ui/vnc_keysym.h
index 1dc039f..7fa2bc1 100644
--- a/ui/vnc_keysym.h
+++ b/ui/vnc_keysym.h
@@ -404,6 +404,7 @@ static const name2keysym_t name2keysym[]={
 {"breve", 0x01a2},  /* U+02D8 BREVE */
 {"caron", 0x01b7},  /* U+02C7 CARON */
 {"Ccaron",0x01c8},  /* U+010C LATIN CAPITAL LETTER C 
WITH CARON */
+{"numerosign",0x06b0},  /* U+2116 NUMERO SIGN */
 {"Cyrillic_a",0x06c1},  /* U+0430 CYRILLIC SMALL LETTER A 
*/
 {"Cyrillic_A",0x06e1},  /* U+0410 CYRILLIC CAPITAL LETTER 
A */
 {"Cyrillic_be",   0x06c2},  /* U+0431 CYRILLIC SMALL LETTER BE 
*/
-- 
2.1.4




[Qemu-devel] [PATCH 40/51] oslib-posix: Fix compiler warning (-Wclobbered) and simplify the code

2015-03-06 Thread Michael Tokarev
From: Stefan Weil 

gcc reports this warning with -Wclobbered:

util/oslib-posix.c: In function ‘os_mem_prealloc’:
util/oslib-posix.c:374:49: error: argument ‘memory’ might be clobbered by
 ‘longjmp’ or ‘vfork’ [-Werror=clobbered]

Fix this and simplify the code by using an existing macro.

Signed-off-by: Stefan Weil 
Signed-off-by: Michael Tokarev 
---
 util/oslib-posix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 16fcec2..37ffd96 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -399,10 +399,10 @@ void os_mem_prealloc(int fd, char *area, size_t memory)
 } else {
 int i;
 size_t hpagesize = fd_getpagesize(fd);
+size_t numpages = DIV_ROUND_UP(memory, hpagesize);
 
 /* MAP_POPULATE silently ignores failures */
-memory = (memory + hpagesize - 1) & -hpagesize;
-for (i = 0; i < (memory / hpagesize); i++) {
+for (i = 0; i < numpages; i++) {
 memset(area + (hpagesize * i), 0, 1);
 }
 
-- 
2.1.4




[Qemu-devel] [PATCH 03/51] xilinx_ethlite: Clean up after commit 2f991ad

2015-03-06 Thread Michael Tokarev
From: Markus Armbruster 

The "fall through" added by the commit is clearly intentional.  Mark
it so.  Hushes up Coverity.

Signed-off-by: Markus Armbruster 
Reviewed-by: Peter Crosthwaite 
Signed-off-by: Michael Tokarev 
---
 hw/net/xilinx_ethlite.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
index 9536f64..ad6b553 100644
--- a/hw/net/xilinx_ethlite.c
+++ b/hw/net/xilinx_ethlite.c
@@ -146,6 +146,7 @@ eth_write(void *opaque, hwaddr addr,
 if (!(value & CTRL_S)) {
 qemu_flush_queued_packets(qemu_get_queue(s->nic));
 }
+/* fall through */
 case R_TX_LEN0:
 case R_TX_LEN1:
 case R_TX_GIE0:
-- 
2.1.4




[Qemu-devel] [PATCH 11/51] block: remove superfluous '\n' around error_report/error_setg

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 block/archipelago.c | 6 +++---
 hw/block/nand.c | 2 +-
 qemu-img.c  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/archipelago.c b/block/archipelago.c
index a8114b5..855655c 100644
--- a/block/archipelago.c
+++ b/block/archipelago.c
@@ -291,7 +291,7 @@ static int qemu_archipelago_init(BDRVArchipelagoState *s)
 
 ret = qemu_archipelago_xseg_init(s);
 if (ret < 0) {
-error_report("Cannot initialize XSEG. Aborting...\n");
+error_report("Cannot initialize XSEG. Aborting...");
 goto err_exit;
 }
 
@@ -645,7 +645,7 @@ static int qemu_archipelago_create_volume(Error **errp, 
const char *volname,
 
 target = xseg_get_target(xseg, req);
 if (!target) {
-error_setg(errp, "Cannot get XSEG target.\n");
+error_setg(errp, "Cannot get XSEG target.");
 goto err_exit;
 }
 memcpy(target, volname, targetlen);
@@ -889,7 +889,7 @@ static BlockAIOCB *qemu_archipelago_aio_rw(BlockDriverState 
*bs,
 return &aio_cb->common;
 
 err_exit:
-error_report("qemu_archipelago_aio_rw(): I/O Error\n");
+error_report("qemu_archipelago_aio_rw(): I/O Error");
 qemu_aio_unref(aio_cb);
 return NULL;
 }
diff --git a/hw/block/nand.c b/hw/block/nand.c
index 1882a0c..61d2cec 100644
--- a/hw/block/nand.c
+++ b/hw/block/nand.c
@@ -393,7 +393,7 @@ static void nand_realize(DeviceState *dev, Error **errp)
 nand_init_2048(s);
 break;
 default:
-error_setg(errp, "Unsupported NAND block size %#x\n",
+error_setg(errp, "Unsupported NAND block size %#x",
1 << s->page_shift);
 return;
 }
diff --git a/qemu-img.c b/qemu-img.c
index 7ac7f56..6d17755 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1645,7 +1645,7 @@ static int img_convert(int argc, char **argv)
 if (skip_create) {
 int64_t output_sectors = blk_nb_sectors(out_blk);
 if (output_sectors < 0) {
-error_report("unable to get output image length: %s\n",
+error_report("unable to get output image length: %s",
  strerror(-output_sectors));
 ret = -1;
 goto out;
-- 
2.1.4




[Qemu-devel] [PATCH 29/51] sparc/leon3.c: fix memory leak

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Signed-off-by: Michael Tokarev 
---
 hw/sparc/leon3.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 751392e..e41ec0b 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -186,6 +186,7 @@ static void leon3_generic_hw_init(MachineState *machine)
 fprintf(stderr, "Can't read bios image %s\n", filename);
 exit(1);
 }
+g_free(filename);
 
 /* Can directly load an application. */
 if (kernel_filename != NULL) {
-- 
2.1.4




[Qemu-devel] [PATCH 35/51] e500: fix memory leak

2015-03-06 Thread Michael Tokarev
Signed-off-by: Michael Tokarev 
Reviewed-by: Paolo Bonzini 
Reviewed-by: Stefan Weil 
---
 hw/ppc/e500.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 7e17d18..a8237a3 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -308,6 +308,7 @@ static int ppce500_load_device_tree(MachineState *machine,
 }
 
 fdt = load_device_tree(filename, &fdt_size);
+g_free(filename);
 if (!fdt) {
 goto out;
 }
-- 
2.1.4




Re: [Qemu-devel] [PATCH] MAINTAINERS: Add jcody as blockjobs, block devices maintainer

2015-03-06 Thread Richard W.M. Jones
On Fri, Mar 06, 2015 at 03:08:29PM -0600, Stefan Hajnoczi wrote:
> You don't need to do anything different.  Jeff will make sure your acked
> patches get merged instead of Kevin or me once this MAINTAINERS commit
> is in qemu.git/master.

Sounds sensible, thanks Jeff.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html



Re: [Qemu-devel] [PATCH 0/6 v5] tilegx: Can load elf64 tilegx binary successfully for linux-user

2015-03-06 Thread Chen Gang
Hello All:

I have to leave Sunrus, the mail address (gang.c...@sunrus.com.cn) will
be closed soon (Sunrus will be closed soon because of money, I guess).

I change my new email address (xili_gchen_5...@hotmail.com) to continue
communicating. gang.chen.5...@gmail.com is still have effect, but it is
not stable (gmail in China is not stable).

And if the patches can pass checking, please add me as the maintainer,
and let Andreas, Chris, Richard, and Peter as Reviewed-by.

Thanks.

On 3/6/15 04:22, Chen Gang wrote:
> After load elf64 tilegx binary for linux-user, the working flow reaches
> 1st correct instruction "__start". Next, we shall load all instructions
> for qemu using.
> 
> This patch is based on Linux kernel tile architecture tilegx 64-bit
> implementation, and also based on tilegx architecture ABI reference.
> 
> The related test:
> 
>   [root@localhost qemu]# ./configure --target-list=tilegx-linux-user && make 
>   [root@localhost qemu]# ./tilegx-linux-user/qemu-tilegx -d all ./test.tgx
>   CPU Reset (CPU 0)
>   CPU Reset (CPU 0)
>   host mmap_min_addr=0x1
>   Reserved 0xe bytes of guest address space
>   Relocating guest address space from 0x0001 to 0x1
>   guest_base  0x0  
>   startend  size prot 
>   0001-000e 000d r-x
>   000e-000f 0001 rw-
>   0040-0041 0001 ---
>   0041-00400081 0080 rw-
>   start_brk   0x
>   end_code0x000d86f7
>   start_code  0x0001
>   start_data  0x000e86f8
>   end_data0x000ea208
>   start_stack 0x00400080f250
>   brk 0x000ec2b0
>   entry   0x00010f60
>   PROLOGUE: [size=40]
>   0x7fcc44c716f0:  push   %rbp 
>   0x7fcc44c716f1:  push   %rbx 
>   0x7fcc44c716f2:  push   %r12 
>   0x7fcc44c716f4:  push   %r13 
>   0x7fcc44c716f6:  push   %r14 
>   0x7fcc44c716f8:  push   %r15 
>   0x7fcc44c716fa:  mov%rdi,%r14
>   0x7fcc44c716fd:  add$0xfb78,%rsp
>   0x7fcc44c71704:  jmpq   *%rsi
>   0x7fcc44c71706:  add$0x488,%rsp
>   0x7fcc44c7170d:  pop%r15 
>   0x7fcc44c7170f:  pop%r14 
>   0x7fcc44c71711:  pop%r13 
>   0x7fcc44c71713:  pop%r12 
>   0x7fcc44c71715:  pop%rbx 
>   0x7fcc44c71716:  pop%rbp 
>   0x7fcc44c71717:  retq 
> 
>   Load elf64 tilegx successfully
>   reach code start position: [00010f60] _start
> 
>   [root@localhost qemu]# echo $?
>   0
>   [root@localhost qemu]#
> 
> 
> Chen Gang (6):
>   target-tilegx: Firstly add TILE-Gx with minimized features
>   linux-user: tilegx: Firstly add architecture related features
>   linux-user: tilegx: Add target features support within qemu
>   linux-user: Support tilegx architecture in syscall
>   linux-user: Support tilegx architecture in linux-user
>   linux-user/syscall.c: conditionalize syscalls which are not defined in
> tilegx
> 
>  configure |   3 +
>  default-configs/tilegx-linux-user.mak |   1 +
>  include/elf.h |   2 +
>  linux-user/elfload.c  |  23 +++
>  linux-user/main.c |  74 +
>  linux-user/syscall.c  |  50 +-
>  linux-user/syscall_defs.h |  38 -
>  linux-user/tilegx/syscall.h   |  80 ++
>  linux-user/tilegx/syscall_nr.h| 278 +
>  linux-user/tilegx/target_cpu.h|  35 +
>  linux-user/tilegx/target_signal.h |  28 
>  linux-user/tilegx/target_structs.h|  48 ++
>  linux-user/tilegx/termbits.h  | 285 
> ++
>  target-tilegx/Makefile.objs   |   1 +
>  target-tilegx/cpu-qom.h   |  71 +
>  target-tilegx/cpu.c   | 153 ++
>  target-tilegx/cpu.h   |  85 ++
>  target-tilegx/helper.h|   0
>  target-tilegx/translate.c |  53 +++
>  19 files changed, 1303 insertions(+), 5 deletions(-)
>  create mode 100644 default-configs/tilegx-linux-user.mak
>  create mode 100644 linux-user/tilegx/syscall.h
>  create mode 100644 linux-user/tilegx/syscall_nr.h
>  create mode 100644 linux-user/tilegx/target_cpu.h
>  create mode 100644 linux-user/tilegx/target_signal.h
>  create mode 100644 linux-user/tilegx/target_structs.h
>  create mode 100644 linux-user/tilegx/termbits.h
>  create mode 100644 target-tilegx/Makefile.objs
>  create mode 100644 target-tilegx/cpu-qom.h
>  create mode 100644 target-tilegx/cpu.c
>  create mode 100644 target-tilegx/cpu.h
>  create mode 100644 target-tilegx/helper.h
>  create mode 100644 target-tilegx/translate.c
> 

-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed



Re: [Qemu-devel] [PATCH 0/6 v5] tilegx: Can load elf64 tilegx binary successfully for linux-user

2015-03-06 Thread Chen Gang
Hello All:

I have to leave Sunrus, the mail address (gang.c...@sunrus.com.cn) will
be closed soon (Sunrus will be closed soon because of money, I guess).

I change my new email address (xili_gchen_5...@hotmail.com) to continue
communicating. gang.chen.5...@gmail.com is still have effect, but it is
not stable (gmail in China is not stable).

And if the patches can pass checking, please add me as the maintainer,
and let Andreas, Chris, Richard, and Peter as Reviewed-by.

Thanks.

On 3/6/15 04:22, Chen Gang wrote:
> After load elf64 tilegx binary for linux-user, the working flow reaches
> 1st correct instruction "__start". Next, we shall load all instructions
> for qemu using.
> 
> This patch is based on Linux kernel tile architecture tilegx 64-bit
> implementation, and also based on tilegx architecture ABI reference.
> 
> The related test:
> 
>   [root@localhost qemu]# ./configure --target-list=tilegx-linux-user && make 
>   [root@localhost qemu]# ./tilegx-linux-user/qemu-tilegx -d all ./test.tgx
>   CPU Reset (CPU 0)
>   CPU Reset (CPU 0)
>   host mmap_min_addr=0x1
>   Reserved 0xe bytes of guest address space
>   Relocating guest address space from 0x0001 to 0x1
>   guest_base  0x0  
>   startend  size prot 
>   0001-000e 000d r-x
>   000e-000f 0001 rw-
>   0040-0041 0001 ---
>   0041-00400081 0080 rw-
>   start_brk   0x
>   end_code0x000d86f7
>   start_code  0x0001
>   start_data  0x000e86f8
>   end_data0x000ea208
>   start_stack 0x00400080f250
>   brk 0x000ec2b0
>   entry   0x00010f60
>   PROLOGUE: [size=40]
>   0x7fcc44c716f0:  push   %rbp 
>   0x7fcc44c716f1:  push   %rbx 
>   0x7fcc44c716f2:  push   %r12 
>   0x7fcc44c716f4:  push   %r13 
>   0x7fcc44c716f6:  push   %r14 
>   0x7fcc44c716f8:  push   %r15 
>   0x7fcc44c716fa:  mov%rdi,%r14
>   0x7fcc44c716fd:  add$0xfb78,%rsp
>   0x7fcc44c71704:  jmpq   *%rsi
>   0x7fcc44c71706:  add$0x488,%rsp
>   0x7fcc44c7170d:  pop%r15 
>   0x7fcc44c7170f:  pop%r14 
>   0x7fcc44c71711:  pop%r13 
>   0x7fcc44c71713:  pop%r12 
>   0x7fcc44c71715:  pop%rbx 
>   0x7fcc44c71716:  pop%rbp 
>   0x7fcc44c71717:  retq 
> 
>   Load elf64 tilegx successfully
>   reach code start position: [00010f60] _start
> 
>   [root@localhost qemu]# echo $?
>   0
>   [root@localhost qemu]#
> 
> 
> Chen Gang (6):
>   target-tilegx: Firstly add TILE-Gx with minimized features
>   linux-user: tilegx: Firstly add architecture related features
>   linux-user: tilegx: Add target features support within qemu
>   linux-user: Support tilegx architecture in syscall
>   linux-user: Support tilegx architecture in linux-user
>   linux-user/syscall.c: conditionalize syscalls which are not defined in
> tilegx
> 
>  configure |   3 +
>  default-configs/tilegx-linux-user.mak |   1 +
>  include/elf.h |   2 +
>  linux-user/elfload.c  |  23 +++
>  linux-user/main.c |  74 +
>  linux-user/syscall.c  |  50 +-
>  linux-user/syscall_defs.h |  38 -
>  linux-user/tilegx/syscall.h   |  80 ++
>  linux-user/tilegx/syscall_nr.h| 278 +
>  linux-user/tilegx/target_cpu.h|  35 +
>  linux-user/tilegx/target_signal.h |  28 
>  linux-user/tilegx/target_structs.h|  48 ++
>  linux-user/tilegx/termbits.h  | 285 
> ++
>  target-tilegx/Makefile.objs   |   1 +
>  target-tilegx/cpu-qom.h   |  71 +
>  target-tilegx/cpu.c   | 153 ++
>  target-tilegx/cpu.h   |  85 ++
>  target-tilegx/helper.h|   0
>  target-tilegx/translate.c |  53 +++
>  19 files changed, 1303 insertions(+), 5 deletions(-)
>  create mode 100644 default-configs/tilegx-linux-user.mak
>  create mode 100644 linux-user/tilegx/syscall.h
>  create mode 100644 linux-user/tilegx/syscall_nr.h
>  create mode 100644 linux-user/tilegx/target_cpu.h
>  create mode 100644 linux-user/tilegx/target_signal.h
>  create mode 100644 linux-user/tilegx/target_structs.h
>  create mode 100644 linux-user/tilegx/termbits.h
>  create mode 100644 target-tilegx/Makefile.objs
>  create mode 100644 target-tilegx/cpu-qom.h
>  create mode 100644 target-tilegx/cpu.c
>  create mode 100644 target-tilegx/cpu.h
>  create mode 100644 target-tilegx/helper.h
>  create mode 100644 target-tilegx/translate.c
> 

-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed



Re: [Qemu-devel] [PATCH] MAINTAINERS: Add jcody as blockjobs, block devices maintainer

2015-03-06 Thread Jeff Cody
On Fri, Mar 06, 2015 at 03:08:29PM -0600, Stefan Hajnoczi wrote:
> On Fri, Mar 06, 2015 at 12:16:06PM -0500, Jeff Cody wrote:
> > The block layer maintainership is being split up into smaller, more
> > manageable pieces.
> > 
> > I propose that I take over / assist with the following areas:
> > 
> > * blockjobs
> > * archipelago
> > * curl
> > * gluster
> > * nfs
> > * rbd
> > * sheepdog
> > * ssh
> > * vhdx
> 
> This patch should also CC Josh Durgin, Hitoshi Mitake, Liu Yuan, Peter
> Lieven, Richard W.M. Jones, and Chrysostomos Nanakos since it affects
> code they maintain.  I have added them.
>

My apologies to all - and thanks for adding them!

Jeff


> Dear maintainers,
> Your patches currently go through Kevin and my block tree.  We are now
> trying to scale the development process by splitting up block layer
> maintainership.
> 
> Instead of Kevin or me including your acked patches in block pull
> requests, Jeff Cody is now going to take over the job of pull requests
> for network block drivers.
> 
> You don't need to do anything different.  Jeff will make sure your acked
> patches get merged instead of Kevin or me once this MAINTAINERS commit
> is in qemu.git/master.
> 
> > 
> > As John Snow noted in a different patch:
> > 
> > As we split out the block layer, we will begin using the qemu-block
> > mailing list as a catchall for all of the block layer subcomponents.
> > Please CC qemu-bl...@nongnu.org for all block layer patches, including
> > any that touch the above listed areas.
> > 
> > Signed-off-by: Jeff Cody 
> > ---
> >  MAINTAINERS | 43 +++
> >  1 file changed, 43 insertions(+)
> 
> Acked-by: Stefan Hajnoczi 
> 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 8c06739..72c1b04 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -770,6 +770,18 @@ F: tests/qemu-iotests/
> >  T: git git://repo.or.cz/qemu/kevin.git block
> >  T: git git://github.com/stefanha/qemu.git block
> >  
> > +Block Jobs
> > +M: Jeff Cody 
> > +L: qemu-bl...@nongnu.org
> > +S: Supported
> > +F: blockjob.c
> > +F: include/block/blockjob.h
> > +F: block/backup.c
> > +F: block/commit.c
> > +F: block/stream.h
> > +F: block/mirror.c
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> > +
> >  Character Devices
> >  M: Anthony Liguori 
> >  M: Paolo Bonzini 
> > @@ -1079,20 +1091,28 @@ F: block/vmdk.c
> >  
> >  RBD
> >  M: Josh Durgin 
> > +M: Jeff Cody 
> > +L: qemu-bl...@nongnu.org
> >  S: Supported
> >  F: block/rbd.c
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> >  
> >  Sheepdog
> >  M: Hitoshi Mitake 
> >  M: Liu Yuan 
> > +M: Jeff Cody 
> > +L: qemu-bl...@nongnu.org
> >  L: sheep...@lists.wpkg.org
> >  S: Supported
> >  F: block/sheepdog.c
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> >  
> >  VHDX
> >  M: Jeff Cody 
> > +L: qemu-bl...@nongnu.org
> >  S: Supported
> >  F: block/vhdx*
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> >  
> >  VDI
> >  M: Stefan Weil 
> > @@ -1107,19 +1127,42 @@ S: Supported
> >  F: block/iscsi.c
> >  
> >  NFS
> > +M: Jeff Cody 
> >  M: Peter Lieven 
> > +L: qemu-bl...@nongnu.org
> >  S: Maintained
> >  F: block/nfs.c
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> >  
> >  SSH
> >  M: Richard W.M. Jones 
> > +M: Jeff Cody 
> > +L: qemu-bl...@nongnu.org
> >  S: Supported
> >  F: block/ssh.c
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> >  
> >  ARCHIPELAGO
> >  M: Chrysostomos Nanakos 
> > +M: Jeff Cody 
> > +L: qemu-bl...@nongnu.org
> >  S: Maintained
> >  F: block/archipelago.c
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> > +
> > +CURL
> > +M: Jeff Cody 
> > +L: qemu-bl...@nongnu.org
> > +S: Supported
> > +F: block/curl.c
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> > +
> > +GLUSTER
> > +M: Jeff Cody 
> > +L: qemu-bl...@nongnu.org
> > +S: Supported
> > +F: block/gluster.c
> > +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> >  
> >  Bootdevice
> >  M: Gonglei 
> > -- 
> > 1.9.3
> > 





Re: [Qemu-devel] [PATCH] MAINTAINERS: Add jcody as blockjobs, block devices maintainer

2015-03-06 Thread Stefan Hajnoczi
On Fri, Mar 06, 2015 at 12:16:06PM -0500, Jeff Cody wrote:
> The block layer maintainership is being split up into smaller, more
> manageable pieces.
> 
> I propose that I take over / assist with the following areas:
> 
> * blockjobs
> * archipelago
> * curl
> * gluster
> * nfs
> * rbd
> * sheepdog
> * ssh
> * vhdx

This patch should also CC Josh Durgin, Hitoshi Mitake, Liu Yuan, Peter
Lieven, Richard W.M. Jones, and Chrysostomos Nanakos since it affects
code they maintain.  I have added them.

Dear maintainers,
Your patches currently go through Kevin and my block tree.  We are now
trying to scale the development process by splitting up block layer
maintainership.

Instead of Kevin or me including your acked patches in block pull
requests, Jeff Cody is now going to take over the job of pull requests
for network block drivers.

You don't need to do anything different.  Jeff will make sure your acked
patches get merged instead of Kevin or me once this MAINTAINERS commit
is in qemu.git/master.

> 
> As John Snow noted in a different patch:
> 
> As we split out the block layer, we will begin using the qemu-block
> mailing list as a catchall for all of the block layer subcomponents.
> Please CC qemu-bl...@nongnu.org for all block layer patches, including
> any that touch the above listed areas.
> 
> Signed-off-by: Jeff Cody 
> ---
>  MAINTAINERS | 43 +++
>  1 file changed, 43 insertions(+)

Acked-by: Stefan Hajnoczi 

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 8c06739..72c1b04 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -770,6 +770,18 @@ F: tests/qemu-iotests/
>  T: git git://repo.or.cz/qemu/kevin.git block
>  T: git git://github.com/stefanha/qemu.git block
>  
> +Block Jobs
> +M: Jeff Cody 
> +L: qemu-bl...@nongnu.org
> +S: Supported
> +F: blockjob.c
> +F: include/block/blockjob.h
> +F: block/backup.c
> +F: block/commit.c
> +F: block/stream.h
> +F: block/mirror.c
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> +
>  Character Devices
>  M: Anthony Liguori 
>  M: Paolo Bonzini 
> @@ -1079,20 +1091,28 @@ F: block/vmdk.c
>  
>  RBD
>  M: Josh Durgin 
> +M: Jeff Cody 
> +L: qemu-bl...@nongnu.org
>  S: Supported
>  F: block/rbd.c
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
>  
>  Sheepdog
>  M: Hitoshi Mitake 
>  M: Liu Yuan 
> +M: Jeff Cody 
> +L: qemu-bl...@nongnu.org
>  L: sheep...@lists.wpkg.org
>  S: Supported
>  F: block/sheepdog.c
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
>  
>  VHDX
>  M: Jeff Cody 
> +L: qemu-bl...@nongnu.org
>  S: Supported
>  F: block/vhdx*
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
>  
>  VDI
>  M: Stefan Weil 
> @@ -1107,19 +1127,42 @@ S: Supported
>  F: block/iscsi.c
>  
>  NFS
> +M: Jeff Cody 
>  M: Peter Lieven 
> +L: qemu-bl...@nongnu.org
>  S: Maintained
>  F: block/nfs.c
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
>  
>  SSH
>  M: Richard W.M. Jones 
> +M: Jeff Cody 
> +L: qemu-bl...@nongnu.org
>  S: Supported
>  F: block/ssh.c
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
>  
>  ARCHIPELAGO
>  M: Chrysostomos Nanakos 
> +M: Jeff Cody 
> +L: qemu-bl...@nongnu.org
>  S: Maintained
>  F: block/archipelago.c
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> +
> +CURL
> +M: Jeff Cody 
> +L: qemu-bl...@nongnu.org
> +S: Supported
> +F: block/curl.c
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
> +
> +GLUSTER
> +M: Jeff Cody 
> +L: qemu-bl...@nongnu.org
> +S: Supported
> +F: block/gluster.c
> +T: git git://github.com/codyprime/qemu-kvm-jtc.git block
>  
>  Bootdevice
>  M: Gonglei 
> -- 
> 1.9.3
> 


pgpNsns2wNZGr.pgp
Description: PGP signature


[Qemu-devel] [PATCH 44/51] gdbstub: avoid possible NULL pointer dereference

2015-03-06 Thread Michael Tokarev
From: Paolo Bonzini 

Coverity reports that s->chr is checked after put_packet dereferences it.
Move the check earlier, consistent with the code used for user-mode
emulation.

Signed-off-by: Paolo Bonzini 
Signed-off-by: Michael Tokarev 
---
 gdbstub.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gdbstub.c b/gdbstub.c
index e4a1a79..8abcb8a 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1443,15 +1443,17 @@ void gdb_exit(CPUArchState *env, int code)
   if (gdbserver_fd < 0 || s->fd < 0) {
   return;
   }
+#else
+  if (!s->chr) {
+  return;
+  }
 #endif
 
   snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code);
   put_packet(s, buf);
 
 #ifndef CONFIG_USER_ONLY
-  if (s->chr) {
-  qemu_chr_delete(s->chr);
-  }
+  qemu_chr_delete(s->chr);
 #endif
 }
 
-- 
2.1.4




[Qemu-devel] [PATCH 43/51] milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning

2015-03-06 Thread Michael Tokarev
From: Radim Krčmář 

man gcc:
  Warn if in a loop with constant number of iterations the compiler
  detects undefined behavior in some statement during one or more of
  the iterations.

Milkymist pfpu has no jump instructions, so checking for MICROCODE_WORDS
instructions should have kept us in bounds of s->microcode, but i++
allowed one loop too many,

  hw/misc/milkymist-pfpu.c: In function ‘pfpu_write’:
  hw/misc/milkymist-pfpu.c:365:20: error: loop exit may only be reached after 
undefined behavior [-Werror=aggressive-loop-optimizations]
   if (i++ >= MICROCODE_WORDS) {
  ^
  hw/misc/milkymist-pfpu.c:167:14: note: possible undefined statement is here
   uint32_t insn = s->microcode[pc];
^

The code can still access out of bounds, because it presumes that PC register
always begins at 0, and we allow writing to it.

Signed-off-by: Radim Krčmář 
Acked-by: Michael Walle 
Signed-off-by: Michael Tokarev 
---
 hw/misc/milkymist-pfpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/misc/milkymist-pfpu.c b/hw/misc/milkymist-pfpu.c
index 609f33f..08b604f 100644
--- a/hw/misc/milkymist-pfpu.c
+++ b/hw/misc/milkymist-pfpu.c
@@ -362,7 +362,7 @@ static void pfpu_start(MilkymistPFPUState *s)
 i = 0;
 while (pfpu_decode_insn(s)) {
 /* decode at most MICROCODE_WORDS instructions */
-if (i++ >= MICROCODE_WORDS) {
+if (++i >= MICROCODE_WORDS) {
 error_report("milkymist_pfpu: too many instructions "
 "executed in microcode. No VECTOUT?");
 break;
-- 
2.1.4




[Qemu-devel] [PATCH 34/51] gitignore: Ignore new tests

2015-03-06 Thread Michael Tokarev
From: Cole Robinson 

Signed-off-by: Cole Robinson 
Signed-off-by: Michael Tokarev 
---
 tests/.gitignore | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index e2e4957..0dcb618 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -5,6 +5,7 @@ check-qjson
 check-qlist
 check-qstring
 check-qom-interface
+rcutorture
 test-aio
 test-bitops
 test-coroutine
@@ -26,6 +27,7 @@ test-qmp-input-strict
 test-qmp-input-visitor
 test-qmp-marshal.c
 test-qmp-output-visitor
+test-rcu-list
 test-rfifolock
 test-string-input-visitor
 test-string-output-visitor
@@ -33,6 +35,7 @@ test-thread-pool
 test-throttle
 test-visitor-serialization
 test-vmstate
+test-write-threshold
 test-x86-cpuid
 test-xbzrle
 *-test
-- 
2.1.4




[Qemu-devel] [PATCH 12/51] a9gtimer: remove superfluous '\n' around error_setg

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 hw/timer/a9gtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/timer/a9gtimer.c b/hw/timer/a9gtimer.c
index 435142a..b087bbd 100644
--- a/hw/timer/a9gtimer.c
+++ b/hw/timer/a9gtimer.c
@@ -289,7 +289,7 @@ static void a9_gtimer_realize(DeviceState *dev, Error 
**errp)
 int i;
 
 if (s->num_cpu < 1 || s->num_cpu > A9_GTIMER_MAX_CPUS) {
-error_setg(errp, "%s: num-cpu must be between 1 and %d\n",
+error_setg(errp, "%s: num-cpu must be between 1 and %d",
__func__, A9_GTIMER_MAX_CPUS);
 return;
 }
-- 
2.1.4




[Qemu-devel] [PATCH 36/51] vhost_net: Add missing 'static' attribute

2015-03-06 Thread Michael Tokarev
From: Stefan Weil 

This fixes a warning from smatch.

Signed-off-by: Stefan Weil 
Signed-off-by: Michael Tokarev 
---
 hw/net/vhost_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 4e3a061..ebfb6db 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -56,7 +56,7 @@ static const int kernel_feature_bits[] = {
 };
 
 /* Features supported by others. */
-const int user_feature_bits[] = {
+static const int user_feature_bits[] = {
 VIRTIO_F_NOTIFY_ON_EMPTY,
 VIRTIO_RING_F_INDIRECT_DESC,
 VIRTIO_RING_F_EVENT_IDX,
-- 
2.1.4




[Qemu-devel] [PATCH 13/51] pl330.c: remove superfluous '\n' around error_setg

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 hw/dma/pl330.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index 16cf77e..5be3df5 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -1566,7 +1566,7 @@ static void pl330_realize(DeviceState *dev, Error **errp)
 s->cfg[1] |= 5;
 break;
 default:
-error_setg(errp, "Bad value for i-cache_len property: %" PRIx8 "\n",
+error_setg(errp, "Bad value for i-cache_len property: %" PRIx8,
s->i_cache_len);
 return;
 }
@@ -1601,7 +1601,7 @@ static void pl330_realize(DeviceState *dev, Error **errp)
 s->cfg[CFG_CRD] |= 0x4;
 break;
 default:
-error_setg(errp, "Bad value for data_width property: %" PRIx8 "\n",
+error_setg(errp, "Bad value for data_width property: %" PRIx8,
s->data_width);
 return;
 }
-- 
2.1.4




Re: [Qemu-devel] [PULL v2 00/11] Net patches

2015-03-06 Thread Stefan Hajnoczi
On Tue, Mar 03, 2015 at 11:50:33PM +0900, Peter Maydell wrote:
> On 28 February 2015 at 02:07, Stefan Hajnoczi  wrote:
> > v2:
> >  * Squash in Jiri's fix for rocker format string specifiers [Peter]
> >  * Squash in Windows build fix [Peter]
> >  * Both build fixes are described in "rocker: add new rocker switch device"

Jiri or Scott: Please address these clang (llvm) warnings and send a
final revision of the Rocker patch series.  I recommend starting from
the patches in this pull request since they already include other
compiler warning fixes.

To build with clang, use: CC=clang ./configure --disable-werror ...

> Still hasn't fixed all the build errors, I'm afraid:
> 
> In file included from
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker.h:24,
>  from
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_fp.c:19:
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_world.h:24:
> error: redefinition of typedef 'RockerTlv'
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_hw.h:143:
> error: previous declaration of 'RockerTlv' was here
> In file included from
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_fp.c:19:
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker.h:71:
> error: redefinition of typedef 'World'
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_world.h:22:
> error: previous declaration of 'World' was here
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker.h:72:
> error: redefinition of typedef 'Rocker'
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_world.h:23:
> error: previous declaration of 'Rocker' was here
> In file included from
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_fp.c:21:
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_fp.h:25:
> error: redefinition of typedef 'Rocker'
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker.h:72:
> error: previous declaration of 'Rocker' was here
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_fp.h:27:
> error: redefinition of typedef 'World'
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker.h:71:
> error: previous declaration of 'World' was here
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_fp.c:42:
> error: redefinition of typedef 'FpPort'
> /home/petmay01/linaro/qemu-for-merges/hw/net/rocker/rocker_fp.h:26:
> error: previous declaration of 'FpPort' was here
> make: *** [hw/net/rocker/rocker_fp.o] Error 1
> 
> (similarly for other types like DescRing and DescInfo).
> 
> -- PMM
> 


pgpfNGc5yHxFe.pgp
Description: PGP signature


[Qemu-devel] [PATCH 31/51] milkymist.c: fix memory leak

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Signed-off-by: Michael Tokarev 
---
 hw/lm32/milkymist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index 256c102..7f62261 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -155,6 +155,7 @@ milkymist_init(MachineState *machine)
 bios_name);
 exit(1);
 }
+g_free(bios_filename);
 
 milkymist_uart_create(0x6000, irq[0]);
 milkymist_sysctl_create(0x60001000, irq[1], irq[2], irq[3],
-- 
2.1.4




[Qemu-devel] [PATCH 07/51] cutils: refine strtol error handling in parse_debug_env

2015-03-06 Thread Michael Tokarev
From: Paolo Bonzini 

Avoid truncation of a 64-bit long to a 32-bit int, and check for errno
(especially ERANGE).

Signed-off-by: Paolo Bonzini 
Reviewed-by: Eric Blake 
Signed-off-by: Michael Tokarev 
---
 util/cutils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/util/cutils.c b/util/cutils.c
index dbe7412..9312e45 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -523,16 +523,17 @@ int parse_debug_env(const char *name, int max, int 
initial)
 {
 char *debug_env = getenv(name);
 char *inv = NULL;
-int debug;
+long debug;
 
 if (!debug_env) {
 return initial;
 }
+errno = 0;
 debug = strtol(debug_env, &inv, 10);
 if (inv == debug_env) {
 return initial;
 }
-if (debug < 0 || debug > max) {
+if (debug < 0 || debug > max || errno != 0) {
 fprintf(stderr, "warning: %s not in [0, %d]", name, max);
 return initial;
 }
-- 
2.1.4




[Qemu-devel] [PATCH 2/6] 9pfs-proxy: simplify error handling

2015-03-06 Thread Michael Tokarev
All filesystem methods that call common v9fs_request() function
also convert return value to errno.  Move this conversion to the
common function and remove redundand error handling in methods.

I didn't remove local `retval' variable in simple functions to
keep the code consistent.

Also, proxy_truncate() seem to prefer zero successful return
instead of returning whatever the helper returned, maybe this
should be changed.

This also removes (harmless) double call to v9fs_string_free()
in proxy_mkdir().

Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 74 ---
 1 file changed, 5 insertions(+), 69 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index f252fe4..bd764be 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -590,6 +590,10 @@ close_error:
 
 out:
 qemu_mutex_unlock(&proxy->mutex);
+if (retval < 0) {
+errno = -retval;
+retval = -1;
+}
 return retval;
 }
 
@@ -597,10 +601,6 @@ static int proxy_lstat(FsContext *fs_ctx, V9fsPath 
*fs_path, struct stat *stbuf)
 {
 int retval;
 retval = v9fs_request(fs_ctx->private, T_LSTAT, stbuf, "s", fs_path);
-if (retval < 0) {
-errno = -retval;
-return -1;
-}
 return retval;
 }
 
@@ -611,7 +611,6 @@ static ssize_t proxy_readlink(FsContext *fs_ctx, V9fsPath 
*fs_path,
 retval = v9fs_request(fs_ctx->private, T_READLINK, buf, "sd",
   fs_path, bufsz);
 if (retval < 0) {
-errno = -retval;
 return -1;
 }
 return strlen(buf);
@@ -631,10 +630,6 @@ static int proxy_open(FsContext *ctx, V9fsPath *fs_path,
   int flags, V9fsFidOpenState *fs)
 {
 fs->fd = v9fs_request(ctx->private, T_OPEN, NULL, "sd", fs_path, flags);
-if (fs->fd < 0) {
-errno = -fs->fd;
-fs->fd = -1;
-}
 return fs->fd;
 }
 
@@ -646,7 +641,6 @@ static int proxy_opendir(FsContext *ctx,
 fs->dir = NULL;
 fd = v9fs_request(ctx->private, T_OPEN, NULL, "sd", fs_path, O_DIRECTORY);
 if (fd < 0) {
-errno = -fd;
 return -1;
 }
 fs->dir = fdopendir(fd);
@@ -732,9 +726,6 @@ static int proxy_chmod(FsContext *fs_ctx, V9fsPath 
*fs_path, FsCred *credp)
 int retval;
 retval = v9fs_request(fs_ctx->private, T_CHMOD, NULL, "sd",
   fs_path, credp->fc_mode);
-if (retval < 0) {
-errno = -retval;
-}
 return retval;
 }
 
@@ -751,10 +742,6 @@ static int proxy_mknod(FsContext *fs_ctx, V9fsPath 
*dir_path,
   &fullname, credp->fc_mode, credp->fc_rdev,
   credp->fc_uid, credp->fc_gid);
 v9fs_string_free(&fullname);
-if (retval < 0) {
-errno = -retval;
-retval = -1;
-}
 return retval;
 }
 
@@ -770,11 +757,6 @@ static int proxy_mkdir(FsContext *fs_ctx, V9fsPath 
*dir_path,
 retval = v9fs_request(fs_ctx->private, T_MKDIR, NULL, "sddd", &fullname,
   credp->fc_mode, credp->fc_uid, credp->fc_gid);
 v9fs_string_free(&fullname);
-if (retval < 0) {
-errno = -retval;
-retval = -1;
-}
-v9fs_string_free(&fullname);
 return retval;
 }
 
@@ -803,10 +785,6 @@ static int proxy_open2(FsContext *fs_ctx, V9fsPath 
*dir_path, const char *name,
   &fullname, flags, credp->fc_mode,
   credp->fc_uid, credp->fc_gid);
 v9fs_string_free(&fullname);
-if (fs->fd < 0) {
-errno = -fs->fd;
-fs->fd = -1;
-}
 return fs->fd;
 }
 
@@ -826,10 +804,6 @@ static int proxy_symlink(FsContext *fs_ctx, const char 
*oldpath,
   &target, &fullname, credp->fc_uid, credp->fc_gid);
 v9fs_string_free(&fullname);
 v9fs_string_free(&target);
-if (retval < 0) {
-errno = -retval;
-retval = -1;
-}
 return retval;
 }
 
@@ -844,20 +818,14 @@ static int proxy_link(FsContext *ctx, V9fsPath *oldpath,
 
 retval = v9fs_request(ctx->private, T_LINK, NULL, "ss", oldpath, &newpath);
 v9fs_string_free(&newpath);
-if (retval < 0) {
-errno = -retval;
-retval = -1;
-}
 return retval;
 }
 
 static int proxy_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size)
 {
 int retval;
-
 retval = v9fs_request(ctx->private, T_TRUNCATE, NULL, "sq", fs_path, size);
 if (retval < 0) {
-errno = -retval;
 return -1;
 }
 return 0;
@@ -878,9 +846,6 @@ static int proxy_rename(FsContext *ctx, const char *oldpath,
   &oldname, &newname);
 v9fs_string_free(&oldname);
 v9fs_string_free(&newname);
-if (retval < 0) {
-errno = -retval;
-}
 return retval;
 }
 
@@ -889,9 +854,6 @@ static int proxy_chown(FsContext *fs_ctx, V9fsPath 
*fs_path, FsCred *credp)
 int retval;
 retval = v9fs_request(fs_ctx->private, T_CHOWN, NULL, "sdd",
 

[Qemu-devel] [PATCH 10/51] qmp-commands.hx: Fix several typos

2015-03-06 Thread Michael Tokarev
From: Alberto Garcia 

Signed-off-by: Alberto Garcia 
Reviewed-by: Eric Blake 
Signed-off-by: Michael Tokarev 
---
 qmp-commands.hx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qmp-commands.hx b/qmp-commands.hx
index a85d847..c12334a 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1,5 +1,5 @@
 HXCOMM QMP dispatch table and documentation
-HXCOMM Text between SQMP and EQMP is copied to the QMP documention file and
+HXCOMM Text between SQMP and EQMP is copied to the QMP documentation file and
 HXCOMM does not show up in the other formats.
 
 SQMP
@@ -1767,7 +1767,7 @@ Arguments:
 
 - "protocol": protocol name (json-string)
 - "password": password (json-string)
-- "connected": [ keep | disconnect | fail ] (josn-string, optional)
+- "connected": [ keep | disconnect | fail ] (json-string, optional)
 
 Example:
 
@@ -2922,7 +2922,7 @@ Channels are described by a json-object, each one contain 
the following:
 - "channel-id": channel id.  Usually "0", might be different needed when
 multiple channels of the same type exist, such as multiple
 display channels in a multihead setup (json-int)
-- "tls": whevener the channel is encrypted (json-bool)
+- "tls": whether the channel is encrypted (json-bool)
 
 Example:
 
-- 
2.1.4




[Qemu-devel] [PATCH 47/51] 9pfs-proxy: simplify error handling

2015-03-06 Thread Michael Tokarev
All filesystem methods that call common v9fs_request() function
also convert return value to errno.  Move this conversion to the
common function and remove redundand error handling in methods.

I didn't remove local `retval' variable in simple functions to
keep the code consistent.

Also, proxy_truncate() seem to prefer zero successful return
instead of returning whatever the helper returned, maybe this
should be changed.

This also removes (harmless) double call to v9fs_string_free()
in proxy_mkdir().

Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 74 ---
 1 file changed, 5 insertions(+), 69 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index f252fe4..bd764be 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -590,6 +590,10 @@ close_error:
 
 out:
 qemu_mutex_unlock(&proxy->mutex);
+if (retval < 0) {
+errno = -retval;
+retval = -1;
+}
 return retval;
 }
 
@@ -597,10 +601,6 @@ static int proxy_lstat(FsContext *fs_ctx, V9fsPath 
*fs_path, struct stat *stbuf)
 {
 int retval;
 retval = v9fs_request(fs_ctx->private, T_LSTAT, stbuf, "s", fs_path);
-if (retval < 0) {
-errno = -retval;
-return -1;
-}
 return retval;
 }
 
@@ -611,7 +611,6 @@ static ssize_t proxy_readlink(FsContext *fs_ctx, V9fsPath 
*fs_path,
 retval = v9fs_request(fs_ctx->private, T_READLINK, buf, "sd",
   fs_path, bufsz);
 if (retval < 0) {
-errno = -retval;
 return -1;
 }
 return strlen(buf);
@@ -631,10 +630,6 @@ static int proxy_open(FsContext *ctx, V9fsPath *fs_path,
   int flags, V9fsFidOpenState *fs)
 {
 fs->fd = v9fs_request(ctx->private, T_OPEN, NULL, "sd", fs_path, flags);
-if (fs->fd < 0) {
-errno = -fs->fd;
-fs->fd = -1;
-}
 return fs->fd;
 }
 
@@ -646,7 +641,6 @@ static int proxy_opendir(FsContext *ctx,
 fs->dir = NULL;
 fd = v9fs_request(ctx->private, T_OPEN, NULL, "sd", fs_path, O_DIRECTORY);
 if (fd < 0) {
-errno = -fd;
 return -1;
 }
 fs->dir = fdopendir(fd);
@@ -732,9 +726,6 @@ static int proxy_chmod(FsContext *fs_ctx, V9fsPath 
*fs_path, FsCred *credp)
 int retval;
 retval = v9fs_request(fs_ctx->private, T_CHMOD, NULL, "sd",
   fs_path, credp->fc_mode);
-if (retval < 0) {
-errno = -retval;
-}
 return retval;
 }
 
@@ -751,10 +742,6 @@ static int proxy_mknod(FsContext *fs_ctx, V9fsPath 
*dir_path,
   &fullname, credp->fc_mode, credp->fc_rdev,
   credp->fc_uid, credp->fc_gid);
 v9fs_string_free(&fullname);
-if (retval < 0) {
-errno = -retval;
-retval = -1;
-}
 return retval;
 }
 
@@ -770,11 +757,6 @@ static int proxy_mkdir(FsContext *fs_ctx, V9fsPath 
*dir_path,
 retval = v9fs_request(fs_ctx->private, T_MKDIR, NULL, "sddd", &fullname,
   credp->fc_mode, credp->fc_uid, credp->fc_gid);
 v9fs_string_free(&fullname);
-if (retval < 0) {
-errno = -retval;
-retval = -1;
-}
-v9fs_string_free(&fullname);
 return retval;
 }
 
@@ -803,10 +785,6 @@ static int proxy_open2(FsContext *fs_ctx, V9fsPath 
*dir_path, const char *name,
   &fullname, flags, credp->fc_mode,
   credp->fc_uid, credp->fc_gid);
 v9fs_string_free(&fullname);
-if (fs->fd < 0) {
-errno = -fs->fd;
-fs->fd = -1;
-}
 return fs->fd;
 }
 
@@ -826,10 +804,6 @@ static int proxy_symlink(FsContext *fs_ctx, const char 
*oldpath,
   &target, &fullname, credp->fc_uid, credp->fc_gid);
 v9fs_string_free(&fullname);
 v9fs_string_free(&target);
-if (retval < 0) {
-errno = -retval;
-retval = -1;
-}
 return retval;
 }
 
@@ -844,20 +818,14 @@ static int proxy_link(FsContext *ctx, V9fsPath *oldpath,
 
 retval = v9fs_request(ctx->private, T_LINK, NULL, "ss", oldpath, &newpath);
 v9fs_string_free(&newpath);
-if (retval < 0) {
-errno = -retval;
-retval = -1;
-}
 return retval;
 }
 
 static int proxy_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size)
 {
 int retval;
-
 retval = v9fs_request(ctx->private, T_TRUNCATE, NULL, "sq", fs_path, size);
 if (retval < 0) {
-errno = -retval;
 return -1;
 }
 return 0;
@@ -878,9 +846,6 @@ static int proxy_rename(FsContext *ctx, const char *oldpath,
   &oldname, &newname);
 v9fs_string_free(&oldname);
 v9fs_string_free(&newname);
-if (retval < 0) {
-errno = -retval;
-}
 return retval;
 }
 
@@ -889,9 +854,6 @@ static int proxy_chown(FsContext *fs_ctx, V9fsPath 
*fs_path, FsCred *credp)
 int retval;
 retval = v9fs_request(fs_ctx->private, T_CHOWN, NULL, "sdd",
 

[Qemu-devel] [PATCH 20/51] arm/digic_boards: Remove superfluous '\n' around error_report()

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 hw/arm/digic_boards.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
index 2a4b872..7114c36 100644
--- a/hw/arm/digic_boards.c
+++ b/hw/arm/digic_boards.c
@@ -65,7 +65,7 @@ static void digic4_board_init(DigicBoard *board)
 s->digic = DIGIC(object_new(TYPE_DIGIC));
 object_property_set_bool(OBJECT(s->digic), true, "realized", &err);
 if (err != NULL) {
-error_report("Couldn't realize DIGIC SoC: %s\n",
+error_report("Couldn't realize DIGIC SoC: %s",
  error_get_pretty(err));
 exit(1);
 }
@@ -104,13 +104,13 @@ static void digic_load_rom(DigicBoardState *s, hwaddr 
addr,
 char *fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, filename);
 
 if (!fn) {
-error_report("Couldn't find rom image '%s'.\n", filename);
+error_report("Couldn't find rom image '%s'.", filename);
 exit(1);
 }
 
 rom_size = load_image_targphys(fn, addr, max_size);
 if (rom_size < 0 || rom_size > max_size) {
-error_report("Couldn't load rom image '%s'.\n", filename);
+error_report("Couldn't load rom image '%s'.", filename);
 exit(1);
 }
 }
-- 
2.1.4




Re: [Qemu-devel] [PATCH v2 0/6] rfc: 9pfs-proxy simplification/cleanup

2015-03-06 Thread Michael Tokarev
I forgot to clean up the temp dir so the result is a
hmessy mix of 2 patchsets, one from trivial patches and
another this 9pfs code (actually it was me executing
git-format-patch twice in a row, once with a wrong
starting point and next with corrected starting point).

I'm sorry for this.  Somehow my handling of patches
become quite a bit messy recently.  I'll try to make
it to work better.

I'll resend the patchset later after doing some more
code changes and patch merging.

And oh well, it all started from a tiny cleanup patch
by Gonglei... ;)

Thanks,

/mjt



Re: [Qemu-devel] [PATCH v4 2/5] target-i386: Remove unused APIC ID default code

2015-03-06 Thread Eduardo Habkost
On Thu, Mar 05, 2015 at 03:46:13PM -0300, Eduardo Habkost wrote:
> On Thu, Mar 05, 2015 at 07:35:17PM +0100, Andreas Färber wrote:
> > Am 05.03.2015 um 14:43 schrieb Eduardo Habkost:
> > > On Tue, Mar 03, 2015 at 11:13:41PM -0300, Eduardo Habkost wrote:
> > >> The existing apic_id = cpu_index code has no visible effect: the PC code
> > >> already initializes the APIC ID according to the topology on
> > >> pc_new_cpu(), and linux-user memcpy()s the CPU state (including
> > >> cpuid_apic_id) on cpu_copy().
> > >>
> > >> Remove the dead code and simply let APIC ID to to be 0 by default. This
> > >> doesn't change behavior of PC because apic-id is already explicitly set,
> > >> and doesn't affect linux-user because APIC ID was already always 0.
> > >>
> > >> Signed-off-by: Eduardo Habkost 
> > > 
> > > This patch is holding the rest of the series, so a Reviewed-by or
> > > Acked-by would be welcome.
> > > 
> > > This change removes the 254-CPU limit from {i386,x86_64}-linux-user that
> > > Peter and I discussed previously.
> > 
> > Reviewed-by: Andreas Färber 
> > 
> > Are you going to send a new pull for the 2 plus these 5 now?
> 
> Yes. I plan to send a pull request tomorrow.
> 
> (If we get reviews in time, the pull request may include the
> instance_init series as well)

I just learned from another thread that Peter will be back to work on
March 10th, so I will submit the pull request on Monday.

-- 
Eduardo



[Qemu-devel] [PATCH 16/51] vhost-scsi: Remove superfluous '\n' around error_report()

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 hw/scsi/vhost-scsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 618b0af..335f442 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -83,7 +83,7 @@ static int vhost_scsi_start(VHostSCSI *s)
 if (abi_version > VHOST_SCSI_ABI_VERSION) {
 error_report("vhost-scsi: The running tcm_vhost kernel abi_version:"
  " %d is greater than vhost_scsi userspace supports: %d, 
please"
- " upgrade your version of QEMU\n", abi_version,
+ " upgrade your version of QEMU", abi_version,
  VHOST_SCSI_ABI_VERSION);
 return -ENOSYS;
 }
@@ -141,7 +141,7 @@ static void vhost_scsi_stop(VHostSCSI *s)
 if (k->set_guest_notifiers) {
 ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
 if (ret < 0) {
-error_report("vhost guest notifier cleanup failed: %d\n", ret);
+error_report("vhost guest notifier cleanup failed: %d", ret);
 }
 }
 assert(ret >= 0);
@@ -186,7 +186,7 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, 
uint8_t val)
 
 ret = vhost_scsi_start(s);
 if (ret < 0) {
-error_report("virtio-scsi: unable to start vhost: %s\n",
+error_report("virtio-scsi: unable to start vhost: %s",
  strerror(-ret));
 
 /* There is no userspace virtio-scsi fallback so exit */
-- 
2.1.4




[Qemu-devel] [PATCH 30/51] macio: fix possible memory leak

2015-03-06 Thread Michael Tokarev
From: Gonglei 

If ret = macio_initfn_ide() is less than 0, the timer_memory
will leak the memory it points to.

Signed-off-by: Gonglei 
Signed-off-by: Michael Tokarev 
---
 hw/misc/macio/macio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index e0f1e88..bf96844 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -273,7 +273,7 @@ static int macio_newworld_initfn(PCIDevice *d)
 MacIOState *s = MACIO(d);
 NewWorldMacIOState *ns = NEWWORLD_MACIO(d);
 SysBusDevice *sysbus_dev;
-MemoryRegion *timer_memory = g_new(MemoryRegion, 1);
+MemoryRegion *timer_memory = NULL;
 int i;
 int cur_irq = 0;
 int ret = macio_common_initfn(d);
@@ -301,6 +301,7 @@ static int macio_newworld_initfn(PCIDevice *d)
 }
 
 /* Timer */
+timer_memory = g_new(MemoryRegion, 1);
 memory_region_init_io(timer_memory, OBJECT(s), &timer_ops, NULL, "timer",
   0x1000);
 memory_region_add_subregion(&s->bar, 0x15000, timer_memory);
-- 
2.1.4




[Qemu-devel] [PATCH 3/6] 9pfs-proxy: rename a few local variables for consistency

2015-03-06 Thread Michael Tokarev
All functions which deal with v9fs_request() use `retval'
variable to hold result of the request (except some which
use this value for other purposes too), but 3 use different
name (ret or err).  Rename these 3 for consistency.
There's no actual code changes.

Signed-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index bd764be..c187d31 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -980,7 +980,7 @@ static int proxy_renameat(FsContext *ctx, V9fsPath *olddir,
   const char *old_name, V9fsPath *newdir,
   const char *new_name)
 {
-int ret;
+int retval;
 V9fsString old_full_name, new_full_name;
 
 v9fs_string_init(&old_full_name);
@@ -989,30 +989,30 @@ static int proxy_renameat(FsContext *ctx, V9fsPath 
*olddir,
 v9fs_string_sprintf(&old_full_name, "%s/%s", olddir->data, old_name);
 v9fs_string_sprintf(&new_full_name, "%s/%s", newdir->data, new_name);
 
-ret = proxy_rename(ctx, old_full_name.data, new_full_name.data);
+retval = proxy_rename(ctx, old_full_name.data, new_full_name.data);
 v9fs_string_free(&old_full_name);
 v9fs_string_free(&new_full_name);
-return ret;
+return retval;
 }
 
 static int proxy_unlinkat(FsContext *ctx, V9fsPath *dir,
   const char *name, int flags)
 {
-int ret;
+int retval;
 V9fsString fullname;
 v9fs_string_init(&fullname);
 
 v9fs_string_sprintf(&fullname, "%s/%s", dir->data, name);
-ret = proxy_remove(ctx, fullname.data);
+retval = proxy_remove(ctx, fullname.data);
 v9fs_string_free(&fullname);
 
-return ret;
+return retval;
 }
 
 static int proxy_ioc_getversion(FsContext *fs_ctx, V9fsPath *path,
 mode_t st_mode, uint64_t *st_gen)
 {
-int err;
+int retval;
 
 /* Do not try to open special files like device nodes, fifos etc
  * we can get fd for regular files and directories only
@@ -1021,8 +1021,8 @@ static int proxy_ioc_getversion(FsContext *fs_ctx, 
V9fsPath *path,
 errno = ENOTTY;
 return -1;
 }
-err = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, "s", path);
-return err;
+retval = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, "s", path);
+return retval;
 }
 
 static int connect_namedsocket(const char *path)
-- 
2.1.4




[Qemu-devel] [PATCH 33/51] gitignore: Track common.env in iotests gitignore

2015-03-06 Thread Michael Tokarev
From: Cole Robinson 

Rather than track it in the toplevel gitignore

Signed-off-by: Cole Robinson 
Signed-off-by: Michael Tokarev 
---
 .gitignore| 1 -
 tests/qemu-iotests/.gitignore | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 090f974..e32a584 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,4 +109,3 @@ cscope.*
 tags
 TAGS
 *~
-/tests/qemu-iotests/common.env
diff --git a/tests/qemu-iotests/.gitignore b/tests/qemu-iotests/.gitignore
index 0541f80..0711cbd 100644
--- a/tests/qemu-iotests/.gitignore
+++ b/tests/qemu-iotests/.gitignore
@@ -1,5 +1,6 @@
 check.log
 check.time
+common.env
 *.out.bad
 *.notrun
 socket_scm_helper
-- 
2.1.4




[Qemu-devel] [PATCH 37/51] disas/arm: Fix warnings caused by missing 'static' attribute

2015-03-06 Thread Michael Tokarev
From: Stefan Weil 

Warnings from the Sparse static analysis tool:

disas/arm.c:1552:15: warning:
 symbol 'last_type' was not declared. Should it be static?
disas/arm.c:1553:5: warning:
 symbol 'last_mapping_sym' was not declared. Should it be static?
disas/arm.c:1554:9: warning:
 symbol 'last_mapping_addr' was not declared. Should it be static?

Instead of adding 'static', the unused variables and the unused code which
refers to those variables (which was deactivated a long time ago in
commit 4b0f1a8b) are removed.

Signed-off-by: Stefan Weil 
Signed-off-by: Michael Tokarev 
---
 disas/arm.c | 128 
 1 file changed, 128 deletions(-)

diff --git a/disas/arm.c b/disas/arm.c
index 76e97a8..6165246 100644
--- a/disas/arm.c
+++ b/disas/arm.c
@@ -1549,10 +1549,6 @@ enum map_type {
   MAP_DATA
 };
 
-enum map_type last_type;
-int last_mapping_sym = -1;
-bfd_vma last_mapping_addr = 0;
-
 /* Decode a bitfield of the form matching regexp (N(-N)?,)*N(-N)?.
Returns pointer to following character of the format string and
fills in *VALUEP and *WIDTHP with the extracted value and number of
@@ -3878,135 +3874,11 @@ print_insn_arm (bfd_vma pc, struct disassemble_info 
*info)
   int   is_data = false;
   unsigned int size = 4;
   void (*printer) (bfd_vma, struct disassemble_info *, long);
-#if 0
-  bfd_boolean   found = false;
-
-  if (info->disassembler_options)
-{
-  parse_disassembler_options (info->disassembler_options);
-
-  /* To avoid repeated parsing of these options, we remove them here.  */
-  info->disassembler_options = NULL;
-}
-
-  /* First check the full symtab for a mapping symbol, even if there
- are no usable non-mapping symbols for this address.  */
-  if (info->symtab != NULL
-  && bfd_asymbol_flavour (*info->symtab) == bfd_target_elf_flavour)
-{
-  bfd_vma addr;
-  int n;
-  int last_sym = -1;
-  enum map_type type = MAP_ARM;
-
-  if (pc <= last_mapping_addr)
-   last_mapping_sym = -1;
-  is_thumb = (last_type == MAP_THUMB);
-  found = false;
-  /* Start scanning at the start of the function, or wherever
-we finished last time.  */
-  n = info->symtab_pos + 1;
-  if (n < last_mapping_sym)
-   n = last_mapping_sym;
-
-  /* Scan up to the location being disassembled.  */
-  for (; n < info->symtab_size; n++)
-   {
- addr = bfd_asymbol_value (info->symtab[n]);
- if (addr > pc)
-   break;
- if ((info->section == NULL
-  || info->section == info->symtab[n]->section)
- && get_sym_code_type (info, n, &type))
-   {
- last_sym = n;
- found = true;
-   }
-   }
-
-  if (!found)
-   {
- n = info->symtab_pos;
- if (n < last_mapping_sym - 1)
-   n = last_mapping_sym - 1;
-
- /* No mapping symbol found at this address.  Look backwards
-for a preceding one.  */
- for (; n >= 0; n--)
-   {
- if (get_sym_code_type (info, n, &type))
-   {
- last_sym = n;
- found = true;
- break;
-   }
-   }
-   }
-
-  last_mapping_sym = last_sym;
-  last_type = type;
-  is_thumb = (last_type == MAP_THUMB);
-  is_data = (last_type == MAP_DATA);
-
-  /* Look a little bit ahead to see if we should print out
-two or four bytes of data.  If there's a symbol,
-mapping or otherwise, after two bytes then don't
-print more.  */
-  if (is_data)
-   {
- size = 4 - (pc & 3);
- for (n = last_sym + 1; n < info->symtab_size; n++)
-   {
- addr = bfd_asymbol_value (info->symtab[n]);
- if (addr > pc)
-   {
- if (addr - pc < size)
-   size = addr - pc;
- break;
-   }
-   }
- /* If the next symbol is after three bytes, we need to
-print only part of the data, so that we can use either
-.byte or .short.  */
- if (size == 3)
-   size = (pc & 1) ? 1 : 2;
-   }
-}
-
-  if (info->symbols != NULL)
-{
-  if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour)
-   {
- coff_symbol_type * cs;
-
- cs = coffsymbol (*info->symbols);
- is_thumb = (   cs->native->u.syment.n_sclass == C_THUMBEXT
- || cs->native->u.syment.n_sclass == C_THUMBSTAT
- || cs->native->u.syment.n_sclass == C_THUMBLABEL
- || cs->native->u.syment.n_sclass == C_THUMBEXTFUNC
- || cs->native->u.syment.n_sclass == C_THUMBSTATFUNC);
-   }
-  else if (bfd_asymbol_flavour (*info->symbols) == bfd_target_elf_flavour
-  && !found)
-   {
- /* If no mapping symbol has been found then

[Qemu-devel] [PATCH 28/51] nbd: fix resource leak

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Signed-off-by: Michael Tokarev 
---
 block/nbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/nbd.c b/block/nbd.c
index 697c021..6634a69 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -274,6 +274,7 @@ static int nbd_open(BlockDriverState *bs, QDict *options, 
int flags,
  */
 sock = nbd_establish_connection(bs, errp);
 if (sock < 0) {
+g_free(export);
 return sock;
 }
 
-- 
2.1.4




[Qemu-devel] [PATCH 15/51] Remove superfluous '\n' around error_report()

2015-03-06 Thread Michael Tokarev
From: Gonglei 

Signed-off-by: Gonglei 
Reviewed-by: Markus Armbruster 
Signed-off-by: Michael Tokarev 
---
 exec.c   | 2 +-
 hw/ide/pci.c | 2 +-
 hw/microblaze/boot.c | 2 +-
 migration/rdma.c | 2 +-
 target-s390x/kvm.c   | 2 +-
 trace/control.c  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/exec.c b/exec.c
index c85321a..ebee8cc 100644
--- a/exec.c
+++ b/exec.c
@@ -1188,7 +1188,7 @@ static void *file_ram_alloc(RAMBlock *block,
 
 error:
 if (mem_prealloc) {
-error_report("%s\n", error_get_pretty(*errp));
+error_report("%s", error_get_pretty(*errp));
 exit(1);
 }
 return NULL;
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index e3f2054..913a976 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -99,7 +99,7 @@ static int32_t bmdma_prepare_buf(IDEDMA *dma, int is_write)
  * This should accommodate the largest ATA transaction
  * for LBA48 (65,536 sectors) and 32K sector sizes. */
 if (s->sg.size > INT32_MAX) {
-error_report("IDE: sglist describes more than 2GiB.\n");
+error_report("IDE: sglist describes more than 2GiB.");
 break;
 }
 bm->cur_prd_addr += l;
diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index a2843cd..38c59db 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -185,7 +185,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr 
ddr_base,
   ram_size - initrd_offset);
 }
 if (initrd_size < 0) {
-error_report("qemu: could not load initrd '%s'\n",
+error_report("qemu: could not load initrd '%s'",
  initrd_filename);
 exit(EXIT_FAILURE);
 }
diff --git a/migration/rdma.c b/migration/rdma.c
index 6bee30c..1989f61 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -1627,7 +1627,7 @@ static int qemu_rdma_exchange_get_response(RDMAContext 
*rdma,
 return -EIO;
 }
 if (head->len > RDMA_CONTROL_MAX_BUFFER - sizeof(*head)) {
-error_report("too long length: %d\n", head->len);
+error_report("too long length: %d", head->len);
 return -EINVAL;
 }
 if (sizeof(*head) + head->len != byte_len) {
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index d7c57d9..508cc0a 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -211,7 +211,7 @@ void kvm_s390_reset_vcpu(S390CPU *cpu)
  * Before this ioctl cpu_synchronize_state() is called in common kvm
  * code (kvm-all) */
 if (kvm_vcpu_ioctl(cs, KVM_S390_INITIAL_RESET, NULL)) {
-error_report("Initial CPU reset failed on CPU %i\n", cs->cpu_index);
+error_report("Initial CPU reset failed on CPU %i", cs->cpu_index);
 }
 }
 
diff --git a/trace/control.c b/trace/control.c
index 0d30801..995beb3 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -126,7 +126,7 @@ static void trace_init_events(const char *fname)
 error_report("WARNING: trace event '%s' does not exist",
  line_ptr);
 } else if (!trace_event_get_state_static(ev)) {
-error_report("WARNING: trace event '%s' is not 
traceable\n",
+error_report("WARNING: trace event '%s' is not traceable",
  line_ptr);
 } else {
 trace_event_set_state_dynamic(ev, enable);
-- 
2.1.4




[Qemu-devel] [PATCH 1/6] 9pfs-proxy: simplify v9fs_request() a bit

2015-03-06 Thread Michael Tokarev
This simplifies code in v9fs_request() a bit by replacing several
ifs with a common variable check and rearranging error/cleanup
code a bit.

Signet-off-by: Michael Tokarev 
---
 hw/9pfs/virtio-9p-proxy.c | 48 ---
 1 file changed, 20 insertions(+), 28 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 59c7445..f252fe4 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -299,7 +299,7 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 dev_t rdev;
 va_list ap;
 int size = 0;
-int retval = 0;
+int retval = 0, err;
 uint64_t offset;
 ProxyHeader header = { 0, 0};
 struct timespec spec[2];
@@ -310,10 +310,11 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 
 qemu_mutex_lock(&proxy->mutex);
 
-if (proxy->sockfd == -1) {
+if (proxy->sockfd < 0) {
 retval = -EIO;
-goto err_out;
+goto out;
 }
+
 iovec = &proxy->out_iovec;
 reply = &proxy->in_iovec;
 va_start(ap, fmt);
@@ -529,15 +530,15 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 va_end(ap);
 
 if (retval < 0) {
-goto err_out;
+goto out;
 }
 
 /* marshal the header details */
 proxy_marshal(iovec, 0, "dd", header.type, header.size);
 header.size += PROXY_HDR_SZ;
 
-retval = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
-if (retval != header.size) {
+err = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
+if (err != header.size) {
 goto close_error;
 }
 
@@ -548,9 +549,7 @@ static int v9fs_request(V9fsProxy *proxy, int type,
  * A file descriptor is returned as response for
  * T_OPEN,T_CREATE on success
  */
-if (v9fs_receivefd(proxy->sockfd, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receivefd(proxy->sockfd, &retval);
 break;
 case T_MKNOD:
 case T_MKDIR:
@@ -564,41 +563,34 @@ static int v9fs_request(V9fsProxy *proxy, int type,
 case T_REMOVE:
 case T_LSETXATTR:
 case T_LREMOVEXATTR:
-if (v9fs_receive_status(proxy, reply, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receive_status(proxy, reply, &retval);
 break;
 case T_LSTAT:
 case T_READLINK:
 case T_STATFS:
 case T_GETVERSION:
-if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
-goto close_error;
-}
+err = v9fs_receive_response(proxy, type, &retval, response);
 break;
 case T_LGETXATTR:
 case T_LLISTXATTR:
 if (!size) {
-if (v9fs_receive_status(proxy, reply, &retval) < 0) {
-goto close_error;
-}
+err = v9fs_receive_status(proxy, reply, &retval);
 } else {
-if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
-goto close_error;
-}
+err = v9fs_receive_response(proxy, type, &retval, response);
 }
 break;
 }
 
-err_out:
-qemu_mutex_unlock(&proxy->mutex);
-return retval;
-
+if (err < 0) {
 close_error:
-close(proxy->sockfd);
-proxy->sockfd = -1;
+close(proxy->sockfd);
+proxy->sockfd = -1;
+retval = -EIO;
+}
+
+out:
 qemu_mutex_unlock(&proxy->mutex);
-return -EIO;
+return retval;
 }
 
 static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat 
*stbuf)
-- 
2.1.4




[Qemu-devel] [PATCH 38/51] disas/cris: Fix warning caused by missing 'static' attribute

2015-03-06 Thread Michael Tokarev
From: Stefan Weil 

Warning from the Sparse static analysis tool:

disas/cris.c:1218:26: warning:
 symbol 'cris_cond15s' was not declared. Should it be static?

Signed-off-by: Stefan Weil 
Signed-off-by: Michael Tokarev 
---
 disas/cris.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/disas/cris.c b/disas/cris.c
index 9dfb4e3..a034dba 100644
--- a/disas/cris.c
+++ b/disas/cris.c
@@ -1215,7 +1215,7 @@ cris_cc_strings[] =
 };
 
 /* Different names and semantics for condition  (0xf).  */
-const struct cris_cond15 cris_cond15s[] =
+static const struct cris_cond15 cris_cond15s[] =
 {
   /* FIXME: In what version did condition "ext" disappear?  */
   {"ext", cris_ver_v0_3},
-- 
2.1.4




[Qemu-devel] [PATCH v2 0/6] rfc: 9pfs-proxy simplification/cleanup

2015-03-06 Thread Michael Tokarev
9pfs-proxy code is terrible.  Not only it does lots of memory
allocations for every filesystem operation, the code is also
badly written.

For example, all filesystem operation methods call a common
function, v9fs_request(), and passes all info about method
arguments, including argument types, to it.  However, the
common v9fs_request() function has a switch(filesystem method),
unpacks method arguments from the argument stack, and re-
request marshalling with a new list of argument types,
ignoring what the individual method handler passed to it.

When receiving a response, this common function has another
per-filesystem-method switch which, in some cases, calls
v9fs_read_response(), which also has the same per-method
switch.

As a result, processing of each request is badly split
between several functions, and the whole thing is just
ugly.

Error handling is also of the same sort.  Common v9fs_request()
return -errno, and every filesystem method which calls it
stores result in errno, instead of letting the common
code to do that.  Error handling is inconsistent too,
some methods return -1 and some return -errno.

This is one small attempt to fix this all.  So far,
addressed is the error handling and arguments of
filesystem methods.

Note: I haven't actually tested this code, only compile-tested it.

Michael Tokarev (6):
  9pfs-proxy: simplify v9fs_request() a bit
  9pfs-proxy: simplify error handling
  9pfs-proxy: rename a few local variables for consistency
  fsdev: introduce v9fs_vmarshal() and v9fs_vunmarshal()
  9pfs-proxy: remove one half of redundrand code
  9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv

 fsdev/virtio-9p-marshal.c |  38 +++--
 fsdev/virtio-9p-marshal.h |   6 +
 hw/9pfs/virtio-9p-proxy.c | 411 +-
 3 files changed, 79 insertions(+), 376 deletions(-)

-- 
2.1.4




[Qemu-devel] [PATCH 24/51] xen: Remove xen_cmos_set_s3_resume()

2015-03-06 Thread Michael Tokarev
From: Thomas Huth 

The function is not used anymore, and thus can be deleted.

Signed-off-by: Thomas Huth 
Acked-by: Stefano Stabellini 
Signed-off-by: Michael Tokarev 
---
 include/hw/xen/xen.h | 1 -
 xen-hvm-stub.c   | 4 
 2 files changed, 5 deletions(-)

diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index b0ed04c..4356af4 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -32,7 +32,6 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data);
-void xen_cmos_set_s3_resume(void *opaque, int irq, int level);
 
 qemu_irq *xen_interrupt_controller_init(void);
 
diff --git a/xen-hvm-stub.c b/xen-hvm-stub.c
index 2d98696..46867d8 100644
--- a/xen-hvm-stub.c
+++ b/xen-hvm-stub.c
@@ -30,10 +30,6 @@ void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
 {
 }
 
-void xen_cmos_set_s3_resume(void *opaque, int irq, int level)
-{
-}
-
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr)
 {
 }
-- 
2.1.4




Re: [Qemu-devel] mfocrf missing on e500v2

2015-03-06 Thread Richard Henderson
On 03/06/2015 08:04 AM, Alexander Graf wrote:
> Hi Richard,
> 
> I've finally managed to check out why my e500v2 automated tests fail to
> run. Apparently they break because autotest wants to execute target code
> and runs into an illegal instruction while doing that:
> 
> Program received signal SIGILL, Illegal instruction.
> 0xb57c84cc in ?? ()
> (gdb) x /i $pc
> => 0xb57c84cc:mfocrf  r0,1
> 
> And lo and behold, I really couldn't find any reference to mfocrf in the
> e500v2 spec.
> 
> Is there any way to disable setcond2 for those chips?

No, not disable setcond2.

But the proper solution is to emit mfcrf (i.e. all of the cr regs, not "one" of
the cregs).  We'd want to check the processor we're running on, since
mfcrf is slower than mfocrf on modern hardware.  Can you see if there's a
bit in AT_HWCAP that covers this?


r~




[Qemu-devel] clang warnings too noisy

2015-03-06 Thread Stefan Hajnoczi
Hi Peter,
You are rejecting pull requests that produce warnings under clang.

clang 3.5.0 on Fedora 21 produces so much noise that it's extremely
tedious and error-prone to try finding relevant new warnings.

Are you using a different clang version which produces fewer warnings?

Is anyone working on making QEMU build cleanly under clang?  Under gcc
people regularly submit patches to keep the build clean (e.g. recent
gcc 5 fixes).

Currently I'm not happy wrangling with clang when very few people seem
to use it or care enough to make QEMU build cleanly.

Examples of noise produced by clang:

1. It complains about glib headers:
In file included from /home/stefanha/qemu/include/net/eth.h:32:
In file included from /home/stefanha/qemu/include/qemu/iov.h:17:
In file included from /home/stefanha/qemu/include/qemu-common.h:43:
In file included from /home/stefanha/qemu/include/glib-compat.h:19:
In file included from /usr/include/glib-2.0/glib.h:50:
In file included from /usr/include/glib-2.0/glib/ghash.h:33:
In file included from /usr/include/glib-2.0/glib/glist.h:32:
/usr/include/glib-2.0/glib/gmem.h:76:78: warning: unknown attribute
'__alloc_size__' ignored [-Wunknown-attributes]
gpointer g_malloc (gsize n_bytes) __attribute__((__malloc__))
__attribute__((__alloc_size__(1)));
 ^
/usr/include/glib-2.0/glib/gmem.h:78:79: warning: unknown attribute
'__alloc_size__' ignored [-Wunknown-attributes]

2. It complains about the 'return !strcmp(s, "?") || !strcmp(s,
"help")' in qemu-common.h:
/home/stefanha/qemu/include/qemu-common.h:150:1916: warning: array
index 3 is past the end of the array (which contains 2 elements)
[-Warray-bounds]
return !__extension__ ({ size_t __s1_len, __s2_len;
(__builtin_constant_p (s) && __builtin_constant_p ("?") && (__s1_len =
strlen (s), __s2_len = strlen ("?"), (!((size_t)(const void *)((s) +
1) - (size_t)(const void *)(s) == 1) || __s1_len >= 4) &&
(!((size_t)(const void *)(("?") + 1) - (size_t)(const void *)("?") ==
1) || __s2_len >= 4)) ? __builtin_strcmp (s, "?") :
(__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) -
(size_t)(const void *)(s) == 1) && (__s1_len = strlen (s), __s1_len <
4) ? (__builtin_constant_p ("?") && ((size_t)(const void *)(("?") + 1)
- (size_t)(const void *)("?") == 1) ? __builtin_strcmp (s, "?") : ...

3. It complains about unused -I paths:
clang: warning: argument unused during compilation: '-I /home/stefanha/qemu/tcg'
clang: warning: argument unused during compilation: '-I
/home/stefanha/qemu/tcg/i386'
clang: warning: argument unused during compilation: '-I
/home/stefanha/qemu/linux-headers'

Stefan



[Qemu-devel] [RFC PATCH 5/6] vga: flag vram as incoherent

2015-03-06 Thread Andrew Jones
Signed-off-by: Andrew Jones 
---
 hw/display/vga.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/display/vga.c b/hw/display/vga.c
index c8c49abc6e8ba..2b74eb8e96462 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2135,6 +2135,7 @@ void vga_common_init(VGACommonState *s, Object *obj, bool 
global_vmstate)
 s->is_vbe_vmstate = 1;
 memory_region_init_ram(&s->vram, obj, "vga.vram", s->vram_size,
&error_abort);
+memory_region_set_incoherent_cache(&s->vram);
 vmstate_register_ram(&s->vram, global_vmstate ? NULL : DEVICE(obj));
 xen_register_framebuffer(&s->vram);
 s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 4/6] kvm-all: set KVM_MEM_INCOHERENT

2015-03-06 Thread Andrew Jones
Signed-off-by: Andrew Jones 
---
 kvm-all.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kvm-all.c b/kvm-all.c
index 507fa7204e062..924b4a0bec21c 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -305,6 +305,9 @@ static int kvm_mem_flags(MemoryRegion *mr)
 if (readonly && kvm_readonly_mem_allowed) {
 flags |= KVM_MEM_READONLY;
 }
+if (memory_region_has_incoherent_cache(mr)) {
+flags |= KVM_MEM_INCOHERENT;
+}
 return flags;
 }
 
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 1/6] memory: add incoherent cache flag

2015-03-06 Thread Andrew Jones
Add an incoherent cache flag, which indicates the region
needs explicit cache maintenance.

Signed-off-by: Andrew Jones 
---
 include/exec/memory.h | 23 +++
 memory.c  | 15 +++
 2 files changed, 38 insertions(+)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 06ffa1d185b93..c947b88b87241 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -158,6 +158,7 @@ struct MemoryRegion {
 bool rom_device;
 bool warning_printed; /* For reservations */
 bool flush_coalesced_mmio;
+bool incoherent_cache;
 MemoryRegion *alias;
 hwaddr alias_offset;
 int32_t priority;
@@ -778,6 +779,28 @@ void memory_region_set_flush_coalesced(MemoryRegion *mr);
 void memory_region_clear_flush_coalesced(MemoryRegion *mr);
 
 /**
+ * memory_region_set_incoherent_cache: Flag this memory region as needing
+ * explicit cache maintenance.
+ *
+ * @mr: the memory region to be updated.
+ */
+void memory_region_set_incoherent_cache(MemoryRegion *mr);
+
+/**
+ * memory_region_clear_incoherent_cache: Remove the incoherent cache flag.
+ *
+ * @mr: the memory region to be updated.
+ */
+void memory_region_clear_incoherent_cache(MemoryRegion *mr);
+
+/**
+ * memory_region_has_incoherent_cache: Return the incoherent cache flag.
+ *
+ * @mr: the memory region to check.
+ */
+bool memory_region_has_incoherent_cache(MemoryRegion *mr);
+
+/**
  * memory_region_add_eventfd: Request an eventfd to be triggered when a word
  *is written to a location.
  *
diff --git a/memory.c b/memory.c
index 20f6d9eeac737..fa74bcb8c1e4c 100644
--- a/memory.c
+++ b/memory.c
@@ -1549,6 +1549,21 @@ void memory_region_clear_flush_coalesced(MemoryRegion 
*mr)
 }
 }
 
+void memory_region_set_incoherent_cache(MemoryRegion *mr)
+{
+mr->incoherent_cache = true;
+}
+
+void memory_region_clear_incoherent_cache(MemoryRegion *mr)
+{
+mr->incoherent_cache = false;
+}
+
+bool memory_region_has_incoherent_cache(MemoryRegion *mr)
+{
+return mr->incoherent_cache;
+}
+
 void memory_region_add_eventfd(MemoryRegion *mr,
hwaddr addr,
unsigned size,
-- 
1.8.3.1




[Qemu-devel] [RFC/WIP PATCH 6/6] memory: add clear_cache_to_poc

2015-03-06 Thread Andrew Jones
Add a function that flushes the cache to PoC. We need a new
function because __builtin___clear_cache only flushes to
PoU. Call this function each time an address in a memory
region that has been flagged as having an incoherent cache
is written. For starters we only implement it for ARM. Most
other architectures don't need it anyway.

Signed-off-by: Andrew Jones 
---
Currently only implemented for aarch64, doesn't completely work yet.

 exec.c  | 16 ++--
 include/exec/exec-all.h | 41 +
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/exec.c b/exec.c
index c85321a38ba69..68268a5961ff5 100644
--- a/exec.c
+++ b/exec.c
@@ -2261,7 +2261,7 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
 
 #else
 
-static void invalidate_and_set_dirty(hwaddr addr,
+static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr,
  hwaddr length)
 {
 if (cpu_physical_memory_range_includes_clean(addr, length)) {
@@ -2269,6 +2269,10 @@ static void invalidate_and_set_dirty(hwaddr addr,
 cpu_physical_memory_set_dirty_range_nocode(addr, length);
 }
 xen_modified_memory(addr, length);
+if (memory_region_has_incoherent_cache(mr)) {
+char *start = qemu_get_ram_ptr(addr);
+clear_cache_to_poc(start, start + length);
+}
 }
 
 static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr)
@@ -2348,7 +2352,7 @@ bool address_space_rw(AddressSpace *as, hwaddr addr, 
uint8_t *buf,
 /* RAM case */
 ptr = qemu_get_ram_ptr(addr1);
 memcpy(ptr, buf, l);
-invalidate_and_set_dirty(addr1, l);
+invalidate_and_set_dirty(mr, addr1, l);
 }
 } else {
 if (!memory_access_is_direct(mr, is_write)) {
@@ -2437,7 +2441,7 @@ static inline void 
cpu_physical_memory_write_rom_internal(AddressSpace *as,
 switch (type) {
 case WRITE_DATA:
 memcpy(ptr, buf, l);
-invalidate_and_set_dirty(addr1, l);
+invalidate_and_set_dirty(mr, addr1, l);
 break;
 case FLUSH_CACHE:
 flush_icache_range((uintptr_t)ptr, (uintptr_t)ptr + l);
@@ -2622,7 +2626,7 @@ void address_space_unmap(AddressSpace *as, void *buffer, 
hwaddr len,
 mr = qemu_ram_addr_from_host(buffer, &addr1);
 assert(mr != NULL);
 if (is_write) {
-invalidate_and_set_dirty(addr1, access_len);
+invalidate_and_set_dirty(mr, addr1, access_len);
 }
 if (xen_enabled()) {
 xen_invalidate_map_cache_entry(buffer);
@@ -2904,7 +2908,7 @@ static inline void stl_phys_internal(AddressSpace *as,
 stl_p(ptr, val);
 break;
 }
-invalidate_and_set_dirty(addr1, 4);
+invalidate_and_set_dirty(mr, addr1, 4);
 }
 }
 
@@ -2967,7 +2971,7 @@ static inline void stw_phys_internal(AddressSpace *as,
 stw_p(ptr, val);
 break;
 }
-invalidate_and_set_dirty(addr1, 2);
+invalidate_and_set_dirty(mr, addr1, 2);
 }
 }
 
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 8eb0db3910e86..9bf74e791f357 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -106,6 +106,43 @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr,
   hwaddr paddr, int prot,
   int mmu_idx, target_ulong size);
 void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr);
+#if defined(__aarch64__)
+static inline void clear_cache_to_poc(char *begin, char *end)
+{
+/* Unfortunately __builtin___clear_cache only flushes
+ * to PoU, we need to implement this for PoC.
+ */
+static unsigned long line_sz = 0;
+unsigned long start, stop, addr;
+
+if (!line_sz) {
+unsigned int ctr_el0;
+asm volatile("mrs %0, ctr_el0" : "=&r" (ctr_el0));
+line_sz = (1UL << ((ctr_el0 >> 16) & 0xf)) * sizeof(int);
+}
+
+start = (unsigned long)begin & ~(line_sz - 1);
+stop = ((unsigned long)(end + line_sz) & ~(line_sz - 1));
+
+for (addr = start; addr < stop; addr += line_sz) {
+asm volatile("dc cvac, %0" : : "r" (addr));
+}
+
+/* FIXME: Ideally, we'd also flush the icache now, just in
+ * case this is for an executable region. But, AArch64 can't
+ * flush it to PoC from userspace. We need a syscall.
+ */
+}
+#elif defined(__arm__)
+static inline void clear_cache_to_poc(char *begin, char *end)
+{
+/* TODO */
+}
+#else
+static inline void clear_cache_to_poc(char *begin, char *end)
+{
+}
+#endif
 #else
 static inline void tlb_flush_page(CPUState *cpu, target_ulong addr)
 {
@@ -114,6 +151,10 @@ static inline void tlb_flush_page(CPUState *cpu, 
target_ulong addr)
 static inline void tlb_flush(CPUState *cpu, int flush_global)
 {
 }
+
+void clear_cache_to_poc(char *begin, char *end)

Re: [Qemu-devel] Reopen file descriptors on 'cont' command

2015-03-06 Thread Christopher Pereira

On 06-03-2015 14:19, Stefan Hajnoczi wrote:

On Wed, Feb 25, 2015 at 09:32:18PM -0300, Christopher Pereira wrote:

Does qemu reopen files on a 'cont' command?

When working with images on a gluster volume, file descriptors may get into
a bad state because of network timeouts, remounting a share, etc...and
reinitializing file descriptors may be usefull to get paused VMs up again.

Related BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1058300

No, QEMU doesn't reopen file descriptors.

This can be challenging because QEMU supports file descriptor passing,
which is used when the QEMU process is isolated using SELinux so it
cannot open files itself.  Reopening would require new file descriptors
passed in from the management tool.


Thanks Stefan.

I confirmed that libvirtd is not passing a FD to QEMU, but an image path.
Is QEMU reopening this image file when the VM is resumed?
QEMU must check if the FD (initialized by QEMU) is still valid, 
especially after resuming a paused VM.





[Qemu-devel] [RFC PATCH 0/6] support KVM_MEM_INCOHERENT

2015-03-06 Thread Andrew Jones
Add support for the new KVM_MEM_INCOHERENT flag, and flag
appropriate memory. (Only flags vram for now.)

Patch 6/6 doesn't appear to be complete. While the VGA output is
99% corruption free, it's not perfect, so it's missing flushes
somewhere... 

Andrew Jones (6):
  memory: add incoherent cache flag
  HACK: linux header update
  kvm-all: put kvm_mem_flags to more work
  kvm-all: set KVM_MEM_INCOHERENT
  vga: flag vram as incoherent
  memory: add clear_cache_to_poc

 exec.c| 16 ++--
 hw/display/vga.c  |  1 +
 include/exec/exec-all.h   | 41 +
 include/exec/memory.h | 23 +++
 kvm-all.c | 28 ++--
 linux-headers/linux/kvm.h |  1 +
 memory.c  | 15 +++
 7 files changed, 109 insertions(+), 16 deletions(-)

-- 
1.8.3.1




[Qemu-devel] [PATCH 3/6] kvm-all: put kvm_mem_flags to more work

2015-03-06 Thread Andrew Jones
Currently kvm_mem_flags just translates bools to bits, let's
make it also determine the bools first. This avoids its parameter
list growing each time we add a flag.

Signed-off-by: Andrew Jones 
---
Posted this, as it makes sense without this series.
http://lists.gnu.org/archive/html/qemu-devel/2015-03/msg01225.html

 kvm-all.c | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 05a79c20e0bba..507fa7204e062 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -294,10 +294,14 @@ err:
  * dirty pages logging control
  */
 
-static int kvm_mem_flags(KVMState *s, bool log_dirty, bool readonly)
+static int kvm_mem_flags(MemoryRegion *mr)
 {
+bool readonly = mr->readonly || memory_region_is_romd(mr);
 int flags = 0;
-flags = log_dirty ? KVM_MEM_LOG_DIRTY_PAGES : 0;
+
+if (memory_region_is_logging(mr)) {
+flags |= KVM_MEM_LOG_DIRTY_PAGES;
+}
 if (readonly && kvm_readonly_mem_allowed) {
 flags |= KVM_MEM_READONLY;
 }
@@ -312,7 +316,10 @@ static int kvm_slot_dirty_pages_log_change(KVMSlot *mem, 
bool log_dirty)
 
 old_flags = mem->flags;
 
-flags = (mem->flags & ~mask) | kvm_mem_flags(s, log_dirty, false);
+flags = mem->flags & ~mask;
+if (log_dirty) {
+flags |= KVM_MEM_LOG_DIRTY_PAGES;
+}
 mem->flags = flags;
 
 /* If nothing changed effectively, no need to issue ioctl */
@@ -642,9 +649,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, 
bool add)
 KVMSlot *mem, old;
 int err;
 MemoryRegion *mr = section->mr;
-bool log_dirty = memory_region_is_logging(mr);
 bool writeable = !mr->readonly && !mr->rom_device;
-bool readonly_flag = mr->readonly || memory_region_is_romd(mr);
 hwaddr start_addr = section->offset_within_address_space;
 ram_addr_t size = int128_get64(section->size);
 void *ram = NULL;
@@ -688,7 +693,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, 
bool add)
 (ram - start_addr == mem->ram - mem->start_addr)) {
 /* The new slot fits into the existing one and comes with
  * identical parameters - update flags and done. */
-kvm_slot_dirty_pages_log_change(mem, log_dirty);
+kvm_slot_dirty_pages_log_change(mem, memory_region_is_logging(mr));
 return;
 }
 
@@ -721,7 +726,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, 
bool add)
 mem->memory_size = old.memory_size;
 mem->start_addr = old.start_addr;
 mem->ram = old.ram;
-mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);
+mem->flags = kvm_mem_flags(mr);
 
 err = kvm_set_user_memory_region(s, mem);
 if (err) {
@@ -742,7 +747,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, 
bool add)
 mem->memory_size = start_addr - old.start_addr;
 mem->start_addr = old.start_addr;
 mem->ram = old.ram;
-mem->flags =  kvm_mem_flags(s, log_dirty, readonly_flag);
+mem->flags =  kvm_mem_flags(mr);
 
 err = kvm_set_user_memory_region(s, mem);
 if (err) {
@@ -766,7 +771,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, 
bool add)
 size_delta = mem->start_addr - old.start_addr;
 mem->memory_size = old.memory_size - size_delta;
 mem->ram = old.ram + size_delta;
-mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);
+mem->flags = kvm_mem_flags(mr);
 
 err = kvm_set_user_memory_region(s, mem);
 if (err) {
@@ -788,7 +793,7 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, 
bool add)
 mem->memory_size = size;
 mem->start_addr = start_addr;
 mem->ram = ram;
-mem->flags = kvm_mem_flags(s, log_dirty, readonly_flag);
+mem->flags = kvm_mem_flags(mr);
 
 err = kvm_set_user_memory_region(s, mem);
 if (err) {
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 5/6] KVM: ARM: implement kvm_*_incoherent_memory_regions

2015-03-06 Thread Andrew Jones
Add the kvm_*_incoherent_memory_regions calls to arm's
kvm_arch_vcpu_ioctl_run and implement the corresponding
arch flush/invalidate functions.

Signed-off-by: Andrew Jones 
---
 arch/arm/include/uapi/asm/kvm.h   |  1 +
 arch/arm/kvm/arm.c|  4 +++
 arch/arm/kvm/mmu.c| 54 +++
 arch/arm64/include/uapi/asm/kvm.h |  1 +
 4 files changed, 60 insertions(+)

diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
index 09ee408c1a676..cb0898a995c4f 100644
--- a/arch/arm/include/uapi/asm/kvm.h
+++ b/arch/arm/include/uapi/asm/kvm.h
@@ -26,6 +26,7 @@
 #define __KVM_HAVE_GUEST_DEBUG
 #define __KVM_HAVE_IRQ_LINE
 #define __KVM_HAVE_READONLY_MEM
+#define __KVM_HAVE_INCOHERENT_MEM
 
 #define KVM_REG_SIZE(id)   \
(1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index c9e6ef1f7403a..789c03c84e7c0 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -486,6 +486,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct 
kvm_run *run)
return ret;
}
 
+   kvm_flush_incoherent_memory_regions(vcpu->kvm);
+
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
 
@@ -556,6 +558,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct 
kvm_run *run)
ret = handle_exit(vcpu, run, ret);
}
 
+   kvm_invalidate_incoherent_memory_regions(vcpu->kvm);
+
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
return ret;
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 2f3a6581b9200..2f45db9cd436a 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1161,6 +1161,24 @@ static void coherent_cache_guest_page(struct kvm_vcpu 
*vcpu, pfn_t pfn,
__coherent_cache_guest_page(pfn, size, need_flush, false);
 }
 
+static void coherent_cache_memslot(struct kvm_memory_slot *slot, bool flush)
+{
+   gfn_t gfn, end = slot->base_gfn + slot->npages;
+   pfn_t pfn;
+
+   for (gfn = slot->base_gfn; gfn < end; ++gfn) {
+   pfn = gfn_to_pfn_memslot(slot, gfn);
+   if (is_error_pfn(pfn)) {
+   pr_err("%s: Bad pfn: gfn=%llx, pfn=%llx, "
+   "userspace_addr=%lx\n", __func__,
+   gfn, pfn, slot->userspace_addr);
+   continue;
+   }
+   __coherent_cache_guest_page(pfn, PAGE_SIZE, flush, !flush);
+   kvm_release_pfn_clean(pfn);
+   }
+}
+
 static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
  struct kvm_memory_slot *memslot, unsigned long hva,
  unsigned long fault_status)
@@ -1802,6 +1820,42 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct 
kvm_memory_slot *slot,
return 0;
 }
 
+void kvm_arch_flush_incoherent(struct kvm *kvm, struct kvm_memory_slot *slot)
+{
+   if (slot->flags & KVM_MEM_READONLY) {
+   /*
+* Readonly memory shouldn't be changing, and we do a
+* clean+invalidate for KVM_MEM_INCOHERENT memory when
+* faulting it in. So, there's nothing to do now.
+*/
+   return;
+   }
+
+   /*
+* Ideally, we would further filter out all pages not touched by
+* userspace on the last exit. No way to know those though, unless
+* we force userspace to fault on all pages in the incoherent
+* memory regions, but even then, I don't see any sane way for
+* do_wp_page to handle the faults without modification. So, sigh...
+*/
+
+   coherent_cache_memslot(slot, true);
+}
+
+void kvm_arch_invalidate_incoherent(struct kvm *kvm, struct kvm_memory_slot 
*slot)
+{
+   if (slot->flags & KVM_MEM_LOG_DIRTY_PAGES) {
+   /*
+* We fault each write when logging is enabled, and do a
+* clean+invalidate on KVM_MEM_INCOHERENT memory while
+* handling the fault. So, there's nothing to do now.
+*/
+   return;
+   }
+
+   coherent_cache_memslot(slot, false);
+}
+
 void kvm_arch_memslots_updated(struct kvm *kvm)
 {
 }
diff --git a/arch/arm64/include/uapi/asm/kvm.h 
b/arch/arm64/include/uapi/asm/kvm.h
index 8e38878c87c61..29ddf77958c2a 100644
--- a/arch/arm64/include/uapi/asm/kvm.h
+++ b/arch/arm64/include/uapi/asm/kvm.h
@@ -38,6 +38,7 @@
 #define __KVM_HAVE_GUEST_DEBUG
 #define __KVM_HAVE_IRQ_LINE
 #define __KVM_HAVE_READONLY_MEM
+#define __KVM_HAVE_INCOHERENT_MEM
 
 #define KVM_REG_SIZE(id)   \
(1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 6/6] KVM: ARM: no need for kvm_arch_flush_incoherent

2015-03-06 Thread Andrew Jones
kvm_arch_flush_incoherent makes things too slow, and we don't
need it. Userspace can flush for us, as the necessary cache
maintenance instruction is not (necessarily) privileged.

Signed-off-by: Andrew Jones 
---
 arch/arm/kvm/mmu.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 2f45db9cd436a..b2d87587a9d79 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1822,6 +1822,11 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct 
kvm_memory_slot *slot,
 
 void kvm_arch_flush_incoherent(struct kvm *kvm, struct kvm_memory_slot *slot)
 {
+   /*
+* We no longer need this function, now that userspace does the
+* flushing.
+*/
+#if 0
if (slot->flags & KVM_MEM_READONLY) {
/*
 * Readonly memory shouldn't be changing, and we do a
@@ -1840,6 +1845,7 @@ void kvm_arch_flush_incoherent(struct kvm *kvm, struct 
kvm_memory_slot *slot)
 */
 
coherent_cache_memslot(slot, true);
+#endif
 }
 
 void kvm_arch_invalidate_incoherent(struct kvm *kvm, struct kvm_memory_slot 
*slot)
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 2/6] KVM: Introduce incoherent cache maintenance API

2015-03-06 Thread Andrew Jones
Add two new memslot functions to the API

  kvm_flush_incoherent_memory_regions
flush all KVM_MEM_INCOHERENT memslot addresses

  kvm_invalidate_incoherent_memory_regions
invalidate all KVM_MEM_INCOHERENT memslot addresses

Signed-off-by: Andrew Jones 
---
 include/linux/kvm_host.h | 14 ++
 virt/kvm/kvm_main.c  | 45 -
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 9dfb519c51e5b..2bdbeeb1b2704 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -517,6 +517,8 @@ int kvm_set_memory_region(struct kvm *kvm,
  struct kvm_userspace_memory_region *mem);
 int __kvm_set_memory_region(struct kvm *kvm,
struct kvm_userspace_memory_region *mem);
+void kvm_flush_incoherent_memory_regions(struct kvm *kvm);
+void kvm_invalidate_incoherent_memory_regions(struct kvm *kvm);
 void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
   struct kvm_memory_slot *dont);
 int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
@@ -705,6 +707,18 @@ static inline bool kvm_arch_has_noncoherent_dma(struct kvm 
*kvm)
 }
 #endif
 
+#ifdef __KVM_HAVE_INCOHERENT_MEM
+void kvm_arch_flush_incoherent(struct kvm *kvm, struct kvm_memory_slot *slot);
+void kvm_arch_invalidate_incoherent(struct kvm *kvm, struct kvm_memory_slot 
*slot);
+#else
+void kvm_arch_flush_incoherent(struct kvm *kvm, struct kvm_memory_slot *slot)
+{
+}
+void kvm_arch_invalidate_incoherent(struct kvm *kvm, struct kvm_memory_slot 
*slot)
+{
+}
+#endif
+
 static inline wait_queue_head_t *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu)
 {
 #ifdef __KVM_HAVE_ARCH_WQP
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 449c1c9ee68b4..96f44c57b8808 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -716,7 +716,7 @@ static void update_memslots(struct kvm_memslots *slots,
 
 static int check_memory_region_flags(struct kvm_userspace_memory_region *mem)
 {
-   u32 valid_flags = KVM_MEM_LOG_DIRTY_PAGES;
+   u32 valid_flags = KVM_MEM_LOG_DIRTY_PAGES | KVM_MEM_INCOHERENT;
 
 #ifdef __KVM_HAVE_READONLY_MEM
valid_flags |= KVM_MEM_READONLY;
@@ -960,6 +960,49 @@ static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
return kvm_set_memory_region(kvm, mem);
 }
 
+static inline bool memory_region_is_incoherent(struct kvm_memory_slot *slot)
+{
+   return slot && slot->id < KVM_USER_MEM_SLOTS
+   && !(slot->flags & KVM_MEMSLOT_INVALID)
+   && slot->flags & KVM_MEM_INCOHERENT;
+}
+
+void kvm_flush_incoherent_memory_regions(struct kvm *kvm)
+{
+   struct kvm_memslots *slots = kvm_memslots(kvm);
+   struct kvm_memory_slot *slot;
+   int idx;
+
+   idx = srcu_read_lock(&kvm->srcu);
+
+   kvm_for_each_memslot(slot, slots) {
+   if (!memory_region_is_incoherent(slot))
+   continue;
+   kvm_arch_flush_incoherent(kvm, slot);
+   }
+   srcu_read_unlock(&kvm->srcu, idx);
+}
+EXPORT_SYMBOL_GPL(kvm_flush_incoherent_memory_regions);
+
+void kvm_invalidate_incoherent_memory_regions(struct kvm *kvm)
+{
+   struct kvm_memslots *slots = kvm_memslots(kvm);
+   struct kvm_memory_slot *slot;
+   int idx;
+
+   idx = srcu_read_lock(&kvm->srcu);
+
+   kvm_for_each_memslot(slot, slots) {
+   if (slot->flags & KVM_MEM_READONLY)
+   continue;
+   if (!memory_region_is_incoherent(slot))
+   continue;
+   kvm_arch_invalidate_incoherent(kvm, slot);
+   }
+   srcu_read_unlock(&kvm->srcu, idx);
+}
+EXPORT_SYMBOL_GPL(kvm_invalidate_incoherent_memory_regions);
+
 int kvm_get_dirty_log(struct kvm *kvm,
struct kvm_dirty_log *log, int *is_dirty)
 {
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 2/6] HACK: linux header update

2015-03-06 Thread Andrew Jones
Should do a proper update-linux-headers.sh update.

Signed-off-by: Andrew Jones 
---
 linux-headers/linux/kvm.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 12045a11c036b..d04e2d781c43b 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -108,6 +108,7 @@ struct kvm_userspace_memory_region {
  */
 #define KVM_MEM_LOG_DIRTY_PAGES(1UL << 0)
 #define KVM_MEM_READONLY   (1UL << 1)
+#define KVM_MEM_INCOHERENT (1UL << 2)
 
 /* for KVM_IRQ_LINE */
 struct kvm_irq_level {
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 0/6] flush/invalidate on entry/exit

2015-03-06 Thread Andrew Jones
Userspace flags memory regions as incoherent and kvm flushes/
invalidates those regions on entry/exit from userspace.

 Result before patch 6/6: restores coherency, way t sloow
 Result with patch 6/6: fast again - well, we removed the code...

Andrew Jones (6):
  kvm: promote KVM_MEMSLOT_INCOHERENT to uapi
  KVM: Introduce incoherent cache maintenance API
  KVM: ARM: change __coherent_cache_guest_page interface
  KVM: ARM: extend __coherent_cache_guest_page
  KVM: ARM: implement kvm_*_incoherent_memory_regions
  KVM: ARM: no need for kvm_arch_flush_incoherent

 arch/arm/include/asm/kvm_mmu.h| 12 +++
 arch/arm/include/uapi/asm/kvm.h   |  1 +
 arch/arm/kvm/arm.c|  4 +++
 arch/arm/kvm/mmu.c| 72 +--
 arch/arm64/include/asm/kvm_mmu.h  | 12 ---
 arch/arm64/include/uapi/asm/kvm.h |  1 +
 include/linux/kvm_host.h  | 15 +++-
 include/uapi/linux/kvm.h  |  1 +
 virt/kvm/kvm_main.c   | 45 +++-
 9 files changed, 147 insertions(+), 16 deletions(-)

-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 4/6] KVM: ARM: extend __coherent_cache_guest_page

2015-03-06 Thread Andrew Jones
Also support only invalidating, rather than always invalidate+clear.

Signed-off-by: Andrew Jones 
---
 arch/arm/include/asm/kvm_mmu.h   | 7 +--
 arch/arm/kvm/mmu.c   | 2 +-
 arch/arm64/include/asm/kvm_mmu.h | 7 +--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
index fd801e96fdd3c..a1c7f554f5de8 100644
--- a/arch/arm/include/asm/kvm_mmu.h
+++ b/arch/arm/include/asm/kvm_mmu.h
@@ -176,7 +176,8 @@ static inline void *kvm_get_hwpgd(struct kvm *kvm)
 
 struct kvm;
 
-#define kvm_flush_dcache_to_poc(a,l)   __cpuc_flush_dcache_area((a), (l))
+#define kvm_flush_dcache_to_poc(a,l)   __cpuc_flush_dcache_area((a), 
(l))
+#define kvm_invalidate_cache_to_poc(a,l)   dmac_unmap_area((a), (l), 0)
 
 static inline bool vcpu_has_cache_enabled(struct kvm_vcpu *vcpu)
 {
@@ -184,7 +185,7 @@ static inline bool vcpu_has_cache_enabled(struct kvm_vcpu 
*vcpu)
 }
 
 static inline void __coherent_cache_guest_page(pfn_t pfn, unsigned long size,
-  bool need_flush)
+  bool need_flush, bool invalidate)
 {
/*
 * If we are going to insert an instruction page and the icache is
@@ -214,6 +215,8 @@ static inline void __coherent_cache_guest_page(pfn_t pfn, 
unsigned long size,
 
if (need_flush)
kvm_flush_dcache_to_poc(va, PAGE_SIZE);
+   if (invalidate)
+   kvm_invalidate_cache_to_poc(va, PAGE_SIZE);
 
if (icache_is_pipt())
__cpuc_coherent_user_range((unsigned long)va,
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 781afc712871c..2f3a6581b9200 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1158,7 +1158,7 @@ static void coherent_cache_guest_page(struct kvm_vcpu 
*vcpu, pfn_t pfn,
  unsigned long size, bool uncached)
 {
bool need_flush = uncached || !vcpu_has_cache_enabled(vcpu);
-   __coherent_cache_guest_page(pfn, size, need_flush);
+   __coherent_cache_guest_page(pfn, size, need_flush, false);
 }
 
 static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h
index 56a976c776bc2..e1090ad70133d 100644
--- a/arch/arm64/include/asm/kvm_mmu.h
+++ b/arch/arm64/include/asm/kvm_mmu.h
@@ -257,7 +257,8 @@ static inline bool kvm_page_empty(void *ptr)
 
 struct kvm;
 
-#define kvm_flush_dcache_to_poc(a,l)   __flush_dcache_area((a), (l))
+#define kvm_flush_dcache_to_poc(a,l)   __flush_dcache_area((a), (l))
+#define kvm_invalidate_cache_to_poc(a,l)   __dma_unmap_area((a), (l), 0)
 
 static inline bool vcpu_has_cache_enabled(struct kvm_vcpu *vcpu)
 {
@@ -265,12 +266,14 @@ static inline bool vcpu_has_cache_enabled(struct kvm_vcpu 
*vcpu)
 }
 
 static inline void __coherent_cache_guest_page(pfn_t pfn, unsigned long size,
-  bool need_flush)
+  bool need_flush, bool invalidate)
 {
void *va = page_address(pfn_to_page(pfn));
 
if (need_flush)
kvm_flush_dcache_to_poc(va, size);
+   if (invalidate)
+   kvm_invalidate_cache_to_poc(va, size);
 
if (!icache_is_aliasing()) {/* PIPT */
flush_icache_range((unsigned long)va,
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 3/6] KVM: ARM: change __coherent_cache_guest_page interface

2015-03-06 Thread Andrew Jones
Remove the vcpu parameter. We can do this by doing the same
query in the caller of __coherent_cache_guest_page, and then
folding the result into its ipa_uncached parameter, which we
rename to need_flush.

A later patch will add a new caller for __coherent_cache_guest_page
that does not have a vcpu parameter.

Signed-off-by: Andrew Jones 
---
 arch/arm/include/asm/kvm_mmu.h   | 7 ++-
 arch/arm/kvm/mmu.c   | 3 ++-
 arch/arm64/include/asm/kvm_mmu.h | 7 +++
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
index 37ca2a4c6f094..fd801e96fdd3c 100644
--- a/arch/arm/include/asm/kvm_mmu.h
+++ b/arch/arm/include/asm/kvm_mmu.h
@@ -183,9 +183,8 @@ static inline bool vcpu_has_cache_enabled(struct kvm_vcpu 
*vcpu)
return (vcpu->arch.cp15[c1_SCTLR] & 0b101) == 0b101;
 }
 
-static inline void __coherent_cache_guest_page(struct kvm_vcpu *vcpu, pfn_t 
pfn,
-  unsigned long size,
-  bool ipa_uncached)
+static inline void __coherent_cache_guest_page(pfn_t pfn, unsigned long size,
+  bool need_flush)
 {
/*
 * If we are going to insert an instruction page and the icache is
@@ -205,8 +204,6 @@ static inline void __coherent_cache_guest_page(struct 
kvm_vcpu *vcpu, pfn_t pfn,
 * and iterate over the range.
 */
 
-   bool need_flush = !vcpu_has_cache_enabled(vcpu) || ipa_uncached;
-
VM_BUG_ON(size & PAGE_MASK);
 
if (!need_flush && !icache_is_pipt())
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index a806e8cecc01b..781afc712871c 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1157,7 +1157,8 @@ void kvm_arch_mmu_write_protect_pt_masked(struct kvm *kvm,
 static void coherent_cache_guest_page(struct kvm_vcpu *vcpu, pfn_t pfn,
  unsigned long size, bool uncached)
 {
-   __coherent_cache_guest_page(vcpu, pfn, size, uncached);
+   bool need_flush = uncached || !vcpu_has_cache_enabled(vcpu);
+   __coherent_cache_guest_page(pfn, size, need_flush);
 }
 
 static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h
index 6458b53731421..56a976c776bc2 100644
--- a/arch/arm64/include/asm/kvm_mmu.h
+++ b/arch/arm64/include/asm/kvm_mmu.h
@@ -264,13 +264,12 @@ static inline bool vcpu_has_cache_enabled(struct kvm_vcpu 
*vcpu)
return (vcpu_sys_reg(vcpu, SCTLR_EL1) & 0b101) == 0b101;
 }
 
-static inline void __coherent_cache_guest_page(struct kvm_vcpu *vcpu, pfn_t 
pfn,
-  unsigned long size,
-  bool ipa_uncached)
+static inline void __coherent_cache_guest_page(pfn_t pfn, unsigned long size,
+  bool need_flush)
 {
void *va = page_address(pfn_to_page(pfn));
 
-   if (!vcpu_has_cache_enabled(vcpu) || ipa_uncached)
+   if (need_flush)
kvm_flush_dcache_to_poc(va, size);
 
if (!icache_is_aliasing()) {/* PIPT */
-- 
1.8.3.1




[Qemu-devel] [RFC PATCH 1/6] kvm: promote KVM_MEMSLOT_INCOHERENT to uapi

2015-03-06 Thread Andrew Jones
Signed-off-by: Andrew Jones 
---
 arch/arm/kvm/mmu.c   | 9 +++--
 include/linux/kvm_host.h | 1 -
 include/uapi/linux/kvm.h | 1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index bcc1b3ad2adce..a806e8cecc01b 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1260,7 +1260,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, 
phys_addr_t fault_ipa,
if (!hugetlb && !force_pte)
hugetlb = transparent_hugepage_adjust(&pfn, &fault_ipa);
 
-   fault_ipa_uncached = memslot->flags & KVM_MEMSLOT_INCOHERENT;
+   fault_ipa_uncached = memslot->flags & KVM_MEM_INCOHERENT;
 
if (hugetlb) {
pmd_t new_pmd = pfn_pmd(pfn, mem_type);
@@ -1784,15 +1784,20 @@ void kvm_arch_free_memslot(struct kvm *kvm, struct 
kvm_memory_slot *free,
 int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
unsigned long npages)
 {
+#if 1
/*
 * Readonly memslots are not incoherent with the caches by definition,
 * but in practice, they are used mostly to emulate ROMs or NOR flashes
 * that the guest may consider devices and hence map as uncached.
 * To prevent incoherency issues in these cases, tag all readonly
 * regions as incoherent.
+*
+* This heuristic can be removed after userspace has been updated to
+* use KVM_MEM_INCOHERENT on readonly regions when necessary.
 */
if (slot->flags & KVM_MEM_READONLY)
-   slot->flags |= KVM_MEMSLOT_INCOHERENT;
+   slot->flags |= KVM_MEM_INCOHERENT;
+#endif
return 0;
 }
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 3b934cc94cc83..9dfb519c51e5b 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -43,7 +43,6 @@
  * include/linux/kvm_h.
  */
 #define KVM_MEMSLOT_INVALID(1UL << 16)
-#define KVM_MEMSLOT_INCOHERENT (1UL << 17)
 
 /* Two fragments for cross MMIO pages. */
 #define KVM_MAX_MMIO_FRAGMENTS 2
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index a37fd1224f363..f7f9432bcf485 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -108,6 +108,7 @@ struct kvm_userspace_memory_region {
  */
 #define KVM_MEM_LOG_DIRTY_PAGES(1UL << 0)
 #define KVM_MEM_READONLY   (1UL << 1)
+#define KVM_MEM_INCOHERENT (1UL << 2)
 
 /* for KVM_IRQ_LINE */
 struct kvm_irq_level {
-- 
1.8.3.1




[Qemu-devel] the arm cache coherency cluster

2015-03-06 Thread Andrew Jones
In reply to this message I'll send two series' one for KVM and
one for QEMU. The two series' are their respective component
complements, and attempt to implement cache coherency for arm
guests using emulated devices, where the emulator (qemu) uses
cached memory for the device memory, but the guest uses
uncached - as device memory is generally used. Right now I've
just focused on VGA vram.

This approach starts as the "add a new memslot flag" approach,
and then turns into the "make qemu do some cache maintenance"
approach with the final patch of each series (6/6). It stops
short of the "add syscalls..." approach. Below is a summary of
all the approaches discussed so far, to my knowledge.

"MAIR manipulating"
Posted[1] by Ard. Works. No performance degradation. Potential
issues with device assignment and the guest getting confused.

"add a new memslot flag"
This posting (not counting patches 6/6). Works. Huge performance
degradation.

"make qemu do some cache maintenance"
This posting (patches 6/6). We can only do so much in qemu
without syscalls. This series does what it can. Almost works,
probably could work, after playing 'find the missing flush'.
This approach still requires the new memslot flag, as userspace
can't invalidate the cache, only clean, or clean+invalidate.
No noticeable performance degradation.

"add syscalls to make qemu do all cache maintenance"
Variant 1: implement as kvm ioctls - to avoid trying to get
   syscalls into the general kernel
Variant 2: add real syscalls, or maybe just ARM private SWIs
   like __ARM_NR_cacheflush
This approach should work, and if we add an invalidate syscall,
then we shouldn't need any kvm changes at all, i.e. no need for
the memslot flag. I haven't experimented with this yet, but I'm
starting to like the idea of variant 2, with a private SWI, so
will try to pull something together soon for that.

"describe the problematic memory as cached to the guest"
Not an ideal solution for virt. Could maybe be workable as a
quirk for a specific device though.

re: $SUBJECT; Here 'cluster' is defined by the urban dictionary.

[1] http://thread.gmane.org/gmane.comp.emulators.kvm.arm.devel/34/



Re: [Qemu-devel] [RFC 0/1] Rolling stats on colo

2015-03-06 Thread Dr. David Alan Gilbert
* zhanghailiang (zhang.zhanghaili...@huawei.com) wrote:
> On 2015/3/5 21:31, Dr. David Alan Gilbert (git) wrote:
> >From: "Dr. David Alan Gilbert" 
> 
> Hi Dave,
> 
> >
> >Hi,
> >   I'm getting COLO running on a couple of our machines here
> >and wanted to see what was actually going on, so I merged
> >in my recent rolling-stats code:
> >
> >http://lists.gnu.org/archive/html/qemu-devel/2015-03/msg00648.html
> >
> >with the following patch, and now I get on the primary side,
> >info migrate shows me:
> >
> >capabilities: xbzrle: off rdma-pin-all: off auto-converge: off zero-blocks: 
> >off colo: on
> >Migration status: colo
> >total time: 0 milliseconds
> >colo checkpoint (ms): Min/Max: 0, 1 Mean: -1.1415868e-13 (Weighted: 
> >4.3136025e-158) Count: 4020 Values: 0@1425561742237, 0@1425561742300, 
> >0@1425561742363, 0@1425561742426, 0@1425561742489, 0@1425561742555, 
> >0@1425561742618, 0@1425561742681, 0@1425561742743, 0@1425561742824
> >colo paused time (ms): Min/Max: 55, 2789 Mean: 63.9 (Weighted: 76.243584) 
> >Count: 4019 Values: 62@1425561742237, 62@1425561742300, 62@1425561742363, 
> >62@1425561742426, 61@1425561742489, 65@1425561742555, 62@1425561742618, 
> >62@1425561742681, 61@1425561742743, 80@1425561742824
> >colo checkpoint size: Min/Max: 18351, 2.1731606e+08 Mean: 150096.4 
> >(Weighted: 127195.56) Count: 4020 Values: 211246@1425561742238, 
> >186622@1425561742301, 227662@1425561742364, 219454@1425561742428, 
> >268702@1425561742490, 96334@1425561742556, 47086@1425561742619, 
> >42982@1425561742682, 55294@1425561742744, 145582@1425561742825
> >
> >which suggests I've got a problem with the packet comparison; but that's
> >a separate issue I'll look at.
> >
> 
> There is an obvious mistake we have made in proxy, the macro 
> 'IPS_UNTRACKED_BIT' in colo-patch-for-kernel.patch should be 14,
> so please fix it before do the follow test. Sorry for this low-grade mistake, 
> we should do full test before issue it. ;)

No, that's OK; we all make them.

However, that didn't cure my problem; but after a bit of experimentation I now 
have
COLO working pretty well; thanks for the help!

   1) I had to disable IPv6 in the guest; it doesn't look like the
   conntrack is coping with IPv6 ICMPV6, and on our test network
   we're getting a few 10s of those each second, so it's constant
   miscompares (they seem to be neighbour broadcasts and multicast
   stuff).

   2) It looks like virtio-net is sending ARPs - possibly every time
   that a snapshot is loaded;  it's not the 'qemu' announce-self code,
   (I added some debug there and it's not being called); and ARPs
   cause a miscompare - so you get a continuous streem of miscompares
   because a miscompare triggers a new snapshot, that sends more ARPs.
   I solved this by switching to e1000.

   3) The other problem with virtio is it's occasionally triggering a
   'virtio: error trying to map MMIO memory' from qemu;  I'm not sure
   why, the state COLO sends over should always be consistent.

   4) With the e1000 setup; connections are generally fairly responsive,
   but sshing into the guest takes *ages* (10s of seconds).  I'm not sure
   why, because a curl to a web server seems OK (less than a second)
   and once the ssh is open it's pretty responsive.

   5) I've seen one instance of; 
  'qemu-system-x86_64: block/raw-posix.c:836: handle_aiocb_rw: Assertion `p 
- buf == aiocb->aio_nbytes' failed.'
  on the primary side.

Stats for a mostly idle guest are now showing:

colo checkpoint (ms): Min/Max: 0, 10004 Mean: 1592.1 (Weighted: 1806.214) 
Count: 227 Values: 1650@1425666160229, 1661@1425666161998, 1662@1425666163736, 
1687@1425666165524, 811@1425666166438, 788@1425666167298, 1619@1425666168992, 
1699@1425666170793, 2711@1425666173602, 1633@1425666175315
colo paused time (ms): Min/Max: 58, 2975 Mean: 90.3 (Weighted: 94.109752) 
Count: 227 Values: 107@1425666160337, 75@1425666162074, 100@1425666163837, 
102@1425666165627, 71@1425666166510, 74@1425666167373, 101@1425666169094, 
97@1425666170891, 79@1425666173682, 97@1425666175413
colo checkpoint size: Min/Max: 212252, 1.9241972e+08 Mean: 5569622.6 (Weighted: 
4826386.5) Count: 227 Values: 5998892@1425666160230, 4660988@1425666161999, 
6002996@1425666163737, 5945540@1425666165525, 4833356@1425666166439, 
5510606@1425666167299, 5793692@1425666168993, 5584388@1425666170794, 
7016684@1425666173603, 4349084@1425666175316

So, one checkpoint every ~1.5 seconds; that's just with an
ssh connected and a script doing a 'curl' to it's http
repeatedly.   Running 'top' on the ssh with a fast refresh
brings the checkpoints much faster; I guess that's because
the output of top is quite random.

> To be honest, the proxy part in github is not integrated, we have cut it just 
> for easy review and understand, so there may be some mistakes.

Yes, that's OK; and I've had a few kernel crashes; normally 
when the qemu crashes, the kernel doesn't really like it;
but that's OK, I'm sure it will get better.

I added 

Re: [Qemu-devel] [PATCH v3 for-2.3 04/24] acpi: add aml_index() term

2015-03-06 Thread Marcel Apfelbaum

On 03/06/2015 12:40 PM, Igor Mammedov wrote:

On Thu,  5 Mar 2015 16:55:02 +0200
Marcel Apfelbaum  wrote:


Add encoding for ACPI DefIndex Opcode.

Signed-off-by: Marcel Apfelbaum 
---
  hw/acpi/aml-build.c | 10 ++
  include/hw/acpi/aml-build.h |  1 +
  2 files changed, 11 insertions(+)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 611c949..0b3fcda 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -477,6 +477,16 @@ Aml *aml_add(Aml *arg1, Aml *arg2)
  return var;
  }

+/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIndex */
+Aml *aml_index(Aml *arg1, Aml *idx)
+{
+Aml *var = aml_opcode(0x88 /* IndexOp */);

could you add assert to check that Arg1 is BuffPkgStrObj?

Sure, thanks!
Marcel




+aml_append(var, arg1);
+aml_append(var, idx);
+build_append_int(var->buf, 0x00 /* NullNameOp */);
+return var;
+}
+
  /* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefNotify */
  Aml *aml_notify(Aml *arg1, Aml *arg2)
  {
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index edc0520..b860732 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -140,6 +140,7 @@ Aml *aml_and(Aml *arg1, Aml *arg2);
  Aml *aml_or(Aml *arg1, Aml *arg2);
  Aml *aml_lless(Aml *arg1, Aml *arg2);
  Aml *aml_add(Aml *arg1, Aml *arg2);
+Aml *aml_index(Aml *arg1, Aml *idx);
  Aml *aml_notify(Aml *arg1, Aml *arg2);
  Aml *aml_call1(const char *method, Aml *arg1);
  Aml *aml_call2(const char *method, Aml *arg1, Aml *arg2);







Re: [Qemu-devel] mfocrf missing on e500v2

2015-03-06 Thread Maciej W. Rozycki
On Fri, 6 Mar 2015, Alexander Graf wrote:

> >> And lo and behold, I really couldn't find any reference to mfocrf in the
> >> e500v2 spec.
> > 
> > Do real e500 processors trap on this operation as well?  
> 
> The illegal instruction I posted about above was when running qemu 
> *on* e500v2, because TCG emits mfocrf ;).

 Ah OK, fair enough!  I guess that answers the question.

  Maciej



Re: [Qemu-devel] mfocrf missing on e500v2

2015-03-06 Thread Alexander Graf



> Am 06.03.2015 um 18:20 schrieb Maciej W. Rozycki :
> 
>> On Fri, 6 Mar 2015, Alexander Graf wrote:
>> 
>> I've finally managed to check out why my e500v2 automated tests fail to
>> run. Apparently they break because autotest wants to execute target code
>> and runs into an illegal instruction while doing that:
>> 
>> Program received signal SIGILL, Illegal instruction.
>> 0xb57c84cc in ?? ()
>> (gdb) x /i $pc
>> => 0xb57c84cc:mfocrf  r0,1
>> 
>> And lo and behold, I really couldn't find any reference to mfocrf in the
>> e500v2 spec.
> 
> Do real e500 processors trap on this operation as well?  

The illegal instruction I posted about above was when running qemu *on* e500v2, 
because TCG emits mfocrf ;).


Alex




Re: [Qemu-devel] qemu crash in coroutine bdrv_co_do_rw

2015-03-06 Thread Stefan Hajnoczi
On Thu, Feb 26, 2015 at 10:29:57AM +0100, Christian Borntraeger wrote:
> is this some know issue? Under heavy load with lots of dataplane devices I 
> sometimes get a segfault in the bdrc_co_do_rw routine:
> 
> #0  bdrv_co_do_rw (opaque=0x0) at /home/cborntra/REPOS/qemu/block.c:4791
> 4791  if (!acb->is_write) {
> (gdb) bt
> #0  bdrv_co_do_rw (opaque=0x0) at /home/cborntra/REPOS/qemu/block.c:4791
> #1  0x801aeb78 in coroutine_trampoline (i0=, 
> i1=-725099072) at /home/cborntra/REPOS/qemu/coroutine-ucontext.c:80
> #2  0x03fffbe1cca2 in __makecontext_ret () from /lib64/libc.so.6
> Backtrace stopped: previous frame identical to this frame (corrupt stack?)
> (gdb) up
> #1  0x801aeb78 in coroutine_trampoline (i0=, 
> i1=-725099072) at /home/cborntra/REPOS/qemu/coroutine-ucontext.c:80
> 80co->entry(co->entry_arg);
> (gdb) print *co
> $1 = {entry = 0x801a3c28 , entry_arg = 0x0, caller = 
> 0x3ffe2fff788, pool_next = {sle_next = 0x3ffd2287990}, co_queue_wakeup = 
> {tqh_first = 0x0, 
> tqh_last = 0x3ffd4c7dde0}, co_queue_next = {tqe_next = 0x0, tqe_prev = 
> 0x0}}
> 
> As you can see enty_arg is 0, causing the problem. Do you have any quick idea 
> before I start debugging?

No, I haven't seen this bug before.  Are you running qemu.git/master?

Have you tried disabling the coroutine pool (freelist)?

Stefan


pgpChjeM2wLCA.pgp
Description: PGP signature


Re: [Qemu-devel] mfocrf missing on e500v2

2015-03-06 Thread Maciej W. Rozycki
On Fri, 6 Mar 2015, Alexander Graf wrote:

> I've finally managed to check out why my e500v2 automated tests fail to
> run. Apparently they break because autotest wants to execute target code
> and runs into an illegal instruction while doing that:
> 
> Program received signal SIGILL, Illegal instruction.
> 0xb57c84cc in ?? ()
> (gdb) x /i $pc
> => 0xb57c84cc:mfocrf  r0,1
> 
> And lo and behold, I really couldn't find any reference to mfocrf in the
> e500v2 spec.

 Do real e500 processors trap on this operation as well?  Here's what 
the Power ISA [1] says on the mtocrf and mfocrf instructions:

"These forms of the mtcrf and mfcr instructions are intended to replace 
the old forms of the instructions (the forms shown in page 102), which 
will eventually be phased out of the architecture. The new forms are 
backward compatible with most processors that comply with versions of 
the architecture that precede Version 2.00.  On those processors, the 
new forms are treated as the old forms.

"However, on some processors that comply with versions of the 
architecture that precede Version 2.00 the new forms may be treated as 
follows:

mtocrf: may cause the system illegal instruction error handler to be 
invoked

mfocrf: may place an undefined value into register RT"

So it looks to me like the ISA, for its extension, relies on partial 
instruction decoding here.

 Furthermore both the opcode and the extended opcode are the same for 
each of mtcrf/mtocrf and mfcr/mfocrf, and the instructions within these 
pairs only differ by the value of a single bit within a field used for 
RA by operations that use it.  That bit is specified as reserved (/) for 
mtcrf/mfcr by e500 processor documentation [2][3][4] and likely a "don't 
care" in real implementations.  Offhand I suspect this is what pre-2.00 
ISA revisions did too.

 So perhaps the partial decoding of mtcrf and mfcr has to be implemented 
in QEMU for the processors concerned instead then?  The answer will 
depend on what actual hardware does.

References:

[1] "Power ISA", IBM Corporation, Version 2.06 Revision B, July 23, 
2010, Section 3.3.15.1 "Move To/From One Condition Register Field 
Instructions", p. 103

[2] "PowerPC e500 Core Family Reference Manual", Freescale 
Semiconductor, Document ID: E500CORERM, Rev. 1, 4/2005, Table D-1 
"Instructions (Binary) by Mnemonic", p. D-17

[3] same, Table D-2 "Instructions (Decimal and Hexadecimal) by Opcode",
p. D-32

[4] same, Table D-3 "Instructions (Binary) by Form", pp. D-37, D-48

  Maciej



Re: [Qemu-devel] Reopen file descriptors on 'cont' command

2015-03-06 Thread Stefan Hajnoczi
On Wed, Feb 25, 2015 at 09:32:18PM -0300, Christopher Pereira wrote:
> Does qemu reopen files on a 'cont' command?
> 
> When working with images on a gluster volume, file descriptors may get into
> a bad state because of network timeouts, remounting a share, etc...and
> reinitializing file descriptors may be usefull to get paused VMs up again.
> 
> Related BZ:
> https://bugzilla.redhat.com/show_bug.cgi?id=1058300

No, QEMU doesn't reopen file descriptors.

This can be challenging because QEMU supports file descriptor passing,
which is used when the QEMU process is isolated using SELinux so it
cannot open files itself.  Reopening would require new file descriptors
passed in from the management tool.

Stefan


pgpfF3boQq2ih.pgp
Description: PGP signature


  1   2   >