Re: [Qemu-devel] [PATCH v2] qom: Fix memory leak in object_property_set_link()

2013-11-18 Thread Amos Kong
On Fri, Nov 15, 2013 at 12:09:47PM -0500, Vlad Yasevich wrote:
 Save the result of the call to object_get_cannonical_path()
 so we can free it.
 
 Signed-off-by: Vlad Yasevich vyase...@redhat.com
 ---
 v1-v2:  Builds and works :)
 
  qom/object.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/qom/object.c b/qom/object.c
 index b617f26..fc19cf6 100644
 --- a/qom/object.c
 +++ b/qom/object.c
 @@ -838,8 +838,9 @@ char *object_property_get_str(Object *obj, const char 
 *name,
  void object_property_set_link(Object *obj, Object *value,
const char *name, Error **errp)
  {
 -object_property_set_str(obj, object_get_canonical_path(value),
 -name, errp);
 +gchar *path = object_get_canonical_path(value);
 +object_property_set_str(obj, path, name, errp);
 +g_free(path);

Reviewed-by: Amos Kong ak...@redhat.com

  }
  
  Object *object_property_get_link(Object *obj, const char *name,
 -- 
 1.8.4.2
 

-- 
Amos.



[Qemu-devel] [PATCH 3/3] ui/vnc: disable adaptive update calculations if not needed

2013-11-18 Thread Peter Lieven
Signed-off-by: Peter Lieven p...@kamp.de
---
 ui/vnc.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/ui/vnc.c b/ui/vnc.c
index edf33be..6683ae9 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3194,7 +3194,9 @@ void vnc_display_open(DisplayState *ds, const char 
*display, Error **errp)
 acl = 1;
 #endif
 } else if (strncmp(options, lossy, 5) == 0) {
+#ifdef CONFIG_VNC_JPEG
 vs-lossy = true;
+#endif
 } else if (strncmp(options, non-adaptive, 12) == 0) {
 vs-non_adaptive = true;
 } else if (strncmp(options, share=, 6) == 0) {
@@ -3211,6 +3213,13 @@ void vnc_display_open(DisplayState *ds, const char 
*display, Error **errp)
 }
 }
 
+/* adaptive updates are only used with tight encoding and
+ * if lossy updates are enabled so we can disable all the
+ * calculations otherwise */
+if (!vs-lossy) {
+vs-non_adaptive = true;
+}
+
 #ifdef CONFIG_VNC_TLS
 if (acl  x509  vs-tls.x509verify) {
 if (!(vs-tls.acl = qemu_acl_init(vnc.x509dname))) {
-- 
1.7.9.5




[Qemu-devel] [PATCH 1/3] ui/vnc: introduce VNC_DIRTY_PIXELS_PER_BIT macro

2013-11-18 Thread Peter Lieven
Signed-off-by: Peter Lieven p...@kamp.de
---
 ui/vnc.c |   55 ++-
 ui/vnc.h |6 +-
 2 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 5601cc3..67b1f75 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -442,17 +442,19 @@ static void vnc_dpy_update(DisplayChangeListener *dcl,
iteration.  otherwise, if (x % 16) != 0, the last iteration may span
two 16-pixel blocks but we only mark the first as dirty
 */
-w += (x % 16);
-x -= (x % 16);
+w += (x % VNC_DIRTY_PIXELS_PER_BIT);
+x -= (x % VNC_DIRTY_PIXELS_PER_BIT);
 
 x = MIN(x, width);
 y = MIN(y, height);
 w = MIN(x + w, width) - x;
 h = MIN(h, height);
 
-for (; y  h; y++)
-for (i = 0; i  w; i += 16)
-set_bit((x + i) / 16, s-dirty[y]);
+for (; y  h; y++) {
+for (i = 0; i  w; i += VNC_DIRTY_PIXELS_PER_BIT) {
+set_bit((x + i) / VNC_DIRTY_PIXELS_PER_BIT, s-dirty[y]);
+}
+}
 }
 
 void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
@@ -769,11 +771,11 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl,
 y = dst_y + h - 1;
 inc = -1;
 }
-w_lim = w - (16 - (dst_x % 16));
+w_lim = w - (VNC_DIRTY_PIXELS_PER_BIT - (dst_x % 
VNC_DIRTY_PIXELS_PER_BIT));
 if (w_lim  0)
 w_lim = w;
 else
-w_lim = w - (w_lim % 16);
+w_lim = w - (w_lim % VNC_DIRTY_PIXELS_PER_BIT);
 for (i = 0; i  h; i++) {
 for (x = 0; x = w_lim;
 x += s, src_row += cmp_bytes, dst_row += cmp_bytes) {
@@ -781,10 +783,10 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl,
 if ((s = w - w_lim) == 0)
 break;
 } else if (!x) {
-s = (16 - (dst_x % 16));
+s = (16 - (dst_x % VNC_DIRTY_PIXELS_PER_BIT));
 s = MIN(s, w_lim);
 } else {
-s = 16;
+s = VNC_DIRTY_PIXELS_PER_BIT;
 }
 cmp_bytes = s * VNC_SERVER_FB_BYTES;
 if (memcmp(src_row, dst_row, cmp_bytes) == 0)
@@ -911,7 +913,7 @@ static int vnc_update_client(VncState *vs, int has_dirty)
 for (y = 0; y  height; y++) {
 int x;
 int last_x = -1;
-for (x = 0; x  width / 16; x++) {
+for (x = 0; x  width / VNC_DIRTY_PIXELS_PER_BIT; x++) {
 if (test_and_clear_bit(x, vs-dirty[y])) {
 if (last_x == -1) {
 last_x = x;
@@ -921,16 +923,21 @@ static int vnc_update_client(VncState *vs, int has_dirty)
 int h = find_and_clear_dirty_height(vs, y, last_x, x,
 height);
 
-n += vnc_job_add_rect(job, last_x * 16, y,
-  (x - last_x) * 16, h);
+n += vnc_job_add_rect(job,
+  last_x * 
VNC_DIRTY_PIXELS_PER_BIT,
+  y,
+  (x - last_x) * 
VNC_DIRTY_PIXELS_PER_BIT,
+  h);
 }
 last_x = -1;
 }
 }
 if (last_x != -1) {
 int h = find_and_clear_dirty_height(vs, y, last_x, x, height);
-n += vnc_job_add_rect(job, last_x * 16, y,
-  (x - last_x) * 16, h);
+n += vnc_job_add_rect(job, last_x * VNC_DIRTY_PIXELS_PER_BIT,
+  y,
+  (x - last_x) * VNC_DIRTY_PIXELS_PER_BIT,
+  h);
 }
 }
 
@@ -1861,7 +1868,7 @@ static void framebuffer_update_request(VncState *vs, int 
incremental,
int w, int h)
 {
 int i;
-const size_t width = surface_width(vs-vd-ds) / 16;
+const size_t width = surface_width(vs-vd-ds) / VNC_DIRTY_PIXELS_PER_BIT;
 const size_t height = surface_height(vs-vd-ds);
 
 if (y_position  height) {
@@ -2563,7 +2570,9 @@ static int vnc_refresh_lossy_rect(VncDisplay *vd, int x, 
int y)
 
 vs-lossy_rect[sty][stx] = 0;
 for (j = 0; j  VNC_STAT_RECT; ++j) {
-bitmap_set(vs-dirty[y + j], x / 16, VNC_STAT_RECT / 16);
+bitmap_set(vs-dirty[y + j],
+   x / VNC_DIRTY_PIXELS_PER_BIT,
+   VNC_STAT_RECT / VNC_DIRTY_PIXELS_PER_BIT);
 }
 has_dirty++;
 }
@@ -2710,17 +2719,21 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
 }
 server_ptr = server_row;
 
-for (x = 0; x + 15  width;
-x += 16, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {
-if 

[Qemu-devel] [PATCH 0/3] ui/vnc: update optimizations

2013-11-18 Thread Peter Lieven
this series includes 2 optimizations for the ui/vnc guest to server and server 
to client
update cycles. comments/reviews appreciated.

Peter

Peter Lieven (3):
  ui/vnc: introduce VNC_DIRTY_PIXELS_PER_BIT macro
  ui/vnc: optimize dirty bitmap tracking
  ui/vnc: disable adaptive update calculations if not needed

 ui/vnc.c |  172 +-
 ui/vnc.h |9 +++-
 2 files changed, 121 insertions(+), 60 deletions(-)

-- 
1.7.9.5




[Qemu-devel] [PATCH 2/3] ui/vnc: optimize dirty bitmap tracking

2013-11-18 Thread Peter Lieven
vnc_update_client currently scans the dirty bitmap of each client
bitwise which is a very costly operation if only few bits are dirty.
vnc_refresh_server_surface does almost the same.
this patch optimizes both by utilizing the heavily optimized
function find_next_bit to find the offset of the next dirty
bit in the dirty bitmaps.

Signed-off-by: Peter Lieven p...@kamp.de
---
 ui/vnc.c |  146 ++
 ui/vnc.h |3 ++
 2 files changed, 92 insertions(+), 57 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 67b1f75..edf33be 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -572,6 +572,16 @@ void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)
 ptr += x * VNC_SERVER_FB_BYTES;
 return ptr;
 }
+/* this sets only the visible pixels of a dirty bitmap */
+#define VNC_SET_VISIBLE_PIXELS_DIRTY(bitmap, w, h) {\
+int x, y;\
+memset(bitmap, 0x00, sizeof(bitmap));\
+for (y = 0; y  h; y++) {\
+for (x = 0; x  w / VNC_DIRTY_PIXELS_PER_BIT; x++) {\
+set_bit(x, bitmap[y]);\
+} \
+} \
+}
 
 static void vnc_dpy_switch(DisplayChangeListener *dcl,
DisplaySurface *surface)
@@ -597,7 +607,9 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
 qemu_pixman_image_unref(vd-guest.fb);
 vd-guest.fb = pixman_image_ref(surface-image);
 vd-guest.format = surface-format;
-memset(vd-guest.dirty, 0xFF, sizeof(vd-guest.dirty));
+VNC_SET_VISIBLE_PIXELS_DIRTY(vd-guest.dirty,
+ surface_width(vd-ds),
+ surface_height(vd-ds));
 
 QTAILQ_FOREACH(vs, vd-clients, next) {
 vnc_colordepth(vs);
@@ -605,7 +617,9 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
 if (vs-vd-cursor) {
 vnc_cursor_define(vs);
 }
-memset(vs-dirty, 0xFF, sizeof(vs-dirty));
+VNC_SET_VISIBLE_PIXELS_DIRTY(vs-dirty,
+ surface_width(vd-ds),
+ surface_height(vd-ds));
 }
 }
 
@@ -882,6 +896,14 @@ static int vnc_update_client_sync(VncState *vs, int 
has_dirty)
 return ret;
 }
 
+#define VNC_CLIENT_UPDATE_RECT() \
+if (last_x != -1) {\
+int h = find_and_clear_dirty_height(vs, y, last_x, x, height);\
+n += vnc_job_add_rect(job,\
+  last_x * VNC_DIRTY_PIXELS_PER_BIT, y,\
+  (x - last_x) * VNC_DIRTY_PIXELS_PER_BIT, h);\
+}
+
 static int vnc_update_client(VncState *vs, int has_dirty)
 {
 if (vs-need_update  vs-csock != -1) {
@@ -910,35 +932,32 @@ static int vnc_update_client(VncState *vs, int has_dirty)
 width = MIN(pixman_image_get_width(vd-server), vs-client_width);
 height = MIN(pixman_image_get_height(vd-server), vs-client_height);
 
-for (y = 0; y  height; y++) {
+y = 0;
+for (;;) {
 int x;
 int last_x = -1;
-for (x = 0; x  width / VNC_DIRTY_PIXELS_PER_BIT; x++) {
+unsigned long offset = find_next_bit((unsigned long *) vs-dirty,
+ height * 
VNC_DIRTY_BITS_PER_LINE(vs),
+ y * 
VNC_DIRTY_BITS_PER_LINE(vs));
+if (offset == height * VNC_DIRTY_BITS_PER_LINE(vs)) {
+/* no more dirty bits */
+break;
+}
+y = offset / VNC_DIRTY_BITS_PER_LINE(vs);
+
+for (x = offset % VNC_DIRTY_BITS_PER_LINE(vs);
+ x  width / VNC_DIRTY_PIXELS_PER_BIT; x++) {
 if (test_and_clear_bit(x, vs-dirty[y])) {
 if (last_x == -1) {
 last_x = x;
 }
 } else {
-if (last_x != -1) {
-int h = find_and_clear_dirty_height(vs, y, last_x, x,
-height);
-
-n += vnc_job_add_rect(job,
-  last_x * 
VNC_DIRTY_PIXELS_PER_BIT,
-  y,
-  (x - last_x) * 
VNC_DIRTY_PIXELS_PER_BIT,
-  h);
-}
+VNC_CLIENT_UPDATE_RECT();
 last_x = -1;
 }
 }
-if (last_x != -1) {
-int h = find_and_clear_dirty_height(vs, y, last_x, x, height);
-n += vnc_job_add_rect(job, last_x * VNC_DIRTY_PIXELS_PER_BIT,
-  y,
-  (x - last_x) * VNC_DIRTY_PIXELS_PER_BIT,
-  h);
-}
+VNC_CLIENT_UPDATE_RECT();
+y++;
 }
 
 vnc_job_push(job);
@@ -2676,8 +2695,8 @@ static int 

[Qemu-devel] [PATCH v2] net: move rxfilter_notify() to net.c

2013-11-18 Thread Amos Kong
rxfilter_notify() is a generic function for all nics, not only for
virtio_net, so move it to net.c

Signed-off-by: Amos Kong ak...@redhat.com
---
v2: fix the memory leak (Stefan)
---
 hw/net/virtio-net.c | 32 +---
 include/net/net.h   |  2 ++
 net/net.c   | 22 ++
 3 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 613f144..cee52ff 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -194,28 +194,6 @@ static void virtio_net_set_link_status(NetClientState *nc)
 virtio_net_set_status(vdev, vdev-status);
 }
 
-static void rxfilter_notify(NetClientState *nc)
-{
-QObject *event_data;
-VirtIONet *n = qemu_get_nic_opaque(nc);
-
-if (nc-rxfilter_notify_enabled) {
-if (n-netclient_name) {
-event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
-n-netclient_name,
-
object_get_canonical_path(OBJECT(n-qdev)));
-} else {
-event_data = qobject_from_jsonf({ 'path': %s },
-
object_get_canonical_path(OBJECT(n-qdev)));
-}
-monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
-qobject_decref(event_data);
-
-/* disable event notification to avoid events flooding */
-nc-rxfilter_notify_enabled = 0;
-}
-}
-
 static char *mac_strdup_printf(const uint8_t *mac)
 {
 return g_strdup_printf(%.2x:%.2x:%.2x:%.2x:%.2x:%.2x, mac[0],
@@ -545,7 +523,7 @@ static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t 
cmd,
 return VIRTIO_NET_ERR;
 }
 
-rxfilter_notify(nc);
+rxfilter_notify(nc, OBJECT(n-qdev));
 
 return VIRTIO_NET_OK;
 }
@@ -601,7 +579,7 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
 s = iov_to_buf(iov, iov_cnt, 0, n-mac, sizeof(n-mac));
 assert(s == sizeof(n-mac));
 qemu_format_nic_info_str(qemu_get_queue(n-nic), n-mac);
-rxfilter_notify(nc);
+rxfilter_notify(nc, OBJECT(n-qdev));
 
 return VIRTIO_NET_OK;
 }
@@ -668,12 +646,12 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t 
cmd,
 n-mac_table.multi_overflow = 1;
 }
 
-rxfilter_notify(nc);
+rxfilter_notify(nc, OBJECT(n-qdev));
 
 return VIRTIO_NET_OK;
 
 error:
-rxfilter_notify(nc);
+rxfilter_notify(nc, OBJECT(n-qdev));
 return VIRTIO_NET_ERR;
 }
 
@@ -700,7 +678,7 @@ static int virtio_net_handle_vlan_table(VirtIONet *n, 
uint8_t cmd,
 else
 return VIRTIO_NET_ERR;
 
-rxfilter_notify(nc);
+rxfilter_notify(nc, OBJECT(n-qdev));
 
 return VIRTIO_NET_OK;
 }
diff --git a/include/net/net.h b/include/net/net.h
index 11e1468..178db62 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -8,6 +8,7 @@
 #include net/queue.h
 #include migration/vmstate.h
 #include qapi-types.h
+#include qom/object.h
 
 #define MAX_QUEUE_NUM 1024
 
@@ -138,6 +139,7 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,
 void *opaque);
 
 void print_net_client(Monitor *mon, NetClientState *nc);
+void rxfilter_notify(NetClientState *nc, Object *obj);
 void do_info_network(Monitor *mon, const QDict *qdict);
 
 /* NIC info */
diff --git a/net/net.c b/net/net.c
index 0a88e68..341dd2b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -41,6 +41,7 @@
 #include qapi-visit.h
 #include qapi/opts-visitor.h
 #include qapi/dealloc-visitor.h
+#include qapi/qmp/qjson.h
 
 /* Net bridge is currently not supported for W32. */
 #if !defined(_WIN32)
@@ -967,6 +968,27 @@ void print_net_client(Monitor *mon, NetClientState *nc)
nc-info_str);
 }
 
+void rxfilter_notify(NetClientState *nc, Object *obj)
+{
+QObject *event_data;
+gchar *path = object_get_canonical_path(obj);
+
+if (nc-rxfilter_notify_enabled) {
+if (nc-name) {
+event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
+nc-name, path);
+} else {
+event_data = qobject_from_jsonf({ 'path': %s }, path);
+}
+monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
+qobject_decref(event_data);
+
+/* disable event notification to avoid events flooding */
+nc-rxfilter_notify_enabled = 0;
+}
+g_free(path);
+}
+
 RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,
   Error **errp)
 {
-- 
1.8.3.1




[Qemu-devel] [PATCH] target-ppc: remove MMUCFG SPR from POWER7/8 class

2013-11-18 Thread Alexey Kardashevskiy
PowerISA 2.06/2.07 put MMUCFG SPR to E (embedded) category so
remove it from POWER7/8 class as it is S (server) category.

Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
---
 target-ppc/translate_init.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index c90d1c6..96a7b2f 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7194,12 +7194,6 @@ static void init_proc_POWER7 (CPUPPCState *env)
  spr_read_generic, spr_write_generic,
  KVM_REG_PPC_PMC6, 0x);
 #endif /* !CONFIG_USER_ONLY */
-/* Memory management */
-/* XXX : not implemented */
-spr_register(env, SPR_MMUCFG, MMUCFG,
- SPR_NOACCESS, SPR_NOACCESS,
- spr_read_generic, SPR_NOACCESS,
- 0x); /* TOFIX */
 gen_spr_amr(env);
 /* XXX : not implemented */
 spr_register(env, SPR_CTRL, SPR_CTRLT,
-- 
1.8.4.rc4




Re: [Qemu-devel] [PATCH v4] ppc: introduce CPUPPCState::cpu_dt_id and CPUState::kvm_cpu_id

2013-11-18 Thread Paolo Bonzini
Il 18/11/2013 04:02, Alexey Kardashevskiy ha scritto:
 On 11/15/2013 09:40 PM, Paolo Bonzini wrote:
 Il 15/11/2013 06:14, Alexey Kardashevskiy ha scritto:

 It does not feel that we really need CPUState::kvm_cpu_id and
 direct calling of kvm_arch_vcpu_id() would be enough.

 Indeed -- and it should be kvm_ppc_vcpu_id() since other architectures
 do not need it.
 
 And ignore kvm_arch_vcpu_id() for spapr/ppc?

Sorry, brain fart - i meant ppc_get_vcpu_dt_id but it has already been
objected to earlier.  So the patch is ok for me, modulo removal of
kvm_cpu_id which you already proposed above.

Paolo




[Qemu-devel] [PATCH 4/4] net, virtio_net: replace the magic value

2013-11-18 Thread Zhi Yong Wu
From: Zhi Yong Wu wu...@linux.vnet.ibm.com

It is more appropriate to use # of queue pairs currently used by
the driver instead of a magic value.

Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com
---
 drivers/net/virtio_net.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index cdc7c90..e0cb2d1 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1619,8 +1619,8 @@ static int virtnet_probe(struct virtio_device *vdev)
if (err)
goto free_stats;
 
-   netif_set_real_num_tx_queues(dev, 1);
-   netif_set_real_num_rx_queues(dev, 1);
+   netif_set_real_num_tx_queues(dev, vi-curr_queue_pairs);
+   netif_set_real_num_rx_queues(dev, vi-curr_queue_pairs);
 
err = register_netdev(dev);
if (err) {
-- 
1.7.6.5




Re: [Qemu-devel] [PATCH v2] target-ppc: move POWER7+ to a separate family

2013-11-18 Thread Alexey Kardashevskiy
On 11/12/2013 06:18 PM, Alexey Kardashevskiy wrote:
 On 11/09/2013 11:20 AM, Alexey Kardashevskiy wrote:
 On 11/09/2013 03:59 AM, Andreas Färber wrote:
 Am 08.11.2013 15:54, schrieb Alexey Kardashevskiy:
 On 11/09/2013 12:44 AM, Andreas Färber wrote:
 Am 08.11.2013 03:37, schrieb Alexey Kardashevskiy:
 So far POWER7+ was a part of POWER7 family. However it has a different
 PVR base value so in order to support PVR masks, it needs a separate
 family class.


 Alexey,

 Another reason to make a POWER7+ family is that its name in the device
 tree (/proc/device-tree/cpus/cpu*) should be Power7+ but not Power7
 and this cannot be easily fixed without a new family class.

 This adds a new family class, PVR base and mask values and moves
 Power7+ v2.1 CPU to a new family. The class init function is copied
 from the POWER7 family.

 Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
 ---
 Changes:
 v2:
 * added VSX enable bit
 ---
  target-ppc/cpu-models.c |  2 +-
  target-ppc/cpu-models.h |  2 ++
  target-ppc/translate_init.c | 38 ++
  3 files changed, 41 insertions(+), 1 deletion(-)

 diff --git a/target-ppc/cpu-models.c b/target-ppc/cpu-models.c
 index 04d88c5..7c9466f 100644
 --- a/target-ppc/cpu-models.c
 +++ b/target-ppc/cpu-models.c
 @@ -1140,7 +1140,7 @@
  POWER7 v2.1)
  POWERPC_DEF(POWER7_v2.3,   CPU_POWERPC_POWER7_v23, 
 POWER7,
  POWER7 v2.3)
 -POWERPC_DEF(POWER7+_v2.1,  CPU_POWERPC_POWER7P_v21,
 POWER7,
 +POWERPC_DEF(POWER7+_v2.1,  CPU_POWERPC_POWER7P_v21,
 POWER7P,
  POWER7+ v2.1)
  POWERPC_DEF(POWER8_v1.0,   CPU_POWERPC_POWER8_v10, 
 POWER8,
  POWER8 v1.0)
 diff --git a/target-ppc/cpu-models.h b/target-ppc/cpu-models.h
 index 731ec4a..49ba4a4 100644
 --- a/target-ppc/cpu-models.h
 +++ b/target-ppc/cpu-models.h
 @@ -558,6 +558,8 @@ enum {
  CPU_POWERPC_POWER7_v20 = 0x003F0200,
  CPU_POWERPC_POWER7_v21 = 0x003F0201,
  CPU_POWERPC_POWER7_v23 = 0x003F0203,
 +CPU_POWERPC_POWER7P_BASE   = 0x004A,
 +CPU_POWERPC_POWER7P_MASK   = 0x,
  CPU_POWERPC_POWER7P_v21= 0x004A0201,
  CPU_POWERPC_POWER8_BASE= 0x004B,
  CPU_POWERPC_POWER8_MASK= 0x,
 diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
 index 35d1389..c030a20 100644
 --- a/target-ppc/translate_init.c
 +++ b/target-ppc/translate_init.c
 @@ -7253,6 +7253,44 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void 
 *data)
  pcc-l1_icache_size = 0x8000;
  }
  
 +POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)
 +{
 +DeviceClass *dc = DEVICE_CLASS(oc);
 +PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
 +
 +dc-fw_name = PowerPC,POWER7+;

 Apart from the commit message differing from the code...


 In what part?

 The spelling of POWER7. You write it should be Power7+ but implement
 it as upper-case POWER7+ (ignoring the PowerPC, prefix, that is).


 Ah. Sorry.


 We've had this discussion before: Jacques reported that on his POWER7+
 box only POWER7 is shown, not POWER7+, equivalent to my POWER5+ box
 showing only PowerPC,POWER5. Compare my commit, which documents this:

 http://git.qemu.org/?p=qemu.git;a=commit;h=793826cd460828975591f289de78672af4a47ef9

 So, adding a POWER7P family seems correct to me, just the fw_name seems
 wrong - or you'll need to investigate further why there are conflicting
 reports of how it is shown. Possibly based on revision or pHyp vs. SLOF?


 Yes we have had this discussion. Paul said it should POWER7+. The only
 P7+ machine I have handy shows +:

 [aik@vpl4 ~]$ ls -d /proc/device-tree/cpus/PowerPC*
 /proc/device-tree/cpus/PowerPC,POWER7+@0
 /proc/device-tree/cpus/PowerPC,POWER7+@2c
 /proc/device-tree/cpus/PowerPC,POWER7+@10
 /proc/device-tree/cpus/PowerPC,POWER7+@30
 /proc/device-tree/cpus/PowerPC,POWER7+@14
 /proc/device-tree/cpus/PowerPC,POWER7+@34
 /proc/device-tree/cpus/PowerPC,POWER7+@18
 /proc/device-tree/cpus/PowerPC,POWER7+@38
 /proc/device-tree/cpus/PowerPC,POWER7+@1c
 /proc/device-tree/cpus/PowerPC,POWER7+@3c
 /proc/device-tree/cpus/PowerPC,POWER7+@20
 /proc/device-tree/cpus/PowerPC,POWER7+@4
 /proc/device-tree/cpus/PowerPC,POWER7+@24
 /proc/device-tree/cpus/PowerPC,POWER7+@8
 /proc/device-tree/cpus/PowerPC,POWER7+@28
 /proc/device-tree/cpus/PowerPC,POWER7+@c

 And this is a host, not a guest. I do not see any good reason to make dt
 names different.

 And this does not really matter if there is + or not for anybody as far
 as we concerned, ppc64_cpu works either way.

 Right, it may not matter, but I expect you to reference the above commit
 id and explain why it should be POWER7+ after all. You failed to come up
 with that answer before that patch got applied, so we need to correct
 me/it now.

 I have checked with Dinar that under Linux using the Sapphire firmware
 PowerPC,POWER7+@0 does indeed show up in 

Re: [Qemu-devel] [PATCH 4/4] net, virtio_net: replace the magic value

2013-11-18 Thread Michael S. Tsirkin
On Mon, Nov 18, 2013 at 04:46:20PM +0800, Zhi Yong Wu wrote:
 From: Zhi Yong Wu wu...@linux.vnet.ibm.com
 
 It is more appropriate to use # of queue pairs currently used by
 the driver instead of a magic value.
 
 Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com

I don't mind, but driver should be submitted separately
from qemu patches. As it is only patch 4/4 made it to netdev.

 ---
  drivers/net/virtio_net.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
 index cdc7c90..e0cb2d1 100644
 --- a/drivers/net/virtio_net.c
 +++ b/drivers/net/virtio_net.c
 @@ -1619,8 +1619,8 @@ static int virtnet_probe(struct virtio_device *vdev)
   if (err)
   goto free_stats;
  
 - netif_set_real_num_tx_queues(dev, 1);
 - netif_set_real_num_rx_queues(dev, 1);
 + netif_set_real_num_tx_queues(dev, vi-curr_queue_pairs);
 + netif_set_real_num_rx_queues(dev, vi-curr_queue_pairs);
  
   err = register_netdev(dev);
   if (err) {
 -- 
 1.7.6.5
 



Re: [Qemu-devel] [PATCH] qemu-img: set nocow flag to new file

2013-11-18 Thread Stefan Hajnoczi
On Mon, Nov 18, 2013 at 12:54:59PM +0800, Chunyan Liu wrote:
 2013/11/15 Stefan Hajnoczi stefa...@gmail.com
 
  On Thu, Nov 14, 2013 at 04:15:28PM +0800, Chunyan Liu wrote:
   Set NOCOW flag to newly created images to solve performance issues on
  btrfs.
  
   Btrfs has terrible performance when hosting VM images, even more when
  the guest
   in those VM are also using btrfs as file system. One way to mitigate
  this bad
   performance is to turn off COW attributes on VM files (since having copy
  on
   write for this kind of data is not useful).
  
   Signed-off-by: Chunyan Liu cy...@suse.com
   ---
block/raw-posix.c |6 ++
block/vdi.c   |7 +++
block/vmdk.c  |7 +++
include/qemu-common.h |9 +
4 files changed, 29 insertions(+), 0 deletions(-)
  
   diff --git a/block/raw-posix.c b/block/raw-posix.c
   index f6d48bb..4a3e9d0 100644
   --- a/block/raw-posix.c
   +++ b/block/raw-posix.c
   @@ -1072,6 +1072,12 @@ static int raw_create(const char *filename,
  QEMUOptionParameter *options,
result = -errno;
error_setg_errno(errp, -result, Could not create file);
} else {
   +#ifdef __linux__
   +/* set NOCOW flag to solve performance issue on fs like btrfs */
   +int attr;
   +attr = FS_NOCOW_FL;
   +ioctl(fd, FS_IOC_SETFLAGS, attr);
   +#endif
  This should be optional and I'm not sure it should be the default.
 
  Rationale: If you're on btrfs you probably expect the copy-on-write and
  snapshot features of the file system.  We shouldn't silently disable
  that unless the user asks for it.
 
 
 The problem is: if users want to use copy-on-write (e.g, for snapshotting)
 and
 don't care about performance degrade, they still be able to issue chattr
 to
 change it to be COW. However, if a file is created as COW, but later users
 care
 about performance, there is no way to switch to NOCOW per file. NOCOW
 should be
 set to new or empty file only on btrfs.

When the NOCOW attribute is set on a file, reflink copying (aka
file-level snapshots) do not work:

$ cp --reflink test.img test-snapshot.img

This produces EINVAL.

It is a regression if qemu-img create suddenly starts breaking this
standard btrfs feature for existing users.

Please make it a .bdrv_create() option which is off by default to avoid
breaking existing users' workflows/scripts.  The result should be
something like:

$ qemu-img create test.img 8G # file has NOCOW cleared
$ qemu-img create -o nocow=on test.img 8G # file has NOCOW set

Stefan



Re: [Qemu-devel] [PATCH 4/4] net, virtio_net: replace the magic value

2013-11-18 Thread Zhi Yong Wu
On Mon, Nov 18, 2013 at 5:50 PM, Michael S. Tsirkin m...@redhat.com wrote:
 On Mon, Nov 18, 2013 at 04:46:20PM +0800, Zhi Yong Wu wrote:
 From: Zhi Yong Wu wu...@linux.vnet.ibm.com

 It is more appropriate to use # of queue pairs currently used by
 the driver instead of a magic value.

 Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com

 I don't mind, but driver should be submitted separately
 from qemu patches. As it is only patch 4/4 made it to netdev.
ok, i will sent v2. By the way, can you help take a look at the
following patches? Maybe i can send their v2 together.
[PATCH 1/3] vhost: remove the dead branch
[PATCH 2/3] vhost: adjust vhost_dev_init() to be void
[PATCH 3/3] vhost: fix the wrong log descriptions



 ---
  drivers/net/virtio_net.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

 diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
 index cdc7c90..e0cb2d1 100644
 --- a/drivers/net/virtio_net.c
 +++ b/drivers/net/virtio_net.c
 @@ -1619,8 +1619,8 @@ static int virtnet_probe(struct virtio_device *vdev)
   if (err)
   goto free_stats;

 - netif_set_real_num_tx_queues(dev, 1);
 - netif_set_real_num_rx_queues(dev, 1);
 + netif_set_real_num_tx_queues(dev, vi-curr_queue_pairs);
 + netif_set_real_num_rx_queues(dev, vi-curr_queue_pairs);

   err = register_netdev(dev);
   if (err) {
 --
 1.7.6.5




-- 
Regards,

Zhi Yong Wu



Re: [Qemu-devel] [PATCH 4/4] net, virtio_net: replace the magic value

2013-11-18 Thread Michael S. Tsirkin
On Mon, Nov 18, 2013 at 06:07:45PM +0800, Zhi Yong Wu wrote:
 On Mon, Nov 18, 2013 at 5:50 PM, Michael S. Tsirkin m...@redhat.com wrote:
  On Mon, Nov 18, 2013 at 04:46:20PM +0800, Zhi Yong Wu wrote:
  From: Zhi Yong Wu wu...@linux.vnet.ibm.com
 
  It is more appropriate to use # of queue pairs currently used by
  the driver instead of a magic value.
 
  Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com
 
  I don't mind, but driver should be submitted separately
  from qemu patches. As it is only patch 4/4 made it to netdev.
 ok, i will sent v2. By the way, can you help take a look at the
 following patches?

Will do.

 Maybe i can send their v2 together.

Please don't, these seem to be completely unrelated.

 [PATCH 1/3] vhost: remove the dead branch
 [PATCH 2/3] vhost: adjust vhost_dev_init() to be void
 [PATCH 3/3] vhost: fix the wrong log descriptions
 
 
 
  ---
   drivers/net/virtio_net.c |4 ++--
   1 files changed, 2 insertions(+), 2 deletions(-)
 
  diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
  index cdc7c90..e0cb2d1 100644
  --- a/drivers/net/virtio_net.c
  +++ b/drivers/net/virtio_net.c
  @@ -1619,8 +1619,8 @@ static int virtnet_probe(struct virtio_device *vdev)
if (err)
goto free_stats;
 
  - netif_set_real_num_tx_queues(dev, 1);
  - netif_set_real_num_rx_queues(dev, 1);
  + netif_set_real_num_tx_queues(dev, vi-curr_queue_pairs);
  + netif_set_real_num_rx_queues(dev, vi-curr_queue_pairs);
 
err = register_netdev(dev);
if (err) {
  --
  1.7.6.5
 
 
 
 
 -- 
 Regards,
 
 Zhi Yong Wu



Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Claudio Fontana
Hello,

On 09/27/2013 08:25 PM, Richard Henderson wrote:
 On 09/26/2013 05:48 PM, Alexander Graf wrote:
 This patch adds emulation support for the orr instruction.

 Signed-off-by: Alexander Graf ag...@suse.de
 ---
  target-arm/helper-a64.c|  28 +++
  target-arm/helper-a64.h|   1 +
  target-arm/translate-a64.c | 120 
 +
  3 files changed, 149 insertions(+)

 diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
 index 8105fb5..da72b7f 100644
 --- a/target-arm/helper-a64.c
 +++ b/target-arm/helper-a64.c
 @@ -24,3 +24,31 @@
  #include sysemu/sysemu.h
  #include qemu/bitops.h
  
 +uint32_t HELPER(pstate_add)(uint32_t pstate, uint64_t a1, uint64_t a2,
 +uint64_t ar)
 +{
 +int64_t s1 = a1;
 +int64_t s2 = a2;
 +int64_t sr = ar;
 +
 +pstate = ~(PSTATE_N | PSTATE_Z | PSTATE_C | PSTATE_V);
 +
 +if (sr  0) {
 +pstate |= PSTATE_N;
 +}
 +
 +if (!ar) {
 +pstate |= PSTATE_Z;
 +}
 +
 +if (ar  (ar  a1)) {
 +pstate |= PSTATE_C;
 +}
 +
 +if ((s1  0  s2  0  sr  0) ||
 +(s1  0  s2  0  sr  0)) {
 +pstate |= PSTATE_V;
 +}
 +
 +return pstate;
 +}
 
 Why are you not using the same split apart bits as A32?
 
 +/* XXX carry_out */
 +switch (shift_type) {
 
 What carry out?  I see no such in the ShiftReg description.
 
 +case 3:
 +tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
 +break;
 
 Incorrect rotate for 32bit?
 
 +static void handle_orr(DisasContext *s, uint32_t insn)
 +{
 +int is_32bit = !get_bits(insn, 31, 1);
 +int dest = get_reg(insn);
 +int source = get_bits(insn, 5, 5);
 +int rm = get_bits(insn, 16, 5);
 +int shift_amount = get_sbits(insn, 10, 6);
 +int is_n = get_bits(insn, 21, 1);
 +int shift_type = get_bits(insn, 22, 2);
 +int opc = get_bits(insn, 29, 2);
 +bool setflags = (opc == 0x3);
 +TCGv_i64 tcg_op2;
 +TCGv_i64 tcg_dest;
 +
 +if (is_32bit  (shift_amount  0)) {
 +/* reserved value */
 +unallocated_encoding(s);
 +}
 
 Why are you extracting shift_amount signed?
 
 +
 +/* MOV is dest = xzr  (source  ~0) */
 
 Comment is wrong.
 
 +if (!shift_amount  source == 0x1f) {

Besides the comment, is this correct?
I am trying to rework this patch, but this part seems incorrect to me.

We land here for the AND as well, and if source(rn) is xzr,
then I would expect the result to be zero for AND regardless of anything else,
and not a MOV.

Can we really do this optimization in general here for AND, OR, EOR?

Thanks for any clarification,

Claudio

 +if (is_32bit) {
 +tcg_gen_ext32u_i64(cpu_reg_sp(dest), cpu_reg(rm));
 +} else {
 +tcg_gen_mov_i64(cpu_reg_sp(dest), cpu_reg(rm));
 +}
 +if (is_n) {
 +tcg_gen_not_i64(cpu_reg_sp(dest), cpu_reg_sp(dest));
 +}
 +if (is_32bit) {
 +tcg_gen_ext32u_i64(cpu_reg_sp(dest), cpu_reg_sp(dest));
 +}
 
 These are incorrect -- no sp in the logical ops, but xzr instead.
 
 And surely we can emit fewer opcodes for the simple cases here.
 Since these are the canonical aliases for mov/mvn, it'll pay off.
 
 TCGv src = cpu_reg(rm);
 TCGv dst = cpu_reg(rd);
 
 if (is_n) {
 tcg_gen_not_i64(dst, src);
 src = dst;
 }
 if (is_32bit) {
 tcg_gen_ext32u_i64(dst, src);
 } else {
 tcg_gen_mov_i64(dst, src);
 }
 
 Note that tcg_gen_mov_i64 does the src == dst check, so a simple
 64-bit mvn will only emit the not.
 
 
 +tcg_dest = cpu_reg(dest);
 +switch (opc) {
 +case 0x0:
 +case 0x3:
 +tcg_gen_and_i64(tcg_dest, cpu_reg(source), tcg_op2);
 +break;
 +case 0x1:
 +tcg_gen_or_i64(tcg_dest, cpu_reg(source), tcg_op2);
 +break;
 +case 0x2:
 +tcg_gen_xor_i64(tcg_dest, cpu_reg(source), tcg_op2);
 +break;
 +}
 +
 +if (is_32bit) {
 +tcg_gen_ext32u_i64(tcg_dest, tcg_dest);
 +}
 +
 +if (setflags) {
 +gen_helper_pstate_add(pstate, pstate, tcg_dest, cpu_reg(31), 
 tcg_dest);
 +}
 
 Incorrect flags generated.  They're different between add/sub and logical.
 In particular, C and V are always zero.
 
 +handle_orr(s, insn);
 
 And please use a more proper name than ORR for something that handles all
 of the logical insns.
 
 
 r~
 




Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Laurent Desnogues
On Mon, Nov 18, 2013 at 11:15 AM, Claudio Fontana
claudio.font...@linaro.org wrote:
 Hello,

 On 09/27/2013 08:25 PM, Richard Henderson wrote:
 On 09/26/2013 05:48 PM, Alexander Graf wrote:
 This patch adds emulation support for the orr instruction.

 Signed-off-by: Alexander Graf ag...@suse.de
 ---
  target-arm/helper-a64.c|  28 +++
  target-arm/helper-a64.h|   1 +
  target-arm/translate-a64.c | 120 
 +
  3 files changed, 149 insertions(+)

 diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
 index 8105fb5..da72b7f 100644
 --- a/target-arm/helper-a64.c
 +++ b/target-arm/helper-a64.c
 @@ -24,3 +24,31 @@
  #include sysemu/sysemu.h
  #include qemu/bitops.h

 +uint32_t HELPER(pstate_add)(uint32_t pstate, uint64_t a1, uint64_t a2,
 +uint64_t ar)
 +{
 +int64_t s1 = a1;
 +int64_t s2 = a2;
 +int64_t sr = ar;
 +
 +pstate = ~(PSTATE_N | PSTATE_Z | PSTATE_C | PSTATE_V);
 +
 +if (sr  0) {
 +pstate |= PSTATE_N;
 +}
 +
 +if (!ar) {
 +pstate |= PSTATE_Z;
 +}
 +
 +if (ar  (ar  a1)) {
 +pstate |= PSTATE_C;
 +}
 +
 +if ((s1  0  s2  0  sr  0) ||
 +(s1  0  s2  0  sr  0)) {
 +pstate |= PSTATE_V;
 +}
 +
 +return pstate;
 +}

 Why are you not using the same split apart bits as A32?

 +/* XXX carry_out */
 +switch (shift_type) {

 What carry out?  I see no such in the ShiftReg description.

 +case 3:
 +tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
 +break;

 Incorrect rotate for 32bit?

 +static void handle_orr(DisasContext *s, uint32_t insn)
 +{
 +int is_32bit = !get_bits(insn, 31, 1);
 +int dest = get_reg(insn);
 +int source = get_bits(insn, 5, 5);
 +int rm = get_bits(insn, 16, 5);
 +int shift_amount = get_sbits(insn, 10, 6);
 +int is_n = get_bits(insn, 21, 1);
 +int shift_type = get_bits(insn, 22, 2);
 +int opc = get_bits(insn, 29, 2);
 +bool setflags = (opc == 0x3);
 +TCGv_i64 tcg_op2;
 +TCGv_i64 tcg_dest;
 +
 +if (is_32bit  (shift_amount  0)) {
 +/* reserved value */
 +unallocated_encoding(s);
 +}

 Why are you extracting shift_amount signed?

 +
 +/* MOV is dest = xzr  (source  ~0) */

 Comment is wrong.

 +if (!shift_amount  source == 0x1f) {

 Besides the comment, is this correct?
 I am trying to rework this patch, but this part seems incorrect to me.

 We land here for the AND as well, and if source(rn) is xzr,
 then I would expect the result to be zero for AND regardless of anything else,
 and not a MOV.

 Can we really do this optimization in general here for AND, OR, EOR?

That part is definitely wrong:  there's a missing check that opc = 1
(ORR/ORN for MOV/MVN).  The comment also is very wrong :-)

Also note that SP can't be accessed by the shifted reg logical ops as
Richard wrote.


Laurent

 Thanks for any clarification,

 Claudio

 +if (is_32bit) {
 +tcg_gen_ext32u_i64(cpu_reg_sp(dest), cpu_reg(rm));
 +} else {
 +tcg_gen_mov_i64(cpu_reg_sp(dest), cpu_reg(rm));
 +}
 +if (is_n) {
 +tcg_gen_not_i64(cpu_reg_sp(dest), cpu_reg_sp(dest));
 +}
 +if (is_32bit) {
 +tcg_gen_ext32u_i64(cpu_reg_sp(dest), cpu_reg_sp(dest));
 +}

 These are incorrect -- no sp in the logical ops, but xzr instead.

 And surely we can emit fewer opcodes for the simple cases here.
 Since these are the canonical aliases for mov/mvn, it'll pay off.

 TCGv src = cpu_reg(rm);
 TCGv dst = cpu_reg(rd);

 if (is_n) {
 tcg_gen_not_i64(dst, src);
 src = dst;
 }
 if (is_32bit) {
 tcg_gen_ext32u_i64(dst, src);
 } else {
 tcg_gen_mov_i64(dst, src);
 }

 Note that tcg_gen_mov_i64 does the src == dst check, so a simple
 64-bit mvn will only emit the not.


 +tcg_dest = cpu_reg(dest);
 +switch (opc) {
 +case 0x0:
 +case 0x3:
 +tcg_gen_and_i64(tcg_dest, cpu_reg(source), tcg_op2);
 +break;
 +case 0x1:
 +tcg_gen_or_i64(tcg_dest, cpu_reg(source), tcg_op2);
 +break;
 +case 0x2:
 +tcg_gen_xor_i64(tcg_dest, cpu_reg(source), tcg_op2);
 +break;
 +}
 +
 +if (is_32bit) {
 +tcg_gen_ext32u_i64(tcg_dest, tcg_dest);
 +}
 +
 +if (setflags) {
 +gen_helper_pstate_add(pstate, pstate, tcg_dest, cpu_reg(31), 
 tcg_dest);
 +}

 Incorrect flags generated.  They're different between add/sub and logical.
 In particular, C and V are always zero.

 +handle_orr(s, insn);

 And please use a more proper name than ORR for something that handles all
 of the logical insns.


 r~





[Qemu-devel] [Bug 1245924] Re: mips64el magnum emulation broken

2013-11-18 Thread Darkstar
I just tried with the 1-line-patch referenced in the link above and it
does indeed fix the black screen problem.

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

Title:
  mips64el magnum emulation broken

Status in QEMU:
  New

Bug description:
  I'm trying to run the following:
  qemu-system-mips64el --machine magnum [...]

  The qemu binaries from (k)ubuntu work fine. info version shows
  1.5.0 (Debian 1.5.0+dfsg-3ubuntu5)

  When I try qemu 1.6.1 (compiled from source .tar.bz2), however, qemu
  only shows a black screen when starting.

  I'm using the following BIOS:
  https://mega.co.nz/#!gg0WBYpJ!MqTL3AFPjf4SJipdYgRK3HtFDIxA59YwI6ay5XI3KEc
  which is the exact one linked to in the first guide below (can also be 
downloaded from there)

  I'm following these guides on installing NT4 on qemu
  http://gunkies.org/wiki/Installing_Windows_NT_4.0_on_Qemu(MIPS)
  http://virtuallyfun.superglobalmegacorp.com/?p=2255

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



[Qemu-devel] [PATCH] Fix processing of the MMU faults caused by the helper functions

2013-11-18 Thread Pavel Dovgaluk
MMU helper functions are called from generated code and other helper 
functions. In both cases they try to get function's return address for
using it while restoring virtual CPU state.

When MMU helper is called from some other helper function 
(like helper_maskmov_xmm) through cpu_st* function, the return address
will point to that helper. That is why CPU state cannot be restored in
the case of MMU fault.

This patch introduces several inline helpers to load return address
at the right place.

Signed-off-by: Pavel Dovgaluk pavel.dovga...@gmail.com
---
 include/exec/exec-all.h |   27 +++
 include/exec/softmmu_header.h   |   32 
 include/exec/softmmu_template.h |   18 ++
 3 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index ea90b64..010c9ba 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -338,6 +338,33 @@ uint16_t helper_ldw_cmmu(CPUArchState *env, target_ulong 
addr, int mmu_idx);
 uint32_t helper_ldl_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
 uint64_t helper_ldq_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
 
+uint8_t helper_call_ldb_cmmu(CPUArchState *env, target_ulong addr,
+ int mmu_idx, uintptr_t retaddr);
+uint16_t helper_call_ldw_cmmu(CPUArchState *env, target_ulong addr,
+  int mmu_idx, uintptr_t retaddr);
+uint32_t helper_call_ldl_cmmu(CPUArchState *env, target_ulong addr,
+  int mmu_idx, uintptr_t retaddr);
+uint64_t helper_call_ldq_cmmu(CPUArchState *env, target_ulong addr,
+  int mmu_idx, uintptr_t retaddr);
+
+uint8_t helper_call_ldb_mmu(CPUArchState *env, target_ulong addr,
+int mmu_idx, uintptr_t retaddr);
+uint16_t helper_call_ldw_mmu(CPUArchState *env, target_ulong addr,
+ int mmu_idx, uintptr_t retaddr);
+uint32_t helper_call_ldl_mmu(CPUArchState *env, target_ulong addr,
+ int mmu_idx, uintptr_t retaddr);
+uint64_t helper_call_ldq_mmu(CPUArchState *env, target_ulong addr,
+ int mmu_idx, uintptr_t retaddr);
+
+void helper_call_stb_mmu(CPUArchState *env, target_ulong addr,
+ uint8_t val, int mmu_idx, uintptr_t retaddr);
+void helper_call_stw_mmu(CPUArchState *env, target_ulong addr,
+ uint16_t val, int mmu_idx, uintptr_t retaddr);
+void helper_call_stl_mmu(CPUArchState *env, target_ulong addr,
+ uint32_t val, int mmu_idx, uintptr_t retaddr);
+void helper_call_stq_mmu(CPUArchState *env, target_ulong addr,
+ uint64_t val, int mmu_idx, uintptr_t retaddr);
+
 #define ACCESS_TYPE (NB_MMU_MODES + 1)
 #define MEMSUFFIX _code
 
diff --git a/include/exec/softmmu_header.h b/include/exec/softmmu_header.h
index d8d9c81..954b79e 100644
--- a/include/exec/softmmu_header.h
+++ b/include/exec/softmmu_header.h
@@ -78,6 +78,17 @@
 #define ADDR_READ addr_read
 #endif
 
+/* inline helper ld function */
+
+static inline DATA_TYPE
+glue(glue(helper_inline_ld, SUFFIX), MEMSUFFIX)(CPUArchState *env,
+target_ulong addr,
+int mmu_idx)
+{
+return glue(glue(helper_call_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx,
+ GETRA());
+}
+
 /* generic load/store macros */
 
 static inline RES_TYPE
@@ -93,7 +104,8 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, 
target_ulong ptr)
 mmu_idx = CPU_MMU_INDEX;
 if (unlikely(env-tlb_table[mmu_idx][page_index].ADDR_READ !=
  (addr  (TARGET_PAGE_MASK | (DATA_SIZE - 1) {
-res = glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx);
+res = glue(glue(helper_inline_ld, SUFFIX),
+   MEMSUFFIX)(env, addr, mmu_idx);
 } else {
 uintptr_t hostaddr = addr + env-tlb_table[mmu_idx][page_index].addend;
 res = glue(glue(ld, USUFFIX), _raw)(hostaddr);
@@ -114,8 +126,8 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, 
target_ulong ptr)
 mmu_idx = CPU_MMU_INDEX;
 if (unlikely(env-tlb_table[mmu_idx][page_index].ADDR_READ !=
  (addr  (TARGET_PAGE_MASK | (DATA_SIZE - 1) {
-res = (DATA_STYPE)glue(glue(helper_ld, SUFFIX),
-   MMUSUFFIX)(env, addr, mmu_idx);
+res = (DATA_STYPE)glue(glue(helper_inline_ld, SUFFIX),
+   MEMSUFFIX)(env, addr, mmu_idx);
 } else {
 uintptr_t hostaddr = addr + env-tlb_table[mmu_idx][page_index].addend;
 res = glue(glue(lds, SUFFIX), _raw)(hostaddr);
@@ -126,6 +138,18 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, 
target_ulong ptr)
 
 #if ACCESS_TYPE != (NB_MMU_MODES + 1)
 
+/* 

Re: [Qemu-devel] [PATCH] doc: fix hardcode helper path

2013-11-18 Thread Michael S. Tsirkin
On Wed, Oct 23, 2013 at 04:49:28AM +0800, Amos Kong wrote:
 The install directory of qemu-bridge-helper is configurabled,
 but we used a fixed path in document.
 
 DEFAULT_BRIDGE_HELPER macro isn't available in texi mode,
 we always use /path/to/ prefix for dynamic path (eg:
 /path/to/image, /path/to/linux, etc).
 
 Signed-off-by: Amos Kong ak...@redhat.com

Applied, thanks.

 ---
  qemu-options.hx | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/qemu-options.hx b/qemu-options.hx
 index 5dc8b75..8b94264 100644
 --- a/qemu-options.hx
 +++ b/qemu-options.hx
 @@ -1605,7 +1605,7 @@ to disable script execution.
  
  If running QEMU as an unprivileged user, use the network helper
  @var{helper} to configure the TAP interface. The default network
 -helper executable is @file{/usr/local/libexec/qemu-bridge-helper}.
 +helper executable is @file{/path/to/qemu-bridge-helper}.
  
  @option{fd}=@var{h} can be used to specify the handle of an already
  opened host TAP interface.
 @@ -1629,7 +1629,7 @@ qemu-system-i386 linux.img \
  #launch a QEMU instance with the default network helper to
  #connect a TAP device to bridge br0
  qemu-system-i386 linux.img \
 - -net nic -net 
 tap,helper=/usr/local/libexec/qemu-bridge-helper
 + -net nic -net tap,helper=/path/to/qemu-bridge-helper
  @end example
  
  @item -netdev bridge,id=@var{id}[,br=@var{bridge}][,helper=@var{helper}]
 @@ -1638,7 +1638,7 @@ Connect a host TAP network interface to a host bridge 
 device.
  
  Use the network helper @var{helper} to configure the TAP interface and
  attach it to the bridge. The default network helper executable is
 -@file{/usr/local/libexec/qemu-bridge-helper} and the default bridge
 +@file{/path/to/qemu-bridge-helper} and the default bridge
  device is @file{br0}.
  
  Examples:
 -- 
 1.8.3.1
 



[Qemu-devel] [PULL for-1.8 2/2] doc: fix hardcoded helper path

2013-11-18 Thread Michael S. Tsirkin
From: Amos Kong ak...@redhat.com

The install directory of qemu-bridge-helper is configurable,
but we use a fixed path in the documentation.

DEFAULT_BRIDGE_HELPER macro isn't available in texi mode,
we should always use /path/to/ prefix for dynamic paths
(e.g.: /path/to/image, /path/to/linux, etc).

Signed-off-by: Amos Kong ak...@redhat.com
Reviewed-by: Stefan Hajnoczi stefa...@redhat.com
Signed-off-by: Michael S. Tsirkin m...@redhat.com
---
 qemu-options.hx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 5dc8b75..8b94264 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1605,7 +1605,7 @@ to disable script execution.
 
 If running QEMU as an unprivileged user, use the network helper
 @var{helper} to configure the TAP interface. The default network
-helper executable is @file{/usr/local/libexec/qemu-bridge-helper}.
+helper executable is @file{/path/to/qemu-bridge-helper}.
 
 @option{fd}=@var{h} can be used to specify the handle of an already
 opened host TAP interface.
@@ -1629,7 +1629,7 @@ qemu-system-i386 linux.img \
 #launch a QEMU instance with the default network helper to
 #connect a TAP device to bridge br0
 qemu-system-i386 linux.img \
- -net nic -net 
tap,helper=/usr/local/libexec/qemu-bridge-helper
+ -net nic -net tap,helper=/path/to/qemu-bridge-helper
 @end example
 
 @item -netdev bridge,id=@var{id}[,br=@var{bridge}][,helper=@var{helper}]
@@ -1638,7 +1638,7 @@ Connect a host TAP network interface to a host bridge 
device.
 
 Use the network helper @var{helper} to configure the TAP interface and
 attach it to the bridge. The default network helper executable is
-@file{/usr/local/libexec/qemu-bridge-helper} and the default bridge
+@file{/path/to/qemu-bridge-helper} and the default bridge
 device is @file{br0}.
 
 Examples:
-- 
MST




[Qemu-devel] [PULL for-1.8 1/2] pc: disable pci-info

2013-11-18 Thread Michael S. Tsirkin
From: Igor Mammedov imamm...@redhat.com

The BIOS that we ship in 1.7 does not use pci info
from host and so far isn't going to use it.
Taking in account problems it caused see 9604f70fdf and
to avoid future incompatibility issues, it's safest to
disable that interface by default for all machine types
including 1.7 as it was never exposed/used by guest.
And properly remove/cleanup it during 1.8 development cycle.

Signed-off-by: Igor Mammedov imamm...@redhat.com
Reviewed-by: Gerd Hoffmann kra...@redhat.com
Reviewed-by: Michael S. Tsirkin m...@redhat.com
Reviewed-by: Eduardo Habkost ehabk...@redhat.com
Signed-off-by: Michael S. Tsirkin m...@redhat.com
---
 hw/i386/pc_piix.c | 2 +-
 hw/i386/pc_q35.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 4fdb7b6..094c421 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -58,7 +58,7 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 
 static bool has_pvpanic;
-static bool has_pci_info = true;
+static bool has_pci_info;
 static bool has_acpi_build = true;
 
 /* PC hardware initialisation */
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 4c191d3..1af8e2b 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -48,7 +48,7 @@
 #define MAX_SATA_PORTS 6
 
 static bool has_pvpanic;
-static bool has_pci_info = true;
+static bool has_pci_info;
 static bool has_acpi_build = true;
 
 /* PC hardware initialisation */
-- 
MST




[Qemu-devel] [PULL for-1.8 0/2] pc last minute fixes for 1.8

2013-11-18 Thread Michael S. Tsirkin
The following changes since commit 5c5432e7d630592ddcc1876ac8a1505f8f14ef15:

  Merge remote-tracking branch 'luiz/queue/qmp' into staging (2013-11-13 
11:49:27 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony

for you to fetch changes up to 420508fbba2a6e8eaff008715b5f7eff83f8e865:

  doc: fix hardcoded helper path (2013-11-18 13:45:10 +0200)


pc last minute fixes for 1.8

This has a patch that drops an unused FW CFG entry.
I think it's best to include it before 1.7 to avoid
the need to maintain it in compat machine types.

There's also a doc bugfix by Amos: I'm guessing
doc fixes are still fair game even at this late stage.

Signed-off-by: Michael S. Tsirkin m...@redhat.com



Amos Kong (1):
  doc: fix hardcoded helper path

Igor Mammedov (1):
  pc: disable pci-info

 hw/i386/pc_piix.c | 2 +-
 hw/i386/pc_q35.c  | 2 +-
 qemu-options.hx   | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

-- 
MST




[Qemu-devel] [Bug 1245924] Re: mips64el magnum emulation broken

2013-11-18 Thread Peter Maydell
That's more of a workaround than a fix. Herve's patch:
 http://lists.gnu.org/archive/html/qemu-devel/2013-11/msg00296.html
is more the right approach I suspect.

(I'm not sure why his email didn't get recorded in this bug; it seems to
have been on the cc.)

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

Title:
  mips64el magnum emulation broken

Status in QEMU:
  New

Bug description:
  I'm trying to run the following:
  qemu-system-mips64el --machine magnum [...]

  The qemu binaries from (k)ubuntu work fine. info version shows
  1.5.0 (Debian 1.5.0+dfsg-3ubuntu5)

  When I try qemu 1.6.1 (compiled from source .tar.bz2), however, qemu
  only shows a black screen when starting.

  I'm using the following BIOS:
  https://mega.co.nz/#!gg0WBYpJ!MqTL3AFPjf4SJipdYgRK3HtFDIxA59YwI6ay5XI3KEc
  which is the exact one linked to in the first guide below (can also be 
downloaded from there)

  I'm following these guides on installing NT4 on qemu
  http://gunkies.org/wiki/Installing_Windows_NT_4.0_on_Qemu(MIPS)
  http://virtuallyfun.superglobalmegacorp.com/?p=2255

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



[Qemu-devel] [PATCH 00/21] RFCv2: add Spice block device

2013-11-18 Thread Marc-André Lureau
Hi,

The following patch series implement a Spice block device, which
allows the client to redirect a block device using the NBD protocol,
which greatly simplifies the Spice code by reusing an existing
protocol, and allows sharing existing qemu NBD implementation.

The backend only support read-only device atm (although it shouldn't
be hard to add write support if necessary)

Usage with a CDROM drive:
 -device ide-cd,drive=cd -drive if=none,id=cd,readonly,file=spicebd:

The associated server and client bits are:
http://lists.freedesktop.org/archives/spice-devel/2013-June/013608.html
http://lists.freedesktop.org/archives/spice-devel/2013-November/015452.html
http://lists.freedesktop.org/archives/spice-devel/2013-November/015431.html

Caveats: This block device driver is a bit special, since it is
successfully initialized with size 0, and once the client is connected
(or want to change block device) it re-opens itself. For this to work,
we allow a block driver to be open with an existing opaque data. We
also save the associate device name in the block drivers.

During migration, the source needs to be able to flush pending
operations, so the Spice channel context must be in a running loop. A
modification to the Spice server API allows to associate a particular
channel with the AIO loop, and may be used in the future to associate
channels with different context or athreads. However, the AIO context
doesn't have timers yet. Since they aren't really needed for the NBD
channel, it's not a problem. I have been told timers in AIO are on
their way, so this could be updated later.

Since the block driver state is not migrated, the destination needs to
wait until the block driver is initialized before the VM can run. This
is done with a simple hold count. It is also necessary to avoid extra
media changed notifications, which is easily done by checking
migration state.


Marc-André Lureau (21):
  vscclient: do not add a socket watch if there is not data to send
  spice-char: remove unused field
  qmp_change_blockdev() remove unused has_format
  include: add missing config-host.h include
  char: add qemu_chr_fe_event()
  Split nbd block client code
  nbd: don't change socket block during negotiate
  nbd: pass export name as init argument
  nbd: make session_close() idempotent
  nbd: finish any pending coroutine
  nbd: avoid uninitialized warnings
  block: save the associated child name in BlockDriverState
  blockdev: add qmp_change_blockdev_int()
  block: extract make_snapshot() from bdrv_open()
  block: add snapshot.size option to avoid extra bdrv_open()
  block: learn to open a driver with a given opaque
  block: allow to call bdrv_open() with an opaque
  block: do not notify change during migration
  sysemu: add vm_start_hold/release
  spice-core: allow an interface to be in AIO context
  block: add spice block device backend

 block.c   | 225 ---
 block/Makefile.objs   |   3 +-
 block/nbd-client.c| 384 +
 block/nbd-client.h|  50 +
 block/nbd.c   | 380 +++-
 block/spicebd.c   | 536 ++
 blockdev.c|  24 ++-
 hw/block/fdc.c|   8 +-
 hw/ide/core.c |  12 +-
 hw/scsi/scsi-disk.c   |  11 +-
 hw/sd/sd.c|   6 +-
 include/block/block.h |   2 +-
 include/block/block_int.h |   1 +
 include/sysemu/blockdev.h |   5 +-
 include/sysemu/char.h |  10 +
 include/sysemu/sysemu.h   |   2 +
 include/ui/qemu-spice.h   |   4 +-
 libcacard/vscclient.c |  10 +-
 nbd.c |   1 -
 qemu-char.c   |   9 +-
 qmp.c |   2 +-
 spice-qemu-char.c |  20 +-
 stubs/vm-stop.c   |   5 +
 ui/spice-core.c   |  62 +-
 vl.c  |  17 ++
 25 files changed, 1320 insertions(+), 469 deletions(-)
 create mode 100644 block/nbd-client.c
 create mode 100644 block/nbd-client.h
 create mode 100644 block/spicebd.c

-- 
1.8.3.1




Re: [Qemu-devel] [PATCH 4/4] net, virtio_net: replace the magic value

2013-11-18 Thread Zhi Yong Wu
On Mon, Nov 18, 2013 at 6:15 PM, Michael S. Tsirkin m...@redhat.com wrote:
 On Mon, Nov 18, 2013 at 06:07:45PM +0800, Zhi Yong Wu wrote:
 On Mon, Nov 18, 2013 at 5:50 PM, Michael S. Tsirkin m...@redhat.com wrote:
  On Mon, Nov 18, 2013 at 04:46:20PM +0800, Zhi Yong Wu wrote:
  From: Zhi Yong Wu wu...@linux.vnet.ibm.com
 
  It is more appropriate to use # of queue pairs currently used by
  the driver instead of a magic value.
 
  Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com
 
  I don't mind, but driver should be submitted separately
  from qemu patches. As it is only patch 4/4 made it to netdev.
 ok, i will sent v2. By the way, can you help take a look at the
 following patches?

 Will do.

 Maybe i can send their v2 together.

 Please don't, these seem to be completely unrelated.
OK, i will send it separately.

 [PATCH 1/3] vhost: remove the dead branch
 [PATCH 2/3] vhost: adjust vhost_dev_init() to be void
 [PATCH 3/3] vhost: fix the wrong log descriptions


 
  ---
   drivers/net/virtio_net.c |4 ++--
   1 files changed, 2 insertions(+), 2 deletions(-)
 
  diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
  index cdc7c90..e0cb2d1 100644
  --- a/drivers/net/virtio_net.c
  +++ b/drivers/net/virtio_net.c
  @@ -1619,8 +1619,8 @@ static int virtnet_probe(struct virtio_device *vdev)
if (err)
goto free_stats;
 
  - netif_set_real_num_tx_queues(dev, 1);
  - netif_set_real_num_rx_queues(dev, 1);
  + netif_set_real_num_tx_queues(dev, vi-curr_queue_pairs);
  + netif_set_real_num_rx_queues(dev, vi-curr_queue_pairs);
 
err = register_netdev(dev);
if (err) {
  --
  1.7.6.5
 



 --
 Regards,

 Zhi Yong Wu



-- 
Regards,

Zhi Yong Wu



[Qemu-devel] [PATCH 01/21] vscclient: do not add a socket watch if there is not data to send

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Fixes the following error:
** (process:780): CRITICAL **: do_socket_send: assertion
`socket_to_send-len != 0' failed

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 libcacard/vscclient.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index a3cb776..c413a4f 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -58,7 +58,7 @@ static QemuMutex socket_to_send_lock;
 static guint socket_tag;
 
 static void
-update_socket_watch(gboolean out);
+update_socket_watch(void);
 
 static gboolean
 do_socket_send(GIOChannel *source,
@@ -80,7 +80,7 @@ do_socket_send(GIOChannel *source,
 g_byte_array_remove_range(socket_to_send, 0, bw);
 
 if (socket_to_send-len == 0) {
-update_socket_watch(FALSE);
+update_socket_watch();
 return FALSE;
 }
 return TRUE;
@@ -89,7 +89,7 @@ do_socket_send(GIOChannel *source,
 static gboolean
 socket_prepare_sending(gpointer user_data)
 {
-update_socket_watch(TRUE);
+update_socket_watch();
 
 return FALSE;
 }
@@ -440,8 +440,10 @@ do_socket(GIOChannel *source,
 }
 
 static void
-update_socket_watch(gboolean out)
+update_socket_watch(void)
 {
+gboolean out = socket_to_send-len  0;
+
 if (socket_tag != 0) {
 g_source_remove(socket_tag);
 }
-- 
1.8.3.1




[Qemu-devel] [PATCH 03/21] qmp_change_blockdev() remove unused has_format

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
---
 blockdev.c| 2 +-
 include/sysemu/blockdev.h | 2 +-
 qmp.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 86e6bff..b8db544 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1524,7 +1524,7 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, 
const char *filename,
 }
 
 void qmp_change_blockdev(const char *device, const char *filename,
- bool has_format, const char *format, Error **errp)
+ const char *format, Error **errp)
 {
 BlockDriverState *bs;
 BlockDriver *drv = NULL;
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index 1082091..134712b 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -64,7 +64,7 @@ DriveInfo *drive_init(QemuOpts *arg, BlockInterfaceType 
block_default_type);
 DriveInfo *add_init_drive(const char *opts);
 
 void qmp_change_blockdev(const char *device, const char *filename,
- bool has_format, const char *format, Error **errp);
+ const char *format, Error **errp);
 void do_commit(Monitor *mon, const QDict *qdict);
 int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
 #endif
diff --git a/qmp.c b/qmp.c
index 4c149b3..1d7a04d 100644
--- a/qmp.c
+++ b/qmp.c
@@ -400,7 +400,7 @@ void qmp_change(const char *device, const char *target,
 if (strcmp(device, vnc) == 0) {
 qmp_change_vnc(target, has_arg, arg, err);
 } else {
-qmp_change_blockdev(device, target, has_arg, arg, err);
+qmp_change_blockdev(device, target, arg, err);
 }
 }
 
-- 
1.8.3.1




[Qemu-devel] [PATCH 04/21] include: add missing config-host.h include

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 include/ui/qemu-spice.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index 86c75c7..a93b4b2 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -18,6 +18,8 @@
 #ifndef QEMU_SPICE_H
 #define QEMU_SPICE_H
 
+#include config-host.h
+
 #ifdef CONFIG_SPICE
 
 #include spice.h
-- 
1.8.3.1




[Qemu-devel] [PATCH 06/21] Split nbd block client code

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 block/Makefile.objs |   2 +-
 block/nbd-client.c  | 372 +++
 block/nbd-client.h  |  51 +++
 block/nbd.c | 373 
 4 files changed, 452 insertions(+), 346 deletions(-)
 create mode 100644 block/nbd-client.c
 create mode 100644 block/nbd-client.h

diff --git a/block/Makefile.objs b/block/Makefile.objs
index f43ecbc..4e8c91e 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -10,7 +10,7 @@ block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
 ifeq ($(CONFIG_POSIX),y)
-block-obj-y += nbd.o sheepdog.o
+block-obj-y += nbd.o nbd-client.o sheepdog.o
 block-obj-$(CONFIG_LIBISCSI) += iscsi.o
 block-obj-$(CONFIG_CURL) += curl.o
 block-obj-$(CONFIG_RBD) += rbd.o
diff --git a/block/nbd-client.c b/block/nbd-client.c
new file mode 100644
index 000..1abfc6a
--- /dev/null
+++ b/block/nbd-client.c
@@ -0,0 +1,372 @@
+/*
+ * QEMU Block driver for  NBD
+ *
+ * Copyright (C) 2008 Bull S.A.S.
+ * Author: Laurent Vivier laurent.viv...@bull.net
+ *
+ * Some parts:
+ *Copyright (C) 2007 Anthony Liguori anth...@codemonkey.ws
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include nbd-client.h
+#include qemu/sockets.h
+
+#define HANDLE_TO_INDEX(bs, handle) ((handle) ^ ((uint64_t)(intptr_t)bs))
+#define INDEX_TO_HANDLE(bs, index)  ((index)  ^ ((uint64_t)(intptr_t)bs))
+
+static void nbd_reply_ready(void *opaque)
+{
+NbdClientSession *s = opaque;
+uint64_t i;
+int ret;
+
+if (s-reply.handle == 0) {
+/* No reply already in flight.  Fetch a header.  It is possible
+ * that another thread has done the same thing in parallel, so
+ * the socket is not readable anymore.
+ */
+ret = nbd_receive_reply(s-sock, s-reply);
+if (ret == -EAGAIN) {
+return;
+}
+if (ret  0) {
+s-reply.handle = 0;
+goto fail;
+}
+}
+
+/* There's no need for a mutex on the receive side, because the
+ * handler acts as a synchronization point and ensures that only
+ * one coroutine is called until the reply finishes.  */
+i = HANDLE_TO_INDEX(s, s-reply.handle);
+if (i = MAX_NBD_REQUESTS) {
+goto fail;
+}
+
+if (s-recv_coroutine[i]) {
+qemu_coroutine_enter(s-recv_coroutine[i], NULL);
+return;
+}
+
+fail:
+for (i = 0; i  MAX_NBD_REQUESTS; i++) {
+if (s-recv_coroutine[i]) {
+qemu_coroutine_enter(s-recv_coroutine[i], NULL);
+}
+}
+}
+
+static void nbd_restart_write(void *opaque)
+{
+NbdClientSession *s = opaque;
+
+qemu_coroutine_enter(s-send_coroutine, NULL);
+}
+
+static int nbd_co_send_request(NbdClientSession *s,
+struct nbd_request *request,
+QEMUIOVector *qiov, int offset)
+{
+int rc, ret;
+
+qemu_co_mutex_lock(s-send_mutex);
+s-send_coroutine = qemu_coroutine_self();
+qemu_aio_set_fd_handler(s-sock, nbd_reply_ready, nbd_restart_write, s);
+if (qiov) {
+if (!s-is_unix) {
+socket_set_cork(s-sock, 1);
+}
+rc = nbd_send_request(s-sock, request);
+if (rc = 0) {
+ret = qemu_co_sendv(s-sock, qiov-iov, qiov-niov,
+offset, request-len);
+if (ret != request-len) {
+rc = -EIO;
+}
+}
+if (!s-is_unix) {
+socket_set_cork(s-sock, 0);
+}
+} else {
+rc = nbd_send_request(s-sock, request);
+}
+qemu_aio_set_fd_handler(s-sock, nbd_reply_ready, NULL, s);
+s-send_coroutine = NULL;
+qemu_co_mutex_unlock(s-send_mutex);
+return rc;
+}
+
+static void nbd_co_receive_reply(NbdClientSession *s,
+struct nbd_request *request, struct 

[Qemu-devel] [PATCH 05/21] char: add qemu_chr_fe_event()

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 include/sysemu/char.h | 10 ++
 qemu-char.c   |  7 +++
 spice-qemu-char.c | 10 ++
 3 files changed, 27 insertions(+)

diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index ad101d9..d23c8f1 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -69,6 +69,7 @@ struct CharDriverState {
 void (*chr_accept_input)(struct CharDriverState *chr);
 void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
 void (*chr_set_fe_open)(struct CharDriverState *chr, int fe_open);
+void (*chr_fe_event)(struct CharDriverState *chr, int event);
 void *opaque;
 char *label;
 char *filename;
@@ -138,6 +139,15 @@ void qemu_chr_fe_set_echo(struct CharDriverState *chr, 
bool echo);
 void qemu_chr_fe_set_open(struct CharDriverState *chr, int fe_open);
 
 /**
+ * @qemu_chr_fe_event:
+ *
+ * Send an event from the back end to the front end.
+ *
+ * @event the event to send
+ */
+void qemu_chr_fe_event(CharDriverState *s, int event);
+
+/**
  * @qemu_chr_fe_printf:
  *
  * Write to a character backend using a printf style interface.
diff --git a/qemu-char.c b/qemu-char.c
index e00f84c..418dc69 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3353,6 +3353,13 @@ void qemu_chr_fe_set_open(struct CharDriverState *chr, 
int fe_open)
 }
 }
 
+void qemu_chr_fe_event(struct CharDriverState *chr, int event)
+{
+if (chr-chr_fe_event) {
+chr-chr_fe_event(chr, event);
+}
+}
+
 int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond,
   GIOFunc func, void *user_data)
 {
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index e074d9e..16439c5 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -222,6 +222,15 @@ static void spice_chr_set_fe_open(struct CharDriverState 
*chr, int fe_open)
 }
 }
 
+static void spice_chr_fe_event(struct CharDriverState *chr, int event)
+{
+#if SPICE_SERVER_VERSION = 0x000c02
+SpiceCharDriver *s = chr-opaque;
+
+spice_server_port_event(s-sin, event);
+#endif
+}
+
 static void print_allowed_subtypes(void)
 {
 const char** psubtype;
@@ -255,6 +264,7 @@ static CharDriverState *chr_open(const char *subtype)
 chr-chr_close = spice_chr_close;
 chr-chr_set_fe_open = spice_chr_set_fe_open;
 chr-explicit_be_open = true;
+chr-chr_fe_event = spice_chr_fe_event;
 
 QLIST_INSERT_HEAD(spice_chars, s, next);
 
-- 
1.8.3.1




[Qemu-devel] [PATCH 13/21] blockdev: add qmp_change_blockdev_int()

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Allow to pass additional arguments, such as options and opaque

Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
---
 blockdev.c| 24 +++-
 include/sysemu/blockdev.h |  3 +++
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index b8db544..f2c3c4e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1498,12 +1498,13 @@ void qmp_block_passwd(const char *device, const char 
*password, Error **errp)
 
 static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename,
 int bdrv_flags, BlockDriver *drv,
-const char *password, Error **errp)
+const char *password, QDict *options,
+Error **errp)
 {
 Error *local_err = NULL;
 int ret;
 
-ret = bdrv_open(bs, filename, NULL, bdrv_flags, drv, local_err);
+ret = bdrv_open(bs, filename, options, bdrv_flags, drv, local_err);
 if (ret  0) {
 error_propagate(errp, local_err);
 return;
@@ -1523,8 +1524,9 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, 
const char *filename,
 }
 }
 
-void qmp_change_blockdev(const char *device, const char *filename,
- const char *format, Error **errp)
+void qmp_change_blockdev_int(const char *device, const char *filename,
+ const char *format, QDict *options, void *opaque,
+ Error **errp)
 {
 BlockDriverState *bs;
 BlockDriver *drv = NULL;
@@ -1554,7 +1556,19 @@ void qmp_change_blockdev(const char *device, const char 
*filename,
 bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR;
 bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0;
 
-qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, drv, NULL, errp);
+if (bs-opaque) {
+error_set(errp, QERR_INVALID_PARAMETER, device);
+return;
+}
+bs-opaque = opaque;
+
+qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, drv, NULL, options, 
errp);
+}
+
+void qmp_change_blockdev(const char *device, const char *filename,
+ const char *format, Error **errp)
+{
+qmp_change_blockdev_int(device, filename, format, NULL, NULL, errp);
 }
 
 /* throttling disk I/O limits */
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index 134712b..5ce4997 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -65,6 +65,9 @@ DriveInfo *add_init_drive(const char *opts);
 
 void qmp_change_blockdev(const char *device, const char *filename,
  const char *format, Error **errp);
+void qmp_change_blockdev_int(const char *device, const char *filename,
+ const char *format, QDict *options, void *opaque,
+ Error **errp);
 void do_commit(Monitor *mon, const QDict *qdict);
 int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
 #endif
-- 
1.8.3.1




[Qemu-devel] [PATCH 07/21] nbd: don't change socket block during negotiate

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

The caller might handle non-blocking using coroutine. Leave the choice
to the caller to use a blocking or non-blocking negotiate.

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 nbd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/nbd.c b/nbd.c
index f847940..3af9d17 100644
--- a/nbd.c
+++ b/nbd.c
@@ -443,7 +443,6 @@ int nbd_receive_negotiate(int csock, const char *name, 
uint32_t *flags,
 
 TRACE(Receiving negotiation.);
 
-qemu_set_block(csock);
 rc = -EINVAL;
 
 if (read_sync(csock, buf, 8) != 8) {
-- 
1.8.3.1




[Qemu-devel] [PATCH 10/21] nbd: finish any pending coroutine

2013-11-18 Thread Marc-André Lureau
Make sure all pending coroutines are finished when closing the session.

Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
---
 block/nbd-client.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index c0ad2c2..ad6fb01 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -32,6 +32,18 @@
 #define HANDLE_TO_INDEX(bs, handle) ((handle) ^ ((uint64_t)(intptr_t)bs))
 #define INDEX_TO_HANDLE(bs, index)  ((index)  ^ ((uint64_t)(intptr_t)bs))
 
+static void nbd_recv_coroutines_enter_all(NbdClientSession *s)
+{
+int i;
+
+for (i = 0; i  MAX_NBD_REQUESTS; i++) {
+if (s-recv_coroutine[i]) {
+fprintf(stderr, *nbd reply enter: %p %d\n, s, s-reply.error);
+qemu_coroutine_enter(s-recv_coroutine[i], NULL);
+}
+}
+}
+
 static void nbd_reply_ready(void *opaque)
 {
 NbdClientSession *s = opaque;
@@ -67,11 +79,7 @@ static void nbd_reply_ready(void *opaque)
 }
 
 fail:
-for (i = 0; i  MAX_NBD_REQUESTS; i++) {
-if (s-recv_coroutine[i]) {
-qemu_coroutine_enter(s-recv_coroutine[i], NULL);
-}
-}
+nbd_recv_coroutines_enter_all(s);
 }
 
 static void nbd_restart_write(void *opaque)
@@ -332,6 +340,10 @@ static void nbd_teardown_connection(NbdClientSession 
*client)
 
 qemu_aio_set_fd_handler(client-sock, NULL, NULL, NULL);
 closesocket(client-sock);
+/* finish any pending coroutines */
+client-reply.handle = 0;
+client-reply.error = EIO;
+nbd_recv_coroutines_enter_all(client);
 client-sock = -1;
 }
 
-- 
1.8.3.1




[Qemu-devel] [PATCH 08/21] nbd: pass export name as init argument

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

There is no need to keep the export name around, and it seems a better
fit as an argument in the init() call.

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 block/nbd-client.c | 10 --
 block/nbd-client.h |  5 ++---
 block/nbd.c| 13 -
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index 1abfc6a..e29227b 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -338,17 +338,15 @@ static void nbd_teardown_connection(NbdClientSession 
*client)
 void nbd_client_session_close(NbdClientSession *client)
 {
 nbd_teardown_connection(client);
-g_free(client-export_name);
-client-export_name = NULL;
 }
 
-int nbd_client_session_init(NbdClientSession *client,
-BlockDriverState *bs, int sock)
+int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
+int sock, const char *export)
 {
 int ret;
 
-/* NBD handshake */
-ret = nbd_receive_negotiate(sock, client-export_name,
+logout(session init %s\n, export);
+ret = nbd_receive_negotiate(sock, export,
 client-nbdflags, client-size,
 client-blocksize);
 if (ret  0) {
diff --git a/block/nbd-client.h b/block/nbd-client.h
index c271236..f2a6337 100644
--- a/block/nbd-client.h
+++ b/block/nbd-client.h
@@ -30,14 +30,13 @@ typedef struct NbdClientSession {
 Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
 struct nbd_reply reply;
 
-char *export_name; /* An NBD server may export several devices */
 bool is_unix;
 
 BlockDriverState *bs;
 } NbdClientSession;
 
-int nbd_client_session_init(NbdClientSession *client,
-BlockDriverState *bs, int sock);
+int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
+int sock, const char *export_name);
 void nbd_client_session_close(NbdClientSession *client);
 
 int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
diff --git a/block/nbd.c b/block/nbd.c
index be75ba0..4455a13 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -188,7 +188,7 @@ out:
 g_free(file);
 }
 
-static int nbd_config(BDRVNBDState *s, QDict *options)
+static int nbd_config(BDRVNBDState *s, QDict *options, char **export)
 {
 Error *local_err = NULL;
 
@@ -218,8 +218,8 @@ static int nbd_config(BDRVNBDState *s, QDict *options)
 qemu_opt_set_number(s-socket_opts, port, NBD_DEFAULT_PORT);
 }
 
-s-client.export_name = g_strdup(qdict_get_try_str(options, export));
-if (s-client.export_name) {
+*export = g_strdup(qdict_get_try_str(options, export));
+if (*export) {
 qdict_del(options, export);
 }
 
@@ -253,10 +253,11 @@ static int nbd_open(BlockDriverState *bs, QDict *options, 
int flags,
 Error **errp)
 {
 BDRVNBDState *s = bs-opaque;
+char *export = NULL;
 int result, sock;
 
 /* Pop the config into our state object. Exit if invalid. */
-result = nbd_config(s, options);
+result = nbd_config(s, options, export);
 if (result != 0) {
 return result;
 }
@@ -270,7 +271,9 @@ static int nbd_open(BlockDriverState *bs, QDict *options, 
int flags,
 }
 
 /* NBD handshake */
-return nbd_client_session_init(s-client, bs, sock);
+result = nbd_client_session_init(s-client, bs, sock, export);
+g_free(export);
+return result;
 }
 
 static int nbd_co_readv(BlockDriverState *bs, int64_t sector_num,
-- 
1.8.3.1




[Qemu-devel] [PATCH 14/21] block: extract make_snapshot() from bdrv_open()

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 block.c | 121 +---
 1 file changed, 70 insertions(+), 51 deletions(-)

diff --git a/block.c b/block.c
index 0558525..09aada5 100644
--- a/block.c
+++ b/block.c
@@ -1038,6 +1038,73 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict 
*options, Error **errp)
 return 0;
 }
 
+static int make_snapshot(BlockDriverState *bs, int64_t total_size,
+ const char **pfilename, BlockDriver **pdrv,
+ Error **errp)
+{
+const char *filename = *pfilename;
+BlockDriver *drv = *pdrv;
+int ret;
+BlockDriver *bdrv_qcow2;
+QEMUOptionParameter *create_options;
+char backing_filename[PATH_MAX];
+/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
+char tmp_filename[PATH_MAX + 1];
+Error *local_err = NULL;
+
+assert(filename != NULL);
+total_size = BDRV_SECTOR_MASK;
+
+/* if snapshot, we create a temporary backing file and open it
+   instead of opening 'filename' directly */
+
+ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
+if (ret  0) {
+goto fail;
+}
+
+/* Real path is meaningless for protocols */
+if (path_has_protocol(filename)) {
+snprintf(backing_filename, sizeof(backing_filename),
+ %s, filename);
+} else if (!realpath(filename, backing_filename)) {
+ret = -errno;
+error_setg_errno(errp, errno, Could not resolve path '%s', filename);
+goto fail;
+}
+
+bdrv_qcow2 = bdrv_find_format(qcow2);
+create_options = parse_option_parameters(, bdrv_qcow2-create_options,
+ NULL);
+
+set_option_parameter_int(create_options, BLOCK_OPT_SIZE, total_size);
+set_option_parameter(create_options, BLOCK_OPT_BACKING_FILE,
+ backing_filename);
+if (drv) {
+set_option_parameter(create_options, BLOCK_OPT_BACKING_FMT,
+ drv-format_name);
+}
+
+ret = bdrv_create(bdrv_qcow2, tmp_filename, create_options, local_err);
+free_option_parameters(create_options);
+if (ret  0) {
+error_setg_errno(errp, -ret, Could not create temporary overlay 
+ '%s': %s, tmp_filename,
+ error_get_pretty(local_err));
+error_free(local_err);
+local_err = NULL;
+goto fail;
+}
+
+*pfilename = tmp_filename;
+*pdrv = bdrv_qcow2;
+bs-is_temporary = 1;
+return 0;
+
+fail:
+return ret;
+}
+
 /*
  * Opens a disk image (raw, qcow2, vmdk, ...)
  *
@@ -1050,8 +1117,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
   int flags, BlockDriver *drv, Error **errp)
 {
 int ret;
-/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
-char tmp_filename[PATH_MAX + 1];
 BlockDriverState *file = NULL;
 QDict *file_options = NULL;
 const char *drvname;
@@ -1069,73 +1134,27 @@ int bdrv_open(BlockDriverState *bs, const char 
*filename, QDict *options,
 if (flags  BDRV_O_SNAPSHOT) {
 BlockDriverState *bs1;
 int64_t total_size;
-BlockDriver *bdrv_qcow2;
-QEMUOptionParameter *create_options;
-char backing_filename[PATH_MAX];
 
 if (qdict_size(options) != 0) {
 error_setg(errp, Can't use snapshot=on with driver-specific 
options);
 ret = -EINVAL;
 goto fail;
 }
-assert(filename != NULL);
-
-/* if snapshot, we create a temporary backing file and open it
-   instead of opening 'filename' directly */
 
-/* if there is a backing file, use it */
-bs1 = bdrv_new_int(, bs);
+bs1 = bdrv_new_int(, NULL);
 ret = bdrv_open(bs1, filename, NULL, 0, drv, local_err);
 if (ret  0) {
 bdrv_unref(bs1);
 goto fail;
 }
-total_size = bdrv_getlength(bs1)  BDRV_SECTOR_MASK;
 
+total_size = bdrv_getlength(bs1)  BDRV_SECTOR_MASK;
 bdrv_unref(bs1);
 
-ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
-if (ret  0) {
-error_setg_errno(errp, -ret, Could not get temporary filename);
-goto fail;
-}
-
-/* Real path is meaningless for protocols */
-if (path_has_protocol(filename)) {
-snprintf(backing_filename, sizeof(backing_filename),
- %s, filename);
-} else if (!realpath(filename, backing_filename)) {
-ret = -errno;
-error_setg_errno(errp, errno, Could not resolve path '%s', 
filename);
-goto fail;
-}
-
-bdrv_qcow2 = bdrv_find_format(qcow2);
-create_options = parse_option_parameters(, 
bdrv_qcow2-create_options,
-   

[Qemu-devel] [PATCH 11/21] nbd: avoid uninitialized warnings

2013-11-18 Thread Marc-André Lureau
==15815== Thread 1:
==15815== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==15815==at 0x65AD5CB: send (send.c:31)
==15815==by 0x37F84B: nbd_wr_sync (nbd.c:145)
==15815==by 0x37F94B: write_sync (nbd.c:186)
==15815==by 0x380FA9: nbd_send_request (nbd.c:681)
==15815==by 0x1C4A2D: nbd_teardown_connection (nbd-client.c:337)
==15815==by 0x1C4AD8: nbd_client_session_close (nbd-client.c:354)
==15815==by 0x1ED2D8: close_socketpair (spicebd.c:132)
==15815==by 0x1EE265: spice_close (spicebd.c:457)
==15815==by 0x1ACBF6: bdrv_close (block.c:1519)
==15815==by 0x1AD804: bdrv_delete (block.c:1772)
==15815==by 0x1B4136: bdrv_unref (block.c:4476)
==15815==by 0x1ACCE0: bdrv_close (block.c:1541)
==15815==  Address 0x7feffef98 is on thread 1's stack

Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
---
 block/nbd-client.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index ad6fb01..82806f1 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -186,11 +186,10 @@ static int nbd_co_readv_1(NbdClientSession *client, 
int64_t sector_num,
   int nb_sectors, QEMUIOVector *qiov,
   int offset)
 {
-struct nbd_request request;
+struct nbd_request request = { .type = NBD_CMD_READ };
 struct nbd_reply reply;
 ssize_t ret;
 
-request.type = NBD_CMD_READ;
 request.from = sector_num * 512;
 request.len = nb_sectors * 512;
 
@@ -210,11 +209,10 @@ static int nbd_co_writev_1(NbdClientSession *client, 
int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov,
int offset)
 {
-struct nbd_request request;
+struct nbd_request request = { .type = NBD_CMD_WRITE };
 struct nbd_reply reply;
 ssize_t ret;
 
-request.type = NBD_CMD_WRITE;
 if (!bdrv_enable_write_cache(client-bs) 
 (client-nbdflags  NBD_FLAG_SEND_FUA)) {
 request.type |= NBD_CMD_FLAG_FUA;
@@ -276,7 +274,7 @@ int nbd_client_session_co_writev(NbdClientSession *client, 
int64_t sector_num,
 
 int nbd_client_session_co_flush(NbdClientSession *client)
 {
-struct nbd_request request;
+struct nbd_request request = { .type = NBD_CMD_FLUSH };
 struct nbd_reply reply;
 ssize_t ret;
 
@@ -284,7 +282,6 @@ int nbd_client_session_co_flush(NbdClientSession *client)
 return 0;
 }
 
-request.type = NBD_CMD_FLUSH;
 if (client-nbdflags  NBD_FLAG_SEND_FUA) {
 request.type |= NBD_CMD_FLAG_FUA;
 }
@@ -306,14 +303,13 @@ int nbd_client_session_co_flush(NbdClientSession *client)
 int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
 int nb_sectors)
 {
-struct nbd_request request;
+struct nbd_request request = { .type = NBD_CMD_TRIM };
 struct nbd_reply reply;
 ssize_t ret;
 
 if (!(client-nbdflags  NBD_FLAG_SEND_TRIM)) {
 return 0;
 }
-request.type = NBD_CMD_TRIM;
 request.from = sector_num * 512;
 request.len = nb_sectors * 512;
 
@@ -331,11 +327,12 @@ int nbd_client_session_co_discard(NbdClientSession 
*client, int64_t sector_num,
 
 static void nbd_teardown_connection(NbdClientSession *client)
 {
-struct nbd_request request;
+struct nbd_request request = {
+.type = NBD_CMD_DISC,
+.from = 0,
+.len = 0
+};
 
-request.type = NBD_CMD_DISC;
-request.from = 0;
-request.len = 0;
 nbd_send_request(client-sock, request);
 
 qemu_aio_set_fd_handler(client-sock, NULL, NULL, NULL);
-- 
1.8.3.1




[Qemu-devel] [PATCH 15/21] block: add snapshot.size option to avoid extra bdrv_open()

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 block.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index 09aada5..9e7632e 100644
--- a/block.c
+++ b/block.c
@@ -1135,27 +1135,32 @@ int bdrv_open(BlockDriverState *bs, const char 
*filename, QDict *options,
 BlockDriverState *bs1;
 int64_t total_size;
 
+total_size = qdict_get_try_int(options, snapshot.size, -1);
+qdict_del(options, snapshot.size);
+
 if (qdict_size(options) != 0) {
 error_setg(errp, Can't use snapshot=on with driver-specific 
options);
 ret = -EINVAL;
 goto fail;
 }
 
-bs1 = bdrv_new_int(, NULL);
-ret = bdrv_open(bs1, filename, NULL, 0, drv, local_err);
-if (ret  0) {
+if (total_size == -1) {
+bs1 = bdrv_new_int(, NULL);
+ret = bdrv_open(bs1, filename, NULL, 0, drv, local_err);
+if (ret  0) {
+bdrv_unref(bs1);
+goto fail;
+}
+total_size = bdrv_getlength(bs1);
 bdrv_unref(bs1);
-goto fail;
 }
 
-total_size = bdrv_getlength(bs1)  BDRV_SECTOR_MASK;
-bdrv_unref(bs1);
-
 ret = make_snapshot(bs, total_size, filename, drv, errp);
 if (ret  0) {
 goto fail;
 }
 }
+qdict_del(options, snapshot.size);
 
 /* Open image file without format layer */
 if (flags  BDRV_O_RDWR) {
-- 
1.8.3.1




[Qemu-devel] [PATCH 17/21] block: allow to call bdrv_open() with an opaque

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

If the block driver already has a bs-opaque when calling bdrv_open(),
pass it down to the file driver.

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com

Conflicts:
block.c
---
 block.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index f154979..ce2427b 100644
--- a/block.c
+++ b/block.c
@@ -1131,6 +1131,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
 QDict *file_options = NULL;
 const char *drvname;
 Error *local_err = NULL;
+void *backing_opaque = NULL;
 
 /* NULL means an empty set of options */
 if (options == NULL) {
@@ -1154,6 +1155,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
 goto fail;
 }
 
+backing_opaque = bs-opaque;
+bs-opaque = NULL;
 if (total_size == -1) {
 bs1 = bdrv_new_int(, NULL, NULL);
 ret = bdrv_open(bs1, filename, NULL, 0, drv, local_err);
@@ -1181,7 +1184,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
 
 ret = bdrv_file_open_int(file, filename, file_options,
  bdrv_open_flags(bs, flags | BDRV_O_UNMAP),
- bs, NULL, local_err);
+ bs, bs-opaque, local_err);
+bs-opaque = NULL;
 if (ret  0) {
 goto fail;
 }
@@ -1217,7 +1221,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
 QDict *backing_options;
 
 qdict_extract_subqdict(options, backing_options, backing.);
-ret = bdrv_open_backing_file_int(bs, backing_options, NULL, 
local_err);
+ret = bdrv_open_backing_file_int(bs, backing_options,
+ backing_opaque, local_err);
 if (ret  0) {
 goto close_and_fail;
 }
-- 
1.8.3.1




[Qemu-devel] [PATCH 18/21] block: do not notify change during migration

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

When starting qemu, a block driver isn't associated with a device, so
no notification is emitted when the media is loaded.

The Spice block driver loads the media during migration. But at
that time, the device is already associated, however, we want to
avoid notification to the guest. Checking the runstate seems the
simplest way.

Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
---
 block.c   |  4 +++-
 hw/block/fdc.c|  8 +---
 hw/ide/core.c | 12 +++-
 hw/scsi/scsi-disk.c   | 11 +++
 hw/sd/sd.c|  6 +-
 include/block/block.h |  2 +-
 stubs/vm-stop.c   |  5 +
 7 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/block.c b/block.c
index ce2427b..fdbc7f9 100644
--- a/block.c
+++ b/block.c
@@ -1864,9 +1864,11 @@ static void bdrv_emit_qmp_eject_event(BlockDriverState 
*bs, bool ejected)
 
 static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load)
 {
+bool notify = !runstate_check(RUN_STATE_INMIGRATE);
+
 if (bs-dev_ops  bs-dev_ops-change_media_cb) {
 bool tray_was_closed = !bdrv_dev_is_tray_open(bs);
-bs-dev_ops-change_media_cb(bs-dev_opaque, load);
+bs-dev_ops-change_media_cb(bs-dev_opaque, load, notify);
 if (tray_was_closed) {
 /* tray open */
 bdrv_emit_qmp_eject_event(bs, true);
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index c5a6c21..bb8cffb 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -1984,11 +1984,13 @@ static void fdctrl_result_timer(void *opaque)
 }
 }
 
-static void fdctrl_change_cb(void *opaque, bool load)
+static void fdctrl_change_cb(void *opaque, bool load, bool notify)
 {
 FDrive *drive = opaque;
 
-drive-media_changed = 1;
+if (notify) {
+drive-media_changed = 1;
+}
 fd_revalidate(drive);
 }
 
@@ -2018,7 +2020,7 @@ static void fdctrl_connect_drives(FDCtrl *fdctrl, Error 
**errp)
 }
 
 fd_init(drive);
-fdctrl_change_cb(drive, 0);
+fdctrl_change_cb(drive, 0, false);
 if (drive-bs) {
 bdrv_set_dev_ops(drive-bs, fdctrl_block_ops, drive);
 }
diff --git a/hw/ide/core.c b/hw/ide/core.c
index e1f4c33..18b2f85 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -882,7 +882,7 @@ static void ide_cfata_metadata_write(IDEState *s)
 }
 
 /* called when the inserted state of the media has changed */
-static void ide_cd_change_cb(void *opaque, bool load)
+static void ide_cd_change_cb(void *opaque, bool load, bool notify)
 {
 IDEState *s = opaque;
 uint64_t nb_sectors;
@@ -898,10 +898,12 @@ static void ide_cd_change_cb(void *opaque, bool load)
  * Then we set UNIT_ATTENTION, by which the guest will
  * detect a new CD in the drive.  See ide_atapi_cmd() for details.
  */
-s-cdrom_changed = 1;
-s-events.new_media = true;
-s-events.eject_request = false;
-ide_set_irq(s-bus);
+if (notify) {
+s-cdrom_changed = 1;
+s-events.new_media = true;
+s-events.eject_request = false;
+ide_set_irq(s-bus);
+}
 }
 
 static void ide_cd_eject_request_cb(void *opaque, bool force)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 74e6a14..87f2299 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2010,7 +2010,7 @@ static void scsi_disk_resize_cb(void *opaque)
 }
 }
 
-static void scsi_cd_change_media_cb(void *opaque, bool load)
+static void scsi_cd_change_media_cb(void *opaque, bool load, bool notify)
 {
 SCSIDiskState *s = opaque;
 
@@ -2024,11 +2024,14 @@ static void scsi_cd_change_media_cb(void *opaque, bool 
load)
  * media_changed governs the state machine used for unit attention
  * report.  media_event is used by GET EVENT STATUS NOTIFICATION.
  */
-s-media_changed = load;
 s-tray_open = !load;
-scsi_device_set_ua(s-qdev, SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM));
-s-media_event = true;
 s-eject_request = false;
+
+if (notify) {
+s-media_changed = load;
+scsi_device_set_ua(s-qdev, SENSE_CODE(UNIT_ATTENTION_NO_MEDIUM));
+s-media_event = true;
+}
 }
 
 static void scsi_cd_eject_request_cb(void *opaque, bool force)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 4502ad1..09f37be 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -439,10 +439,14 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv)
 sd-expecting_acmd = false;
 }
 
-static void sd_cardchange(void *opaque, bool load)
+static void sd_cardchange(void *opaque, bool load, bool notify)
 {
 SDState *sd = opaque;
 
+if (!notify) {
+return;
+}
+
 qemu_set_irq(sd-inserted_cb, bdrv_is_inserted(sd-bdrv));
 if (bdrv_is_inserted(sd-bdrv)) {
 sd_reset(sd, sd-bdrv);
diff --git a/include/block/block.h b/include/block/block.h
index 3560deb..a5ccbb5 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -36,7 +36,7 @@ typedef struct BlockDevOps {
  * 

[Qemu-devel] [PATCH 20/21] spice-core: allow an interface to be in AIO context

2013-11-18 Thread Marc-André Lureau
The Spice block driver must be able complete operations within a AIO
context only.

Spice is currently only running within the main loop, and doesn't allow
the block driver to complete operations, such as flush during migration.

This patch allows a Spice interface to be associated with a different
context. Currently, the interface user_data is simply used to
differentiate main loop from AIO, but could later be used to associate
an interface with a particular thread.

Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
---
 include/ui/qemu-spice.h |  2 +-
 qemu-char.c |  2 +-
 spice-qemu-char.c   |  9 +++
 ui/spice-core.c | 62 +++--
 4 files changed, 62 insertions(+), 13 deletions(-)

diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index a93b4b2..d5ba702 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -48,7 +48,7 @@ int qemu_spice_migrate_info(const char *hostname, int port, 
int tls_port,
 void do_info_spice_print(Monitor *mon, const QObject *data);
 void do_info_spice(Monitor *mon, QObject **ret_data);
 
-CharDriverState *qemu_chr_open_spice_vmc(const char *type);
+CharDriverState *qemu_chr_open_spice_vmc(const char *type, bool aio);
 #if SPICE_SERVER_VERSION = 0x000c02
 CharDriverState *qemu_chr_open_spice_port(const char *name);
 void qemu_spice_register_ports(void);
diff --git a/qemu-char.c b/qemu-char.c
index 418dc69..bfac7bf 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3747,7 +3747,7 @@ ChardevReturn *qmp_chardev_add(const char *id, 
ChardevBackend *backend,
 #endif
 #ifdef CONFIG_SPICE
 case CHARDEV_BACKEND_KIND_SPICEVMC:
-chr = qemu_chr_open_spice_vmc(backend-spicevmc-type);
+chr = qemu_chr_open_spice_vmc(backend-spicevmc-type, false);
 break;
 case CHARDEV_BACKEND_KIND_SPICEPORT:
 chr = qemu_chr_open_spice_port(backend-spiceport-fqdn);
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 16439c5..421f7de 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -248,7 +248,7 @@ static void print_allowed_subtypes(void)
 fprintf(stderr, \n);
 }
 
-static CharDriverState *chr_open(const char *subtype)
+static CharDriverState *chr_open(const char *subtype, bool aio)
 {
 CharDriverState *chr;
 SpiceCharDriver *s;
@@ -257,6 +257,7 @@ static CharDriverState *chr_open(const char *subtype)
 s = g_malloc0(sizeof(SpiceCharDriver));
 s-chr = chr;
 s-active = false;
+s-sin.base.user_data = (void*)aio;
 s-sin.subtype = g_strdup(subtype);
 chr-opaque = s;
 chr-chr_write = spice_chr_write;
@@ -271,7 +272,7 @@ static CharDriverState *chr_open(const char *subtype)
 return chr;
 }
 
-CharDriverState *qemu_chr_open_spice_vmc(const char *type)
+CharDriverState *qemu_chr_open_spice_vmc(const char *type, bool aio)
 {
 const char **psubtype = spice_server_char_device_recognized_subtypes();
 
@@ -291,7 +292,7 @@ CharDriverState *qemu_chr_open_spice_vmc(const char *type)
 return NULL;
 }
 
-return chr_open(type);
+return chr_open(type, aio);
 }
 
 #if SPICE_SERVER_VERSION = 0x000c02
@@ -305,7 +306,7 @@ CharDriverState *qemu_chr_open_spice_port(const char *name)
 return NULL;
 }
 
-chr = chr_open(port);
+chr = chr_open(port, false);
 s = chr-opaque;
 s-sin.portname = g_strdup(name);
 
diff --git a/ui/spice-core.c b/ui/spice-core.c
index e4d533d..0f69630 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -53,34 +53,64 @@ static QemuThread me;
 
 struct SpiceTimer {
 QEMUTimer *timer;
+QEMUBH *bh;
 QTAILQ_ENTRY(SpiceTimer) next;
 };
 static QTAILQ_HEAD(, SpiceTimer) timers = QTAILQ_HEAD_INITIALIZER(timers);
 
+#if SPICE_INTERFACE_CORE_MAJOR = 2
+static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque, 
SpiceBaseInstance *sin)
+#else
 static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque)
+#endif
 {
 SpiceTimer *timer;
 
 timer = g_malloc0(sizeof(*timer));
-timer-timer = timer_new_ms(QEMU_CLOCK_REALTIME, func, opaque);
+
+#if SPICE_INTERFACE_CORE_MAJOR = 2
+bool aio = sin ? !!sin-user_data : false;
+if (aio) {
+fprintf(stderr, AIO doesn't have timers yet, using BH\n);
+timer-bh = qemu_bh_new(func, opaque);
+} else
+#endif
+{
+timer-timer = timer_new_ms(QEMU_CLOCK_REALTIME, func, opaque);
+}
+
 QTAILQ_INSERT_TAIL(timers, timer, next);
+
 return timer;
 }
 
 static void timer_start(SpiceTimer *timer, uint32_t ms)
 {
-timer_mod(timer-timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + ms);
+if (timer-bh) {
+qemu_bh_schedule_idle(timer-bh); /* at least every 10ms, see async.c 
*/
+} else {
+timer_mod(timer-timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + ms);
+}
 }
 
 static void timer_cancel(SpiceTimer *timer)
 {
-timer_del(timer-timer);
+if (timer-bh) {
+qemu_bh_cancel(timer-bh);
+} else {
+timer_del(timer-timer);
+}
 }
 

[Qemu-devel] [PATCH 21/21] block: add spice block device backend

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 block/Makefile.objs |   1 +
 block/spicebd.c | 536 
 2 files changed, 537 insertions(+)
 create mode 100644 block/spicebd.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 4e8c91e..f49b7c3 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -16,6 +16,7 @@ block-obj-$(CONFIG_CURL) += curl.o
 block-obj-$(CONFIG_RBD) += rbd.o
 block-obj-$(CONFIG_GLUSTERFS) += gluster.o
 block-obj-$(CONFIG_LIBSSH2) += ssh.o
+common-obj-$(CONFIG_SPICE) += spicebd.o
 endif
 
 common-obj-y += stream.o
diff --git a/block/spicebd.c b/block/spicebd.c
new file mode 100644
index 000..6b23b61
--- /dev/null
+++ b/block/spicebd.c
@@ -0,0 +1,536 @@
+/*
+ * Spice block backend for QEMU.
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ * Author: Marc-André Lureau marcandre.lur...@redhat.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include stdarg.h
+#include spice/protocol.h
+
+#include nbd-client.h
+#include ui/qemu-spice.h
+#include block/block_int.h
+#include qemu/sockets.h
+#include qemu/uri.h
+#include qapi/qmp/qint.h
+#include sysemu/sysemu.h
+#include sysemu/char.h
+#include qmp-commands.h
+#include sysemu/blockdev.h
+#include migration/migration.h
+
+#ifndef DEBUG_SPICE
+#define DEBUG_SPICE   0
+#endif
+
+#define SOCKET_CHR 0
+#define SOCKET_NBD 1
+
+#define DPRINTF(fmt, ...)   \
+do {\
+if (DEBUG_SPICE) {  \
+fprintf(stderr, spicebd: %-15s  fmt \n, \
+__func__, ##__VA_ARGS__);   \
+}   \
+} while (0)
+
+typedef struct Buffer {
+uint8_t data[4096];
+uint8_t *p;
+char left;
+} Buffer;
+
+typedef struct BDRVSpiceState {
+BlockDriverState *bs;
+QEMUBH *bh;
+NbdClientSession client;
+
+/* our spicechr-fd pipe */
+int sv[2];
+Buffer readb;
+Buffer writeb;
+
+int aio_count;
+CharDriverState *chr;
+guint chr_watch;
+
+Coroutine *coroutine;
+bool need_read;
+bool need_write;
+bool opened;
+bool inmigrate;
+} BDRVSpiceState;
+
+static void nbd_read_handler(void *opaque);
+static void update_chr_handlers(BDRVSpiceState *s);
+
+static int parse_uri(const char *filename, QDict *options, Error **errp)
+{
+URI *uri = NULL;
+
+uri = uri_parse(filename);
+if (!uri) {
+return -EINVAL;
+}
+
+if (strcmp(uri-scheme, spicebd) != 0) {
+error_setg(errp, URI scheme must be 'spicebd');
+goto err;
+}
+
+uri_free(uri);
+return 0;
+
+ err:
+if (uri) {
+uri_free(uri);
+}
+return -EINVAL;
+}
+
+static void spice_parse_filename(const char *filename, QDict *options,
+ Error **errp)
+{
+parse_uri(filename, options, errp);
+}
+
+static void co_restart(void *opaque)
+{
+BDRVSpiceState *s = opaque;
+
+qemu_coroutine_enter(s-coroutine, NULL);
+}
+
+static void close_socketpair(BDRVSpiceState *s)
+{
+if (!s-opened) {
+return;
+}
+
+DPRINTF();
+nbd_client_session_close(s-client);
+
+if (s-sv[SOCKET_NBD] = 0) {
+qemu_aio_set_fd_handler(s-sv[SOCKET_NBD], NULL, NULL, NULL);
+closesocket(s-sv[SOCKET_NBD]);
+s-sv[SOCKET_NBD] = -1;
+}
+
+if (s-sv[SOCKET_CHR] = 0) {
+qemu_aio_set_fd_handler(s-sv[SOCKET_CHR], NULL, NULL, NULL);
+closesocket(s-sv[SOCKET_CHR]);
+s-sv[SOCKET_CHR] = -1;
+}
+
+if (s-inmigrate) {
+vm_start_release();
+s-inmigrate = false;
+}
+
+s-opened = FALSE;
+if (s-coroutine  s-coroutine != qemu_coroutine_self()) {
+co_restart(s);
+}
+}
+
+static int 

Re: [Qemu-devel] [PULL 47/58] qdev-monitor: Unref device when device_add fails

2013-11-18 Thread Amos Kong
On Tue, Oct 08, 2013 at 07:44:45PM +0200, Andreas Färber wrote:
 From: Stefan Hajnoczi stefa...@redhat.com
 
 qdev_device_add() leaks the created device upon failure.  I suspect this
 problem crept in because qdev_free() unparents the device but does not
 drop a reference - confusing name.
 
 Cc: qemu-sta...@nongnu.org
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
 Signed-off-by: Andreas Färber afaer...@suse.de

Hi Stefan,

This commit caused a regression bug:

hotplug more than 32 disks to vm, qemu crash

---

[amos@amosk qemu]$ cat radd.sh 
for i in `seq 3 9` a b c d e f 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f;do
for j in `seq 1 7` 0;do
/bin/cp /images/none.qcow2 /tmp/resize$i$j.qcow2

echo drive_add $i.$j id=drv$i$j,file=/tmp/resize$i$j.qcow2,if=none
echo drive_add $i.$j id=drv$i$j,file=/tmp/resize$i$j.qcow2,if=none | nc -U 
/tmp/m

echo device_add 
virtio-blk-pci,id=dev$i$j,drive=drv$i$j,addr=0x$i.$j,multifunction=on
echo device_add 
virtio-blk-pci,id=dev$i$j,drive=drv$i$j,addr=0x$i.$j,multifunction=on | nc -U 
/tmp/m
done
done



#0  0x558b7f95 in flatview_ref (view=0x0) at 
/home/devel/qemu/memory.c:300
#1  0x558b9689 in address_space_get_flatview (as=0x5645d660) at 
/home/devel/qemu/memory.c:656
#2  0x558ba416 in address_space_update_topology (as=0x5645d660) at 
/home/devel/qemu/memory.c:760
#3  0x558ba5cf in memory_region_transaction_commit () at 
/home/devel/qemu/memory.c:799
#4  0x558bcfcc in memory_region_set_enabled (mr=0x5647af08, 
enabled=false) at /home/devel/qemu/memory.c:1503
#5  0x5571a0af in do_pci_register_device (pci_dev=0x5647ac10, 
bus=0x564132b0, name=0x56261100 virtio-blk-pci, devfn=26) at 
hw/pci/pci.c:846
#6  0x5571c6cc in pci_qdev_init (qdev=0x5647ac10) at 
hw/pci/pci.c:1751
#7  0x55694d70 in device_realize (dev=0x5647ac10, 
err=0x7fffc8e8) at hw/core/qdev.c:178
#8  0x556966fc in device_set_realized (obj=0x5647ac10, value=true, 
err=0x7fffca60) at hw/core/qdev.c:699
#9  0x557e7b57 in property_set_bool (obj=0x5647ac10, 
v=0x5679a830, opaque=0x56461b10, name=0x559922ae realized, 
errp=0x7fffca60)
at qom/object.c:1315
#10 0x557e665b in object_property_set (obj=0x5647ac10, 
v=0x5679a830, name=0x559922ae realized, errp=0x7fffca60) at 
qom/object.c:803
#11 0x557e816e in object_property_set_qobject (obj=0x5647ac10, 
value=0x56678880, name=0x559922ae realized, errp=0x7fffca60) at 
qom/qom-qobject.c:24
#12 0x557e6950 in object_property_set_bool (obj=0x5647ac10, 
value=true, name=0x559922ae realized, errp=0x7fffca60) at 
qom/object.c:866
#13 0x55694ca7 in qdev_init (dev=0x5647ac10) at hw/core/qdev.c:163
#14 0x557c60ee in qdev_device_add (opts=0x56525370) at 
qdev-monitor.c:543
#15 0x557c6730 in do_device_add (mon=0x562fb760, 
qdict=0x5645d440, ret_data=0x7fffcb80) at qdev-monitor.c:656
#16 0x558c8892 in handle_user_command (mon=0x562fb760, 
cmdline=0x563f0f60 device_add 
virtio-blk-pci,id=dev32,drive=drv32,addr=0x3.2,multifunction=on)
at /home/devel/qemu/monitor.c:4137
#17 0x558ca10f in monitor_command_cb (mon=0x562fb760, 
cmdline=0x563f0f60 device_add 
virtio-blk-pci,id=dev32,drive=drv32,addr=0x3.2,multifunction=on, 
opaque=0x0) at /home/devel/qemu/monitor.c:4757
#18 0x557e9491 in readline_handle_byte (rs=0x563f0f60, ch=10) at 
readline.c:373
#19 0x558ca045 in monitor_read (opaque=0x562fb760, 
buf=0x7fffccf0 \n\315\377\377\377\177, size=1) at 
/home/devel/qemu/monitor.c:4743
#20 0x557c6cc8 in qemu_chr_be_write (s=0x56269040, 
buf=0x7fffccf0 \n\315\377\377\377\177, len=1) at qemu-char.c:165
#21 0x557cb026 in tcp_chr_read (chan=0x5645fe40, cond=G_IO_IN, 
opaque=0x56269040) at qemu-char.c:2487
#22 0x776ede06 in g_main_context_dispatch () from 
/lib64/libglib-2.0.so.0
#23 0x5578ef33 in glib_pollfds_poll () at main-loop.c:189
#24 0x5578f028 in os_host_main_loop_wait (timeout=77312299) at 
main-loop.c:234
#25 0x5578f100 in main_loop_wait (nonblocking=0) at main-loop.c:483
#26 0x5582e234 in main_loop () at vl.c:2014
#27 0x55835697 in main (argc=14, argv=0x7fffe298, 
envp=0x7fffe310) at vl.c:4362

 ---
  qdev-monitor.c | 2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/qdev-monitor.c b/qdev-monitor.c
 index b1ce26a..531b258 100644
 --- a/qdev-monitor.c
 +++ b/qdev-monitor.c
 @@ -518,6 +518,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
  }
  if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
  qdev_free(qdev);
 +object_unref(OBJECT(qdev));
  return NULL;
  }
  if (qdev-id) {
 @@ -531,6 +532,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
  g_free(name);
  }
  if (qdev_init(qdev)  0) {
 + 

Re: [Qemu-devel] [PATCH 05/21] char: add qemu_chr_fe_event()

2013-11-18 Thread Alon Levy
On 11/18/2013 02:25 PM, Marc-André Lureau wrote:
 From: Marc-André Lureau marcandre.lur...@redhat.com

The patch description is incomplete, or the patch should be split - this
patch also implements qemu_chr_fe_event for spiceport.

 
 Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
 ---
  include/sysemu/char.h | 10 ++
  qemu-char.c   |  7 +++
  spice-qemu-char.c | 10 ++
  3 files changed, 27 insertions(+)
 
 diff --git a/include/sysemu/char.h b/include/sysemu/char.h
 index ad101d9..d23c8f1 100644
 --- a/include/sysemu/char.h
 +++ b/include/sysemu/char.h
 @@ -69,6 +69,7 @@ struct CharDriverState {
  void (*chr_accept_input)(struct CharDriverState *chr);
  void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
  void (*chr_set_fe_open)(struct CharDriverState *chr, int fe_open);
 +void (*chr_fe_event)(struct CharDriverState *chr, int event);
  void *opaque;
  char *label;
  char *filename;
 @@ -138,6 +139,15 @@ void qemu_chr_fe_set_echo(struct CharDriverState *chr, 
 bool echo);
  void qemu_chr_fe_set_open(struct CharDriverState *chr, int fe_open);
  
  /**
 + * @qemu_chr_fe_event:
 + *
 + * Send an event from the back end to the front end.
 + *
 + * @event the event to send
 + */
 +void qemu_chr_fe_event(CharDriverState *s, int event);
 +
 +/**
   * @qemu_chr_fe_printf:
   *
   * Write to a character backend using a printf style interface.
 diff --git a/qemu-char.c b/qemu-char.c
 index e00f84c..418dc69 100644
 --- a/qemu-char.c
 +++ b/qemu-char.c
 @@ -3353,6 +3353,13 @@ void qemu_chr_fe_set_open(struct CharDriverState *chr, 
 int fe_open)
  }
  }
  
 +void qemu_chr_fe_event(struct CharDriverState *chr, int event)
 +{
 +if (chr-chr_fe_event) {
 +chr-chr_fe_event(chr, event);
 +}
 +}
 +
  int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond,
GIOFunc func, void *user_data)
  {
 diff --git a/spice-qemu-char.c b/spice-qemu-char.c
 index e074d9e..16439c5 100644
 --- a/spice-qemu-char.c
 +++ b/spice-qemu-char.c
 @@ -222,6 +222,15 @@ static void spice_chr_set_fe_open(struct CharDriverState 
 *chr, int fe_open)
  }
  }
  
 +static void spice_chr_fe_event(struct CharDriverState *chr, int event)
 +{
 +#if SPICE_SERVER_VERSION = 0x000c02
 +SpiceCharDriver *s = chr-opaque;
 +
 +spice_server_port_event(s-sin, event);
 +#endif
 +}
 +
  static void print_allowed_subtypes(void)
  {
  const char** psubtype;
 @@ -255,6 +264,7 @@ static CharDriverState *chr_open(const char *subtype)
  chr-chr_close = spice_chr_close;
  chr-chr_set_fe_open = spice_chr_set_fe_open;
  chr-explicit_be_open = true;
 +chr-chr_fe_event = spice_chr_fe_event;
  
  QLIST_INSERT_HEAD(spice_chars, s, next);
  
 




[Qemu-devel] [PATCH 02/21] spice-char: remove unused field

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
---
 spice-qemu-char.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 6d147a7..e074d9e 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -11,7 +11,6 @@
 typedef struct SpiceCharDriver {
 CharDriverState*  chr;
 SpiceCharDeviceInstance sin;
-char  *subtype;
 bool  active;
 bool  blocked;
 const uint8_t *datapos;
-- 
1.8.3.1




Re: [Qemu-devel] [RESEND][PATCH 1.7] migration: drop MADVISE_DONT_NEED for incoming zero pages

2013-11-18 Thread Peter Lieven

On 24.10.2013 11:14, Paolo Bonzini wrote:

Il 24/10/2013 08:21, Peter Lieven ha scritto:

Additionally we memmap target memory so it is essentially
zero initialized (except for e.g. option roms and bios which are loaded
into target memory although they shouldn't).

It was reported recently that this madvise causes a performance degradation
in some situations. As the madvise should only be called rarely and if it's 
called
it is likely on a busy page (it was non-zero and changed to zero during 
migration)
drop it completely.

Tagging this patch for 1.7.

has this been merged?

Peter



Re: [Qemu-devel] [Spice-devel] [PATCH 20/21] spice-core: allow an interface to be in AIO context

2013-11-18 Thread Alon Levy
On 11/18/2013 02:25 PM, Marc-André Lureau wrote:
 The Spice block driver must be able complete operations within a AIO
 context only.
 
 Spice is currently only running within the main loop, and doesn't allow
 the block driver to complete operations, such as flush during migration.
 
 This patch allows a Spice interface to be associated with a different
 context. Currently, the interface user_data is simply used to
 differentiate main loop from AIO, but could later be used to associate
 an interface with a particular thread.
 
 Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
 ---
  include/ui/qemu-spice.h |  2 +-
  qemu-char.c |  2 +-
  spice-qemu-char.c   |  9 +++
  ui/spice-core.c | 62 
 +++--
  4 files changed, 62 insertions(+), 13 deletions(-)
 
 diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
 index a93b4b2..d5ba702 100644
 --- a/include/ui/qemu-spice.h
 +++ b/include/ui/qemu-spice.h
 @@ -48,7 +48,7 @@ int qemu_spice_migrate_info(const char *hostname, int port, 
 int tls_port,
  void do_info_spice_print(Monitor *mon, const QObject *data);
  void do_info_spice(Monitor *mon, QObject **ret_data);
  
 -CharDriverState *qemu_chr_open_spice_vmc(const char *type);
 +CharDriverState *qemu_chr_open_spice_vmc(const char *type, bool aio);
  #if SPICE_SERVER_VERSION = 0x000c02
  CharDriverState *qemu_chr_open_spice_port(const char *name);
  void qemu_spice_register_ports(void);
 diff --git a/qemu-char.c b/qemu-char.c
 index 418dc69..bfac7bf 100644
 --- a/qemu-char.c
 +++ b/qemu-char.c
 @@ -3747,7 +3747,7 @@ ChardevReturn *qmp_chardev_add(const char *id, 
 ChardevBackend *backend,
  #endif
  #ifdef CONFIG_SPICE
  case CHARDEV_BACKEND_KIND_SPICEVMC:
 -chr = qemu_chr_open_spice_vmc(backend-spicevmc-type);
 +chr = qemu_chr_open_spice_vmc(backend-spicevmc-type, false);
  break;
  case CHARDEV_BACKEND_KIND_SPICEPORT:
  chr = qemu_chr_open_spice_port(backend-spiceport-fqdn);
 diff --git a/spice-qemu-char.c b/spice-qemu-char.c
 index 16439c5..421f7de 100644
 --- a/spice-qemu-char.c
 +++ b/spice-qemu-char.c
 @@ -248,7 +248,7 @@ static void print_allowed_subtypes(void)
  fprintf(stderr, \n);
  }
  
 -static CharDriverState *chr_open(const char *subtype)
 +static CharDriverState *chr_open(const char *subtype, bool aio)
  {
  CharDriverState *chr;
  SpiceCharDriver *s;
 @@ -257,6 +257,7 @@ static CharDriverState *chr_open(const char *subtype)
  s = g_malloc0(sizeof(SpiceCharDriver));
  s-chr = chr;
  s-active = false;
 +s-sin.base.user_data = (void*)aio;
  s-sin.subtype = g_strdup(subtype);
  chr-opaque = s;
  chr-chr_write = spice_chr_write;
 @@ -271,7 +272,7 @@ static CharDriverState *chr_open(const char *subtype)
  return chr;
  }
  
 -CharDriverState *qemu_chr_open_spice_vmc(const char *type)
 +CharDriverState *qemu_chr_open_spice_vmc(const char *type, bool aio)
  {
  const char **psubtype = spice_server_char_device_recognized_subtypes();
  
 @@ -291,7 +292,7 @@ CharDriverState *qemu_chr_open_spice_vmc(const char *type)
  return NULL;
  }
  
 -return chr_open(type);
 +return chr_open(type, aio);
  }
  
  #if SPICE_SERVER_VERSION = 0x000c02
 @@ -305,7 +306,7 @@ CharDriverState *qemu_chr_open_spice_port(const char 
 *name)
  return NULL;
  }
  
 -chr = chr_open(port);
 +chr = chr_open(port, false);
  s = chr-opaque;
  s-sin.portname = g_strdup(name);
  
 diff --git a/ui/spice-core.c b/ui/spice-core.c
 index e4d533d..0f69630 100644
 --- a/ui/spice-core.c
 +++ b/ui/spice-core.c
 @@ -53,34 +53,64 @@ static QemuThread me;
  
  struct SpiceTimer {
  QEMUTimer *timer;
 +QEMUBH *bh;
  QTAILQ_ENTRY(SpiceTimer) next;
  };
  static QTAILQ_HEAD(, SpiceTimer) timers = QTAILQ_HEAD_INITIALIZER(timers);
  
 +#if SPICE_INTERFACE_CORE_MAJOR = 2
 +static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque, 
 SpiceBaseInstance *sin)
 +#else
  static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque)
 +#endif
  {
  SpiceTimer *timer;
  
  timer = g_malloc0(sizeof(*timer));
 -timer-timer = timer_new_ms(QEMU_CLOCK_REALTIME, func, opaque);
 +
 +#if SPICE_INTERFACE_CORE_MAJOR = 2
 +bool aio = sin ? !!sin-user_data : false;

Shouldn't there be a cast there:
(bool)sin-user_data
?


 +if (aio) {
 +fprintf(stderr, AIO doesn't have timers yet, using BH\n);
 +timer-bh = qemu_bh_new(func, opaque);
 +} else
 +#endif
 +{
 +timer-timer = timer_new_ms(QEMU_CLOCK_REALTIME, func, opaque);
 +}
 +
  QTAILQ_INSERT_TAIL(timers, timer, next);
 +
  return timer;
  }
  
  static void timer_start(SpiceTimer *timer, uint32_t ms)
  {
 -timer_mod(timer-timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + ms);
 +if (timer-bh) {
 +qemu_bh_schedule_idle(timer-bh); /* at least every 10ms, see 
 async.c */
 +} else {
 +

Re: [Qemu-devel] [PATCH] net: move rxfilter_notify() to net.c

2013-11-18 Thread Amos Kong
On Fri, Nov 15, 2013 at 11:49:27AM -0500, Vlad Yasevich wrote:
 On 11/15/2013 10:27 AM, Stefan Hajnoczi wrote:
 On Tue, Nov 05, 2013 at 07:00:48PM +0800, Amos Kong wrote:
 @@ -545,7 +523,7 @@ static int virtio_net_handle_rx_mode(VirtIONet *n, 
 uint8_t cmd,
   return VIRTIO_NET_ERR;
   }
 
 -rxfilter_notify(nc);
 +rxfilter_notify(nc, object_get_canonical_path(OBJECT(n-qdev)));
 
   return VIRTIO_NET_OK;
   }
 [...]
 diff --git a/net/net.c b/net/net.c
 index c330c9a..f41a457 100644
 --- a/net/net.c
 +++ b/net/net.c
 @@ -40,6 +40,7 @@
   #include qapi-visit.h
   #include qapi/opts-visitor.h
   #include qapi/dealloc-visitor.h
 +#include qapi/qmp/qjson.h
 
   /* Net bridge is currently not supported for W32. */
   #if !defined(_WIN32)
 @@ -962,6 +963,25 @@ void print_net_client(Monitor *mon, NetClientState *nc)
  nc-info_str);
   }
 
 +void rxfilter_notify(NetClientState *nc, const char *path)
 +{
 +QObject *event_data;
 +
 +if (nc-rxfilter_notify_enabled) {
 +if (nc-name) {
 +event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
 +   nc-name, path);
 +} else {
 +event_data = qobject_from_jsonf({ 'path': %s }, path);
 +}
 +monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
 +qobject_decref(event_data);
 +
 +/* disable event notification to avoid events flooding */
 +nc-rxfilter_notify_enabled = 0;
 +}
 +}
 
 Please fix the memory leak:
 object_get_canonical_path() returns a gchar* that the caller must free.

 Wow, this memory leak is all over the place and not just in this patch.

Yes, my v2 fix the memory leak in rxfilter_notify().
I just check the code, your patch fixed _the last_ leak
of object_get_canonical_path(). Thanks.
 
 -vlad

-- 
Amos.



Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Michael Matz
Hi,

On Mon, 18 Nov 2013, Claudio Fontana wrote:

  +case 3:
  +tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
  +break;
  
  Incorrect rotate for 32bit?

32bit rotates and shifts were fixed in a patch later than the 60er series 
Alex posted.  See attached.  (Generally there are many fixes to emulated 
instructions in that branch)

  +if (!shift_amount  source == 0x1f) {
 
 Besides the comment, is this correct?

No, it needs to check for opc == 1.

  +tcg_dest = cpu_reg(dest);
  +switch (opc) {
  +case 0x0:
  +case 0x3:
  +tcg_gen_and_i64(tcg_dest, cpu_reg(source), tcg_op2);
  +break;
  +case 0x1:
  +tcg_gen_or_i64(tcg_dest, cpu_reg(source), tcg_op2);
  +break;
  +case 0x2:
  +tcg_gen_xor_i64(tcg_dest, cpu_reg(source), tcg_op2);
  +break;
  +}
  +
  +if (is_32bit) {
  +tcg_gen_ext32u_i64(tcg_dest, tcg_dest);
  +}
  +
  +if (setflags) {
  +gen_helper_pstate_add(pstate, pstate, tcg_dest, cpu_reg(31), 
  tcg_dest);
  +}
  
  Incorrect flags generated.  They're different between add/sub and logical.
  In particular, C and V are always zero.

That's done correctly with the fixed pstate helpers coming with a later 
patch (see attached as well).  reg31 is zero, so that's flags as if for 
dest == dest + 0, and PSTATE_C and PSTATE_V will be zero.  That is, the 
logical flags are the same as the arithmetic flags for result plus zero 
with no carry_in.


Ciao,
Michael.From df54486da31d6329696effa61096eda5ab85395a Mon Sep 17 00:00:00 2001
From: Michael Matz m...@suse.de
Date: Sun, 24 Mar 2013 02:52:42 +0100
Subject: [PATCH] Fix 32bit rotates.

The 32bit shifts generally weren't careful with the upper parts,
either bits could leak in (for right shift) or leak or (for left shift).
And rotate was completely off, rotating around bit 63, not 31.
This fixes the CAST5 hash algorithm.
---
 target-arm/translate-a64.c | 30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
index 96dc281..e3941a1 100644
--- a/target-arm/translate-a64.c
+++ b/target-arm/translate-a64.c
@@ -596,25 +596,49 @@ static TCGv_i64 get_shift(int reg, int shift_type, TCGv_i64 tcg_shift,
 r = tcg_temp_new_i64();
 
 /* XXX carry_out */
+/* Careful with the width.  We work on 64bit, but must make sure
+   that we zero-extend the result on out, and ignore any upper bits,
+   that might still be set in that register.  */
 switch (shift_type) {
 case 0: /* LSL */
+	/* left shift is easy, simply zero-extend on out */
 tcg_gen_shl_i64(r, cpu_reg(reg), tcg_shift);
+	if (is_32bit)
+	  tcg_gen_ext32u_i64 (r, r);
 break;
 case 1: /* LSR */
-tcg_gen_shr_i64(r, cpu_reg(reg), tcg_shift);
+	/* For logical right shift we zero extend first, to zero
+	   the upper bits.  We don't need to extend on out.  */
+	if (is_32bit) {
+	tcg_gen_ext32u_i64 (r, cpu_reg(reg));
+	tcg_gen_shr_i64 (r, r, tcg_shift);
+	} else
+	  tcg_gen_shr_i64(r, cpu_reg(reg), tcg_shift);
 break;
 case 2: /* ASR */
+	/* For arithmetic right shift we sign extend first, then shift,
+	   and then need to clear the upper bits again.  */
 if (is_32bit) {
 TCGv_i64 tcg_tmp = tcg_temp_new_i64();
 tcg_gen_ext32s_i64(tcg_tmp, cpu_reg(reg));
 tcg_gen_sar_i64(r, tcg_tmp, tcg_shift);
+	tcg_gen_ext32u_i64 (r, r);
 tcg_temp_free_i64(tcg_tmp);
 } else {
 tcg_gen_sar_i64(r, cpu_reg(reg), tcg_shift);
 }
 break;
-case 3:
-tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
+case 3: /* ROR */
+	/* For rotation extending doesn't help, we really have to use
+	   a 32bit rotate.  */
+	if (is_32bit) {
+	TCGv_i32 tmp = tcg_temp_new_i32();
+tcg_gen_trunc_i64_i32(tmp, cpu_reg(reg));
+	tcg_gen_rotr_i32(tmp, tmp, tcg_shift);
+tcg_gen_extu_i32_i64(r, tmp);
+tcg_temp_free_i32(tmp);
+	} else
+	  tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
 break;
 }
 
-- 
1.8.1.4

From 33137f8a660750d7d8598c7e467f4ccc8dc5ef85 Mon Sep 17 00:00:00 2001
From: Michael Matz m...@suse.de
Date: Sat, 23 Mar 2013 04:53:44 +0100
Subject: [PATCH] Fix the pstate flags helpers

ADCS and SBCS/SUBS sometimes gave the wrong results
for the C and V flags.  This fixes it.
---
 target-arm/helper-a64.c | 52 -
 1 file changed, 12 insertions(+), 40 deletions(-)

diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
index 4375bf0..4fcb09b 100644
--- a/target-arm/helper-a64.c
+++ b/target-arm/helper-a64.c
@@ -7,8 +7,6 @@
 
 uint32_t HELPER(pstate_add)(uint32_t pstate, uint64_t a1, uint64_t a2, uint64_t ar)
 {
-int64_t s1 = a1;
-int64_t s2 = a2;
 int64_t sr = ar;
 
 pstate = ~(PSTATE_N | PSTATE_Z | PSTATE_C | PSTATE_V);
@@ -21,11 +19,15 @@ 

[Qemu-devel] [PATCH 19/21] sysemu: add vm_start_hold/release

2013-11-18 Thread Marc-André Lureau
This is a simple solution (or hack?) to allow the Spice block driver to
hold the VM from starting before the migration state is completed.

During migration, the destination qemu needs to initialize the NBD
session. This requires waiting for the Spice client and communication
before the VM is started, but using a running main loop.

Signed-off-by: Marc-André Lureau marcandre.lur...@gmail.com
---
 include/sysemu/sysemu.h |  2 ++
 vl.c| 17 +
 2 files changed, 19 insertions(+)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index cd5791e..a76a6e7 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -38,6 +38,8 @@ void vm_state_notify(int running, RunState state);
 #define VMRESET_REPORT   true
 
 void vm_start(void);
+void vm_start_hold(void);
+void vm_start_release(void);
 int vm_stop(RunState state);
 int vm_stop_force_state(RunState state);
 
diff --git a/vl.c b/vl.c
index 4ad15b8..8905ba5 100644
--- a/vl.c
+++ b/vl.c
@@ -1690,8 +1690,25 @@ void vm_state_notify(int running, RunState state)
 }
 }
 
+static int start_hold;
+
+void vm_start_hold(void)
+{
+start_hold++;
+}
+
+void vm_start_release(void)
+{
+start_hold--;
+vm_start();
+}
+
 void vm_start(void)
 {
+if (start_hold != 0) {
+return;
+}
+
 if (!runstate_is_running()) {
 cpu_enable_ticks();
 runstate_set(RUN_STATE_RUNNING);
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Peter Maydell
On 18 November 2013 13:12, Michael Matz m...@suse.de wrote:
 Hi,

 On Mon, 18 Nov 2013, Claudio Fontana wrote:

  +case 3:
  +tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
  +break;
 
  Incorrect rotate for 32bit?

 32bit rotates and shifts were fixed in a patch later than the 60er series
 Alex posted.  See attached.  (Generally there are many fixes to emulated
 instructions in that branch)

I think we're going to need to look through and fold in those
fixes, otherwise we'll end up reduplicating that work in the
course of code review :-(

-- PMM



[Qemu-devel] [PATCH 16/21] block: learn to open a driver with a given opaque

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

If the block driver is given an opaque data, there is no need to
allocate a new one. This allows to pass an existing driver state to the
new driver.

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 block.c | 48 +---
 1 file changed, 29 insertions(+), 19 deletions(-)

diff --git a/block.c b/block.c
index 9e7632e..f154979 100644
--- a/block.c
+++ b/block.c
@@ -319,7 +319,7 @@ void bdrv_register(BlockDriver *bdrv)
 
 /* create a new block device (by default it is empty) */
 static BlockDriverState *bdrv_new_int(const char *device_name,
-BlockDriverState *child)
+BlockDriverState *child, void *opaque)
 {
 BlockDriverState *bs;
 
@@ -344,13 +344,14 @@ static BlockDriverState *bdrv_new_int(const char 
*device_name,
 child-device_name);
 }
 }
+bs-opaque = opaque;
 
 return bs;
 }
 
 BlockDriverState *bdrv_new(const char *device_name)
 {
-return bdrv_new_int(device_name, NULL);
+return bdrv_new_int(device_name, NULL, NULL);
 }
 
 void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify)
@@ -810,7 +811,9 @@ static int bdrv_open_common(BlockDriverState *bs, 
BlockDriverState *file,
 }
 
 bs-drv = drv;
-bs-opaque = g_malloc0(drv-instance_size);
+if (bs-opaque == NULL) {
+bs-opaque = g_malloc0(drv-instance_size);
+}
 
 bs-enable_write_cache = !!(flags  BDRV_O_CACHE_WB);
 
@@ -864,7 +867,8 @@ free_and_fail:
 }
 
 static int bdrv_file_open_int(BlockDriverState **pbs, const char *filename,
-QDict *options, int flags, BlockDriverState *child, Error **errp)
+QDict *options, int flags, BlockDriverState *child, void *opaque,
+Error **errp)
 {
 BlockDriverState *bs;
 BlockDriver *drv;
@@ -878,7 +882,7 @@ static int bdrv_file_open_int(BlockDriverState **pbs, const 
char *filename,
 options = qdict_new();
 }
 
-bs = bdrv_new_int(, child);
+bs = bdrv_new_int(, child, opaque);
 bs-options = options;
 options = qdict_clone_shallow(options);
 
@@ -975,18 +979,11 @@ fail:
 int bdrv_file_open(BlockDriverState **pbs, const char *filename,
QDict *options, int flags, Error **errp)
 {
-return bdrv_file_open_int(pbs, filename, options, flags, NULL, errp);
+return bdrv_file_open_int(pbs, filename, options, flags, NULL, NULL, errp);
 }
 
-/*
- * Opens the backing file for a BlockDriverState if not yet open
- *
- * options is a QDict of options to pass to the block drivers, or NULL for an
- * empty set of options. The reference to the QDict is transferred to this
- * function (even on failure), so if the caller intends to reuse the 
dictionary,
- * it needs to use QINCREF() before calling bdrv_file_open.
- */
-int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
+static int bdrv_open_backing_file_int(BlockDriverState *bs,
+QDict *options, void *opaque, Error **errp)
 {
 char backing_filename[PATH_MAX];
 int back_flags, ret;
@@ -1014,7 +1011,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict 
*options, Error **errp)
sizeof(backing_filename));
 }
 
-bs-backing_hd = bdrv_new_int(, bs);
+bs-backing_hd = bdrv_new_int(, bs, opaque);
 if (bs-backing_format[0] != '\0') {
 back_drv = bdrv_find_format(bs-backing_format);
 }
@@ -1038,6 +1035,19 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict 
*options, Error **errp)
 return 0;
 }
 
+/*
+ * Opens the backing file for a BlockDriverState if not yet open
+ *
+ * options is a QDict of options to pass to the block drivers, or NULL for an
+ * empty set of options. The reference to the QDict is transferred to this
+ * function (even on failure), so if the caller intends to reuse the 
dictionary,
+ * it needs to use QINCREF() before calling bdrv_file_open.
+ */
+int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
+{
+return bdrv_open_backing_file_int(bs, options, NULL, errp);
+}
+
 static int make_snapshot(BlockDriverState *bs, int64_t total_size,
  const char **pfilename, BlockDriver **pdrv,
  Error **errp)
@@ -1145,7 +1155,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
 }
 
 if (total_size == -1) {
-bs1 = bdrv_new_int(, NULL);
+bs1 = bdrv_new_int(, NULL, NULL);
 ret = bdrv_open(bs1, filename, NULL, 0, drv, local_err);
 if (ret  0) {
 bdrv_unref(bs1);
@@ -1171,7 +1181,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
 
 ret = bdrv_file_open_int(file, filename, file_options,
  bdrv_open_flags(bs, flags | BDRV_O_UNMAP),
- bs, local_err);
+ bs, NULL, local_err);
 if (ret  0) {
 

[Qemu-devel] [PATCH 09/21] nbd: make session_close() idempotent

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 block/nbd-client.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index e29227b..c0ad2c2 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -337,7 +337,12 @@ static void nbd_teardown_connection(NbdClientSession 
*client)
 
 void nbd_client_session_close(NbdClientSession *client)
 {
+if (!client-bs) {
+return;
+}
+
 nbd_teardown_connection(client);
+client-bs = NULL;
 }
 
 int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
-- 
1.8.3.1




[Qemu-devel] [PATCH 12/21] block: save the associated child name in BlockDriverState

2013-11-18 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@redhat.com

This allows the Spice block driver to eject the associated device.

Signed-off-by: Marc-André Lureau marcandre.lur...@redhat.com
---
 block.c   | 58 ---
 include/block/block_int.h |  1 +
 2 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/block.c b/block.c
index 6d5c804..0558525 100644
--- a/block.c
+++ b/block.c
@@ -318,7 +318,8 @@ void bdrv_register(BlockDriver *bdrv)
 }
 
 /* create a new block device (by default it is empty) */
-BlockDriverState *bdrv_new(const char *device_name)
+static BlockDriverState *bdrv_new_int(const char *device_name,
+BlockDriverState *child)
 {
 BlockDriverState *bs;
 
@@ -334,9 +335,24 @@ BlockDriverState *bdrv_new(const char *device_name)
 qemu_co_queue_init(bs-throttled_reqs[1]);
 bs-refcnt = 1;
 
+if (child) {
+if (strlen(child-child_device_name)) {
+pstrcpy(bs-child_device_name, sizeof(bs-child_device_name),
+child-child_device_name);
+} else {
+pstrcpy(bs-child_device_name, sizeof(bs-child_device_name),
+child-device_name);
+}
+}
+
 return bs;
 }
 
+BlockDriverState *bdrv_new(const char *device_name)
+{
+return bdrv_new_int(device_name, NULL);
+}
+
 void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify)
 {
 notifier_list_add(bs-close_notifiers, notify);
@@ -847,16 +863,8 @@ free_and_fail:
 return ret;
 }
 
-/*
- * Opens a file using a protocol (file, host_device, nbd, ...)
- *
- * options is a QDict of options to pass to the block drivers, or NULL for an
- * empty set of options. The reference to the QDict belongs to the block layer
- * after the call (even on failure), so if the caller intends to reuse the
- * dictionary, it needs to use QINCREF() before calling bdrv_file_open.
- */
-int bdrv_file_open(BlockDriverState **pbs, const char *filename,
-   QDict *options, int flags, Error **errp)
+static int bdrv_file_open_int(BlockDriverState **pbs, const char *filename,
+QDict *options, int flags, BlockDriverState *child, Error **errp)
 {
 BlockDriverState *bs;
 BlockDriver *drv;
@@ -870,7 +878,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char 
*filename,
 options = qdict_new();
 }
 
-bs = bdrv_new();
+bs = bdrv_new_int(, child);
 bs-options = options;
 options = qdict_clone_shallow(options);
 
@@ -957,6 +965,20 @@ fail:
 }
 
 /*
+ * Opens a file using a protocol (file, host_device, nbd, ...)
+ *
+ * options is a QDict of options to pass to the block drivers, or NULL for an
+ * empty set of options. The reference to the QDict belongs to the block layer
+ * after the call (even on failure), so if the caller intends to reuse the
+ * dictionary, it needs to use QINCREF() before calling bdrv_file_open.
+ */
+int bdrv_file_open(BlockDriverState **pbs, const char *filename,
+   QDict *options, int flags, Error **errp)
+{
+return bdrv_file_open_int(pbs, filename, options, flags, NULL, errp);
+}
+
+/*
  * Opens the backing file for a BlockDriverState if not yet open
  *
  * options is a QDict of options to pass to the block drivers, or NULL for an
@@ -992,8 +1014,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict 
*options, Error **errp)
sizeof(backing_filename));
 }
 
-bs-backing_hd = bdrv_new();
-
+bs-backing_hd = bdrv_new_int(, bs);
 if (bs-backing_format[0] != '\0') {
 back_drv = bdrv_find_format(bs-backing_format);
 }
@@ -1063,7 +1084,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
instead of opening 'filename' directly */
 
 /* if there is a backing file, use it */
-bs1 = bdrv_new();
+bs1 = bdrv_new_int(, bs);
 ret = bdrv_open(bs1, filename, NULL, 0, drv, local_err);
 if (ret  0) {
 bdrv_unref(bs1);
@@ -1124,8 +1145,9 @@ int bdrv_open(BlockDriverState *bs, const char *filename, 
QDict *options,
 
 qdict_extract_subqdict(options, file_options, file.);
 
-ret = bdrv_file_open(file, filename, file_options,
- bdrv_open_flags(bs, flags | BDRV_O_UNMAP), 
local_err);
+ret = bdrv_file_open_int(file, filename, file_options,
+ bdrv_open_flags(bs, flags | BDRV_O_UNMAP),
+ bs, local_err);
 if (ret  0) {
 goto fail;
 }
@@ -1883,7 +1905,7 @@ int bdrv_commit(BlockDriverState *bs)
 
 if (!drv)
 return -ENOMEDIUM;
-
+
 if (!bs-backing_hd) {
 return -ENOTSUP;
 }
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 1666066..e0f31dc 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -301,6 +301,7 @@ struct BlockDriverState {
 bool iostatus_enabled;
 BlockDeviceIoStatus iostatus;
 char 

Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Claudio Fontana
On 11/18/2013 02:15 PM, Peter Maydell wrote:
 On 18 November 2013 13:12, Michael Matz m...@suse.de wrote:
 Hi,

 On Mon, 18 Nov 2013, Claudio Fontana wrote:

 +case 3:
 +tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
 +break;

 Incorrect rotate for 32bit?

 32bit rotates and shifts were fixed in a patch later than the 60er series
 Alex posted.  See attached.  (Generally there are many fixes to emulated
 instructions in that branch)
 
 I think we're going to need to look through and fold in those
 fixes, otherwise we'll end up reduplicating that work in the
 course of code review :-(
 
 -- PMM
 

Thanks all.

Regarding the access to registers in 32 bit mode, and the consequent write to 
registers in 32 bit mode,
I am investigating how to do it a little bit more general, in the sense that 
generally when we access registers in 32bit mode
we will (often) need to ignore the upper bits of the source register, and write 
zero to the destination register.
Not always but often. This could be done once for all to reduce the chances of 
mistakes.

C.





[Qemu-devel] [Bug 1245924] Re: mips64el magnum emulation broken

2013-11-18 Thread Darkstar
Yeah, that patch looks better, I was already wondering why nobody seemed
to care since it's a pretty easy fix. I have a another bug I want to
report with MIPS Magnum but it depends on this bug here so I'd rather
wait until this is fixed before submitting the other bug report (or can
I make a bug depend on another bug somehow?)

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

Title:
  mips64el magnum emulation broken

Status in QEMU:
  New

Bug description:
  I'm trying to run the following:
  qemu-system-mips64el --machine magnum [...]

  The qemu binaries from (k)ubuntu work fine. info version shows
  1.5.0 (Debian 1.5.0+dfsg-3ubuntu5)

  When I try qemu 1.6.1 (compiled from source .tar.bz2), however, qemu
  only shows a black screen when starting.

  I'm using the following BIOS:
  https://mega.co.nz/#!gg0WBYpJ!MqTL3AFPjf4SJipdYgRK3HtFDIxA59YwI6ay5XI3KEc
  which is the exact one linked to in the first guide below (can also be 
downloaded from there)

  I'm following these guides on installing NT4 on qemu
  http://gunkies.org/wiki/Installing_Windows_NT_4.0_on_Qemu(MIPS)
  http://virtuallyfun.superglobalmegacorp.com/?p=2255

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



Re: [Qemu-devel] [PATCH v2] net: move rxfilter_notify() to net.c

2013-11-18 Thread Stefan Hajnoczi
On Mon, Nov 18, 2013 at 04:20:12PM +0800, Amos Kong wrote:
 @@ -967,6 +968,27 @@ void print_net_client(Monitor *mon, NetClientState *nc)
 nc-info_str);
  }
  
 +void rxfilter_notify(NetClientState *nc, Object *obj)
 +{
 +QObject *event_data;
 +gchar *path = object_get_canonical_path(obj);
 +
 +if (nc-rxfilter_notify_enabled) {
 +if (nc-name) {
 +event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
 +nc-name, path);
 +} else {
 +event_data = qobject_from_jsonf({ 'path': %s }, path);
 +}
 +monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
 +qobject_decref(event_data);
 +
 +/* disable event notification to avoid events flooding */
 +nc-rxfilter_notify_enabled = 0;

Only hw/net/virtio-net.c uses nc-rxfilter_notify_enabled.  This
function isn't reusable in its current form so I'm left wondering what
the point of this patch is?

If you have patches that invoke rxfilter_notify() from other NICs then
please submit them together in a series.

Otherwise, let's not move things around just for the sake of it,
especially when the refactoring is not done correctly.

Stefan



Re: [Qemu-devel] [PATCH] HMP: snapshot_blkdev can not consider //root/sn1 and /root/sn1 as the same file

2013-11-18 Thread Stefan Hajnoczi
On Fri, Nov 15, 2013 at 10:21:40AM -0700, Eric Blake wrote:
 On 11/15/2013 09:42 AM, Max Reitz wrote:
 
  Actually, the same problem can occur anyway if you have a path with a
  couple of “.” and “..” in it – or even just a hardlink. Thus, to be
  completely safe, we'd have to check whether the snapshot file (if it
  already exists) has a different inode number and/or is located on a
  different filesystem.
 
 See also the recent thread on detecting backing file loops - this should
 be part of that solution (if it isn't already):
 https://lists.gnu.org/archive/html/qemu-devel/2013-11/msg01840.html
 
 
 Backing file loops might get away with string-only detection; but then I
 start to worry that the string-only detection will misbehave on relative
 paths (consider: /dir1/a - /dir1/b [backed by relative 'a'] - /dir2/a
 [backed by absolute /dir1/b] - /dir2/a [backed by relative 'a']);
 devno/inode pairs are the only reliable to detect loops when only the
 filesystem is involved, but then you also introduce network protocols
 (and there, it's worse: gluster://host1/vol/img and
 gluster://host2/vol/img could be the same file, if host1 and host2 are
 part of the same storage cluster, but there is no devno/inode to tell
 you that).

Detecting identical files is not a problem that can be solved in the
general case.  Once network storage comes into play we don't have the
ability to check file identity.

Users can misconfigure QEMU if they try hard enough.  Filename string
manipulation is very error-prone and I'd rather just avoid it than
provide a false sense of security.

What's the real use case for this patch?

Stefan



[Qemu-devel] [Bug 1252270] [NEW] installing NT4 on MIPS Magnum/Jazz asserts

2013-11-18 Thread Darkstar
Public bug reported:

While installing NT4 on MIPS Magnum (Jazz), when the NT Installer tries
to format the harddisk, QEmu 1.6.1 crashes with an assertion:

qemu-system-mips64el: g364: invalid read at [00102000]
qemu-system-mips64el: hw/scsi/scsi-bus.c:1577: scsi_req_data: Assertion 
`req-cmd.mode != SCSI_XFER_NONE' failed.
./nt4mips.sh: line 3: 20336 Aborted (core dumped) 
./qemu-system-mips64el --machine magnum -m 64 -net nic -net user -hda nt4.dsk 
-cdrom NTWKS40D.ISO -global ds1225y.filename=nvram.bin -global 
ds1225y.size=16384

This assertion also occurred with the stock Ubuntu version of QEmu
(1.5.0 (Debian 1.5.0+dfsg-3ubuntu5)) which I tried before.

Note that to even get this far, you need the patch mentioned in
BUG1245924, otherwise QEmu 1.6.1 won't even start/boot at all

NT4 installation guide I'm following:
http://gunkies.org/wiki/Installing_Windows_NT_4.0_on_Qemu(MIPS)
http://virtuallyfun.superglobalmegacorp.com/?p=2255

** Affects: qemu
 Importance: Undecided
 Status: New

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

Title:
  installing NT4 on MIPS Magnum/Jazz asserts

Status in QEMU:
  New

Bug description:
  While installing NT4 on MIPS Magnum (Jazz), when the NT Installer
  tries to format the harddisk, QEmu 1.6.1 crashes with an assertion:

  qemu-system-mips64el: g364: invalid read at [00102000]
  qemu-system-mips64el: hw/scsi/scsi-bus.c:1577: scsi_req_data: Assertion 
`req-cmd.mode != SCSI_XFER_NONE' failed.
  ./nt4mips.sh: line 3: 20336 Aborted (core dumped) 
./qemu-system-mips64el --machine magnum -m 64 -net nic -net user -hda nt4.dsk 
-cdrom NTWKS40D.ISO -global ds1225y.filename=nvram.bin -global 
ds1225y.size=16384

  This assertion also occurred with the stock Ubuntu version of QEmu
  (1.5.0 (Debian 1.5.0+dfsg-3ubuntu5)) which I tried before.

  Note that to even get this far, you need the patch mentioned in
  BUG1245924, otherwise QEmu 1.6.1 won't even start/boot at all

  NT4 installation guide I'm following:
  http://gunkies.org/wiki/Installing_Windows_NT_4.0_on_Qemu(MIPS)
  http://virtuallyfun.superglobalmegacorp.com/?p=2255

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



[Qemu-devel] [Bug 1252270] Re: installing NT4 on MIPS Magnum/Jazz asserts

2013-11-18 Thread Darkstar
As a side note, that invalid read at... warning is unrelated, as it
happens right on startup

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

Title:
  installing NT4 on MIPS Magnum/Jazz asserts

Status in QEMU:
  New

Bug description:
  While installing NT4 on MIPS Magnum (Jazz), when the NT Installer
  tries to format the harddisk, QEmu 1.6.1 crashes with an assertion:

  qemu-system-mips64el: g364: invalid read at [00102000]
  qemu-system-mips64el: hw/scsi/scsi-bus.c:1577: scsi_req_data: Assertion 
`req-cmd.mode != SCSI_XFER_NONE' failed.
  ./nt4mips.sh: line 3: 20336 Aborted (core dumped) 
./qemu-system-mips64el --machine magnum -m 64 -net nic -net user -hda nt4.dsk 
-cdrom NTWKS40D.ISO -global ds1225y.filename=nvram.bin -global 
ds1225y.size=16384

  This assertion also occurred with the stock Ubuntu version of QEmu
  (1.5.0 (Debian 1.5.0+dfsg-3ubuntu5)) which I tried before.

  Note that to even get this far, you need the patch mentioned in
  BUG1245924, otherwise QEmu 1.6.1 won't even start/boot at all

  NT4 installation guide I'm following:
  http://gunkies.org/wiki/Installing_Windows_NT_4.0_on_Qemu(MIPS)
  http://virtuallyfun.superglobalmegacorp.com/?p=2255

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



Re: [Qemu-devel] [PATCH v2] net: move rxfilter_notify() to net.c

2013-11-18 Thread Amos Kong
On Mon, Nov 18, 2013 at 02:25:40PM +0100, Stefan Hajnoczi wrote:
 On Mon, Nov 18, 2013 at 04:20:12PM +0800, Amos Kong wrote:
  @@ -967,6 +968,27 @@ void print_net_client(Monitor *mon, NetClientState *nc)
  nc-info_str);
   }
   
  +void rxfilter_notify(NetClientState *nc, Object *obj)
  +{
  +QObject *event_data;
  +gchar *path = object_get_canonical_path(obj);
  +
  +if (nc-rxfilter_notify_enabled) {
  +if (nc-name) {
  +event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
  +nc-name, path);
  +} else {
  +event_data = qobject_from_jsonf({ 'path': %s }, path);
  +}
  +monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
  +qobject_decref(event_data);
  +
  +/* disable event notification to avoid events flooding */
  +nc-rxfilter_notify_enabled = 0;
 
 Only hw/net/virtio-net.c uses nc-rxfilter_notify_enabled.  This
 function isn't reusable in its current form so I'm left wondering what
 the point of this patch is?
 
 If you have patches that invoke rxfilter_notify() from other NICs then
 please submit them together in a series.

I don't have patch to change other NICs to send rxfilter notify right
now.

So I will send a patch to fix the leak. We can move the function to
net.c in future.
 
 Otherwise, let's not move things around just for the sake of it,
 especially when the refactoring is not done correctly.
 
 Stefan

-- 
Amos.



Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Claudio Fontana
Btw, in the first patch:

On 11/18/2013 02:12 PM, Michael Matz wrote:
 
 From df54486da31d6329696effa61096eda5ab85395a Mon Sep 17 00:00:00 2001
 From: Michael Matz m...@suse.de
 Date: Sun, 24 Mar 2013 02:52:42 +0100
 Subject: [PATCH] Fix 32bit rotates.
 
 The 32bit shifts generally weren't careful with the upper parts,
 either bits could leak in (for right shift) or leak or (for left shift).
 And rotate was completely off, rotating around bit 63, not 31.
 This fixes the CAST5 hash algorithm.
 ---
  target-arm/translate-a64.c | 30 +++---
  1 file changed, 27 insertions(+), 3 deletions(-)
 
 diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
 index 96dc281..e3941a1 100644
 --- a/target-arm/translate-a64.c
 +++ b/target-arm/translate-a64.c
 @@ -596,25 +596,49 @@ static TCGv_i64 get_shift(int reg, int shift_type, 
 TCGv_i64 tcg_shift,
  r = tcg_temp_new_i64();
  
  /* XXX carry_out */
 +/* Careful with the width.  We work on 64bit, but must make sure
 +   that we zero-extend the result on out, and ignore any upper bits,
 +   that might still be set in that register.  */
  switch (shift_type) {
  case 0: /* LSL */
 + /* left shift is easy, simply zero-extend on out */
  tcg_gen_shl_i64(r, cpu_reg(reg), tcg_shift);
 + if (is_32bit)
 +   tcg_gen_ext32u_i64 (r, r);
  break;
  case 1: /* LSR */
 -tcg_gen_shr_i64(r, cpu_reg(reg), tcg_shift);
 + /* For logical right shift we zero extend first, to zero
 +the upper bits.  We don't need to extend on out.  */
 + if (is_32bit) {
 + tcg_gen_ext32u_i64 (r, cpu_reg(reg));
 + tcg_gen_shr_i64 (r, r, tcg_shift);
 + } else
 +   tcg_gen_shr_i64(r, cpu_reg(reg), tcg_shift);
  break;
  case 2: /* ASR */
 + /* For arithmetic right shift we sign extend first, then shift,
 +and then need to clear the upper bits again.  */
  if (is_32bit) {
  TCGv_i64 tcg_tmp = tcg_temp_new_i64();
  tcg_gen_ext32s_i64(tcg_tmp, cpu_reg(reg));
  tcg_gen_sar_i64(r, tcg_tmp, tcg_shift);
 + tcg_gen_ext32u_i64 (r, r);
  tcg_temp_free_i64(tcg_tmp);
  } else {
  tcg_gen_sar_i64(r, cpu_reg(reg), tcg_shift);
  }
  break;
 -case 3:
 -tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
 +case 3: /* ROR */
 + /* For rotation extending doesn't help, we really have to use
 +a 32bit rotate.  */
 + if (is_32bit) {
 + TCGv_i32 tmp = tcg_temp_new_i32();
 +tcg_gen_trunc_i64_i32(tmp, cpu_reg(reg));
 + tcg_gen_rotr_i32(tmp, tmp, tcg_shift);

Isn't this problematic?
We are using gen_rotr_i32, but passing tcg_shift, which is a TCGv_i64.
I remember I had compilation failures in the past when I tried something 
similar,
so my understanding is that this can work with a certain compiler under certain 
compiler options,
but is not guaranteed to work in all cases.

I think we need to either explicitly convert the tcg_shift to a TCGv_i32, or we 
need to use an open coded version of the rotr_i64 that inserts at (32 - n) 
instead of (64 - n)

What do you think?

C.

 +tcg_gen_extu_i32_i64(r, tmp);
 +tcg_temp_free_i32(tmp);
 + } else
 +   tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
  break;
  }
  
 -- 1.8.1.4
 




Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Peter Maydell
On 18 November 2013 13:43, Claudio Fontana claudio.font...@linaro.org wrote:
 We are using gen_rotr_i32, but passing tcg_shift, which is a TCGv_i64.
 I remember I had compilation failures in the past when I tried something 
 similar,
 so my understanding is that this can work with a certain compiler under 
 certain compiler options,
 but is not guaranteed to work in all cases.

It's a debug option -- if you build with --enable-debug
then TCGv_i32/TCGv_i64 mismatches should always cause
compile failures.

-- PMM



Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Michael Matz
Hi,

On Mon, 18 Nov 2013, Peter Maydell wrote:

   +case 3:
   +tcg_gen_rotr_i64(r, cpu_reg(reg), tcg_shift);
   +break;
  
   Incorrect rotate for 32bit?
 
  32bit rotates and shifts were fixed in a patch later than the 60er series
  Alex posted.  See attached.  (Generally there are many fixes to emulated
  instructions in that branch)
 
 I think we're going to need to look through and fold in those fixes, 
 otherwise we'll end up reduplicating that work in the course of code 
 review :-(

Most probably.  Authorship will be lost :-/ I was planning to submit all 
of these once the 60er set of Alex would be applied.  If you're reworking 
that set more of less completely then it indeed makes more sense to fold 
in those things and so it'd probably be better to have them applied (i.e. 
basically have our full branch applied when dissecting things).

The commits that fix things in the a64 decoder proper (not the linux-user 
implementation) would be:

e14c1a5 softfloat: correctly handle overflow in float[32|64] to uint64 
conversion
cbc98b1 aarch64: Fix FCVTZU for single float
a91f762 aarch64: Fix UZP/ZIP/TRN
644c748 aarch64: Fix 32bit TST
2a717e8 Fix FCVTAS and FCVTAU
0dd22d0 Fix decoding of floating-fixed conversions
d52c999 Fix implementation of USHLL/SSHLL
cfbb9e1 Fix using uninitialized value
ecfdfcd Fix typo in FSUB detection
87fd8ca Increase MAX_OP_PER_INSTR
38452d8 Fix USHLL, and implement other SIMD shifts
4146d40 Fix INS element
a62437c Fix fcmp(e) with NaNs
ec2b8f3 softfloat: Fix float64_to_uint64
b003867 Fix EXTR for 32bit
df54486 Fix 32bit rotates.
33137f8 Fix the pstate flags helpers
75cb838 Don't set flush to zero by default
564e811 Fix 128bit ldr (literal)
0ff91a0 Fix long immediate constants

(That's all on top Alex' posted patchset but not git rebased onto it, top 
of Alex roughly corresponds to commit 40d66b61)


Ciao,
Michael.



[Qemu-devel] [PATCH] virtio-net: fix the memory leak in rxfilter_notify()

2013-11-18 Thread Amos Kong
object_get_canonical_path() returns a gchar*, it should be freeed by the
caller.

Signed-off-by: Amos Kong ak...@redhat.com
---
 hw/net/virtio-net.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 613f144..2b2fb57 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -198,15 +198,14 @@ static void rxfilter_notify(NetClientState *nc)
 {
 QObject *event_data;
 VirtIONet *n = qemu_get_nic_opaque(nc);
+gchar *path = object_get_canonical_path(OBJECT(n-qdev));
 
 if (nc-rxfilter_notify_enabled) {
 if (n-netclient_name) {
 event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
-n-netclient_name,
-
object_get_canonical_path(OBJECT(n-qdev)));
+n-netclient_name, path);
 } else {
-event_data = qobject_from_jsonf({ 'path': %s },
-
object_get_canonical_path(OBJECT(n-qdev)));
+event_data = qobject_from_jsonf({ 'path': %s }, path);
 }
 monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
 qobject_decref(event_data);
@@ -214,6 +213,7 @@ static void rxfilter_notify(NetClientState *nc)
 /* disable event notification to avoid events flooding */
 nc-rxfilter_notify_enabled = 0;
 }
+g_free(path);
 }
 
 static char *mac_strdup_printf(const uint8_t *mac)
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Peter Maydell
On 18 November 2013 13:46, Michael Matz m...@suse.de wrote:
 On Mon, 18 Nov 2013, Peter Maydell wrote:
 I think we're going to need to look through and fold in those fixes,
 otherwise we'll end up reduplicating that work in the course of code
 review :-(

 Most probably.  Authorship will be lost :-/ I was planning to submit all
 of these once the 60er set of Alex would be applied.  If you're reworking
 that set more of less completely then it indeed makes more sense to fold
 in those things and so it'd probably be better to have them applied (i.e.
 basically have our full branch applied when dissecting things).

 The commits that fix things in the a64 decoder proper (not the linux-user
 implementation) would be:

 e14c1a5 softfloat: correctly handle overflow in float[32|64] to uint64 
 conversion
 cbc98b1 aarch64: Fix FCVTZU for single float
 a91f762 aarch64: Fix UZP/ZIP/TRN
 644c748 aarch64: Fix 32bit TST
 2a717e8 Fix FCVTAS and FCVTAU
 0dd22d0 Fix decoding of floating-fixed conversions
 d52c999 Fix implementation of USHLL/SSHLL
 cfbb9e1 Fix using uninitialized value
 ecfdfcd Fix typo in FSUB detection
 87fd8ca Increase MAX_OP_PER_INSTR
 38452d8 Fix USHLL, and implement other SIMD shifts
 4146d40 Fix INS element
 a62437c Fix fcmp(e) with NaNs
 ec2b8f3 softfloat: Fix float64_to_uint64
 b003867 Fix EXTR for 32bit
 df54486 Fix 32bit rotates.
 33137f8 Fix the pstate flags helpers
 75cb838 Don't set flush to zero by default
 564e811 Fix 128bit ldr (literal)
 0ff91a0 Fix long immediate constants

This looks like a small enough list to be tractable to fold
in. My suggestion for authorship would be that we have the
'From' line indicate whoever wrote the bulk of the code and
add sign-off lines from both of you.

(Some of those, like the softfloat fixes, are probably
standalone patches anyway.)

thanks
-- PMM



Re: [Qemu-devel] [PATCH] virtio-net: fix the memory leak in rxfilter_notify()

2013-11-18 Thread Michael S. Tsirkin
On Mon, Nov 18, 2013 at 09:47:25PM +0800, Amos Kong wrote:
 object_get_canonical_path() returns a gchar*, it should be freeed by the
 caller.
 
 Signed-off-by: Amos Kong ak...@redhat.com

Reviewed-by: Michael S. Tsirkin m...@redhat.com

 ---
  hw/net/virtio-net.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
 index 613f144..2b2fb57 100644
 --- a/hw/net/virtio-net.c
 +++ b/hw/net/virtio-net.c
 @@ -198,15 +198,14 @@ static void rxfilter_notify(NetClientState *nc)
  {
  QObject *event_data;
  VirtIONet *n = qemu_get_nic_opaque(nc);
 +gchar *path = object_get_canonical_path(OBJECT(n-qdev));
  
  if (nc-rxfilter_notify_enabled) {

It would be a bit nicer to put gchar *path within this scope.

  if (n-netclient_name) {
  event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
 -n-netclient_name,
 -
 object_get_canonical_path(OBJECT(n-qdev)));
 +n-netclient_name, path);
  } else {
 -event_data = qobject_from_jsonf({ 'path': %s },
 -
 object_get_canonical_path(OBJECT(n-qdev)));
 +event_data = qobject_from_jsonf({ 'path': %s }, path);
  }
  monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
  qobject_decref(event_data);
 @@ -214,6 +213,7 @@ static void rxfilter_notify(NetClientState *nc)
  /* disable event notification to avoid events flooding */
  nc-rxfilter_notify_enabled = 0;
  }
 +g_free(path);
  }
  
  static char *mac_strdup_printf(const uint8_t *mac)
 -- 
 1.8.3.1



Re: [Qemu-devel] [PATCH] virtio-net: fix the memory leak in rxfilter_notify()

2013-11-18 Thread Vlad Yasevich
On 11/18/2013 08:47 AM, Amos Kong wrote:
 object_get_canonical_path() returns a gchar*, it should be freeed by the
 caller.
 
 Signed-off-by: Amos Kong ak...@redhat.com

Reviewed-by: Vlad Yasevich vyase...@redhat.com

-vlad

 ---
  hw/net/virtio-net.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
 index 613f144..2b2fb57 100644
 --- a/hw/net/virtio-net.c
 +++ b/hw/net/virtio-net.c
 @@ -198,15 +198,14 @@ static void rxfilter_notify(NetClientState *nc)
  {
  QObject *event_data;
  VirtIONet *n = qemu_get_nic_opaque(nc);
 +gchar *path = object_get_canonical_path(OBJECT(n-qdev));
  
  if (nc-rxfilter_notify_enabled) {
  if (n-netclient_name) {
  event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
 -n-netclient_name,
 -
 object_get_canonical_path(OBJECT(n-qdev)));
 +n-netclient_name, path);
  } else {
 -event_data = qobject_from_jsonf({ 'path': %s },
 -
 object_get_canonical_path(OBJECT(n-qdev)));
 +event_data = qobject_from_jsonf({ 'path': %s }, path);
  }
  monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
  qobject_decref(event_data);
 @@ -214,6 +213,7 @@ static void rxfilter_notify(NetClientState *nc)
  /* disable event notification to avoid events flooding */
  nc-rxfilter_notify_enabled = 0;
  }
 +g_free(path);
  }
  
  static char *mac_strdup_printf(const uint8_t *mac)
 




Re: [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation

2013-11-18 Thread Michael Matz
Hi,

On Mon, 18 Nov 2013, Claudio Fontana wrote:

  +tcg_gen_trunc_i64_i32(tmp, cpu_reg(reg));
  +   tcg_gen_rotr_i32(tmp, tmp, tcg_shift);
 
 Isn't this problematic?
 We are using gen_rotr_i32, but passing tcg_shift, which is a TCGv_i64.

With CONFIG_DEBUG_TCG it'll break, yes.  Though in principle there's no 
canonical relation between the two argument types for shifts and rotates 
(unlike addition for example) TCG indeed wants to ensure that 
typeof(arg2)==typeof(arg1).

 I remember I had compilation failures in the past when I tried something 
 similar, so my understanding is that this can work with a certain 
 compiler under certain compiler options, but is not guaranteed to work 
 in all cases.
 
 I think we need to either explicitly convert the tcg_shift to a 
 TCGv_i32, or we need to use an open coded version of the rotr_i64 that 
 inserts at (32 - n) instead of (64 - n)
 
 What do you think?

I think converting tcg_shift might eventually lead to better generated 
code (if tcg is optmizing enough, now or in the future, haven't checked).


Ciao,
Michael.



[Qemu-devel] First Patch, Requesting Comments

2013-11-18 Thread Varad Gautam
Hi! I'm new here, and am working on my first bug. I have posted a patch
for Bug#603872 [1] to the list.. It's incomplete right now, but please
have a look and tell me if I'm headed in the right direction. (I don't

know if I can send incomplete patches to the mailing list for suggestions
or if I run into some problems.)

Usecase: `qemu-img convert` with -p now shows the write speed.

I have a few doubts relating to the patch.


1. I'm calculating the speed using the time taken to run the for(;;)
at qemu-img.c:1477. I figured that every time this loop runs, n1
sectors are converted, and so I calculate the write_speed
accordingly. Is this correct?


2. I have changed qemu-progress.c:qemu_progress_print() to take in a
speed parameter, thinking that it would be the best option. Should I
do it some other way instead (maybe write another function to print
just speed)?


Also, what does IO_BUF_SIZE in the same file relate to?

Thanks.
Varad

[1] https://bugs.launchpad.net/qemu/+bug/603872


Re: [Qemu-devel] [PULL 47/58] qdev-monitor: Unref device when device_add fails

2013-11-18 Thread Andreas Färber
Am 18.11.2013 13:29, schrieb Amos Kong:
 On Tue, Oct 08, 2013 at 07:44:45PM +0200, Andreas Färber wrote:
 From: Stefan Hajnoczi stefa...@redhat.com

 qdev_device_add() leaks the created device upon failure.  I suspect this
 problem crept in because qdev_free() unparents the device but does not
 drop a reference - confusing name.

 Cc: qemu-sta...@nongnu.org
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
 Signed-off-by: Andreas Färber afaer...@suse.de
 
 Hi Stefan,
 
 This commit caused a regression bug:
 
 hotplug more than 32 disks to vm, qemu crash
 
 ---
 
 [amos@amosk qemu]$ cat radd.sh 
 for i in `seq 3 9` a b c d e f 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f;do
 for j in `seq 1 7` 0;do
 /bin/cp /images/none.qcow2 /tmp/resize$i$j.qcow2
 
 echo drive_add $i.$j id=drv$i$j,file=/tmp/resize$i$j.qcow2,if=none
 echo drive_add $i.$j id=drv$i$j,file=/tmp/resize$i$j.qcow2,if=none | nc -U 
 /tmp/m
 
 echo device_add 
 virtio-blk-pci,id=dev$i$j,drive=drv$i$j,addr=0x$i.$j,multifunction=on
 echo device_add 
 virtio-blk-pci,id=dev$i$j,drive=drv$i$j,addr=0x$i.$j,multifunction=on | nc -U 
 /tmp/m
 done
 done

Hi, thanks for catching this.

Is this only with virtio-blk-pci or with any PCI card or only when
drives are involved? Either way it would be really great if you could
add such tests to Stefan's qtest using QMP, so that it can easily be run
by everyone.

The stacktrace below is not really telling to me. I wonder if we forget
to clean up some MemoryRegion in the device that still has a back
reference or whether the Memory API still references MemoryRegions that
have been destroyed by the device or forgets the reference devices it
still needs... Paolo?

I had reviewed the call paths and believe the patch to be 100% good, so
the fault will very likely be elsewhere.

Regards,
Andreas

 
 
 
 #0  0x558b7f95 in flatview_ref (view=0x0) at 
 /home/devel/qemu/memory.c:300
 #1  0x558b9689 in address_space_get_flatview (as=0x5645d660) at 
 /home/devel/qemu/memory.c:656
 #2  0x558ba416 in address_space_update_topology (as=0x5645d660) 
 at /home/devel/qemu/memory.c:760
 #3  0x558ba5cf in memory_region_transaction_commit () at 
 /home/devel/qemu/memory.c:799
 #4  0x558bcfcc in memory_region_set_enabled (mr=0x5647af08, 
 enabled=false) at /home/devel/qemu/memory.c:1503
 #5  0x5571a0af in do_pci_register_device (pci_dev=0x5647ac10, 
 bus=0x564132b0, name=0x56261100 virtio-blk-pci, devfn=26) at 
 hw/pci/pci.c:846
 #6  0x5571c6cc in pci_qdev_init (qdev=0x5647ac10) at 
 hw/pci/pci.c:1751
 #7  0x55694d70 in device_realize (dev=0x5647ac10, 
 err=0x7fffc8e8) at hw/core/qdev.c:178
 #8  0x556966fc in device_set_realized (obj=0x5647ac10, 
 value=true, err=0x7fffca60) at hw/core/qdev.c:699
 #9  0x557e7b57 in property_set_bool (obj=0x5647ac10, 
 v=0x5679a830, opaque=0x56461b10, name=0x559922ae realized, 
 errp=0x7fffca60)
 at qom/object.c:1315
 #10 0x557e665b in object_property_set (obj=0x5647ac10, 
 v=0x5679a830, name=0x559922ae realized, errp=0x7fffca60) at 
 qom/object.c:803
 #11 0x557e816e in object_property_set_qobject (obj=0x5647ac10, 
 value=0x56678880, name=0x559922ae realized, errp=0x7fffca60) at 
 qom/qom-qobject.c:24
 #12 0x557e6950 in object_property_set_bool (obj=0x5647ac10, 
 value=true, name=0x559922ae realized, errp=0x7fffca60) at 
 qom/object.c:866
 #13 0x55694ca7 in qdev_init (dev=0x5647ac10) at hw/core/qdev.c:163
 #14 0x557c60ee in qdev_device_add (opts=0x56525370) at 
 qdev-monitor.c:543
 #15 0x557c6730 in do_device_add (mon=0x562fb760, 
 qdict=0x5645d440, ret_data=0x7fffcb80) at qdev-monitor.c:656
 #16 0x558c8892 in handle_user_command (mon=0x562fb760, 
 cmdline=0x563f0f60 device_add 
 virtio-blk-pci,id=dev32,drive=drv32,addr=0x3.2,multifunction=on)
 at /home/devel/qemu/monitor.c:4137
 #17 0x558ca10f in monitor_command_cb (mon=0x562fb760, 
 cmdline=0x563f0f60 device_add 
 virtio-blk-pci,id=dev32,drive=drv32,addr=0x3.2,multifunction=on, 
 opaque=0x0) at /home/devel/qemu/monitor.c:4757
 #18 0x557e9491 in readline_handle_byte (rs=0x563f0f60, ch=10) at 
 readline.c:373
 #19 0x558ca045 in monitor_read (opaque=0x562fb760, 
 buf=0x7fffccf0 \n\315\377\377\377\177, size=1) at 
 /home/devel/qemu/monitor.c:4743
 #20 0x557c6cc8 in qemu_chr_be_write (s=0x56269040, 
 buf=0x7fffccf0 \n\315\377\377\377\177, len=1) at qemu-char.c:165
 #21 0x557cb026 in tcp_chr_read (chan=0x5645fe40, cond=G_IO_IN, 
 opaque=0x56269040) at qemu-char.c:2487
 #22 0x776ede06 in g_main_context_dispatch () from 
 /lib64/libglib-2.0.so.0
 #23 0x5578ef33 in glib_pollfds_poll () at main-loop.c:189
 #24 0x5578f028 in os_host_main_loop_wait (timeout=77312299) at 
 

Re: [Qemu-devel] [PATCH v2] target-lm32: move model features to LM32CPU

2013-11-18 Thread Andreas Färber
Am 17.11.2013 21:46, schrieb Michael Walle:
 Am 2013-10-14 23:46, schrieb Michael Walle:
 This allows us to completely remove CPULM32State from DisasContext.
 Instead, copy the fields we need to DisasContext.

 Cc: Andreas Färber afaer...@suse.de
 Signed-off-by: Michael Walle mich...@walle.cc
 ---

 changes since v1:
  - instead of storing a pointer to the cpu definitions, register
individual cpu types and store features in LM32CPU.
  - cpu_list() iterates over these types now.
 
 ping,
 
 andreas, could you please review this patch?

Sorry, didn't manage to before KVM Forum and forgot afterwards...

Andreas

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



[Qemu-devel] Do chardev socket can deal with sigio

2013-11-18 Thread Xiaoziliang


Hello,


I am sorry to trouble you , Now I meet a problem when I use qemu to implement 
my program.


Do you know how to set the chardev socket can deal with sigio?


It means that the vm need to be blocked like this 
wait_rep=1;while(wait_rep==1) until it receives the message from host  .


I used the chardev socket to establish the communication between host and vm.


But it seems that the chardev socket can not deal with the sigio in qemu.


when the message is send to the vm, it do not call my_read function 
automatically.


Do you know how to set the parameter of chardev socket ?(I think 
qemu_fe_char_iotcl maybe valid,but I don't know how to call the function)


Thanks in advance.

Xiao,ZiLiang

[Qemu-devel] First Patch, Requesting Comments‏

2013-11-18 Thread Varad Gautam

Hi! I'm new here, and am working on my first bug. I have posted a patch
for Bug#603872 [1]. It's incomplete right now, but please have a look and
tell me if I'm headed in the right direction. (I don't know if I can send
incomplete patches to the mailing list for suggestions or if I run into
some problems.)
 
Usecase: `qemu-img convert` with -p now shows the write speed.
 
I have a few doubts relating to the patch.
 
1. I'm calculating the speed using the time taken to run the for(;;)
at qemu-img.c:1477. I figured that every time this loop runs, n1
sectors are converted, and so I calculate the write_speed
accordingly. Is this correct?
 
2. I have changed qemu-progress.c:qemu_progress_print() to take in a
speed parameter, thinking that it would be the best option. Should I
do it some other way instead (maybe write another function to print
just speed)?
 
Also, what does IO_BUF_SIZE in the same file relate to?
 
Thanks.
Varad
 
[1] https://bugs.launchpad.net/qemu/+bug/603872



[Qemu-devel] [Bug 1252011] Re: needs pdcurses.dll to start

2013-11-18 Thread Stefan Weil
This is not a QEMU bug but a problem with privately built QEMU binaries
for Windows.

http://qemu.weilnetz.de/w32/old/qemu-w32-setup-20131116.exe now includes
support for curses, but failed to add the necessary pdcurses.dll.

http://qemu.weilnetz.de/w32/qemu-w32-setup-20131118.exe includes the
missing dll.


** Changed in: qemu
   Status: New = Invalid

** Changed in: qemu
 Assignee: (unassigned) = Stefan Weil (ubuntu-weilnetz)

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

Title:
  needs pdcurses.dll to start

Status in QEMU:
  Invalid

Bug description:
  QEMU version: 1.6.90.0 from 2013 11 16
  Host OS: Windows XP SP3 x86
  Host machine: 3.2 GHz AMD Athlon 64 dual core processor, 4 GB DDR II (3.2 
seen by the OS) memory
  Guest OS: Grub4Dos boot manager menu
  Problem: it needs pdcurses.dll and it won't start without it.

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



[Qemu-devel] [Bug 1252010] Re: can't assign enough RAM to the VM

2013-11-18 Thread Stefan Weil
QEMU currently needs contiguous memory for the guest memory. Hosts
running 32 bit Windows only provide about 2 GiB for programs. This 2 GiB
is used for the executable, all loaded dlls and dynamic memory.
Especially the dlls cause memory fragmentation, so newer versions of
QEMU which need more dlls get less contiguous memory.

Running 32 bit QEMU on 64 bit Windows helps, and 64 bit QEMU also has no
problem with allocating a large guest RAM.

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

Title:
  can't assign enough RAM to the VM

Status in QEMU:
  Confirmed

Bug description:
  QEMU version: 1.6.90.0 from 2013 11 16
  Host OS: Windows XP SP3 x86
  Host machine: 3.2 GHz AMD Athlon 64 dual core processor, 4 GB DDR II (3.2 
seen by the OS) memory
  Guest OS: Grub4Dos boot manager menu
  Problem: you can't assign more than 880 MB memory to the VM, although with 
0.15.1.0 version you can assign up to 1179 MB.

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



[Qemu-devel] First Patch, Requesting Comments

2013-11-18 Thread Varad Gautam
Hi! I'm new here, and am working on my first bug. I have posted a patch
for Bug#603872 [1] to the list.. It's incomplete right now, but please
have a look and tell me if I'm headed in the right direction. (I don't
know if I can send incomplete patches to the mailing list for suggestions
or if I run into some problems.)

Usecase: `qemu-img convert` with -p now shows the write speed.

I have a few doubts relating to the patch.

1. I'm calculating the speed using the time taken to run the for(;;)
at qemu-img.c:1477. I figured that every time this loop runs, n1
sectors are converted, and so I calculate the write_speed
accordingly. Is this correct?

2. I have changed qemu-progress.c:qemu_progress_print() to take in a
speed parameter, thinking that it would be the best option. Should I
do it some other way instead (maybe write another function to print
just speed)?

Also, what does IO_BUF_SIZE in the same file relate to?

Thanks.
Varad

[1] https://bugs.launchpad.net/qemu/+bug/603872


[Qemu-devel] [Bug 1252010] Re: can't assign enough RAM to the VM

2013-11-18 Thread Stefan Weil
** Changed in: qemu
   Status: New = Confirmed

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

Title:
  can't assign enough RAM to the VM

Status in QEMU:
  Confirmed

Bug description:
  QEMU version: 1.6.90.0 from 2013 11 16
  Host OS: Windows XP SP3 x86
  Host machine: 3.2 GHz AMD Athlon 64 dual core processor, 4 GB DDR II (3.2 
seen by the OS) memory
  Guest OS: Grub4Dos boot manager menu
  Problem: you can't assign more than 880 MB memory to the VM, although with 
0.15.1.0 version you can assign up to 1179 MB.

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



[Qemu-devel] First Patch, Requesting Review

2013-11-18 Thread Varad Gautam
Hi! I'm new here, and am working on my first bug. I have posted a patch
for Bug#603872 [1]. It's incomplete right now, but please have a look and
tell me if I'm headed in the right direction. (I don't know if I can send
incomplete patches to the mailing list for suggestions or if I run into
some problems.)
 
Usecase: `qemu-img convert` with -p now shows the write speed.
 
I have a few doubts relating to the patch.
 
1. I'm calculating the speed using the time taken to run the for(;;)
at qemu-img.c:1477. I figured that every time this loop runs, n1
sectors are converted, and so I calculate the write_speed
accordingly. Is this correct?
 
2. I have changed qemu-progress.c:qemu_progress_print() to take in a
speed parameter, thinking that it would be the best option. Should I
do it some other way instead (maybe write another function to print
just speed)?
 
Also, what does IO_BUF_SIZE in the same file relate to?
 
Thanks.
Varad
 
[1] https://bugs.launchpad.net/qemu/+bug/603872



[Qemu-devel] [PATCH/RFC] qemu-img: show image conversion speed

2013-11-18 Thread Varad Gautam
From: Varad Gautam varadgau...@live.com

Calculate and display write speed when converting image with the
-p parameter. qemu-progress:qemu_progress_print() now takes speed
parameter to print.

Signed-off-by: Varad Gautam varadgau...@gmail.com
---
 include/qemu-common.h |4 ++--
 qemu-img.c|   31 +--
 util/qemu-progress.c  |   11 +++
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/include/qemu-common.h b/include/qemu-common.h
index 5054836..0e27c68 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -349,9 +349,9 @@ size_t qemu_iovec_memset(QEMUIOVector *qiov, size_t offset,
 
 bool buffer_is_zero(const void *buf, size_t len);
 
-void qemu_progress_init(int enabled, float min_skip);
+void qemu_progress_init(int enabled, float min_skip, float speed);
 void qemu_progress_end(void);
-void qemu_progress_print(float delta, int max);
+void qemu_progress_print(float delta, int max, float speed);
 const char *qemu_get_vm_name(void);
 
 #define QEMU_FILE_TYPE_BIOS   0
diff --git a/qemu-img.c b/qemu-img.c
index bf3fb4f..cf313ed 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -945,7 +945,7 @@ static int img_compare(int argc, char **argv)
 filename2 = argv[optind++];
 
 /* Initialize before goto out */
-qemu_progress_init(progress, 2.0);
+qemu_progress_init(progress, 2.0, 0);
 
 bs1 = bdrv_new_open(filename1, fmt1, BDRV_O_FLAGS, true, quiet);
 if (!bs1) {
@@ -970,7 +970,7 @@ static int img_compare(int argc, char **argv)
 total_sectors = MIN(total_sectors1, total_sectors2);
 progress_base = MAX(total_sectors1, total_sectors2);
 
-qemu_progress_print(0, 100);
+qemu_progress_print(0, 100, 0);
 
 if (strict  total_sectors1 != total_sectors2) {
 ret = 1;
@@ -1053,7 +1053,7 @@ static int img_compare(int argc, char **argv)
 }
 }
 sector_num += nb_sectors;
-qemu_progress_print(((float) nb_sectors / progress_base)*100, 100);
+qemu_progress_print(((float) nb_sectors / progress_base)*100, 100, 0);
 }
 
 if (total_sectors1 != total_sectors2) {
@@ -1101,7 +1101,7 @@ static int img_compare(int argc, char **argv)
 }
 }
 sector_num += nb_sectors;
-qemu_progress_print(((float) nb_sectors / progress_base)*100, 100);
+qemu_progress_print(((float) nb_sectors / progress_base)*100, 100, 
0);
 }
 }
 
@@ -1127,7 +1127,7 @@ static int img_convert(int argc, char **argv)
 const char *fmt, *out_fmt, *cache, *out_baseimg, *out_filename;
 BlockDriver *drv, *proto_drv;
 BlockDriverState **bs = NULL, *out_bs = NULL;
-int64_t total_sectors, nb_sectors, sector_num, bs_offset;
+int64_t total_sectors, nb_sectors, sector_num, bs_offset, time;
 uint64_t bs_sectors;
 uint8_t * buf = NULL;
 const uint8_t *buf1;
@@ -1136,7 +1136,7 @@ static int img_convert(int argc, char **argv)
 QEMUOptionParameter *out_baseimg_param;
 char *options = NULL;
 const char *snapshot_name = NULL;
-float local_progress = 0;
+float local_progress = 0, write_speed = 0;
 int min_sparse = 8; /* Need at least 4k of zeros for sparse detection */
 bool quiet = false;
 Error *local_err = NULL;
@@ -1223,7 +1223,7 @@ static int img_convert(int argc, char **argv)
 out_filename = argv[argc - 1];
 
 /* Initialize before goto out */
-qemu_progress_init(progress, 2.0);
+qemu_progress_init(progress, 2.0, write_speed);
 
 if (options  is_help_option(options)) {
 ret = print_block_option_help(out_filename, out_fmt);
@@ -1237,7 +1237,7 @@ static int img_convert(int argc, char **argv)
 goto out;
 }
 
-qemu_progress_print(0, 100);
+qemu_progress_print(0, 100, write_speed);
 
 bs = g_malloc0(bs_n * sizeof(BlockDriverState *));
 
@@ -1460,7 +1460,7 @@ static int img_convert(int argc, char **argv)
 }
 }
 sector_num += n;
-qemu_progress_print(local_progress, 100);
+qemu_progress_print(local_progress, 100, write_speed);
 }
 /* signal EOF to align */
 bdrv_write_compressed(out_bs, 0, NULL, 0);
@@ -1475,6 +1475,7 @@ static int img_convert(int argc, char **argv)
 }
 
 for(;;) {
+time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
 nb_sectors = total_sectors - sector_num;
 if (nb_sectors = 0) {
 break;
@@ -1547,7 +1548,9 @@ static int img_convert(int argc, char **argv)
 n -= n1;
 buf1 += n1 * 512;
 }
-qemu_progress_print(local_progress, 100);
+time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - time;
+write_speed = (sectors_to_bytes(n1) * 10 / (double) time ) 
/ 1048576 ;
+qemu_progress_print(local_progress, 100, write_speed);
 }
 }
 out:
@@ -2174,8 +2177,8 @@ static int img_rebase(int 

Re: [Qemu-devel] [PATCH] e1000/rtl8139: update HMP NIC when every bit is written

2013-11-18 Thread Michael S. Tsirkin
On Tue, Nov 05, 2013 at 07:17:18PM +0800, Amos Kong wrote:
 We currently just update the HMP NIC info when the last bit of macaddr
 is written. This assumes that guest driver will write all the macaddr
 from bit 0 to bit 5 when it changes the macaddr, this is the current
 behavior of linux driver (e1000/rtl8139cp), but we can't do this
 assumption.
 
 The macaddr that is used for rx-filter will be updated when every bit
 is changed. This patch updates the e1000/rtl8139 nic to update HMP NIC
 info when every bit is changed. It will be same as virtio-net.
 
 Signed-off-by: Amos Kong ak...@redhat.com

Vlad here told me he did some research and this
does not actually match hardware behaviour
for either e1000 or rtl8139.

Vlad, would you like to elaborate on-list?

I think we should revert this for 1.8 and
look at emulating actual hardware behaviour.

 ---
  hw/net/e1000.c   | 2 +-
  hw/net/rtl8139.c | 5 +
  2 files changed, 2 insertions(+), 5 deletions(-)
 
 diff --git a/hw/net/e1000.c b/hw/net/e1000.c
 index ec8ecd7..2d60639 100644
 --- a/hw/net/e1000.c
 +++ b/hw/net/e1000.c
 @@ -1110,7 +1110,7 @@ mac_writereg(E1000State *s, int index, uint32_t val)
  
  s-mac_reg[index] = val;
  
 -if (index == RA + 1) {
 +if (index == RA || index == RA + 1) {
  macaddr[0] = cpu_to_le32(s-mac_reg[RA]);
  macaddr[1] = cpu_to_le32(s-mac_reg[RA + 1]);
  qemu_format_nic_info_str(qemu_get_queue(s-nic), (uint8_t *)macaddr);
 diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
 index 5329f44..7f2b4db 100644
 --- a/hw/net/rtl8139.c
 +++ b/hw/net/rtl8139.c
 @@ -2741,10 +2741,7 @@ static void rtl8139_io_writeb(void *opaque, uint8_t 
 addr, uint32_t val)
  
  switch (addr)
  {
 -case MAC0 ... MAC0+4:
 -s-phys[addr - MAC0] = val;
 -break;
 -case MAC0+5:
 +case MAC0 ... MAC0+5:
  s-phys[addr - MAC0] = val;
  qemu_format_nic_info_str(qemu_get_queue(s-nic), s-phys);
  break;
 -- 
 1.8.3.1
 



Re: [Qemu-devel] [PATCH v2] target-lm32: move model features to LM32CPU

2013-11-18 Thread Andreas Färber
Am 15.10.2013 00:46, schrieb Michael Walle:
 This allows us to completely remove CPULM32State from DisasContext.
 Instead, copy the fields we need to DisasContext.
 
 Cc: Andreas Färber afaer...@suse.de
 Signed-off-by: Michael Walle mich...@walle.cc
 ---
 
 changes since v1:
  - instead of storing a pointer to the cpu definitions, register
individual cpu types and store features in LM32CPU.
  - cpu_list() iterates over these types now.
 
 
  target-lm32/cpu-qom.h   |5 ++
  target-lm32/cpu.c   |  187 
 ++-
  target-lm32/cpu.h   |7 +-
  target-lm32/helper.c|  128 +---
  target-lm32/translate.c |   29 +---
  5 files changed, 214 insertions(+), 142 deletions(-)
 
 diff --git a/target-lm32/cpu-qom.h b/target-lm32/cpu-qom.h
 index 723f604..3bf7956 100644
 --- a/target-lm32/cpu-qom.h
 +++ b/target-lm32/cpu-qom.h
 @@ -59,6 +59,11 @@ typedef struct LM32CPU {
  CPUState parent_obj;
  /* public */
  
 +uint32_t revision;
 +uint8_t num_interrupts;
 +uint8_t num_breakpoints;
 +uint8_t num_watchpoints;
 +uint32_t features;
  CPULM32State env;

For TCG performance reasons you should place the fields after env. In
that case please separate them from env with a white line.

  } LM32CPU;
  
 diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c
 index 869878c..ae372b8 100644
 --- a/target-lm32/cpu.c
 +++ b/target-lm32/cpu.c
 @@ -29,6 +29,87 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value)
  cpu-env.pc = value;
  }
  
 +/* Sort alphabetically by type name. */
 +static gint lm32_cpu_list_compare(gconstpointer a, gconstpointer b)
 +{
 +ObjectClass *class_a = (ObjectClass *)a;
 +ObjectClass *class_b = (ObjectClass *)b;
 +const char *name_a, *name_b;
 +
 +name_a = object_class_get_name(class_a);
 +name_b = object_class_get_name(class_b);
 +return strcmp(name_a, name_b);
 +}
 +
 +static void lm32_cpu_list_entry(gpointer data, gpointer user_data)
 +{
 +ObjectClass *oc = data;
 +CPUListState *s = user_data;
 +const char *typename = object_class_get_name(oc);
 +char *name;
 +
 +name = g_strndup(typename, strlen(typename) - strlen(- TYPE_LM32_CPU));
 +(*s-cpu_fprintf)(s-file,   %s\n, name);
 +g_free(name);
 +}
 +
 +
 +void lm32_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 +{
 +CPUListState s = {
 +.file = f,
 +.cpu_fprintf = cpu_fprintf,
 +};
 +GSList *list;
 +
 +list = object_class_get_list(TYPE_LM32_CPU, false);
 +list = g_slist_sort(list, lm32_cpu_list_compare);
 +(*cpu_fprintf)(f, Available CPUs:\n);
 +g_slist_foreach(list, lm32_cpu_list_entry, s);
 +g_slist_free(list);
 +}
 +
 +static void init_cfg_reg(LM32CPU *cpu)

Optionally you could use a lm32_cpu_ prefix here for consistency.

 +{
 +CPULM32State *env = cpu-env;
 +uint32_t cfg = 0;
 +
 +if (cpu-features  LM32_FEATURE_MULTIPLY) {
 +cfg |= CFG_M;
 +}
 +
 +if (cpu-features  LM32_FEATURE_DIVIDE) {
 +cfg |= CFG_D;
 +}
 +
 +if (cpu-features  LM32_FEATURE_SHIFT) {
 +cfg |= CFG_S;
 +}
 +
 +if (cpu-features  LM32_FEATURE_SIGN_EXTEND) {
 +cfg |= CFG_X;
 +}
 +
 +if (cpu-features  LM32_FEATURE_I_CACHE) {
 +cfg |= CFG_IC;
 +}
 +
 +if (cpu-features  LM32_FEATURE_D_CACHE) {
 +cfg |= CFG_DC;
 +}
 +
 +if (cpu-features  LM32_FEATURE_CYCLE_COUNT) {
 +cfg |= CFG_CC;
 +}
 +
 +cfg |= (cpu-num_interrupts  CFG_INT_SHIFT);
 +cfg |= (cpu-num_breakpoints  CFG_BP_SHIFT);
 +cfg |= (cpu-num_watchpoints  CFG_WP_SHIFT);
 +cfg |= (cpu-revision  CFG_REV_SHIFT);
 +
 +env-cfg = cfg;
 +}
 +
  /* CPUClass::reset() */
  static void lm32_cpu_reset(CPUState *s)
  {
 @@ -41,6 +122,7 @@ static void lm32_cpu_reset(CPUState *s)
  /* reset cpu state */
  memset(env, 0, offsetof(CPULM32State, breakpoints));
  
 +init_cfg_reg(cpu);
  tlb_flush(env, 1);
  }
  
 @@ -74,6 +156,91 @@ static void lm32_cpu_initfn(Object *obj)
  }
  }
  
 +static void lm32_basic_cpu_initfn(Object *obj)
 +{
 +LM32CPU *cpu = LM32_CPU(obj);
 +
 +cpu-revision = 3;
 +cpu-num_interrupts = 32;
 +cpu-num_breakpoints = 4;
 +cpu-num_watchpoints = 4;
 +cpu-features = LM32_FEATURE_SHIFT
 +| LM32_FEATURE_SIGN_EXTEND
 +| LM32_FEATURE_CYCLE_COUNT;

Out of a personal style preference I would align the LM32_FEATURE_
prefix. Either by placing the | last or by aligning | with =. But just a
suggestion, it was already this way before.

Other than that looks good, thanks, so once you fix the env issue, feel
free to add my Reviewed-by. Sorry for the delay in reviewing changes I
suggested.

Regards,
Andreas

 +}
 +
 +static void lm32_standard_cpu_initfn(Object *obj)
 +{
 +LM32CPU *cpu = LM32_CPU(obj);
 +
 +cpu-revision = 3;
 +cpu-num_interrupts = 32;
 +cpu-num_breakpoints = 4;
 +

Re: [Qemu-devel] [PATCH v2] net: move rxfilter_notify() to net.c

2013-11-18 Thread Stefan Hajnoczi
On Mon, Nov 18, 2013 at 09:39:26PM +0800, Amos Kong wrote:
 On Mon, Nov 18, 2013 at 02:25:40PM +0100, Stefan Hajnoczi wrote:
  On Mon, Nov 18, 2013 at 04:20:12PM +0800, Amos Kong wrote:
   @@ -967,6 +968,27 @@ void print_net_client(Monitor *mon, NetClientState 
   *nc)
   nc-info_str);
}

   +void rxfilter_notify(NetClientState *nc, Object *obj)
   +{
   +QObject *event_data;
   +gchar *path = object_get_canonical_path(obj);
   +
   +if (nc-rxfilter_notify_enabled) {
   +if (nc-name) {
   +event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
   +nc-name, path);
   +} else {
   +event_data = qobject_from_jsonf({ 'path': %s }, path);
   +}
   +monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
   +qobject_decref(event_data);
   +
   +/* disable event notification to avoid events flooding */
   +nc-rxfilter_notify_enabled = 0;
  
  Only hw/net/virtio-net.c uses nc-rxfilter_notify_enabled.  This
  function isn't reusable in its current form so I'm left wondering what
  the point of this patch is?
  
  If you have patches that invoke rxfilter_notify() from other NICs then
  please submit them together in a series.
 
 I don't have patch to change other NICs to send rxfilter notify right
 now.
 
 So I will send a patch to fix the leak. We can move the function to
 net.c in future.

Okay, sounds good.

Stefan



Re: [Qemu-devel] dataplane, thread and gpu stuff

2013-11-18 Thread Stefan Hajnoczi
On Mon, Nov 18, 2013 at 02:52:53PM +1000, Dave Airlie wrote:
 So after talking to a few people at kvm forum I think the GPU code
 should probably use the dataplane stuff from the outset,
 
 The main advantages I think this gives me is being able to dequeue
 objects from the vq from a thread and send irq vectors from there as
 well.
 
 Though since it appears the dataplane stuff is kvm specific (at least
 the irq handling), I was wondering how I should deal with fallbacks
 for non-kvm operation, and quite how much falling back I need to do.
 
 Can I still use the dataplane/vring code from the normal bottom half
 handlers or do I have to write separate code for both situations.

As of today, there are still two vring implementations in
hw/virtio/virtio.c and hw/virtio/dataplane/vring.c.  This means it isn't
clean and easy to integrate into a new device yet.  Existing dataplane
devices basically take advantage of the fact that the non-dataplane
version sets up the device before I/O.

Paolo can give you details on the latest thread-safe memory API stuff
and whether it's already usable for virtio.

Regarding irqfd, we could emulate it in TCG using an EventNotifier
(eventfd).  At that point I think it's no longer kvm-specific.

Stefan



Re: [Qemu-devel] [PULL for-1.8 0/2] pc last minute fixes for 1.8

2013-11-18 Thread Eric Blake
On 11/18/2013 04:53 AM, Michael S. Tsirkin wrote:
 The following changes since commit 5c5432e7d630592ddcc1876ac8a1505f8f14ef15:
 
   Merge remote-tracking branch 'luiz/queue/qmp' into staging (2013-11-13 
 11:49:27 -0800)
 
 are available in the git repository at:
 
   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
 
 for you to fetch changes up to 420508fbba2a6e8eaff008715b5f7eff83f8e865:
 
   doc: fix hardcoded helper path (2013-11-18 13:45:10 +0200)
 
 
 pc last minute fixes for 1.8
 
 This has a patch that drops an unused FW CFG entry.
 I think it's best to include it before 1.7 to avoid
 the need to maintain it in compat machine types.

Which is it?  Last minute fixes to be included in 1.7, or some of the
first patches to be applied for 1.8 once 1.7 is out the door?

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH for-1.7] qom: fix object_property_set_link() memory leak

2013-11-18 Thread Stefan Hajnoczi
object_get_canonical_path() returns a string that the caller is
responsible for freeing.

Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 qom/object.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index b617f26..fc19cf6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -838,8 +838,9 @@ char *object_property_get_str(Object *obj, const char *name,
 void object_property_set_link(Object *obj, Object *value,
   const char *name, Error **errp)
 {
-object_property_set_str(obj, object_get_canonical_path(value),
-name, errp);
+gchar *path = object_get_canonical_path(value);
+object_property_set_str(obj, path, name, errp);
+g_free(path);
 }
 
 Object *object_property_get_link(Object *obj, const char *name,
-- 
1.8.4.2




Re: [Qemu-devel] [PATCH for-1.7] qom: fix object_property_set_link() memory leak

2013-11-18 Thread Andreas Färber
Am 18.11.2013 16:10, schrieb Stefan Hajnoczi:
 object_get_canonical_path() returns a string that the caller is
 responsible for freeing.
 
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com

What's the difference to Vlad's v2?

Andreas

 ---
  qom/object.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/qom/object.c b/qom/object.c
 index b617f26..fc19cf6 100644
 --- a/qom/object.c
 +++ b/qom/object.c
 @@ -838,8 +838,9 @@ char *object_property_get_str(Object *obj, const char 
 *name,
  void object_property_set_link(Object *obj, Object *value,
const char *name, Error **errp)
  {
 -object_property_set_str(obj, object_get_canonical_path(value),
 -name, errp);
 +gchar *path = object_get_canonical_path(value);
 +object_property_set_str(obj, path, name, errp);
 +g_free(path);
  }
  
  Object *object_property_get_link(Object *obj, const char *name,
 


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



Re: [Qemu-devel] [PATCH] virtio-net: fix the memory leak in rxfilter_notify()

2013-11-18 Thread Stefan Hajnoczi
On Mon, Nov 18, 2013 at 09:47:25PM +0800, Amos Kong wrote:
 object_get_canonical_path() returns a gchar*, it should be freeed by the
 caller.
 
 Signed-off-by: Amos Kong ak...@redhat.com
 ---
  hw/net/virtio-net.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

Thanks, applied to my net tree (will send pull request for QEMU 1.7):
https://github.com/stefanha/qemu/commits/net

Stefan



Re: [Qemu-devel] [PULL for-1.8 0/2] pc last minute fixes for 1.8

2013-11-18 Thread Michael S. Tsirkin
On Mon, Nov 18, 2013 at 08:06:48AM -0700, Eric Blake wrote:
 On 11/18/2013 04:53 AM, Michael S. Tsirkin wrote:
  The following changes since commit 5c5432e7d630592ddcc1876ac8a1505f8f14ef15:
  
Merge remote-tracking branch 'luiz/queue/qmp' into staging (2013-11-13 
  11:49:27 -0800)
  
  are available in the git repository at:
  
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
  
  for you to fetch changes up to 420508fbba2a6e8eaff008715b5f7eff83f8e865:
  
doc: fix hardcoded helper path (2013-11-18 13:45:10 +0200)
  
  
  pc last minute fixes for 1.8
  
  This has a patch that drops an unused FW CFG entry.
  I think it's best to include it before 1.7 to avoid
  the need to maintain it in compat machine types.
 
 Which is it?  Last minute fixes to be included in 1.7, or some of the
 first patches to be applied for 1.8 once 1.7 is out the door?

Ugh. That should have been 1.7.

Anthony, would you like me to sign with
proper name and re-send?

 -- 
 Eric Blake   eblake redhat com+1-919-301-3266
 Libvirt virtualization library http://libvirt.org
 





Re: [Qemu-devel] [PATCH] virtio-net: fix the memory leak in rxfilter_notify()

2013-11-18 Thread Michael S. Tsirkin
On Mon, Nov 18, 2013 at 04:14:08PM +0100, Stefan Hajnoczi wrote:
 On Mon, Nov 18, 2013 at 09:47:25PM +0800, Amos Kong wrote:
  object_get_canonical_path() returns a gchar*, it should be freeed by the
  caller.
  
  Signed-off-by: Amos Kong ak...@redhat.com
  ---
   hw/net/virtio-net.c | 8 
   1 file changed, 4 insertions(+), 4 deletions(-)
 
 Thanks, applied to my net tree (will send pull request for QEMU 1.7):
 https://github.com/stefanha/qemu/commits/net
 
 Stefan

I'd prefer it for my comment to be addressed first ...



Re: [Qemu-devel] [PATCH for-1.7] tests: add missing -display none to qtests

2013-11-18 Thread Stefan Hajnoczi
On Thu, Nov 14, 2013 at 04:14:11PM +0100, Stefan Hajnoczi wrote:
 Commit 7ceeedd016facf8d58e14a0d1417fa7225d71072 (blockdev-test: add
 test case for drive_add duplicate IDs) and commit
 43cd209803d6cffb1e1a028c9ff2fd0ff4fce954 (qdev-monitor-test: add
 device_add leak test cases) added qtest tests without specifying
 -display none.
 
 As a result, make check now tries to use graphics (GTK or SDL).  Since
 graphics are not used by the test and inappropriate for headless make
 check runs, add the missing -display none.
 
 This fixes make check in the QEMU buildbot.
 
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
 ---
  tests/blockdev-test.c | 2 +-
  tests/qdev-monitor-test.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

Applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan



Re: [Qemu-devel] [PATCH] qtest: Adding -display none to new tests

2013-11-18 Thread Stefan Hajnoczi
On Fri, Nov 15, 2013 at 08:54:06PM +0100, Kevin Wolf wrote:
 Without it, you either get a window for a short time, or worse, test
 failures when 'make check' isn't run in an X session.
 
 Signed-off-by: Kevin Wolf kw...@redhat.com
 ---
  tests/blockdev-test.c | 2 +-
  tests/qdev-monitor-test.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

Thanks, I merged earlier [PATCH for-1.7] tests: add missing -display
none to qtests patch.



Re: [Qemu-devel] [PULL 11/13] target-i386: forward CPUID cache leaves when -cpu host is used

2013-11-18 Thread Peter Lieven

I do not know, but this patch might introduce a regression.

If I specify: -smp 2,sockets=1,cores=2,threads=1 to a Windows 2012 R2 Server it 
crashes
at boot time. -smp 2 works.

git bisect start
# good: [62ecc3a0e3c77a4944c92a02dd7fae2ab1f2290d] Update VERSION for 1.6.1 
release
git bisect good 62ecc3a0e3c77a4944c92a02dd7fae2ab1f2290d
# bad: [964668b03d26f0b5baa5e5aff0c966f4fcb76e9e] Update version for 1.7.0-rc0 
release
git bisect bad 964668b03d26f0b5baa5e5aff0c966f4fcb76e9e
# good: [1ee2daeb6448312d6d0e22175f5c1b9b01f8974c] Update version for 1.6.0
git bisect good 1ee2daeb6448312d6d0e22175f5c1b9b01f8974c
# bad: [03cfd8faa7ffb7201e2949b99c2f35b1fef7078b] linux-user: add support of 
binfmt_misc 'O' flag
git bisect bad 03cfd8faa7ffb7201e2949b99c2f35b1fef7078b
# good: [5a93d5c2abc719bd44f6c9fbeed88d3cae712606] Merge remote-tracking branch 
'mjt/trivial-patches' into staging
git bisect good 5a93d5c2abc719bd44f6c9fbeed88d3cae712606
# good: [a27292b5d7545509bfa171922516d2033c570205] virtio-scsi: Make type 
virtio-scsi-common abstract
git bisect good a27292b5d7545509bfa171922516d2033c570205
# good: [469936ae0a9891b2de7e46743f683535b0819bee] target-i386: Fix segment 
cache dump
git bisect good 469936ae0a9891b2de7e46743f683535b0819bee
# bad: [3e4be9c29784df09c364b52a55e826a0b05b950e] Merge remote-tracking branch 
'qemu-kvm/uq/master' into staging
git bisect bad 3e4be9c29784df09c364b52a55e826a0b05b950e
# good: [2571f8f5fbaea5dc3bdcd84737f109b459576e90] Merge remote-tracking branch 
'spice/spice.v74' into staging
git bisect good 2571f8f5fbaea5dc3bdcd84737f109b459576e90
# good: [c5daeae1b4ddff97d605bd954a7c2a2b2cf6040f] linux-headers: update to 3.11
git bisect good c5daeae1b4ddff97d605bd954a7c2a2b2cf6040f
# good: [ceae18bd74e8940ff79935a257c72e665b084bcc] lsi: add 53C810 variant
git bisect good ceae18bd74e8940ff79935a257c72e665b084bcc
# bad: [f010bc643a2759e87e989c3e4e85f15ec71ae98f] target-i386: add feature 
kvm_pv_unhalt
git bisect bad f010bc643a2759e87e989c3e4e85f15ec71ae98f
# bad: [4f2656079f903efcd0d8224cbc79170ad3ee5b70] linux-headers: update to 
3.12-rc1
git bisect bad 4f2656079f903efcd0d8224cbc79170ad3ee5b70
# bad: [787aaf5703a702094f395db6795e74230282cd62] target-i386: forward CPUID 
cache leaves when -cpu host is used
git bisect bad 787aaf5703a702094f395db6795e74230282cd62

Peter

On 20.09.2013 18:24, Paolo Bonzini wrote:

From: Benoît Canet ben...@irqsave.net

Some users running cpu intensive tasks checking the cache CPUID leaves at
startup and making decisions based on the result reported that the guest was
not reflecting the host CPUID leaves when -cpu host is used.

This patch fix this.

Signed-off-by: Benoît Canet ben...@irqsave.net
[Rename new field to cache_info_passthrough - Paolo]
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
  target-i386/cpu-qom.h |  3 +++
  target-i386/cpu.c | 19 +++
  2 files changed, 22 insertions(+)

diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index c4447c2..f4fab15 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -70,6 +70,9 @@ typedef struct X86CPU {
  bool hyperv_relaxed_timing;
  int hyperv_spinlock_attempts;
  
+/* if true the CPUID code directly forward host cache leaves to the guest */

+bool cache_info_passthrough;
+
  /* Features that were filtered out because of missing host capabilities */
  uint32_t filtered_features[FEATURE_WORDS];
  
diff --git a/target-i386/cpu.c b/target-i386/cpu.c

index c36345e..46edd75 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -486,6 +486,7 @@ typedef struct x86_def_t {
  int stepping;
  FeatureWordArray features;
  char model_id[48];
+bool cache_info_passthrough;
  } x86_def_t;
  
  #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)

@@ -1139,6 +1140,7 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
  assert(kvm_enabled());
  
  x86_cpu_def-name = host;

+x86_cpu_def-cache_info_passthrough = true;
  host_cpuid(0x0, 0, eax, ebx, ecx, edx);
  x86_cpu_vendor_words2str(x86_cpu_def-vendor, ebx, edx, ecx);
  
@@ -1888,6 +1890,7 @@ static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp)

  env-features[FEAT_C000_0001_EDX] = def-features[FEAT_C000_0001_EDX];
  env-features[FEAT_7_0_EBX] = def-features[FEAT_7_0_EBX];
  env-cpuid_xlevel2 = def-xlevel2;
+cpu-cache_info_passthrough = def-cache_info_passthrough;
  
  object_property_set_str(OBJECT(cpu), def-model_id, model-id, errp);

  }
@@ -2062,6 +2065,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, 
uint32_t count,
  break;
  case 2:
  /* cache info: needed for Pentium Pro compatibility */
+if (cpu-cache_info_passthrough) {
+host_cpuid(index, 0, eax, ebx, ecx, edx);
+break;
+}
  *eax = 1; /* Number of CPUID[EAX=2] calls required */
  *ebx = 0;
  *ecx = 0;
@@ -2071,6 +2078,10 @@ void cpu_x86_cpuid(CPUX86State *env, 

Re: [Qemu-devel] [PATCH] qemu-iotests: Add -c cache-mode to check

2013-11-18 Thread Stefan Hajnoczi
On Thu, Nov 14, 2013 at 10:24:04AM +0800, Fam Zheng wrote:
 The default cache mode for drive options is changed to writethrough, and
 overridable with ./check -c mode.

Please make the default writeback so that ./check completes more
quickly.

Also, please also indicate in the commit description why the change was
made (i.e.  you want qemu-iotests to succeed on tmpfs by default).

Stefan



Re: [Qemu-devel] [PATCH] qtest: Adding -display none to new tests

2013-11-18 Thread Kevin Wolf
Am 18.11.2013 um 16:18 hat Stefan Hajnoczi geschrieben:
 On Fri, Nov 15, 2013 at 08:54:06PM +0100, Kevin Wolf wrote:
  Without it, you either get a window for a short time, or worse, test
  failures when 'make check' isn't run in an X session.
  
  Signed-off-by: Kevin Wolf kw...@redhat.com
  ---
   tests/blockdev-test.c | 2 +-
   tests/qdev-monitor-test.c | 2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)
 
 Thanks, I merged earlier [PATCH for-1.7] tests: add missing -display
 none to qtests patch.

It didn't arrive in master yet. Are you sure it was queued in the block
tree?

Kevin



[Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify()

2013-11-18 Thread Amos Kong
object_get_canonical_path() returns a gchar*, it should be freeed by the
caller.

Signed-off-by: Amos Kong ak...@redhat.com
---
v2: put gchar *path inside rxfilter_notify_enabled block
---
 hw/net/virtio-net.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 613f144..b75c753 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -200,16 +200,16 @@ static void rxfilter_notify(NetClientState *nc)
 VirtIONet *n = qemu_get_nic_opaque(nc);
 
 if (nc-rxfilter_notify_enabled) {
+gchar *path = object_get_canonical_path(OBJECT(n-qdev));
 if (n-netclient_name) {
 event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
-n-netclient_name,
-
object_get_canonical_path(OBJECT(n-qdev)));
+n-netclient_name, path);
 } else {
-event_data = qobject_from_jsonf({ 'path': %s },
-
object_get_canonical_path(OBJECT(n-qdev)));
+event_data = qobject_from_jsonf({ 'path': %s }, path);
 }
 monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
 qobject_decref(event_data);
+g_free(path);
 
 /* disable event notification to avoid events flooding */
 nc-rxfilter_notify_enabled = 0;
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH] qemu-iotests: Add -c cache-mode to check

2013-11-18 Thread Stefan Hajnoczi
On Thu, Nov 14, 2013 at 10:24:04AM +0800, Fam Zheng wrote:
 The default cache mode for drive options is changed to writethrough, and
 overridable with ./check -c mode.
 
 Signed-off-by: Fam Zheng f...@redhat.com
 ---
  tests/qemu-iotests/common | 13 -
  tests/qemu-iotests/iotests.py |  3 ++-
  2 files changed, 14 insertions(+), 2 deletions(-)

BTW, I looked back at Kevin's reply to your earlier patch and saw he
suggested making the default writethrough.

Kevin: Any reason not to use writeback by default?



Re: [Qemu-devel] [PULL 11/13] target-i386: forward CPUID cache leaves when -cpu host is used

2013-11-18 Thread Peter Lieven

On 18.11.2013 16:23, Peter Lieven wrote:

I do not know, but this patch might introduce a regression.

If I specify: -smp 2,sockets=1,cores=2,threads=1 to a Windows 2012 R2 Server it 
crashes
at boot time. -smp 2 works.

for Linux /proc/cpuinfo reveals no cpu layout information (sibliings, cores, 
threads etc.) with
this patch applied and a manual socket,core,thread configuration.


git bisect start
# good: [62ecc3a0e3c77a4944c92a02dd7fae2ab1f2290d] Update VERSION for 1.6.1 
release
git bisect good 62ecc3a0e3c77a4944c92a02dd7fae2ab1f2290d
# bad: [964668b03d26f0b5baa5e5aff0c966f4fcb76e9e] Update version for 1.7.0-rc0 
release
git bisect bad 964668b03d26f0b5baa5e5aff0c966f4fcb76e9e
# good: [1ee2daeb6448312d6d0e22175f5c1b9b01f8974c] Update version for 1.6.0
git bisect good 1ee2daeb6448312d6d0e22175f5c1b9b01f8974c
# bad: [03cfd8faa7ffb7201e2949b99c2f35b1fef7078b] linux-user: add support of 
binfmt_misc 'O' flag
git bisect bad 03cfd8faa7ffb7201e2949b99c2f35b1fef7078b
# good: [5a93d5c2abc719bd44f6c9fbeed88d3cae712606] Merge remote-tracking branch 
'mjt/trivial-patches' into staging
git bisect good 5a93d5c2abc719bd44f6c9fbeed88d3cae712606
# good: [a27292b5d7545509bfa171922516d2033c570205] virtio-scsi: Make type 
virtio-scsi-common abstract
git bisect good a27292b5d7545509bfa171922516d2033c570205
# good: [469936ae0a9891b2de7e46743f683535b0819bee] target-i386: Fix segment 
cache dump
git bisect good 469936ae0a9891b2de7e46743f683535b0819bee
# bad: [3e4be9c29784df09c364b52a55e826a0b05b950e] Merge remote-tracking branch 
'qemu-kvm/uq/master' into staging
git bisect bad 3e4be9c29784df09c364b52a55e826a0b05b950e
# good: [2571f8f5fbaea5dc3bdcd84737f109b459576e90] Merge remote-tracking branch 
'spice/spice.v74' into staging
git bisect good 2571f8f5fbaea5dc3bdcd84737f109b459576e90
# good: [c5daeae1b4ddff97d605bd954a7c2a2b2cf6040f] linux-headers: update to 3.11
git bisect good c5daeae1b4ddff97d605bd954a7c2a2b2cf6040f
# good: [ceae18bd74e8940ff79935a257c72e665b084bcc] lsi: add 53C810 variant
git bisect good ceae18bd74e8940ff79935a257c72e665b084bcc
# bad: [f010bc643a2759e87e989c3e4e85f15ec71ae98f] target-i386: add feature 
kvm_pv_unhalt
git bisect bad f010bc643a2759e87e989c3e4e85f15ec71ae98f
# bad: [4f2656079f903efcd0d8224cbc79170ad3ee5b70] linux-headers: update to 
3.12-rc1
git bisect bad 4f2656079f903efcd0d8224cbc79170ad3ee5b70
# bad: [787aaf5703a702094f395db6795e74230282cd62] target-i386: forward CPUID 
cache leaves when -cpu host is used
git bisect bad 787aaf5703a702094f395db6795e74230282cd62

Peter

On 20.09.2013 18:24, Paolo Bonzini wrote:

From: Benoît Canet ben...@irqsave.net

Some users running cpu intensive tasks checking the cache CPUID leaves at
startup and making decisions based on the result reported that the guest was
not reflecting the host CPUID leaves when -cpu host is used.

This patch fix this.

Signed-off-by: Benoît Canet ben...@irqsave.net
[Rename new field to cache_info_passthrough - Paolo]
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
  target-i386/cpu-qom.h |  3 +++
  target-i386/cpu.c | 19 +++
  2 files changed, 22 insertions(+)

diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index c4447c2..f4fab15 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -70,6 +70,9 @@ typedef struct X86CPU {
  bool hyperv_relaxed_timing;
  int hyperv_spinlock_attempts;
  +/* if true the CPUID code directly forward host cache leaves to the 
guest */
+bool cache_info_passthrough;
+
  /* Features that were filtered out because of missing host capabilities */
  uint32_t filtered_features[FEATURE_WORDS];
  diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c36345e..46edd75 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -486,6 +486,7 @@ typedef struct x86_def_t {
  int stepping;
  FeatureWordArray features;
  char model_id[48];
+bool cache_info_passthrough;
  } x86_def_t;
#define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
@@ -1139,6 +1140,7 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
  assert(kvm_enabled());
x86_cpu_def-name = host;
+x86_cpu_def-cache_info_passthrough = true;
  host_cpuid(0x0, 0, eax, ebx, ecx, edx);
  x86_cpu_vendor_words2str(x86_cpu_def-vendor, ebx, edx, ecx);
  @@ -1888,6 +1890,7 @@ static void cpu_x86_register(X86CPU *cpu, const char 
*name, Error **errp)
  env-features[FEAT_C000_0001_EDX] = def-features[FEAT_C000_0001_EDX];
  env-features[FEAT_7_0_EBX] = def-features[FEAT_7_0_EBX];
  env-cpuid_xlevel2 = def-xlevel2;
+cpu-cache_info_passthrough = def-cache_info_passthrough;
object_property_set_str(OBJECT(cpu), def-model_id, model-id, errp);
  }
@@ -2062,6 +2065,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, 
uint32_t count,
  break;
  case 2:
  /* cache info: needed for Pentium Pro compatibility */
+if (cpu-cache_info_passthrough) {
+host_cpuid(index, 0, eax, ebx, ecx, edx);

Re: [Qemu-devel] [PATCH] qemu-iotests: Add -c cache-mode to check

2013-11-18 Thread Kevin Wolf
Am 18.11.2013 um 16:29 hat Stefan Hajnoczi geschrieben:
 On Thu, Nov 14, 2013 at 10:24:04AM +0800, Fam Zheng wrote:
  The default cache mode for drive options is changed to writethrough, and
  overridable with ./check -c mode.
 
 Please make the default writeback so that ./check completes more
 quickly.

Changing the cache mode should be a separate patch.

The current default for all shell script based tests is
cache=writethrough (can be overridden with -nocache) and Python test
cases should respect the same setting.

This is also the problem that I see with this patch: It doesn't make
'-nocache' an alias of '-c none', but both control different aspects.
What should happen is that '-c mode' sets

QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS -t mode

like -nocache does today, and the Python scripts should refer to the
same cache settings as the bash scripts do.

Kevin



Re: [Qemu-devel] [PATCH] qemu-iotests: Add -c cache-mode to check

2013-11-18 Thread Kevin Wolf
Am 18.11.2013 um 16:32 hat Stefan Hajnoczi geschrieben:
 On Thu, Nov 14, 2013 at 10:24:04AM +0800, Fam Zheng wrote:
  The default cache mode for drive options is changed to writethrough, and
  overridable with ./check -c mode.
  
  Signed-off-by: Fam Zheng f...@redhat.com
  ---
   tests/qemu-iotests/common | 13 -
   tests/qemu-iotests/iotests.py |  3 ++-
   2 files changed, 14 insertions(+), 2 deletions(-)
 
 BTW, I looked back at Kevin's reply to your earlier patch and saw he
 suggested making the default writethrough.
 
 Kevin: Any reason not to use writeback by default?

I'm not opposed to changing the default in a second step. It's just that
writethrough is the default today and tests not respecting this are
buggy. So the incremental fix is to make them obey the global setting,
and then that setting can be tweaked in a second step.

Kevin



Re: [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify()

2013-11-18 Thread Michael S. Tsirkin
On Mon, Nov 18, 2013 at 11:32:17PM +0800, Amos Kong wrote:
 object_get_canonical_path() returns a gchar*, it should be freeed by the
 caller.
 
 Signed-off-by: Amos Kong ak...@redhat.com

Reviewed-by: Michael S. Tsirkin m...@redhat.com

 ---
 v2: put gchar *path inside rxfilter_notify_enabled block
 ---
  hw/net/virtio-net.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
 index 613f144..b75c753 100644
 --- a/hw/net/virtio-net.c
 +++ b/hw/net/virtio-net.c
 @@ -200,16 +200,16 @@ static void rxfilter_notify(NetClientState *nc)
  VirtIONet *n = qemu_get_nic_opaque(nc);
  
  if (nc-rxfilter_notify_enabled) {
 +gchar *path = object_get_canonical_path(OBJECT(n-qdev));
  if (n-netclient_name) {
  event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
 -n-netclient_name,
 -
 object_get_canonical_path(OBJECT(n-qdev)));
 +n-netclient_name, path);
  } else {
 -event_data = qobject_from_jsonf({ 'path': %s },
 -
 object_get_canonical_path(OBJECT(n-qdev)));
 +event_data = qobject_from_jsonf({ 'path': %s }, path);
  }
  monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
  qobject_decref(event_data);
 +g_free(path);
  
  /* disable event notification to avoid events flooding */
  nc-rxfilter_notify_enabled = 0;
 -- 
 1.8.3.1



  1   2   3   >