[Qemu-devel] [Bug 1308341] Re: Multiple CPUs causes blue screen on Windows guest

2014-05-13 Thread Krzysztof Cybulski
It look like adding hyperv in features section to guest definition
helps, my Win7 VM  now is running for ~12h, when without hyperv it was
like 3-4 hour. I will test it for few days and will post here again.

  features
acpi/
apic/
pae/
hyperv
  relaxed state='on'/
/hyperv
  /features

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

Title:
  Multiple CPUs causes blue screen on Windows guest

Status in QEMU:
  New
Status in “qemu” package in Ubuntu:
  New
Status in “qemu-kvm” package in Ubuntu:
  Confirmed

Bug description:
  Configuring a Windows 7 guest using more than one CPU cases the guest to 
fail. This happens after a few hours after guest boot. This is the error on the 
blue screen:
  A clock interrupt was not received on a secondary processor within the 
allocated time interval

  After resetting, the guest will never boot and a new bluescreen with
  the error STOP: 0x005c appears. Shutting down the guest
  completely and restarting it will allow it to boot and run for a few
  hours again.

  The guest was created using virt-manager. The error happens with or
  without virtio devices and with both 32-bit and 64-bit Windows 7
  guests.

  I am using Ubuntu 14.04 release candidate.

  qemu-kvm version 2.0.0~rc1+dfsg-0ubuntu3

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



Re: [Qemu-devel] [PATCH] usb: fix up post load checks

2014-05-13 Thread Gerd Hoffmann
On Di, 2014-05-13 at 03:02 +, Gonglei (Arei) wrote:
 Hi,
 
  -Original Message-
  From: qemu-devel-bounces+arei.gonglei=huawei@nongnu.org
  [mailto:qemu-devel-bounces+arei.gonglei=huawei@nongnu.org] On
  Behalf Of Michael S. Tsirkin
  Sent: Monday, May 12, 2014 8:16 PM
  To: qemu-devel@nongnu.org
  Cc: Gerd Hoffmann; dgilb...@redhat.com
  Subject: [Qemu-devel] [PATCH] usb: fix up post load checks
  
  Correct post load checks:
  1. dev-setup_len == sizeof(dev-data_buf)
  seems fine, no need to fail migration
  2. When state is DATA, passing index  len
 will cause memcpy with negative length,
 resulting in heap overflow
  
  First of the issues was reported by dgilbert.
  
  Reported-by: Dr. David Alan Gilbert dgilb...@redhat.com
  Signed-off-by: Michael S. Tsirkin m...@redhat.com
  ---
   hw/usb/bus.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
  
  diff --git a/hw/usb/bus.c b/hw/usb/bus.c
  index e48b19f..2721719 100644
  --- a/hw/usb/bus.c
  +++ b/hw/usb/bus.c
  @@ -51,8 +51,9 @@ static int usb_device_post_load(void *opaque, int
  version_id)
   }
   if (dev-setup_index  0 ||
   dev-setup_len  0 ||
  -dev-setup_index = sizeof(dev-data_buf) ||
 
 Does this check should be deleted ?

It's ok, index = len  len = sizeof(buf) implies index = sizeof(buf)

 
  -dev-setup_len = sizeof(dev-data_buf)) {
  +(dev-setup_state == SETUP_STATE_DATA 
  + dev-setup_index  dev-setup_len) ||
  +dev-setup_len  sizeof(dev-data_buf)) {
   return -EINVAL;
   }
   return 0;
  --
  MST
 
 Best regards,
 -Gonglei





Re: [Qemu-devel] [RFC PATCH 08/11] softmmu: make do_unaligned_access extern

2014-05-13 Thread Andreas Färber
Am 08.05.2014 18:09, schrieb Paolo Bonzini:
 We will reference it from more files in the next patch.
 
 Signed-off-by: Paolo Bonzini pbonz...@redhat.com
 ---
  target-alpha/cpu.h | 3 +++
  target-alpha/mem_helper.c  | 4 ++--
  target-mips/cpu.h  | 3 +++
  target-mips/op_helper.c| 8 ++--
  target-sparc/cpu.h | 4 
  target-sparc/ldst_helper.c | 9 +++--
  target-xtensa/cpu.h| 3 +++
  target-xtensa/op_helper.c  | 5 +
  8 files changed, 21 insertions(+), 18 deletions(-)
 
 diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h
 index d9b861f..242068f 100644
 --- a/target-alpha/cpu.h
 +++ b/target-alpha/cpu.h
 @@ -498,6 +498,9 @@ static inline void cpu_get_tb_cpu_state(CPUAlphaState 
 *env, target_ulong *pc,
  *pflags = flags;
  }
  
 +void do_unaligned_access(CPUAlphaState *env, target_ulong addr,
 + int is_write, int is_user, uintptr_t retaddr);
 +
  #include exec/exec-all.h
  
  #endif /* !defined (__CPU_ALPHA_H__) */
[snip]

Have you considered turning this into CPUClass hooks instead, as done
with do_unassigned_access?

Before your patch, this was a static function used only by
softmmu_template.h - making it global is not exactly helping with
multi-target support. Any solution to remedy regressions appreciated.

Regards,
Andreas

-- 
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] xhci: child detach fix

2014-05-13 Thread Gerd Hoffmann
  Hi,

 BTW, in usb_release_port(), the detached port should be insert
 the head of bus-free list table. Because of the save/restore will
 cause qemu crash, after hot plug/hot unplug multi times. For example,
 save the port '2' to memory file, but when we restore it, the port will
 be assign to '1' over again, which not match with the memory file,
 and then crash qemu.

If you want hotplug and live migration play well you have to explicitly
assign devices ports, i.e.

  -device usb-host,port=2,$args

Otherwise it will simply not work reliable.

cheers,
  Gerd





[Qemu-devel] [PATCH v2 04/16] highbank: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/net/xgmac.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
index 88349ac..734c2e5 100644
--- a/hw/net/xgmac.c
+++ b/hw/net/xgmac.c
@@ -30,14 +30,16 @@
 #include net/net.h
 #include net/checksum.h
 
+//#define DEBUG_XGMAC
+
 #ifdef DEBUG_XGMAC
-#define DEBUGF_BRK(message, args...) do { \
- fprintf(stderr, (message), ## args); \
- } while (0)
+#define DEBUG_XGMAC_ENABLED 1
 #else
-#define DEBUGF_BRK(message, args...) do { } while (0)
+#define DEBUG_XGMAC_ENABLED 0
 #endif
 
+#define DEBUGF_BRK(message, args...) QEMU_DPRINTF(DEBUG_XGMAC_ENABLED, 
xgmag, message, ## args)
+
 #define XGMAC_CONTROL   0x   /* MAC Configuration */
 #define XGMAC_FRAME_FILTER  0x0001   /* MAC Frame Filter */
 #define XGMAC_FLOW_CTRL 0x0006   /* MAC Flow Control */
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 07/16] stellaris: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/net/stellaris_enet.c |   21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
index d04e6a4..f6737a9 100644
--- a/hw/net/stellaris_enet.c
+++ b/hw/net/stellaris_enet.c
@@ -13,16 +13,17 @@
 //#define DEBUG_STELLARIS_ENET 1
 
 #ifdef DEBUG_STELLARIS_ENET
-#define DPRINTF(fmt, ...) \
-do { printf(stellaris_enet:  fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, stellaris_enet: error:  fmt , ## __VA_ARGS__); 
exit(1);} while (0)
+#define DEBUG_STELLARIS_ENET_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) do {} while(0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, stellaris_enet: error:  fmt , ## __VA_ARGS__);} while 
(0)
+#define DEBUG_STELLARIS_ENET_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_STELLARIS_ENET_ENABLED, 
stellaris_enet, fmt, ## __VA_ARGS__)
+
+#define BADF(fmt, ...) \
+QEMU_DPRINTF(1, stellaris_enet error, fmt, ## __VA_ARGS__); \
+do { if (DEBUG_STELLARIS_ENET_ENABLED) { exit(1); } } while (0)
+
 #define SE_INT_RX   0x01
 #define SE_INT_TXER 0x02
 #define SE_INT_TXEMP0x04
@@ -97,7 +98,7 @@ static ssize_t stellaris_enet_receive(NetClientState *nc, 
const uint8_t *buf, si
 return -1;
 }
 
-DPRINTF(Received packet len=%d\n, size);
+DPRINTF(Received packet len=%d\n, (int)size);
 n = s-next_packet + s-np;
 if (n = 31)
 n -= 31;
@@ -212,14 +213,14 @@ static void stellaris_enet_write(void *opaque, hwaddr 
offset,
 switch (offset) {
 case 0x00: /* IACK */
 s-ris = ~value;
-DPRINTF(IRQ ack %02x/%02x\n, value, s-ris);
+DPRINTF(IRQ ack %02x/%02x\n, (unsigned)value, s-ris);
 stellaris_enet_update(s);
 /* Clearing TXER also resets the TX fifo.  */
 if (value  SE_INT_TXER)
 s-tx_frame_len = -1;
 break;
 case 0x04: /* IM */
-DPRINTF(IRQ mask %02x/%02x\n, value, s-ris);
+DPRINTF(IRQ mask %02x/%02x\n, (unsigned)value, s-ris);
 s-im = value;
 stellaris_enet_update(s);
 break;
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 15/16] pci-host: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/pci-host/bonito.c  |   10 ++
 hw/pci-host/ppce500.c |8 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 902441f..4a1dd20 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -50,11 +50,13 @@
 //#define DEBUG_BONITO
 
 #ifdef DEBUG_BONITO
-#define DPRINTF(fmt, ...) fprintf(stderr, %s:  fmt, __FUNCTION__, 
##__VA_ARGS__)
+#define DEBUG_BONITO_ENABLED 1
 #else
-#define DPRINTF(fmt, ...)
+#define DEBUG_BONITO_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_BONITO_ENABLED, bonito, fmt, ## 
__VA_ARGS__)
+
 /* from linux soure code. include/asm-mips/mips-boards/bonito64.h*/
 #define BONITO_BOOT_BASE0x1fc0
 #define BONITO_BOOT_SIZE0x0010
@@ -235,7 +237,7 @@ static void bonito_writel(void *opaque, hwaddr addr,
 
 saddr = (addr - BONITO_REGBASE)  2;
 
-DPRINTF(bonito_writel TARGET_FMT_plx val %x saddr %x\n, addr, val, 
saddr);
+DPRINTF(bonito_writel TARGET_FMT_plx val %x saddr %x\n, addr, 
(unsigned)val, saddr);
 switch (saddr) {
 case BONITO_BONPONCFG:
 case BONITO_IODEVCFG:
@@ -322,7 +324,7 @@ static void bonito_pciconf_writel(void *opaque, hwaddr addr,
 PCIBonitoState *s = opaque;
 PCIDevice *d = PCI_DEVICE(s);
 
-DPRINTF(bonito_pciconf_writel TARGET_FMT_plx val %x\n, addr, val);
+DPRINTF(bonito_pciconf_writel TARGET_FMT_plx val %x\n, addr, 
(unsigned)val);
 d-config_write(d, addr, val, 4);
 }
 
diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c
index c80b7cb..dfeb19e 100644
--- a/hw/pci-host/ppce500.c
+++ b/hw/pci-host/ppce500.c
@@ -21,12 +21,16 @@
 #include qemu/bswap.h
 #include hw/pci-host/ppce500.h
 
+//#define DEBUG_PCI
+
 #ifdef DEBUG_PCI
-#define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
+#define DEBUG_PCI_ENABLED 1
 #else
-#define pci_debug(fmt, ...)
+#define DEBUG_PCI_ENABLED 0
 #endif
 
+#define pci_debug(fmt, ...) QEMU_DPRINTF(DEBUG_PCI_ENABLED, ppce500, fmt, ## 
__VA_ARGS__)
+
 #define PCIE500_CFGADDR   0x0
 #define PCIE500_CFGDATA   0x4
 #define PCIE500_REG_BASE  0xC00
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 08/16] tpm: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/tpm/tpm_passthrough.c |8 
 hw/tpm/tpm_tis.c |   10 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 56e9e0f..673ab0e 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -37,13 +37,13 @@
 /* #define DEBUG_TPM */
 
 #ifdef DEBUG_TPM
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_TPM_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_TPM_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_TPM_ENABLED, tpm-passthrough, 
fmt, ## __VA_ARGS__)
+
 #define TYPE_TPM_PASSTHROUGH tpm-passthrough
 #define TPM_PASSTHROUGH(obj) \
 OBJECT_CHECK(TPMPassthruState, (obj), TYPE_TPM_PASSTHROUGH)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 6f0a4d2..302f2bf 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -30,16 +30,16 @@
 #include qemu-common.h
 #include qemu/main-loop.h
 
-/*#define DEBUG_TIS */
+/*#define DEBUG_TIS*/
 
 #ifdef DEBUG_TIS
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_TIS_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_TIS_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_TIS_ENABLED, tpm-tis, fmt, ## 
__VA_ARGS__)
+
 /* whether the STS interrupt is supported */
 #define RAISE_STS_IRQ
 
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 06/16] spapr: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/net/spapr_llan.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index c47..1639f4b 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -39,11 +39,13 @@
 /*#define DEBUG*/
 
 #ifdef DEBUG
-#define DPRINTF(fmt...) do { fprintf(stderr, fmt); } while (0)
+#define DEBUG_ENABLED 1
 #else
-#define DPRINTF(fmt...)
+#define DEBUG_ENABLED 0
 #endif
 
+#define DPRINTF(fmt...) QEMU_DPRINTF(DEBUG_ENABLED, spapr_llan, fmt)
+
 /*
  * Virtual LAN device
  */
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 10/16] i8257: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/dma/i8257.c |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index 4490372..22cb2bf 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -27,15 +27,16 @@
 
 /* #define DEBUG_DMA */
 
-#define dolog(...) fprintf (stderr, dma:  __VA_ARGS__)
 #ifdef DEBUG_DMA
-#define linfo(...) fprintf (stderr, dma:  __VA_ARGS__)
-#define ldebug(...) fprintf (stderr, dma:  __VA_ARGS__)
+#define DEBUG_DMA_ENABLED 1
 #else
-#define linfo(...)
-#define ldebug(...)
+#define DEBUG_DMA_ENABLED 0
 #endif
 
+#define dolog(...) QEMU_DPRINTF(1, dma, __VA_ARGS__)
+#define linfo(...) QEMU_DPRINTF(DEBUG_DMA_ENABLED, dma, __VA_ARGS__);
+#define ldebug linfo
+
 struct dma_regs {
 int now[2];
 uint16_t base[2];
@@ -301,7 +302,7 @@ static uint64_t read_cont(void *opaque, hwaddr nport, 
unsigned size)
 break;
 }
 
-ldebug (read_cont: nport %#06x, iport %#04x val %#x\n, nport, iport, 
val);
+ldebug (read_cont: nport %#06x, iport %#04x val %#x\n, (unsigned)nport, 
iport, val);
 return val;
 }
 
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 13/16] isa: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/isa/vt82c686.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 1a93afd..5184e4b 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -29,11 +29,13 @@
 //#define DEBUG_VT82C686B
 
 #ifdef DEBUG_VT82C686B
-#define DPRINTF(fmt, ...) fprintf(stderr, %s:  fmt, __FUNCTION__, 
##__VA_ARGS__)
+#define DEBUG_VT82C686B_ENABLED 1
 #else
-#define DPRINTF(fmt, ...)
+#define DEBUG_VT82C686B_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_VT82C686B_ENABLED, vt82c686, 
fmt, ## __VA_ARGS__)
+
 typedef struct SuperIOConfig
 {
 uint8_t config[0xff];
@@ -53,7 +55,7 @@ static void superio_ioport_writeb(void *opaque, hwaddr addr, 
uint64_t data,
 int can_write;
 SuperIOConfig *superio_conf = opaque;
 
-DPRINTF(superio_ioport_writeb  address 0x%x  val 0x%x\n, addr, data);
+DPRINTF(superio_ioport_writeb  address 0x%x  val 0x%x\n, (unsigned)addr, 
(unsigned)data);
 if (addr == 0x3f0) {
 superio_conf-index = data  0xff;
 } else {
@@ -99,7 +101,7 @@ static uint64_t superio_ioport_readb(void *opaque, hwaddr 
addr, unsigned size)
 {
 SuperIOConfig *superio_conf = opaque;
 
-DPRINTF(superio_ioport_readb  address 0x%x\n, addr);
+DPRINTF(superio_ioport_readb  address 0x%x\n, (unsigned)addr);
 return (superio_conf-config[superio_conf-index]);
 }
 
-- 
1.7.10.4




[Qemu-devel] [PATCH 0/4] Support more than 255 cpus

2014-05-13 Thread Li, Zhen-Hua
From: Li, ZhenHua zhen-h...@hp.com

These series patches are trying to make Qemu support more than 255 CPUs. 
The max cpu number changed to 4096.

 Support more than 255 cpus: ACPI and APIC defines
 Support more than 255 cpus: max_cpus to 4096
 Support more than 255 cpus: max cpumask bit to 4096
 Support more than 255 cpus: runtime chec

 include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
 include/hw/i386/apic_internal.h| 2 +-
 include/hw/i386/pc.h | 2 +-
 include/sysemu/sysemu.h | 2 +-
 hw/i386/acpi-build.c | 8 



Re: [Qemu-devel] [PATCH] virtio-blk: Allow config-wce in dataplane

2014-05-13 Thread Fam Zheng
On Tue, 05/13 09:07, Paolo Bonzini wrote:
 Il 13/05/2014 04:24, Fam Zheng ha scritto:
 Dataplane now uses block layer. Protect bdrv_set_enable_write_cache with
 aio_context_acquire and aio_context_release, so we can enable config-wce
 to allow guest to modify the write cache online.
 
 Signed-off-by: Fam Zheng f...@redhat.com
 
 ---
 This applies on top of Stefan's dataplane: use QEMU block layer
 series.
 
 Signed-off-by: Fam Zheng f...@redhat.com
 ---
  hw/block/dataplane/virtio-blk.c | 6 --
  hw/block/virtio-blk.c   | 9 -
  2 files changed, 8 insertions(+), 7 deletions(-)
 
 diff --git a/hw/block/dataplane/virtio-blk.c 
 b/hw/block/dataplane/virtio-blk.c
 index 79fb612..46a6824 100644
 --- a/hw/block/dataplane/virtio-blk.c
 +++ b/hw/block/dataplane/virtio-blk.c
 @@ -332,12 +332,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, 
 VirtIOBlkConf *blk,
  return;
  }
 
 -if (blk-config_wce) {
 -error_setg(errp, device is incompatible with x-data-plane, 
 - use config-wce=off);
 -return;
 -}
 -
  /* If dataplane is (re-)enabled while the guest is running there could 
  be
   * block jobs that can conflict.
   */
 diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
 index 8a568e5..a031e56 100644
 --- a/hw/block/virtio-blk.c
 +++ b/hw/block/virtio-blk.c
 @@ -26,6 +26,7 @@
  # include scsi/sg.h
  #endif
  #include hw/virtio/virtio-bus.h
 +#include block/block_int.h
 
 You shouldn't need to include this header file.  Apart from this, the patch
 looks good.

It's for bdrv_get_aio_context, otherwise it doesn't compile.

Fam



Re: [Qemu-devel] [PATCH v2 2/3] PPC: Allow little-endian user mode.

2014-05-13 Thread Alexander Graf


On 10.05.14 11:16, Doug Kwan wrote:

This allow running PPC64 little-endian in user mode if target is configured
that way.  In PPC64 LE user mode we set MSR.LE during initialization.
Overhaul handling of byteswapping in code generation and mem helpers.

Signed-off-by: Doug Kwan dougk...@google.com
---
  target-ppc/mem_helper.c |  25 ++--
  target-ppc/translate.c  | 150 +---
  target-ppc/translate_init.c |   9 +++
  3 files changed, 89 insertions(+), 95 deletions(-)



[...]


diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 4d94015..84381ae 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -8418,6 +8418,9 @@ static void ppc_cpu_reset(CPUState *s)
  msr |= (target_ulong)1  MSR_VR; /* Allow altivec usage */
  msr |= (target_ulong)1  MSR_SPE; /* Allow SPE usage */
  msr |= (target_ulong)1  MSR_PR;
+#if !defined(TARGET_WORDS_BIGENDIAN)
+msr |= (target_ulong)1  MSR_LE; /* Little-endian user mode */
+#endif
  #endif
  
  #if defined(TARGET_PPC64)

@@ -8461,6 +8464,12 @@ static void ppc_cpu_reset(CPUState *s)
  
  /* Flush all TLBs */

  tlb_flush(s, 1);
+
+#if defined(CONFIG_USER_ONLY)  !defined(TARGET_WORDS_BIGENDIAN)
+if (!msr_le) {
+cpu_abort(CPU(cpu), Cannot set QEMU to little-endian user mode\n);


We don't have this check the other way around, so why do we need it 
here? How do you ever get to this?



Alex




[Qemu-devel] [PATCH 3/4] Support more than 255 cpus: max cpumask bit to 4096

2014-05-13 Thread Li, Zhen-Hua
From: Li, ZhenHua zhen-h...@hp.com

Change MAX_CPUMASK_BITS from 255 to 4096.

Signed-off-by: Li, ZhenHua zhen-h...@hp.com
---
 include/sysemu/sysemu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index ba5c7f8..97961a6 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -139,7 +139,7 @@ extern QEMUClockType rtc_clock;
  *
  * Note that cpu-get_arch_id() may be larger than MAX_CPUMASK_BITS.
  */
-#define MAX_CPUMASK_BITS 255
+#define MAX_CPUMASK_BITS 4096
 
 extern int nb_numa_nodes;
 extern uint64_t node_mem[MAX_NODES];
-- 
2.0.0-rc0




Re: [Qemu-devel] [PATCH] virtio-blk: Allow config-wce in dataplane

2014-05-13 Thread Paolo Bonzini

Il 13/05/2014 04:24, Fam Zheng ha scritto:

Dataplane now uses block layer. Protect bdrv_set_enable_write_cache with
aio_context_acquire and aio_context_release, so we can enable config-wce
to allow guest to modify the write cache online.

Signed-off-by: Fam Zheng f...@redhat.com

---
This applies on top of Stefan's dataplane: use QEMU block layer
series.

Signed-off-by: Fam Zheng f...@redhat.com
---
 hw/block/dataplane/virtio-blk.c | 6 --
 hw/block/virtio-blk.c   | 9 -
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 79fb612..46a6824 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -332,12 +332,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, 
VirtIOBlkConf *blk,
 return;
 }

-if (blk-config_wce) {
-error_setg(errp, device is incompatible with x-data-plane, 
- use config-wce=off);
-return;
-}
-
 /* If dataplane is (re-)enabled while the guest is running there could be
  * block jobs that can conflict.
  */
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 8a568e5..a031e56 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -26,6 +26,7 @@
 # include scsi/sg.h
 #endif
 #include hw/virtio/virtio-bus.h
+#include block/block_int.h


You shouldn't need to include this header file.  Apart from this, the 
patch looks good.


Paolo



 typedef struct VirtIOBlockReq
 {
@@ -523,7 +524,10 @@ static void virtio_blk_set_config(VirtIODevice *vdev, 
const uint8_t *config)
 struct virtio_blk_config blkcfg;

 memcpy(blkcfg, config, sizeof(blkcfg));
+
+aio_context_acquire(bdrv_get_aio_context(s-bs));
 bdrv_set_enable_write_cache(s-bs, blkcfg.wce != 0);
+aio_context_release(bdrv_get_aio_context(s-bs));
 }

 static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features)
@@ -582,7 +586,10 @@ static void virtio_blk_set_status(VirtIODevice *vdev, 
uint8_t status)
  * s-bs would erroneously be placed in writethrough mode.
  */
 if (!(features  (1  VIRTIO_BLK_F_CONFIG_WCE))) {
-bdrv_set_enable_write_cache(s-bs, !!(features  (1  
VIRTIO_BLK_F_WCE)));
+aio_context_acquire(bdrv_get_aio_context(s-bs));
+bdrv_set_enable_write_cache(s-bs,
+!!(features  (1  VIRTIO_BLK_F_WCE)));
+aio_context_release(bdrv_get_aio_context(s-bs));
 }
 }







[Qemu-devel] [PATCH v2 16/16] common: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 include/qemu-common.h |7 +++
 migration-rdma.c  |   32 ++--
 page_cache.c  |   10 ++
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/include/qemu-common.h b/include/qemu-common.h
index 3f3fd60..3593bdc 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -463,3 +463,10 @@ int parse_debug_env(const char *name, int max, int 
initial);
 const char *qemu_ether_ntoa(const MACAddr *mac);
 
 #endif
+
+#define QEMU_DPRINTF(cond,pfx,fmt,...) \
+  do { \
+if (cond) { \
+  fprintf(stderr, pfx: %s:fmt, __func__, ## __VA_ARGS__); \
+} \
+  } while (0)
diff --git a/migration-rdma.c b/migration-rdma.c
index eeb4302..9f9fa8d 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -32,39 +32,35 @@
 //#define DEBUG_RDMA_REALLY_VERBOSE
 
 #ifdef DEBUG_RDMA
-#define DPRINTF(fmt, ...) \
-do { printf(rdma:  fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_RDMA_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_RDMA_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_RDMA_ENABLED, rdma, fmt, ## 
__VA_ARGS__)
+
 #ifdef DEBUG_RDMA_VERBOSE
-#define DDPRINTF(fmt, ...) \
-do { printf(rdma:  fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_RDMA_VERBOSE_ENABLED 1
 #else
-#define DDPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_RDMA_VERBOSE_ENABLED 0
 #endif
 
+#define DDPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_RDMA_VERBOSE_ENABLED, rdma, 
fmt, ## __VA_ARGS__)
+
 #ifdef DEBUG_RDMA_REALLY_VERBOSE
-#define DDDPRINTF(fmt, ...) \
-do { printf(rdma:  fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_RDMA_REALLY_VERBOSE_ENABLED 1
 #else
-#define DDDPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_RDMA_REALLY_VERBOSE_ENABLED 0
 #endif
 
+#define DDDPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_RDMA_REALLY_VERBOSE_ENABLED, 
rdma, fmt, ## __VA_ARGS__)
+
 /*
  * Print and error on both the Monitor and the Log file.
  */
 #define ERROR(errp, fmt, ...) \
-do { \
-fprintf(stderr, RDMA ERROR:  fmt \n, ## __VA_ARGS__); \
-if (errp  (*(errp) == NULL)) { \
-error_setg(errp, RDMA ERROR:  fmt, ## __VA_ARGS__); \
-} \
-} while (0)
+QEMU_DPRINTF(1, RDMA ERROR, fmt\n, ## __VA_ARGS__); \
+do { if (errp  (*(errp) == NULL)) { error_setg(errp, RDMA ERROR:  fmt, 
## __VA_ARGS__); } } while (0)
 
 #define RDMA_RESOLVE_TIMEOUT_MS 1
 
diff --git a/page_cache.c b/page_cache.c
index b033681..514d8c0 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -25,14 +25,16 @@
 #include qemu-common.h
 #include migration/page_cache.h
 
+//#define DEBUG_CACHE 1
+
 #ifdef DEBUG_CACHE
-#define DPRINTF(fmt, ...) \
-do { fprintf(stdout, cache:  fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_CACHE_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_CACHE_ENABLED 0 
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_CACHE_ENABLED, cache, fmt, ## 
__VA_ARGS__)
+
 typedef struct CacheItem CacheItem;
 
 struct CacheItem {
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/i386/kvm/pci-assign.c |9 -
 hw/i386/multiboot.c  |6 --
 target-i386/kvm.c|8 
 xen-hvm.c|   12 ++--
 xen-mapcache.c   |8 
 5 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index e55421a..35757ae 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -51,14 +51,13 @@
 //#define DEVICE_ASSIGNMENT_DEBUG
 
 #ifdef DEVICE_ASSIGNMENT_DEBUG
-#define DEBUG(fmt, ...)   \
-do {  \
-fprintf(stderr, %s:  fmt, __func__ , __VA_ARGS__);  \
-} while (0)
+#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 1
 #else
-#define DEBUG(fmt, ...)
+#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 0
 #endif
 
+#define DEBUG(fmt, ...) QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, 
pci_assign, fmt, ## __VA_ARGS__)
+
 typedef struct PCIRegion {
 int type;   /* Memory or port I/O */
 int valid;
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index 985ca1e..cd215dc 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -33,11 +33,13 @@
 //#define DEBUG_MULTIBOOT
 
 #ifdef DEBUG_MULTIBOOT
-#define mb_debug(a...) fprintf(stderr, ## a)
+#define DEBUG_MULTIBOOT_ENABLED 1
 #else
-#define mb_debug(a...)
+#define DEBUG_MULTIBOOT_ENABLED 0
 #endif
 
+#define mb_debug(a...) QEMU_DPRINTF(DEBUG_MULTIBOOT_ENABLED, i386 multiboot, 
a)
+
 #define MULTIBOOT_STRUCT_ADDR 0x9000
 
 #if MULTIBOOT_STRUCT_ADDR  0xf
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 4389959..d6cd89c 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -37,13 +37,13 @@
 //#define DEBUG_KVM
 
 #ifdef DEBUG_KVM
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_KVM_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_KVM_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_KVM_ENABLED, i386 kvm, fmt, ## 
__VA_ARGS__)
+
 #define MSR_KVM_WALL_CLOCK  0x11
 #define MSR_KVM_SYSTEM_TIME 0x12
 
diff --git a/xen-hvm.c b/xen-hvm.c
index a64486c..ccce342 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -26,16 +26,16 @@
 #include xen/hvm/params.h
 #include xen/hvm/e820.h
 
-//#define DEBUG_XEN_HVM
+//#define DEBUG_XEN
 
-#ifdef DEBUG_XEN_HVM
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, xen:  fmt, ## __VA_ARGS__); } while (0)
+#ifdef DEBUG_XEN
+#define DEBUG_XEN_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_XEN_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_XEN_ENABLED, xen, fmt, ## 
__VA_ARGS__)
+
 static MemoryRegion ram_memory, ram_640k, ram_lo, ram_hi;
 static MemoryRegion *framebuffer;
 static bool xen_in_migration;
diff --git a/xen-mapcache.c b/xen-mapcache.c
index eda914a..a50bb80 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -26,13 +26,13 @@
 //#define MAPCACHE_DEBUG
 
 #ifdef MAPCACHE_DEBUG
-#  define DPRINTF(fmt, ...) do { \
-fprintf(stderr, xen_mapcache:  fmt, ## __VA_ARGS__); \
-} while (0)
+#define MAPCACHE_DEBUG_ENABLED 1
 #else
-#  define DPRINTF(fmt, ...) do { } while (0)
+#define MAPCACHE_DEBUG_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(MAPCACHE_DEBUG_ENABLED, xen_mapcache, 
fmt, ## __VA_ARGS__)
+
 #if defined(__i386__)
 #  define MCACHE_BUCKET_SHIFT 16
 #  define MCACHE_MAX_SIZE (1UL31) /* 2GB Cap */
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 11/16] rc4030: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/dma/rc4030.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c
index af26632..84f9f33 100644
--- a/hw/dma/rc4030.c
+++ b/hw/dma/rc4030.c
@@ -32,17 +32,16 @@
 //#define DEBUG_RC4030
 //#define DEBUG_RC4030_DMA
 
-#ifdef DEBUG_RC4030
-#define DPRINTF(fmt, ...) \
-do { printf(rc4030:  fmt , ## __VA_ARGS__); } while (0)
 static const char* irq_names[] = { parallel, floppy, sound, video,
 network, scsi, keyboard, mouse, serial0, serial1 };
+#ifdef DEBUG_RC4030
+#define DEBUG_RC4030_ENABLED 1
 #else
-#define DPRINTF(fmt, ...)
+#define DEBUG_RC4030_ENABLED 0
 #endif
 
-#define RC4030_ERROR(fmt, ...) \
-do { fprintf(stderr, rc4030 ERROR: %s:  fmt, __func__ , ## __VA_ARGS__); } 
while (0)
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_RC4030_ENABLED, rc4030, fmt, ## 
__VA_ARGS__)
+#define RC4030_ERROR(fmt, ...) QEMU_DPRINTF(1, rc4030 ERROR, fmt, ## 
__VA_ARGS__)
 
 //
 /* rc4030 emulation */
-- 
1.7.10.4




[Qemu-devel] [PATCH v2 09/16] i82374: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/dma/i82374.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c
index b8ad2e6..7026f24 100644
--- a/hw/dma/i82374.c
+++ b/hw/dma/i82374.c
@@ -27,14 +27,13 @@
 //#define DEBUG_I82374
 
 #ifdef DEBUG_I82374
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, i82374:  fmt , ## __VA_ARGS__); } while (0)
+#define DEBUG_I82374_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do {} while (0)
+#define DEBUG_I82374_ENABLED 0
 #endif
-#define BADF(fmt, ...) \
-do { fprintf(stderr, i82374 ERROR:  fmt , ## __VA_ARGS__); } while (0)
+
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_I82374_ENABLED, i82374, fmt, ## 
__VA_ARGS__)
+#define BADF(fmt, ...) QEMU_DPRINTF(1, i82374 ERROR, fmt, ## __VA_ARGS__)
 
 typedef struct I82374State {
 uint8_t commands[8];
-- 
1.7.10.4




Re: [Qemu-devel] [RFC PATCH 09/11] target-arm: move arm_*_code to a separate file

2014-05-13 Thread Andreas Färber
Am 08.05.2014 18:09, schrieb Paolo Bonzini:
 These will soon require cpu_ldst.h, so move them out of cpu.h.
 
 Signed-off-by: Paolo Bonzini pbonz...@redhat.com
 ---
  target-arm/arm_ldst.h  | 47 
 ++
  target-arm/cpu.h   | 22 --
  target-arm/helper.c|  1 +
  target-arm/translate-a64.c |  1 +
  target-arm/translate.c |  1 +
  5 files changed, 50 insertions(+), 22 deletions(-)
  create mode 100644 target-arm/arm_ldst.h
 
 diff --git a/target-arm/arm_ldst.h b/target-arm/arm_ldst.h
 new file mode 100644
 index 000..42260ac
 --- /dev/null
 +++ b/target-arm/arm_ldst.h
 @@ -0,0 +1,47 @@
 +/*
 + * ARM load/store instructions for code (armeb-user support)
 + *
 + *  Copyright (c) 2012 CodeSourcery, LLC
 + *
 + * This library is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2 of the License, or (at your option) any later version.
 + *
 + * This library is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with this library; if not, see 
 http://www.gnu.org/licenses/.
 + */
 +
 +#ifndef ARM_LDST_H
 +#define ARM_LDST_H
 +
 +#include qemu/bswap.h
 +
 +/* Load an instruction and return it in the standard little-endian order */
 +static inline uint32_t arm_ldl_code(CPUARMState *env, target_ulong addr,
 +bool do_swap)
 +{
 +uint32_t insn = cpu_ldl_code(env, addr);
 +if (do_swap) {
 +return bswap32(insn);
 +}
 +return insn;
 +}
 +
 +/* Ditto, for a halfword (Thumb) instruction */
 +static inline uint16_t arm_lduw_code(CPUARMState *env, target_ulong addr,
 + bool do_swap)
 +{
 +uint16_t insn = cpu_lduw_code(env, addr);
 +if (do_swap) {
 +return bswap16(insn);
 +}
 +return insn;
 +}
 +
 +#endif
[snip]

Reviewed-by: Andreas Färber afaer...@suse.de

I notice that these user-only functions/macros are taking CPUARMState
but never use it today. Should I convert them to CPUState once I tackle
linux-user, or can we just drop that unused argument?

Regards,
Andreas

-- 
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] [RFC] vhost: Can we change synchronize_rcu to call_rcu in vhost_set_memory() in vhost kernel module?

2014-05-13 Thread Gonglei (Arei)
Hi,

 -Original Message-
 From: Paolo Bonzini [mailto:pbonz...@redhat.com]
 Sent: Monday, May 12, 2014 5:58 PM

 Perhaps we can check for cases where only the address is changing, and
 poke at an existing struct kvm_kernel_irq_routing_entry without doing
 any RCU synchronization?
 
 As long as kvm_set_msi_irq only reads address_lo once, it should work.
 
 VHOST_SET_MEM_TABLE is a different problem.  What happens in userspace
 that leads to calling that ioctl?  Can we remove it altogether, or delay
 it to after the destination has started running?
 
I thought this approach is a little different from the original, as eliminating 
synchronize_rcu() 
means when the KVM_SET_GSI_ROUTING ioctl returns, CPUs that using old irq 
routing table 
may still running, and thus when vCPU in VM done setting CPU affinity, other 
vCPUs in VM 
may receive stale IRQs.

But since in the original code, 
kvm_set_msi()-kvm_irq_delivery_to_apic()-...-__apic_accept_irq() may only 
sets vCPU's 
LAPIC, and kvm_vcpu_kick(), which means destination vCPUs may get scheduled to 
run after 
vCPU setting IRQ affinity get returned, thus receiving old stale IRQs.

So thanks for the suggestion, I'll try it.

And VHOST_SET_MEM_TABLE ioctl comes from vhost_dev_start() in QEMU when 
migration 
destination starts devices.

Best regards,
-Gonglei



[Qemu-devel] [PATCH v2 14/16] lan9118: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/net/lan9118.c |   26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index e528290..5f43ab6 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -21,16 +21,22 @@
 //#define DEBUG_LAN9118
 
 #ifdef DEBUG_LAN9118
-#define DPRINTF(fmt, ...) \
-do { printf(lan9118:  fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { hw_error(lan9118: error:  fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_LAN9118_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) do {} while(0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, lan9118: error:  fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_LAN9118_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_LAN9118_ENABLED, lan9118, fmt, 
## __VA_ARGS__)
+
+#define BADF(fmt, ...) \
+do { \
+if(DEBUG_LAN9118_ENABLED) { \
+hw_error(lan9118: error:  fmt , ## __VA_ARGS__); \
+}else{ \
+fprintf(stderr, lan9118: error:  fmt , ## __VA_ARGS__); \
+} \
+} while (0)
+
 #define CSR_ID_REV  0x50
 #define CSR_IRQ_CFG 0x54
 #define CSR_INT_STS 0x58
@@ -1031,7 +1037,7 @@ static void lan9118_writel(void *opaque, hwaddr offset,
 s-int_sts |= val  SW_INT;
 break;
 case CSR_FIFO_INT:
-DPRINTF(FIFO INT levels %08x\n, val);
+DPRINTF(FIFO INT levels %08x\n, (unsigned)val);
 s-fifo_int = val;
 break;
 case CSR_RX_CFG:
@@ -1112,9 +1118,9 @@ static void lan9118_writel(void *opaque, hwaddr offset,
 if (val  0x8000) {
 if (val  0x4000) {
 s-mac_data = do_mac_read(s, val  0xf);
-DPRINTF(MAC read %d = 0x%08x\n, val  0xf, s-mac_data);
+DPRINTF(MAC read %d = 0x%08x\n, (unsigned)(val  0xf), 
s-mac_data);
 } else {
-DPRINTF(MAC write %d = 0x%08x\n, val  0xf, s-mac_data);
+DPRINTF(MAC write %d = 0x%08x\n, (unsigned)(val  0xf), 
s-mac_data);
 do_mac_write(s, val  0xf, s-mac_data);
 }
 }
-- 
1.7.10.4




Re: [Qemu-devel] [RFC PATCH 08/11] softmmu: make do_unaligned_access extern

2014-05-13 Thread Paolo Bonzini

Il 13/05/2014 08:53, Andreas Färber ha scritto:

 +void do_unaligned_access(CPUAlphaState *env, target_ulong addr,
 + int is_write, int is_user, uintptr_t retaddr);
 +
  #include exec/exec-all.h

  #endif /* !defined (__CPU_ALPHA_H__) */

[snip]

Have you considered turning this into CPUClass hooks instead, as done
with do_unassigned_access?

Before your patch, this was a static function used only by
softmmu_template.h - making it global is not exactly helping with
multi-target support. Any solution to remedy regressions appreciated.


Good idea!

Paolo



Re: [Qemu-devel] [RFC] vhost: Can we change synchronize_rcu to call_rcu in vhost_set_memory() in vhost kernel module?

2014-05-13 Thread Gonglei (Arei)
Hi,

 -Original Message-
 From: Michael S. Tsirkin [mailto:m...@redhat.com]
 Sent: Monday, May 12, 2014 6:31 PM
 
 vhost does everything under a VQ lock.
 I think RCU for VHOST_SET_MEM_TABLE can be replaced with
 taking and freeing the VQ lock.
 
 Does the below solve the problem for you
 (warning: untested, sorry, busy with other bugs right now)?
 
 
 Signed-off-by: Michael S. Tsirkin m...@redhat.com
 
 ---
 
 diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
 index 78987e4..df2e3eb 100644
 --- a/drivers/vhost/vhost.c
 +++ b/drivers/vhost/vhost.c
 @@ -593,6 +593,7 @@ static long vhost_set_memory(struct vhost_dev *d,
 struct vhost_memory __user *m)
  {
   struct vhost_memory mem, *newmem, *oldmem;
   unsigned long size = offsetof(struct vhost_memory, regions);
 + int i;
 
   if (copy_from_user(mem, m, size))
   return -EFAULT;
 @@ -619,7 +620,14 @@ static long vhost_set_memory(struct vhost_dev *d,
 struct vhost_memory __user *m)
   oldmem = rcu_dereference_protected(d-memory,
  lockdep_is_held(d-mutex));
   rcu_assign_pointer(d-memory, newmem);
 - synchronize_rcu();
 +
 + /* All memory accesses are done under some VQ mutex.
 +  * So below is a faster equivalent of synchronize_rcu()
 +  */
 + for (i = 0; i  dev-nvqs; ++i) {
 + mutex_lock(d-vqs[idx]-mutex);
 + mutex_unlock(d-vqs[idx]-mutex);
 + }
   kfree(oldmem);
   return 0;
  }

Thanks for your advice, I suppose getting mutexes should generally be faster 
than waiting for 
CPU context switches. And I think d-mutex should also be synchronized since 
somewhere gets 
only this mutex directly and not vq mutexes. Is this right?

I'll try this approach, thanks.

Best regards,
-Gonglei



[Qemu-devel] [PATCH v2 12/16] sd: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/sd/sd.c |7 ---
 hw/sd/ssi-sd.c |   14 +++---
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 4502ad1..4a11466 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -37,12 +37,13 @@
 //#define DEBUG_SD 1
 
 #ifdef DEBUG_SD
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, SD:  fmt , ## __VA_ARGS__); } while (0)
+#define DEBUG_SD_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) do {} while(0)
+#define DEBUG_SD_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_SD_ENABLED, SD, fmt, ## 
__VA_ARGS__)
+
 #define ACMD41_ENQUIRY_MASK 0x00ff
 
 typedef enum {
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index b012e57..8048056 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -17,16 +17,16 @@
 //#define DEBUG_SSI_SD 1
 
 #ifdef DEBUG_SSI_SD
-#define DPRINTF(fmt, ...) \
-do { printf(ssi_sd:  fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, ssi_sd: error:  fmt , ## __VA_ARGS__); exit(1);} while 
(0)
+#define DEBUG_SSI_SD_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) do {} while(0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, ssi_sd: error:  fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_SSI_SD_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_SSI_SD_ENABLED, ssi_sd, fmt, ## 
__VA_ARGS__)
+#define BADF(fmt, ...) \
+QEMU_DPRINTF(1, ssi_sd error, fmt, ## __VA_ARGS__); \
+do { if(DEBUG_SSI_SD_ENABLED) { exit(1); } } while (0)
+
 typedef enum {
 SSI_SD_CMD,
 SSI_SD_CMDARG,
-- 
1.7.10.4




[Qemu-devel] [PATCH 1/4] Support more than 255 cpus: ACPI and APIC defines

2014-05-13 Thread Li, Zhen-Hua
From: Li, ZhenHua zhen-h...@hp.com

Change ACPI_CPU_HOTPLUG_ID_LIMIT from 256 to 4096;
Change MAX_APICS from 256 to 4096;

Signed-off-by: Li, ZhenHua zhen-h...@hp.com
---
 include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
 include/hw/i386/apic_internal.h| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/hw/acpi/cpu_hotplug_defs.h 
b/include/hw/acpi/cpu_hotplug_defs.h
index 9f33663..17381e6 100644
--- a/include/hw/acpi/cpu_hotplug_defs.h
+++ b/include/hw/acpi/cpu_hotplug_defs.h
@@ -21,10 +21,10 @@
 /* Limit for CPU arch IDs for CPU hotplug. All hotpluggable CPUs should
  * have CPUClass.get_arch_id()  ACPI_CPU_HOTPLUG_ID_LIMIT.
  */
-#define ACPI_CPU_HOTPLUG_ID_LIMIT 256
+#define ACPI_CPU_HOTPLUG_ID_LIMIT 4096
 
 /* 256 CPU IDs, 8 bits per entry: */
-#define ACPI_GPE_PROC_LEN 32
+#define ACPI_GPE_PROC_LEN ((ACPI_CPU_HOTPLUG_ID_LIMIT)/8)
 
 #define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8
 #define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00
diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h
index 70542a6..e21f30e 100644
--- a/include/hw/i386/apic_internal.h
+++ b/include/hw/i386/apic_internal.h
@@ -64,7 +64,7 @@
 #define VAPIC_ENABLE_BIT0
 #define VAPIC_ENABLE_MASK   (1  VAPIC_ENABLE_BIT)
 
-#define MAX_APICS 255
+#define MAX_APICS 4096
 
 typedef struct APICCommonState APICCommonState;
 
-- 
2.0.0-rc0




Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 06/16] spapr: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Alexander Graf


On 13.05.14 09:02, Marc Marí wrote:

Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com


I think this patch set should go in as a whole via a single tree.

Acked-by: Alexander Graf ag...@suse.de


Alex




[Qemu-devel] [PATCH 2/4] Support more than 255 cpus: max_cpus to 4096

2014-05-13 Thread Li, Zhen-Hua
From: Li, ZhenHua zhen-h...@hp.com

max_cpus from 255 to 4096. So the machine types can support up to 4096 cpus.

Signed-off-by: Li, ZhenHua zhen-h...@hp.com
---
 include/hw/i386/pc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 9010246..8183141 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -411,6 +411,6 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 #define PC_DEFAULT_MACHINE_OPTIONS \
 PC_COMMON_MACHINE_OPTIONS, \
 .hot_add_cpu = pc_hot_add_cpu, \
-.max_cpus = 255
+.max_cpus = 4096
 
 #endif
-- 
2.0.0-rc0




Re: [Qemu-devel] [PATCH] xhci: child detach fix

2014-05-13 Thread Gonglei (Arei)
 -Original Message-
 From: Gerd Hoffmann [mailto:kra...@redhat.com]
 Sent: Tuesday, May 13, 2014 2:56 PM
 
  BTW, in usb_release_port(), the detached port should be insert
  the head of bus-free list table. Because of the save/restore will
  cause qemu crash, after hot plug/hot unplug multi times. For example,
  save the port '2' to memory file, but when we restore it, the port will
  be assign to '1' over again, which not match with the memory file,
  and then crash qemu.
 
 If you want hotplug and live migration play well you have to explicitly
 assign devices ports, i.e.
 
   -device usb-host,port=2,$args
 
 Otherwise it will simply not work reliable.
 
Yep, I have noticed that case, which pass-through two USB devices, and
then hot-unplug the first one, then save/restore, which will also crash qemu.

So maybe assign ports ahead was the exclusive method. Thanks,

Best regards,
-Gonglei



Re: [Qemu-devel] [RFC PATCH 11/11] softmmu: move all load/store functions to cpu_ldst.h

2014-05-13 Thread Andreas Färber
Am 08.05.2014 18:09, schrieb Paolo Bonzini:
 Unify pieces of cpu-all.h, exec-all.h, softmmu_exec.h and tcg/tcg.h
 into a single new header file with all helpers.
 
 Signed-off-by: Paolo Bonzini pbonz...@redhat.com
 ---
  include/exec/cpu-all.h | 119 ---
  include/exec/cpu_ldst.h| 369 
 -
  .../exec/{softmmu_header.h = cpu_ldst_template.h} |   2 +-
  include/exec/exec-all.h|  25 --
  include/exec/softmmu_exec.h| 216 
  tcg/tcg.h  |  13 -
  6 files changed, 368 insertions(+), 376 deletions(-)
  rename include/exec/{softmmu_header.h = cpu_ldst_template.h} (98%)
  delete mode 100644 include/exec/softmmu_exec.h

Seems like a nice cleanup,

Acked-by: Andreas Färber afaer...@suse.de

Will rth be handling this along with the backend conversions mentioned
in the cover letter?

Cheers,
Andreas

-- 
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 v2 2/3] PPC: Allow little-endian user mode.

2014-05-13 Thread Alexander Graf


On 13.05.14 09:30, Doug Kwan (關振德) wrote:




On Tue, May 13, 2014 at 12:05 AM, Alexander Graf ag...@suse.de 
mailto:ag...@suse.de wrote:



On 10.05.14 11:16, Doug Kwan wrote:

This allow running PPC64 little-endian in user mode if target
is configured
that way.  In PPC64 LE user mode we set MSR.LE during
initialization.
Overhaul handling of byteswapping in code generation and mem
helpers.

Signed-off-by: Doug Kwan dougk...@google.com
mailto:dougk...@google.com
---
  target-ppc/mem_helper.c |  25 ++--
  target-ppc/translate.c  | 150
+---
  target-ppc/translate_init.c |   9 +++
  3 files changed, 89 insertions(+), 95 deletions(-)


[...]


diff --git a/target-ppc/translate_init.c
b/target-ppc/translate_init.c
index 4d94015..84381ae 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -8418,6 +8418,9 @@ static void ppc_cpu_reset(CPUState *s)
  msr |= (target_ulong)1  MSR_VR; /* Allow altivec usage */
  msr |= (target_ulong)1  MSR_SPE; /* Allow SPE usage */
  msr |= (target_ulong)1  MSR_PR;
+#if !defined(TARGET_WORDS_BIGENDIAN)
+msr |= (target_ulong)1  MSR_LE; /* Little-endian user
mode */
+#endif
  #endif
#if defined(TARGET_PPC64)
@@ -8461,6 +8464,12 @@ static void ppc_cpu_reset(CPUState *s)
/* Flush all TLBs */
  tlb_flush(s, 1);
+
+#if defined(CONFIG_USER_ONLY)  !defined(TARGET_WORDS_BIGENDIAN)
+if (!msr_le) {
+cpu_abort(CPU(cpu), Cannot set QEMU to little-endian
user mode\n);


We don't have this check the other way around, so why do we need
it here? How do you ever get to this?


Alex

I am just being paranoid as I am new to this code base.  The reason 
why this is asymmetric because the PPC targets are big-endian by 
default and I don't know if all CPUs support setting msr.le.  If 
someone specifies a CPU that does not support little-endian mode, I 
want to stop qemu early with an error.  The check can be removed if it 
is redundant.


Well, all CPUs that Linux supports with LE today also support the MSR_LE 
bit. If anyone would ever want to do an e500 LE port things would become 
messy, as LE is a TLB property there, so we don't have a generic bit to 
look at.


I think we just drop this check. If the user passes in an incompatible 
CPU it's his own fault :).



Alex




Re: [Qemu-devel] [RFC PATCH 11/11] softmmu: move all load/store functions to cpu_ldst.h

2014-05-13 Thread Paolo Bonzini

Il 13/05/2014 09:13, Andreas Färber ha scritto:

Am 08.05.2014 18:09, schrieb Paolo Bonzini:

Unify pieces of cpu-all.h, exec-all.h, softmmu_exec.h and tcg/tcg.h
into a single new header file with all helpers.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 include/exec/cpu-all.h | 119 ---
 include/exec/cpu_ldst.h| 369 -
 .../exec/{softmmu_header.h = cpu_ldst_template.h} |   2 +-
 include/exec/exec-all.h|  25 --
 include/exec/softmmu_exec.h| 216 
 tcg/tcg.h  |  13 -
 6 files changed, 368 insertions(+), 376 deletions(-)
 rename include/exec/{softmmu_header.h = cpu_ldst_template.h} (98%)
 delete mode 100644 include/exec/softmmu_exec.h


Seems like a nice cleanup,

Acked-by: Andreas Färber afaer...@suse.de

Will rth be handling this along with the backend conversions mentioned
in the cover letter?


I guess so, in the meanwhile I'll send out the ld_raw-ld_p conversion 
separately, and the v2 of do_unaligned_access conversion for you to review.


Paolo




[Qemu-devel] [PATCH v2 03/16] scsi: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/scsi/lsi53c895a.c   |   17 -
 hw/scsi/scsi-generic.c |   12 +---
 hw/scsi/spapr_vscsi.c  |8 
 3 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index cb30414..4c92198 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -24,16 +24,16 @@
 //#define DEBUG_LSI_REG
 
 #ifdef DEBUG_LSI
-#define DPRINTF(fmt, ...) \
-do { printf(lsi_scsi:  fmt , ## __VA_ARGS__); } while (0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, lsi_scsi: error:  fmt , ## __VA_ARGS__); exit(1);} 
while (0)
+#define DEBUG_LSI_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) do {} while(0)
-#define BADF(fmt, ...) \
-do { fprintf(stderr, lsi_scsi: error:  fmt , ## __VA_ARGS__);} while (0)
+#define DEBUG_LSI_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_LSI_ENABLED, lsi_scsi, fmt, ## 
__VA_ARGS__)
+#define BADF(fmt, ...) \
+QEMU_DPRINTF(1, lsi_scsi error, fmt, ## __VA_ARGS__); \
+do { if(DEBUG_LSI_ENABLED) { exit(1); } } while (0)
+
 #define LSI_MAX_DEVS 7
 
 #define LSI_SCNTL0_TRG0x01
@@ -1261,12 +1261,11 @@ again:
 uint8_t data8;
 int reg;
 int operator;
-#ifdef DEBUG_LSI
+
 static const char *opcode_names[3] =
 {Write, Read, Read-Modify-Write};
 static const char *operator_names[8] =
 {MOV, SHL, OR, XOR, AND, SHR, ADD, ADC};
-#endif
 
 reg = ((insn  16)  0x7f) | (insn  0x80);
 data8 = (insn  8)  0xff;
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 8d92e0d..bf1207f 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -21,14 +21,13 @@
 //#define DEBUG_SCSI
 
 #ifdef DEBUG_SCSI
-#define DPRINTF(fmt, ...) \
-do { printf(scsi-generic:  fmt , ## __VA_ARGS__); } while (0)
+#define DEBUG_SCSI_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) do {} while(0)
+#define DEBUG_SCSI_ENABLED 0
 #endif
 
-#define BADF(fmt, ...) \
-do { fprintf(stderr, scsi-generic:  fmt , ## __VA_ARGS__); } while (0)
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_SCSI_ENABLED, scsi-generic, 
fmt, ## __VA_ARGS__)
+#define BADF(fmt, ...)  QEMU_DPRINTF(1, scsi-generic, fmt, ## __VA_ARGS__)
 
 #include stdio.h
 #include sys/types.h
@@ -303,8 +302,7 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t 
*cmd)
 SCSIDevice *s = r-req.dev;
 int ret;
 
-DPRINTF(Command: lun=%d tag=0x%x len %zd data=0x%02x, lun, tag,
-r-req.cmd.xfer, cmd[0]);
+DPRINTF(Command: len %zd data=0x%02x, r-req.cmd.xfer, cmd[0]);
 
 #ifdef DEBUG_SCSI
 {
diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index d4ada4f..c844bb0 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -45,13 +45,13 @@
 /*#define DEBUG_VSCSI*/
 
 #ifdef DEBUG_VSCSI
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_VSCSI_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_VSCSI_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_VSCSI_ENABLED, spapr_vscsi, 
fmt, ## __VA_ARGS__)
+
 /*
  * Virtual SCSI device
  */
-- 
1.7.10.4




[Qemu-devel] [PATCH 4/4] Support more than 255 cpus: runtime check

2014-05-13 Thread Li, Zhen-Hua
From: Li, ZhenHua zhen-h...@hp.com

There is some runtime check for max cpu count. Make them support 4096 cpus.

Signed-off-by: Li, ZhenHua zhen-h...@hp.com
---
 hw/i386/acpi-build.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index c98df88..5c3bf10 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -272,7 +272,7 @@ static void GCC_FMT_ATTR(2, 3)
 build_append_nameseg(GArray *array, const char *format, ...)
 {
 /* It would be nicer to use g_string_vprintf but it's only there in 2.22 */
-char s[] = ;
+char s[] = XX;
 int len;
 va_list args;
 
@@ -280,7 +280,7 @@ build_append_nameseg(GArray *array, const char *format, ...)
 len = vsnprintf(s, sizeof s, format, args);
 va_end(args);
 
-assert(len == 4);
+assert(len == 4 || len == 5 || len == 6);
 g_array_append_vals(array, s, len);
 }
 
@@ -680,7 +680,7 @@ build_append_notify_method(GArray *device, const char *name,
 for (i = 0; i  count; i++) {
 GArray *target = build_alloc_array();
 build_append_nameseg(target, format, i);
-assert(i  256); /* Fits in 1 byte */
+assert(i  4096); /* Fits in 1 byte */
 build_append_notify_target_ifequal(method, target, i, 1);
 build_free_array(target);
 }
@@ -1006,7 +1006,7 @@ build_ssdt(GArray *table_data, GArray *linker,
 
 /* The current AML generator can cover the APIC ID range [0..255],
  * inclusive, for VCPU hotplug. */
-QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT  256);
+QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT  4096);
 g_assert(acpi_cpus = ACPI_CPU_HOTPLUG_ID_LIMIT);
 
 /* Copy header and patch values in the S3_ / S4_ / S5_ packages */
-- 
2.0.0-rc0




Re: [Qemu-devel] [PATCH v2 01/16] x86: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Andreas Färber
Am 13.05.2014 09:02, schrieb Marc Marí:
 Modify debug macros to have the same format through the codebase and use 
 regular
 ifs instead of ifdef.
 
 As the debug printf is always put in code, some casting had to be added to 
 avoid
 warnings treated as errors at compile time.
 
 Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
 ---
  hw/i386/kvm/pci-assign.c |9 -
  hw/i386/multiboot.c  |6 --
  target-i386/kvm.c|8 
  xen-hvm.c|   12 ++--
  xen-mapcache.c   |8 
  5 files changed, 22 insertions(+), 21 deletions(-)
 
 diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
 index e55421a..35757ae 100644
 --- a/hw/i386/kvm/pci-assign.c
 +++ b/hw/i386/kvm/pci-assign.c
 @@ -51,14 +51,13 @@
  //#define DEVICE_ASSIGNMENT_DEBUG
  
  #ifdef DEVICE_ASSIGNMENT_DEBUG
 -#define DEBUG(fmt, ...)   \
 -do {  \
 -fprintf(stderr, %s:  fmt, __func__ , __VA_ARGS__);  \
 -} while (0)
 +#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 1
  #else
 -#define DEBUG(fmt, ...)
 +#define DEVICE_ASSIGNMENT_DEBUG_ENABLED 0
  #endif
  
 +#define DEBUG(fmt, ...) QEMU_DPRINTF(DEVICE_ASSIGNMENT_DEBUG_ENABLED, 
 pci_assign, fmt, ## __VA_ARGS__)

This is broken, QEMU_DPRINTF() is not defined yet. Looks like an
ordering issue with 16/16.

Regards,
Andreas

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



[Qemu-devel] [PATCH v2 00/16] Convert conditional compilation of debug printfs

2014-05-13 Thread Marc Marí
A macro has been added to qemu-common.h to simplify and standarize the debug
printfs. Some of those printfs have been changed too.

Marc Marí (16):
  x86: Convert conditional compilation of debug printfs to regular ifs
  s390: Convert conditional compilation of debug printfs to regular ifs
  scsi: Convert conditional compilation of debug printfs to regular ifs
  highbank: Convert conditional compilation of debug printfs to regular
ifs
  xilinx: Convert conditional compilation of debug printfs to regular
ifs
  spapr: Convert conditional compilation of debug printfs to regular
ifs
  stellaris: Convert conditional compilation of debug printfs to
regular ifs
  tpm: Convert conditional compilation of debug printfs to regular ifs
  i82374: Convert conditional compilation of debug printfs to regular
ifs
  i8257: Convert conditional compilation of debug printfs to regular
ifs
  rc4030: Convert conditional compilation of debug printfs to regular
ifs
  sd: Convert conditional compilation of debug printfs to regular ifs
  isa: Convert conditional compilation of debug printfs to regular ifs
  lan9118: Convert conditional compilation of debug printfs to regular
ifs
  pci-host: Convert conditional compilation of debug printfs to regular
ifs
  common: Convert conditional compilation of debug printfs to regular
ifs

 hw/dma/i82374.c|   11 +--
 hw/dma/i8257.c |   13 +++--
 hw/dma/rc4030.c|   11 +--
 hw/i386/kvm/pci-assign.c   |9 -
 hw/i386/multiboot.c|6 --
 hw/isa/vt82c686.c  |   10 ++
 hw/net/cadence_gem.c   |   11 ++-
 hw/net/lan9118.c   |   26 --
 hw/net/spapr_llan.c|6 --
 hw/net/stellaris_enet.c|   21 +++--
 hw/net/xgmac.c |   10 ++
 hw/pci-host/bonito.c   |   10 ++
 hw/pci-host/ppce500.c  |8 ++--
 hw/s390x/s390-virtio-bus.c |8 
 hw/s390x/s390-virtio.c |8 
 hw/scsi/lsi53c895a.c   |   17 -
 hw/scsi/scsi-generic.c |   12 +---
 hw/scsi/spapr_vscsi.c  |8 
 hw/sd/sd.c |7 ---
 hw/sd/ssi-sd.c |   14 +++---
 hw/tpm/tpm_passthrough.c   |8 
 hw/tpm/tpm_tis.c   |   10 +-
 include/qemu-common.h  |7 +++
 migration-rdma.c   |   32 ++--
 page_cache.c   |   10 ++
 target-i386/kvm.c  |8 
 target-s390x/helper.c  |   22 ++
 target-s390x/kvm.c |8 
 xen-hvm.c  |   12 ++--
 xen-mapcache.c |8 
 30 files changed, 190 insertions(+), 161 deletions(-)

-- 
1.7.10.4




[Qemu-devel] [PATCH v2 02/16] s390: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/s390x/s390-virtio-bus.c |8 
 hw/s390x/s390-virtio.c |8 
 target-s390x/helper.c  |   22 ++
 target-s390x/kvm.c |8 
 4 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 9c71afa..c3a6302 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -38,13 +38,13 @@
 /* #define DEBUG_S390 */
 
 #ifdef DEBUG_S390
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_S390_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_S390_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_S390_ENABLED, s390 virtio bus, 
fmt, ## __VA_ARGS__)
+
 #define VIRTIO_EXT_CODE   0x2603
 
 static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index aef2003..133c320 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -42,13 +42,13 @@
 //#define DEBUG_S390
 
 #ifdef DEBUG_S390
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_S390_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_S390_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_S390_ENABLED, s390 virtio, fmt, 
## __VA_ARGS__)
+
 #define MAX_BLK_DEVS10
 #define ZIPL_FILENAME   s390-zipl.rom
 
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 7c76fc1..c5bfa7e 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -30,19 +30,25 @@
 //#define DEBUG_S390_STDOUT
 
 #ifdef DEBUG_S390
-#ifdef DEBUG_S390_STDOUT
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); \
- qemu_log(fmt, ##__VA_ARGS__); } while (0)
+#define DEBUG_S390_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { qemu_log(fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_S390_ENABLED 0
 #endif
+
+#ifdef DEBUG_S390_STDOUT
+#define DEBUG_S390_STDOUT_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_S390_STDOUT_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) \
+do { \
+if(DEBUG_S390_ENABLED) { \
+qemu_log(fmt, ##__VA_ARGS__); \
+QEMU_DPRINTF(DEBUG_S390_STDOUT_ENABLED, s390x helper, fmt, ## 
__VA_ARGS__); \
+} \
+} while (0)
+
 #ifdef DEBUG_S390_PTE
 #define PTE_DPRINTF DPRINTF
 #else
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index b7b0edc..5aad3c9 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -41,13 +41,13 @@
 /* #define DEBUG_KVM */
 
 #ifdef DEBUG_KVM
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#define DEBUG_KVM_ENABLED 1
 #else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
+#define DEBUG_KVM_ENABLED 0
 #endif
 
+#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_KVM_ENABLED, s390 kvm, fmt, ## 
__VA_ARGS__)
+
 #define IPA0_DIAG   0x8300
 #define IPA0_SIGP   0xae00
 #define IPA0_B2 0xb200
-- 
1.7.10.4




Re: [Qemu-devel] [PATCH] usb: fix up post load checks

2014-05-13 Thread Gerd Hoffmann
  Hi,

 +(dev-setup_state == SETUP_STATE_DATA 

Fails to build, SETUP_STATE_DATA is not defined here.

I think we can simply drop that check, index should never ever be larger
than len, no matter what the state is.

cheers,
  Gerd





[Qemu-devel] [PATCH] xhci: add endpoint cap on express bus only

2014-05-13 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/usb/hcd-xhci.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 6753a42..a203bc6 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3594,8 +3594,10 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
  
PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64,
  xhci-mem);
 
-ret = pcie_endpoint_cap_init(dev, 0xa0);
-assert(ret = 0);
+if (pci_bus_is_express(dev-bus)) {
+ret = pcie_endpoint_cap_init(dev, 0xa0);
+assert(ret = 0);
+}
 
 if (xhci-flags  (1  XHCI_FLAG_USE_MSI)) {
 msi_init(dev, 0x70, xhci-numintrs, true, false);
-- 
1.8.3.1




[Qemu-devel] [PATCH v2 05/16] xilinx: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
Modify debug macros to have the same format through the codebase and use regular
ifs instead of ifdef.

As the debug printf is always put in code, some casting had to be added to avoid
warnings treated as errors at compile time.

Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
---
 hw/net/cadence_gem.c |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index cdb1825..aa93372 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -28,15 +28,16 @@
 #include net/net.h
 #include net/checksum.h
 
+//#define CADENCE_GEM_ERR_DEBUG
+
 #ifdef CADENCE_GEM_ERR_DEBUG
-#define DB_PRINT(...) do { \
-fprintf(stderr,  : %s: , __func__); \
-fprintf(stderr, ## __VA_ARGS__); \
-} while (0);
+#define CADENCE_GEM_ERR_DEBUG_ENABLED 1
 #else
-#define DB_PRINT(...)
+#define CADENCE_GEM_ERR_DEBUG_ENABLED 0
 #endif
 
+#define DB_PRINT(...) QEMU_DPRINTF(CADENCE_GEM_ERR_DEBUG_ENABLED, 
cadence_gem, __VA_ARGS__)
+
 #define GEM_NWCTRL(0x/4) /* Network Control reg */
 #define GEM_NWCFG (0x0004/4) /* Network Config reg */
 #define GEM_NWSTATUS  (0x0008/4) /* Network Status reg */
-- 
1.7.10.4




Re: [Qemu-devel] [PATCH v2 0/3] Adding new user mode target ppc64le-linux-user

2014-05-13 Thread Alexander Graf


On 10.05.14 11:16, Doug Kwan wrote:

Hi

I have made changes based on comments to the previous set of pathces.

1. Target name is now ppc64le-linux-user.
2. I used a memop mask to avoid generating redundant byteswap pairs that
cancel out each other.  This is suggested by Peter Maydell.
3. There is code to handle machine name correctly in uname.

This is not mean to be final though.  Tom Musta of IBM kindly offered to help
me with this.  So I am handling over this set of patches.  Tom will continue
from this version.

Thanks for all the comments and suggestions so far.


I like the patch set for the most part. I guess in v3 it will be ready 
for inclusion :).



Alex




Re: [Qemu-devel] Qemu live migration code

2014-05-13 Thread Dr. David Alan Gilbert
* Bechir Bani (bechir.b...@gmail.com) wrote:
  Hi ,
 
 There is someone who can explain to me the role of two trace points in the
 file* Migration.c *
 
 The trace points are :
 
  *  migrate_pending* : what are the attributes *pending size *and *max* ?

'pending_size' is an estimate of the amount of data left to be transferred
in the iterative part.
'max_size' is an estimate of the amount of data that can be transferred in the
'max_downtime' period
Thus if pending_size  max_size it can stop iterating and transfer the last
part.

  *  migrate_transferred*: what are the attributes *transferred* ,*
 time_spent* , *bandwidth* and *max_size* ?

Every so often it recalculates bandwidths etc:
   transferred_bytes - actual bytes transferred during migration since the last
  time it did that set of calculations
   time_spent - time since it last did that set of calculations
   bandwidth - transferred_bytes  / time_spent
   max_size = as in the previous trace point.

Dave
   
 
 
 Thank you !
 
 
 2014-03-25 6:03 GMT-04:00 Sanidhya Kashyap sanidhya.ii...@gmail.com:
 
 
 
 
  On Tue, Mar 25, 2014 at 2:10 AM, Bechir Bani bechir.b...@gmail.comwrote:
 
  Hi Sanidhya,
 
 
  Which function in savevm.c can tell me about the stop time ?
 
 
  the migration thread function in migration.c file which has function name
  - qemu_savevm_state_complete will get executed in the stop and copy phase.
 
 
 
  2014-03-24 13:46 GMT-04:00 Sanidhya Kashyap sanidhya.ii...@gmail.com:
 
  savevm.c will tell you about the stop time.
 
  arch_init.c (ram_save_block) will tell about the number of pages
  transferred.
 
 
  On Mon, Mar 24, 2014 at 10:51 PM, Bechir Bani 
  bechir.b...@gmail.comwrote:
 
  I have a task to add trace points in the source code of Qemu. The goal
  is to know the number of pages transferred at each iteration and stop 
  time
  of the machine as well.
 
 
  2014-03-24 12:50 GMT-04:00 Dr. David Alan Gilbert dgilb...@redhat.com
  :
 
  * Bechir Bani (bechir.b...@gmail.com) wrote:
   Hi,
  
   I want to know the source code of qemu which is responsible for the
   migration of virtual machines, more precisely where the part of the
  code
   that describes the stages of memory transfer. is that you can help
  me?
 
  It's split around a few files; memory is mostly in arch_init.c;
  It's something like:
 
 migration.c   Overall management
savevm.c
  qemu-file.cFile buffering/bytes on the wire
  vmstate.c  Structured saving of individual devices
  arch_init.cRAM special code, and a few other things
 
  What are you trying to do/change?
 
  Dave
 
  --
  Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
 
 
 
 
  --
  *Béchir Bani *
  
  *Ecole Polytechnique de Montréal *
  
  *Laboratoire DORSAL*
  *
  *Montréal - Canada*
 
 
 
 
 
  --
  *Béchir Bani *
  
  *Ecole Polytechnique de Montréal *
  
  *Laboratoire DORSAL*
  *
  *Montréal - Canada*
 
 
 
 
 
 -- 
 *Béchir Bani *
 
 *Ecole Polytechnique de Montréal *
 
 *Laboratoire DORSAL*
 *
 *Montréal - Canada*
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



Re: [Qemu-devel] [PATCH 4/4] Support more than 255 cpus: runtime check

2014-05-13 Thread Max Filippov
On Tue, May 13, 2014 at 11:09 AM, Li, Zhen-Hua zhen-h...@hp.com wrote:
 From: Li, ZhenHua zhen-h...@hp.com

 There is some runtime check for max cpu count. Make them support 4096 cpus.

 Signed-off-by: Li, ZhenHua zhen-h...@hp.com
 ---
  hw/i386/acpi-build.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
 index c98df88..5c3bf10 100644
 --- a/hw/i386/acpi-build.c
 +++ b/hw/i386/acpi-build.c

[...]

 @@ -680,7 +680,7 @@ build_append_notify_method(GArray *device, const char 
 *name,
  for (i = 0; i  count; i++) {
  GArray *target = build_alloc_array();
  build_append_nameseg(target, format, i);
 -assert(i  256); /* Fits in 1 byte */
 +assert(i  4096); /* Fits in 1 byte */

The comment is no longer true.
Also the function build_append_notify_method is called with format argument
set to CP%0.02X, looks like this should be changed to CP%0.03X.

-- 
Thanks.
-- Max



Re: [Qemu-devel] segfault while booting from saved snapshot

2014-05-13 Thread Shehbaz Jaffer
Hi,

Could anyone please give me the command to do live-migration to to a
file? I have tried searching on QEMU Wiki but all the articles that I
have come across point to snapshotting the disk, and not the entire VM
to a file.

Appreciate your help.

Thanks,
Shehbaz

On Sat, Apr 19, 2014 at 11:07 PM, Shehbaz Jaffer
shehbazjaffer...@gmail.com wrote:
 Thankyou for your reply. Live migration does seem like an interesting option
 to explore. I will look into it and get back if I get stuck.


 On Wed, Apr 16, 2014 at 6:16 PM, Kevin Wolf kw...@redhat.com wrote:

 Am 15.04.2014 um 16:55 hat Shehbaz Jaffer geschrieben:
  Thankyou for your reply. I do not face the error using qemu.1.7.1
  version.
 
  1 quick question:
 
  I want to create a qcow2 image file after my VM has completed booting;
  i.e.,
  when I boot from this new snapshot, I should directly get to my VMs
  login
  prompt. How can i create such a qcow2 snapshot?
 
  I tried stopped the VM using QMP after the VM had completed booting, and
  then
  using host CLI to create a qcow2 image :
 
  qemu-img create -b ubuntu.qcow2 -f qcow2 newsnap.qcow2
 
  This created a new qcow2 file - newsnap.qcow2 on top of ubuntu.qcow2,
  however
  when I boot using newsnap.qcow2, It takes me again through the complete
  boot
  process - till the login prompt.
 
  Is there a way to create the qcow2 snapshot after VM has completed
  booting?

 The reason for this is that you only create a snapshot of the disk this
 way, not of the VM state (i.e. RAM contents, device states, etc.)

 The most convenient way when you're using qemu directly is probably
 using internal snapshots. This is what the savevm/loadvm HMP commands
 provide (not sure if there is a QMP equivalent); you can also use the
 -loadvm command line parameter to start a VM from a snapshot.

 Another option is that you take an external snapshot in a new qcow2 file
 like you did, but you additionally do a live migration into a file. When
 restarting the VM, you need to use the -incoming option and feed that
 file back to qemu. As this is a bit more cumbersome, this is probably
 more an option for management tools than for manual use.

 Kevin




 --
 Shehbaz Jaffer
 MTS | Advanced Technology Group |  NetApp



-- 
Shehbaz Jaffer
MTS | Advanced Technology Group |  NetApp



Re: [Qemu-devel] [RFC] vhost: Can we change synchronize_rcu to call_rcu in vhost_set_memory() in vhost kernel module?

2014-05-13 Thread Michael S. Tsirkin
On Tue, May 13, 2014 at 07:03:20AM +, Gonglei (Arei) wrote:
 Hi,
 
  -Original Message-
  From: Michael S. Tsirkin [mailto:m...@redhat.com]
  Sent: Monday, May 12, 2014 6:31 PM
  
  vhost does everything under a VQ lock.
  I think RCU for VHOST_SET_MEM_TABLE can be replaced with
  taking and freeing the VQ lock.
  
  Does the below solve the problem for you
  (warning: untested, sorry, busy with other bugs right now)?
  
  
  Signed-off-by: Michael S. Tsirkin m...@redhat.com
  
  ---
  
  diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
  index 78987e4..df2e3eb 100644
  --- a/drivers/vhost/vhost.c
  +++ b/drivers/vhost/vhost.c
  @@ -593,6 +593,7 @@ static long vhost_set_memory(struct vhost_dev *d,
  struct vhost_memory __user *m)
   {
  struct vhost_memory mem, *newmem, *oldmem;
  unsigned long size = offsetof(struct vhost_memory, regions);
  +   int i;
  
  if (copy_from_user(mem, m, size))
  return -EFAULT;
  @@ -619,7 +620,14 @@ static long vhost_set_memory(struct vhost_dev *d,
  struct vhost_memory __user *m)
  oldmem = rcu_dereference_protected(d-memory,
 lockdep_is_held(d-mutex));
  rcu_assign_pointer(d-memory, newmem);
  -   synchronize_rcu();
  +
  +   /* All memory accesses are done under some VQ mutex.
  +* So below is a faster equivalent of synchronize_rcu()
  +*/
  +   for (i = 0; i  dev-nvqs; ++i) {
  +   mutex_lock(d-vqs[idx]-mutex);
  +   mutex_unlock(d-vqs[idx]-mutex);
  +   }
  kfree(oldmem);
  return 0;
   }
 
 Thanks for your advice, I suppose getting mutexes should generally be faster 
 than waiting for 
 CPU context switches. And I think d-mutex should also be synchronized since 
 somewhere gets 
 only this mutex directly and not vq mutexes. Is this right?

No because all memory table accesses are under some vq mutex.

 I'll try this approach, thanks.
 
 Best regards,
 -Gonglei



Re: [Qemu-devel] [PATCH] usb: fix up post load checks

2014-05-13 Thread Michael S. Tsirkin
On Tue, May 13, 2014 at 09:50:09AM +0200, Gerd Hoffmann wrote:
   Hi,
 
  +(dev-setup_state == SETUP_STATE_DATA 
 
 Fails to build, SETUP_STATE_DATA is not defined here.
 
 I think we can simply drop that check, index should never ever be larger
 than len, no matter what the state is.
 
 cheers,
   Gerd

I'm confused by usb_generic_async_ctrl_complete which can modify len
without touching index.
If index is stale it could get  len?
Could you hop on irc so we can discuss?

-- 
MST



Re: [Qemu-devel] segfault while booting from saved snapshot

2014-05-13 Thread Kevin Wolf
Am 13.05.2014 um 10:20 hat Shehbaz Jaffer geschrieben:
 Hi,
 
 Could anyone please give me the command to do live-migration to to a
 file? I have tried searching on QEMU Wiki but all the articles that I
 have come across point to snapshotting the disk, and not the entire VM
 to a file.

In the HMP monitor: migrate exec:cat  /tmp/vmstate

Kevin

 Appreciate your help.
 
 Thanks,
 Shehbaz
 
 On Sat, Apr 19, 2014 at 11:07 PM, Shehbaz Jaffer
 shehbazjaffer...@gmail.com wrote:
  Thankyou for your reply. Live migration does seem like an interesting option
  to explore. I will look into it and get back if I get stuck.
 
 
  On Wed, Apr 16, 2014 at 6:16 PM, Kevin Wolf kw...@redhat.com wrote:
 
  Am 15.04.2014 um 16:55 hat Shehbaz Jaffer geschrieben:
   Thankyou for your reply. I do not face the error using qemu.1.7.1
   version.
  
   1 quick question:
  
   I want to create a qcow2 image file after my VM has completed booting;
   i.e.,
   when I boot from this new snapshot, I should directly get to my VMs
   login
   prompt. How can i create such a qcow2 snapshot?
  
   I tried stopped the VM using QMP after the VM had completed booting, and
   then
   using host CLI to create a qcow2 image :
  
   qemu-img create -b ubuntu.qcow2 -f qcow2 newsnap.qcow2
  
   This created a new qcow2 file - newsnap.qcow2 on top of ubuntu.qcow2,
   however
   when I boot using newsnap.qcow2, It takes me again through the complete
   boot
   process - till the login prompt.
  
   Is there a way to create the qcow2 snapshot after VM has completed
   booting?
 
  The reason for this is that you only create a snapshot of the disk this
  way, not of the VM state (i.e. RAM contents, device states, etc.)
 
  The most convenient way when you're using qemu directly is probably
  using internal snapshots. This is what the savevm/loadvm HMP commands
  provide (not sure if there is a QMP equivalent); you can also use the
  -loadvm command line parameter to start a VM from a snapshot.
 
  Another option is that you take an external snapshot in a new qcow2 file
  like you did, but you additionally do a live migration into a file. When
  restarting the VM, you need to use the -incoming option and feed that
  file back to qemu. As this is a bit more cumbersome, this is probably
  more an option for management tools than for manual use.
 
  Kevin
 
 
 
 
  --
  Shehbaz Jaffer
  MTS | Advanced Technology Group |  NetApp
 
 
 
 -- 
 Shehbaz Jaffer
 MTS | Advanced Technology Group |  NetApp



Re: [Qemu-devel] [PATCH 4/5] qcow1: Validate image size (CVE-2014-0223)

2014-05-13 Thread Kevin Wolf
Am 12.05.2014 um 19:04 hat Benoît Canet geschrieben:
 The Monday 12 May 2014 à 18:43:33 (+0200), Kevin Wolf wrote :
  Am 12.05.2014 um 17:50 hat Benoît Canet geschrieben:
   The Monday 12 May 2014 à 15:04:10 (+0200), Kevin Wolf wrote :
A huge image size could cause s-l1_size to overflow. Make sure that
images never require a L1 table larger than what fits in s-l1_size.

This cannot only cause unbounded allocations, but also the allocation of
a too small L1 table, resulting in out-of-bounds array accesses (both
reads and writes).

Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block/qcow.c   | 16 ++--
 tests/qemu-iotests/092 |  9 +
 tests/qemu-iotests/092.out |  7 +++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index e8038e5..3566c05 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -61,7 +61,7 @@ typedef struct BDRVQcowState {
 int cluster_sectors;
 int l2_bits;
 int l2_size;
-int l1_size;
+unsigned int l1_size;
 uint64_t cluster_offset_mask;
 uint64_t l1_table_offset;
 uint64_t *l1_table;
@@ -166,7 +166,19 @@ static int qcow_open(BlockDriverState *bs, QDict 
*options, int flags,
 
 /* read the level 1 table */
 shift = s-cluster_bits + s-l2_bits;
-s-l1_size = (header.size + (1LL  shift) - 1)  shift;
+if (header.size  UINT64_MAX - (1LL  shift)) {
   
   I won't be much helpfull but this feel wrong.
   Does each l1 entry point to an l2 chunk mapping itself to 1  
   (s-cluster_bits + s-l2_bits) bytes ?
   Where the size for the L2 chunk themselves is accounted ?
  
  Not sure what your concern is, but this is basically the same system as
  with qcow2: L1 entries point to the offsets of L2 tables. L2 tables map
  virtual disk clusters to image file clusters. They don't map metadata
  like themselves.
  
  One cluster contains (1  cluster_bits) bytes. One L2 table contains
  mappings for (1  l2_bits) clusters. Therefore, (1  (cluster_bits +
  l2_bits)) is the number of bytes on the virtual disk that are described
  by a single L2 table.
 
 I am under the impression that this test compute the maximum size left for
 the header.

No, it doesn't. It only ensures that (header.size + (1LL  shift) - 1)
doesn't overflow, which is part of rounding up the image size.

Kevin

 So as there is probably more that one L2 table the space left for the header
 is 1 - nb_l2_table * number_of_byte_covered_by_l2 - number of byte of l1 - 
 number of 
 bytes of l2 themselve.
 
  
  All of this is not related to this patch. All I'm doing here is catching
  integer overflows in the calculation of s-l1_size. Apart from error
  cases, the calculation is unchanged.
  
  Kevin
  
+error_setg(errp, Image too large);
+ret = -EINVAL;
+goto fail;
+} else {
+uint64_t l1_size = (header.size + (1LL  shift) - 1)  shift;
+if (l1_size  INT_MAX / sizeof(uint64_t)) {
+error_setg(errp, Image too large);
+ret = -EINVAL;
+goto fail;
+}
+s-l1_size = l1_size;
+}
 
 s-l1_table_offset = header.l1_table_offset;
 s-l1_table = g_malloc(s-l1_size * sizeof(uint64_t));
  



Re: [Qemu-devel] [PATCH] usb: fix up post load checks

2014-05-13 Thread Gerd Hoffmann
On Di, 2014-05-13 at 11:32 +0300, Michael S. Tsirkin wrote:
 On Tue, May 13, 2014 at 09:50:09AM +0200, Gerd Hoffmann wrote:
Hi,
  
   +(dev-setup_state == SETUP_STATE_DATA 
  
  Fails to build, SETUP_STATE_DATA is not defined here.
  
  I think we can simply drop that check, index should never ever be larger
  than len, no matter what the state is.
  
  cheers,
Gerd
 
 I'm confused by usb_generic_async_ctrl_complete which can modify len
 without touching index.

only in setup state, before any data from/to the buffer is transfered,
so index is still zero at that point.

flow is this:

state_setup: len = $buflen, index = 0
state_data:  xfer %buf data, increase index up to len while doing so.
state_ack:   index == len
state_idle:  likewise.

cheers,
  Gerd





[Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039

2014-05-13 Thread Markus Armbruster
The shell script attempts to suppress core dumps like this:

old_ulimit=$(ulimit -c)
ulimit -c 0
$QEMU_IO arg...
ulimit -c $old_ulimit

This breaks the test hard unless the limit was zero to begin with!
ulimit sets both hard and soft limit by default, and (re-)raising the
hard limit requires privileges.  Broken since it was added in commit
dc68afe.

Could be fixed by adding -S to set only the soft limit, but I'm not
sure how portable that is in practice.  Simply do it in a subshell
instead, like this:

(ulimit -c 0; exec $QEMU_IO arg...)

Signed-off-by: Markus Armbruster arm...@redhat.com
---
 tests/qemu-iotests/039 | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
index b9cbe99..182b0f0 100755
--- a/tests/qemu-iotests/039
+++ b/tests/qemu-iotests/039
@@ -67,10 +67,8 @@ echo == Creating a dirty image file ==
 IMGOPTS=compat=1.1,lazy_refcounts=on
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG | _filter_qemu_io
-ulimit -c $old_ulimit
+(ulimit -c 0 # do not produce a core dump on abort(3)
+exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
_filter_qemu_io
 
 # The dirty bit must be set
 ./qcow2.py $TEST_IMG dump-header | grep incompatible_features
@@ -103,10 +101,8 @@ echo == Opening a dirty image read/write should repair it 
==
 IMGOPTS=compat=1.1,lazy_refcounts=on
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG | _filter_qemu_io
-ulimit -c $old_ulimit
+(ulimit -c 0 # do not produce a core dump on abort(3)
+exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
_filter_qemu_io
 
 # The dirty bit must be set
 ./qcow2.py $TEST_IMG dump-header | grep incompatible_features
@@ -122,10 +118,8 @@ echo == Creating an image file with lazy_refcounts=off ==
 IMGOPTS=compat=1.1,lazy_refcounts=off
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG | _filter_qemu_io
-ulimit -c $old_ulimit
+(ulimit -c 0 # do not produce a core dump on abort(3)
+exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
_filter_qemu_io
 
 # The dirty bit must not be set since lazy_refcounts=off
 ./qcow2.py $TEST_IMG dump-header | grep incompatible_features
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH] Add backing file option to qemu-img create help.

2014-05-13 Thread Kevin Wolf
Am 12.05.2014 um 19:02 hat Eric Blake geschrieben:
 On 05/12/2014 10:36 AM, Kevin Wolf wrote:
 
  rebase [-q] [-f fmt] [-t cache] [-p] [-u] -b backing_file [-F
  backing_fmt] filename
 
  'rebase' lacks -o; so it must continue to document -b.  This thread was
  started in context to the 'create' subcommand, not the 'rebase'
  subcommand.  (Arguably, we may need to add -o to rebase someday, but
  that's not for this patch)
  
  What would qemu-img rebase do with -o? It is just for (safely) changing
  the backing file, not for updating options. There is qemu-img amend for
  that, and it does have an -o option.
 
 It's a consistency argument.  Why can't we have:
 
 rebase -o backing_file=file,backing_fmt=fmt
 
 similar to create, instead of having to treat rebase as the oddball
 command that still takes separate options for two highly related items?

But that's inconsistent with other -o options if you can't say:

rebase -o lazy_refcounts=on

rebase will always be the oddball because a backing file is not just an
option for it, but it is the whole purpose of the command. Perhaps we
shouldn't have used -b, but just a second non-option argument. But I
don't think changing this now is worth it.

Kevin


pgpcXpLZy0G8s.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH] virtio: allow mapping up to max queue size

2014-05-13 Thread Dr. David Alan Gilbert
* Michael S. Tsirkin (m...@redhat.com) wrote:
 It's a loop from i  num_sg  and the array is VIRTQUEUE_MAX_SIZE - so
 it's OK if the value read is VIRTQUEUE_MAX_SIZE.
 
 Not a big problem in practice as people don't use
 such big queues, but it's inelegant.
 
 Reported-by: Dr. David Alan Gilbert dgilb...@redhat.com
 Cc: qemu-sta...@nongnu.org
 Signed-off-by: Michael S. Tsirkin m...@redhat.com

Reviewed-by: Dr. David Alan Gilbert dgilb...@redhat.com

 ---
  hw/virtio/virtio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
 index 7f4e7ec..3557c17 100644
 --- a/hw/virtio/virtio.c
 +++ b/hw/virtio/virtio.c
 @@ -430,7 +430,7 @@ void virtqueue_map_sg(struct iovec *sg, hwaddr *addr,
  unsigned int i;
  hwaddr len;
  
 -if (num_sg = VIRTQUEUE_MAX_SIZE) {
 +if (num_sg  VIRTQUEUE_MAX_SIZE) {
  error_report(virtio: map attempt out of bounds: %zd  %d,
   num_sg, VIRTQUEUE_MAX_SIZE);
  exit(1);
 -- 
 MST
 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



[Qemu-devel] usb: usb tablet freeze when save/restore guest os

2014-05-13 Thread Gonglei (Arei)
Hi,

For recent Linux guests, the usb tablet will be suspended when it is idle.
When Qemu detect the usb tablet event, will call uhci_wakeup(), which
according the value of port-ctrl to decide to call uhci_resume() or not. 
UHCI_PORT_RD bit is set to 1 for UHCI is resuming, and qemu will not call
uhci_resume(). The other way round, qemu will call uhci_resume() and then
post a interrupt to guest os, meanwhile set UHCI_PORT_RD bit to 1.

In the guests, after handle the interrupt, will call uhci_finish_suspend(), 
which
clear UHCI_PORT_RD bit, Then qemu will know that the UHCI resume
process has finished.

In the situation of save/restore guest os, when the guest os is saving 
memory iteratively, meanwhile the usb tablet work normally (by vnc). When qemu
has set the UHCI_PORT_RD bit to 1, and post a interrupt to guest os, but
guest os has hibernated this moment, so the interrupt cannot be handled
in time. So, the UHCI_PORT_RD bit will not be cleared by uhci_finish_suspend().

When we restore the guest os, and the usb tablet event happen again, but 
because of UHCI_PORT_RD bit being set to 1, qemu consider the guest os is
handling the interrupt of resuming UHCI, so will not post another interrupt.
For guest os, will not handle UHCI event because it not receive an interrupt,
which cause usb tablet freeze.  

So, we should provide a mechanism for avoiding losing interrupt of UHCI.
IMHO the LEGACY SUPPORT REGISTER will give us some help, and I have
finished a patch and tested it work well.

Anything idea? Thanks!


Best regards,
-Gonglei





Re: [Qemu-devel] [PATCH v2 02/16] s390: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Cornelia Huck
On Tue, 13 May 2014 09:02:38 +0200
Marc Marí marc.mari.barc...@gmail.com wrote:

I'd replace the subject with

s390: convert debug printfs to QEMU_DPRINTF

which is more descriptive and has the additional virtue of being
shorter ;)

 Modify debug macros to have the same format through the codebase and use 
 regular
 ifs instead of ifdef.
 
 As the debug printf is always put in code, some casting had to be added to 
 avoid
 warnings treated as errors at compile time.
 
 Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
 ---
  hw/s390x/s390-virtio-bus.c |8 
  hw/s390x/s390-virtio.c |8 
  target-s390x/helper.c  |   22 ++
  target-s390x/kvm.c |8 
  4 files changed, 26 insertions(+), 20 deletions(-)
 
 diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
 index 9c71afa..c3a6302 100644
 --- a/hw/s390x/s390-virtio-bus.c
 +++ b/hw/s390x/s390-virtio-bus.c
 @@ -38,13 +38,13 @@
  /* #define DEBUG_S390 */
 
  #ifdef DEBUG_S390
 -#define DPRINTF(fmt, ...) \
 -do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
 +#define DEBUG_S390_ENABLED 1
  #else
 -#define DPRINTF(fmt, ...) \
 -do { } while (0)
 +#define DEBUG_S390_ENABLED 0
  #endif
 
 +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_S390_ENABLED, s390 virtio 
 bus, fmt, ## __VA_ARGS__)

I think this line is a bit too long.

 +
  #define VIRTIO_EXT_CODE   0x2603
 
  static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
 diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
 index aef2003..133c320 100644
 --- a/hw/s390x/s390-virtio.c
 +++ b/hw/s390x/s390-virtio.c
 @@ -42,13 +42,13 @@
  //#define DEBUG_S390
 
  #ifdef DEBUG_S390
 -#define DPRINTF(fmt, ...) \
 -do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
 +#define DEBUG_S390_ENABLED 1
  #else
 -#define DPRINTF(fmt, ...) \
 -do { } while (0)
 +#define DEBUG_S390_ENABLED 0
  #endif
 
 +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_S390_ENABLED, s390 virtio, 
 fmt, ## __VA_ARGS__)

dito

 +
  #define MAX_BLK_DEVS10
  #define ZIPL_FILENAME   s390-zipl.rom
 

 diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
 index b7b0edc..5aad3c9 100644
 --- a/target-s390x/kvm.c
 +++ b/target-s390x/kvm.c
 @@ -41,13 +41,13 @@
  /* #define DEBUG_KVM */
 
  #ifdef DEBUG_KVM
 -#define DPRINTF(fmt, ...) \
 -do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
 +#define DEBUG_KVM_ENABLED 1
  #else
 -#define DPRINTF(fmt, ...) \
 -do { } while (0)
 +#define DEBUG_KVM_ENABLED 0
  #endif
 
 +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_KVM_ENABLED, s390 kvm, fmt, 
 ## __VA_ARGS__)

dito :)

 +
  #define IPA0_DIAG   0x8300
  #define IPA0_SIGP   0xae00
  #define IPA0_B2 0xb200




Re: [Qemu-devel] [PATCH v2 16/16] common: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Cornelia Huck
On Tue, 13 May 2014 09:02:52 +0200
Marc Marí marc.mari.barc...@gmail.com wrote:

 Modify debug macros to have the same format through the codebase and use 
 regular
 ifs instead of ifdef.
 
 As the debug printf is always put in code, some casting had to be added to 
 avoid
 warnings treated as errors at compile time.
 
 Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
 ---
  include/qemu-common.h |7 +++
  migration-rdma.c  |   32 ++--
  page_cache.c  |   10 ++
  3 files changed, 27 insertions(+), 22 deletions(-)
 
 diff --git a/include/qemu-common.h b/include/qemu-common.h
 index 3f3fd60..3593bdc 100644
 --- a/include/qemu-common.h
 +++ b/include/qemu-common.h
 @@ -463,3 +463,10 @@ int parse_debug_env(const char *name, int max, int 
 initial);
  const char *qemu_ether_ntoa(const MACAddr *mac);
 
  #endif
 +
 +#define QEMU_DPRINTF(cond,pfx,fmt,...) \
 +  do { \
 +if (cond) { \
 +  fprintf(stderr, pfx: %s:fmt, __func__, ## __VA_ARGS__); \
 +} \
 +  } while (0)

I'd split that hunk into a seperate patch and make it the first one in
the series. That way, you'd preserve bisectability.




Re: [Qemu-devel] [RFC PATCH 09/11] target-arm: move arm_*_code to a separate file

2014-05-13 Thread Peter Maydell
On 13 May 2014 08:03, Andreas Färber afaer...@suse.de wrote:
 I notice that these user-only functions/macros are taking CPUARMState
 but never use it today. Should I convert them to CPUState once I tackle
 linux-user, or can we just drop that unused argument?

I think they mostly take that argument for consistency with
cpu_ldl_code; we can drop it, I guess.

thanks
-- PMM



Re: [Qemu-devel] [PATCH] usb: fix up post load checks

2014-05-13 Thread Michael S. Tsirkin
On Tue, May 13, 2014 at 10:44:45AM +0200, Gerd Hoffmann wrote:
 On Di, 2014-05-13 at 11:32 +0300, Michael S. Tsirkin wrote:
  On Tue, May 13, 2014 at 09:50:09AM +0200, Gerd Hoffmann wrote:
 Hi,
   
+(dev-setup_state == SETUP_STATE_DATA 
   
   Fails to build, SETUP_STATE_DATA is not defined here.
   
   I think we can simply drop that check, index should never ever be larger
   than len, no matter what the state is.
   
   cheers,
 Gerd
  
  I'm confused by usb_generic_async_ctrl_complete which can modify len
  without touching index.
 
 only in setup state, before any data from/to the buffer is transfered,
 so index is still zero at that point.


And SETUP_STATE_PARAM?

 flow is this:
 
 state_setup: len = $buflen, index = 0
 state_data:  xfer %buf data, increase index up to len while doing so.
 state_ack:   index == len
 state_idle:  likewise.
 
 cheers,
   Gerd
 



Re: [Qemu-devel] [PATCH] virtio-blk: Allow config-wce in dataplane

2014-05-13 Thread Paolo Bonzini

Il 13/05/2014 09:13, Fam Zheng ha scritto:

On Tue, 05/13 09:07, Paolo Bonzini wrote:

Il 13/05/2014 04:24, Fam Zheng ha scritto:

Dataplane now uses block layer. Protect bdrv_set_enable_write_cache with
aio_context_acquire and aio_context_release, so we can enable config-wce
to allow guest to modify the write cache online.

Signed-off-by: Fam Zheng f...@redhat.com

---
This applies on top of Stefan's dataplane: use QEMU block layer
series.

Signed-off-by: Fam Zheng f...@redhat.com
---
hw/block/dataplane/virtio-blk.c | 6 --
hw/block/virtio-blk.c   | 9 -
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 79fb612..46a6824 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -332,12 +332,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, 
VirtIOBlkConf *blk,
return;
}

-if (blk-config_wce) {
-error_setg(errp, device is incompatible with x-data-plane, 
- use config-wce=off);
-return;
-}
-
/* If dataplane is (re-)enabled while the guest is running there could be
 * block jobs that can conflict.
 */
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 8a568e5..a031e56 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -26,6 +26,7 @@
# include scsi/sg.h
#endif
#include hw/virtio/virtio-bus.h
+#include block/block_int.h


You shouldn't need to include this header file.  Apart from this, the patch
looks good.


It's for bdrv_get_aio_context, otherwise it doesn't compile.


I think it should be moved to block/block.h then.  Stefan?

Paolo




Re: [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure.

2014-05-13 Thread Paolo Bonzini

Il 13/05/2014 01:35, Hani Benhabiles ha scritto:

Otherwise, the nbd client may hang waiting for the server response.

Signed-off-by: Hani Benhabiles h...@linux.com
---

Quick method to trigger such behaviour:

(qemu) nbd_server_start localhost:10809
(qemu) nbd_server_add sd0
$ nbd-client localhost 10809 -name  /dev/nbd0
Negotiation: ..

(Client will hang indefinitely.)

 blockdev-nbd.c | 4 ++--
 qemu-nbd.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 922cf56..b60b66d 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -27,8 +27,8 @@ static void nbd_accept(void *opaque)
 socklen_t addr_len = sizeof(addr);

 int fd = accept(server_fd, (struct sockaddr *)addr, addr_len);
-if (fd = 0) {
-nbd_client_new(NULL, fd, nbd_client_put);
+if (fd = 0  !nbd_client_new(NULL, fd, nbd_client_put)) {
+close(fd);
 }
 }

diff --git a/qemu-nbd.c b/qemu-nbd.c
index eed79fa..f70e4b0 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -369,8 +369,10 @@ static void nbd_accept(void *opaque)
 return;
 }

-if (fd = 0  nbd_client_new(exp, fd, nbd_client_closed)) {
+if (nbd_client_new(exp, fd, nbd_client_closed)) {
 nb_fds++;
+} else {
+close(fd);
 }
 }




Acked-by: Paolo Bonzini pbonz...@redhat.com

Michael, can you queue this yourself?

Paolo



Re: [Qemu-devel] [PATCH 02/10] tcg: Invert the inclusion of helper.h

2014-05-13 Thread Alex Bennée

Richard Henderson r...@twiddle.net writes:

 Rather than include helper.h with N values of GEN_HELPER, include a
 secondary file that sets up the macros to include helper.h.  This
 minimizes the files that must be rebuilt when changing the macros
 for file N.

 Signed-off-by: Richard Henderson r...@twiddle.net
 ---
  include/exec/helper-gen.h|  92 +
  include/exec/{def-helper.h = helper-head.h} | 144 
 +--
  include/exec/helper-proto.h  |  38 +++
  include/exec/helper-tcg.h|  35 +++

I still find the macro gymnastics of the helper generators a pain
because hitting find on gen_helper_foo doesn't lead you anywhere
useful but I guess that's the price you pay for using macros.

Reviewed-by: Alex Bennée alex.ben...@linaro.org

-- 
Alex Bennée




Re: [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes.

2014-05-13 Thread Paolo Bonzini

Il 13/05/2014 01:35, Hani Benhabiles ha scritto:

Signed-off-by: Hani Benhabiles h...@linux.com
---
 nbd.c | 2 +-
 qemu-nbd.c| 2 +-
 qemu-nbd.texi | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/nbd.c b/nbd.c
index e5084b6..e0d032c 100644
--- a/nbd.c
+++ b/nbd.c
@@ -306,7 +306,7 @@ static int nbd_send_negotiate(NBDClient *client)
 [ 8 ..  15]   magic(NBD_CLIENT_MAGIC)
 [16 ..  23]   size
 [24 ..  25]   server flags (0)
-[24 ..  27]   export flags
+[26 ..  27]   export flags
 [28 .. 151]   reserved (0)

Negotiation header with options, part 1:
diff --git a/qemu-nbd.c b/qemu-nbd.c
index f70e4b0..cd6bd50 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -294,7 +294,7 @@ static void *nbd_client_thread(void *arg)
 fd = open(device, O_RDWR);
 if (fd  0) {
 /* Linux-only, we can use %m in printf.  */
-fprintf(stderr, Failed to open %s: %m, device);
+fprintf(stderr, Failed to open %s: %m\n, device);
 goto out_socket;
 }

diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index 0a7e013..46fd483 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -15,7 +15,7 @@ Export QEMU disk image using NBD protocol.
 @item @var{filename}
  is a disk image filename
 @item -p, --port=@var{port}
-  port to listen on (default @samp{1024})
+  port to listen on (default @samp{10809})
 @item -o, --offset=@var{offset}
   offset into the image
 @item -b, --bind=@var{iface}




Acked-by: Paolo Bonzini pbonz...@redhat.com




Re: [Qemu-devel] [PATCH 0/4] Support more than 255 cpus

2014-05-13 Thread Andreas Färber
Am 13.05.2014 09:09, schrieb Li, Zhen-Hua:
 From: Li, ZhenHua zhen-h...@hp.com
 
 These series patches are trying to make Qemu support more than 255 CPUs. 
 The max cpu number changed to 4096.

This series is not trivial.
And it's not a bug fix either, so not stable material.

CC'ing Igor and Eduardo for review.

Regards,
Andreas

  Support more than 255 cpus: ACPI and APIC defines
  Support more than 255 cpus: max_cpus to 4096
  Support more than 255 cpus: max cpumask bit to 4096
  Support more than 255 cpus: runtime chec
 
  include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
  include/hw/i386/apic_internal.h| 2 +-
  include/hw/i386/pc.h | 2 +-
  include/sysemu/sysemu.h | 2 +-
  hw/i386/acpi-build.c | 8 

-- 
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 v2 15/16] pci-host: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
El Tue, 13 May 2014 09:02:51 +0200
Marc Marí marc.mari.barc...@gmail.com escribió:
 diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c
 index c80b7cb..dfeb19e 100644
 --- a/hw/pci-host/ppce500.c
 +++ b/hw/pci-host/ppce500.c
 @@ -21,12 +21,16 @@
  #include qemu/bswap.h
  #include hw/pci-host/ppce500.h
  
 +//#define DEBUG_PCI
 +
  #ifdef DEBUG_PCI
 -#define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
 +#define DEBUG_PCI_ENABLED 1
  #else
 -#define pci_debug(fmt, ...)
 +#define DEBUG_PCI_ENABLED 0
  #endif
  
 +#define pci_debug(fmt, ...) QEMU_DPRINTF(DEBUG_PCI_ENABLED,
 ppce500, fmt, ## __VA_ARGS__) +
  #define PCIE500_CFGADDR   0x0
  #define PCIE500_CFGDATA   0x4
  #define PCIE500_REG_BASE  0xC00

In this file, the function name is already written to the macro, so now
it will appear two times. The calls to the macro can be changed to not
add the function name, which, in my opinion, is a bit nicer.

Marc



Re: [Qemu-devel] [PATCH v2 11/16] rc4030: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
El Tue, 13 May 2014 09:02:47 +0200
Marc Marí marc.mari.barc...@gmail.com escribió:
  hw/dma/rc4030.c |   11 +--
  1 file changed, 5 insertions(+), 6 deletions(-)
 
 diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c
 index af26632..84f9f33 100644
 --- a/hw/dma/rc4030.c
 +++ b/hw/dma/rc4030.c
 @@ -32,17 +32,16 @@
  //#define DEBUG_RC4030
  //#define DEBUG_RC4030_DMA
  
 -#ifdef DEBUG_RC4030
 -#define DPRINTF(fmt, ...) \
 -do { printf(rc4030:  fmt , ## __VA_ARGS__); } while (0)
  static const char* irq_names[] = { parallel, floppy, sound,
 video, network, scsi, keyboard, mouse, serial0,
 serial1 }; +#ifdef DEBUG_RC4030
 +#define DEBUG_RC4030_ENABLED 1
  #else
 -#define DPRINTF(fmt, ...)
 +#define DEBUG_RC4030_ENABLED 0
  #endif
  
 -#define RC4030_ERROR(fmt, ...) \
 -do { fprintf(stderr, rc4030 ERROR: %s:  fmt, __func__ , ##
 __VA_ARGS__); } while (0) +#define DPRINTF(fmt, ...)
 QEMU_DPRINTF(DEBUG_RC4030_ENABLED, rc4030, fmt, ## __VA_ARGS__)
 +#define RC4030_ERROR(fmt, ...) QEMU_DPRINTF(1, rc4030 ERROR, fmt,
 ##
 __VA_ARGS__) // /*
 rc4030 emulation */

This file debugs to stdout. Modifying it was a misreading. printfs in
the code can be changed to fprintfs to stderr or the macro can be left
as it was.

Marc



Re: [Qemu-devel] [PATCH 03/10] tcg: Push tcg-runtime routines into exec/helper-*

2014-05-13 Thread Alex Bennée

Richard Henderson r...@twiddle.net writes:

 Rather than special casing them, use the standard mechanisms
 for tcg helper generation.

 Signed-off-by: Richard Henderson r...@twiddle.net
 ---
  include/exec/helper-gen.h   |  1 +
  include/exec/helper-head.h  | 12 
  include/exec/helper-proto.h |  1 +
  include/exec/helper-tcg.h   |  1 +
  tcg-runtime.c   | 40 +---
  tcg/tcg-op.h| 35 ++-
  tcg/tcg-runtime.h   | 30 +-
  tcg/tcg.c   | 16 
  tcg/tcg.h   |  2 --
  9 files changed, 67 insertions(+), 71 deletions(-)

 diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h
 index f6d9ec3..abde615 100644
 --- a/include/exec/helper-gen.h
 +++ b/include/exec/helper-gen.h
 @@ -80,6 +80,7 @@ static inline void glue(gen_helper_, 
 name)(dh_retvar_decl(ret) \
  }
  
  #include helper.h
 +#include tcg-runtime.h
  
  #undef DEF_HELPER_FLAGS_0
  #undef DEF_HELPER_FLAGS_1
 diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h
 index 2cbae22..0b5bd83 100644
 --- a/include/exec/helper-head.h
 +++ b/include/exec/helper-head.h
 @@ -18,6 +18,8 @@
  #ifndef DEF_HELPER_H
  #define DEF_HELPER_H 1
  
 +#include qemu/osdep.h
 +
  #define HELPER(name) glue(helper_, name)
  
  #define GET_TCGV_i32 GET_TCGV_I32
 @@ -32,10 +34,12 @@
  #define dh_alias_s64 i64
  #define dh_alias_f32 i32
  #define dh_alias_f64 i64
 -#if TARGET_LONG_BITS == 32
 -#define dh_alias_tl i32
 -#else
 -#define dh_alias_tl i64
 +#ifdef TARGET_LONG_BITS
 +# if TARGET_LONG_BITS == 32
 +#  define dh_alias_tl i32
 +# else
 +#  define dh_alias_tl i64
 +# endif

This bit seems unrelated to the rest of the patch. In fact I can't see
any uses of the dh_alias_* in the code base although there is some
dh_alias() glue magic that could be throwing me off.

  #endif
snip

Otherwise:

Reviewed-by: Alex Bennée alex.ben...@linaro.org

-- 
Alex Bennée




Re: [Qemu-devel] uvesafb doesn't work with seabios

2014-05-13 Thread Bernhard Walle

Am 2014-05-13 07:52, schrieb Bernhard Walle:

Hi,

* Kevin O'Connor ke...@koconnor.net [2014-05-12 22:07]:

On Mon, May 12, 2014 at 08:53:53PM +0200, Bernhard Walle wrote:
 Am 2014-05-12 07:29, schrieb Kevin O'Connor:
 
 It does look like the x86emu issue.  You can try applying the
 SeaVGABIOS patch below to confirm it.

 The output doesn't appear. But I'm sure that I copied the correct files
 because modifications of other strings worked.

Heh - old versions of x86emu apparently don't support rep outsb
either.  Can you test the patch below instead?


Okay, the output appears. So that means that I should update
v86d (the x86emu lib included there is okay?)?


I already have the latest version of x86d from
https://github.com/mjanusz/v86d/commits/master.


Regards,
Bernhard




Re: [Qemu-devel] [PATCH v2 09/16] i82374: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
El Tue, 13 May 2014 09:02:45 +0200
Marc Marí marc.mari.barc...@gmail.com escribió:
  hw/dma/i82374.c |   11 +--
  1 file changed, 5 insertions(+), 6 deletions(-)
 
 diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c
 index b8ad2e6..7026f24 100644
 --- a/hw/dma/i82374.c
 +++ b/hw/dma/i82374.c
 @@ -27,14 +27,13 @@
  //#define DEBUG_I82374
  
  #ifdef DEBUG_I82374
 -#define DPRINTF(fmt, ...) \
 -do { fprintf(stderr, i82374:  fmt , ## __VA_ARGS__); } while (0)
 +#define DEBUG_I82374_ENABLED 1
  #else
 -#define DPRINTF(fmt, ...) \
 -do {} while (0)
 +#define DEBUG_I82374_ENABLED 0
  #endif
 -#define BADF(fmt, ...) \
 -do { fprintf(stderr, i82374 ERROR:  fmt , ## __VA_ARGS__); } while
 (0) +
 +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_I82374_ENABLED,
 i82374, fmt, ## __VA_ARGS__) +#define BADF(fmt, ...)
 QEMU_DPRINTF(1, i82374 ERROR, fmt, ## __VA_ARGS__) 
  typedef struct I82374State {
  uint8_t commands[8];

In this file, the function name is already written when the macros are
called, so now it will appear two times. The calls to the macro can be
changed to not add the function name, which, in my opinion, is a bit
nicer.

Marc



Re: [Qemu-devel] segfault while booting from saved snapshot

2014-05-13 Thread Shehbaz Jaffer
On Tue, May 13, 2014 at 2:08 PM, Kevin Wolf kw...@redhat.com wrote:
 Am 13.05.2014 um 10:20 hat Shehbaz Jaffer geschrieben:
 Hi,

 Could anyone please give me the command to do live-migration to to a
 file? I have tried searching on QEMU Wiki but all the articles that I
 have come across point to snapshotting the disk, and not the entire VM
 to a file.

 In the HMP monitor: migrate exec:cat  /tmp/vmstate

Thanks, It worked.

For others who want to do the same please note:
We can load the vmstate saved earlier appending:

-incoming exec:cat /tmp/vmstate

to the command while launching the new VM.

 Kevin

 Appreciate your help.

 Thanks,
 Shehbaz

 On Sat, Apr 19, 2014 at 11:07 PM, Shehbaz Jaffer
 shehbazjaffer...@gmail.com wrote:
  Thankyou for your reply. Live migration does seem like an interesting 
  option
  to explore. I will look into it and get back if I get stuck.
 
 
  On Wed, Apr 16, 2014 at 6:16 PM, Kevin Wolf kw...@redhat.com wrote:
 
  Am 15.04.2014 um 16:55 hat Shehbaz Jaffer geschrieben:
   Thankyou for your reply. I do not face the error using qemu.1.7.1
   version.
  
   1 quick question:
  
   I want to create a qcow2 image file after my VM has completed booting;
   i.e.,
   when I boot from this new snapshot, I should directly get to my VMs
   login
   prompt. How can i create such a qcow2 snapshot?
  
   I tried stopped the VM using QMP after the VM had completed booting, and
   then
   using host CLI to create a qcow2 image :
  
   qemu-img create -b ubuntu.qcow2 -f qcow2 newsnap.qcow2
  
   This created a new qcow2 file - newsnap.qcow2 on top of ubuntu.qcow2,
   however
   when I boot using newsnap.qcow2, It takes me again through the complete
   boot
   process - till the login prompt.
  
   Is there a way to create the qcow2 snapshot after VM has completed
   booting?
 
  The reason for this is that you only create a snapshot of the disk this
  way, not of the VM state (i.e. RAM contents, device states, etc.)
 
  The most convenient way when you're using qemu directly is probably
  using internal snapshots. This is what the savevm/loadvm HMP commands
  provide (not sure if there is a QMP equivalent); you can also use the
  -loadvm command line parameter to start a VM from a snapshot.
 
  Another option is that you take an external snapshot in a new qcow2 file
  like you did, but you additionally do a live migration into a file. When
  restarting the VM, you need to use the -incoming option and feed that
  file back to qemu. As this is a bit more cumbersome, this is probably
  more an option for management tools than for manual use.
 
  Kevin
 
 
 
 
  --
  Shehbaz Jaffer
  MTS | Advanced Technology Group |  NetApp



 --
 Shehbaz Jaffer
 MTS | Advanced Technology Group |  NetApp



-- 
Shehbaz Jaffer
MTS | Advanced Technology Group |  NetApp



Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039

2014-05-13 Thread Fam Zheng
On Tue, 05/13 10:46, Markus Armbruster wrote:
 The shell script attempts to suppress core dumps like this:
 
 old_ulimit=$(ulimit -c)
 ulimit -c 0
 $QEMU_IO arg...
 ulimit -c $old_ulimit
 
 This breaks the test hard unless the limit was zero to begin with!
 ulimit sets both hard and soft limit by default, and (re-)raising the
 hard limit requires privileges.  Broken since it was added in commit
 dc68afe.
 
 Could be fixed by adding -S to set only the soft limit, but I'm not
 sure how portable that is in practice.  Simply do it in a subshell
 instead, like this:
 
 (ulimit -c 0; exec $QEMU_IO arg...)
 
 Signed-off-by: Markus Armbruster arm...@redhat.com
 ---
  tests/qemu-iotests/039 | 18 ++
  1 file changed, 6 insertions(+), 12 deletions(-)
 
 diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
 index b9cbe99..182b0f0 100755
 --- a/tests/qemu-iotests/039
 +++ b/tests/qemu-iotests/039
 @@ -67,10 +67,8 @@ echo == Creating a dirty image file ==
  IMGOPTS=compat=1.1,lazy_refcounts=on
  _make_test_img $size
  
 -old_ulimit=$(ulimit -c)
 -ulimit -c 0 # do not produce a core dump on abort(3)
 -$QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG | _filter_qemu_io
 -ulimit -c $old_ulimit
 +(ulimit -c 0 # do not produce a core dump on abort(3)
 +exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
 _filter_qemu_io

This works well.

But when I try to put this in a function to avoid repeating:

function _no_dump_exec()
{
(ulimit -c 0; exec $@)
}

_no_dump_exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
_filter_qemu_io

it doesn't work:

039 1s ... - output mismatch (see 039.out.bad)
--- 039.out 2014-05-13 12:10:39.248866480 +0800
+++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
@@ -9,6 +9,7 @@

 == Creating a dirty image file ==
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
+./039: line 51: 10517 Aborted $@
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 incompatible_features 0x1

Any idea what the difference is here?

Thanks,
Fam

  
  # The dirty bit must be set
  ./qcow2.py $TEST_IMG dump-header | grep incompatible_features
 @@ -103,10 +101,8 @@ echo == Opening a dirty image read/write should repair 
 it ==
  IMGOPTS=compat=1.1,lazy_refcounts=on
  _make_test_img $size
  
 -old_ulimit=$(ulimit -c)
 -ulimit -c 0 # do not produce a core dump on abort(3)
 -$QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG | _filter_qemu_io
 -ulimit -c $old_ulimit
 +(ulimit -c 0 # do not produce a core dump on abort(3)
 +exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
 _filter_qemu_io
  
  # The dirty bit must be set
  ./qcow2.py $TEST_IMG dump-header | grep incompatible_features
 @@ -122,10 +118,8 @@ echo == Creating an image file with lazy_refcounts=off 
 ==
  IMGOPTS=compat=1.1,lazy_refcounts=off
  _make_test_img $size
  
 -old_ulimit=$(ulimit -c)
 -ulimit -c 0 # do not produce a core dump on abort(3)
 -$QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG | _filter_qemu_io
 -ulimit -c $old_ulimit
 +(ulimit -c 0 # do not produce a core dump on abort(3)
 +exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
 _filter_qemu_io
  
  # The dirty bit must not be set since lazy_refcounts=off
  ./qcow2.py $TEST_IMG dump-header | grep incompatible_features
 -- 
 1.8.1.4
 
 



[Qemu-devel] [Bug 1315159] Re: Cannot invoke qemu-kvm with spice paramenter renderer

2014-05-13 Thread Fantu
renderer property in spice parameter of qemu don't exists.
http://git.qemu.org/?p=qemu.git;a=blob_plain;f=qemu-options.hx;hb=master
Look from line DEF(spice, HAS_ARG, QEMU_OPTION_spice, for all valid 
parameters.

** Changed in: qemu
   Status: New = Invalid

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

Title:
  Cannot invoke qemu-kvm with spice paramenter renderer

Status in QEMU:
  Invalid

Bug description:
  I'm running qemu-kvm version 2.0.0 on Fedora 20, spice server version
  0.12.4-3.  The spice user manual states that I can specify the type of
  rendering to be done by the client by providing:

  renderer=oglpbuf+oglpixmap+cairo

  However, when I invoke qemu-kvm with the following option:

   -spice port=5900,addr=0.0.0.0,disable-ticketing,seamless-
  migration=on,renderer=oglpbuf+oglpixmap+cairo

  I get Invalid parameter 'renderer'.

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



Re: [Qemu-devel] [PATCH 04/10] tcg: Use helper-gen.h in tcg-op.h

2014-05-13 Thread Alex Bennée

Richard Henderson r...@twiddle.net writes:

 No need to open-code the setup of the builtin helpers.

 Signed-off-by: Richard Henderson r...@twiddle.net
 ---
  tcg/tcg-op.h | 175 
 +--
  1 file changed, 25 insertions(+), 150 deletions(-)

 diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h
 index 8560695..f4367a0 100644
 --- a/tcg/tcg-op.h
 +++ b/tcg/tcg-op.h
 @@ -24,6 +24,14 @@
  #include tcg.h
  #include exec/helper-proto.h
  
 +static inline void tcg_gen_helperN(void *func, int flags, int sizemask,
 +   TCGArg ret, int nargs, TCGArg *args)
 +{
 +tcg_gen_callN(tcg_ctx, func, flags, sizemask, ret, nargs, args);
 +}
 +
 +#include exec/helper-gen.h
 +
snip
  
 -/* A version of dh_sizemask from def-helper.h that doesn't rely on
 -   preprocessor magic.  */
 -static inline int tcg_gen_sizemask(int n, int is_64bit, int is_signed)
 -{
 -return (is_64bit  n*2) | (is_signed  (n*2 + 1));
 -}
 -
 -/* helper calls */
 -static inline void tcg_gen_helperN(void *func, int flags, int sizemask,
 -   TCGArg ret, int nargs, TCGArg *args)
 -{
 -tcg_gen_callN(tcg_ctx, func, flags, sizemask, ret, nargs, args);
 -}
 -
snip
  
  static inline void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, 
 tcg_target_long offset)
 @@ -708,12 +675,7 @@ static inline void tcg_gen_div_i32(TCGv_i32 ret, 
 TCGv_i32 arg1, TCGv_i32 arg2)
  tcg_gen_op5_i32(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2);
  tcg_temp_free_i32(t0);
  } else {
 -int sizemask = 0;
 -/* Return value and both arguments are 32-bit and signed.  */
 -sizemask |= tcg_gen_sizemask(0, 0, 1);
 -sizemask |= tcg_gen_sizemask(1, 0, 1);
 -sizemask |= tcg_gen_sizemask(2, 0, 1);
 -tcg_gen_helper32(helper_div_i32, sizemask, ret, arg1, arg2);
 +gen_helper_div_i32(ret, arg1, arg2);
  }
  }

I'm having trouble figuring out what the sizemask stuff was trying to
achieve and if it's required/covered after the change. Is the final
helper now the one defined as?

DEF(div_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_div_i32))

it's hard to follow the parameters of this compared to the target
helpers where the the argument sizes are a lot more explicit.

-- 
Alex Bennée




Re: [Qemu-devel] usb: usb tablet freeze when save/restore guest os

2014-05-13 Thread Gonglei (Arei)
Signed-off-by: Gonglei arei.gong...@huawei.com
---
 hw/usb/hcd-uhci.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 0820244..fe0ad81 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -680,6 +680,12 @@ static void uhci_wakeup(USBPort *port1)
 {
 UHCIState *s = port1-opaque;
 UHCIPort *port = s-ports[port1-index];
+uint8_t *pci_conf = s-dev.config;
+
+/* Do not resume UHCI when UHCI PIRQ was disabled */
+if (pci_conf[0xc1] == 0x00  pci_conf[0xc0] == 0x00) {
+return;
+}

 if (port-ctrl  UHCI_PORT_SUSPEND  !(port-ctrl  UHCI_PORT_RD)) {
 port-ctrl |= UHCI_PORT_RD;
@@ -1241,6 +1247,10 @@ static int usb_uhci_common_initfn(PCIDevice *dev)
 /* TODO: reset value should be 0. */
 pci_conf[USB_SBRN] = USB_RELEASE_1; // release number

+/* LEGACY SUPPORT REGISTER - UHCI11D 5.2.1 */
+pci_conf[0xc0] |= 0x00;
+pci_conf[0xc1] |= 0x20; /* Enable USB PIRQ */
+
 pci_config_set_interrupt_pin(pci_conf, u-info.irq_pin + 1);

 if (s-masterbus) {
-- 
1.7.12.4

 -Original Message-
 From: Gonglei (Arei)
 Sent: Tuesday, May 13, 2014 5:05 PM
 To: qemu-devel@nongnu.org
 Cc: 'Gerd Hoffmann'; Huangweidong (C); 'Michael S. Tsirkin'
 Subject: usb: usb tablet freeze when save/restore guest os
 
 Hi,
 
 For recent Linux guests, the usb tablet will be suspended when it is idle.
 When Qemu detect the usb tablet event, will call uhci_wakeup(), which
 according the value of port-ctrl to decide to call uhci_resume() or not.
 UHCI_PORT_RD bit is set to 1 for UHCI is resuming, and qemu will not call
 uhci_resume(). The other way round, qemu will call uhci_resume() and then
 post a interrupt to guest os, meanwhile set UHCI_PORT_RD bit to 1.
 
 In the guests, after handle the interrupt, will call uhci_finish_suspend(), 
 which
 clear UHCI_PORT_RD bit, Then qemu will know that the UHCI resume
 process has finished.
 
 In the situation of save/restore guest os, when the guest os is saving
 memory iteratively, meanwhile the usb tablet work normally (by vnc). When
 qemu
 has set the UHCI_PORT_RD bit to 1, and post a interrupt to guest os, but
 guest os has hibernated this moment, so the interrupt cannot be handled
 in time. So, the UHCI_PORT_RD bit will not be cleared by 
 uhci_finish_suspend().
 
 When we restore the guest os, and the usb tablet event happen again, but
 because of UHCI_PORT_RD bit being set to 1, qemu consider the guest os is
 handling the interrupt of resuming UHCI, so will not post another interrupt.
 For guest os, will not handle UHCI event because it not receive an interrupt,
 which cause usb tablet freeze.
 
 So, we should provide a mechanism for avoiding losing interrupt of UHCI.
 IMHO the LEGACY SUPPORT REGISTER will give us some help, and I have
 finished a patch and tested it work well.
 
 Anything idea? Thanks!
 
 
 Best regards,
 -Gonglei
 




Re: [Qemu-devel] [PATCH 05/10] tcg: Inline tcg_gen_helperN

2014-05-13 Thread Alex Bennée

Richard Henderson r...@twiddle.net writes:

 Signed-off-by: Richard Henderson r...@twiddle.net

Reviewed-by: Alex Bennée alex.ben...@linaro.org

 ---
  include/exec/helper-gen.h | 12 ++--
  tcg/tcg-op.h  |  7 ---
  2 files changed, 6 insertions(+), 13 deletions(-)

 diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h
 index abde615..208d1d2 100644
 --- a/include/exec/helper-gen.h
 +++ b/include/exec/helper-gen.h
 @@ -11,7 +11,7 @@ static inline void glue(gen_helper_, 
 name)(dh_retvar_decl0(ret)) \
  { \
int sizemask; \
sizemask = dh_is_64bit(ret); \
 -  tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 0, NULL); \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), flags, sizemask, dh_retvar(ret), 0, 
 NULL); \
  }
  
  #define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \
 @@ -21,7 +21,7 @@ static inline void glue(gen_helper_, 
 name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1
int sizemask = 0; \
dh_sizemask(ret, 0); \
dh_arg(t1, 1); \
 -  tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 1, args); \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), flags, sizemask, dh_retvar(ret), 1, 
 args); \
  }
  
  #define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \
 @@ -33,7 +33,7 @@ static inline void glue(gen_helper_, 
 name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1
dh_sizemask(ret, 0); \
dh_arg(t1, 1); \
dh_arg(t2, 2); \
 -  tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 2, args); \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), flags, sizemask, dh_retvar(ret), 2, 
 args); \
  }
  
  #define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \
 @@ -46,7 +46,7 @@ static inline void glue(gen_helper_, 
 name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1
dh_arg(t1, 1); \
dh_arg(t2, 2); \
dh_arg(t3, 3); \
 -  tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 3, args); \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), flags, sizemask, dh_retvar(ret), 3, 
 args); \
  }
  
  #define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \
 @@ -60,7 +60,7 @@ static inline void glue(gen_helper_, 
 name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1
dh_arg(t2, 2); \
dh_arg(t3, 3); \
dh_arg(t4, 4); \
 -  tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 4, args); \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), flags, sizemask, dh_retvar(ret), 4, 
 args); \
  }
  
  #define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \
 @@ -76,7 +76,7 @@ static inline void glue(gen_helper_, 
 name)(dh_retvar_decl(ret) \
dh_arg(t3, 3); \
dh_arg(t4, 4); \
dh_arg(t5, 5); \
 -  tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 5, args); \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), flags, sizemask, dh_retvar(ret), 5, 
 args); \
  }
  
  #include helper.h
 diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h
 index f4367a0..719533a 100644
 --- a/tcg/tcg-op.h
 +++ b/tcg/tcg-op.h
 @@ -23,13 +23,6 @@
   */
  #include tcg.h
  #include exec/helper-proto.h
 -
 -static inline void tcg_gen_helperN(void *func, int flags, int sizemask,
 -   TCGArg ret, int nargs, TCGArg *args)
 -{
 -tcg_gen_callN(tcg_ctx, func, flags, sizemask, ret, nargs, args);
 -}
 -
  #include exec/helper-gen.h
  
  int gen_new_label(void);

-- 
Alex Bennée




Re: [Qemu-devel] [PATCH 07/10] tcg: Register the helper info struct rather than the name

2014-05-13 Thread Alex Bennée

Richard Henderson r...@twiddle.net writes:

 This will let us find all the info from the hash table.

 Signed-off-by: Richard Henderson r...@twiddle.net
Reviewed-by: Alex Bennée alex.ben...@linaro.org

 ---
  tcg/tcg.c | 7 +--
  1 file changed, 5 insertions(+), 2 deletions(-)

 diff --git a/tcg/tcg.c b/tcg/tcg.c
 index b64471f..3bbf982 100644
 --- a/tcg/tcg.c
 +++ b/tcg/tcg.c
 @@ -356,7 +356,7 @@ void tcg_context_init(TCGContext *s)
  
  for (i = 0; i  ARRAY_SIZE(all_helpers); ++i) {
  g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func,
 -(gpointer)all_helpers[i].name);
 +(gpointer)all_helpers[i]);
  }
  
  tcg_target_init(s);
 @@ -1149,7 +1149,10 @@ static inline const char *tcg_find_helper(TCGContext 
 *s, uintptr_t val)
  {
  const char *ret = NULL;
  if (s-helpers) {
 -ret = g_hash_table_lookup(s-helpers, (gpointer)val);
 +TCGHelperInfo *info = g_hash_table_lookup(s-helpers, (gpointer)val);
 +if (info) {
 +ret = info-name;
 +}
  }
  return ret;
  }

-- 
Alex Bennée




[Qemu-devel] [PATCH v2] usb: fix up post load checks

2014-05-13 Thread Michael S. Tsirkin
Correct post load checks:
1. dev-setup_len == sizeof(dev-data_buf)
seems fine, no need to fail migration
2. When state is DATA, passing index  len
   will cause memcpy with negative length,
   resulting in heap overflow

First of the issues was reported by dgilbert.

Reported-by: Dr. David Alan Gilbert dgilb...@redhat.com
Signed-off-by: Michael S. Tsirkin m...@redhat.com
---

changes from v1:
- drop state check
- lightly tested

 hw/usb/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index e48b19f..ff1dfe6 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -51,8 +51,8 @@ static int usb_device_post_load(void *opaque, int version_id)
 }
 if (dev-setup_index  0 ||
 dev-setup_len  0 ||
-dev-setup_index = sizeof(dev-data_buf) ||
-dev-setup_len = sizeof(dev-data_buf)) {
+dev-setup_index  dev-setup_len ||
+dev-setup_len  sizeof(dev-data_buf)) {
 return -EINVAL;
 }
 return 0;
-- 
MST



Re: [Qemu-devel] [PATCH 08/10] tcg: Save flags and computed sizemask in TCGHelperInfo

2014-05-13 Thread Alex Bennée

Richard Henderson r...@twiddle.net writes:

 Signed-off-by: Richard Henderson r...@twiddle.net
 ---
snip
 +#define DEF_HELPER_FLAGS_0(NAME, FLAGS, ret) \
 +  { .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
 +.sizemask = dh_sizemask(ret, 0) },
 +
 +#define DEF_HELPER_FLAGS_1(NAME, FLAGS, ret, t1) \
 +  { .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
 +.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) },
 +
 +#define DEF_HELPER_FLAGS_2(NAME, FLAGS, ret, t1, t2) \
 +  { .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
 +.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
 +| dh_sizemask(t2, 2) },
 +
 +#define DEF_HELPER_FLAGS_3(NAME, FLAGS, ret, t1, t2, t3) \
 +  { .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
 +.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
 +| dh_sizemask(t2, 2) | dh_sizemask(t3, 3) },
 +
 +#define DEF_HELPER_FLAGS_4(NAME, FLAGS, ret, t1, t2, t3, t4) \
 +  { .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
 +.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
 +| dh_sizemask(t2, 2) | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) },
 +
 +#define DEF_HELPER_FLAGS_5(NAME, FLAGS, ret, t1, t2, t3, t4, t5) \
 +  { .func = HELPER(NAME), .name = #NAME, .flags = FLAGS, \
 +.sizemask = dh_sizemask(ret, 0) | dh_sizemask(t1, 1) \
 +| dh_sizemask(t2, 2) | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) \
 +| dh_sizemask(t5, 5) },

I'll come back to this when I understand the sizemask stuff better.
  
  #include helper.h
  #include tcg-runtime.h
 diff --git a/tcg/tcg.c b/tcg/tcg.c
 index 3bbf982..d71a9bf 100644
 --- a/tcg/tcg.c
 +++ b/tcg/tcg.c
 @@ -310,6 +310,8 @@ void tcg_pool_reset(TCGContext *s)
  typedef struct TCGHelperInfo {
  void *func;
  const char *name;
 +unsigned flags;
 +unsigned sizemask;
  } TCGHelperInfo;
  
  #include exec/helper-proto.h
 @@ -696,6 +698,11 @@ void tcg_gen_callN(TCGContext *s, void *func, unsigned 
 int flags,
  int real_args;
  int nb_rets;
  TCGArg *nparam;
 +TCGHelperInfo *info;
 +
 +info = g_hash_table_lookup(s-helpers, (gpointer)func);
 +assert(info != NULL);
 +assert(info-sizemask == sizemask);

I assume g_assert vs assert is purely cosmetic? QEMU seems inconsistent
at best about this :-/

  
  #if defined(__sparc__)  !defined(__arch64__) \
   !defined(CONFIG_TCG_INTERPRETER)

-- 
Alex Bennée




Re: [Qemu-devel] [PATCH v2 08/16] tpm: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
El Tue, 13 May 2014 09:02:44 +0200
Marc Marí marc.mari.barc...@gmail.com escribió:
 diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
 index 6f0a4d2..302f2bf 100644
 --- a/hw/tpm/tpm_tis.c
 +++ b/hw/tpm/tpm_tis.c
 @@ -30,16 +30,16 @@
  #include qemu-common.h
  #include qemu/main-loop.h
  
 -/*#define DEBUG_TIS */
 +/*#define DEBUG_TIS*/
  
  #ifdef DEBUG_TIS
 -#define DPRINTF(fmt, ...) \
 -do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
 +#define DEBUG_TIS_ENABLED 1
  #else
 -#define DPRINTF(fmt, ...) \
 -do { } while (0)
 +#define DEBUG_TIS_ENABLED 0
  #endif
  
 +#define DPRINTF(fmt, ...) QEMU_DPRINTF(DEBUG_TIS_ENABLED, tpm-tis,
 fmt, ## __VA_ARGS__) +
  /* whether the STS interrupt is supported */
  #define RAISE_STS_IRQ
  

I saw that later in that file there are some DPRINTF that do not add a
\n at the end (for example in L.141). As this codes are already in a
#ifdef DEBUG_TIS, some of this DPRINTFs can be changed to fprintf in
next versions.

Marc



Re: [Qemu-devel] [PATCH 10/10] tcg: Move size effects out of dh_arg

2014-05-13 Thread Alex Bennée

Richard Henderson r...@twiddle.net writes:

 Tidying the initialization of the args arrays at the same time.

 Signed-off-by: Richard Henderson r...@twiddle.net
 ---
  include/exec/helper-gen.h  | 87 
 --
  include/exec/helper-head.h |  2 +-
  2 files changed, 39 insertions(+), 50 deletions(-)

 diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h
 index 4d290b2..a04a034 100644
 --- a/include/exec/helper-gen.h
 +++ b/include/exec/helper-gen.h
 @@ -6,65 +6,54 @@
  
  #include exec/helper-head.h
  
 -#define DEF_HELPER_FLAGS_0(name, flags, ret) \
 -static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \
 -{ \
 -  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 0, NULL); \
 +#define DEF_HELPER_FLAGS_0(name, flags, ret)\
 +static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret))\
 +{   \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 0, NULL);   \
  }
  
 -#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \
 -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) 
 dh_arg_decl(t1, 1)) \
 -{ \
 -  TCGArg args[1]; \
 -  dh_arg(t1, 1); \
 -  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 1, args); \
 +#define DEF_HELPER_FLAGS_1(name, flags, ret, t1)\
 +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret)  \
 +dh_arg_decl(t1, 1)) \
 +{   \
 +  TCGArg args[1] = { dh_arg(t1, 1) };   \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 1, args);   \
  }
  
 -#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \
 -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) 
 dh_arg_decl(t1, 1), \
 -dh_arg_decl(t2, 2)) \
 -{ \
 -  TCGArg args[2]; \
 -  dh_arg(t1, 1); \
 -  dh_arg(t2, 2); \
 -  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 2, args); \
 +#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2)\
 +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret)  \
 +dh_arg_decl(t1, 1), dh_arg_decl(t2, 2)) \
 +{   \
 +  TCGArg args[2] = { dh_arg(t1, 1), dh_arg(t2, 2) };\
 +  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 2, args);   \
  }
  
 -#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \
 -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) 
 dh_arg_decl(t1, 1), \
 -dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \
 -{ \
 -  TCGArg args[3]; \
 -  dh_arg(t1, 1); \
 -  dh_arg(t2, 2); \
 -  dh_arg(t3, 3); \
 -  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 3, args); \
 +#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3)\
 +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret)  \
 +dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \
 +{   \
 +  TCGArg args[3] = { dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3) }; \
 +  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 3, args);   \
  }
  
 -#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \
 -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) 
 dh_arg_decl(t1, 1), \
 -dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \
 -{ \
 -  TCGArg args[4]; \
 -  dh_arg(t1, 1); \
 -  dh_arg(t2, 2); \
 -  dh_arg(t3, 3); \
 -  dh_arg(t4, 4); \
 -  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 4, args); \
 +#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4)\
 +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret)  \
 +dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), \
 +dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \
 +{   \
 +  TCGArg args[4] = { dh_arg(t1, 1), dh_arg(t2, 2),  \
 + dh_arg(t3, 3), dh_arg(t4, 4) };\
 +  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 4, args);   \
  }
  
 -#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \
 -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \
 -dh_arg_decl(t1, 1),  dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \
 -dh_arg_decl(t4, 4), dh_arg_decl(t5, 5)) \
 -{ \
 -  TCGArg args[5]; \
 -  dh_arg(t1, 1); \
 -  dh_arg(t2, 2); \
 -  dh_arg(t3, 3); \
 -  dh_arg(t4, 4); \
 -  dh_arg(t5, 5); \
 -  tcg_gen_callN(tcg_ctx, HELPER(name), dh_retvar(ret), 5, args); \
 +#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5)\
 +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret)  

Re: [Qemu-devel] [PATCH] usb: fix up post load checks

2014-05-13 Thread Gerd Hoffmann
  Hi,


 And SETUP_STATE_PARAM?

Shortcut for small control transfers on xhci.  Doesn't go through the
idle - setup - data - ack state engine.

security-wise: you can't go from 'param' to 'data' without 'setup'
inbetween.  beside that index should still be zero at the point where
len is modified (simliar to the other place in setup state).

side note: changing len should not happen in normal operation, only with
a malicious / buggy guest.  It happens in case the guest claims the data
transfer is larger than the buffer supplied by the guest.

cheers,
  Gerd





[Qemu-devel] Undefined error for curl_multi_socket_action

2014-05-13 Thread Gaurav Sharma
After rebasing my code with the master branch, i have started getting error
for this method curl_multi_socket_action.
In the file blocl/curl.c I can see function call for this method without
NEED_CURL_TIMER_CALLBACK directive check also.

Is this is know issue, and what i can do to get rid of it apart from
commenting the function call ?

Thanks,
Gaurav


Re: [Qemu-devel] [PATCH v2 05/16] xilinx: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
El Tue, 13 May 2014 09:02:41 +0200
Marc Marí marc.mari.barc...@gmail.com escribió:
 Modify debug macros to have the same format through the codebase and
 use regular ifs instead of ifdef.
 
 As the debug printf is always put in code, some casting had to be
 added to avoid warnings treated as errors at compile time.
 
 Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
 ---
  hw/net/cadence_gem.c |   11 ++-
  1 file changed, 6 insertions(+), 5 deletions(-)
 
 diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
 index cdb1825..aa93372 100644
 --- a/hw/net/cadence_gem.c
 +++ b/hw/net/cadence_gem.c
 @@ -28,15 +28,16 @@
  #include net/net.h
  #include net/checksum.h
  
 +//#define CADENCE_GEM_ERR_DEBUG
 +
  #ifdef CADENCE_GEM_ERR_DEBUG
 -#define DB_PRINT(...) do { \
 -fprintf(stderr,  : %s: , __func__); \
 -fprintf(stderr, ## __VA_ARGS__); \
 -} while (0);
 +#define CADENCE_GEM_ERR_DEBUG_ENABLED 1
  #else
 -#define DB_PRINT(...)
 +#define CADENCE_GEM_ERR_DEBUG_ENABLED 0
  #endif
  
 +#define DB_PRINT(...) QEMU_DPRINTF(CADENCE_GEM_ERR_DEBUG_ENABLED,
 cadence_gem, __VA_ARGS__) +
  #define GEM_NWCTRL(0x/4) /* Network Control reg */
  #define GEM_NWCFG (0x0004/4) /* Network Config reg */
  #define GEM_NWSTATUS  (0x0008/4) /* Network Status reg */

I saw that later in that file there are some DB_PRINT that do not add a
\n at the end (for example in L.1128). This can either be solved by
using fprintfs in between a #if CADENCE_GEM_ERR_DEBUG_ENABLED, adding a
\n after the message or leave the macro as it was.

Marc



Re: [Qemu-devel] [PATCH] kvm: make one_reg helpers available for everyone

2014-05-13 Thread Alexander Graf


On 09.05.14 10:06, Cornelia Huck wrote:

s390x introduced helper functions for getting/setting one_regs with
commit 860643bc. However, nothing about these is s390-specific.

Alexey Kardashevskiy had already posted a general version, so let's
merge the two patches and massage the code a bit.

CC: Alexey Kardashevskiy a...@ozlabs.ru
Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com


Thanks a lot for the patch Conny. Unfortunately Paolo seems to have 
missed this and queued Alexey's patch instead.


Does s390x even compile still with Alexey's patch applied? If it does, 
please post a simple follow-up patch removing your own s390 
implementation. If it doesn't compile, NACK on the current KVM pull request.



Alex


---
  include/sysemu/kvm.h | 20 
  kvm-all.c| 28 
  target-s390x/kvm.c   | 29 -
  trace-events |  6 ++
  4 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 5ad4e0e..a6c2823 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -383,4 +383,24 @@ void kvm_init_irq_routing(KVMState *s);
   *   0: irq chip was created
   */
  int kvm_arch_irqchip_create(KVMState *s);
+
+/**
+ * kvm_set_one_reg - set a register value in KVM via KVM_SET_ONE_REG ioctl
+ * @id: The register ID
+ * @source: The pointer to the value to be set. It must point to a variable
+ *  of the correct type/size for the register being accessed.
+ *
+ * Returns: 0 on success, or a negative errno on failure.
+ */
+int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);
+
+/**
+ * kvm_get_one_reg - get a register value from KVM via KVM_GET_ONE_REG ioctl
+ * @id: The register ID
+ * @target: The pointer where the value is to be stored. It must point to a
+ *  variable of the correct type/size for the register being accessed.
+ *
+ * Returns: 0 on success, or a negative errno on failure.
+ */
+int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target);
  #endif
diff --git a/kvm-all.c b/kvm-all.c
index 5cb7f26..94520e5 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -2114,3 +2114,31 @@ int kvm_create_device(KVMState *s, uint64_t type, bool 
test)
  
  return test ? 0 : create_dev.fd;

  }
+
+int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source)
+{
+struct kvm_one_reg reg;
+int r;
+
+reg.id = id;
+reg.addr = (uintptr_t) source;
+r = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, reg);
+if (r) {
+trace_kvm_failed_reg_set(id, strerror(r));
+}
+return r;
+}
+
+int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target)
+{
+struct kvm_one_reg reg;
+int r;
+
+reg.id = id;
+reg.addr = (uintptr_t) target;
+r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, reg);
+if (r) {
+trace_kvm_failed_reg_get(id, strerror(r));
+}
+return r;
+}
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index b7b0edc..ba2dffe 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -129,35 +129,6 @@ void kvm_arch_reset_vcpu(CPUState *cpu)
  }
  }
  
-static int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source)

-{
-struct kvm_one_reg reg;
-int r;
-
-reg.id = id;
-reg.addr = (uint64_t) source;
-r = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, reg);
-if (r) {
-trace_kvm_failed_reg_set(id, strerror(errno));
-}
-return r;
-}
-
-static int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target)
-{
-struct kvm_one_reg reg;
-int r;
-
-reg.id = id;
-reg.addr = (uint64_t) target;
-r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, reg);
-if (r) {
-trace_kvm_failed_reg_get(id, strerror(errno));
-}
-return r;
-}
-
-
  int kvm_arch_put_registers(CPUState *cs, int level)
  {
  S390CPU *cpu = S390_CPU(cs);
diff --git a/trace-events b/trace-events
index af4449d..2c5b307 100644
--- a/trace-events
+++ b/trace-events
@@ -1230,6 +1230,8 @@ kvm_run_exit(int cpu_index, uint32_t reason) cpu_index %d, 
reason %d
  kvm_device_ioctl(int fd, int type, void *arg) dev fd %d, type 0x%x, arg %p
  kvm_failed_spr_set(int str, const char *msg) Warning: Unable to set SPR %d to 
KVM: %s
  kvm_failed_spr_get(int str, const char *msg) Warning: Unable to retrieve SPR %d 
from KVM: %s
+kvm_failed_reg_get(uint64_t id, const char *msg) Warning: Unable to retrieve ONEREG % 
PRIu64  from KVM: %s
+kvm_failed_reg_set(uint64_t id, const char *msg) Warning: Unable to set ONEREG % 
PRIu64  to KVM: %s
  
  # memory.c

  memory_region_ops_read(void *mr, uint64_t addr, uint64_t value, unsigned size) mr %p addr 
%#PRIx64 value %#PRIx64 size %u
@@ -1246,7 +1248,3 @@ xen_pv_mmio_write(uint64_t addr) WARNING: write to Xen 
PV Device MMIO space (ad
  # hw/pci/pci_host.c
  pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs, unsigned val) 
%s %02u:%u @0x%x - 0x%x
  pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned offs, unsigned 

Re: [Qemu-devel] [PATCH v2 04/16] highbank: Convert conditional compilation of debug printfs to regular ifs

2014-05-13 Thread Marc Marí
El Tue, 13 May 2014 09:02:40 +0200
Marc Marí marc.mari.barc...@gmail.com escribió:
 Modify debug macros to have the same format through the codebase and
 use regular ifs instead of ifdef.
 
 As the debug printf is always put in code, some casting had to be
 added to avoid warnings treated as errors at compile time.
 
 Signed-off-by: Marc Marí marc.mari.barc...@gmail.com
 ---
  hw/net/xgmac.c |   10 ++
  1 file changed, 6 insertions(+), 4 deletions(-)
 
 diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
 index 88349ac..734c2e5 100644
 --- a/hw/net/xgmac.c
 +++ b/hw/net/xgmac.c
 @@ -30,14 +30,16 @@
  #include net/net.h
  #include net/checksum.h
  
 +//#define DEBUG_XGMAC
 +
  #ifdef DEBUG_XGMAC
 -#define DEBUGF_BRK(message, args...) do { \
 - fprintf(stderr, (message),
 ## args); \
 - } while (0)
 +#define DEBUG_XGMAC_ENABLED 1
  #else
 -#define DEBUGF_BRK(message, args...) do { } while (0)
 +#define DEBUG_XGMAC_ENABLED 0
  #endif
  
 +#define DEBUGF_BRK(message, args...)
 QEMU_DPRINTF(DEBUG_XGMAC_ENABLED, xgmag, message, ## args) +
  #define XGMAC_CONTROL   0x   /* MAC Configuration */
  #define XGMAC_FRAME_FILTER  0x0001   /* MAC Frame Filter */
  #define XGMAC_FLOW_CTRL 0x0006   /* MAC Flow Control */

In this file, the function name is already written when the macros are
called, so now it will appear two times. The calls to the macro can be
changed to not add the function name, which, in my opinion, is a bit
nicer.

Marc



[Qemu-devel] [RFC 1/3] using CPUMASK bitmaps to calculate cpu index

2014-05-13 Thread Chen Fan
instead of seeking the number of CPUs, using CPUMASK bitmaps to
calculate the cpu index, also would be a gread benefit to remove
cpu index.

Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
 exec.c  | 9 -
 include/qom/cpu.h   | 9 +
 include/sysemu/sysemu.h | 7 ---
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/exec.c b/exec.c
index cf12049..2948841 100644
--- a/exec.c
+++ b/exec.c
@@ -473,16 +473,15 @@ void cpu_exec_init(CPUArchState *env)
 {
 CPUState *cpu = ENV_GET_CPU(env);
 CPUClass *cc = CPU_GET_CLASS(cpu);
-CPUState *some_cpu;
 int cpu_index;
 
 #if defined(CONFIG_USER_ONLY)
 cpu_list_lock();
 #endif
-cpu_index = 0;
-CPU_FOREACH(some_cpu) {
-cpu_index++;
-}
+cpu_index = find_first_zero_bit(cc-cpu_present_mask,
+MAX_CPUMASK_BITS);
+set_bit(cpu_index, cc-cpu_present_mask);
+
 cpu-cpu_index = cpu_index;
 cpu-numa_node = 0;
 QTAILQ_INIT(cpu-breakpoints);
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index df977c8..b8f46b1 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -70,6 +70,13 @@ typedef void (*CPUUnassignedAccess)(CPUState *cpu, hwaddr 
addr,
 
 struct TranslationBlock;
 
+/* The following shall be true for all CPUs:
+ *   cpu-cpu_index  max_cpus = MAX_CPUMASK_BITS
+ *
+ * Note that cpu-get_arch_id() may be larger than MAX_CPUMASK_BITS.
+ */
+#define MAX_CPUMASK_BITS 255
+
 /**
  * CPUClass:
  * @class_by_name: Callback to map -cpu command line model name to an
@@ -142,6 +149,8 @@ typedef struct CPUClass {
 const struct VMStateDescription *vmsd;
 int gdb_num_core_regs;
 const char *gdb_core_xml_file;
+
+DECLARE_BITMAP(cpu_present_mask, MAX_CPUMASK_BITS);
 } CPUClass;
 
 #ifdef HOST_WORDS_BIGENDIAN
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index ba5c7f8..04edb8b 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -134,13 +134,6 @@ extern QEMUClockType rtc_clock;
 
 #define MAX_NODES 64
 
-/* The following shall be true for all CPUs:
- *   cpu-cpu_index  max_cpus = MAX_CPUMASK_BITS
- *
- * Note that cpu-get_arch_id() may be larger than MAX_CPUMASK_BITS.
- */
-#define MAX_CPUMASK_BITS 255
-
 extern int nb_numa_nodes;
 extern uint64_t node_mem[MAX_NODES];
 extern unsigned long *node_cpumask[MAX_NODES];
-- 
1.8.1.4




[Qemu-devel] [RFC 0/3] cpu: add device_add foo-x86_64-cpu support

2014-05-13 Thread Chen Fan
this patches tried to make cpu hotplug with device_add, 
and made -device foo-x86_64-cpu available,also we can
set apic-id property with command line, if without setting
apic-id property, we added first unoccupied apic id as the
default new apic id. and hotplug cpu with device_add, we
must make check of APIC ID after cpu object initialization
that was different from 'cpu_add' command which check 'ids'
at the beginning.

Chen Fan (3):
  using CPUMASK bitmaps to calculate cpu index
  cpu: introduce CpuTopoInfo structure for argument simplification
  cpu: add device_add foo-x86_64-cpu support

 exec.c  |  9 +++--
 include/qom/cpu.h   | 11 ++
 include/sysemu/sysemu.h |  7 
 qdev-monitor.c  | 11 ++
 target-i386/cpu.c   | 91 -
 target-i386/topology.h  | 51 ++-
 6 files changed, 151 insertions(+), 29 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [RFC 2/3] cpu: introduce CpuTopoInfo structure for argument simplification

2014-05-13 Thread Chen Fan
Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
Reviewed-by: Eduardo Habkost ehabk...@redhat.com
---
 target-i386/topology.h | 33 +
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/target-i386/topology.h b/target-i386/topology.h
index 07a6c5f..e9ff89c 100644
--- a/target-i386/topology.h
+++ b/target-i386/topology.h
@@ -47,6 +47,12 @@
  */
 typedef uint32_t apic_id_t;
 
+typedef struct X86CPUTopoInfo {
+unsigned pkg_id;
+unsigned core_id;
+unsigned smt_id;
+} X86CPUTopoInfo;
+
 /* Return the bit width needed for 'count' IDs
  */
 static unsigned apicid_bitwidth_for_count(unsigned count)
@@ -92,13 +98,11 @@ static inline unsigned apicid_pkg_offset(unsigned nr_cores, 
unsigned nr_threads)
  */
 static inline apic_id_t apicid_from_topo_ids(unsigned nr_cores,
  unsigned nr_threads,
- unsigned pkg_id,
- unsigned core_id,
- unsigned smt_id)
+ const X86CPUTopoInfo *topo)
 {
-return (pkg_id   apicid_pkg_offset(nr_cores, nr_threads)) |
-   (core_id  apicid_core_offset(nr_cores, nr_threads)) |
-   smt_id;
+return (topo-pkg_id   apicid_pkg_offset(nr_cores, nr_threads)) |
+   (topo-core_id  apicid_core_offset(nr_cores, nr_threads)) |
+   topo-smt_id;
 }
 
 /* Calculate thread/core/package IDs for a specific topology,
@@ -107,14 +111,12 @@ static inline apic_id_t apicid_from_topo_ids(unsigned 
nr_cores,
 static inline void x86_topo_ids_from_idx(unsigned nr_cores,
  unsigned nr_threads,
  unsigned cpu_index,
- unsigned *pkg_id,
- unsigned *core_id,
- unsigned *smt_id)
+ X86CPUTopoInfo *topo)
 {
 unsigned core_index = cpu_index / nr_threads;
-*smt_id = cpu_index % nr_threads;
-*core_id = core_index % nr_cores;
-*pkg_id = core_index / nr_cores;
+topo-smt_id = cpu_index % nr_threads;
+topo-core_id = core_index % nr_cores;
+topo-pkg_id = core_index / nr_cores;
 }
 
 /* Make APIC ID for the CPU 'cpu_index'
@@ -125,10 +127,9 @@ static inline apic_id_t x86_apicid_from_cpu_idx(unsigned 
nr_cores,
 unsigned nr_threads,
 unsigned cpu_index)
 {
-unsigned pkg_id, core_id, smt_id;
-x86_topo_ids_from_idx(nr_cores, nr_threads, cpu_index,
-  pkg_id, core_id, smt_id);
-return apicid_from_topo_ids(nr_cores, nr_threads, pkg_id, core_id, smt_id);
+X86CPUTopoInfo topo;
+x86_topo_ids_from_idx(nr_cores, nr_threads, cpu_index, topo);
+return apicid_from_topo_ids(nr_cores, nr_threads, topo);
 }
 
 #endif /* TARGET_I386_TOPOLOGY_H */
-- 
1.8.1.4




[Qemu-devel] [RFC 3/3] cpu: add device_add foo-x86_64-cpu support

2014-05-13 Thread Chen Fan
In order to implement adding cpu with device_add, we should make the
check of APIC ID after object_init(), so add UserCreatable complete
method for checking APIC ID availability, and introduce cpu_physid_mask
for saving occupied APIC ID, then we could use -device foo-x86_64-cpu
without setting apic-id property to add default APIC IDs.

Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
 include/qom/cpu.h  |  2 ++
 qdev-monitor.c | 11 ++
 target-i386/cpu.c  | 91 +-
 target-i386/topology.h | 18 ++
 4 files changed, 121 insertions(+), 1 deletion(-)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index b8f46b1..8ba9f7b 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -151,6 +151,7 @@ typedef struct CPUClass {
 const char *gdb_core_xml_file;
 
 DECLARE_BITMAP(cpu_present_mask, MAX_CPUMASK_BITS);
+DECLARE_BITMAP(cpu_physid_mask, MAX_CPUMASK_BITS);
 } CPUClass;
 
 #ifdef HOST_WORDS_BIGENDIAN
@@ -296,6 +297,7 @@ struct CPUState {
 QTAILQ_HEAD(CPUTailQ, CPUState);
 extern struct CPUTailQ cpus;
 #define CPU_NEXT(cpu) QTAILQ_NEXT(cpu, node)
+#define CPU_REMOVE(cpu) QTAILQ_REMOVE(cpus, cpu, node)
 #define CPU_FOREACH(cpu) QTAILQ_FOREACH(cpu, cpus, node)
 #define CPU_FOREACH_SAFE(cpu, next_cpu) \
 QTAILQ_FOREACH_SAFE(cpu, cpus, node, next_cpu)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 02cbe43..36c200e 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -24,6 +24,7 @@
 #include qmp-commands.h
 #include sysemu/arch_init.h
 #include qemu/config-file.h
+#include qom/object_interfaces.h
 
 /*
  * Aliases were a bad idea from the start.  Let's keep them
@@ -556,6 +557,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
 return NULL;
 }
 
+user_creatable_complete(OBJECT(dev), err);
+if (err != NULL) {
+qerror_report_err(err);
+ error_free(err);
+ object_unparent(OBJECT(dev));
+ object_unref(OBJECT(dev));
+ qerror_report(QERR_DEVICE_INIT_FAILED, driver);
+ return NULL;
+}
+
 dev-opts = opts;
 object_property_set_bool(OBJECT(dev), true, realized, err);
 if (err != NULL) {
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 8f193a9..56cc3ad 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -48,6 +48,7 @@
 #include hw/i386/apic_internal.h
 #endif
 
+#include qom/object_interfaces.h
 
 /* Cache topology CPUID constants: */
 
@@ -158,7 +159,7 @@
 #define L2_ITLB_4K_ASSOC   4
 #define L2_ITLB_4K_ENTRIES   512
 
-
+static int64_t cpu_2_physid[MAX_CPUMASK_BITS];
 
 static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
  uint32_t vendor2, uint32_t vendor3)
@@ -1546,12 +1547,16 @@ static void x86_cpuid_get_apic_id(Object *obj, Visitor 
*v, void *opaque,
 static void x86_cpuid_set_apic_id(Object *obj, Visitor *v, void *opaque,
   const char *name, Error **errp)
 {
+CPUState *cs = CPU(obj);
+CPUClass *cc = CPU_GET_CLASS(obj);
 X86CPU *cpu = X86_CPU(obj);
 DeviceState *dev = DEVICE(obj);
 const int64_t min = 0;
 const int64_t max = UINT32_MAX;
 Error *error = NULL;
 int64_t value;
+X86CPUTopoInfo topo;
+int64_t phys_id;
 
 if (dev-realized) {
 error_setg(errp, Attempt to set property '%s' on '%s' after 
@@ -1571,10 +1576,28 @@ static void x86_cpuid_set_apic_id(Object *obj, Visitor 
*v, void *opaque,
 return;
 }
 
+if (value  x86_cpu_apic_id_from_index(max_cpus - 1)) {
+error_setg(errp, CPU with APIC ID % PRIi64
+is more than MAX APIC ID limits, value);
+return;
+}
+
+x86_topo_ids_from_apic_id(smp_cores, smp_threads, value, topo);
+if (topo.smt_id = smp_threads || topo.core_id = smp_cores) {
+error_setg(errp, CPU with APIC ID % PRIi64  does not match 
+   topology configuration., value);
+return;
+}
+
 if ((value != cpu-env.cpuid_apic_id)  cpu_exists(value)) {
 error_setg(errp, CPU with APIC ID % PRIi64  exists, value);
 return;
 }
+
+phys_id = (topo.smt_id + topo.core_id * smp_threads
++ topo.pkg_id * smp_cores * smp_threads);
+set_bit(phys_id, cc-cpu_physid_mask);
+cpu_2_physid[cs-cpu_index] = phys_id;
 cpu-env.cpuid_apic_id = value;
 }
 
@@ -1999,12 +2022,57 @@ out:
 return cpu;
 }
 
+static void x86_cpu_cpudef_instance_init(Object *obj)
+{
+DeviceState *dev = DEVICE(obj);
+X86CPU *cpu = X86_CPU(obj);
+CPUX86State *env = cpu-env;
+
+dev-hotplugged = true;
+
+env-cpuid_apic_id = ~0U;
+}
+
+static void x86_cpu_cpudef_complete(UserCreatable *uc, Error **errp)
+{
+CPUState *cs = CPU(uc);
+X86CPU *cpu = X86_CPU(uc);
+CPUClass *cc = CPU_GET_CLASS(OBJECT(uc));
+int64_t phys_id;
+
+if (cpu-env.cpuid_apic_id != ~0U) {
+return;
+}
+
+phys_id = find_first_zero_bit(cc-cpu_physid_mask, 

Re: [Qemu-devel] KVM call agenda for 2014-05-13

2014-05-13 Thread Andreas Färber
Am 12.05.2014 13:09, schrieb Peter Maydell:
 On 12 May 2014 11:30, Peter Crosthwaite peter.crosthwa...@xilinx.com wrote:
 On Mon, May 12, 2014 at 7:44 PM, Peter Maydell peter.mayd...@linaro.org 
 wrote:
 On 12 May 2014 10:10, Juan Quintela quint...@redhat.com wrote:
 Please, send any topic that you are interested in covering.

 - QOMifying both Memory regions and GPIOs and attaching them via QOM
   links (Peter Crosthwaite)

 Is there some further useful material on-list on this subject, or
 are we just going to have a rerun of the discussions on the
 last two calls?
 
 I have any ugly work-in-progress series. TBH I was going to wait for
 discussion outcomes. Want me to RFC it?
 
 I don't think you necessarily need to post code, but maybe a writeup
 of current status/options would be useful to try to make the on-call
 discussion productive?

Here's my WIP qemu_irq conversion, so that we don't discuss IRQs for the
third time in a row without results:

https://github.com/afaerber/qemu-cpu/commits/qom-irq

make check passes, not further tested yet.
As a side effect, cleaning up the leaks turned out rather easy.

The only remaining users of qemu_free_irqs() are serial-pci.c and
ipack.c. If we can get rid of it altogether, the hacks for freeing the
memory chunk could be avoided.

Regards,
Andreas

-- 
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 memory v1 1/1] memory: Simplify mr_add_subregion() if-else

2014-05-13 Thread Paolo Bonzini

Il 12/05/2014 10:13, Peter Crosthwaite ha scritto:

This if else is not needed. The previous call to memory_region_add
(whether _overlap or not) will always set priority and may_overlap
to desired values. And its not possible to get here without having
called memory_region_add_subregion due to the null guard on parent.
So we can just directly call memory_region_add_subregion_common.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 memory.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/memory.c b/memory.c
index 3f1df23..1352881 100644
--- a/memory.c
+++ b/memory.c
@@ -1501,8 +1501,6 @@ void memory_region_set_enabled(MemoryRegion *mr, bool 
enabled)
 void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
 {
 MemoryRegion *parent = mr-parent;
-int priority = mr-priority;
-bool may_overlap = mr-may_overlap;

 if (addr == mr-addr || !parent) {
 mr-addr = addr;
@@ -1512,11 +1510,7 @@ void memory_region_set_address(MemoryRegion *mr, hwaddr 
addr)
 memory_region_transaction_begin();
 memory_region_ref(mr);
 memory_region_del_subregion(parent, mr);
-if (may_overlap) {
-memory_region_add_subregion_overlap(parent, addr, mr, priority);
-} else {
-memory_region_add_subregion(parent, addr, mr);
-}
+memory_region_add_subregion_common(parent, addr, mr);
 memory_region_unref(mr);
 memory_region_transaction_commit();
 }



Thanks, I'll include this in the next memory pull request.

Paolo



Re: [Qemu-devel] [PULL 0/8] KVM changes for 2014-05-08

2014-05-13 Thread Cornelia Huck
On Sat, 10 May 2014 08:50:44 +0200
Paolo Bonzini pbonz...@redhat.com wrote:

 The following changes since commit 3a87f8b6859e6221b827ab4737779dddb37553ec:
 
   Merge remote-tracking branch 'remotes/afaerber/tags/ppc-for-2.0' into 
 staging (2014-03-20 11:45:38 +)
 
 are available in the git repository at:
 
 
   git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master

I rebased to qemu/master, where compilation fails with

/home/cohuck/git/qemu/target-s390x/kvm.c:132: error: static declaration of 
‘kvm_set_one_reg’ follows non-static declaration
/home/cohuck/git/qemu/include/sysemu/kvm.h:383: error: previous declaration of 
‘kvm_set_one_reg’ was here
/home/cohuck/git/qemu/target-s390x/kvm.c:146: error: static declaration of 
‘kvm_get_one_reg’ follows non-static declaration
/home/cohuck/git/qemu/include/sysemu/kvm.h:393: error: previous declaration of 
‘kvm_get_one_reg’ was here

 
 for you to fetch changes up to 12474c96368ec3a01ad95c81fe9d00bd33e01877:
 
   target-i386: the x86 CPL is stored in CS.selector - auto update hflags 
 accordingly. (2014-05-10 08:47:56 +0200)
 
 
 Alexey Kardashevskiy (1):
   kvm: add set_one_reg/get_one_reg helpers

Here's where the conflict gets introduced. I don't mind using generic
helper functions, but these are missing the trace events on failure. So
I'd either like to have this patch replaced by
1399622806-61662-1-git-send-email-cornelia.h...@de.ibm.com, or
alternatively I can do an add-on patch that removes the s390
implementation introduced with 860643bc (s390x/kvm: rework KVM
synchronize to tracing for some ONEREGS) and adds a trace event to the
common code implementation.

 
 Gonglei (1):
   pci-assign: Fix a bug when map MSI-X table memory failed
 
 Kevin O'Connor (4):
   target-i386: set eflags prior to calling svm_load_seg_cache() in 
 svm_helper.c
   target-i386: set eflags and cr0 prior to calling 
 cpu_x86_load_seg_cache() in smm_helper.c
   target-i386: set eflags prior to calling cpu_x86_load_seg_cache() in 
 seg_helper.c
   target-i386: the x86 CPL is stored in CS.selector - auto update hflags 
 accordingly.
 
 Michael S. Tsirkin (1):
   pci-assign: limit # of msix vectors
 
 Stefan Weil (1):
   target-i386: Remove unused data from local array
 
  bsd-user/main.c  |  2 --
  hw/i386/kvm/pci-assign.c | 13 ++--
  include/sysemu/kvm.h | 20 ++
  kvm-all.c| 18 
  linux-user/main.c|  2 --
  target-i386/cpu.h| 25 +++
  target-i386/kvm.c|  3 +--
  target-i386/seg_helper.c | 53 
 +---
  target-i386/smm_helper.c | 34 +++
  target-i386/svm_helper.c | 11 ++
  10 files changed, 96 insertions(+), 85 deletions(-)




Re: [Qemu-devel] KVM call agenda for 2014-05-13

2014-05-13 Thread Peter Crosthwaite
On Tuesday, May 13, 2014, Andreas Färber afaer...@suse.de wrote:

 Am 12.05.2014 13:09, schrieb Peter Maydell:
  On 12 May 2014 11:30, Peter Crosthwaite 
  peter.crosthwa...@xilinx.comjavascript:;
 wrote:
  On Mon, May 12, 2014 at 7:44 PM, Peter Maydell 
 peter.mayd...@linaro.org javascript:; wrote:
  On 12 May 2014 10:10, Juan Quintela quint...@redhat.comjavascript:;
 wrote:
  Please, send any topic that you are interested in covering.
 
  - QOMifying both Memory regions and GPIOs and attaching them via QOM
links (Peter Crosthwaite)
 
  Is there some further useful material on-list on this subject, or
  are we just going to have a rerun of the discussions on the
  last two calls?
 
  I have any ugly work-in-progress series. TBH I was going to wait for
  discussion outcomes. Want me to RFC it?
 
  I don't think you necessarily need to post code, but maybe a writeup
  of current status/options would be useful to try to make the on-call
  discussion productive?

 Here's my WIP qemu_irq conversion, so that we don't discuss IRQs for the
 third time in a row without results:

 https://github.com/afaerber/qemu-cpu/commits/qom-irq


Same basic idea as my wip series. No conflict of design at all. I've done
some stuff around parenting irqs to their devs that would build onto this.

regards,
Peter



 make check passes, not further tested yet.
 As a side effect, cleaning up the leaks turned out rather easy.

 The only remaining users of qemu_free_irqs() are serial-pci.c and
 ipack.c. If we can get rid of it altogether, the hacks for freeing the
 memory chunk could be avoided.

 Regards,
 Andreas

 --
 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] [PULL 00/17] Block patches

2014-05-13 Thread Peter Maydell
On 9 May 2014 20:03, Stefan Hajnoczi stefa...@redhat.com wrote:
 The following changes since commit 43cbeffb19877c62cbe0aaf08b2f235d98d71340:

   Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' 
 into staging (2014-05-08 12:38:01 +0100)

 are available in the git repository at:


   git://github.com/stefanha/qemu.git tags/block-pull-request

 for you to fetch changes up to 5a007547df76446ab891df93ebc55749716609bf:

   glib: fix g_poll early timeout on windows (2014-05-09 20:57:35 +0200)

Applied, thanks.

-- PMM



Re: [Qemu-devel] KVM call agenda for 2014-05-13

2014-05-13 Thread Peter Maydell
On 13 May 2014 00:27, Peter Crosthwaite peter.crosthwa...@xilinx.com wrote:
 Ok so here's my plan:

This generally all sounds good to me. A slight nit:

 QOMify address spaces. So they can be instantiated, reffed etc.
 completely aside from the hotplug discussion this greatly helps
 connecting bus master devices using proper QOM links. E.G. using
 machine-set link properties rather address_space_memory everywhere.

I'm not sure that the thing a bus master exposes to be connected
up should be an AddressSpace -- I think it should be a MemoryRegion
(more precisely, the code creating the bus-master should create
a MemoryRegion and pass it to the bus-master device).

Consider a board model which puts together some RAM and
devices. It ought to have the same interface for passing this
up to the CPU whether it's doing so directly or via some SoC
container device. For the SoC container case, this has to be
by passing a MemoryRegion, since the SoC will want to add
some devices of its own to create a combined board+SoC view to
pass to the CPU object proper. So for consistency the interface
for passing things to the CPU should also be a MemoryRegion
(which the CPU then turns into an AddressSpace for its own
internal use.)

thanks
-- PMM



Re: [Qemu-devel] [PATCH v4] libxl: add basic spice support for pv domUs

2014-05-13 Thread Fabio Fantoni

Il 13/05/2014 11:50, Ian Campbell ha scritto:

On Tue, 2014-05-13 at 10:00 +0200, Fabio Fantoni wrote:

But: Does spice already require a VFB? In which case the existing
handing of that will suffice.

I think I'm probably confused about something: Does this patch
enable/expose SPICE to the guest? Or does it simply enable the existing
PVFB's output to be exposed from the qemu process to a spice client? I
had been thinking this was a parallel feature to PVFB, but I'm starting
to suspect this might actually be an additional feature *of* PVFB, which
is correct? (I'm afraid that depending on which it is I might have to
check back over my review to make sure I haven't suggested anything
stupid)

Does QXL change that answer?

QXL and other emulated vga is now not supported on pv domUs because
require an emulated pci bus and MMIO not supported on pv domUs FWIK.

Right, but what about the previous paragraph? That was the important bit
for me to understand, since it impacts the entire configuration model
and libxl API.


During my first test, I was enabled spice in pv domus but the guest wont
show nothing while connecting to it.
On my second shot, I've added -vga xenfb but it is deprecated. This way
I've got at least video out but no mouse nor keyboard.
Following the suggestions from Stefano Stabellini I've then activated
vfb the same way as for vnc and i got it all working but mouse, which is
only visible in some circumstances (such grafical debian installer) but
always working (even if not visible).
The last one is the actual patch.
Probably the vfb part is not complete or at least improvable.
Perhaps it is even not necessary if pvfb will became modified to works
with spice, so domUs use this through its modules.

Is SPICE a mechanism for exposing the PVFB or is it something entirely
separate? That is the crux of my question above.


I added also qemu-devel and spice-devel on cc:
Any one on this please?




I feel I'm not perfectly undrestanding pvfb. Please would you like
better describe me this component?

I need to understand what it is this patch is actually doing. I'm
starting to worry that perhaps you don't understand either.


Make possible using spice with basic features also on pv domUs.
Since emulated vgas is not supported on pv I use vfb instead, even if 
this part is incomplete and rudimental.
I'm waiting from some aswers from spice and qemu teams to share some 
light on the question above.


Thanks for any reply and sorry for my bad english.




Another thing: i noticed that vnc has all its parameters duplicated in
vfb too. For the moment I omissed them since i feel they are not
necessary - aren't they

It really depends on the answer to my questions above.

If SPICE is nothing to do with PVFB then it obviously makes no sense for
it to be separate.

If SPICE is just a backend for PVFB then it actually makes *more* sense
to expose spice as a PVFB configuration parameter than as a set of top
level options. The fact that VNC is exposed as a top level thing too is
somewhat anomalous but was done for xend compatibility (nb: it is the
top level duplicating the vfb VNC settings, not vice versa IMHO).

Ian.





Re: [Qemu-devel] [PATCH 0/4] Support more than 255 cpus

2014-05-13 Thread Jan Kiszka
On 2014-05-13 09:09, Li, Zhen-Hua wrote:
 From: Li, ZhenHua zhen-h...@hp.com
 
 These series patches are trying to make Qemu support more than 255 CPUs. 
 The max cpu number changed to 4096.
 
  Support more than 255 cpus: ACPI and APIC defines
  Support more than 255 cpus: max_cpus to 4096
  Support more than 255 cpus: max cpumask bit to 4096
  Support more than 255 cpus: runtime chec
 
  include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
  include/hw/i386/apic_internal.h| 2 +-
  include/hw/i386/pc.h | 2 +-
  include/sysemu/sysemu.h | 2 +-
  hw/i386/acpi-build.c | 8 

Don't we need x2APIC support to provide 255 CPUs? Where so you enforce
this, i.e. keep the restriction to 255 CPUs when we are not in KVM mode
with in-kernel APIC (the emulate APIC lacks x2APIC mode, unfortunately)?
But, wait, KVM only supports up to 255 VCPUs. So what are you targeting at?

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux



Re: [Qemu-devel] [PATCH v4] libxl: add basic spice support for pv domUs

2014-05-13 Thread Ian Campbell
On Tue, 2014-05-13 at 12:51 +0200, Fabio Fantoni wrote:
 Il 13/05/2014 11:50, Ian Campbell ha scritto:
  On Tue, 2014-05-13 at 10:00 +0200, Fabio Fantoni wrote:
  But: Does spice already require a VFB? In which case the existing
  handing of that will suffice.
 
  I think I'm probably confused about something: Does this patch
  enable/expose SPICE to the guest? Or does it simply enable the existing
  PVFB's output to be exposed from the qemu process to a spice client? I
  had been thinking this was a parallel feature to PVFB, but I'm starting
  to suspect this might actually be an additional feature *of* PVFB, which
  is correct? (I'm afraid that depending on which it is I might have to
  check back over my review to make sure I haven't suggested anything
  stupid)
 
  Does QXL change that answer?
  QXL and other emulated vga is now not supported on pv domUs because
  require an emulated pci bus and MMIO not supported on pv domUs FWIK.
  Right, but what about the previous paragraph? That was the important bit
  for me to understand, since it impacts the entire configuration model
  and libxl API.
 
  During my first test, I was enabled spice in pv domus but the guest wont
  show nothing while connecting to it.
  On my second shot, I've added -vga xenfb but it is deprecated. This way
  I've got at least video out but no mouse nor keyboard.
  Following the suggestions from Stefano Stabellini I've then activated
  vfb the same way as for vnc and i got it all working but mouse, which is
  only visible in some circumstances (such grafical debian installer) but
  always working (even if not visible).
  The last one is the actual patch.
  Probably the vfb part is not complete or at least improvable.
  Perhaps it is even not necessary if pvfb will became modified to works
  with spice, so domUs use this through its modules.
  Is SPICE a mechanism for exposing the PVFB or is it something entirely
  separate? That is the crux of my question above.
 
 I added also qemu-devel and spice-devel on cc:
 Any one on this please?
 
 
  I feel I'm not perfectly undrestanding pvfb. Please would you like
  better describe me this component?
  I need to understand what it is this patch is actually doing. I'm
  starting to worry that perhaps you don't understand either.
 
 Make possible using spice with basic features also on pv domUs.

*How* is the important thing. How is SPICE exposed to the guest? How is
SPICE exposed to the user/client?

I'm a bit surprised you've been pushing a patch to enable something
without knowing the answers to these sorts questions. If you don't
understand what it does how do you know it is doing the correct thing,
and how can you therefore explain it to the person reviewing the patch?

 Since emulated vgas is not supported on pv I use vfb instead, even if 
 this part is incomplete and rudimental.

What is incomplete and rudimentary?

 I'm waiting from some aswers from spice and qemu teams to share some 
 light on the question above.
 
 Thanks for any reply and sorry for my bad english.
 
 
  Another thing: i noticed that vnc has all its parameters duplicated in
  vfb too. For the moment I omissed them since i feel they are not
  necessary - aren't they
  It really depends on the answer to my questions above.
 
  If SPICE is nothing to do with PVFB then it obviously makes no sense for
  it to be separate.
 
  If SPICE is just a backend for PVFB then it actually makes *more* sense
  to expose spice as a PVFB configuration parameter than as a set of top
  level options. The fact that VNC is exposed as a top level thing too is
  somewhat anomalous but was done for xend compatibility (nb: it is the
  top level duplicating the vfb VNC settings, not vice versa IMHO).
 
  Ian.
 





Re: [Qemu-devel] KVM call agenda for 2014-05-13

2014-05-13 Thread Peter Crosthwaite
On Tuesday, May 13, 2014, Peter Maydell peter.mayd...@linaro.org wrote:

 On 13 May 2014 00:27, Peter Crosthwaite 
 peter.crosthwa...@xilinx.comjavascript:;
 wrote:
  Ok so here's my plan:

 This generally all sounds good to me. A slight nit:

  QOMify address spaces. So they can be instantiated, reffed etc.
  completely aside from the hotplug discussion this greatly helps
  connecting bus master devices using proper QOM links. E.G. using
  machine-set link properties rather address_space_memory everywhere.

 I'm not sure that the thing a bus master exposes to be connected
 up should be an AddressSpace -- I think it should be a MemoryRegion
 (more precisely, the code creating the bus-master should create
 a MemoryRegion and pass it to the bus-master device).


So this does alter the current thinking slightly, in that the current DMA
API has devices reffing addr spaces. I think the idea there is to provide
iommu capability?


 Consider a board model which puts together some RAM and
 devices. It ought to have the same interface for passing this
 up to the CPU whether it's doing so directly or via some SoC
 container device. For the SoC container case, this has to be
 by passing a MemoryRegion, since the SoC will want to add
 some devices of its own to create a combined board+SoC view to
 pass to the CPU object proper.


My thinking here is SoC can create an address space for it's masters to
master (cpu included) and add slave peripherals to its root MR. Both AS and
MR are then exposed to board level by the SoC for board level master and
slaves resp.


 So for consistency the interface
 for passing things to the CPU should also be a MemoryRegion
 (which the CPU then turns into an AddressSpace for its own
 internal use.)


Although if we pull this off without major change its definitely preffered
by me. AS vs MR confusion is an issue. Can we realistically convert all
master AS refs to MR?

Regards
Peter


 thanks
 -- PMM




Re: [Qemu-devel] [PULL 0/8] KVM changes for 2014-05-08

2014-05-13 Thread Paolo Bonzini

Il 13/05/2014 12:31, Cornelia Huck ha scritto:

On Sat, 10 May 2014 08:50:44 +0200
Paolo Bonzini pbonz...@redhat.com wrote:


The following changes since commit 3a87f8b6859e6221b827ab4737779dddb37553ec:

  Merge remote-tracking branch 'remotes/afaerber/tags/ppc-for-2.0' into staging 
(2014-03-20 11:45:38 +)

are available in the git repository at:


  git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master


I rebased to qemu/master, where compilation fails with

/home/cohuck/git/qemu/target-s390x/kvm.c:132: error: static declaration of 
‘kvm_set_one_reg’ follows non-static declaration
/home/cohuck/git/qemu/include/sysemu/kvm.h:383: error: previous declaration of 
‘kvm_set_one_reg’ was here
/home/cohuck/git/qemu/target-s390x/kvm.c:146: error: static declaration of 
‘kvm_get_one_reg’ follows non-static declaration
/home/cohuck/git/qemu/include/sysemu/kvm.h:393: error: previous declaration of 
‘kvm_get_one_reg’ was here


I'll resend the pull request, thanks.

Paolo




Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039

2014-05-13 Thread Markus Armbruster
Fam Zheng f...@redhat.com writes:

 On Tue, 05/13 10:46, Markus Armbruster wrote:
 The shell script attempts to suppress core dumps like this:
 
 old_ulimit=$(ulimit -c)
 ulimit -c 0
 $QEMU_IO arg...
 ulimit -c $old_ulimit
 
 This breaks the test hard unless the limit was zero to begin with!
 ulimit sets both hard and soft limit by default, and (re-)raising the
 hard limit requires privileges.  Broken since it was added in commit
 dc68afe.
 
 Could be fixed by adding -S to set only the soft limit, but I'm not
 sure how portable that is in practice.  Simply do it in a subshell
 instead, like this:
 
 (ulimit -c 0; exec $QEMU_IO arg...)
 
 Signed-off-by: Markus Armbruster arm...@redhat.com
 ---
  tests/qemu-iotests/039 | 18 ++
  1 file changed, 6 insertions(+), 12 deletions(-)
 
 diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
 index b9cbe99..182b0f0 100755
 --- a/tests/qemu-iotests/039
 +++ b/tests/qemu-iotests/039
 @@ -67,10 +67,8 @@ echo == Creating a dirty image file ==
  IMGOPTS=compat=1.1,lazy_refcounts=on
  _make_test_img $size
  
 -old_ulimit=$(ulimit -c)
 -ulimit -c 0 # do not produce a core dump on abort(3)
 -$QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG | _filter_qemu_io
 -ulimit -c $old_ulimit
 +(ulimit -c 0 # do not produce a core dump on abort(3)
 +exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
 _filter_qemu_io

 This works well.

 But when I try to put this in a function to avoid repeating:

 function _no_dump_exec()
 {
 (ulimit -c 0; exec $@)
 }

 _no_dump_exec $QEMU_IO -c write -P 0x5a 0 512 -c abort $TEST_IMG) | 
 _filter_qemu_io

 it doesn't work:

 039 1s ... - output mismatch (see 039.out.bad)
 --- 039.out 2014-05-13 12:10:39.248866480 +0800
 +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
 @@ -9,6 +9,7 @@

  == Creating a dirty image file ==
  Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 +./039: line 51: 10517 Aborted $@
  wrote 512/512 bytes at offset 0
  512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
  incompatible_features 0x1

 Any idea what the difference is here?

Full patch of your version, please.



  1   2   3   4   >