Re: [Qemu-devel] removing on-demand msix vector allocation

2012-12-06 Thread Jan Kiszka
On 2012-12-06 08:59, Michael S. Tsirkin wrote:
> I've been looking at handling of msix masking
> in qemu. It looks like all of virtio,vfio and
> device assignment implemented their own
> similar but slightly different thing.
> So I am inclined to move this handling to common
> code in msix.c, adding irqfd support right there.
> 
> While doing this rework, one of the more painful
> bits of code to change is the code that dynamically
> allocates msix table entries as we inject msi.
> If this actually triggers it's going to be
> painfully slow as route changes are rcu
> write side in kernel.
> Since recent kernels support direct injection,
> do we care anymore? I think if you run out of
> vectors, it's better to simply disable irqchip
> than try to limp along changing routes all the time.

But how would the logic without dynamic allocation look like? Always
configure a route in the PCI layer if an MSI/MSI-X entry is enabled?
That would also affect emulated devices that don't use irqfd, thus you
would waste routing entries. OTOH, if don't set up such routes, you
cannot support MSI/-X on older x86 kernels without direct vector injection.

Jan




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [ANNOUNCE] QEMU 1.3.0 release

2012-12-06 Thread Markus Armbruster
Gerhard Wiesinger  writes:

> On 03.12.2012 21:51, Anthony Liguori wrote:
>> Hi,
>>
>> Major features include:
>>   - After nearly 6 years of work, all remaining differences between the
>> qemu-kvm.git and qemu.git have been merged into qemu.git
>>
>
> How is qemu-kvm enabled?
> --enable-kvm ?

Yes.

> Is there a runtime only command line switch also available?

I didn't get that.



Re: [Qemu-devel] [PATCH v5 00/11] virtio: virtio-blk data plane

2012-12-06 Thread Stefan Hajnoczi
On Thu, Dec 06, 2012 at 01:38:28PM +0200, Michael S. Tsirkin wrote:
> On Wed, Dec 05, 2012 at 09:46:59PM +0100, Stefan Hajnoczi wrote:
> > This series adds the -device virtio-blk-pci,x-data-plane=on property that
> > enables a high performance I/O codepath.  A dedicated thread is used to 
> > process
> > virtio-blk requests outside the global mutex and without going through the 
> > QEMU
> > block layer.
> > 
> > Khoa Huynh  reported an increase from 140,000 IOPS to 
> > 600,000
> > IOPS for a single VM using virtio-blk-data-plane in July:
> > 
> >   http://comments.gmane.org/gmane.comp.emulators.kvm.devel/94580
> > 
> > The virtio-blk-data-plane approach was originally presented at Linux 
> > Plumbers
> > Conference 2010.  The following slides contain a brief overview:
> > 
> >   
> > http://linuxplumbersconf.org/2010/ocw/system/presentations/651/original/Optimizing_the_QEMU_Storage_Stack.pdf
> > 
> > The basic approach is:
> > 1. Each virtio-blk device has a thread dedicated to handling ioeventfd
> >signalling when the guest kicks the virtqueue.
> > 2. Requests are processed without going through the QEMU block layer using
> >Linux AIO directly.
> > 3. Completion interrupts are injected via irqfd from the dedicated thread.
> > 
> > To try it out:
> > 
> >   qemu -drive if=none,id=drive0,cache=none,aio=native,format=raw,file=...
> >-device virtio-blk-pci,drive=drive0,scsi=off,x-data-plane=on
> > 
> > Limitations:
> >  * Only format=raw is supported
> >  * Live migration is not supported
> >  * Block jobs, hot unplug, and other operations fail with -EBUSY
> >  * I/O throttling limits are ignored
> >  * Only Linux hosts are supported due to Linux AIO usage
> > 
> > The code has reached a stage where I feel it is ready to merge.  Users have
> > been playing with it for some time and want the significant performance 
> > boost.
> > 
> > We are refactoring QEMU to get rid of the global mutex.  I believe that
> > virtio-blk-data-plane can eventually become the default mode of operation.
> > 
> > Instead of waiting for global mutex removal efforts to finish, I want to use
> > virtio-blk-data-plane as an example device for AioContext and threaded hw
> > dispatch refactoring.  This means:
> > 
> > 1. When the block layer can bind to an AioContext and execute I/O outside 
> > the
> >global mutex, virtio-blk-data-plane can use this (and gain image format
> >support).
> > 
> > 2. When hw dispatch no longer needs the global mutex we can use hw/virtio.c
> >again and perhaps run a pool of iothreads instead of dedicated data plane
> >threads.
> > 
> > But in the meantime, I have cleaned up the virtio-blk-data-plane code so 
> > that
> > it can be merged as an experimental feature.
> 
> I mostly looked at the virtio side of the patchset.
> I don't see any bugs here. I sent some improvement suggestions but
> we can do them in tree as well.

Thanks Michael.  I'll send follow-up patches to split the iov_discard()
function and to address config-wce.

Stefan



Re: [Qemu-devel] [PATCH v5 10/11] dataplane: add virtio-blk data plane code

2012-12-06 Thread Stefan Hajnoczi
On Thu, Dec 06, 2012 at 08:35:55AM +0100, Paolo Bonzini wrote:
> Il 05/12/2012 21:47, Stefan Hajnoczi ha scritto:
> > +
> > +/* Block until pending requests have completed
> > + *
> > + * The vring continues to be serviced so ensure no new requests will be 
> > added
> > + * to avoid races.
> > + */
> > +void virtio_blk_data_plane_drain(VirtIOBlockDataPlane *s)
> > +{
> > +qemu_mutex_lock(&s->num_reqs_lock);
> > +while (s->num_reqs > 0) {
> > +qemu_cond_wait(&s->no_reqs_cond, &s->num_reqs_lock);
> > +}
> > +qemu_mutex_unlock(&s->num_reqs_lock);
> > +}
> 
> Hi Stefan,
> 
> so this was not changed from v4?

BTW I should go into slightly more detail about why I stopped short of
implementing the notify+join approach.

notify+join means stopping the event loop and data plane thread so
that the caller is sure that virtio-blk-data-plane is quiesced.

Unfortunately this doesn't map nicely to bdrv_drain_all() where the
caller has the global mutex, quiesces I/O, and then performs a critical
operation.  I/O resumes after the caller returns or releases the global
mutex:

bdrv_drain_all();
critical_operation();
return;
/* now it's okay to process I/O again */

We cannot use notify+join here because bdrv_drain_all() would stop the
data plane thread but nothing restarts it!

Perhaps we'd need a "resume" call after the critical operation so that
the data plane thread is restarted - but this sounds invasive and is a
departure from how existing I/O and emulated devices work.

Stefan



Re: [Qemu-devel] [PATCH v5 10/11] dataplane: add virtio-blk data plane code

2012-12-06 Thread Stefan Hajnoczi
On Thu, Dec 06, 2012 at 08:35:55AM +0100, Paolo Bonzini wrote:
> Il 05/12/2012 21:47, Stefan Hajnoczi ha scritto:
> > +
> > +/* Block until pending requests have completed
> > + *
> > + * The vring continues to be serviced so ensure no new requests will be 
> > added
> > + * to avoid races.
> > + */
> > +void virtio_blk_data_plane_drain(VirtIOBlockDataPlane *s)
> > +{
> > +qemu_mutex_lock(&s->num_reqs_lock);
> > +while (s->num_reqs > 0) {
> > +qemu_cond_wait(&s->no_reqs_cond, &s->num_reqs_lock);
> > +}
> > +qemu_mutex_unlock(&s->num_reqs_lock);
> > +}
> 
> Hi Stefan,
> 
> so this was not changed from v4?

It's unchanged.  From the v5 cover letter:

 * Note I did not get rid of the mutex+condvar approach to draining
   requests.  I've had good feedback on the performance of the patch
   series so I'm not worried about eliminating the lock (it's very
   rarely contended).  Hope Michael and Paolo are okay with this
   approach.

Stefan



Re: [Qemu-devel] [PATCH v5 00/11] virtio: virtio-blk data plane

2012-12-06 Thread Stefan Hajnoczi
On Fri, Dec 07, 2012 at 10:43:24AM +0800, Liu Yuan wrote:
> On 12/06/2012 04:46 AM, Stefan Hajnoczi wrote:
> > Limitations:
> >  * Only format=raw is supported
> 
> The boost number looks promising, but support of other format(which
> might as well fit into this new IO path design) is in the plan? It seems
> that bypassing block layer would end up adding yet another 'block layer'
> as we add more format support.

Right, that's why the next step is to complete the AioContext work that
Paolo recently contributed.  It will allow us to run the QEMU block
layer outside the global mutex.

Once that refactoring is complete the data plane thread will be able to
run image format code.

We'll need to be careful so as not to lose the level of performance that
it achieves right now, but there is no fundamental reason why we cannot
continue to keep this level of performance while still supporting image
formats.

Stefan



Re: [Qemu-devel] [PATCH v5 10/11] dataplane: add virtio-blk data plane code

2012-12-06 Thread Stefan Hajnoczi
On Thu, Dec 06, 2012 at 01:33:58PM +0200, Michael S. Tsirkin wrote:
> On Wed, Dec 05, 2012 at 09:47:09PM +0100, Stefan Hajnoczi wrote:
> > virtio-blk-data-plane is a subset implementation of virtio-blk.
> 
> I already asked this:
> 
> what confuses me a bit is how, being a subset, it exposes the
> same feature bits. For example wce config is ineffective, right?
> So I think it should not expose WCE feature bit.

It works like vhost - the virtio negotiation and setup is still handled
by QEMU but the actual vring processing is done by dataplane.

virtio-blk-data-plane works with cache=none.  You're right that WCE
should not be toggled because we don't automatically flush after every
request.

Stefan



Re: [Qemu-devel] [RFC 3/3] docs: document virtio-balloon stats

2012-12-06 Thread Dietmar Maurer
> +The memory statistics are:
> +
> + o stat-swap-in
> + o stat-swap-out
> + o stat-major-faults
> + o stat-minor-faults
> + o stat-free-memory
> + o stat-total-memory

I want to implement an automatic ballooning policy, so I need to
know the amount of free RAM inside the guest.

But it seem that the balloon driver reports free ram without accounting
buffers and cache.

Is it possible to extent those statistic to include buffer/cache values?





[Qemu-devel] [PATCH] target-arm: GIC: bug fixes for arm_gic.c

2012-12-06 Thread Daniel Sangorrin
Hi, I found some bugs in the way the IRQ number is calculated
at certain places in arm_gic.c. Perhaps there are a few more
errors that I didn't notice. These bugs were not noticeable
when running Linux as a guest, but I found them when running
my own porting of a multicore real-time OS (TOPPERS/FMP).

NOTE: the main problem I had was that the target CPUs where not
set correctly. Instead of GIC_SET_PENDING(irq + i, GIC_TARGET(irq));
it should read as GIC_SET_PENDING(irq + i, GIC_TARGET(irq + i));

I have tested the patch both with FMP and with a recent Linux, but
please review it since I'm not an expert on QEMU and this is my
first patch.

target-arm: bug fixes for arm_gic.c

The IRQ number was not calculated correctly in the
function gic_dist_writeb for accesses to set/clear
pending and set/clear enable.

Signed-off-by: Daniel Sangorrin 
---
 hw/arm_gic.c |   90 --
 1 file changed, 50 insertions(+), 40 deletions(-)

diff --git a/hw/arm_gic.c b/hw/arm_gic.c
index f9e423f..f3f233c 100644
--- a/hw/arm_gic.c
+++ b/hw/arm_gic.c
@@ -368,71 +368,81 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
 } else if (offset < 0x180) {
 /* Interrupt Set Enable.  */
 irq = (offset - 0x100) * 8 + GIC_BASE_IRQ;
+for (i = 0; i < 8; i++) {
+if (value & (1 << i)) {
+irq = irq + i;
+break;
+}
+}
 if (irq >= s->num_irq)
 goto bad_reg;
 if (irq < 16)
-  value = 0xff;
-for (i = 0; i < 8; i++) {
-if (value & (1 << i)) {
-int mask = (irq < GIC_INTERNAL) ? (1 << cpu) : GIC_TARGET(irq);
-int cm = (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK;
+value = 0xff;
+int mask = (irq < GIC_INTERNAL) ? (1 << cpu) : GIC_TARGET(irq);
+int cm = (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK;

-if (!GIC_TEST_ENABLED(irq + i, cm)) {
-DPRINTF("Enabled IRQ %d\n", irq + i);
-}
-GIC_SET_ENABLED(irq + i, cm);
-/* If a raised level triggered IRQ enabled then mark
-   is as pending.  */
-if (GIC_TEST_LEVEL(irq + i, mask)
-&& !GIC_TEST_TRIGGER(irq + i)) {
-DPRINTF("Set %d pending mask %x\n", irq + i, mask);
-GIC_SET_PENDING(irq + i, mask);
-}
-}
+if (!GIC_TEST_ENABLED(irq, cm)) {
+DPRINTF("Enabled IRQ %d\n", irq);
+}
+GIC_SET_ENABLED(irq, cm);
+/* If a raised level triggered IRQ enabled then mark is as pending */
+if (GIC_TEST_LEVEL(irq, mask) && !GIC_TEST_TRIGGER(irq)) {
+DPRINTF("Set %d pending mask %x\n", irq, mask);
+GIC_SET_PENDING(irq, mask);
 }
 } else if (offset < 0x200) {
 /* Interrupt Clear Enable.  */
 irq = (offset - 0x180) * 8 + GIC_BASE_IRQ;
-if (irq >= s->num_irq)
-goto bad_reg;
-if (irq < 16)
-  value = 0;
 for (i = 0; i < 8; i++) {
 if (value & (1 << i)) {
-int cm = (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK;
-
-if (GIC_TEST_ENABLED(irq + i, cm)) {
-DPRINTF("Disabled IRQ %d\n", irq + i);
-}
-GIC_CLEAR_ENABLED(irq + i, cm);
+irq = irq + i;
+break;
 }
 }
-} else if (offset < 0x280) {
-/* Interrupt Set Pending.  */
-irq = (offset - 0x200) * 8 + GIC_BASE_IRQ;
 if (irq >= s->num_irq)
 goto bad_reg;
 if (irq < 16)
-  irq = 0;
+value = 0;
+
+int cm = (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK;

+if (GIC_TEST_ENABLED(irq, cm)) {
+DPRINTF("Disabled IRQ %d\n", irq);
+}
+GIC_CLEAR_ENABLED(irq, cm);
+} else if (offset < 0x280) {
+/* Interrupt Set Pending.  */
+irq = (offset - 0x200) * 8 + GIC_BASE_IRQ;
 for (i = 0; i < 8; i++) {
 if (value & (1 << i)) {
-GIC_SET_PENDING(irq + i, GIC_TARGET(irq));
+irq = irq + i;
+break;
 }
 }
+
+if (irq >= s->num_irq) {
+goto bad_reg;
+}
+if (irq < 16) {
+irq = 0;
+}
+
+GIC_SET_PENDING(irq, GIC_TARGET(irq));
 } else if (offset < 0x300) {
 /* Interrupt Clear Pending.  */
 irq = (offset - 0x280) * 8 + GIC_BASE_IRQ;
-if (irq >= s->num_irq)
-goto bad_reg;
 for (i = 0; i < 8; i++) {
-/* ??? This currently clears the pending bit for all CPUs, even
-   for per-CPU interrupts.  It's unclear whether this is the
-   corect behavior.  */
-if (value & (1 <<

Re: [Qemu-devel] [PATCH v4] correct error message qemu-img reported

2012-12-06 Thread li guang
在 2012-12-06四的 11:04 +0100,Kevin Wolf写道:
> Am 05.11.2012 08:41, schrieb liguang:
> > qemu-img will complain when qcow or qcow2
> > size overflow for 64 bits, report the right
> > message in this condition.
> > 
> > Signed-off-by: liguang 
> > ---
> >  qemu-img.c |7 ++-
> >  1 files changed, 6 insertions(+), 1 deletions(-)
> > 
> > diff --git a/qemu-img.c b/qemu-img.c
> > index b41e670..d9434ad 100644
> > --- a/qemu-img.c
> > +++ b/qemu-img.c
> > @@ -340,7 +340,12 @@ static int img_create(int argc, char **argv)
> >  int64_t sval;
> >  char *end;
> >  sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
> > -if (sval < 0 || *end) {
> > +if (sval < 0) {
> > +error_report("Image size must be less than 8 exabytes!");
> > +ret = -1;
> > +goto out;
> > +}
> 
> This is wrong, overflows are not the only way how strtosz_suffix() can fail.
> 
> Before this patch:
> 
> $ ./qemu-img create /tmp/foo bar
> qemu-img: Invalid image size specified! You may use k, M, G or T
> suffixes for
> qemu-img: kilobytes, megabytes, gigabytes and terabytes
> 
> With the patch applied:
> 
> $ ./qemu-img create /tmp/foo bar
> qemu-img: Image size must be less than 8 exabytes!
> 

Oh, my fault, I'll fix.
Thanks!

> Kevin
> 
> 
> > +if (*end) {
> >  error_report("Invalid image size specified! You may use k, M, 
> > G or "
> >"T suffixes for ");
> >  error_report("kilobytes, megabytes, gigabytes and terabytes.");
> > 
> 
> 
> 

-- 
regards!
li guang




[Qemu-devel] [ [PATCH 2/2] qemu-img:report size overflow error message

2012-12-06 Thread liguang
qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.

Signed-off-by: liguang 
---
 qemu-img.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index e29e01b..f3209b4 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -353,6 +353,11 @@ static int img_create(int argc, char **argv)
 ret = -1;
 goto out;
 }
+if (sval == 0) {
+error_report("Image size must be less than 8 exabytes!");
+ret = -1;
+goto out;
+}
 img_size = (uint64_t)sval;
 }
 
-- 
1.7.2.5




[Qemu-devel] [ [PATCH 1/2] cutils:change strtosz_suffix_unit function

2012-12-06 Thread liguang
if value to be translated is larger than INT64_MAX,
this function will not be convenient for caller to
be aware of it, so change a little for this.

Signed-off-by: liguang 
---
 cutils.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cutils.c b/cutils.c
index 4f0692f..8905b5e 100644
--- a/cutils.c
+++ b/cutils.c
@@ -219,11 +219,11 @@ static int64_t suffix_mul(char suffix, int64_t unit)
 int64_t strtosz_suffix_unit(const char *nptr, char **end,
 const char default_suffix, int64_t unit)
 {
-int64_t retval = -1;
+int64_t retval = -1, mul;
 char *endptr;
 unsigned char c;
 int mul_required = 0;
-double val, mul, integral, fraction;
+double val, integral, fraction;
 
 errno = 0;
 val = strtod(nptr, &endptr);
@@ -246,6 +246,7 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end,
 goto fail;
 }
 if ((val * mul >= INT64_MAX) || val < 0) {
+retval = 0;
 goto fail;
 }
 retval = val * mul;
-- 
1.7.2.5




Re: [Qemu-devel] [PATCH v5 00/11] virtio: virtio-blk data plane

2012-12-06 Thread Liu Yuan
Hi Stefan,

On 12/06/2012 04:46 AM, Stefan Hajnoczi wrote:
> Limitations:
>  * Only format=raw is supported

The boost number looks promising, but support of other format(which
might as well fit into this new IO path design) is in the plan? It seems
that bypassing block layer would end up adding yet another 'block layer'
as we add more format support.

Thanks,
Yuan



[Qemu-devel] [PATCH] net, hub: fix the indent in the comments

2012-12-06 Thread zwu . kernel
From: Zhi Yong Wu 

  Remove some redundant blanks in the comments of
net_hub_id_for_client().

Signed-off-by: Zhi Yong Wu 
---
 net/hub.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/hub.c b/net/hub.c
index be41301..3b2d1ff 100644
--- a/net/hub.c
+++ b/net/hub.c
@@ -256,7 +256,7 @@ void net_hub_info(Monitor *mon)
 /**
  * Get the hub id that a client is connected to
  *
- * @id  Pointer for hub id output, may be NULL
+ * @id: Pointer for hub id output, may be NULL
  */
 int net_hub_id_for_client(NetClientState *nc, int *id)
 {
-- 
1.7.6.5




[Qemu-devel] [PATCH v3 2/3] target-i386:make hw_breakpoint_enabled return bool type

2012-12-06 Thread liguang
Signed-off-by: liguang 
---
 target-i386/cpu.h |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 29245d1..3646128 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -996,9 +996,20 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, 
target_ulong addr,
 #define cpu_handle_mmu_fault cpu_x86_handle_mmu_fault
 void cpu_x86_set_a20(CPUX86State *env, int a20_state);
 
-static inline int hw_breakpoint_enabled(unsigned long dr7, int index)
+static inline bool hw_local_breakpoint_enabled(unsigned long dr7, int index)
 {
-return (dr7 >> (index * 2)) & 3;
+return !(((dr7 >> (index * 2)) ^ 1) & 3);
+}
+
+static inline bool hw_global_breakpoint_enabled(unsigned long dr7, int index)
+{
+return !!((dr7 >> (index * 2)) & 2);
+}
+
+static inline bool hw_breakpoint_enabled(unsigned long dr7, int index)
+{
+return (hw_global_breakpoint_enabled(dr7, index) ||
+hw_local_breakpoint_enabled(dr7, index));
 }
 
 static inline int hw_breakpoint_type(unsigned long dr7, int index)
-- 
1.7.2.5




[Qemu-devel] [PATCH v3 3/3] target-i386:slightly refactor dr7 related function

2012-12-06 Thread liguang
Signed-off-by: liguang 
---
 target-i386/helper.c  |   74 +---
 target-i386/machine.c |5 ++-
 target-i386/misc_helper.c |4 +-
 target-i386/seg_helper.c  |6 ++--
 4 files changed, 57 insertions(+), 32 deletions(-)

diff --git a/target-i386/helper.c b/target-i386/helper.c
index bf206cf..62746c5 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -966,30 +966,33 @@ hwaddr cpu_get_phys_page_debug(CPUX86State *env, 
target_ulong addr)
 
 void hw_breakpoint_insert(CPUX86State *env, int index)
 {
-int type, err = 0;
+int type = 0, err = 0;
 
 switch (hw_breakpoint_type(env->dr[7], index)) {
-case 0:
-if (hw_breakpoint_enabled(env->dr[7], index))
+case DR7_TYPE_BP_INST:
+if (hw_breakpoint_enabled(env->dr[7], index)) {
 err = cpu_breakpoint_insert(env, env->dr[index], BP_CPU,
 &env->cpu_breakpoint[index]);
+}
 break;
-case 1:
+case DR7_TYPE_DATA_WR:
 type = BP_CPU | BP_MEM_WRITE;
-goto insert_wp;
-case 2:
- /* No support for I/O watchpoints yet */
 break;
-case 3:
+case DR7_TYPE_DATA_RW:
 type = BP_CPU | BP_MEM_ACCESS;
-insert_wp:
+break;
+   case DR7_TYPE_IO_RW:
+/* No support for I/O watchpoints yet */
+break;
+}
+   if (type) {
 err = cpu_watchpoint_insert(env, env->dr[index],
 hw_breakpoint_len(env->dr[7], index),
 type, &env->cpu_watchpoint[index]);
-break;
 }
-if (err)
+if (err) {
 env->cpu_breakpoint[index] = NULL;
+}
 }
 
 void hw_breakpoint_remove(CPUX86State *env, int index)
@@ -997,15 +1000,16 @@ void hw_breakpoint_remove(CPUX86State *env, int index)
 if (!env->cpu_breakpoint[index])
 return;
 switch (hw_breakpoint_type(env->dr[7], index)) {
-case 0:
-if (hw_breakpoint_enabled(env->dr[7], index))
+case DR7_TYPE_BP_INST:
+if (hw_breakpoint_enabled(env->dr[7], index)) {
 cpu_breakpoint_remove_by_ref(env, env->cpu_breakpoint[index]);
+}
 break;
-case 1:
-case 3:
+case DR7_TYPE_DATA_RW:
+case DR7_TYPE_DATA_WR:
 cpu_watchpoint_remove_by_ref(env, env->cpu_watchpoint[index]);
 break;
-case 2:
+case DR7_TYPE_IO_RW:
 /* No support for I/O watchpoints yet */
 break;
 }
@@ -1014,22 +1018,42 @@ void hw_breakpoint_remove(CPUX86State *env, int index)
 int check_hw_breakpoints(CPUX86State *env, int force_dr6_update)
 {
 target_ulong dr6;
-int reg, type;
+int index;
 int hit_enabled = 0;
+bool bp_match = false;
+bool wp_match = false;
 
 dr6 = env->dr[6] & ~0xf;
-for (reg = 0; reg < 4; reg++) {
-type = hw_breakpoint_type(env->dr[7], reg);
-if ((type == 0 && env->dr[reg] == env->eip) ||
-((type & 1) && env->cpu_watchpoint[reg] &&
- (env->cpu_watchpoint[reg]->flags & BP_WATCHPOINT_HIT))) {
-dr6 |= 1 << reg;
-if (hw_breakpoint_enabled(env->dr[7], reg))
+   for (index = 0; index < DR7_MAX_BP; index++) {
+switch (hw_breakpoint_type(env->dr[7], index)) {
+case DR7_TYPE_BP_INST:
+if (env->dr[index] == env->eip) {
+bp_match = true;
+}
+break;
+case DR7_TYPE_DATA_WR:
+case DR7_TYPE_DATA_RW:
+if (env->cpu_watchpoint[index] &&
+env->cpu_watchpoint[index]->flags & BP_WATCHPOINT_HIT) {
+wp_match = true;
+}
+   break;
+case DR7_TYPE_IO_RW:
+break;
+}
+if (bp_match || wp_match) {
+dr6 |= 1 << index;
+if (hw_breakpoint_enabled(env->dr[7], index)) {
 hit_enabled = 1;
+}
+bp_match = false;
+wp_match = false;
 }
 }
-if (hit_enabled || force_dr6_update)
+if (hit_enabled || force_dr6_update) {
 env->dr[6] = dr6;
+   }
+
 return hit_enabled;
 }
 
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 4771508..67131a4 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -265,10 +265,11 @@ static int cpu_post_load(void *opaque, int version_id)
 
 cpu_breakpoint_remove_all(env, BP_CPU);
 cpu_watchpoint_remove_all(env, BP_CPU);
-for (i = 0; i < 4; i++)
+for (i = 0; i < DR7_MAX_BP; i++) {
 hw_breakpoint_insert(env, i);
-
+   }
 tlb_flush(env, 1);
+
 return 0;
 }
 
diff --git a/target-i386/misc_helper.c b/target-i386/misc_helper.c
index a020379..5ee0863 100644
--- a/target-i386/misc_helper.c
+++ b/target-i386/misc_helper.c
@@ -197,11 +197,11 @@ void helper_movl_drN_T0(CPUX86State *env, int reg, 
target_ulong t0)
 env->dr[reg] = t0;
 hw_breakpoint_insert(env, reg);
   

[Qemu-devel] [PATCH v3 1/3] target-i386:define name of breakpoint bit in dr7

2012-12-06 Thread liguang
Signed-off-by: liguang 
---
 target-i386/cpu.h |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 90ef1ff..29245d1 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -231,6 +231,13 @@
 #define DR7_TYPE_SHIFT  16
 #define DR7_LEN_SHIFT   18
 #define DR7_FIXED_1 0x0400
+#define DR7_LOCAL_BP_MASK   0x55
+#define DR7_MAX_BP  4
+#define DR7_TYPE_BP_INST 0x0
+#define DR7_TYPE_DATA_WR 0x1
+#define DR7_TYPE_IO_RW   0x2
+#define DR7_TYPE_DATA_RW 0x3
+
 
 #define PG_PRESENT_BIT 0
 #define PG_RW_BIT  1
-- 
1.7.2.5




[Qemu-devel] [PATCH v3 0/3] target-i386:make breakpoint more cleaner

2012-12-06 Thread li guang
try to make breakpoint related functions
more cleaner.
originally, these functions implicit use
0,1,2,3 as name of breakpoint, really
hard to understand, so name them readable,
and also refactor the statement to
check these types for clean reason.

v2 changes:
1. split 'breakpoint_enabled' into '{local,global}_enable'
2. add some braces for if statement

v3 change:
rework functions hw_local_breakpoint_enabled

 target-i386/cpu.h |22 ++--
 target-i386/helper.c  |74 --
 target-i386/machine.c |5  +-
 target-i386/misc_helper.c |4  +-
 target-i386/seg_helper.c  |6  ++--
 5 files changed, 77 insertions(+), 34 deletions(-)

-- 
regards!
li guang




Re: [Qemu-devel] [PATCH 3/3] target-i386:slightly refactor dr7 related function

2012-12-06 Thread li guang
在 2012-12-06四的 09:48 +,Peter Maydell写道:
> On 6 December 2012 09:36, Andreas Färber  wrote:
> > Am 06.12.2012 10:27, schrieb li guang:
> >> 在 2012-12-06四的 09:23 +,Peter Maydell写道:
> >>> On 6 December 2012 09:16, li guang  wrote:
>  在 2012-12-06四的 08:54 +,Peter Maydell写道:
> > On 6 December 2012 03:03, liguang  wrote:
> >> Signed-off-by: liguang 
> >> --- a/target-i386/seg_helper.c
> >> +++ b/target-i386/seg_helper.c
> >> @@ -465,9 +465,9 @@ static void switch_tss(CPUX86State *env, int 
> >> tss_selector,
> >>
> >>  #ifndef CONFIG_USER_ONLY
> >>  /* reset local breakpoints */
> >> -if (env->dr[7] & 0x55) {
> >> -for (i = 0; i < 4; i++) {
> >> -if (hw_breakpoint_enabled(env->dr[7], i) == 0x1) {
> >> +if (env->dr[7] & DR7_LOCAL_BP_MASK) {
> >> +for (i = 0; i < DR7_MAX_BP; i++) {
> >> +if (hw_breakpoint_enabled(env->dr[7], i)) {
> >>  hw_breakpoint_remove(env, i);
> >>  }
> >>  }
> >
> > This is still wrong.
> 
>  do you mean the use of 'hw_breakpoint_enabled'? or others?
>  maybe a mistake, I change it to 'hw_local_breakpoint_enabled'.
>  if it is I'll re-send a corrected patch.
> >>>
> >>> I mean that in the comments on the previous version of this
> >>> patchseet we explained that this check is specifically checking
> >>> for whether the breakpoint is enabled locally, and that your
> >>> change to just returning bool broke this. And in this version
> >>> of the patch there is still exactly the same problem.
> >>
> >> why broke?
> >> this function just ask if breakpoint 'i' was enable,
> >> so we answer enabled or not? 2 simple cases, any problem?
> >
> > The code comment specifically says "reset local breakpoints". IIUC you
> > are also resetting global breakpoints, which you shouldn't.
> >
> > Personally I'd be fine with a hw_local_breakpoint_enabled().
> 
> The check you want is
>  (hw_local_breakpoint_enabled() && !hw_global_breakpoint_enabled())
> 

Yes, it's the right choice.
Thanks!

> if you're going to do it like that. [We don't want to take out the
> bp if it was enabled globally as well as locally.]
> 
> -- PMM
> 

-- 
regards!
li guang




[Qemu-devel] [PATCH] gitignore: Add virtfs-proxy-helper

2012-12-06 Thread Cole Robinson

Signed-off-by: Cole Robinson 
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index bd6ba1c..3ce57cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,7 @@ test-qmp-output-visitor
 test-string-input-visitor
 test-string-output-visitor
 test-visitor-serialization
+fsdev/virtfs-proxy-helper
 fsdev/virtfs-proxy-helper.1
 fsdev/virtfs-proxy-helper.pod
 .gdbinit
-- 
1.8.0




Re: [Qemu-devel] [BUG] QEMU crashes when 64bit BAR is present

2012-12-06 Thread Alexey Korolev
On 06/12/12 20:45, Gerd Hoffmann wrote:
> On 12/06/12 05:09, Alexey Korolev wrote:
>> I tried the head today.
>> Qemu crashes in the same way as before.
> Hmm.  Doesn't reproduce here (using RHEL-5 as guest, although it is 5.8
> so more recent than your centos 5.5).
>
> Is this a 32bit or 64bit guest?
It is a 64bit guest OS.
I've upgraded to RHEL 5.8 and still have the same problem.
Could you please send me a qemu command line you are running?



Re: [Qemu-devel] [PATCH] virtio: verify that all outstanding buffers are flushed (was Re: vmstate conversion for virtio?)

2012-12-06 Thread Rusty Russell
"Michael S. Tsirkin"  writes:

> On Thu, Dec 06, 2012 at 04:33:06PM +1030, Rusty Russell wrote:
>> "Michael S. Tsirkin"  writes:
>> > Add sanity check to address the following concern:
>> >
>> > On Wed, Dec 05, 2012 at 09:47:22AM +1030, Rusty Russell wrote:
>> >> All we need is the index of the request; the rest can be re-read from
>> >> the ring.
>> 
>> The terminology I used here was loose, indeed.
>> 
>> We need the head of the chained descriptor, which we already read from
>> the ring when we gathered the request.
>
> So ack that patch?

No, because I don't understand it.  Is it true for the case of
virtio_blk, which has outstanding requests?

>> Currently we dump a massive structure; it's inelegant at the very least.
>> 
>> Cheers,
>> Rusty.
>
> Hmm not sure what you refer to. I see this per ring:
>
> qemu_put_be32(f, vdev->vq[i].vring.num);
> qemu_put_be64(f, vdev->vq[i].pa);
> qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
>
> Looks like there's no way around savng these fields.

Not what I'm referring to.  See here:

virtio.h defines a 48k structure:

#define VIRTQUEUE_MAX_SIZE 1024

typedef struct VirtQueueElement
{
unsigned int index;
unsigned int out_num;
unsigned int in_num;
hwaddr in_addr[VIRTQUEUE_MAX_SIZE];
hwaddr out_addr[VIRTQUEUE_MAX_SIZE];
struct iovec in_sg[VIRTQUEUE_MAX_SIZE];
struct iovec out_sg[VIRTQUEUE_MAX_SIZE];
} VirtQueueElement;

virtio-blk.c uses it in its request struct:

typedef struct VirtIOBlockReq
{
VirtIOBlock *dev;
VirtQueueElement elem;
struct virtio_blk_inhdr *in;
struct virtio_blk_outhdr *out;
struct virtio_scsi_inhdr *scsi;
QEMUIOVector qiov;
struct VirtIOBlockReq *next;
BlockAcctCookie acct;
} VirtIOBlockReq;

... and saves it in virtio_blk_save:

static void virtio_blk_save(QEMUFile *f, void *opaque)
{
VirtIOBlock *s = opaque;
VirtIOBlockReq *req = s->rq;

virtio_save(&s->vdev, f);

while (req) {
qemu_put_sbyte(f, 1);
qemu_put_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem));
req = req->next;
}
qemu_put_sbyte(f, 0);
}

Cheers,
Rusty.



Re: [Qemu-devel] [PATCH 2/2] target-i386: use visit_type_unit_suffixed_int() to parse tsc_freq property value

2012-12-06 Thread mdroth
On Thu, Dec 06, 2012 at 10:12:05PM +0100, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov 

Reviewed-by: Michael Roth 

> ---
>   v2:
>- replace visit_type_freq() with visit_type_unit_suffixed_int()
>  in x86_cpuid_set_tsc_freq()
> ---
>  target-i386/cpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index c6c2ca0..b7f0aba 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1195,7 +1195,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor 
> *v, void *opaque,
>  const int64_t max = INT64_MAX;
>  int64_t value;
> 
> -visit_type_int(v, &value, name, errp);
> +visit_type_unit_suffixed_int(v, &value, name, 1000, errp);
>  if (error_is_set(errp)) {
>  return;
>  }
> -- 
> 1.7.11.7
> 



Re: [Qemu-devel] [PATCH 1/2] qapi: add visitor for parsing int[KMGT] input string

2012-12-06 Thread mdroth
On Thu, Dec 06, 2012 at 10:12:04PM +0100, Igor Mammedov wrote:
> Caller of visit_type_unit_suffixed_int() will have to specify
> value of 'K' suffix via unit argument.
> For Kbytes it's 1024, for Khz it's 1000.
> 
> Signed-off-by: Igor Mammedov 

Reviewed-by: Michael Roth 

> ---
>  v2:
>   - convert type_freq to type_unit_suffixed_int.
>   - provide qapi_dealloc_type_unit_suffixed_int() impl.
> ---
>  qapi/qapi-dealloc-visitor.c |  7 +++
>  qapi/qapi-visit-core.c  | 13 +
>  qapi/qapi-visit-core.h  |  8 
>  qapi/string-input-visitor.c | 22 ++
>  4 files changed, 50 insertions(+)
> 
> diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
> index 75214e7..57e662c 100644
> --- a/qapi/qapi-dealloc-visitor.c
> +++ b/qapi/qapi-dealloc-visitor.c
> @@ -143,6 +143,12 @@ static void qapi_dealloc_type_enum(Visitor *v, int *obj, 
> const char *strings[],
>  {
>  }
> 
> +static void qapi_dealloc_type_unit_suffixed_int(Visitor *v, int64_t *obj,
> +const char *name,
> +const int unit, Error **errp)
> +{
> +}
> +
>  Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v)
>  {
>  return &v->visitor;
> @@ -170,6 +176,7 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
>  v->visitor.type_str = qapi_dealloc_type_str;
>  v->visitor.type_number = qapi_dealloc_type_number;
>  v->visitor.type_size = qapi_dealloc_type_size;
> +v->visitor.type_unit_suffixed_int = qapi_dealloc_type_unit_suffixed_int;
> 
>  QTAILQ_INIT(&v->stack);
> 
> diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
> index 7a82b63..dcbc1a9 100644
> --- a/qapi/qapi-visit-core.c
> +++ b/qapi/qapi-visit-core.c
> @@ -311,3 +311,16 @@ void input_type_enum(Visitor *v, int *obj, const char 
> *strings[],
>  g_free(enum_str);
>  *obj = value;
>  }
> +
> +void visit_type_unit_suffixed_int(Visitor *v, int64_t *obj, const char *name,
> +  const int unit, Error **errp)
> +{
> +if (!error_is_set(errp)) {
> +return;
> +}
> +if (v->type_unit_suffixed_int) {
> +v->type_unit_suffixed_int(v, obj, name, unit, errp);
> +} else {
> +visit_type_int64(v, obj, name, errp);
> +}
> +}
> diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h
> index 60aceda..04e690a 100644
> --- a/qapi/qapi-visit-core.h
> +++ b/qapi/qapi-visit-core.h
> @@ -62,6 +62,12 @@ struct Visitor
>  void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error 
> **errp);
>  /* visit_type_size() falls back to (*type_uint64)() if type_size is 
> unset */
>  void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error 
> **errp);
> +/*
> + * visit_unit_suffixed_int() falls back to (*type_int64)()
> + * if type_unit_suffixed_int is unset
> +*/
> +void (*type_unit_suffixed_int)(Visitor *v, int64_t *obj, const char 
> *name,
> +   const int unit, Error **errp);
>  };
> 
>  void visit_start_handle(Visitor *v, void **obj, const char *kind,
> @@ -91,5 +97,7 @@ void visit_type_size(Visitor *v, uint64_t *obj, const char 
> *name, Error **errp);
>  void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
>  void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
>  void visit_type_number(Visitor *v, double *obj, const char *name, Error 
> **errp);
> +void visit_type_unit_suffixed_int(Visitor *v, int64_t *obj, const char *name,
> +  const int unit, Error **errp);
> 
>  #endif
> diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
> index 497eb9a..d2bd154 100644
> --- a/qapi/string-input-visitor.c
> +++ b/qapi/string-input-visitor.c
> @@ -110,6 +110,27 @@ static void parse_start_optional(Visitor *v, bool 
> *present,
>  *present = true;
>  }
> 
> +static void parse_type_unit_suffixed_int(Visitor *v, int64_t *obj,
> + const char *name, const int unit,
> + Error **errp)
> +{
> +StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
> +char *endp = (char *) siv->string;
> +long long val = 0;
> +
> +if (siv->string) {
> +val = strtosz_suffix_unit(siv->string, &endp,
> + STRTOSZ_DEFSUFFIX_B, unit);
> +}
> +if (!siv->string || val == -1 || *endp) {
> +error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
> +  "a value representable as a non-negative int64");
> +return;
> +}
> +
> +*obj = val;
> +}
> +
>  Visitor *string_input_get_visitor(StringInputVisitor *v)
>  {
>  return &v->visitor;
> @@ -132,6 +153,7 @@ StringInputVisitor *string_input_visitor_new(const char 
> *str)
>  v->visitor.type_str = parse_type_str;
>  v->visitor.type_number = parse_type_number;
>  v->visitor.sta

Re: [Qemu-devel] [RFC] 1.4 release schedule

2012-12-06 Thread Blue Swirl
On Thu, Dec 6, 2012 at 10:19 AM, Kevin Wolf  wrote:
> Am 05.12.2012 20:58, schrieb Blue Swirl:
>> On Wed, Dec 5, 2012 at 7:41 PM, Hans de Goede  wrote:
>>> Hi,
>>>
>>>
>>> On 12/05/2012 08:28 PM, Blue Swirl wrote:

 On Tue, Dec 4, 2012 at 10:00 PM, Anthony Liguori 
 wrote:
>
> Peter Maydell  writes:
>
>> On 4 December 2012 18:38, Blue Swirl  wrote:
>>>
>>> The definition of the hard freeze bothers me. A few patches that went
>>> in after 1.3-rc0 were not bug fixes but just new features, so the
>>> difference between soft and hard freezes was not clear.
>>
>>
>> My vote for this would be to adhere to our definition
>> and only commit bugfixes.
>
>
> Let's get specific.  What was committed post hard freeze that's not a
> bug fix?


 d3067b0 Documentation: Update image format information
 a13e5e0 Documentation: Update block cache mode information
 044d003 qemu-tech.texi: update implemented xtensa features list
>>>
>>>
>>> Adding missing / updating docs to be more accurate is a bug fix,
>>> and one with a very low chance of causing regressions at that.
>>
>> I don't think they are bug fixes but improvements to documentation
>> features. But I agree patches only touching documentation, comment and
>> string contents could be exempted.
>
> Actually these patches contain changes where the documentation didn't
> match the implementation. In other words, the documentation was indeed
> buggy.
>
> They also added some missing things, but as you said, improving
> documentation during the hard freeze isn't a bad thing anyway.
>
 74c856e tests: add thread pool unit tests
 b2ea25d tests: add AioContext unit tests
>
> And the same is true for tests. They can only improve the release.
>
>> 1bc6b70 block: add bdrv_reopen() support for raw hdev, floppy, and cdrom
>
> Bug fix. Live commit on block devices was broken because the (already
> implemented) callbacks accidentally weren't added to all BlockDriver
> structs, but only to the 'file' one.
>
> I'll admit that the commit message doesn't make this very clear, but
> anyway you should probably trust subsystem maintainers a bit more that
> they know what they are doing.

I'm not objecting to committing patches like these. The description of
hard freeze just should take these into account, something like:

"After the hard feature freeze, the master branch in git is no longer
open for general development. Only bug fixes and improvements to
documentation will be accepted until the next release. Changes to
strings, comments and tests may be considered if they improve the
release."

>
> Kevin



Re: [Qemu-devel] [RFC] 1.4 release schedule

2012-12-06 Thread Blue Swirl
On Thu, Dec 6, 2012 at 9:01 AM, Andreas Färber  wrote:
> Am 05.12.2012 20:28, schrieb Blue Swirl:
>> On Tue, Dec 4, 2012 at 10:00 PM, Anthony Liguori  wrote:
>>> What was committed post hard freeze that's not a
>>> bug fix?
>>
>> d3067b0 Documentation: Update image format information
>> a13e5e0 Documentation: Update block cache mode information
>> 044d003 qemu-tech.texi: update implemented xtensa features list
>
>> a0a7068 target-i386: Enable SSSE3 TCG support
>
> Fixed a regression - cf. commit message
>
>> 80ae416 target-i386/cpu: Add missing flags to Haswell CPU model
>
> Bug fix - keyword "missing", we certainly did not want backwards
> compatibility issues for a newly introduced model.
>
>> 42015c9 virtio-rng: fix typos, comments
>
>> e1e54f3 target-i386: cpu: add missing flags to Haswell CPU model
>
> Same as above.
>
>> 339c270 qom: make object_finalize static
>
> Not a bugfix and agreed as not needed for 1.3 but still applied
>
>> 64b625f qdev: simplify (de)allocation of buses
>> fde9bf4 qom: make object_delete usable for statically-allocated objects
>> 667d22d qdev: move bus removal to object_unparent
>
> Bug fix with preparations
>
>> 74c856e tests: add thread pool unit tests
>> b2ea25d tests: add AioContext unit tests
>> 21022c9 q35: Add kvmclock support
>> a1c9304 ich9: Add i82801b11 dmi-to-pci bridge
>> df2d8b3 q35: Introduce q35 pc based chipset emulator
>> 678e7b9 ich9: Add smbus
>> 4d00636 ich9: Add the lpc chip
>> e516572 ich9: Add acpi support and definitions
>> 410edd9 pc/piix_pci: factor out smram/pam logic
>> d8ee038 pc_piix: Move kvm irq routing functions out of pc_piix.c
>> a39e356 pc: Move ioapic_init() from pc_piix.c to pc.c
>> 9011a1a pc, pc_piix: split out pc nic initialization
>> 723aedd usb-redir: Don't handle interrupt output packets async
>> 234e810 usb-redir: Split usb_handle_interrupt_data into separate
>> in/out functions
>> 33c1a68 usb-bt: Return NAK instead of STALL when interrupt ep has no data
>> 1bc6b70 block: add bdrv_reopen() support for raw hdev, floppy, and cdrom
>> d132c79 target-mips: Add comments on POOL32Axf encoding
>
> Generally I have been in favor of allowing patches that improve the
> quality of the release while not introducing regressions, like typo
> fixes or documentation updates. This cycle I was much stricter with the
> only-bugfixes rule so I don't understand your complaint.

I'm just whining about the small mismatch between description of hard
freeze and reality. All of the patches were OK and they probably
improved the release, whether they matched the description or not.

>
> If for any reason you think a certain PATCH or PULL should not be
> applied at a certain point in time, feel free to reply before it gets
> committed/merged, which is usually several days later.

But that is a part of the problem, I'm not so sure which patches or
pulls should be applied after the hard freeze.

>
> 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] [ANNOUNCE] QEMU 1.3.0 release

2012-12-06 Thread Gerhard Wiesinger

On 03.12.2012 21:51, Anthony Liguori wrote:

Hi,

Major features include:
  - After nearly 6 years of work, all remaining differences between the
qemu-kvm.git and qemu.git have been merged into qemu.git



How is qemu-kvm enabled?
--enable-kvm ?

Is there a runtime only command line switch also available?

Thank you.

Ciao,
Gerhard




Re: [Qemu-devel] [RFC] 1.4 release schedule

2012-12-06 Thread Blue Swirl
On Thu, Dec 6, 2012 at 8:05 AM, Markus Armbruster  wrote:
> Blue Swirl  writes:
>
>> On Wed, Dec 5, 2012 at 7:41 PM, Hans de Goede  wrote:
>>> Hi,
>>>
>>>
>>> On 12/05/2012 08:28 PM, Blue Swirl wrote:

 On Tue, Dec 4, 2012 at 10:00 PM, Anthony Liguori 
 wrote:
>
> Peter Maydell  writes:
>
>> On 4 December 2012 18:38, Blue Swirl  wrote:
>>>
>>> The definition of the hard freeze bothers me. A few patches that went
>>> in after 1.3-rc0 were not bug fixes but just new features, so the
>>> difference between soft and hard freezes was not clear.
>>
>>
>> My vote for this would be to adhere to our definition
>> and only commit bugfixes.
>
>
> Let's get specific.  What was committed post hard freeze that's not a
> bug fix?


 d3067b0 Documentation: Update image format information
 a13e5e0 Documentation: Update block cache mode information
 044d003 qemu-tech.texi: update implemented xtensa features list
>>>
>>>
>>> Adding missing / updating docs to be more accurate is a bug fix,
>>> and one with a very low chance of causing regressions at that.
>>
>> I don't think they are bug fixes but improvements to documentation
>> features. But I agree patches only touching documentation, comment and
>> string contents could be exempted.
>
> What about improvements to tests?  No impact on anything but "make
> check".

While not bug fixes either, those should be also OK. Though if we had
a QA or release team running tests (including these), they would
probably have to restart their test cycle if there are changes to the
test sets so it's not 100% clear.

>
> [...]



Re: [Qemu-devel] [PATCH 1/1] tmp105: Fix I2C protocol bug

2012-12-06 Thread Blue Swirl
On Wed, Dec 5, 2012 at 7:48 PM, Alex Horn  wrote:
> The private buffer length field must only be incremented after the I2C
> frame has been transmitted.
>
> To expose this bug, assume the temperature in the TMP105 hardware model
> is +0.125 C (e.g. snow slush). Note that eleven bit precision is required
> to read this value; otherwise the reading is equal to zero centigrade (ice).
>
> Continue by considering the following I2C protocol steps:
>
> 1) Start transfer with I2C_START_SEND
> 2) Send byte 0x01 (i.e. configuration register)
> 3) Send byte 0x40 (i.e. eleven bit precision)
> 4) End transfer with I2C_FINISH
>
> 5) Start transfer with I2C_START_SEND
> 6) Send byte 0x00 (i.e. temperature register)
> 7) End transfer I2C_FINISH
>
> 8) Start transfer with I2C_START_RECV
> 9) Receive high-order byte of temperature
>...
>
> In step (1), the function tmp105_tx() is called. By the conditional
> check !s->len and the side effect with ++, s->len is equal to 1 when
> step (2) begins. Thus, 0x40 is written to s->buf[1] in step (3).
> By definition of tmp105_write(), s->config is set to zero in step (3).
> Thus, when we read the higher-order byte in step (9), it is zero!
>
> In other words, the TMP105 hardware model allows us to measure 0 C (ice)
> even with eleven bit precision when, in fact, it should be 0.125 C (slush)!
>
> Signed-off-by: Alex Horn 
> ---
>  hw/tmp105.c |3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/hw/tmp105.c b/hw/tmp105.c
> index 8e8dbd9..5f41a3f 100644
> --- a/hw/tmp105.c
> +++ b/hw/tmp105.c
> @@ -152,7 +152,7 @@ static int tmp105_tx(I2CSlave *i2c, uint8_t data)
>  {
>  TMP105State *s = (TMP105State *) i2c;
>
> -if (!s->len ++)
> +if (s->len == 0)

Please fix coding style (add braces) while touching this line.

QEMU code is not yet consistent with our CODING_STYLE, but changes
should make progress towards that.

>  s->pointer = data;
>  else {
>  if (s->len <= 2)
> @@ -160,6 +160,7 @@ static int tmp105_tx(I2CSlave *i2c, uint8_t data)
>  tmp105_write(s);
>  }
>
> +s->len ++;

Please remove the space between s->len and ++. However, I don't think
the change is entirely correct since the 'else' clause currently seems
to take the increment into account:
if (s->len <= 2)
s->buf[s->len - 1] = data;
tmp105_write(s);

Shouldn't the '- 1'  in the middle line be removed?

>  return 0;
>  }
>
> --
> 1.7.6.5
>
>



[Qemu-devel] [PATCH 1/2] qapi: add visitor for parsing int[KMGT] input string

2012-12-06 Thread Igor Mammedov
Caller of visit_type_unit_suffixed_int() will have to specify
value of 'K' suffix via unit argument.
For Kbytes it's 1024, for Khz it's 1000.

Signed-off-by: Igor Mammedov 
---
 v2:
  - convert type_freq to type_unit_suffixed_int.
  - provide qapi_dealloc_type_unit_suffixed_int() impl.
---
 qapi/qapi-dealloc-visitor.c |  7 +++
 qapi/qapi-visit-core.c  | 13 +
 qapi/qapi-visit-core.h  |  8 
 qapi/string-input-visitor.c | 22 ++
 4 files changed, 50 insertions(+)

diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index 75214e7..57e662c 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -143,6 +143,12 @@ static void qapi_dealloc_type_enum(Visitor *v, int *obj, 
const char *strings[],
 {
 }
 
+static void qapi_dealloc_type_unit_suffixed_int(Visitor *v, int64_t *obj,
+const char *name,
+const int unit, Error **errp)
+{
+}
+
 Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v)
 {
 return &v->visitor;
@@ -170,6 +176,7 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
 v->visitor.type_str = qapi_dealloc_type_str;
 v->visitor.type_number = qapi_dealloc_type_number;
 v->visitor.type_size = qapi_dealloc_type_size;
+v->visitor.type_unit_suffixed_int = qapi_dealloc_type_unit_suffixed_int;
 
 QTAILQ_INIT(&v->stack);
 
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 7a82b63..dcbc1a9 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -311,3 +311,16 @@ void input_type_enum(Visitor *v, int *obj, const char 
*strings[],
 g_free(enum_str);
 *obj = value;
 }
+
+void visit_type_unit_suffixed_int(Visitor *v, int64_t *obj, const char *name,
+  const int unit, Error **errp)
+{
+if (!error_is_set(errp)) {
+return;
+}
+if (v->type_unit_suffixed_int) {
+v->type_unit_suffixed_int(v, obj, name, unit, errp);
+} else {
+visit_type_int64(v, obj, name, errp);
+}
+}
diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h
index 60aceda..04e690a 100644
--- a/qapi/qapi-visit-core.h
+++ b/qapi/qapi-visit-core.h
@@ -62,6 +62,12 @@ struct Visitor
 void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error 
**errp);
 /* visit_type_size() falls back to (*type_uint64)() if type_size is unset 
*/
 void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error 
**errp);
+/*
+ * visit_unit_suffixed_int() falls back to (*type_int64)()
+ * if type_unit_suffixed_int is unset
+*/
+void (*type_unit_suffixed_int)(Visitor *v, int64_t *obj, const char *name,
+   const int unit, Error **errp);
 };
 
 void visit_start_handle(Visitor *v, void **obj, const char *kind,
@@ -91,5 +97,7 @@ void visit_type_size(Visitor *v, uint64_t *obj, const char 
*name, Error **errp);
 void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
 void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
 void visit_type_number(Visitor *v, double *obj, const char *name, Error 
**errp);
+void visit_type_unit_suffixed_int(Visitor *v, int64_t *obj, const char *name,
+  const int unit, Error **errp);
 
 #endif
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 497eb9a..d2bd154 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -110,6 +110,27 @@ static void parse_start_optional(Visitor *v, bool *present,
 *present = true;
 }
 
+static void parse_type_unit_suffixed_int(Visitor *v, int64_t *obj,
+ const char *name, const int unit,
+ Error **errp)
+{
+StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
+char *endp = (char *) siv->string;
+long long val = 0;
+
+if (siv->string) {
+val = strtosz_suffix_unit(siv->string, &endp,
+ STRTOSZ_DEFSUFFIX_B, unit);
+}
+if (!siv->string || val == -1 || *endp) {
+error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
+  "a value representable as a non-negative int64");
+return;
+}
+
+*obj = val;
+}
+
 Visitor *string_input_get_visitor(StringInputVisitor *v)
 {
 return &v->visitor;
@@ -132,6 +153,7 @@ StringInputVisitor *string_input_visitor_new(const char 
*str)
 v->visitor.type_str = parse_type_str;
 v->visitor.type_number = parse_type_number;
 v->visitor.start_optional = parse_start_optional;
+v->visitor.type_unit_suffixed_int = parse_type_unit_suffixed_int;
 
 v->string = str;
 return v;
-- 
1.7.11.7




[Qemu-devel] [PATCH 2/2] target-i386: use visit_type_unit_suffixed_int() to parse tsc_freq property value

2012-12-06 Thread Igor Mammedov
Signed-off-by: Igor Mammedov 
---
  v2:
   - replace visit_type_freq() with visit_type_unit_suffixed_int()
 in x86_cpuid_set_tsc_freq()
---
 target-i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c6c2ca0..b7f0aba 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1195,7 +1195,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor 
*v, void *opaque,
 const int64_t max = INT64_MAX;
 int64_t value;
 
-visit_type_int(v, &value, name, errp);
+visit_type_unit_suffixed_int(v, &value, name, 1000, errp);
 if (error_is_set(errp)) {
 return;
 }
-- 
1.7.11.7




[Qemu-devel] [PATCH 0/2] introduce visitor for parsing suffixed integer

2012-12-06 Thread Igor Mammedov
Igor Mammedov (2):
  qapi: add visitor for parsing int[KMGT] input string
  target-i386: use visit_type_unit_suffixed_int() to parse tsc_freq
property value

 qapi/qapi-dealloc-visitor.c |  7 +++
 qapi/qapi-visit-core.c  | 13 +
 qapi/qapi-visit-core.h  |  8 
 qapi/string-input-visitor.c | 22 ++
 target-i386/cpu.c   |  2 +-
 5 files changed, 51 insertions(+), 1 deletion(-)

-- 
1.7.11.7




Re: [Qemu-devel] [PATCH 5/6] add visitor for parsing hz[KMG] input string

2012-12-06 Thread Igor Mammedov
On Wed, 5 Dec 2012 15:00:59 -0600
mdroth  wrote:

> On Wed, Dec 05, 2012 at 05:21:50PM -0200, Eduardo Habkost wrote:
> > On Wed, Dec 05, 2012 at 11:52:29AM -0600, mdroth wrote:
> > > On Tue, Dec 04, 2012 at 05:34:42PM -0200, Eduardo Habkost wrote:
> > [...]
> > > > diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
> > > > index 497eb9a..74fe395 100644
> > > > --- a/qapi/string-input-visitor.c
> > > > +++ b/qapi/string-input-visitor.c
> > > > @@ -110,6 +110,27 @@ static void parse_start_optional(Visitor *v, bool 
> > > > *present,
> > > >  *present = true;
> > > >  }
> > > >  
> > > > +static void parse_type_freq(Visitor *v, int64_t *obj, const char *name,
> > > > +Error **errp)
> > > > +{
> > > > +StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, 
> > > > v);
> > > > +char *endp = (char *) siv->string;
> > > > +long long val = 0;
> > > > +
> > > > +errno = 0;
> > > 
> > > If this is for strtosz_suffix_unit(), it looks like this is already
> > > handled internally and can be dropped. Relic from a previous version
> > > that called strtod() directly maybe?
> > > 
> > > If that's not the case, I think it should be fixed in the called 
> > > function[s]
> > > rather than for each caller.
> > > 
> > > > +if (siv->string) {
> > > > +val = strtosz_suffix_unit(siv->string, &endp,
> > > > + STRTOSZ_DEFSUFFIX_B, 1000);
> > > 
> > > Specifying 1000 as the unit size will make "1M" == 1000^2 as opposed to
> > > 1024^2. Is this intentional?
> > 
> > I don't know if this is a good idea for a generalx-use visitor, but this is 
> > the
> > current behavior of "-cpu ...,tsc_freq=1M", that we need to keep for
> > compatibility, somehow.
> > 
> > > 
> > > > +}
> > > > +if (!siv->string || val == -1 || *endp) {
> > > > +error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
> > > > +  "a value representable as a non-negative int64");
> > > > +return;
> > > > +}
> > > > +
> > > > +*obj = val;
> > > > +}
> > > > +
> > > >  Visitor *string_input_get_visitor(StringInputVisitor *v)
> > > >  {
> > > >  return &v->visitor;
> > > > @@ -132,6 +153,7 @@ StringInputVisitor *string_input_visitor_new(const 
> > > > char *str)
> > > >  v->visitor.type_str = parse_type_str;
> > > >  v->visitor.type_number = parse_type_number;
> > > >  v->visitor.start_optional = parse_start_optional;
> > > > +v->visitor.type_freq = parse_type_freq;
> > > 
> > > This seems applicable for stuff like -m 1G and potentionally some other
> > > properties. We can make it generic later, but if we do end up re-spinning
> > > consider something like ->type_unit_suffixed_int(). But I'm not against
> > > leaving as is for now since I can't think of a better name for it atm :)
> > 
> > I thought the visitor was going to support things like "1GHz", but if it's 
> > just
> > a "suffixed int" with no unit, the name could be changed, I guess.
> > 
> > But we still have the 1000 vs 1024 problem. On the one hand, it would be
> > interesting to make make it consistent and use the same base everywhere.
> > On the other hand, I assume we have different command-line options using
> > different bases and we'll need to keep compatibility.
> 
> If we were to map it to a QAPI schema definition at some point, I'd
> imagine it looking something like:
> 
> { 'field_name': { 'type': 'suffixed_int', 'unit': 1000 } }
> 
> with 'unit' defaulting to 1024 if unspecified. (I have some patches
> floating around as part of the QIDL series for doing more descriptive
> QAPI definitions) 
> 
> > 
> > Must all visitor functions have the
> > "function(Visitor *v, obj, const char *name, Error **errp)" signature,
> > or can we add additional type-specific arguments? (so we could tell
> > the visitor if the default base should be 1000 or 1024)
> 
> Visitor functions don't necessarilly have to follow the same basic
> signature, so it would be okay to declare it with an extra 'unit' param
> and pass that in. We could still hide this behind a visit_type_freq()
> wrapper in open-coded visitors as well, I'd just prefer to make the bits
> we add to qapi-visit-core.c more general where possible to keep unit
> tests and code generation stuff somewhat sane for the core api.
Lets try to do it this way and if people don't like idea fall back to fixed
type_freq. I'll post patches in a momment

> 
> > 
> > -- 
> > Eduardo
> > 


-- 
Regards,
  Igor



[Qemu-devel] [Bug 1087411] [NEW] pseries machine breaks in instalation of SLES11_SP2

2012-12-06 Thread Erlon R. Cruz
Public bug reported:

QEMU version: 1.0, 1.1, and 1.2

Host OS:
Intel(R) Core(TM) i5-2520M CPU @ 2.50GH
 Linux tpad 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 
x86_64 x86_64 GNU/Linux

SLES Media:
SLES-11-SP2-DVD-ppc64-GM-DVD1.iso: sha256 -> 
2247dd6bb495eb50860668e46f7d6ba004eece9909f347c8ce487fd6a5f65ee1

Command line:
./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512 -net 
nic,vlan=0 -net tap -nographic -cdrom 
/exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda /exports/sles11_sp2.qcow2 
-monitor unix:/dev/tty1,nowait,server

Error message (after starting instalation ~23%):
Installation of package ./suse/ppc64/vim-base-7.2-8.15.2.ppc64.rpm failed.
Subprocess failed. Error: RPM failed: error: 
%post(vim-base-7.2-8.15.2.ppc64.rpm)

** Affects: qemu
 Importance: Undecided
 Status: New

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

Title:
  pseries machine breaks in instalation of SLES11_SP2

Status in QEMU:
  New

Bug description:
  QEMU version: 1.0, 1.1, and 1.2

  Host OS:
  Intel(R) Core(TM) i5-2520M CPU @ 2.50GH
   Linux tpad 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 
x86_64 x86_64 x86_64 GNU/Linux

  SLES Media:
  SLES-11-SP2-DVD-ppc64-GM-DVD1.iso: sha256 -> 
2247dd6bb495eb50860668e46f7d6ba004eece9909f347c8ce487fd6a5f65ee1

  Command line:
  ./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512 -net 
nic,vlan=0 -net tap -nographic -cdrom 
  /exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda 
/exports/sles11_sp2.qcow2 -monitor unix:/dev/tty1,nowait,server

  Error message (after starting instalation ~23%):
  Installation of package ./suse/ppc64/vim-base-7.2-8.15.2.ppc64.rpm failed.
  Subprocess failed. Error: RPM failed: error: 
%post(vim-base-7.2-8.15.2.ppc64.rpm)

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



Re: [Qemu-devel] [Qemu-ppc] [PATCH 08/13] pseries: Update SLOF for NVRAM support

2012-12-06 Thread Erlon Cruz
On Wed, Dec 5, 2012 at 12:39 PM, Alexander Graf  wrote:

>
> On 05.12.2012, at 15:37, Alexander Graf wrote:
>
>
> On 05.12.2012, at 15:35, Alexander Graf wrote:
>
>
> On 05.12.2012, at 15:09, Erlon Cruz wrote:
>
> Hi Alex,
>
>
>>  Could you please post
>>
>>   * the exact command line you were using
>>
>
>  ./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512
> -net nic,vlan=0 -net tap -nographic -cdrom
> /exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda
> /exports/sles11_sp2.qcow2 -monitor unix:/dev/tty1,nowait,server
>
>
> Ah, so you're using -M mac99, which means any patch that says "pseries"
> shouldn't affect that VM at all.
>
>
> Scratch that. -machine type=pseries obviously makes this a pseries machine.
>
> Please still try to check if 1.2 or 1.1 work for you. Checking if
> disabling graphics makes things work would be interesting too.
>
>
> Also -cpu 970 would be an interesting thing to try.
>

This fails right in the kernel  start:

found display   : /pci@8002001/vga@0, opening... done
instantiating rtas at 0x1dbf... done
boot cpu hw idx 0
copying OF device tree...
Building dt strings...
Building dt structure...
Device tree strings 0x0578 -> 0x05780780
Device tree struct  0x0579 -> 0x057a
Calling quiesce...
returning from prom_init
Trying to read invalid spr 8 008 at c0926cbc
Trying to read invalid spr 28 01c at 0720



> Alex
>
>


Re: [Qemu-devel] [PATCH 08/13] pseries: Update SLOF for NVRAM support

2012-12-06 Thread Erlon Cruz
On Wed, Dec 5, 2012 at 12:35 PM, Alexander Graf  wrote:

>
> On 05.12.2012, at 15:09, Erlon Cruz wrote:
>
> Hi Alex,
>
>
>>  Could you please post
>>
>>   * the exact command line you were using
>>
>
>  ./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512
> -net nic,vlan=0 -net tap -nographic -cdrom
> /exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda
> /exports/sles11_sp2.qcow2 -monitor unix:/dev/tty1,nowait,server
>
>
> Ah, so you're using -M mac99, which means any patch that says "pseries"
> shouldn't affect that VM at all.
>
>
>   * details about your host: architecture, OS, kernel version
>>
>
>  Intel(R) Core(TM) i5-2520M CPU @ 2.50GH
>  Linux tpad 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012
> x86_64 x86_64 x86_64 GNU/Linux
>
>* is this using KVM or TCG?
>>
>
> TCG
>
>
>>   * what SLES exactly are you using here?
>>
>
> SLES-11-SP2-DVD-ppc64-GM-DVD1.iso: sha256 ->
> 2247dd6bb495eb50860668e46f7d6ba004eece9909f347c8ce487fd6a5f65ee1
>
>   * the exact QEMU version
>>
>>
> Git: 01bbd8b... Update version for 1.3.0-rc2
>
> I also run the media check from the installer and it says its OK. The only
> abnormal think i could see is a message about the network interface, but it
> doesn't seen to affect the behavior in the rootfs guests:
>
>  Starting udev... ibmveth 1001: (unregistered net_device): unable to
> change checksum offload settings. 1 rc=-2 ret_attr=1001
>
> This last time I run, before that first error I mentioned I got this error
> in this package:
>
> Installation of package ./suse/ppc64/liborc-0_4-0-0.4.11-7.5.23.ppc64.rpm
> failed.
> Subprocess failed. Error: RPM failed: Inconsistency detected by ld.so:
> dl-lookup
>
> but after retrying it passed. But when it hit the vi-base it stuck in that
> error no matter how many times I retry or skip the package.
>
>
> This smells quite a lot like a TCG emulation bug. Could you please check
> if older versions used to work, so whether this is a regression or
> something that never really worked?
>
> Please also give -M pseries -vga std a try.
>

 /home/erlon/internal_git/qemu/ppc64-softmmu/qemu-system-ppc64 -machine
type=pseries,usb=off -m 512 -net nic,vlan=0 -net tap  -cdrom
/exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda
/exports/sles11_sp2.qcow2 -vga std
Bringing up interface tap1... Done
Adding interface tap1 to bridge br0... Done
Warning: Disabling some instructions which are not emulated by TCG (0x0,
0x6)


Then I got no output after: Trying to load from cdrom ... Successfully
loaded
Not sure if it hanged or just the graphics where not shown. Does SLES uses
console=hvc0 in the boot options?


>
> Alex
>
>


Re: [Qemu-devel] [Qemu-ppc] [PATCH 08/13] pseries: Update SLOF for NVRAM support

2012-12-06 Thread Erlon Cruz
On Wed, Dec 5, 2012 at 12:37 PM, Alexander Graf  wrote:

>
> On 05.12.2012, at 15:35, Alexander Graf wrote:
>
>
> On 05.12.2012, at 15:09, Erlon Cruz wrote:
>
> Hi Alex,
>
>
>>  Could you please post
>>
>>   * the exact command line you were using
>>
>
>  ./ppc64-softmmu/qemu-system-ppc64 -machine type=pseries,usb=off -m 512
> -net nic,vlan=0 -net tap -nographic -cdrom
> /exports/isos/SLES-11-SP2-DVD-ppc64-GM-DVD1.iso -hda
> /exports/sles11_sp2.qcow2 -monitor unix:/dev/tty1,nowait,server
>
>
> Ah, so you're using -M mac99, which means any patch that says "pseries"
> shouldn't affect that VM at all.
>
>
> Scratch that. -machine type=pseries obviously makes this a pseries machine.
>
> Please still try to check if 1.2 or 1.1 work for you. Checking if
> disabling graphics makes things work would be interesting too.
>
>
All versions (v1.0, v1.1.0, v1.2.0) shows the same problem. Any idea on how
to get more info about this? Is there a way to reproduce the error from the
shell I got after aborting?


> Alex
>
>


[Qemu-devel] [PATCH] target-mips: Fix incorrect reads and writes to DSPControl register

2012-12-06 Thread Petar Jovanovic
From: Petar Jovanovic 

Upper 4 bits of ccond (bits 31..28 ) of DSPControl register are not used in
the MIPS32 architecture. They are used in the MIPS64 architecture. For MIPS32
these bits must be written as zero, and return zero on read.

The change fixes writes (WRDSP) and reads (RDDSP) to the register. It also fixes
the tests that use these instructions, and makes them smaller and simpler.

Signed-off-by: Petar Jovanovic 
---
 target-mips/dsp_helper.c  |8 
 tests/tcg/mips/mips32-dsp/rddsp.c |   32 
 tests/tcg/mips/mips32-dsp/wrdsp.c |   32 
 3 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/target-mips/dsp_helper.c b/target-mips/dsp_helper.c
index 14daf91..acf7ceb 100644
--- a/target-mips/dsp_helper.c
+++ b/target-mips/dsp_helper.c
@@ -3948,7 +3948,11 @@ void helper_wrdsp(target_ulong rs, target_ulong 
mask_num, CPUMIPSState *env)
 if (mask[4] == 1) {
 overwrite &= 0x00FF;
 newbits   &= 0x00FF;
+#if defined(TARGET_MIPS64)
 newbits   |= 0xFF00 & rs;
+#else
+newbits   |= 0x0F00 & rs;
+#endif
 }
 
 if (mask[5] == 1) {
@@ -3999,7 +4003,11 @@ target_ulong helper_rddsp(target_ulong masknum, 
CPUMIPSState *env)
 }
 
 if (mask[4] == 1) {
+#if defined(TARGET_MIPS64)
 temp |= dsp & 0xFF00;
+#else
+temp |= dsp & 0x0F00;
+#endif
 }
 
 if (mask[5] == 1) {
diff --git a/tests/tcg/mips/mips32-dsp/rddsp.c 
b/tests/tcg/mips/mips32-dsp/rddsp.c
index e8948ec..2f30285 100644
--- a/tests/tcg/mips/mips32-dsp/rddsp.c
+++ b/tests/tcg/mips/mips32-dsp/rddsp.c
@@ -6,14 +6,13 @@ int main()
 int dsp_i, dsp_o;
 int ccond_i, outflag_i, efi_i, c_i, scount_i, pos_i;
 int ccond_o, outflag_o, efi_o, c_o, scount_o, pos_o;
-int ccond_r, outflag_r, efi_r, c_r, scount_r, pos_r;
 
-ccond_i   = 0x00BC;/* 4 */
-outflag_i = 0x001B;/* 3 */
-efi_i = 0x0001;/* 5 */
-c_i   = 0x0001;/* 2 */
-scount_i  = 0x000F;/* 1 */
-pos_i = 0x000C;/* 0 */
+ccond_i   = 0x000C;  /* 4 */
+outflag_i = 0x001B;  /* 3 */
+efi_i = 0x0001;  /* 5 */
+c_i   = 0x0001;  /* 2 */
+scount_i  = 0x000F;  /* 1 */
+pos_i = 0x000C;  /* 0 */
 
 dsp_i = (ccond_i   << 24) | \
 (outflag_i << 16) | \
@@ -22,13 +21,6 @@ int main()
 (scount_i  <<  7) | \
 pos_i;
 
-ccond_r   = ccond_i;
-outflag_r = outflag_i;
-efi_r = efi_i;
-c_r   = c_i;
-scount_r  = scount_i;
-pos_r = pos_i;
-
 __asm
 ("wrdsp %1, 0x3F\n\t"
  "rddsp %0, 0x3F\n\t"
@@ -43,12 +35,12 @@ int main()
 scount_o  = (dsp_o >>  7) & 0x3F;
 pos_o =  dsp_o & 0x1F;
 
-assert(ccond_o   == ccond_r);
-assert(outflag_o == outflag_r);
-assert(efi_o == efi_r);
-assert(c_o   == c_r);
-assert(scount_o  == scount_r);
-assert(pos_o == pos_r);
+assert(ccond_o   == ccond_i);
+assert(outflag_o == outflag_i);
+assert(efi_o == efi_i);
+assert(c_o   == c_i);
+assert(scount_o  == scount_i);
+assert(pos_o == pos_i);
 
 return 0;
 }
diff --git a/tests/tcg/mips/mips32-dsp/wrdsp.c 
b/tests/tcg/mips/mips32-dsp/wrdsp.c
index e8948ec..dc54943 100644
--- a/tests/tcg/mips/mips32-dsp/wrdsp.c
+++ b/tests/tcg/mips/mips32-dsp/wrdsp.c
@@ -6,14 +6,13 @@ int main()
 int dsp_i, dsp_o;
 int ccond_i, outflag_i, efi_i, c_i, scount_i, pos_i;
 int ccond_o, outflag_o, efi_o, c_o, scount_o, pos_o;
-int ccond_r, outflag_r, efi_r, c_r, scount_r, pos_r;
 
-ccond_i   = 0x00BC;/* 4 */
-outflag_i = 0x001B;/* 3 */
-efi_i = 0x0001;/* 5 */
-c_i   = 0x0001;/* 2 */
-scount_i  = 0x000F;/* 1 */
-pos_i = 0x000C;/* 0 */
+ccond_i   = 0x00BC;  /* 4 */
+outflag_i = 0x001B;  /* 3 */
+efi_i = 0x0001;  /* 5 */
+c_i   = 0x0001;  /* 2 */
+scount_i  = 0x000F;  /* 1 */
+pos_i = 0x000C;  /* 0 */
 
 dsp_i = (ccond_i   << 24) | \
 (outflag_i << 16) | \
@@ -22,13 +21,6 @@ int main()
 (scount_i  <<  7) | \
 pos_i;
 
-ccond_r   = ccond_i;
-outflag_r = outflag_i;
-efi_r = efi_i;
-c_r   = c_i;
-scount_r  = scount_i;
-pos_r = pos_i;
-
 __asm
 ("wrdsp %1, 0x3F\n\t"
  "rddsp %0, 0x3F\n\t"
@@ -43,12 +35,12 @@ int main()
 scount_o  = (dsp_o >>  7) & 0x3F;
 pos_o =  dsp_o & 0x1F;
 
-assert(ccond_o   == ccond_r);
-assert(outflag_o == outflag_r);
-assert(efi_o == efi_r);
-assert(c_o   == c_r);
-assert(scount_o  == scount_r);
-assert(pos_o == pos_r);
+assert(ccond_o   == (ccond_i & 0x0F));
+assert(outflag_o == outflag_i);
+assert(efi_o == efi_i);
+assert(c_o   == c_i);
+assert(scount_o  == scount_i);
+ass

[Qemu-devel] [Bug 1034980] Re: pseries machine: vscsi scsi qemu cd-rom does not work in win32

2012-12-06 Thread Kenneth Salerno
This started to work in version 1.2, thanks!

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

Title:
  pseries machine: vscsi scsi qemu cd-rom does not work in win32

Status in QEMU:
  New

Bug description:
  On Win32, the cd-rom device is not detected at all in the pseries machine 
(SLOF):
 
 qemu-system-ppc64 -M pseries -m 512 -cdrom img.iso
etc.
 VSCSI: Looking for disks
 Populating /pci@8002001,0

  
  On Linux however, the scsi qemu cd-rom device is detected and works fine in 
the pseries machine:

 qemu-system-ppc64 -M pseries -m 512 -cdrom img.iso
etc.
 VSCSI: Looking for disks
SCSI ID 2 CD-ROM   : "QEMU QEMU CD-ROM  1.1."
 Populating /pci@8002001,0

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



[Qemu-devel] Understanding KVM

2012-12-06 Thread Ian Molton

Hi,

Im trying to figure out how (on, say, x86), qemu (1.3, git) knows when 
the guest has accessed a page - in particular, on a framebuffer.


It looks like its done via dirty page logs, which are maintained by the 
host kernel, so probably this is a kernel question, more than a qemu one.


Is this the case? if so, where do the bits in the dirty bitmap get set? 
I cant find anything in the kernel that seems to do much with it, other 
than to copy the bitmap to userspace.


-Ian



Re: [Qemu-devel] [RFC 2/3] virtio-balloon: re-enable balloon stats

2012-12-06 Thread Luiz Capitulino
On Thu, 6 Dec 2012 11:03:21 -0600
mdroth  wrote:

> On Tue, Dec 04, 2012 at 01:04:47PM -0200, Luiz Capitulino wrote:
> > The statistics are now available through device properties via a
> > polling mechanism. First, a client has to enable polling, then it
> > can query the stats.
> > 
> > The following control properties are introduced:
> > 
> >  o stats-polling-interval: a value greater than zero enables polling
> >in the specified interval (in seconds). When value equals zero,
> >polling is disabled. If polling is already enabled and a value
> >greater than zero is written, the polling interval time is changed
> > 
> >  o stats-last-update: last stats update timestamp, in seconds.
> > 
> > The following stats properties are introduced:
> > 
> >  o stat-swap-in
> >  o stat-swap-out
> >  o stat-major-faults
> >  o stat-minor-faults
> >  o stat-free-memory
> >  o stat-total-memory
> > 
> > All values are in bytes. A value of -1 means that the statistic isn't
> > available right now.
> > 
> > FIXME: Can balloon_stats_poll_cb(), balloon_stats_set_poll_interval(),
> >virtio_balloon_handle_output() can run in parallel?
> > 
> > XXX: Should we return an error instead of -1? Might require a specific
> >  error. Although this is not exactly a failure...
> > 
> > Signed-off-by: Luiz Capitulino 
> > ---
> > 
> > NOTE: Anthony suggested having a bool to enable/disable polling, but I 
> > prefer
> >   to let the client specify the polling interval. I can revisit this,
> >   though.
> > 
> >  hw/virtio-balloon.c | 156 
> > +++-
> >  1 file changed, 155 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
> > index 4398025..06af18f 100644
> > --- a/hw/virtio-balloon.c
> > +++ b/hw/virtio-balloon.c
> > @@ -22,6 +22,8 @@
> >  #include "virtio-balloon.h"
> >  #include "kvm.h"
> >  #include "exec-memory.h"
> > +#include "qemu-timer.h"
> > +#include "qapi/qapi-visit-core.h"
> > 
> >  #if defined(__linux__)
> >  #include 
> > @@ -36,6 +38,9 @@ typedef struct VirtIOBalloon
> >  uint64_t stats[VIRTIO_BALLOON_S_NR];
> >  VirtQueueElement stats_vq_elem;
> >  size_t stats_vq_offset;
> > +QEMUTimer *stats_timer;
> > +int64_t stats_last_update;
> > +int64_t stats_poll_interval;
> >  DeviceState *qdev;
> >  } VirtIOBalloon;
> > 
> > @@ -53,6 +58,16 @@ static void balloon_page(void *addr, int deflate)
> >  #endif
> >  }
> > 
> > +static const char *balloon_stat_names[] = {
> > +   [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", 
> > +   [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out",
> > +   [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults",
> > +   [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults",
> > +   [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory",
> > +   [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory",
> > +   [VIRTIO_BALLOON_S_NR] = NULL
> > +};
> > +
> >  /*
> >   * reset_stats - Mark all items in the stats array as unset
> >   *
> > @@ -67,6 +82,119 @@ static inline void reset_stats(VirtIOBalloon *dev)
> >  for (i = 0; i < VIRTIO_BALLOON_S_NR; dev->stats[i++] = -1);
> >  }
> > 
> > +static bool balloon_stats_supported(const VirtIOBalloon *s)
> > +{
> > +return s->vdev.guest_features & (1 << VIRTIO_BALLOON_F_STATS_VQ);
> > +}
> > +
> > +static bool balloon_stats_enabled(const VirtIOBalloon *s)
> > +{
> > +return s->stats_poll_interval > 0;
> > +}
> > +
> > +static void balloon_stats_disable_timer(VirtIOBalloon *s)
> > +{
> > +if (balloon_stats_enabled(s)) {
> > +qemu_del_timer(s->stats_timer);
> > +qemu_free_timer(s->stats_timer);
> > +s->stats_timer = NULL;
> > +s->stats_poll_interval = 0;
> > +}
> > +}
> > +
> > +static void balloon_stats_change_timer(VirtIOBalloon *s, int secs)
> > +{
> > +qemu_mod_timer(s->stats_timer, qemu_get_clock_ms(vm_clock) + secs * 
> > 1000);
> > +}
> > +
> > +static void balloon_stats_poll_cb(void *opaque)
> > +{
> > +VirtIOBalloon *s = opaque;
> > +
> > +virtqueue_push(s->svq, &s->stats_vq_elem, s->stats_vq_offset);
> > +virtio_notify(&s->vdev, s->svq);
> 
> I think we'll want to add some logic to avoid the potential for
> re-pushing an elem we've already processed, as I think that violates the
> virtio spec. In the past the monitor blocked us from doing this but with
> timer-driven requests I think it's a possibility now.

I'll check that, thanks for the feedback Mike.

> 
> But the general approach seems sane to me and the code looks to
> be in decent shape.
> 
> > -- 
> > 1.8.0
> > 
> > 
> 




Re: [Qemu-devel] [PATCH 3/7] target-alpha: Add support for -cpu ?

2012-12-06 Thread Eduardo Habkost
On Thu, Dec 06, 2012 at 05:02:52PM +0100, Andreas Färber wrote:
> Am 06.12.2012 16:42, schrieb Andreas Färber:
> > Am 06.12.2012 16:37, schrieb Eduardo Habkost:
> >> On Wed, Oct 31, 2012 at 04:04:00AM +0100, Andreas Färber wrote:
> >>> Implement alphabetical listing of CPU subclasses.
> >>>
> >>> Signed-off-by: Andreas Färber 
> >>> ---
> >>>  target-alpha/cpu.c |   41 +
> >>>  target-alpha/cpu.h |4 +++-
> >>>  2 Dateien geändert, 44 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
> >>>
> >>> diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
> >>> index e1a5739..ab25c44 100644
> >>> --- a/target-alpha/cpu.c
> >>> +++ b/target-alpha/cpu.c
> >>> @@ -23,6 +23,47 @@
> >>>  #include "qemu-common.h"
> >>>  
> >>>  
> >>> +typedef struct AlphaCPUListState {
> >>> +fprintf_function cpu_fprintf;
> >>> +FILE *file;
> >>> +} AlphaCPUListState;
> >>> +
> >>> +/* Sort alphabetically by type name. */
> >>> +static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)
> >>> +{
> >>> +ObjectClass *class_a = (ObjectClass *)a;
> >>> +ObjectClass *class_b = (ObjectClass *)b;
> >>> +const char *name_a, *name_b;
> >>> +
> >>> +name_a = object_class_get_name(class_a);
> >>> +name_b = object_class_get_name(class_b);
> >>> +return strcmp(name_a, name_b);
> >>> +}
> >>> +
> >>> +static void alpha_cpu_list_entry(gpointer data, gpointer user_data)
> >>> +{
> >>> +ObjectClass *oc = data;
> >>> +AlphaCPUListState *s = user_data;
> >>> +
> >>> +(*s->cpu_fprintf)(s->file, "  %s\n",
> >>> +  object_class_get_name(oc));
> >>> +}
> >>> +
> >>> +void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf)
> >>> +{
> >>> +AlphaCPUListState s = {
> >>> +.file = f,
> >>> +.cpu_fprintf = cpu_fprintf,
> >>> +};
> >>> +GSList *list;
> >>> +
> >>> +list = object_class_get_list(TYPE_ALPHA_CPU, false);
> >>> +list = g_slist_sort(list, alpha_cpu_list_compare);
> >>> +(*cpu_fprintf)(f, "Available CPUs:\n");
> >>> +g_slist_foreach(list, alpha_cpu_list_entry, &s);
> >>> +g_slist_free(list);
> >>> +}
> >>
> >> target-arm has very similar code. Isn't it better to first write a
> >> common reusable function to list CPU models using the list of
> >> subclasses, instead of adding very similar functions to all
> >> architectures?
> > 
> > Most ordering functions vary slightly (target-arm for "any"). It would
> > be possible to generalize the struct and provide a wrapper with type and
> > callback arguments,
> 
> Just remembered Anthony being against callbacks in this context:
> 
> http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg02944.html
> 
> The RFC was for specifically for implementing the CPU lists. So I used
> g_slist_* instead as suggested, which duplicates a few lines FWIW.
> If someone has suggestions how else to share more code, I'm all ears.

We could simply reuse the existing arch_query_cpu_definitions() interface to
implement cpu_list(), and the target-specific arch_query_cpu_definitions()
could reorder the list any way it wants. The list could then be used for both
cpu_list() and the the QMP query-cpu-definitions command.

If necessary, we can add a "description" field to CpuDefinitionInfo, so targets
can optionally return a description of each CPU model, too (that's the case for
the current x86 cpu_list() output).

 
> Andreas
> 
> > but then again some functions add a header line like
> > here, some don't, and some even hardcode some options like "host". For
> > the targets that already had -cpu ? support before QOM I tried to keep
> > output identical apart from possibly the order.
> > 
> > Andreas
> 
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

-- 
Eduardo



Re: [Qemu-devel] [RFC 3/3] docs: document virtio-balloon stats

2012-12-06 Thread mdroth
On Thu, Dec 06, 2012 at 01:31:09PM -0200, Luiz Capitulino wrote:
> On Thu, 6 Dec 2012 13:24:11 +
> "Daniel P. Berrange"  wrote:
> 
> > On Tue, Dec 04, 2012 at 01:04:48PM -0200, Luiz Capitulino wrote:
> > > Signed-off-by: Luiz Capitulino 
> > > ---
> > >  docs/virtio-balloon-stats.txt | 73 
> > > +++
> > >  1 file changed, 73 insertions(+)
> > >  create mode 100644 docs/virtio-balloon-stats.txt
> > > 
> > > diff --git a/docs/virtio-balloon-stats.txt b/docs/virtio-balloon-stats.txt
> > > new file mode 100644
> > > index 000..7e7ddc4
> > > --- /dev/null
> > > +++ b/docs/virtio-balloon-stats.txt
> > > @@ -0,0 +1,73 @@
> > > +virtio balloon memory statistics
> > > +
> > > +
> > > +The virtio balloon driver supports guest memory statistics reporting. 
> > > These
> > > +statistics are available to QEMU users as QOM (QEMU Obejct Model) device
> > > +properties via a polling mechanism.
> > > +
> > > +Basically, clients have to enable polling. Then they can query the 
> > > available
> > > +statistics.
> > > +
> > > +There are two control properties and six memory statistics from the 
> > > guest.
> > > +
> > > +The control properties are:
> > > +
> > > + o stats-polling-interval: a value greater than zero enables polling
> > > +   in the specified interval (in seconds). When value equals zero,
> > > +   polling is disabled. If polling is already enabled and a value
> > > +   greater than zero is written, the polling interval time is changed
> > > +
> > > + o stats-last-update: last stats update timestamp, in seconds
> > > +
> > > +The memory statistics are:
> > > +
> > > + o stat-swap-in
> > > + o stat-swap-out
> > > + o stat-major-faults
> > > + o stat-minor-faults
> > > + o stat-free-memory
> > > + o stat-total-memory
> > > +
> > > +All values are in bytes. A value of -1 means that the statistic isn't
> > > +available right now.
> > > +
> > > +Here are a few examples. The virtio-balloon device is assumed to be in 
> > > the
> > > +'/machine/peripheral-anon/device[1]' QOM path.
> > > +
> > > +Enable polling with 2 seconds interval:
> > > +
> > > +{ "execute": "qom-set",
> > > + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > > +  "property": "stats-polling-interval", "value": 2 } }
> > > +
> > > +{ "return": {} }
> > > +
> > > +Change polling to 10 seconds:
> > > +
> > > +{ "execute": "qom-set",
> > > + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > > +  "property": "stats-polling-interval", "value": 10 } }
> > > +
> > > +{ "return": {} }
> > > +
> > > +Get last update timestamp and free memory stat:
> > > +
> > > +{ "execute": "qom-get",
> > > +  "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > > +  "property": "stats-last-update" } }
> > > +
> > > +{ "return": 1354629634 }
> > > +
> > > +{ "execute": "qom-get",
> > > +  "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > > +  "property": "stat-free-memory" } }
> > > +
> > > +{ "return": 845115392 }
> > > +
> > > +Disable polling:
> > > +
> > > +{ "execute": "qom-set",
> > > + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > > +  "property": "stats-polling-interval", "value": 0 } }
> > > +
> > > +{ "return": {} }
> > 
> > 
> > What sort of performance implications are there for enabling polling of
> > virtio stats. Is it the kind of thing that it is reasonable to just
> > enable for all VMs on a 10 second interval, so we'll always have stats
> > available without having to have thought to enable them ahead of time ?
> 
> I can't think of any performance implications. Would be nice to get a
> second opinion from the CC'ed people though.

Pushing/popping/processing one vq entry every 10 seconds should be
virtually unnoticeable given that virtio-net/blk do this much more frequently
with much more processing overhead per entry on a relatively idle guest. So
performance-wise, I don't think it's an issue. As to whether or not it
*should* be enabled by default I'm not so sure, but if it actually simplifies
things on that end I'd say it's worth it if the alternatives are
cumbersome.

> 
> > eg, the use case I'm wondering is that someone comes along and just
> > runs   'virsh memstats $DOMAIN' and wants to see the latest data
> > right away. 
> > 
> > I'm not suggesting that libvirt would be actually asking QEMU for the
> > stats every 10 seconds. Only that libvirt tells QEMU to collect them.
> > Then libvirt can just ask for them whenver someone wants them.
> 
> Note that once you enable polling, the balloon driver will immediately make
> a request to the guest, that is, it won't wait the specified time interval to
> send the first request.
> 
> So, the first call to virsh memstats could start polling and also poll for it
> (although you do need to be prepared for the case where the guest doesn't
> respond).
> 
> Also, you could c

Re: [Qemu-devel] [RFC 2/3] virtio-balloon: re-enable balloon stats

2012-12-06 Thread mdroth
On Tue, Dec 04, 2012 at 01:04:47PM -0200, Luiz Capitulino wrote:
> The statistics are now available through device properties via a
> polling mechanism. First, a client has to enable polling, then it
> can query the stats.
> 
> The following control properties are introduced:
> 
>  o stats-polling-interval: a value greater than zero enables polling
>in the specified interval (in seconds). When value equals zero,
>polling is disabled. If polling is already enabled and a value
>greater than zero is written, the polling interval time is changed
> 
>  o stats-last-update: last stats update timestamp, in seconds.
> 
> The following stats properties are introduced:
> 
>  o stat-swap-in
>  o stat-swap-out
>  o stat-major-faults
>  o stat-minor-faults
>  o stat-free-memory
>  o stat-total-memory
> 
> All values are in bytes. A value of -1 means that the statistic isn't
> available right now.
> 
> FIXME: Can balloon_stats_poll_cb(), balloon_stats_set_poll_interval(),
>virtio_balloon_handle_output() can run in parallel?
> 
> XXX: Should we return an error instead of -1? Might require a specific
>  error. Although this is not exactly a failure...
> 
> Signed-off-by: Luiz Capitulino 
> ---
> 
> NOTE: Anthony suggested having a bool to enable/disable polling, but I prefer
>   to let the client specify the polling interval. I can revisit this,
> though.
> 
>  hw/virtio-balloon.c | 156 
> +++-
>  1 file changed, 155 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
> index 4398025..06af18f 100644
> --- a/hw/virtio-balloon.c
> +++ b/hw/virtio-balloon.c
> @@ -22,6 +22,8 @@
>  #include "virtio-balloon.h"
>  #include "kvm.h"
>  #include "exec-memory.h"
> +#include "qemu-timer.h"
> +#include "qapi/qapi-visit-core.h"
> 
>  #if defined(__linux__)
>  #include 
> @@ -36,6 +38,9 @@ typedef struct VirtIOBalloon
>  uint64_t stats[VIRTIO_BALLOON_S_NR];
>  VirtQueueElement stats_vq_elem;
>  size_t stats_vq_offset;
> +QEMUTimer *stats_timer;
> +int64_t stats_last_update;
> +int64_t stats_poll_interval;
>  DeviceState *qdev;
>  } VirtIOBalloon;
> 
> @@ -53,6 +58,16 @@ static void balloon_page(void *addr, int deflate)
>  #endif
>  }
> 
> +static const char *balloon_stat_names[] = {
> +   [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", 
> +   [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out",
> +   [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults",
> +   [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults",
> +   [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory",
> +   [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory",
> +   [VIRTIO_BALLOON_S_NR] = NULL
> +};
> +
>  /*
>   * reset_stats - Mark all items in the stats array as unset
>   *
> @@ -67,6 +82,119 @@ static inline void reset_stats(VirtIOBalloon *dev)
>  for (i = 0; i < VIRTIO_BALLOON_S_NR; dev->stats[i++] = -1);
>  }
> 
> +static bool balloon_stats_supported(const VirtIOBalloon *s)
> +{
> +return s->vdev.guest_features & (1 << VIRTIO_BALLOON_F_STATS_VQ);
> +}
> +
> +static bool balloon_stats_enabled(const VirtIOBalloon *s)
> +{
> +return s->stats_poll_interval > 0;
> +}
> +
> +static void balloon_stats_disable_timer(VirtIOBalloon *s)
> +{
> +if (balloon_stats_enabled(s)) {
> +qemu_del_timer(s->stats_timer);
> +qemu_free_timer(s->stats_timer);
> +s->stats_timer = NULL;
> +s->stats_poll_interval = 0;
> +}
> +}
> +
> +static void balloon_stats_change_timer(VirtIOBalloon *s, int secs)
> +{
> +qemu_mod_timer(s->stats_timer, qemu_get_clock_ms(vm_clock) + secs * 
> 1000);
> +}
> +
> +static void balloon_stats_poll_cb(void *opaque)
> +{
> +VirtIOBalloon *s = opaque;
> +
> +virtqueue_push(s->svq, &s->stats_vq_elem, s->stats_vq_offset);
> +virtio_notify(&s->vdev, s->svq);

I think we'll want to add some logic to avoid the potential for
re-pushing an elem we've already processed, as I think that violates the
virtio spec. In the past the monitor blocked us from doing this but with
timer-driven requests I think it's a possibility now.

But the general approach seems sane to me and the code looks to
be in decent shape.

> -- 
> 1.8.0
> 
> 



Re: [Qemu-devel] [PATCH 2/7] target-alpha: Turn CPU definitions into subclasses

2012-12-06 Thread Andreas Färber
Am 06.12.2012 17:09, schrieb Eduardo Habkost:
> On Thu, Dec 06, 2012 at 04:51:31PM +0100, Andreas Färber wrote:
>> Am 06.12.2012 16:29, schrieb Eduardo Habkost:
>>> On Wed, Oct 31, 2012 at 04:03:59AM +0100, Andreas Färber wrote:
>>> [...]
 +static void alpha_cpu_register(const AlphaCPUInfo *info)
 +{
 +TypeInfo type_info = {
 +.name = info->name,
 +.parent = TYPE_ALPHA_CPU,
 +.instance_init = info->initfn,
 +};
 +
 +type_register_static(&type_info);
>>>
>>> You should use type_register() instead of type_register_static(), here.
>>
>> I still don't understand why. (CC'ing Anthony, Paolo, Peter)
>>
>> The TypeInfo argument is in no way retained inside
>> qom/object.c:type_register_internal().
>> Therefore the lifetime of TypeInfo should be completely irrelevant for
>> the static/non-static decision and the documentation should be fixed IMO.
>> Is there a reason to do it differently? What would we want to do with
>> TypeInfo after transfer of its field values to TypeImpl?
> 
> The current implementation doesn't matter. It can change at any minute. The
> interface, on the other hand, is documented as:
> 
>   type_register_static:
>   @info: The #TypeInfo of the new type.
> 
>   @info and all of the strings it points to should exist for the life time
>   that the type is registered.

Both implementation and documentation can be changed. My question is,
why does the documentation say this and where does Anthony (or Paolo)
want to go with the current implementation that makes this necessary.

Like, if we switched to C++, we would drop both registration functions
completely.

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 3/7] target-alpha: Add support for -cpu ?

2012-12-06 Thread Eduardo Habkost
On Thu, Dec 06, 2012 at 03:59:46PM +, Peter Maydell wrote:
> On 6 December 2012 15:37, Eduardo Habkost  wrote:
> > target-arm has very similar code. Isn't it better to first write a
> > common reusable function to list CPU models using the list of
> > subclasses, instead of adding very similar functions to all
> > architectures?
> 
> What would be particularly useful to have as a common
> utility routine is support for x86-style +feature,-feature
> syntax. At the moment we don't implement that on most
> other targets but it would be good to have that on ARM
> at some point.

Once we finish the work on x86, I plan to make the code reusable by
other architectures.

That would include the +feature,-feature parsing and the CPU model ->
CPU class lookup (this one may be more complicated to make reusable, but
I think it's doable).

-- 
Eduardo



Re: [Qemu-devel] [PATCH 2/7] target-alpha: Turn CPU definitions into subclasses

2012-12-06 Thread Eduardo Habkost
On Thu, Dec 06, 2012 at 04:51:31PM +0100, Andreas Färber wrote:
> Am 06.12.2012 16:29, schrieb Eduardo Habkost:
> > On Wed, Oct 31, 2012 at 04:03:59AM +0100, Andreas Färber wrote:
> > [...]
> >> +static void alpha_cpu_register(const AlphaCPUInfo *info)
> >> +{
> >> +TypeInfo type_info = {
> >> +.name = info->name,
> >> +.parent = TYPE_ALPHA_CPU,
> >> +.instance_init = info->initfn,
> >> +};
> >> +
> >> +type_register_static(&type_info);
> > 
> > You should use type_register() instead of type_register_static(), here.
> 
> I still don't understand why. (CC'ing Anthony, Paolo, Peter)
> 
> The TypeInfo argument is in no way retained inside
> qom/object.c:type_register_internal().
> Therefore the lifetime of TypeInfo should be completely irrelevant for
> the static/non-static decision and the documentation should be fixed IMO.
> Is there a reason to do it differently? What would we want to do with
> TypeInfo after transfer of its field values to TypeImpl?

The current implementation doesn't matter. It can change at any minute. The
interface, on the other hand, is documented as:

  type_register_static:
  @info: The #TypeInfo of the new type.

  @info and all of the strings it points to should exist for the life time
  that the type is registered.

-- 
Eduardo



Re: [Qemu-devel] [PATCH 3/7] target-alpha: Add support for -cpu ?

2012-12-06 Thread Andreas Färber
Am 06.12.2012 16:42, schrieb Andreas Färber:
> Am 06.12.2012 16:37, schrieb Eduardo Habkost:
>> On Wed, Oct 31, 2012 at 04:04:00AM +0100, Andreas Färber wrote:
>>> Implement alphabetical listing of CPU subclasses.
>>>
>>> Signed-off-by: Andreas Färber 
>>> ---
>>>  target-alpha/cpu.c |   41 +
>>>  target-alpha/cpu.h |4 +++-
>>>  2 Dateien geändert, 44 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
>>>
>>> diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
>>> index e1a5739..ab25c44 100644
>>> --- a/target-alpha/cpu.c
>>> +++ b/target-alpha/cpu.c
>>> @@ -23,6 +23,47 @@
>>>  #include "qemu-common.h"
>>>  
>>>  
>>> +typedef struct AlphaCPUListState {
>>> +fprintf_function cpu_fprintf;
>>> +FILE *file;
>>> +} AlphaCPUListState;
>>> +
>>> +/* Sort alphabetically by type name. */
>>> +static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)
>>> +{
>>> +ObjectClass *class_a = (ObjectClass *)a;
>>> +ObjectClass *class_b = (ObjectClass *)b;
>>> +const char *name_a, *name_b;
>>> +
>>> +name_a = object_class_get_name(class_a);
>>> +name_b = object_class_get_name(class_b);
>>> +return strcmp(name_a, name_b);
>>> +}
>>> +
>>> +static void alpha_cpu_list_entry(gpointer data, gpointer user_data)
>>> +{
>>> +ObjectClass *oc = data;
>>> +AlphaCPUListState *s = user_data;
>>> +
>>> +(*s->cpu_fprintf)(s->file, "  %s\n",
>>> +  object_class_get_name(oc));
>>> +}
>>> +
>>> +void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf)
>>> +{
>>> +AlphaCPUListState s = {
>>> +.file = f,
>>> +.cpu_fprintf = cpu_fprintf,
>>> +};
>>> +GSList *list;
>>> +
>>> +list = object_class_get_list(TYPE_ALPHA_CPU, false);
>>> +list = g_slist_sort(list, alpha_cpu_list_compare);
>>> +(*cpu_fprintf)(f, "Available CPUs:\n");
>>> +g_slist_foreach(list, alpha_cpu_list_entry, &s);
>>> +g_slist_free(list);
>>> +}
>>
>> target-arm has very similar code. Isn't it better to first write a
>> common reusable function to list CPU models using the list of
>> subclasses, instead of adding very similar functions to all
>> architectures?
> 
> Most ordering functions vary slightly (target-arm for "any"). It would
> be possible to generalize the struct and provide a wrapper with type and
> callback arguments,

Just remembered Anthony being against callbacks in this context:

http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg02944.html

The RFC was for specifically for implementing the CPU lists. So I used
g_slist_* instead as suggested, which duplicates a few lines FWIW.
If someone has suggestions how else to share more code, I'm all ears.

Andreas

> but then again some functions add a header line like
> here, some don't, and some even hardcode some options like "host". For
> the targets that already had -cpu ? support before QOM I tried to keep
> output identical apart from possibly the order.
> 
> 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 3/7] target-alpha: Add support for -cpu ?

2012-12-06 Thread Peter Maydell
On 6 December 2012 15:37, Eduardo Habkost  wrote:
> target-arm has very similar code. Isn't it better to first write a
> common reusable function to list CPU models using the list of
> subclasses, instead of adding very similar functions to all
> architectures?

What would be particularly useful to have as a common
utility routine is support for x86-style +feature,-feature
syntax. At the moment we don't implement that on most
other targets but it would be good to have that on ARM
at some point.

-- PMM



Re: [Qemu-devel] [PATCH 2/7] target-alpha: Turn CPU definitions into subclasses

2012-12-06 Thread Andreas Färber
Am 06.12.2012 16:29, schrieb Eduardo Habkost:
> On Wed, Oct 31, 2012 at 04:03:59AM +0100, Andreas Färber wrote:
> [...]
>> +static void alpha_cpu_register(const AlphaCPUInfo *info)
>> +{
>> +TypeInfo type_info = {
>> +.name = info->name,
>> +.parent = TYPE_ALPHA_CPU,
>> +.instance_init = info->initfn,
>> +};
>> +
>> +type_register_static(&type_info);
> 
> You should use type_register() instead of type_register_static(), here.

I still don't understand why. (CC'ing Anthony, Paolo, Peter)

The TypeInfo argument is in no way retained inside
qom/object.c:type_register_internal().
Therefore the lifetime of TypeInfo should be completely irrelevant for
the static/non-static decision and the documentation should be fixed IMO.
Is there a reason to do it differently? What would we want to do with
TypeInfo after transfer of its field values to TypeImpl?

FWIW if, as suggested earlier, we don't loop over Alpha CPU models in
favor of a handful of trivial static TypeInfos, it becomes irrelevant
for this patch but I'd still like to understand for the remaining
architectures.

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 3/3] docs: document virtio-balloon stats

2012-12-06 Thread Luiz Capitulino
On Thu, 6 Dec 2012 13:24:11 +
"Daniel P. Berrange"  wrote:

> On Tue, Dec 04, 2012 at 01:04:48PM -0200, Luiz Capitulino wrote:
> > Signed-off-by: Luiz Capitulino 
> > ---
> >  docs/virtio-balloon-stats.txt | 73 
> > +++
> >  1 file changed, 73 insertions(+)
> >  create mode 100644 docs/virtio-balloon-stats.txt
> > 
> > diff --git a/docs/virtio-balloon-stats.txt b/docs/virtio-balloon-stats.txt
> > new file mode 100644
> > index 000..7e7ddc4
> > --- /dev/null
> > +++ b/docs/virtio-balloon-stats.txt
> > @@ -0,0 +1,73 @@
> > +virtio balloon memory statistics
> > +
> > +
> > +The virtio balloon driver supports guest memory statistics reporting. These
> > +statistics are available to QEMU users as QOM (QEMU Obejct Model) device
> > +properties via a polling mechanism.
> > +
> > +Basically, clients have to enable polling. Then they can query the 
> > available
> > +statistics.
> > +
> > +There are two control properties and six memory statistics from the guest.
> > +
> > +The control properties are:
> > +
> > + o stats-polling-interval: a value greater than zero enables polling
> > +   in the specified interval (in seconds). When value equals zero,
> > +   polling is disabled. If polling is already enabled and a value
> > +   greater than zero is written, the polling interval time is changed
> > +
> > + o stats-last-update: last stats update timestamp, in seconds
> > +
> > +The memory statistics are:
> > +
> > + o stat-swap-in
> > + o stat-swap-out
> > + o stat-major-faults
> > + o stat-minor-faults
> > + o stat-free-memory
> > + o stat-total-memory
> > +
> > +All values are in bytes. A value of -1 means that the statistic isn't
> > +available right now.
> > +
> > +Here are a few examples. The virtio-balloon device is assumed to be in the
> > +'/machine/peripheral-anon/device[1]' QOM path.
> > +
> > +Enable polling with 2 seconds interval:
> > +
> > +{ "execute": "qom-set",
> > + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > +"property": "stats-polling-interval", "value": 2 } }
> > +
> > +{ "return": {} }
> > +
> > +Change polling to 10 seconds:
> > +
> > +{ "execute": "qom-set",
> > + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > +"property": "stats-polling-interval", "value": 10 } }
> > +
> > +{ "return": {} }
> > +
> > +Get last update timestamp and free memory stat:
> > +
> > +{ "execute": "qom-get",
> > +  "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > +  "property": "stats-last-update" } }
> > +
> > +{ "return": 1354629634 }
> > +
> > +{ "execute": "qom-get",
> > +  "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > +  "property": "stat-free-memory" } }
> > +
> > +{ "return": 845115392 }
> > +
> > +Disable polling:
> > +
> > +{ "execute": "qom-set",
> > + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> > +"property": "stats-polling-interval", "value": 0 } }
> > +
> > +{ "return": {} }
> 
> 
> What sort of performance implications are there for enabling polling of
> virtio stats. Is it the kind of thing that it is reasonable to just
> enable for all VMs on a 10 second interval, so we'll always have stats
> available without having to have thought to enable them ahead of time ?

I can't think of any performance implications. Would be nice to get a
second opinion from the CC'ed people though.

> eg, the use case I'm wondering is that someone comes along and just
> runs   'virsh memstats $DOMAIN' and wants to see the latest data
> right away. 
> 
> I'm not suggesting that libvirt would be actually asking QEMU for the
> stats every 10 seconds. Only that libvirt tells QEMU to collect them.
> Then libvirt can just ask for them whenver someone wants them.

Note that once you enable polling, the balloon driver will immediately make
a request to the guest, that is, it won't wait the specified time interval to
send the first request.

So, the first call to virsh memstats could start polling and also poll for it
(although you do need to be prepared for the case where the guest doesn't
respond).

Also, you could consider adding the time interval in libvirt's API and
virsh memstats.



Re: [Qemu-devel] [PATCH 3/7] target-alpha: Add support for -cpu ?

2012-12-06 Thread Andreas Färber
Am 06.12.2012 16:37, schrieb Eduardo Habkost:
> On Wed, Oct 31, 2012 at 04:04:00AM +0100, Andreas Färber wrote:
>> Implement alphabetical listing of CPU subclasses.
>>
>> Signed-off-by: Andreas Färber 
>> ---
>>  target-alpha/cpu.c |   41 +
>>  target-alpha/cpu.h |4 +++-
>>  2 Dateien geändert, 44 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
>>
>> diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
>> index e1a5739..ab25c44 100644
>> --- a/target-alpha/cpu.c
>> +++ b/target-alpha/cpu.c
>> @@ -23,6 +23,47 @@
>>  #include "qemu-common.h"
>>  
>>  
>> +typedef struct AlphaCPUListState {
>> +fprintf_function cpu_fprintf;
>> +FILE *file;
>> +} AlphaCPUListState;
>> +
>> +/* Sort alphabetically by type name. */
>> +static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)
>> +{
>> +ObjectClass *class_a = (ObjectClass *)a;
>> +ObjectClass *class_b = (ObjectClass *)b;
>> +const char *name_a, *name_b;
>> +
>> +name_a = object_class_get_name(class_a);
>> +name_b = object_class_get_name(class_b);
>> +return strcmp(name_a, name_b);
>> +}
>> +
>> +static void alpha_cpu_list_entry(gpointer data, gpointer user_data)
>> +{
>> +ObjectClass *oc = data;
>> +AlphaCPUListState *s = user_data;
>> +
>> +(*s->cpu_fprintf)(s->file, "  %s\n",
>> +  object_class_get_name(oc));
>> +}
>> +
>> +void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf)
>> +{
>> +AlphaCPUListState s = {
>> +.file = f,
>> +.cpu_fprintf = cpu_fprintf,
>> +};
>> +GSList *list;
>> +
>> +list = object_class_get_list(TYPE_ALPHA_CPU, false);
>> +list = g_slist_sort(list, alpha_cpu_list_compare);
>> +(*cpu_fprintf)(f, "Available CPUs:\n");
>> +g_slist_foreach(list, alpha_cpu_list_entry, &s);
>> +g_slist_free(list);
>> +}
> 
> target-arm has very similar code. Isn't it better to first write a
> common reusable function to list CPU models using the list of
> subclasses, instead of adding very similar functions to all
> architectures?

Most ordering functions vary slightly (target-arm for "any"). It would
be possible to generalize the struct and provide a wrapper with type and
callback arguments, but then again some functions add a header line like
here, some don't, and some even hardcode some options like "host". For
the targets that already had -cpu ? support before QOM I tried to keep
output identical apart from possibly the order.

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] qxl: use correct rom size for revision < 4

2012-12-06 Thread Alon Levy
RHBZ 869981

Before this patch revision < 4 (4 is the default) would result in a wrong
qxl_rom size of 16384 instead of 8192 when building with
spice-protocol-0.12, due to the addition of fields in
the rom for client capabilities and monitors config that were added
between spice-protocol 0.10 and 0.12.

The solution is a bit involved, since I decided not to change QXLRom
which is defined externally in spice-protocol. Instead for revision < 4
we allocate 72 bytes for the QXLRom on the qxl_rom bar (bytes [0,71])
and make sure no fields out of that range are accessed, via checking of
the revision and nop-ing.

Signed-off-by: Alon Levy 
---
 hw/qxl.c | 37 -
 hw/qxl.h |  2 ++
 trace-events |  2 ++
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index 3f835b8..4794f13 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -314,10 +314,26 @@ static inline uint32_t msb_mask(uint32_t val)
 return mask;
 }
 
-static ram_addr_t qxl_rom_size(void)
+static ram_addr_t init_qxl_rom_size(PCIQXLDevice *qxl)
 {
-uint32_t rom_size = sizeof(QXLRom) + sizeof(QXLModes) + sizeof(qxl_modes);
+uint32_t rom_size;
 
+switch (qxl->revision) {
+case 1:
+case 2:
+case 3:
+/* rom_size ends up in [4096, 8192), so it fits all revisions <= 3 */
+qxl->qxl_rom_size = 72;
+break;
+case 4:
+/* rom_size ends up >= 8192 for spice-protocol >= 12.1 because of added
+ * client capabilities */
+qxl->qxl_rom_size = sizeof(QXLRom);
+break;
+default:
+abort();
+}
+rom_size = qxl->qxl_rom_size + sizeof(QXLModes) + sizeof(qxl_modes);
 rom_size = MAX(rom_size, TARGET_PAGE_SIZE);
 rom_size = msb_mask(rom_size * 2 - 1);
 return rom_size;
@@ -326,7 +342,7 @@ static ram_addr_t qxl_rom_size(void)
 static void init_qxl_rom(PCIQXLDevice *d)
 {
 QXLRom *rom = memory_region_get_ram_ptr(&d->rom_bar);
-QXLModes *modes = (QXLModes *)(rom + 1);
+QXLModes *modes = (QXLModes *)((void *)rom + d->qxl_rom_size);
 uint32_t ram_header_size;
 uint32_t surface0_area_size;
 uint32_t num_pages;
@@ -338,7 +354,7 @@ static void init_qxl_rom(PCIQXLDevice *d)
 rom->magic = cpu_to_le32(QXL_ROM_MAGIC);
 rom->id= cpu_to_le32(d->id);
 rom->log_level = cpu_to_le32(d->guestdebug);
-rom->modes_offset  = cpu_to_le32(sizeof(QXLRom));
+rom->modes_offset  = cpu_to_le32(d->qxl_rom_size);
 
 rom->slot_gen_bits = MEMSLOT_GENERATION_BITS;
 rom->slot_id_bits  = MEMSLOT_SLOT_BITS;
@@ -981,6 +997,12 @@ static void interface_set_client_capabilities(QXLInstance 
*sin,
 {
 PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
 
+if (qxl->revision < 4) {
+trace_qxl_set_client_capabilities_unsupported_by_revision(qxl->id,
+  
qxl->revision);
+return;
+}
+
 if (runstate_check(RUN_STATE_INMIGRATE) ||
 runstate_check(RUN_STATE_POSTMIGRATE)) {
 return;
@@ -1013,6 +1035,11 @@ static int interface_client_monitors_config(QXLInstance 
*sin,
 QXLRom *rom = memory_region_get_ram_ptr(&qxl->rom_bar);
 int i;
 
+if (qxl->revision < 4) {
+trace_qxl_client_monitors_config_unsupported_by_device(qxl->id,
+   qxl->revision);
+return 0;
+}
 /*
  * Older windows drivers set int_mask to 0 when their ISR is called,
  * then later set it to ~0. So it doesn't relate to the actual interrupts
@@ -2031,7 +2058,7 @@ static int qxl_init_common(PCIQXLDevice *qxl)
 pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
 pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
 
-qxl->rom_size = qxl_rom_size();
+qxl->rom_size = init_qxl_rom_size(qxl);
 memory_region_init_ram(&qxl->rom_bar, "qxl.vrom", qxl->rom_size);
 vmstate_register_ram(&qxl->rom_bar, &qxl->pci.qdev);
 init_qxl_rom(qxl);
diff --git a/hw/qxl.h b/hw/qxl.h
index b3564fb..c9dee70 100644
--- a/hw/qxl.h
+++ b/hw/qxl.h
@@ -92,6 +92,8 @@ typedef struct PCIQXLDevice {
 QXLRom shadow_rom;
 QXLRom *rom;
 QXLModes   *modes;
+uint32_t   qxl_rom_size; /* size allocated for QXLRom,
+<= sizeof(QXLRom) */
 uint32_t   rom_size;
 MemoryRegion   rom_bar;
 
diff --git a/trace-events b/trace-events
index 6c6cbf1..7d9d62d 100644
--- a/trace-events
+++ b/trace-events
@@ -1006,8 +1006,10 @@ qxl_send_events_vm_stopped(int qid, uint32_t events) "%d 
%d"
 qxl_set_guest_bug(int qid) "%d"
 qxl_interrupt_client_monitors_config(int qid, int num_heads, void *heads) "%d 
%d %p"
 qxl_client_monitors_config_unsupported_by_guest(int qid, uint32_t int_mask, 
void *client_monitors_config) "%d %X %p"
+qxl_client_monitors_config_unsupported_by_device(int qid, int revision) "%d 
revision=%d"
 qxl_clien

Re: [Qemu-devel] [PATCH 3/7] target-alpha: Add support for -cpu ?

2012-12-06 Thread Eduardo Habkost
On Wed, Oct 31, 2012 at 04:04:00AM +0100, Andreas Färber wrote:
> Implement alphabetical listing of CPU subclasses.
> 
> Signed-off-by: Andreas Färber 
> ---
>  target-alpha/cpu.c |   41 +
>  target-alpha/cpu.h |4 +++-
>  2 Dateien geändert, 44 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
> 
> diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
> index e1a5739..ab25c44 100644
> --- a/target-alpha/cpu.c
> +++ b/target-alpha/cpu.c
> @@ -23,6 +23,47 @@
>  #include "qemu-common.h"
>  
>  
> +typedef struct AlphaCPUListState {
> +fprintf_function cpu_fprintf;
> +FILE *file;
> +} AlphaCPUListState;
> +
> +/* Sort alphabetically by type name. */
> +static gint alpha_cpu_list_compare(gconstpointer a, gconstpointer b)
> +{
> +ObjectClass *class_a = (ObjectClass *)a;
> +ObjectClass *class_b = (ObjectClass *)b;
> +const char *name_a, *name_b;
> +
> +name_a = object_class_get_name(class_a);
> +name_b = object_class_get_name(class_b);
> +return strcmp(name_a, name_b);
> +}
> +
> +static void alpha_cpu_list_entry(gpointer data, gpointer user_data)
> +{
> +ObjectClass *oc = data;
> +AlphaCPUListState *s = user_data;
> +
> +(*s->cpu_fprintf)(s->file, "  %s\n",
> +  object_class_get_name(oc));
> +}
> +
> +void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf)
> +{
> +AlphaCPUListState s = {
> +.file = f,
> +.cpu_fprintf = cpu_fprintf,
> +};
> +GSList *list;
> +
> +list = object_class_get_list(TYPE_ALPHA_CPU, false);
> +list = g_slist_sort(list, alpha_cpu_list_compare);
> +(*cpu_fprintf)(f, "Available CPUs:\n");
> +g_slist_foreach(list, alpha_cpu_list_entry, &s);
> +g_slist_free(list);
> +}

target-arm has very similar code. Isn't it better to first write a
common reusable function to list CPU models using the list of
subclasses, instead of adding very similar functions to all
architectures?

-- 
Eduardo



Re: [Qemu-devel] [PATCH 2/7] target-alpha: Turn CPU definitions into subclasses

2012-12-06 Thread Eduardo Habkost
On Wed, Oct 31, 2012 at 04:03:59AM +0100, Andreas Färber wrote:
[...]
> +static void alpha_cpu_register(const AlphaCPUInfo *info)
> +{
> +TypeInfo type_info = {
> +.name = info->name,
> +.parent = TYPE_ALPHA_CPU,
> +.instance_init = info->initfn,
> +};
> +
> +type_register_static(&type_info);

You should use type_register() instead of type_register_static(), here.

-- 
Eduardo



[Qemu-devel] [PATCH 04/32] build: add $(TARGET_DIR) to "GEN config-target.h" lines

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 rules.mak |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/rules.mak b/rules.mak
index 77d2360..8448b94 100644
--- a/rules.mak
+++ b/rules.mak
@@ -71,7 +71,7 @@ TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py
@test -f $@ || cp $< $@
 
 %.h-timestamp: %.mak
-   $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " 
 GEN   $*.h")
+   $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " 
 GEN   $(TARGET_DIR)$*.h")
@cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h
 
 # will delete the target of a rule if commands exit with a nonzero exit status
-- 
1.7.1





[Qemu-devel] [PATCH 03/32] build: adjust setting of QEMU_INCLUDES

2012-12-06 Thread Paolo Bonzini
Make it correct for nested directories, and move the static part
from Makefile to configure.

Signed-off-by: Paolo Bonzini 
---
 Makefile  |2 --
 configure |3 +--
 rules.mak |3 +++
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 7e38112..9ebd3cd 100644
--- a/Makefile
+++ b/Makefile
@@ -145,8 +145,6 @@ audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += 
$(FMOD_CFLAGS)
 
 QEMU_CFLAGS+=$(CURL_CFLAGS)
 
-QEMU_CFLAGS += -I$(SRC_PATH)/include
-
 ui/cocoa.o: ui/cocoa.m
 
 ui/sdl.o audio/sdlaudio.o ui/sdl_zoom.o hw/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS)
diff --git a/configure b/configure
index 994f731..caaa426 100755
--- a/configure
+++ b/configure
@@ -269,7 +269,7 @@ QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
$QEMU_CFLAGS"
-QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
+QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include -I\$(SRC_PATH)/fpu"
 if test "$debug_info" = "yes"; then
 CFLAGS="-g $CFLAGS"
 LDFLAGS="-g $LDFLAGS"
@@ -3336,7 +3336,6 @@ fi
 if test "$slirp" = "yes" ; then
   echo "CONFIG_SLIRP=y" >> $config_host_mak
   echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
-  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
 fi
 if test "$vde" = "yes" ; then
   echo "CONFIG_VDE=y" >> $config_host_mak
diff --git a/rules.mak b/rules.mak
index d0b04e4..77d2360 100644
--- a/rules.mak
+++ b/rules.mak
@@ -14,6 +14,9 @@ MAKEFLAGS += -rR
 # Flags for dependency generation
 QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 
+# Same as -I$(SRC_PATH) -I., but for the nested source/object directories
+QEMU_CFLAGS += -I$(

[Qemu-devel] [PATCH 13/32] net: move net.c to net/

2012-12-06 Thread Paolo Bonzini
Acked-by: Paolo Bonzini 
Signed-off-by: Paolo Bonzini 
---
 Makefile.objs  |2 +-
 net/Makefile.objs  |2 +-
 net.c => net/net.c |8 
 3 files changed, 6 insertions(+), 6 deletions(-)
 rename net.c => net/net.c (99%)

diff --git a/Makefile.objs b/Makefile.objs
index 0fb3904..569d834 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -66,7 +66,7 @@ endif
 # single QEMU executable should support all CPUs and machines.
 
 common-obj-y = $(block-obj-y) blockdev.o blockdev-nbd.o block/
-common-obj-y += net.o net/
+common-obj-y += net/
 common-obj-y += qom/
 common-obj-y += readline.o console.o cursor.o
 common-obj-y += qemu-pixman.o
diff --git a/net/Makefile.objs b/net/Makefile.objs
index cf04187..a08cd14 100644
--- a/net/Makefile.objs
+++ b/net/Makefile.objs
@@ -1,4 +1,4 @@
-common-obj-y = queue.o checksum.o util.o hub.o
+common-obj-y = net.o queue.o checksum.o util.o hub.o
 common-obj-y += socket.o
 common-obj-y += dump.o
 common-obj-$(CONFIG_POSIX) += tap.o
diff --git a/net.c b/net/net.c
similarity index 99%
rename from net.c
rename to net/net.c
index 4f3d642..7b1600f 100644
--- a/net.c
+++ b/net/net.c
@@ -24,10 +24,10 @@
 #include "config-host.h"
 
 #include "net.h"
-#include "net/clients.h"
-#include "net/hub.h"
-#include "net/slirp.h"
-#include "net/util.h"
+#include "clients.h"
+#include "hub.h"
+#include "slirp.h"
+#include "util.h"
 
 #include "monitor.h"
 #include "qemu-common.h"
-- 
1.7.1





[Qemu-devel] [PATCH 05/32] build: move rules from Makefile to */Makefile.objs

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 Makefile|   10 --
 audio/Makefile.objs |3 +++
 block/Makefile.objs |2 ++
 hw/Makefile.objs|2 ++
 ui/Makefile.objs|5 +
 5 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 9ebd3cd..5810718 100644
--- a/Makefile
+++ b/Makefile
@@ -141,16 +141,6 @@ ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
 
 recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 
-audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
-
-QEMU_CFLAGS+=$(CURL_CFLAGS)
-
-ui/cocoa.o: ui/cocoa.m
-
-ui/sdl.o audio/sdlaudio.o ui/sdl_zoom.o hw/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS)
-
-ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
-
 bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
 
 version.o: $(SRC_PATH)/version.rc config-host.h
diff --git a/audio/Makefile.objs b/audio/Makefile.objs
index 0f2932d..d71a877 100644
--- a/audio/Makefile.objs
+++ b/audio/Makefile.objs
@@ -12,3 +12,6 @@ common-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
 common-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
 common-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
 common-obj-y += wavcapture.o
+
+$(obj)/audio.o $(obj)/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
+$(obj)/sdlaudio.o: QEMU_CFLAGS += $(SDL_CFLAGS)
diff --git a/block/Makefile.objs b/block/Makefile.objs
index 7f01510..c067f38 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -18,3 +18,5 @@ endif
 common-obj-y += stream.o
 common-obj-y += commit.o
 common-obj-y += mirror.o
+
+$(obj)/curl.o: QEMU_CFLAGS+=$(CURL_CFLAGS)
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index d581d8d..864bb55 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -209,3 +209,5 @@ ifeq ($(CONFIG_PCI), y)
 obj-$(CONFIG_KVM) += ivshmem.o
 obj-$(CONFIG_LINUX) += vfio_pci.o
 endif
+
+$(obj)/baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) 
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index adc07be..fd339d2 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -12,3 +12,8 @@ common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
 common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_CURSES) += curses.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
+
+$(obj)/sdl.o $(obj)/sdl_zoom.o: QEMU_CFLAGS += $(SDL_CFLAGS) 
+$(obj)/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
+
+$(obj)/cocoa.o: $(SRC_PATH)/$(obj)/cocoa.m
-- 
1.7.1





[Qemu-devel] [PATCH 21/32] qapi: move include files to include/qapi/

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 backends/rng-egd.c |2 +-
 backends/rng-random.c  |2 +-
 backends/rng.c |2 +-
 balloon.c  |2 +-
 block.c|2 +-
 block.h|2 +-
 block/qcow2.c  |2 +-
 block/qed.c|2 +-
 block_int.h|2 +-
 blockdev-nbd.c |2 +-
 blockdev.c |4 ++--
 blockdev.h |2 +-
 blockjob.c |2 +-
 dump-stub.c|2 +-
 dump.c |2 +-
 error.c|8 
 hmp.h  |2 +-
 hw/ivshmem.c   |2 +-
 hw/mc146818rtc.c   |2 +-
 hw/pci-hotplug.c   |2 +-
 hw/pcie_aer.c  |2 +-
 hw/qdev-addr.c |2 +-
 hw/qdev-core.h |2 +-
 hw/qdev-properties.c   |4 ++--
 hw/qdev.c  |4 ++--
 hw/vga_int.h   |2 +-
 hw/watchdog.c  |2 +-
 include/net/net.h  |2 +-
 include/net/slirp.h|2 +-
 .../qapi/dealloc-visitor.h |2 +-
 error.h => include/qapi/error.h|0
 {qapi => include/qapi}/opts-visitor.h  |2 +-
 {qapi => include/qapi}/qmp-input-visitor.h |4 ++--
 {qapi => include/qapi}/qmp-output-visitor.h|4 ++--
 qapi/qmp-core.h => include/qapi/qmp/dispatch.h |6 +++---
 json-lexer.h => include/qapi/qmp/json-lexer.h  |4 ++--
 json-parser.h => include/qapi/qmp/json-parser.h|4 ++--
 .../qapi/qmp/json-streamer.h   |4 ++--
 qbool.h => include/qapi/qmp/qbool.h|2 +-
 qdict.h => include/qapi/qmp/qdict.h|4 ++--
 qerror.h => include/qapi/qmp/qerror.h  |6 +++---
 qfloat.h => include/qapi/qmp/qfloat.h  |2 +-
 qint.h => include/qapi/qmp/qint.h  |2 +-
 qjson.h => include/qapi/qmp/qjson.h|4 ++--
 qlist.h => include/qapi/qmp/qlist.h|2 +-
 qobject.h => include/qapi/qmp/qobject.h|0
 qstring.h => include/qapi/qmp/qstring.h|2 +-
 qemu-objects.h => include/qapi/qmp/types.h |   16 
 {qapi => include/qapi}/string-input-visitor.h  |2 +-
 {qapi => include/qapi}/string-output-visitor.h |2 +-
 .../qapi/visitor-impl.h|4 ++--
 qapi/qapi-visit-core.h => include/qapi/visitor.h   |2 +-
 include/qemu/rng.h |2 +-
 include/ui/console.h   |4 ++--
 json-lexer.c   |   10 +-
 json-parser.c  |   18 +-
 json-streamer.c|   10 +-
 migration.h|4 ++--
 monitor.c  |   16 
 monitor.h  |4 ++--
 net/net.c  |2 +-
 qapi/opts-visitor.c|6 +++---
 qapi/qapi-dealloc-visitor.c|6 +++---
 qapi/qapi-visit-core.c |6 +++---
 qapi/qmp-dispatch.c|   10 +-
 qapi/qmp-input-visitor.c   |8 
 qapi/qmp-output-visitor.c  |8 
 qapi/qmp-registry.c|2 +-
 qapi/string-input-visitor.c|6 +++---
 qapi/string-output-visitor.c   |6 +++---
 qbool.c|4 ++--
 qdict.c|   12 ++--
 qemu-char.h|4 ++--
 qemu-config.c  |2 +-
 qemu-config.h  |2 +-
 qemu-img.c |2 +-
 qemu-option.c  |6 +++---
 qemu-option.h   

[Qemu-devel] [PATCH 01/32] libcacard: simplify rules for recursive build

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 Makefile |   10 +-
 1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 9ecbcbb..d06fbad 100644
--- a/Makefile
+++ b/Makefile
@@ -169,19 +169,11 @@ libqemustub.a: $(stub-obj-y)
 # Support building shared library libcacard
 
 .PHONY: libcacard.la install-libcacard
-ifeq ($(LIBTOOL),)
-libcacard.la:
-   @echo "libtool is missing, please install and rerun configure"; exit 1
-
-install-libcacard:
-   @echo "libtool is missing, please install and rerun configure"; exit 1
-else
-libcacard.la: $(oslib-obj-y) qemu-timer-common.o $(addsuffix .lo, $(basename 
$(trace-obj-y)))
+libcacard.la: $(oslib-obj-y) qemu-timer-common.o $(trace-obj-y)
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" 
TARGET_DIR="$*/" libcacard.la,)
 
 install-libcacard: libcacard.la
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libcacard V="$(V)" 
TARGET_DIR="$*/" install-libcacard,)
-endif
 
 ##
 
-- 
1.7.1





[Qemu-devel] [PATCH 4/4] HMP: Introduce console command

2012-12-06 Thread Lei Li
Signed-off-by: Lei Li 
---
 hmp-commands.hx |   21 +
 hmp.c   |   52 
 hmp.h   |1 +
 monitor.c   |   15 +++
 monitor.h   |3 +++
 5 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 3975e22..9ec5ed7 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -874,6 +874,27 @@ if the requested size is larger than it.
 ETEXI
 
 {
+.name   = "console",
+.args_type  = "chardev:s",
+.params = "chardev",
+.mhandler.cmd = hmp_console,
+},
+
+STEXI
+@item console @var{device}
+@findex console
+Connect to the serial console from within the monitor, allow to write data
+to memchardev @var{chardev}. Exit from the console and return back to
+monitor by 'ctrl-]' or enter.
+
+@example
+(qemu) console foo
+foo: data string...
+@end example
+
+ETEXI
+
+{
 .name   = "migrate",
 .args_type  = "detach:-d,blk:-b,inc:-i,uri:s",
 .params = "[-d] [-b] [-i] uri",
diff --git a/hmp.c b/hmp.c
index 413012f..a6c053c 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1365,3 +1365,55 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict 
*qdict)
 qmp_nbd_server_stop(&errp);
 hmp_handle_error(mon, &errp);
 }
+
+enum escape_char
+{
+ESCAPE_CHAR_CTRL_GS = 0x1d  /* ctrl-] used for escape */
+};
+
+static void hmp_read_console(Monitor *mon, const char *data,
+ void *opaque)
+{
+CharDriverState *chr = opaque;
+uint32_t size = strlen(data);
+enum escape_char console_escape = ESCAPE_CHAR_CTRL_GS;
+
+Error *err = NULL;
+
+if (*data == console_escape) {
+monitor_resume(mon);
+return;
+}
+
+qmp_memchar_write(chr->label, size, data, 0, 0, &err);
+
+if (err) {
+monitor_printf(mon, "%s\n", error_get_pretty(err));
+monitor_read_command(mon,1);
+error_free(err);
+return;
+}
+
+monitor_read_command(mon, 1);
+}
+
+void hmp_console(Monitor *mon, const QDict *qdict)
+{
+const char *device = qdict_get_str(qdict, "chardev");
+CharDriverState *chr;
+Error *err = NULL;
+
+chr = qemu_chr_find(device);
+
+if (!chr) {
+error_set(&err, QERR_DEVICE_NOT_FOUND, device);
+goto out;
+}
+
+if (monitor_read_console(mon, device, hmp_read_console, chr) < 0) {
+monitor_printf(mon, "Connect to console %s failed\n", device);
+}
+
+out:
+hmp_handle_error(mon, &err);
+}
diff --git a/hmp.h b/hmp.h
index 22a6646..9082324 100644
--- a/hmp.h
+++ b/hmp.h
@@ -82,5 +82,6 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict);
 void hmp_nbd_server_start(Monitor *mon, const QDict *qdict);
 void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
 void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
+void hmp_console(Monitor *mon, const QDict *qdict);
 
 #endif
diff --git a/monitor.c b/monitor.c
index c0e32d6..695a19a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -256,6 +256,21 @@ int monitor_read_password(Monitor *mon, ReadLineFunc 
*readline_func,
 }
 }
 
+int monitor_read_console(Monitor *mon, const char *device,
+ ReadLineFunc *readline_func, void *opaque)
+{
+char prompt[60];
+
+if (!mon->rs) {
+return -1;
+}
+
+snprintf(prompt, sizeof(prompt), "%s: ", device);
+readline_start(mon->rs, prompt, 0, readline_func, opaque);
+
+return 0;
+}
+
 void monitor_flush(Monitor *mon)
 {
 if (mon && mon->outbuf_index != 0 && !mon->mux_out) {
diff --git a/monitor.h b/monitor.h
index b4ef955..5f584b9 100644
--- a/monitor.h
+++ b/monitor.h
@@ -87,6 +87,9 @@ ReadLineState *monitor_get_rs(Monitor *mon);
 int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
   void *opaque);
 
+int monitor_read_console(Monitor *mon, const char *device,
+ ReadLineFunc *readline_func, void *opaque);
+
 int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret);
 
 int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret);
-- 
1.7.7.6




[Qemu-devel] [PATCH 2/4] QAPI: Introduce memchar-write QMP command

2012-12-06 Thread Lei Li
Signed-off-by: Lei Li 
---
 hmp-commands.hx  |   15 +++
 hmp.c|   13 +
 hmp.h|1 +
 qapi-schema.json |   41 +
 qemu-char.c  |   48 
 qmp-commands.hx  |   34 ++
 6 files changed, 152 insertions(+), 0 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 010b8c9..a60ba69 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -840,6 +840,21 @@ Inject an NMI on the given CPU (x86 only).
 ETEXI
 
 {
+.name   = "memchar_write",
+.args_type  = "chardev:s,data:s",
+.params = "chardev data",
+.mhandler.cmd = hmp_memchar_write,
+},
+
+STEXI
+@item memchar_write @var{chardev} @var{data}
+@findex memchar_write
+Provide writing interface for CirMemCharDriver. Write @var{data}
+to char device 'memory'.
+
+ETEXI
+
+{
 .name   = "migrate",
 .args_type  = "detach:-d,blk:-b,inc:-i,uri:s",
 .params = "[-d] [-b] [-i] uri",
diff --git a/hmp.c b/hmp.c
index 180ba2b..05b8c21 100644
--- a/hmp.c
+++ b/hmp.c
@@ -683,6 +683,19 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict)
 hmp_handle_error(mon, &errp);
 }
 
+void hmp_memchar_write(Monitor *mon, const QDict *qdict)
+{
+uint32_t size;
+const char *chardev = qdict_get_str(qdict, "chardev");
+const char *data = qdict_get_str(qdict, "data");
+Error *errp = NULL;
+
+size = strlen(data);
+qmp_memchar_write(chardev, size, data, false, 0, &errp);
+
+hmp_handle_error(mon, &errp);
+}
+
 static void hmp_cont_cb(void *opaque, int err)
 {
 if (!err) {
diff --git a/hmp.h b/hmp.h
index 0ab03be..3ea9896 100644
--- a/hmp.h
+++ b/hmp.h
@@ -43,6 +43,7 @@ void hmp_system_powerdown(Monitor *mon, const QDict *qdict);
 void hmp_cpu(Monitor *mon, const QDict *qdict);
 void hmp_memsave(Monitor *mon, const QDict *qdict);
 void hmp_pmemsave(Monitor *mon, const QDict *qdict);
+void hmp_memchar_write(Monitor *mon, const QDict *qdict);
 void hmp_cont(Monitor *mon, const QDict *qdict);
 void hmp_system_wakeup(Monitor *mon, const QDict *qdict);
 void hmp_inject_nmi(Monitor *mon, const QDict *qdict);
diff --git a/qapi-schema.json b/qapi-schema.json
index 5dfa052..d9fd635 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -325,6 +325,47 @@
 { 'command': 'query-chardev', 'returns': ['ChardevInfo'] }
 
 ##
+# @DataFormat:
+#
+# An enumeration of data format.
+#
+# @utf8: The data format is 'utf8'.
+#
+# @base64: The data format is 'base64'.
+#
+# Since: 1.4
+##
+{ 'enum': 'DataFormat'
+  'data': [ 'utf8', 'base64' ] }
+
+##
+# @memchar-write:
+#
+# Provide writing interface for memchardev. Write data to char
+# device 'memory'.
+#
+# @chardev: the name of the memory char device.
+#
+# @size: the size to write in bytes.
+#
+# @data: the source data write to memchar.
+#
+# @format: #optional the format of the data write to chardev 'memory',
+#  by default is 'utf8'.
+#
+# Returns: Nothing on success
+#  If @chardev is not a valid char device, DeviceNotFound
+#
+# Notes: For now assume 'drop' behaver, which would result in writes
+#dropping queued data.
+#
+# Since: 1.4
+##
+{ 'command': 'memchar-write',
+  'data': {'chardev': 'str', 'size': 'int', 'data': 'str',
+   '*format': 'DataFormat'} }
+
+##
 # @CommandInfo:
 #
 # Information about a QMP command
diff --git a/qemu-char.c b/qemu-char.c
index 3e45ce6..a407087 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2724,6 +2724,54 @@ fail:
 return NULL;
 }
 
+static bool qemu_is_chr(const CharDriverState *chr, const char *filename)
+{
+return strcmp(chr->filename, filename);
+}
+
+void qmp_memchar_write(const char *chardev, int64_t size,
+   const char *data, bool has_format,
+   enum DataFormat format,
+   Error **errp)
+{
+CharDriverState *chr;
+guchar *write_data;
+int ret;
+gsize write_count;
+
+chr = qemu_chr_find(chardev);
+if (!chr) {
+error_set(errp, QERR_DEVICE_NOT_FOUND, chardev);
+return;
+}
+
+if (qemu_is_chr(chr, "memory")) {
+error_setg(errp,"%s is not memory char device\n", chardev);
+return;
+}
+
+/* XXX: Drop the coming data when the buffer is full. */
+if (cirmem_chr_is_full(chr)) {
+error_setg(errp, "Memory device %s is full", chardev);
+return;
+}
+
+write_count = (gsize)size;
+
+if (has_format && (format == DATA_FORMAT_BASE64)) {
+write_data = g_base64_decode(data, &write_count);
+} else {
+write_data = (uint8_t *)data;
+}
+
+ret = cirmem_chr_write(chr, write_data, write_count);
+
+if (ret < 0) {
+error_setg(errp, "Failed to write to device %s", chardev);
+return;
+}
+}
+
 QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
 {
 char host[65], port[33], width[8], hei

[Qemu-devel] [PATCH 3/4] QAPI: Introduce memchar-read QMP command

2012-12-06 Thread Lei Li
Signed-off-by: Lei Li 
---
 hmp-commands.hx  |   19 ++
 hmp.c|   17 
 hmp.h|1 +
 qapi-schema.json |   25 +++
 qemu-char.c  |   57 ++
 qmp-commands.hx  |   34 
 6 files changed, 153 insertions(+), 0 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index a60ba69..3975e22 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -855,6 +855,25 @@ to char device 'memory'.
 ETEXI
 
 {
+.name   = "memchar_read",
+.args_type  = "chardev:s,size:i",
+.params = "chardev size",
+.mhandler.cmd = hmp_memchar_read,
+},
+
+STEXI
+@item memchar_read @var{chardev}
+@findex memchar_read
+Provide read interface for CirMemCharDriver. Read from char device
+'memory' and return @var{size} of the data.
+
+@var{size} is the size of data want to read from. Refer to unencoded
+size of the raw data, would adjust to the init size of the memchar
+if the requested size is larger than it.
+
+ETEXI
+
+{
 .name   = "migrate",
 .args_type  = "detach:-d,blk:-b,inc:-i,uri:s",
 .params = "[-d] [-b] [-i] uri",
diff --git a/hmp.c b/hmp.c
index 05b8c21..413012f 100644
--- a/hmp.c
+++ b/hmp.c
@@ -696,6 +696,23 @@ void hmp_memchar_write(Monitor *mon, const QDict *qdict)
 hmp_handle_error(mon, &errp);
 }
 
+void hmp_memchar_read(Monitor *mon, const QDict *qdict)
+{
+uint32_t size = qdict_get_int(qdict, "size");
+const char *chardev = qdict_get_str(qdict, "chardev");
+char *data;
+Error *errp = NULL;
+
+data = qmp_memchar_read(chardev, size, false, 0, &errp);
+if (errp) {
+monitor_printf(mon, "%s\n", error_get_pretty(errp));
+error_free(errp);
+return;
+}
+
+monitor_printf(mon, "%s\n", data);
+}
+
 static void hmp_cont_cb(void *opaque, int err)
 {
 if (!err) {
diff --git a/hmp.h b/hmp.h
index 3ea9896..22a6646 100644
--- a/hmp.h
+++ b/hmp.h
@@ -44,6 +44,7 @@ void hmp_cpu(Monitor *mon, const QDict *qdict);
 void hmp_memsave(Monitor *mon, const QDict *qdict);
 void hmp_pmemsave(Monitor *mon, const QDict *qdict);
 void hmp_memchar_write(Monitor *mon, const QDict *qdict);
+void hmp_memchar_read(Monitor *mon, const QDict *qdict);
 void hmp_cont(Monitor *mon, const QDict *qdict);
 void hmp_system_wakeup(Monitor *mon, const QDict *qdict);
 void hmp_inject_nmi(Monitor *mon, const QDict *qdict);
diff --git a/qapi-schema.json b/qapi-schema.json
index d9fd635..811377c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -366,6 +366,31 @@
'*format': 'DataFormat'} }
 
 ##
+# @memchar-read:
+#
+# Provide read interface for memchardev. Read from the char
+# device 'memory' and return the data.
+#
+# @chardev: the name of the memory char device.
+#
+# @size: the size to read in bytes.
+#
+# @format: #optional the format of the data want to read from
+#  memchardev, by default is 'utf8'.
+#
+# Returns: The data read from memchar as string
+#  If @chardev is not a valid memchr device, DeviceNotFound
+#
+# Notes: For now assume 'drop' behaver, which would result in reads
+#returning empty strings.
+#
+# Since: 1.4
+##
+{ 'command': 'memchar-read',
+  'data': {'chardev': 'str', 'size': 'int', '*format': 'DataFormat'},
+  'returns': 'str' }
+
+##
 # @CommandInfo:
 #
 # Information about a QMP command
diff --git a/qemu-char.c b/qemu-char.c
index a407087..b69b9dc 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2772,6 +2772,63 @@ void qmp_memchar_write(const char *chardev, int64_t size,
 }
 }
 
+char *qmp_memchar_read(const char *chardev, int64_t size,
+   bool has_format, enum DataFormat format,
+   Error **errp)
+{
+CharDriverState *chr;
+guchar *read_data;
+char *data = NULL;
+int ret;
+size_t count;
+
+chr = qemu_chr_find(chardev);
+if (!chr) {
+error_set(errp, QERR_DEVICE_NOT_FOUND, chardev);
+return NULL;
+}
+
+if (qemu_is_chr(chr, "memory")) {
+error_setg(errp,"%s is not memory char device\n", chardev);
+return NULL;
+}
+
+if (size <= 0) {
+error_setg(errp, "Failed to read from device %s", chardev);
+return NULL;
+}
+
+/* XXX: Return the empty strings when the buffer is empty. */
+if (cirmem_chr_is_empty(chr)) {
+error_setg(errp, "Memory device %s is empty", chardev);
+return NULL;
+}
+
+count = qemu_chr_cirmem_count(chr);
+size = size > count ? count : size;
+read_data = g_malloc0(size + 1);
+
+ret = cirmem_chr_read(chr, read_data, size);
+if (ret < 0) {
+error_setg(errp, "Failed to read from device %s", chardev);
+goto fail;
+}
+
+if (has_format && (format == DATA_FORMAT_BASE64)) {
+   if (read_data) {
+   data = g_base64_encode(read_data, (size_t)size);
+   }
+} else {
+dat

[Qemu-devel] [PATCH 0/4 V8] char: Add CirMemCharDriver and provide QMP interface

2012-12-06 Thread Lei Li
This patch series attempts to add new char backend CirMemCharDriver with
a circular buffer and expose it to users by introducing QMP interface
memchar-write and memchar-read and via the command line like the other
CharDriverStates.

Serial ports in qemu always use CharDriverStates as there backends,
Right now, all of our backends always try to write the data from the
guest to a socket or file. The concern from OpenStack is that this could
lead to unbounded disk space usage since they log the serial output.
For more detail of the background info:
https://bugs.launchpad.net/nova/+bug/832507

So we want to use a circular buffer in QEMU instead, and then OpenStack
can periodically read the buffer in QEMU and log it.

The QMP commands introduced like:

{ 'command': 'memchar-write',
  'data': {'chardev': 'str', 'size': 'int', 'data': 'str',
   'format': 'str' } }

{ 'command': 'memchar-read',
  'data': {'chardev': 'str', 'size': 'int', 'format': 'str' },
  'returns': 'str' }

Expose CirMemCharDriver via the command line like:

qemu -chardev memory,id=foo,maxcapacity=65536 -serial chardev:foo

Introduce HMP command 'console' like:

(qemu) console foo
foo: Input data

Note:
Now all of the feature were implemented, and the pervious comments
are fixed up too. Since this patch series have been for mailing list
for some time and missed 1.3, rebase it with minor fix.

Changes since v7:
  - Rebase the code and fix the format error pointed by Eric.
  - Modify the version info.

Changes since v6:
  - Improve the document based on Luiz's comments.
  - Keep pointing to the right position in cbuf for the case producer
and consumer might overflow for long running VMs pointed by Luiz.
  - Limit the size of read_data to the amount of bytes available in the
circular buffer.
  - Other fixups from Luiz.

Changes since v5:
  - Avoid writing the IAC information to the queue.
  - Grammar of the doc for command line options improved from Eric.

Changes since v4:
  - Get rid of all CongestionControl bits, and assume a dropping behavior
based on Luiz's suggestion for now. Will add it when we add async
support to QMP.
  - Squashed the patches about CirMemCharDriver in one.
  - Other fixups from Luiz.

Changes since v3:
  - Improve the algorithm of circular buffer based on Anthony's
suggestion.
  - Some changes suggested by Luiz and Blue.
  - And other fixups.

Changes since v2:
  - Add congestion mechanism. For the 'block' option as sync command,
will support it later when we gain the necessary infrastructure
enhancement.
  - Add HMP 'console' command so that can interact with multiple
chardevs via a single monitor socket.
  - Make the circular buffer backend and the current MemCharDriver
live in parallel, expose a new char backend with circular buffer
CirMemCharDriver suggested by Luiz.
  - Other fixs from Eric and Markus.

Changes since v1:
  - Exposing the MemCharDriver via command line.
  - Support base64 data format suggested by Anthony and Eric.
  - Follow the new rule for the name of qmp command from Eric.


Lei Li (4):
  qemu-char: Add new char backend CirMemCharDriver
  QAPI: Introduce memchar-write QMP command
  QAPI: Introduce memchar-read QMP command
  HMP: Introduce console command

 hmp-commands.hx  |   72 +++
 hmp.c|   99 +++
 hmp.h|3 +
 monitor.c|   15 
 monitor.h|3 +
 qapi-schema.json |   96 +
 qemu-char.c  |  217 ++
 qemu-config.c|3 +
 qemu-options.hx  |   10 +++
 qmp-commands.hx  |   89 +
 10 files changed, 607 insertions(+), 0 deletions(-)




[Qemu-devel] [PATCH 18/32] qapi: remove qapi/qapi-types-core.h

2012-12-06 Thread Paolo Bonzini
The file is only including error.h and qerror.h.  Prefer explicit
inclusion of whatever files are needed.
Signed-off-by: Paolo Bonzini 
---
 qapi/opts-visitor.c |1 +
 qapi/qapi-dealloc-visitor.c |1 +
 qapi/qapi-types-core.h  |   20 
 qapi/qapi-visit-core.c  |1 +
 qapi/qapi-visit-core.h  |2 +-
 qapi/qapi-visit-impl.h  |2 +-
 qemu-option-internal.h  |1 +
 qom/object.c|1 +
 scripts/qapi-commands.py|2 ++
 target-i386/cpu.c   |1 +
 10 files changed, 10 insertions(+), 22 deletions(-)
 delete mode 100644 qapi/qapi-types-core.h

diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index e3fd254..6ccb8a1 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu-common.h"
+#include "qerror.h"
 #include "opts-visitor.h"
 #include "qemu-queue.h"
 #include "qemu-option-internal.h"
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index 75214e7..7c44042 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -15,6 +15,7 @@
 #include "qemu-queue.h"
 #include "qemu-common.h"
 #include "qemu-objects.h"
+#include "qapi-visit-impl.h"
 
 typedef struct StackEntry
 {
diff --git a/qapi/qapi-types-core.h b/qapi/qapi-types-core.h
deleted file mode 100644
index 831df21..000
--- a/qapi/qapi-types-core.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Core Definitions for QAPI-generated Types
- *
- * Copyright IBM, Corp. 2011
- *
- * Authors:
- *  Anthony Liguori   
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-
-#ifndef QAPI_TYPES_CORE_H
-#define QAPI_TYPES_CORE_H
-
-#include "error.h"
-#include "qerror.h"
-
-#endif
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 3002939..4649fb7 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -12,6 +12,7 @@
  */
 
 #include "qemu-common.h"
+#include "qerror.h"
 #include "qapi/qapi-visit-core.h"
 #include "qapi/qapi-visit-impl.h"
 
diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h
index 60aceda..00ce678 100644
--- a/qapi/qapi-visit-core.h
+++ b/qapi/qapi-visit-core.h
@@ -13,7 +13,7 @@
 #ifndef QAPI_VISITOR_CORE_H
 #define QAPI_VISITOR_CORE_H
 
-#include "qapi/qapi-types-core.h"
+#include "error.h"
 #include 
 
 typedef struct GenericList
diff --git a/qapi/qapi-visit-impl.h b/qapi/qapi-visit-impl.h
index 0f3a189..efd4271 100644
--- a/qapi/qapi-visit-impl.h
+++ b/qapi/qapi-visit-impl.h
@@ -12,7 +12,7 @@
 #ifndef QAPI_VISITOR_IMPL_H
 #define QAPI_VISITOR_IMPL_H
 
-#include "qapi/qapi-types-core.h"
+#include "error.h"
 #include "qapi/qapi-visit-core.h"
 
 void input_type_enum(Visitor *v, int *obj, const char *strings[],
diff --git a/qemu-option-internal.h b/qemu-option-internal.h
index 19fdc1c..77899b0 100644
--- a/qemu-option-internal.h
+++ b/qemu-option-internal.h
@@ -27,6 +27,7 @@
 #define QEMU_OPTIONS_INTERNAL_H
 
 #include "qemu-option.h"
+#include "qemu-error.h"
 
 struct QemuOpt {
 const char   *name;
diff --git a/qom/object.c b/qom/object.c
index 0739aa2..8d3036d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -15,6 +15,7 @@
 #include "qapi/qapi-visit-core.h"
 #include "qapi/string-input-visitor.h"
 #include "qapi/string-output-visitor.h"
+#include "qerror.h"
 
 /* TODO: replace QObject with a simpler visitor to avoid a dependency
  * of the QOM core on QObject?  */
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 2db0bf1..5d034c2 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -367,6 +367,8 @@ def gen_command_def_prologue(prefix="", proxy=False):
  */
 
 #include "qemu-common.h"
+#include "module.h"
+#include "qerror.h"
 #include "qemu-objects.h"
 #include "qapi/qmp-core.h"
 #include "qapi/qapi-visit-core.h"
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f56aa0d..52f5e5e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -26,6 +26,7 @@
 
 #include "qemu-option.h"
 #include "qemu-config.h"
+#include "qerror.h"
 
 #include "qapi/qapi-visit-core.h"
 #include "arch_init.h"
-- 
1.7.1





[Qemu-devel] [PATCH 1/4] qemu-char: Add new char backend CirMemCharDriver

2012-12-06 Thread Lei Li
Signed-off-by: Lei Li 
---
 qemu-char.c |  131 +++
 qemu-config.c   |3 +
 qemu-options.hx |   10 
 3 files changed, 144 insertions(+), 0 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 242b799..3e45ce6 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -99,6 +99,7 @@
 #include "ui/qemu-spice.h"
 
 #define READ_BUF_LEN 4096
+#define CBUFF_SIZE 65536
 
 /***/
 /* character device */
@@ -2599,6 +2600,130 @@ size_t qemu_chr_mem_osize(const CharDriverState *chr)
 return d->outbuf_size;
 }
 
+/*/
+/*CircularMemory chardev*/
+
+typedef struct {
+size_t size;
+size_t head;
+size_t count;
+uint8_t *cbuf;
+} CirMemCharDriver;
+
+static bool cirmem_chr_is_empty(const CharDriverState *chr)
+{
+const CirMemCharDriver *d = chr->opaque;
+
+return d->count == 0;
+}
+
+static bool cirmem_chr_is_full(const CharDriverState *chr)
+{
+const CirMemCharDriver *d = chr->opaque;
+
+return d->count == d->size;
+}
+
+static size_t qemu_chr_cirmem_count(const CharDriverState *chr)
+{
+const CirMemCharDriver *d = chr->opaque;
+
+return d->count;
+}
+
+static int cirmem_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
+{
+CirMemCharDriver *d = chr->opaque;
+int i;
+int tail;
+
+if (!buf || (len < 0)) {
+return -1;
+}
+
+for (i = 0; i < len; i++ ) {
+/* Avoid writing the IAC information to the queue. */
+if ((unsigned char)buf[i] == IAC) {
+continue;
+}
+
+tail = (d->head + d->count) % d->size;
+d->cbuf[tail] = buf[i];
+if (d->count == d->size) {
+d->head = (d->head + 1) % d->size;
+} else {
+++d->count;
+}
+}
+
+return 0;
+}
+
+static int cirmem_chr_read(CharDriverState *chr, uint8_t *buf, int len)
+{
+CirMemCharDriver *d = chr->opaque;
+int i;
+
+if (cirmem_chr_is_empty(chr) || len < 0) {
+return -1;
+}
+
+for (i = 0; i < len; i++) {
+buf[i] = d->cbuf[d->head];
+d->head = (d->head + 1) % d->size;
+d->count--;
+
+if (cirmem_chr_is_empty(chr)) {
+break;
+}
+}
+
+return 0;
+}
+
+static void cirmem_chr_close(struct CharDriverState *chr)
+{
+CirMemCharDriver *d = chr->opaque;
+
+g_free(d->cbuf);
+g_free(d);
+chr->opaque = NULL;
+}
+
+static CharDriverState *qemu_chr_open_cirmemchr(QemuOpts *opts)
+{
+CharDriverState *chr;
+CirMemCharDriver *d;
+
+chr = g_malloc0(sizeof(CharDriverState));
+d = g_malloc(sizeof(*d));
+
+d->size = qemu_opt_get_number(opts, "maxcapacity", 0);
+if (d->size == 0) {
+d->size = CBUFF_SIZE;
+}
+
+/* The size must be power of 2 */
+if (d->size & (d->size - 1)) {
+goto fail;
+}
+
+d->head = 0;
+d->count = 0;
+d->cbuf = g_malloc0(d->size);
+
+chr->opaque = d;
+chr->chr_write = cirmem_chr_write;
+chr->chr_close = cirmem_chr_close;
+
+return chr;
+
+fail:
+g_free(d);
+g_free(chr);
+return NULL;
+}
+
 QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
 {
 char host[65], port[33], width[8], height[8];
@@ -2663,6 +2788,11 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const 
char *filename)
 qemu_opt_set(opts, "path", p);
 return opts;
 }
+if (strstart(filename, "memory", &p)) {
+qemu_opt_set(opts, "backend", "memory");
+qemu_opt_set(opts, "maxcapacity", p);
+return opts;
+}
 if (strstart(filename, "tcp:", &p) ||
 strstart(filename, "telnet:", &p)) {
 if (sscanf(p, "%64[^:]:%32[^,]%n", host, port, &pos) < 2) {
@@ -2736,6 +2866,7 @@ static const struct {
 { .name = "udp",   .open = qemu_chr_open_udp },
 { .name = "msmouse",   .open = qemu_chr_open_msmouse },
 { .name = "vc",.open = text_console_init },
+{ .name = "memory",.open = qemu_chr_open_cirmemchr },
 #ifdef _WIN32
 { .name = "file",  .open = qemu_chr_open_win_file_out },
 { .name = "pipe",  .open = qemu_chr_open_win_pipe },
diff --git a/qemu-config.c b/qemu-config.c
index 10d1ba4..ddc2a2a 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -217,6 +217,9 @@ static QemuOptsList qemu_chardev_opts = {
 },{
 .name = "debug",
 .type = QEMU_OPT_NUMBER,
+},{
+.name = "maxcapacity",
+.type = QEMU_OPT_NUMBER,
 },
 { /* end of list */ }
 },
diff --git a/qemu-options.hx b/qemu-options.hx
index de43b1b..fb1bae4 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1728,6 +1728,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
 "-chardev msmouse,id=id[,mux=on|off]\n"
 "-chardev 
vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
 " [,mux=on|off]

[Qemu-devel] [PATCH 22/32] block: move include files to include/block/

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 aes.c  |2 +-
 aio-posix.c|2 +-
 aio-win32.c|2 +-
 async.c|2 +-
 block-migration.c  |2 +-
 block.c|6 +++---
 block/blkdebug.c   |2 +-
 block/blkverify.c  |2 +-
 block/bochs.c  |2 +-
 block/cloop.c  |2 +-
 block/commit.c |4 ++--
 block/cow.c|2 +-
 block/curl.c   |2 +-
 block/dmg.c|2 +-
 block/gluster.c|2 +-
 block/iscsi.c  |2 +-
 block/linux-aio.c  |2 +-
 block/mirror.c |4 ++--
 block/nbd.c|4 ++--
 block/parallels.c  |2 +-
 block/qcow.c   |4 ++--
 block/qcow2-cache.c|2 +-
 block/qcow2-cluster.c  |2 +-
 block/qcow2-refcount.c |2 +-
 block/qcow2-snapshot.c |2 +-
 block/qcow2.c  |4 ++--
 block/qcow2.h  |4 ++--
 block/qed.h|2 +-
 block/raw-posix.c  |4 ++--
 block/raw-win32.c  |4 ++--
 block/raw.c|2 +-
 block/rbd.c|2 +-
 block/sheepdog.c   |2 +-
 block/stream.c |4 ++--
 block/vdi.c|2 +-
 block/vmdk.c   |2 +-
 block/vpc.c|2 +-
 block/vvfat.c  |2 +-
 block/win32-aio.c  |4 ++--
 blockdev-nbd.c |2 +-
 blockdev.c |4 ++--
 blockdev.h |2 +-
 blockjob.c |8 
 cmd.c  |2 +-
 coroutine-gthread.c|2 +-
 coroutine-sigaltstack.c|2 +-
 coroutine-ucontext.c   |2 +-
 coroutine-win32.c  |2 +-
 dma.h  |2 +-
 hw/9pfs/codir.c|2 +-
 hw/9pfs/cofile.c   |2 +-
 hw/9pfs/cofs.c |2 +-
 hw/9pfs/coxattr.c  |2 +-
 hw/9pfs/virtio-9p-coth.c   |2 +-
 hw/9pfs/virtio-9p-coth.h   |2 +-
 hw/9pfs/virtio-9p.h|2 +-
 hw/hd-geometry.c   |2 +-
 hw/hw.h|2 +-
 hw/ide/cmd646.c|2 +-
 hw/ide/ich.c   |2 +-
 hw/ide/isa.c   |2 +-
 hw/ide/macio.c |2 +-
 hw/ide/microdrive.c|2 +-
 hw/ide/mmio.c  |2 +-
 hw/ide/pci.c   |2 +-
 hw/ide/via.c   |2 +-
 hw/mips_fulong2e.c |2 +-
 hw/mips_malta.c|2 +-
 hw/musicpal.c  |2 +-
 hw/pflash_cfi01.c  |2 +-
 hw/pflash_cfi02.c  |2 +-
 hw/ppc405_boards.c |2 +-
 hw/s390-virtio-bus.c   |2 +-
 hw/s390-virtio.c   |2 +-
 hw/scsi.h  |2 +-
 hw/sd.c|2 +-
 hw/spitz.c |2 +-
 hw/tosa.c  |2 +-
 aes.h => include/block/aes.h   |0
 qemu-aio.h => include/block/aio.h

[Qemu-devel] [PATCH 07/32] build: kill libdis, move disassemblers to disas/

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 .gitignore |1 +
 Makefile   |9 +++---
 Makefile.dis   |   20 --
 Makefile.objs  |   19 ++---
 Makefile.target|5 +---
 bsd-user/elfload.c |2 +-
 configure  |   45 
 cpu-exec.c |2 +-
 disas.c|4 +-
 disas/Makefile.objs|   16 +++
 alpha-dis.c => disas/alpha.c   |2 +-
 arm-dis.c => disas/arm.c   |2 +-
 cris-dis.c => disas/cris.c |2 +-
 hppa-dis.c => disas/hppa.c |2 +-
 i386-dis.c => disas/i386.c |2 +-
 ia64-dis.c => disas/ia64.c |2 +-
 lm32-dis.c => disas/lm32.c |2 +-
 m68k-dis.c => disas/m68k.c |2 +-
 microblaze-dis.c => disas/microblaze.c |2 +-
 mips-dis.c => disas/mips.c |2 +-
 ppc-dis.c => disas/ppc.c   |2 +-
 s390-dis.c => disas/s390.c |2 +-
 sh4-dis.c => disas/sh4.c   |2 +-
 sparc-dis.c => disas/sparc.c   |2 +-
 tci-dis.c => disas/tci.c   |2 +-
 hw/loader.c|2 +-
 dis-asm.h => include/disas/bfd.h   |0
 disas.h => include/disas/disas.h   |0
 linux-user/elfload.c   |2 +-
 monitor.c  |2 +-
 qemu-log.h |2 +-
 target-alpha/translate.c   |2 +-
 target-arm/translate.c |2 +-
 target-cris/translate.c|2 +-
 target-i386/translate.c|2 +-
 target-lm32/translate.c|2 +-
 target-m68k/translate.c|2 +-
 target-microblaze/helper.c |2 +-
 target-microblaze/translate.c  |2 +-
 target-mips/translate.c|2 +-
 target-openrisc/translate.c|2 +-
 target-ppc/translate.c |2 +-
 target-ppc/translate_init.c|2 +-
 target-s390x/translate.c   |2 +-
 target-sh4/translate.c |2 +-
 target-sparc/translate.c   |2 +-
 target-unicore32/translate.c   |2 +-
 target-xtensa/translate.c  |2 +-
 translate-all.c|2 +-
 user-exec.c|2 +-
 vl.c   |2 +-
 51 files changed, 86 insertions(+), 115 deletions(-)
 delete mode 100644 Makefile.dis
 create mode 100644 disas/Makefile.objs
 rename alpha-dis.c => disas/alpha.c (99%)
 rename arm-dis.c => disas/arm.c (99%)
 rename cris-dis.c => disas/cris.c (99%)
 rename hppa-dis.c => disas/hppa.c (99%)
 rename i386-dis.c => disas/i386.c (99%)
 rename ia64-dis.c => disas/ia64.c (99%)
 rename lm32-dis.c => disas/lm32.c (99%)
 rename m68k-dis.c => disas/m68k.c (99%)
 rename microblaze-dis.c => disas/microblaze.c (99%)
 rename mips-dis.c => disas/mips.c (99%)
 rename ppc-dis.c => disas/ppc.c (99%)
 rename s390-dis.c => disas/s390.c (99%)
 rename sh4-dis.c => disas/sh4.c (99%)
 rename sparc-dis.c => disas/sparc.c (99%)
 rename tci-dis.c => disas/tci.c (98%)
 rename dis-asm.h => include/disas/bfd.h (100%)
 rename disas.h => include/disas/disas.h (100%)

diff --git a/.gitignore b/.gitignore
index bd6ba1c..ca52f01 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 config-devices.*
 config-all-devices.*
+config-all-disas.*
 config-host.*
 config-target.*
 trace.h
diff --git a/Makefile b/Makefile
index 5810718..da47cb8 100644
--- a/Makefile
+++ b/Makefile
@@ -99,6 +99,7 @@ defconfig:
rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
 
 -include config-all-devices.mak
+-include config-all-disas.mak
 
 all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all
 
@@ -129,9 +130,9 @@ $(SRC_PATH)/pixman/configure:
 
 $(SUBDIR_RULES): libqemustub.a
 
-$(filter %-softmmu,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) 
$(common-obj-y) $(extra-obj-y) subdir-libdis
+$(filter %-softmmu,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) 
$(common-obj-y) $(extra-obj-y)
 
-$(filter %-user,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) 
subdir-libdis-user subdir-libuser
+$(filter %-user,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) 
subdir-libuser
 
 ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
 romsubdir-%:
@@ -223,7 +224,7 @@ $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
 
 qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(oslib-obj-y) $(trace-obj-y) 
$(qapi-obj-y) $(qobject-obj-y) $(version-obj-y) libqemustub.a
 
-QEMULIBS=libuser libdis libdis-user
+QEMULIBS=libuser
 
 clean:
 # avoid old build problems by removing potentially incorrect old files
@@ -255,7 +256,7 @@ qemu-%.tar.bz2:
 
 distclean: clean
rm -f config-host.mak con

[Qemu-devel] [PATCH 26/32] qom: move include files to include/qom/

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 hw/qdev-core.h  |2 +-
 hw/stream.h |2 +-
 include/qemu/rng-random.h   |2 +-
 include/qemu/rng.h  |2 +-
 include/{qemu => qom}/cpu.h |2 +-
 include/{qemu => qom}/object.h  |0
 include/{qemu => qom}/qom-qobject.h |2 +-
 qmp.c   |2 +-
 qom/container.c |2 +-
 qom/cpu.c   |2 +-
 qom/object.c|4 ++--
 qom/qom-qobject.c   |4 ++--
 target-alpha/cpu-qom.h  |2 +-
 target-arm/cpu-qom.h|2 +-
 target-cris/cpu-qom.h   |2 +-
 target-i386/cpu-qom.h   |2 +-
 target-lm32/cpu-qom.h   |2 +-
 target-m68k/cpu-qom.h   |2 +-
 target-microblaze/cpu-qom.h |2 +-
 target-mips/cpu-qom.h   |2 +-
 target-openrisc/cpu.h   |2 +-
 target-ppc/cpu-qom.h|2 +-
 target-s390x/cpu-qom.h  |2 +-
 target-sh4/cpu-qom.h|2 +-
 target-sparc/cpu-qom.h  |2 +-
 target-unicore32/cpu-qom.h  |2 +-
 target-xtensa/cpu-qom.h |2 +-
 27 files changed, 28 insertions(+), 28 deletions(-)
 rename include/{qemu => qom}/cpu.h (99%)
 rename include/{qemu => qom}/object.h (100%)
 rename include/{qemu => qom}/qom-qobject.h (97%)

diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index 506977c..93a3a2a 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -4,7 +4,7 @@
 #include "qemu-queue.h"
 #include "qemu-option.h"
 #include "qemu-types.h"
-#include "qemu/object.h"
+#include "qom/object.h"
 #include "hw/irq.h"
 #include "qapi/error.h"
 
diff --git a/hw/stream.h b/hw/stream.h
index 21123a9..f6137d6 100644
--- a/hw/stream.h
+++ b/hw/stream.h
@@ -2,7 +2,7 @@
 #define STREAM_H 1
 
 #include "qemu-common.h"
-#include "qemu/object.h"
+#include "qom/object.h"
 
 /* stream slave. Used until qdev provides a generic way.  */
 #define TYPE_STREAM_SLAVE "stream-slave"
diff --git a/include/qemu/rng-random.h b/include/qemu/rng-random.h
index 6249290..4332772 100644
--- a/include/qemu/rng-random.h
+++ b/include/qemu/rng-random.h
@@ -12,7 +12,7 @@
 #ifndef QEMU_RNG_RANDOM_H
 #define QEMU_RNG_RANDOM_H
 
-#include "qemu/object.h"
+#include "qom/object.h"
 
 #define TYPE_RNG_RANDOM "rng-random"
 #define RNG_RANDOM(obj) OBJECT_CHECK(RndRandom, (obj), TYPE_RNG_RANDOM)
diff --git a/include/qemu/rng.h b/include/qemu/rng.h
index 3791297..509abd0 100644
--- a/include/qemu/rng.h
+++ b/include/qemu/rng.h
@@ -13,7 +13,7 @@
 #ifndef QEMU_RNG_H
 #define QEMU_RNG_H
 
-#include "qemu/object.h"
+#include "qom/object.h"
 #include "qemu-common.h"
 #include "qapi/error.h"
 
diff --git a/include/qemu/cpu.h b/include/qom/cpu.h
similarity index 99%
rename from include/qemu/cpu.h
rename to include/qom/cpu.h
index 61b7698..9682dd5 100644
--- a/include/qemu/cpu.h
+++ b/include/qom/cpu.h
@@ -20,7 +20,7 @@
 #ifndef QEMU_CPU_H
 #define QEMU_CPU_H
 
-#include "qemu/object.h"
+#include "qom/object.h"
 #include "qemu-thread.h"
 
 /**
diff --git a/include/qemu/object.h b/include/qom/object.h
similarity index 100%
rename from include/qemu/object.h
rename to include/qom/object.h
diff --git a/include/qemu/qom-qobject.h b/include/qom/qom-qobject.h
similarity index 97%
rename from include/qemu/qom-qobject.h
rename to include/qom/qom-qobject.h
index f9dff12..77cd717 100644
--- a/include/qemu/qom-qobject.h
+++ b/include/qom/qom-qobject.h
@@ -13,7 +13,7 @@
 #ifndef QEMU_QOM_QOBJECT_H
 #define QEMU_QOM_QOBJECT_H
 
-#include "qemu/object.h"
+#include "qom/object.h"
 
 /*
  * object_property_get_qobject:
diff --git a/qmp.c b/qmp.c
index e873f0a..5b3a5d7 100644
--- a/qmp.c
+++ b/qmp.c
@@ -23,7 +23,7 @@
 #include "arch_init.h"
 #include "hw/qdev.h"
 #include "blockdev.h"
-#include "qemu/qom-qobject.h"
+#include "qom/qom-qobject.h"
 
 NameInfo *qmp_query_name(Error **errp)
 {
diff --git a/qom/container.c b/qom/container.c
index 4ca8b5c..ceb0f01 100644
--- a/qom/container.c
+++ b/qom/container.c
@@ -10,7 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include "qemu/object.h"
+#include "qom/object.h"
 #include "module.h"
 #include 
 
diff --git a/qom/cpu.c b/qom/cpu.c
index 5b36046..d4d436f 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -18,7 +18,7 @@
  * 
  */
 
-#include "qemu/cpu.h"
+#include "qom/cpu.h"
 #include "qemu-common.h"
 
 void cpu_reset(CPUState *cpu)
diff --git a/qom/object.c b/qom/object.c
index 932f8b3..351b88c 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -10,7 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include "qemu/object.h"
+#include "qom/object.h"
 #include "qemu-common.h"
 #include "qapi/visitor.h"
 #include "qapi/string-input-visitor.h"
@@ -19,7 +19,7 @@
 
 /* TODO: replace QObject with a simpler visitor to avoid a depend

[Qemu-devel] [PATCH 10/32] janitor: do not include qemu-char everywhere

2012-12-06 Thread Paolo Bonzini
Touching char/char.h basically causes the whole of QEMU to
be rebuilt.  Avoid this, it is usually unnecessary.

Signed-off-by: Paolo Bonzini 
---
 audio/alsaaudio.c|1 -
 audio/ossaudio.c |1 -
 block/raw-posix.c|1 -
 bt-host.c|1 -
 bt-vhci.c|1 -
 buffered_file.c  |1 -
 console.c|1 +
 console.h|1 -
 hmp.c|1 +
 hw/9pfs/virtio-9p-coth.c |1 -
 hw/ivshmem.c |1 +
 hw/spapr_hcall.c |2 --
 hw/strongarm.c   |1 +
 hw/xen_disk.c|1 -
 hw/xen_nic.c |1 -
 hw/xilinx_axidma.c   |1 -
 hw/xilinx_axienet.c  |1 -
 hw/xtensa_lx60.c |1 +
 iohandler.c  |1 -
 migration-exec.c |1 -
 migration-fd.c   |1 -
 migration-tcp.c  |1 -
 migration-unix.c |1 -
 monitor.h|1 -
 net/slirp.c  |1 +
 net/socket.c |1 -
 net/tap.c|1 -
 net/vde.c|1 -
 qmp.c|1 +
 savevm.c |1 -
 ui/qemu-spice.h  |1 -
 31 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 564d632..cd553c2 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -24,7 +24,6 @@
 #include 
 #include "qemu-common.h"
 #include "main-loop.h"
-#include "qemu-char.h"
 #include "audio.h"
 
 #if QEMU_GNUC_PREREQ(4, 3)
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 45abe39..8249a00 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -33,7 +33,6 @@
 #include "qemu-common.h"
 #include "main-loop.h"
 #include "host-utils.h"
-#include "qemu-char.h"
 #include "audio.h"
 
 #define AUDIO_CAP "oss"
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 550c81f..aa8b96f 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -23,7 +23,6 @@
  */
 #include "qemu-common.h"
 #include "qemu-timer.h"
-#include "qemu-char.h"
 #include "qemu-log.h"
 #include "block_int.h"
 #include "module.h"
diff --git a/bt-host.c b/bt-host.c
index 8b47370..3118645 100644
--- a/bt-host.c
+++ b/bt-host.c
@@ -18,7 +18,6 @@
  */
 
 #include "qemu-common.h"
-#include "qemu-char.h"
 #include "net.h"
 #include "bt-host.h"
 #include "main-loop.h"
diff --git a/bt-vhci.c b/bt-vhci.c
index 878460a..6fecb66 100644
--- a/bt-vhci.c
+++ b/bt-vhci.c
@@ -18,7 +18,6 @@
  */
 
 #include "qemu-common.h"
-#include "qemu-char.h"
 #include "net.h"
 #include "hw/bt.h"
 #include "main-loop.h"
diff --git a/buffered_file.c b/buffered_file.c
index bd0f61d..f13443e 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -16,7 +16,6 @@
 #include "qemu-common.h"
 #include "hw/hw.h"
 #include "qemu-timer.h"
-#include "qemu-char.h"
 #include "buffered_file.h"
 
 //#define DEBUG_BUFFERED_FILE
diff --git a/console.c b/console.c
index 048b48e..9ac7b28 100644
--- a/console.c
+++ b/console.c
@@ -25,6 +25,7 @@
 #include "console.h"
 #include "qemu-timer.h"
 #include "qmp-commands.h"
+#include "qemu-char.h"
 
 //#define DEBUG_CONSOLE
 #define DEFAULT_BACKSCROLL 512
diff --git a/console.h b/console.h
index 50a0512..6fcca23 100644
--- a/console.h
+++ b/console.h
@@ -1,7 +1,6 @@
 #ifndef CONSOLE_H
 #define CONSOLE_H
 
-#include "qemu-char.h"
 #include "qemu-pixman.h"
 #include "qdict.h"
 #include "notify.h"
diff --git a/hmp.c b/hmp.c
index 180ba2b..873962f 100644
--- a/hmp.c
+++ b/hmp.c
@@ -15,6 +15,7 @@
 
 #include "hmp.h"
 #include "net.h"
+#include "qemu-char.h"
 #include "qemu-option.h"
 #include "qemu-timer.h"
 #include "qmp-commands.h"
diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c
index 25556cc..9368df7 100644
--- a/hw/9pfs/virtio-9p-coth.c
+++ b/hw/9pfs/virtio-9p-coth.c
@@ -12,7 +12,6 @@
  *
  */
 
-#include "qemu-char.h"
 #include "fsdev/qemu-fsdev.h"
 #include "qemu-thread.h"
 #include "qemu-coroutine.h"
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index f6dbb21..320ac8d 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -24,6 +24,7 @@
 #include "migration.h"
 #include "qerror.h"
 #include "event_notifier.h"
+#include "qemu-char.h"
 
 #include 
 #include 
diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index 63cadb8..1fac362 100644
--- a/hw/spapr_hcall.c
+++ b/hw/spapr_hcall.c
@@ -1,8 +1,6 @@
 #include "sysemu.h"
 #include "cpu.h"
-#include "qemu-char.h"
 #include "sysemu.h"
-#include "qemu-char.h"
 #include "helper_regs.h"
 #include "hw/spapr.h"
 
diff --git a/hw/strongarm.c b/hw/strongarm.c
index 4385515..44bec34 100644
--- a/hw/strongarm.c
+++ b/hw/strongarm.c
@@ -30,6 +30,7 @@
 #include "strongarm.h"
 #include "qemu-error.h"
 #include "arm-misc.h"
+#include "qemu-char.h"
 #include "sysemu.h"
 #include "ssi.h"
 
diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index e6bb2f2..423b580 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -36,7 +36,6 @@
 #include 
 
 #include "hw.h"
-#include "qemu-char.h"
 #include "xen_backend.h"

Re: [Qemu-devel] buildbot failure in qemu on virtfs_x86_64_debian_6_0

2012-12-06 Thread Aneesh Kumar K.V
q...@buildbot.b1-systems.de writes:

> The Buildbot has detected a new failure on builder virtfs_x86_64_debian_6_0 
> while building qemu.
> Full details are available at:
>  
> http://buildbot.b1-systems.de/qemu/builders/virtfs_x86_64_debian_6_0/builds/307
>
> Buildbot URL: http://buildbot.b1-systems.de/qemu/
>
> Buildslave for this Build: yuzuki
>
> Build Reason: The Nightly scheduler named 'nightly_virtfs' triggered this 
> build
> Build Source Stamp: [branch for-upstream] HEAD
> Blamelist: 
>
> BUILD FAILED: failed git

Hmm, My github repo changed this week from QEMU.git to qemu.git. 

git://github.com/kvaneesh/qemu.git

The backing repo for the earlier one was pointing to a wrong one. I am
not sure how that happened. I remember forking the right QEMU.git.

-aneesh




Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk.

2012-12-06 Thread KONRAD Frédéric

On 06/12/2012 15:21, Peter Maydell wrote:

On 6 December 2012 13:58, KONRAD Frédéric  wrote:

On 06/12/2012 11:13, Peter Maydell wrote:

It can't just be a command line alias, or we will break migration.
It has to be a simple device that composes together the virtio-pci
and virtio-blk devices, plus legacy support for properties and
migration state, I think.

Can we do virtio-blk refactoring and virtio-blk-pci at the same time for not
breaking anything ?

Not breaking things is a key part of the requirements here.

Agree with that.


It's ok to say "I haven't converted virtio-net or the s390
transport in this patchset and therefore they are broken" as
an initial RFC (because we can look at how PCI/blk is done
and check it works before we expand the same thing out to
other transports/devices).  But you need to show how the
virtio-blk / virtio-pci refactoring works and leaves you with
a virtio-blk-pci that isn't broken (either at the end or at
any step along the way).

And if virtio-blk-pci is broken can we refactor it in the same "patch" ?



-- PMM






[Qemu-devel] [PATCH 12/32] net: do not include net.h everywhere

2012-12-06 Thread Paolo Bonzini
Acked-by: Paolo Bonzini 
Signed-off-by: Paolo Bonzini 
---
 arch_init.c  |1 -
 hw/alpha_sys.h   |1 -
 hw/device-hotplug.c  |1 -
 hw/lm32_boards.c |1 -
 hw/milkymist-hw.h|1 +
 hw/milkymist.c   |1 -
 hw/s390-virtio-bus.c |1 -
 hw/spapr_vscsi.c |1 -
 hw/virtex_ml507.c|1 -
 hw/virtio-net.h  |1 -
 hw/virtio-pci.c  |1 -
 hw/virtio-scsi.h |1 -
 hw/xen_backend.h |1 -
 hw/xen_platform.c|1 -
 input.c  |1 -
 qemu-char.c  |1 -
 qemu-timer.c |1 -
 17 files changed, 1 insertions(+), 16 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index dde7fad..1973037 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -40,7 +40,6 @@
 #include "hw/audiodev.h"
 #include "kvm.h"
 #include "migration.h"
-#include "net.h"
 #include "gdbstub.h"
 #include "hw/smbios.h"
 #include "exec-memory.h"
diff --git a/hw/alpha_sys.h b/hw/alpha_sys.h
index 7604d09..f39723d 100644
--- a/hw/alpha_sys.h
+++ b/hw/alpha_sys.h
@@ -6,7 +6,6 @@
 #include "pci.h"
 #include "pci_host.h"
 #include "ide.h"
-#include "net.h"
 #include "pc.h"
 #include "irq.h"
 
diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c
index eec0fe3..f896cb4 100644
--- a/hw/device-hotplug.c
+++ b/hw/device-hotplug.c
@@ -24,7 +24,6 @@
 
 #include "hw.h"
 #include "boards.h"
-#include "net.h"
 #include "blockdev.h"
 #include "qemu-config.h"
 #include "sysemu.h"
diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c
index 772cb8b..f59d3bf 100644
--- a/hw/lm32_boards.c
+++ b/hw/lm32_boards.c
@@ -19,7 +19,6 @@
 
 #include "sysbus.h"
 #include "hw.h"
-#include "net.h"
 #include "flash.h"
 #include "devices.h"
 #include "boards.h"
diff --git a/hw/milkymist-hw.h b/hw/milkymist-hw.h
index 96b2a7f..0253b7a 100644
--- a/hw/milkymist-hw.h
+++ b/hw/milkymist-hw.h
@@ -3,6 +3,7 @@
 
 #include "qdev.h"
 #include "qdev-addr.h"
+#include "net.h"
 
 static inline DeviceState *milkymist_uart_create(hwaddr base,
 qemu_irq irq)
diff --git a/hw/milkymist.c b/hw/milkymist.c
index 4c8111a..c26ea4a 100644
--- a/hw/milkymist.c
+++ b/hw/milkymist.c
@@ -19,7 +19,6 @@
 
 #include "sysbus.h"
 #include "hw.h"
-#include "net.h"
 #include "flash.h"
 #include "sysemu.h"
 #include "devices.h"
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index e0ac2d1..169dd46 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -20,7 +20,6 @@
 #include "hw.h"
 #include "block.h"
 #include "sysemu.h"
-#include "net.h"
 #include "boards.h"
 #include "monitor.h"
 #include "loader.h"
diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c
index e3d4b23..2d81132 100644
--- a/hw/spapr_vscsi.c
+++ b/hw/spapr_vscsi.c
@@ -34,7 +34,6 @@
 #include "hw.h"
 #include "scsi.h"
 #include "scsi-defs.h"
-#include "net.h" /* Remove that when we can */
 #include "srp.h"
 #include "hw/qdev.h"
 #include "hw/spapr.h"
diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c
index 6ab8fee..1fdbc49 100644
--- a/hw/virtex_ml507.c
+++ b/hw/virtex_ml507.c
@@ -25,7 +25,6 @@
 #include "sysbus.h"
 #include "hw.h"
 #include "serial.h"
-#include "net.h"
 #include "flash.h"
 #include "sysemu.h"
 #include "devices.h"
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 36aa463..58661d9 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -15,7 +15,6 @@
 #define _QEMU_VIRTIO_NET_H
 
 #include "virtio.h"
-#include "net.h"
 #include "pci.h"
 
 #define ETH_ALEN6
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 71f4fb5..2f3507a 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -26,7 +26,6 @@
 #include "qemu-error.h"
 #include "msi.h"
 #include "msix.h"
-#include "net.h"
 #include "loader.h"
 #include "kvm.h"
 #include "blockdev.h"
diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h
index 91924f6..8635dab 100644
--- a/hw/virtio-scsi.h
+++ b/hw/virtio-scsi.h
@@ -15,7 +15,6 @@
 #define _QEMU_VIRTIO_SCSI_H
 
 #include "virtio.h"
-#include "net.h"
 #include "pci.h"
 
 /* The ID for virtio_scsi */
diff --git a/hw/xen_backend.h b/hw/xen_backend.h
index fea86dd..3305630 100644
--- a/hw/xen_backend.h
+++ b/hw/xen_backend.h
@@ -4,7 +4,6 @@
 #include "xen_common.h"
 #include "sysemu.h"
 #include "net.h"
-#include "net/hub.h"
 
 /* - */
 
diff --git a/hw/xen_platform.c b/hw/xen_platform.c
index a54e7a2..982e1aa 100644
--- a/hw/xen_platform.c
+++ b/hw/xen_platform.c
@@ -30,7 +30,6 @@
 #include "pci.h"
 #include "irq.h"
 #include "xen_common.h"
-#include "net.h"
 #include "xen_backend.h"
 #include "trace.h"
 #include "exec-memory.h"
diff --git a/input.c b/input.c
index 25d3973..123bb23 100644
--- a/input.c
+++ b/input.c
@@ -23,7 +23,6 @@
  */
 
 #include "sysemu.h"
-#include "net.h"
 #include "monitor.h"
 #include "console.h"
 #include "error.h"
diff --git a/qemu-char.c b/qemu-char.c
index 242b799..f066ad0 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 #include "qemu-common.h"
-#include "net.h"
 #include "monitor.h"
 #include "

[Qemu-devel] [PATCH 11/32] net: move Bluetooth stuff out of net.h

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 bt-host.c  |1 -
 bt-host.h  |   13 -
 bt-vhci.c  |2 +-
 hw/bt-hci-csr.c|2 +-
 hw/bt-hci.c|2 +-
 hw/bt.c|2 +-
 hw/usb/dev-bluetooth.c |2 +-
 net.h  |   14 --
 8 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/bt-host.c b/bt-host.c
index 3118645..65aaca3 100644
--- a/bt-host.c
+++ b/bt-host.c
@@ -18,7 +18,6 @@
  */
 
 #include "qemu-common.h"
-#include "net.h"
 #include "bt-host.h"
 #include "main-loop.h"
 
diff --git a/bt-host.h b/bt-host.h
index f1eff65..2bc6d53 100644
--- a/bt-host.h
+++ b/bt-host.h
@@ -1,9 +1,20 @@
 #ifndef BT_HOST_H
 #define BT_HOST_H
 
-struct HCIInfo;
+/* BT HCI info */
+
+struct HCIInfo {
+int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
+void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
+void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
+void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len);
+void *opaque;
+void (*evt_recv)(void *opaque, const uint8_t *data, int len);
+void (*acl_recv)(void *opaque, const uint8_t *data, int len);
+};
 
 /* bt-host.c */
 struct HCIInfo *bt_host_hci(const char *id);
+struct HCIInfo *qemu_next_hci(void);
 
 #endif
diff --git a/bt-vhci.c b/bt-vhci.c
index 6fecb66..13c0e53 100644
--- a/bt-vhci.c
+++ b/bt-vhci.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu-common.h"
-#include "net.h"
+#include "bt-host.h"
 #include "hw/bt.h"
 #include "main-loop.h"
 
diff --git a/hw/bt-hci-csr.c b/hw/bt-hci-csr.c
index 772b677..0faabbb 100644
--- a/hw/bt-hci-csr.c
+++ b/hw/bt-hci-csr.c
@@ -22,7 +22,7 @@
 #include "qemu-char.h"
 #include "qemu-timer.h"
 #include "irq.h"
-#include "net.h"
+#include "bt-host.h"
 #include "bt.h"
 
 struct csrhci_s {
diff --git a/hw/bt-hci.c b/hw/bt-hci.c
index e54cfd7..d2ad57f 100644
--- a/hw/bt-hci.c
+++ b/hw/bt-hci.c
@@ -21,7 +21,7 @@
 #include "qemu-common.h"
 #include "qemu-timer.h"
 #include "usb.h"
-#include "net.h"
+#include "bt-host.h"
 #include "bt.h"
 
 struct bt_hci_s {
diff --git a/hw/bt.c b/hw/bt.c
index dc99fc2..3fea098 100644
--- a/hw/bt.c
+++ b/hw/bt.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu-common.h"
-#include "net.h"
+#include "bt-host.h"
 #include "bt.h"
 
 /* Slave implementations can ignore this */
diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c
index 39984f5..4a37442 100644
--- a/hw/usb/dev-bluetooth.c
+++ b/hw/usb/dev-bluetooth.c
@@ -21,7 +21,7 @@
 #include "qemu-common.h"
 #include "hw/usb.h"
 #include "hw/usb/desc.h"
-#include "net.h"
+#include "bt-host.h"
 #include "hw/bt.h"
 
 struct USBBtState {
diff --git a/net.h b/net.h
index 04fda1d..1d0816b 100644
--- a/net.h
+++ b/net.h
@@ -133,20 +133,6 @@ extern int nb_nics;
 extern NICInfo nd_table[MAX_NICS];
 extern int default_net;
 
-/* BT HCI info */
-
-struct HCIInfo {
-int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
-void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
-void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
-void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len);
-void *opaque;
-void (*evt_recv)(void *opaque, const uint8_t *data, int len);
-void (*acl_recv)(void *opaque, const uint8_t *data, int len);
-};
-
-struct HCIInfo *qemu_next_hci(void);
-
 /* from net.c */
 extern const char *legacy_tftp_prefix;
 extern const char *legacy_bootp_filename;
-- 
1.7.1





[Qemu-devel] [PATCH 02/32] vscclient: use per-target variables

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 Makefile |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index d06fbad..7e38112 100644
--- a/Makefile
+++ b/Makefile
@@ -189,8 +189,9 @@ qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) 
$(block-obj-y) libqemustub.a
 
 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
 
+vscclient$(EXESUF): LIBS += $(libcacard_libs)
 vscclient$(EXESUF): $(libcacard-y) $(oslib-obj-y) $(trace-obj-y) 
libcacard/vscclient.o libqemustub.a
-   $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(libcacard_libs) 
$(LIBS),"  LINK  $@")
+   $(call LINK, $^)
 
 fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o 
fsdev/virtio-9p-marshal.o oslib-posix.o $(trace-obj-y)
 fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
-- 
1.7.1





[Qemu-devel] [PATCH 5/6] qcow2: Move BLKDBG_EVENT out of the lock

2012-12-06 Thread Kevin Wolf
We want to use these events to suspend requests for testing concurrent
AIO requests. Suspending requests while they are holding the CoMutex is
rather boring for this purpose.

Signed-off-by: Kevin Wolf 
---
 block/qcow2.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index c1ff31f..0a08ec7 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -835,8 +835,8 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState 
*bs,
 cur_nr_sectors * 512);
 }
 
-BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
 qemu_co_mutex_unlock(&s->lock);
+BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
 trace_qcow2_writev_data(qemu_coroutine_self(),
 (cluster_offset >> 9) + index_in_cluster);
 ret = bdrv_co_writev(bs->file,
-- 
1.7.6.5




[Qemu-devel] [PATCH 08/32] build: kill libuser

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 Makefile|8 +++-
 Makefile.objs   |3 ++-
 Makefile.target |3 +--
 Makefile.user   |   24 
 configure   |3 ---
 5 files changed, 6 insertions(+), 35 deletions(-)
 delete mode 100644 Makefile.user

diff --git a/Makefile b/Makefile
index da47cb8..0c6ad1e 100644
--- a/Makefile
+++ b/Makefile
@@ -132,7 +132,7 @@ $(SUBDIR_RULES): libqemustub.a
 
 $(filter %-softmmu,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) 
$(common-obj-y) $(extra-obj-y)
 
-$(filter %-user,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) 
subdir-libuser
+$(filter %-user,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) 
$(user-obj-y)
 
 ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
 romsubdir-%:
@@ -224,8 +224,6 @@ $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
 
 qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(oslib-obj-y) $(trace-obj-y) 
$(qapi-obj-y) $(qobject-obj-y) $(version-obj-y) libqemustub.a
 
-QEMULIBS=libuser
-
 clean:
 # avoid old build problems by removing potentially incorrect old files
rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h 
gen-op-arm.h
@@ -242,7 +240,7 @@ clean:
rm -rf qapi-generated
rm -rf qga/qapi-generated
$(MAKE) -C tests/tcg clean
-   for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \
+   for d in $(ALL_SUBDIRS) libcacard; do \
if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
rm -f $$d/qemu-options.def; \
 done
@@ -265,7 +263,7 @@ distclean: clean
rm -f config.log
rm -f linux-headers/asm
rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi 
qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf 
qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr
-   for d in $(TARGET_DIRS) $(QEMULIBS); do \
+   for d in $(TARGET_DIRS); do \
rm -rf $$d || exit 1 ; \
 done
if test -f pixman/config.log; then make -C pixman distclean; fi
diff --git a/Makefile.objs b/Makefile.objs
index 26793f1..0fb3904 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -121,7 +121,6 @@ user-obj-y += tcg-runtime.o host-utils.o
 user-obj-y += cache-utils.o
 user-obj-y += module.o
 user-obj-y += qemu-user.o
-user-obj-y += $(trace-obj-y)
 user-obj-y += qom/
 
 ##
@@ -194,6 +193,8 @@ trace-obj-y += trace/control.o
 
 $(trace-obj-y): $(GENERATED_HEADERS)
 
+universal-obj-y += $(trace-obj-y)
+
 ##
 # smartcard
 
diff --git a/Makefile.target b/Makefile.target
index f353651..8bbad38 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -155,9 +155,8 @@ all-obj-y += $(addprefix ../, $(universal-obj-y))
 
 ifdef CONFIG_SOFTMMU
 all-obj-y += $(addprefix ../, $(common-obj-y))
-all-obj-y += $(addprefix ../, $(trace-obj-y))
 else
-all-obj-y += $(addprefix ../libuser/, $(user-obj-y))
+all-obj-y += $(addprefix ../, $(user-obj-y))
 endif #CONFIG_LINUX_USER
 
 ifdef QEMU_PROGW
diff --git a/Makefile.user b/Makefile.user
deleted file mode 100644
index 9302d33..000
--- a/Makefile.user
+++ /dev/null
@@ -1,24 +0,0 @@
-# Makefile for qemu target independent user files.
-
-include ../config-host.mak
-include $(SRC_PATH)/rules.mak
--include config.mak
-
-.PHONY: all
-
-$(call set-vpath, $(SRC_PATH))
-
-QEMU_CFLAGS+=-I..
-QEMU_CFLAGS += -I$(SRC_PATH)/include
-QEMU_CFLAGS += -DCONFIG_USER_ONLY
-
-include $(SRC_PATH)/Makefile.objs
-
-all: $(user-obj-y)
-# Dummy command so that make thinks it has done something
-   @true
-
-clean:
-   for d in . trace; do \
-   rm -f $$d/*.o $$d/*.d $$d/*.a $$d/*~; \
-   done
diff --git a/configure b/configure
index ce9761b..ec07c76 100755
--- a/configure
+++ b/configure
@@ -4205,9 +4205,6 @@ for rom in seabios vgabios ; do
 echo "LD=$ld" >> $config_mak
 done
 
-d=libuser
-symlink "$source_path/Makefile.user" "$d/Makefile"
-
 if test "$docs" = "yes" ; then
   mkdir -p QMP
 fi
-- 
1.7.1





Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk.

2012-12-06 Thread Peter Maydell
On 6 December 2012 13:58, KONRAD Frédéric  wrote:
> On 06/12/2012 11:13, Peter Maydell wrote:
>> It can't just be a command line alias, or we will break migration.
>> It has to be a simple device that composes together the virtio-pci
>> and virtio-blk devices, plus legacy support for properties and
>> migration state, I think.

> Can we do virtio-blk refactoring and virtio-blk-pci at the same time for not
> breaking anything ?

Not breaking things is a key part of the requirements here.
It's ok to say "I haven't converted virtio-net or the s390
transport in this patchset and therefore they are broken" as
an initial RFC (because we can look at how PCI/blk is done
and check it works before we expand the same thing out to
other transports/devices).  But you need to show how the
virtio-blk / virtio-pci refactoring works and leaves you with
a virtio-blk-pci that isn't broken (either at the end or at
any step along the way).

-- PMM



[Qemu-devel] [PATCH 09/32] janitor: do not rely on indirect inclusions of or from qemu-char.h

2012-12-06 Thread Paolo Bonzini
Various header files rely on qemu-char.h including qemu-config.h or
main-loop.h, but they really do not need qemu-char.h at all (particularly
interesting is the case of the block layer!).  Clean this up, and also
add missing inclusions of qemu-char.h itself.

Signed-off-by: Paolo Bonzini 
---
 arch_init.c|1 +
 audio/alsaaudio.c  |1 +
 audio/ossaudio.c   |1 +
 block/blkdebug.c   |1 +
 block/iscsi.c  |1 +
 bt-host.c  |1 +
 bt-vhci.c  |1 +
 event_notifier-posix.c |1 +
 exec.c |1 +
 hw/arm_boot.c  |1 +
 hw/dma.c   |1 +
 hw/fw_cfg.c|1 +
 hw/jazz_led.c  |1 +
 hw/mac_dbdma.c |1 +
 hw/puv3.c  |2 ++
 hw/qdev-monitor.c  |1 +
 hw/qdev-properties.c   |1 +
 hw/s390x/sclpconsole.c |1 +
 hw/tcx.c   |1 +
 hw/usb/dev-network.c   |1 +
 net.c  |1 +
 qemu-config.h  |1 +
 spice-qemu-char.c  |1 +
 target-i386/kvm.c  |1 +
 24 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index e6effe8..dde7fad 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -46,6 +46,7 @@
 #include "exec-memory.h"
 #include "hw/pcspk.h"
 #include "qemu/page_cache.h"
+#include "qemu-config.h"
 #include "qmp-commands.h"
 #include "trace.h"
 
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index cb45b49..564d632 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -23,6 +23,7 @@
  */
 #include 
 #include "qemu-common.h"
+#include "main-loop.h"
 #include "qemu-char.h"
 #include "audio.h"
 
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index df51b7c..45abe39 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -31,6 +31,7 @@
 #include 
 #endif
 #include "qemu-common.h"
+#include "main-loop.h"
 #include "host-utils.h"
 #include "qemu-char.h"
 #include "audio.h"
diff --git a/block/blkdebug.c b/block/blkdebug.c
index d61ece8..19df74e 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu-common.h"
+#include "qemu-config.h"
 #include "block_int.h"
 #include "module.h"
 
diff --git a/block/iscsi.c b/block/iscsi.c
index c0b70b3..33b93d8 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include "qemu-common.h"
+#include "qemu-config.h"
 #include "qemu-error.h"
 #include "block_int.h"
 #include "trace.h"
diff --git a/bt-host.c b/bt-host.c
index 0d3ad28..8b47370 100644
--- a/bt-host.c
+++ b/bt-host.c
@@ -21,6 +21,7 @@
 #include "qemu-char.h"
 #include "net.h"
 #include "bt-host.h"
+#include "main-loop.h"
 
 #ifndef _WIN32
 # include 
diff --git a/bt-vhci.c b/bt-vhci.c
index bbc1029..878460a 100644
--- a/bt-vhci.c
+++ b/bt-vhci.c
@@ -21,6 +21,7 @@
 #include "qemu-char.h"
 #include "net.h"
 #include "hw/bt.h"
+#include "main-loop.h"
 
 #define VHCI_DEV   "/dev/vhci"
 #define VHCI_UDEV  "/dev/hci_vhci"
diff --git a/event_notifier-posix.c b/event_notifier-posix.c
index 6f3239a..f0bd839 100644
--- a/event_notifier-posix.c
+++ b/event_notifier-posix.c
@@ -13,6 +13,7 @@
 #include "qemu-common.h"
 #include "event_notifier.h"
 #include "qemu-char.h"
+#include "main-loop.h"
 
 #ifdef CONFIG_EVENTFD
 #include 
diff --git a/exec.c b/exec.c
index 8435de0..d4ef5b2 100644
--- a/exec.c
+++ b/exec.c
@@ -33,6 +33,7 @@
 #include "kvm.h"
 #include "hw/xen.h"
 #include "qemu-timer.h"
+#include "qemu-config.h"
 #include "memory.h"
 #include "dma.h"
 #include "exec-memory.h"
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 92e2cab..ae1cf66 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -15,6 +15,7 @@
 #include "loader.h"
 #include "elf.h"
 #include "device_tree.h"
+#include "qemu-config.h"
 
 #define KERNEL_ARGS_ADDR 0x100
 #define KERNEL_LOAD_ADDR 0x0001
diff --git a/hw/dma.c b/hw/dma.c
index d6aeac2..b5d9f7f 100644
--- a/hw/dma.c
+++ b/hw/dma.c
@@ -23,6 +23,7 @@
  */
 #include "hw.h"
 #include "isa.h"
+#include "main-loop.h"
 
 /* #define DEBUG_DMA */
 
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index 2b92cda..7b0e50f 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -27,6 +27,7 @@
 #include "fw_cfg.h"
 #include "sysbus.h"
 #include "qemu-error.h"
+#include "qemu-config.h"
 
 /* debug firmware config */
 //#define DEBUG_FW_CFG
diff --git a/hw/jazz_led.c b/hw/jazz_led.c
index 640e75e..09c7742 100644
--- a/hw/jazz_led.c
+++ b/hw/jazz_led.c
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include "qemu-common.h"
 #include "console.h"
 #include "pixel_ops.h"
 #include "trace.h"
diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c
index e551156..41eee50 100644
--- a/hw/mac_dbdma.c
+++ b/hw/mac_dbdma.c
@@ -39,6 +39,7 @@
 #include "hw.h"
 #include "isa.h"
 #include "mac_dbdma.h"
+#include "main-loop.h"
 
 /* debug DBDMA */
 //#define DEBUG_DBDMA
diff --git a/hw/puv3.c b/hw/puv3.c
index 764799c..57c4e19 100644
--- a/hw/puv3.c
+++ b/hw/puv3.c
@@ -8,6 +8,8 @@
  * published by the Free Software Foundation, or an

[Qemu-devel] [PATCH 6/6] qemu-iotests: Test concurrent cluster allocations

2012-12-06 Thread Kevin Wolf
This adds some first tests for qcow2's dependency handling when two
parallel write requests access the same cluster.

Signed-off-by: Kevin Wolf 
---
 tests/qemu-iotests/046 |  215 
 tests/qemu-iotests/046.out |  163 +
 tests/qemu-iotests/group   |1 +
 3 files changed, 379 insertions(+), 0 deletions(-)
 create mode 100755 tests/qemu-iotests/046
 create mode 100644 tests/qemu-iotests/046.out

diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046
new file mode 100755
index 000..e0176f4
--- /dev/null
+++ b/tests/qemu-iotests/046
@@ -0,0 +1,215 @@
+#!/bin/bash
+#
+# Test concurrent cluster allocations
+#
+# Copyright (C) 2012 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+#
+
+# creator
+owner=kw...@redhat.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1   # failure is the default!
+
+_cleanup()
+{
+   _cleanup_test_img
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_supported_fmt qcow2
+_supported_proto generic
+_supported_os Linux
+
+CLUSTER_SIZE=64k
+size=128M
+
+echo
+echo "== creating backing file for COW tests =="
+
+_make_test_img $size
+
+function backing_io()
+{
+local offset=$1
+local sectors=$2
+local op=$3
+local pattern=0
+local cur_sec=0
+
+for i in $(seq 0 $((sectors - 1))); do
+cur_sec=$((offset / 65536 + i))
+pattern=$(( ( (cur_sec % 128) + (cur_sec / 128)) % 128 ))
+
+echo "$op -P $pattern $((cur_sec * 64))k 64k"
+done
+}
+
+backing_io 0 16 write | $QEMU_IO $TEST_IMG | _filter_qemu_io
+
+mv $TEST_IMG $TEST_IMG.base
+
+_make_test_img -b $TEST_IMG.base 6G
+
+echo
+echo "== Some concurrent requests touching the same cluster =="
+
+function overlay_io()
+{
+# Allocate middle of cluster 1, then write to somewhere before and after it
+cat  < wrote 65536/65536 bytes at offset 0
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 65536
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 131072
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 196608
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 262144
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 327680
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 393216
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 458752
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 524288
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 589824
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 655360
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 720896
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 786432
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 851968
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 917504
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> wrote 65536/65536 bytes at offset 983040
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 
backing_file='TEST_DIR/t.IMGFMT.base' 
+
+== Some concurrent requests touching the same cluster ==
+qemu-io> qemu-io> qemu-io> blkdebug: Suspended request 'A'
+qemu-io> qemu-io> qemu-io> qemu-io> qemu-io> blkdebug: Resuming request 'A'
+qemu-io> wrote 8192/8192 bytes at offset XXX
+8 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset XXX
+8 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset XXX
+8 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io> qemu-io> blkdebug: Suspended request 'A'
+qemu-io> qemu-io> qemu-io> blkdebug: Resuming request 'A'
+

[Qemu-devel] [PATCH 06/32] build: create ldscripts/

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure  |2 +-
 alpha.ld => ldscripts/alpha.ld |0
 arm.ld => ldscripts/arm.ld |0
 hppa.ld => ldscripts/hppa.ld   |0
 i386.ld => ldscripts/i386.ld   |0
 ia64.ld => ldscripts/ia64.ld   |0
 m68k.ld => ldscripts/m68k.ld   |0
 mips.ld => ldscripts/mips.ld   |0
 ppc.ld => ldscripts/ppc.ld |0
 ppc64.ld => ldscripts/ppc64.ld |0
 s390.ld => ldscripts/s390.ld   |0
 sparc.ld => ldscripts/sparc.ld |0
 sparc64.ld => ldscripts/sparc64.ld |0
 x86_64.ld => ldscripts/x86_64.ld   |0
 14 files changed, 1 insertions(+), 1 deletions(-)
 rename alpha.ld => ldscripts/alpha.ld (100%)
 rename arm.ld => ldscripts/arm.ld (100%)
 rename hppa.ld => ldscripts/hppa.ld (100%)
 rename i386.ld => ldscripts/i386.ld (100%)
 rename ia64.ld => ldscripts/ia64.ld (100%)
 rename m68k.ld => ldscripts/m68k.ld (100%)
 rename mips.ld => ldscripts/mips.ld (100%)
 rename ppc.ld => ldscripts/ppc.ld (100%)
 rename ppc64.ld => ldscripts/ppc64.ld (100%)
 rename s390.ld => ldscripts/s390.ld (100%)
 rename sparc.ld => ldscripts/sparc.ld (100%)
 rename sparc64.ld => ldscripts/sparc64.ld (100%)
 rename x86_64.ld => ldscripts/x86_64.ld (100%)

diff --git a/configure b/configure
index caaa426..efec798 100755
--- a/configure
+++ b/configure
@@ -4151,7 +4151,7 @@ fi
 if test "$ARCH" = "tci"; then
   linker_script=""
 else
-  linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
+  linker_script="-Wl,-T../config-host.ld 
-Wl,-T,\$(SRC_PATH)/ldscripts/\$(ARCH).ld"
 fi
 
 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
diff --git a/alpha.ld b/ldscripts/alpha.ld
similarity index 100%
rename from alpha.ld
rename to ldscripts/alpha.ld
diff --git a/arm.ld b/ldscripts/arm.ld
similarity index 100%
rename from arm.ld
rename to ldscripts/arm.ld
diff --git a/hppa.ld b/ldscripts/hppa.ld
similarity index 100%
rename from hppa.ld
rename to ldscripts/hppa.ld
diff --git a/i386.ld b/ldscripts/i386.ld
similarity index 100%
rename from i386.ld
rename to ldscripts/i386.ld
diff --git a/ia64.ld b/ldscripts/ia64.ld
similarity index 100%
rename from ia64.ld
rename to ldscripts/ia64.ld
diff --git a/m68k.ld b/ldscripts/m68k.ld
similarity index 100%
rename from m68k.ld
rename to ldscripts/m68k.ld
diff --git a/mips.ld b/ldscripts/mips.ld
similarity index 100%
rename from mips.ld
rename to ldscripts/mips.ld
diff --git a/ppc.ld b/ldscripts/ppc.ld
similarity index 100%
rename from ppc.ld
rename to ldscripts/ppc.ld
diff --git a/ppc64.ld b/ldscripts/ppc64.ld
similarity index 100%
rename from ppc64.ld
rename to ldscripts/ppc64.ld
diff --git a/s390.ld b/ldscripts/s390.ld
similarity index 100%
rename from s390.ld
rename to ldscripts/s390.ld
diff --git a/sparc.ld b/ldscripts/sparc.ld
similarity index 100%
rename from sparc.ld
rename to ldscripts/sparc.ld
diff --git a/sparc64.ld b/ldscripts/sparc64.ld
similarity index 100%
rename from sparc64.ld
rename to ldscripts/sparc64.ld
diff --git a/x86_64.ld b/ldscripts/x86_64.ld
similarity index 100%
rename from x86_64.ld
rename to ldscripts/x86_64.ld
-- 
1.7.1





[Qemu-devel] [PATCH 14/32] net: reorganize headers

2012-12-06 Thread Paolo Bonzini
Move public headers to include/net, and leave private headers in net/.
Put the virtio headers in include/net/tap.h, removing the multiple copies
that existed.  Leave include/net/tap.h as the interface for NICs, and
net/tap_int.h as the interface for OS-specific parts of the tap backend.

Acked-by: Paolo Bonzini 
Signed-off-by: Paolo Bonzini 
---
 hmp.c   |2 +-
 hw/axis_dev88.c |2 +-
 hw/cadence_gem.c|2 +-
 hw/dp8393x.c|2 +-
 hw/e1000.c  |2 +-
 hw/eepro100.c   |2 +-
 hw/etraxfs.h|2 +-
 hw/etraxfs_eth.c|2 +-
 hw/exynos4_boards.c |2 +-
 hw/gumstix.c|2 +-
 hw/highbank.c   |2 +-
 hw/integratorcp.c   |2 +-
 hw/kzm.c|2 +-
 hw/lan9118.c|2 +-
 hw/lance.c  |2 +-
 hw/mainstone.c  |2 +-
 hw/mcf5208.c|2 +-
 hw/mcf_fec.c|2 +-
 hw/milkymist-hw.h   |2 +-
 hw/milkymist-minimac2.c |2 +-
 hw/mips_fulong2e.c  |2 +-
 hw/mips_jazz.c  |2 +-
 hw/mips_malta.c |2 +-
 hw/mips_mipssim.c   |2 +-
 hw/mips_r4k.c   |2 +-
 hw/mipsnet.c|2 +-
 hw/musicpal.c   |2 +-
 hw/ne2000-isa.c |2 +-
 hw/ne2000.c |2 +-
 hw/opencores_eth.c  |2 +-
 hw/openrisc_sim.c   |2 +-
 hw/pc.h |2 +-
 hw/pc_piix.c|2 +-
 hw/pci-hotplug.c|2 +-
 hw/pci.c|2 +-
 hw/pcnet-pci.c  |2 +-
 hw/pcnet.c  |2 +-
 hw/petalogix_ml605_mmu.c|2 +-
 hw/petalogix_s3adsp1800_mmu.c   |2 +-
 hw/ppc440_bamboo.c  |2 +-
 hw/ppc_newworld.c   |2 +-
 hw/ppc_oldworld.c   |2 +-
 hw/ppc_prep.c   |2 +-
 hw/qdev-properties.c|2 +-
 hw/qdev.c   |2 +-
 hw/r2d.c|2 +-
 hw/realview.c   |2 +-
 hw/rtl8139.c|2 +-
 hw/s390-virtio.c|2 +-
 hw/smc91c111.c  |2 +-
 hw/spapr.c  |2 +-
 hw/spapr_llan.c |2 +-
 hw/stellaris.c  |2 +-
 hw/stellaris_enet.c |2 +-
 hw/sun4m.c  |2 +-
 hw/sun4u.c  |2 +-
 hw/usb/dev-network.c|2 +-
 hw/versatilepb.c|2 +-
 hw/vexpress.c   |2 +-
 hw/vhost_net.c  |2 +-
 hw/vhost_net.h  |2 +-
 hw/virtio-net.c |2 +-
 hw/virtio-net.h |   27 ---
 hw/virtio.h |2 +-
 hw/xen_backend.h|2 +-
 hw/xen_nic.c|2 +-
 hw/xgmac.c  |2 +-
 hw/xilinx.h |2 +-
 hw/xilinx_axienet.c |2 +-
 hw/xilinx_ethlite.c |2 +-
 hw/xilinx_zynq.c|2 +-
 hw/xtensa_lx60.c|2 +-
 {net => include/net}/checksum.h |0
 net.h => include/net/net.h  |3 +++
 {net => include/net}/queue.h|0
 {net => include/net}/slirp.h|0
 {net => include/net}/tap.h  |   37 +++--
 monitor.c   |2 +-
 net/clients.h   |2 +-
 net/hub.c   |2 +-
 net/hub.h   |2 --
 net/net.c   |4 ++--
 net/queue.c |2 +-
 net/slirp.c |2 +-
 net/socket.c|2 +-
 net/tap-aix.c   |2 +-
 net/tap-bsd.c   |2 +-
 net/tap-haiku.c |2 +-
 net/tap-linux.c |3 ++-
 net/tap-linux.h |   20 ++--
 net/tap-solaris.c   |2 +-
 net/tap-win32.c |4 ++--
 net/tap.c   |6 +++---
 net/{tap.h => tap_int.h}|   18 +++---
 net/util.c  |2 +-
 net/vde.c   |2 +-
 savevm.c|2 +-
 vl.c|2 +-
 98 files changed, 125 insertions(+), 169 deletions(-)
 rename {net => include/net}/checksum.h (100%)
 rename net.h => include/net/net.h (98%)
 rename {net => include/net}/queue.h (100%)
 rename {net => include/net}/slirp.h (100%)
 copy {net => include/net}/tap.h (69%)
 rename net/{tap.h => tap_int.h} (77%)

diff --git a/hmp.c b/hmp.c
index

Re: [Qemu-devel] detecting seccomp sandbox capability via QMP

2012-12-06 Thread Daniel P. Berrange
On Thu, Dec 06, 2012 at 08:00:56AM -0600, Anthony Liguori wrote:
> "Daniel P. Berrange"  writes:
> 
> > On Tue, Dec 04, 2012 at 03:44:54PM -0600, Anthony Liguori wrote:
> >> "Daniel P. Berrange"  writes:
> >> 
> >> > On Tue, Dec 04, 2012 at 01:13:46PM -0600, Anthony Liguori wrote:
> >> >> "Daniel P. Berrange"  writes:
> >> >> 
> >> >> >
> >> >> > In the absence of any way to detect it via QMP, libvirt should 
> >> >> > fallback
> >> >> > to hardcoding it based on the version number. This presumes that QEMU 
> >> >> > was
> >> >> > built with it enabled in configure, but we've no other option for 
> >> >> > current
> >> >> > released 1.2/1.3 versions.
> >> >> 
> >> >> echo quit | qemu -machine none -S -monitor stdio -vnc none -sandbox on
> >> >> 
> >> >> A non-zero execute means QEMU doesn't support the option.  This will
> >> >> work for any new command line option introduction and can be considered
> >> >> a "supported" way of probing for whether options are supported.
> >> >
> >> > One of the significant benefits to libvirt of the QMP based feature
> >> > detection, was that we no longer have to invoke QEMU multiple times
> >> > to query different data. I don't want to regress in this regard,
> >> > because invoking QEMU many times has a noticable performance impact
> >> > for some applications eg virt-sandbox were even 100ms delays are
> >> > relevant.  So while what you describe does work, I don't think it
> >> > is a satisfactory approach for libvirt.
> >> 
> >> Okay, so in terms of what exists today, I don't have a better option.
> >> But we could add:
> >> 
> >> { 'enum': 'ConfigEntryType',
> >>   'data': [ 'number', 'string', 'bool', 'size' ] }
> >> 
> >> { 'type': 'ConfigEntry',
> >>   'data': { 'name': 'str', 'type': 'ConfigEntryType' } }
> >> 
> >> { 'type': 'ConfigSection',
> >>   'data': { 'name': 'str', 'fields': [ 'ConfigEntry' ] } }
> >> 
> >> { 'command': 'query-config-schema',
> >>   'returns': [ 'ConfigSection' ] }
> 
> 
> >> 
> >> This technically introspects config sections but obviously could be used
> >> to detect the availability of -sandbox.
> >> 
> >> If it's useful, I can take a quick swing at implementing (or someone
> >> else certainly could).
> >
> > I'm not sure I entirely understand what information a 'ConfigSection'
> > would represent. By config here, do you mean any command line argument
> > or something else ?
> 
> We no longer should be adding command line arguments that don't use
> QemuOpts and have a equivalent -readconfig syntax.  We could even
> eliminate new options and do something like:
> 
> qemu -conf sandbox:enable=on
> 
> But that's not user friendly so we'll stick with adding higher level
> options like -sandbox.
> 
> So what I'm proposing is to introspection on what -readconfig supports
> and then from that, you can infer when new higher level command line
> arguments are added.
> 
> >  Could you give a short example of the actual JSON
> > you envisage returning for this schema. Your suggestion sounds good,
> > but I want to make sure I'm not mis-understanding things :-)
> 
> [ { 'name': 'sandbox',
> 'fields': [ { 'name': 'enable', 'type': 'bool' } ] },
>   { 'name': 'add-fd',
> 'fields': [ { 'name': 'fd', 'type': 'number' },
> { 'name': 'set', 'type': 'number' },
> { 'name': 'opaque', 'type': 'str' } ] },
>   ...
> ]

Ok, that all sounds like a good idea to me - it should address one of the
major gaps in the new QMP based capabilities detection.

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



Re: [Qemu-devel] [PATCH v5 07/11] iov: add iov_discard() to remove data

2012-12-06 Thread Stefan Hajnoczi
On Thu, Dec 06, 2012 at 01:36:42PM +0200, Michael S. Tsirkin wrote:
> On Wed, Dec 05, 2012 at 09:47:06PM +0100, Stefan Hajnoczi wrote:
> > The iov_discard() function removes data from the front or back of the
> > vector.  This is useful when peeling off header/footer structs.
> > 
> > Signed-off-by: Stefan Hajnoczi 
> > ---
> >  iov.c | 41 +
> >  iov.h | 13 +
> >  2 files changed, 54 insertions(+)
> > 
> > diff --git a/iov.c b/iov.c
> > index a81eedc..6eed089 100644
> > --- a/iov.c
> > +++ b/iov.c
> > @@ -354,3 +354,44 @@ size_t qemu_iovec_memset(QEMUIOVector *qiov, size_t 
> > offset,
> >  {
> >  return iov_memset(qiov->iov, qiov->niov, offset, fillc, bytes);
> >  }
> > +
> > +size_t iov_discard(struct iovec **iov, unsigned int *iov_cnt, ssize_t 
> > bytes)
> > +{
> > +size_t total = 0;
> > +struct iovec *cur;
> > +int direction;
> > +
> > +if (*iov_cnt == 0) {
> > +return 0;
> > +}
> > +
> > +if (bytes < 0) {
> > +bytes = -bytes;
> > +direction = -1;
> > +cur = *iov + (*iov_cnt - 1);
> > +} else {
> > +direction = 1;
> > +cur = *iov;
> > +}
> > +
> > +while (*iov_cnt > 0) {
> > +if (cur->iov_len > bytes) {
> > +if (direction > 0) {
> > +cur->iov_base += bytes;
> > +}
> > +cur->iov_len -= bytes;
> > +total += bytes;
> > +break;
> > +}
> > +
> > +bytes -= cur->iov_len;
> > +total += cur->iov_len;
> > +cur += direction;
> > +*iov_cnt -= 1;
> > +}
> > +
> > +if (direction > 0) {
> > +*iov = cur;
> > +}
> > +return total;
> > +}
> > diff --git a/iov.h b/iov.h
> > index 34c8ec9..d6d1fa6 100644
> > --- a/iov.h
> > +++ b/iov.h
> > @@ -95,3 +95,16 @@ void iov_hexdump(const struct iovec *iov, const unsigned 
> > int iov_cnt,
> >  unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt,
> >   const struct iovec *iov, unsigned int iov_cnt,
> >   size_t offset, size_t bytes);
> > +
> > +/*
> > + * Remove a given number of bytes from the front or back of a vector.
> > + * This may update iov and/or iov_cnt to exclude iovec elements that are
> > + * no longer required.
> > + *
> > + * Data is discarded from the front of the vector if bytes is positive and
> > + * from the back of the vector if bytes is negative.
> 
> I think I already commented on this: I think this interface is too tricky,
> and use of ssize_t is a bad idea since most of code uses size_t:
> you might start getting integer overflow errors if you convert.
> 
> Better to have
> size_t iov_discard_front(struct iovec **iov, unsigned int *iov_cnt, ssize_t 
> bytes);
> size_t iov_discard_back(struct iovec **iov, unsigned int *iov_cnt, ssize_t 
> bytes);
> 
> which explicitly do the right thing.
> 
> The fix up users to use size_t everywhere.

Okay, will split into front/back.

Stefan



Re: [Qemu-devel] detecting seccomp sandbox capability via QMP

2012-12-06 Thread Anthony Liguori
"Daniel P. Berrange"  writes:

> On Tue, Dec 04, 2012 at 03:44:54PM -0600, Anthony Liguori wrote:
>> "Daniel P. Berrange"  writes:
>> 
>> > On Tue, Dec 04, 2012 at 01:13:46PM -0600, Anthony Liguori wrote:
>> >> "Daniel P. Berrange"  writes:
>> >> 
>> >> >
>> >> > In the absence of any way to detect it via QMP, libvirt should fallback
>> >> > to hardcoding it based on the version number. This presumes that QEMU 
>> >> > was
>> >> > built with it enabled in configure, but we've no other option for 
>> >> > current
>> >> > released 1.2/1.3 versions.
>> >> 
>> >> echo quit | qemu -machine none -S -monitor stdio -vnc none -sandbox on
>> >> 
>> >> A non-zero execute means QEMU doesn't support the option.  This will
>> >> work for any new command line option introduction and can be considered
>> >> a "supported" way of probing for whether options are supported.
>> >
>> > One of the significant benefits to libvirt of the QMP based feature
>> > detection, was that we no longer have to invoke QEMU multiple times
>> > to query different data. I don't want to regress in this regard,
>> > because invoking QEMU many times has a noticable performance impact
>> > for some applications eg virt-sandbox were even 100ms delays are
>> > relevant.  So while what you describe does work, I don't think it
>> > is a satisfactory approach for libvirt.
>> 
>> Okay, so in terms of what exists today, I don't have a better option.
>> But we could add:
>> 
>> { 'enum': 'ConfigEntryType',
>>   'data': [ 'number', 'string', 'bool', 'size' ] }
>> 
>> { 'type': 'ConfigEntry',
>>   'data': { 'name': 'str', 'type': 'ConfigEntryType' } }
>> 
>> { 'type': 'ConfigSection',
>>   'data': { 'name': 'str', 'fields': [ 'ConfigEntry' ] } }
>> 
>> { 'command': 'query-config-schema',
>>   'returns': [ 'ConfigSection' ] }


>> 
>> This technically introspects config sections but obviously could be used
>> to detect the availability of -sandbox.
>> 
>> If it's useful, I can take a quick swing at implementing (or someone
>> else certainly could).
>
> I'm not sure I entirely understand what information a 'ConfigSection'
> would represent. By config here, do you mean any command line argument
> or something else ?

We no longer should be adding command line arguments that don't use
QemuOpts and have a equivalent -readconfig syntax.  We could even
eliminate new options and do something like:

qemu -conf sandbox:enable=on

But that's not user friendly so we'll stick with adding higher level
options like -sandbox.

So what I'm proposing is to introspection on what -readconfig supports
and then from that, you can infer when new higher level command line
arguments are added.

>  Could you give a short example of the actual JSON
> you envisage returning for this schema. Your suggestion sounds good,
> but I want to make sure I'm not mis-understanding things :-)

[ { 'name': 'sandbox',
'fields': [ { 'name': 'enable', 'type': 'bool' } ] },
  { 'name': 'add-fd',
'fields': [ { 'name': 'fd', 'type': 'number' },
{ 'name': 'set', 'type': 'number' },
{ 'name': 'opaque', 'type': 'str' } ] },
  ...
]

Regards,

Anthony Liguori

>
> Regards,
> Daniel
> -- 
> |: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org  -o- http://virt-manager.org :|
> |: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
> |: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk.

2012-12-06 Thread KONRAD Frédéric

On 06/12/2012 11:13, Peter Maydell wrote:

On 6 December 2012 09:53, Andreas Färber  wrote:

Am 06.12.2012 10:21, schrieb KONRAD Frédéric:

I agree with that, but, there is an issue :
The refactored VirtIOBlk is a device and seems to work, but the device
which use this VirtIOBlock
(eg virtio-blk-pci) are just allocating a structure ( in
virtio_common_init ).

That's why this patch is breaking virtio-blk-pci.

Don't understand that part due to lack of virtio knowledge...
Patch 5/6 introduces VirtIODevice as sitting on TYPE_VIRTIO_BUS. So with
this patch VirtIOBlk is moving to that new bus and virtio-blk-pci should
only be necessary as a command line option alias for backwards
compatibility, no?

It can't just be a command line alias, or we will break migration.
It has to be a simple device that composes together the virtio-pci
and virtio-blk devices, plus legacy support for properties and
migration state, I think.

-- PMM

Can we do virtio-blk refactoring and virtio-blk-pci at the same time for not
breaking anything ?

Or do you have a better idea ?

Fred



[Qemu-devel] [PATCH 20/32] janitor: add guards to headers

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 gen-icount.h|5 +
 host-utils.h|4 
 hw/9pfs/virtio-9p-synth.h   |4 
 hw/audiodev.h   |5 +
 hw/baum.h   |4 
 hw/bt.h |5 +
 hw/cris-boot.h  |4 
 hw/empty_slot.h |5 +
 hw/escc.h   |5 +
 hw/etraxfs.h|5 +
 hw/etraxfs_dma.h|5 +
 hw/flash.h  |5 +
 hw/lm32.h   |5 +
 hw/mac_dbdma.h  |4 
 hw/msmouse.h|5 +
 hw/ne2000.h |5 +
 hw/pci_ids.h|4 
 hw/pcmcia.h |5 +
 hw/pcnet.h  |5 +
 hw/ppc.h|5 +
 hw/qdev-addr.h  |5 +
 hw/qxl.h|5 +
 hw/s390-virtio-bus.h|4 
 hw/scsi-defs.h  |4 
 hw/serial.h |4 
 hw/soc_dma.h|6 ++
 hw/usb/hcd-ehci.h   |4 
 hw/vga_int.h|4 
 hw/xilinx.h |6 ++
 iov.h   |5 +
 linux-user/cris/syscall.h   |5 +
 linux-user/microblaze/syscall.h |6 ++
 linux-user/syscall_defs.h   |6 ++
 slirp/bootp.h   |4 
 slirp/main.h|4 
 slirp/tftp.h|4 
 softmmu-semi.h  |4 
 target-cris/crisv32-decode.h|4 
 tcg/arm/tcg-target.h|3 +++
 tcg/hppa/tcg-target.h   |3 +++
 tcg/i386/tcg-target.h   |3 +++
 tcg/ia64/tcg-target.h   |3 +++
 tcg/mips/tcg-target.h   |3 +++
 tcg/ppc/tcg-target.h|3 +++
 tcg/ppc64/tcg-target.h  |3 +++
 tcg/s390/tcg-target.h   |3 +++
 tcg/sparc/tcg-target.h  |3 +++
 tests/tcg/cris/crisutils.h  |5 +
 ui/curses_keys.h|5 +
 ui/d3des.h  |4 
 50 files changed, 219 insertions(+), 0 deletions(-)

diff --git a/gen-icount.h b/gen-icount.h
index 248cf5b..1541f0b 100644
--- a/gen-icount.h
+++ b/gen-icount.h
@@ -1,3 +1,6 @@
+#ifndef GEN_ICOUNT_H
+#define GEN_ICOUNT_H 1
+
 #include "qemu-timer.h"
 
 /* Helpers for instruction counting code generation.  */
@@ -46,3 +49,5 @@ static inline void gen_io_end(void)
 tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io));
 tcg_temp_free_i32(tmp);
 }
+
+#endif
diff --git a/host-utils.h b/host-utils.h
index 821db93..a5f8464 100644
--- a/host-utils.h
+++ b/host-utils.h
@@ -22,6 +22,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef HOST_UTILS_H
+#define HOST_UTILS_H 1
 
 #include "compiler.h"   /* QEMU_GNUC_PREREQ */
 
@@ -234,3 +236,5 @@ static inline int ctpop64(uint64_t val)
 return val;
 #endif
 }
+
+#endif
diff --git a/hw/9pfs/virtio-9p-synth.h b/hw/9pfs/virtio-9p-synth.h
index e03f434..ab05a8e 100644
--- a/hw/9pfs/virtio-9p-synth.h
+++ b/hw/9pfs/virtio-9p-synth.h
@@ -10,6 +10,8 @@
  * the COPYING file in the top-level directory.
  *
  */
+#ifndef HW_9PFS_VIRTIO9P_SYNTH_H
+#define HW_9PFS_VIRTIO9P_SYNTH_H 1
 
 #include 
 #include 
@@ -48,3 +50,5 @@ extern int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int 
mode,
 extern int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
 const char *name, v9fs_synth_read read,
 v9fs_synth_write write, void *arg);
+
+#endif
diff --git a/hw/audiodev.h b/hw/audiodev.h
index ed2790f..428274f 100644
--- a/hw/audiodev.h
+++ b/hw/audiodev.h
@@ -1,3 +1,6 @@
+#ifndef HW_AUDIODEV_H
+#define HW_AUDIODEV_H 1
+
 /* es1370.c */
 int es1370_init(PCIBus *bus);
 
@@ -18,3 +21,5 @@ int cs4231a_init(ISABus *bus);
 
 /* intel-hda.c + hda-audio.c */
 int intel_hda_and_codec_init(PCIBus *bus);
+
+#endif
diff --git a/hw/baum.h b/hw/baum.h
index 8af710f..7635884 100644
--- a/hw/baum.h
+++ b/hw/baum.h
@@ -21,6 +21,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef HW_BAUM_H
+#define HW_BAUM_H 1
 
 /* char device */
 CharDriverState *chr_baum_init(QemuOpts *opts);
+
+#endif
diff --git a/hw/bt.h b/hw/bt.h
index ebf6a37..830af94 100644
--- a/hw/bt.h
+++ b/hw/bt.h
@@ -23,6 +23,9 @@
  * along with this program; if not, see .
  */
 
+#ifndef HW_BT_H
+#define HW_BT_H 1
+
 #include "hw/irq.h"
 
 /* BD Address */
@@ -2183,3 +2186,5 @@ enum bt_sdp_attribute_id {
 SDP_ATTR_NORMALLY_CONNECTABLE  = 0x020d,
 SDP_ATTR_BOOT_DEVICE   = 0x020e,
 };
+
+#endif

[Qemu-devel] [PATCH 16/32] ui: move files to ui/ and include/ui/

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 Makefile.objs |4 +---
 hmp.c |2 +-
 hw/adb.c  |2 +-
 hw/ads7846.c  |2 +-
 hw/applesmc.c |2 +-
 hw/blizzard.c |4 ++--
 hw/bt-hid.c   |2 +-
 hw/cirrus_vga.c   |2 +-
 hw/escc.c |2 +-
 hw/exynos4210_fimd.c  |4 ++--
 hw/framebuffer.c  |2 +-
 hw/g364fb.c   |4 ++--
 hw/hid.c  |2 +-
 hw/hpet.c |2 +-
 hw/jazz_led.c |4 ++--
 hw/kvm/pci-assign.c   |2 +-
 hw/lm832x.c   |2 +-
 hw/milkymist-softusb.c|2 +-
 hw/milkymist-vgafb.c  |4 ++--
 hw/msmouse.c  |6 +++---
 hw/musicpal.c |5 ++---
 hw/nseries.c  |2 +-
 hw/omap_dss.c |2 +-
 hw/omap_lcdc.c|5 ++---
 hw/omap_sx1.c |2 +-
 hw/palm.c |2 +-
 hw/pl110.c|5 ++---
 hw/ps2.c  |2 +-
 hw/puv3.c |2 +-
 hw/pxa2xx_keypad.c|2 +-
 hw/pxa2xx_lcd.c   |4 ++--
 hw/qxl.h  |2 +-
 hw/sm501.c|5 ++---
 hw/spitz.c|2 +-
 hw/ssd0303.c  |2 +-
 hw/ssd0323.c  |2 +-
 hw/stellaris_input.c  |2 +-
 hw/tc6393xb.c |4 ++--
 hw/tcx.c  |4 ++--
 hw/tsc2005.c  |2 +-
 hw/tsc210x.c  |2 +-
 hw/twl92230.c |2 +-
 hw/usb/dev-hid.c  |2 +-
 hw/usb/dev-storage.c  |2 +-
 hw/usb/dev-wacom.c|2 +-
 hw/usb/host-stub.c|2 +-
 hw/vga-isa-mm.c   |4 ++--
 hw/vga-isa.c  |4 ++--
 hw/vga-pci.c  |4 ++--
 hw/vga.c  |4 ++--
 hw/vmmouse.c  |2 +-
 hw/vmware_vga.c   |2 +-
 hw/xenfb.c|2 +-
 hw/z2.c   |2 +-
 console.h => include/ui/console.h |2 +-
 {hw => include/ui}/pixel_ops.h|0
 qemu-pixman.h => include/ui/qemu-pixman.h |0
 {ui => include/ui}/qemu-spice.h   |0
 {ui => include/ui}/spice-display.h|2 +-
 monitor.c |2 +-
 qemu-char.c   |2 +-
 qemu-timer.c  |2 +-
 target-unicore32/helper.c |2 +-
 ui/Makefile.objs  |2 +-
 ui/cocoa.m|2 +-
 console.c => ui/console.c |2 +-
 ui/curses.c   |2 +-
 cursor.c => ui/cursor.c   |2 +-
 cursor_hidden.xpm => ui/cursor_hidden.xpm |0
 cursor_left_ptr.xpm => ui/cursor_left_ptr.xpm |0
 input.c => ui/input.c |2 +-
 qemu-pixman.c => ui/qemu-pixman.c |2 +-
 qemu-x509.h => ui/qemu-x509.h |0
 ui/sdl.c  |2 +-
 ui/spice-core.c   |4 ++--
 ui/spice-display.c|6 +++---
 ui/spice-input.c  |4 ++--
 vgafont.h => ui/vgafont.h |0
 ui/vnc.h  |2 +-
 vl.c  |2 +-
 80 files changed, 95 insertions(+), 101 deletions(-)
 rename console.h => include/ui/console.h (99%)
 rename {hw => include/ui}/pixel_ops.h (100%)
 rename qemu-pixman.h => include/ui/qemu-pixman.h (100%)
 rename {ui => include/ui}/qemu-spice.h (100%)
 rename {ui => include/ui}/spice-display.h (99%)
 rename console.c => ui/console.c (99%)
 rename cursor.c => ui/cursor.c (99

[Qemu-devel] [PATCH 24/32] monitor: move include files to include/monitor/

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 arch_init.c  |2 +-
 audio/audio.c|2 +-
 audio/wavcapture.c   |2 +-
 balloon.c|2 +-
 balloon.h|2 +-
 block.c  |2 +-
 blockdev-nbd.c   |2 +-
 blockdev.c   |2 +-
 blockjob.c   |2 +-
 cpus.c   |2 +-
 disas.c  |2 +-
 dump.c   |2 +-
 gdbstub.c|2 +-
 hmp.c|2 +-
 hw/acpi.c|2 +-
 hw/ccid-card-emulated.c  |2 +-
 hw/ccid-card-passthru.c  |2 +-
 hw/device-hotplug.c  |2 +-
 hw/i8259.c   |2 +-
 hw/ide/ahci.c|2 +-
 hw/isa-bus.c |2 +-
 hw/kvm/pci-assign.c  |2 +-
 hw/lm32_pic.c|2 +-
 hw/loader.c  |2 +-
 hw/pc.c  |2 +-
 hw/pci-hotplug.c |2 +-
 hw/pci-stub.c|2 +-
 hw/pci.c |2 +-
 hw/pcie_aer.c|2 +-
 hw/qdev-monitor.c|2 +-
 hw/qdev-monitor.h|2 +-
 hw/qxl.c |2 +-
 hw/s390-virtio-bus.c |2 +-
 hw/s390-virtio.c |2 +-
 hw/s390x/event-facility.c|2 +-
 hw/slavio_intctl.c   |2 +-
 hw/spapr_vio.c   |2 +-
 hw/sun4c_intctl.c|2 +-
 hw/sysbus.c  |2 +-
 hw/usb/bus.c |2 +-
 hw/usb/dev-smartcard-reader.c|2 +-
 hw/usb/dev-storage.c |2 +-
 hw/usb/hcd-ehci.h|2 +-
 hw/usb/host-bsd.c|2 +-
 hw/usb/host-linux.c  |2 +-
 hw/usb/host-stub.c   |2 +-
 hw/usb/redirect.c|2 +-
 hw/virtio-serial-bus.c   |2 +-
 hw/watchdog.c|2 +-
 include/block/block_int.h|2 +-
 monitor.h => include/monitor/monitor.h   |2 +-
 readline.h => include/monitor/readline.h |0
 include/ui/console.h |2 +-
 include/ui/qemu-spice.h  |4 ++--
 migration-fd.c   |2 +-
 migration.c  |2 +-
 monitor.c|4 ++--
 net/hub.c|2 +-
 net/net.c|2 +-
 net/slirp.c  |2 +-
 net/socket.c |2 +-
 net/tap.c|2 +-
 osdep.c  |2 +-
 qemu-char.c  |2 +-
 qemu-error.c |2 +-
 qemu-sockets.c   |2 +-
 qemu-timer.c |2 +-
 qemu-tool.c  |2 +-
 qemu-user.c  |2 +-
 qerror.c |2 +-
 readline.c   |4 ++--
 savevm.c |2 +-
 slirp/misc.c |4 ++--
 stubs/fdset-add-fd.c |2 +-
 stubs/fdset-find-fd.c|2 +-
 stubs/fdset-get-fd.c |2 +-
 stubs/fdset-remove-fd.c  |2 +-
 stubs/get-fd.c   |2 +-
 target-i386/helper.c |2 +-
 ui/input.c   |2 +-
 ui/spice-core.c  |2 +-
 ui/spice-display.c   |2 +-
 ui/vnc.h |2 +-
 vl.c |2 +-
 84 files changed, 87 insertions(+), 87 deletions(-)
 rename monitor.h => include/monitor/monitor.h (99%)
 rename readline.h => include/monitor/readline.h (100%)

diff --git a/arch_init.c b/arch_init.c
index 212c90a..4d3271b 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -29,7 +29,7 @@
 #include 
 #endif
 #include "config.h"
-#include "monitor.h"
+#include "monitor/monitor.h"
 #include "sysemu.h"
 #include "bitops.h"
 #include "bitmap.h"
diff --git a/audio/audio.c b/audio/audio.c
index 1c77389..a0cc727 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -23,7 +23,7 @@
  */
 #include "hw/h

[Qemu-devel] [PATCH 17/32] qapi: move inclusions of qemu-common.h from headers to .c files

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 qapi/opts-visitor.c  |1 +
 qapi/qapi-types-core.h   |1 -
 qapi/qapi-visit-core.c   |1 +
 scripts/qapi-commands.py |1 +
 scripts/qapi-visit.py|1 +
 5 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index e048b6c..e3fd254 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -10,6 +10,7 @@
  *
  */
 
+#include "qemu-common.h"
 #include "opts-visitor.h"
 #include "qemu-queue.h"
 #include "qemu-option-internal.h"
diff --git a/qapi/qapi-types-core.h b/qapi/qapi-types-core.h
index f781fc3..831df21 100644
--- a/qapi/qapi-types-core.h
+++ b/qapi/qapi-types-core.h
@@ -14,7 +14,6 @@
 #ifndef QAPI_TYPES_CORE_H
 #define QAPI_TYPES_CORE_H
 
-#include "qemu-common.h"
 #include "error.h"
 #include "qerror.h"
 
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 7a82b63..3002939 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -11,6 +11,7 @@
  *
  */
 
+#include "qemu-common.h"
 #include "qapi/qapi-visit-core.h"
 #include "qapi/qapi-visit-impl.h"
 
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 3c4678d..2db0bf1 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -366,6 +366,7 @@ def gen_command_def_prologue(prefix="", proxy=False):
  *
  */
 
+#include "qemu-common.h"
 #include "qemu-objects.h"
 #include "qapi/qmp-core.h"
 #include "qapi/qapi-visit-core.h"
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index a360de7..f1aabb3 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -298,6 +298,7 @@ fdef.write(mcgen('''
  *
  */
 
+#include "qemu-common.h"
 #include "%(header)s"
 ''',
  header=basename(h_file)))
-- 
1.7.1





[Qemu-devel] [PATCH 29/32] softmmu: move remaining include files to include/ subdirectories

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 backends/rng-egd.c |2 +-
 bt-host.c  |2 +-
 bt-vhci.c  |2 +-
 event_notifier-posix.c |2 +-
 gdbstub.c  |2 +-
 hmp.c  |2 +-
 hw/baum.c  |2 +-
 hw/bt-hci-csr.c|4 ++--
 hw/bt-hci.c|2 +-
 hw/bt.c|2 +-
 hw/cadence_uart.c  |2 +-
 hw/ccid-card-emulated.c|2 +-
 hw/ccid-card-passthru.c|2 +-
 hw/debugcon.c  |2 +-
 hw/escc.c  |2 +-
 hw/etraxfs_ser.c   |2 +-
 hw/exynos4210_uart.c   |2 +-
 hw/grlib_apbuart.c |2 +-
 hw/imx_serial.c|2 +-
 hw/ivshmem.c   |2 +-
 hw/leon3.c |2 +-
 hw/lm32_juart.c|2 +-
 hw/lm32_uart.c |2 +-
 hw/mcf_uart.c  |2 +-
 hw/milkymist-uart.c|2 +-
 hw/mips_fulong2e.c |2 +-
 hw/mips_malta.c|2 +-
 hw/msmouse.c   |2 +-
 hw/omap2.c |2 +-
 hw/omap_uart.c |2 +-
 hw/parallel.c  |2 +-
 hw/pl011.c |2 +-
 hw/pxa2xx.c|2 +-
 hw/qdev-properties.c   |2 +-
 hw/s390x/sclpconsole.c |2 +-
 hw/serial.c|2 +-
 hw/sh_serial.c |2 +-
 hw/spapr_events.c  |2 +-
 hw/spapr_rtas.c|2 +-
 hw/spapr_vty.c |2 +-
 hw/strongarm.c |2 +-
 hw/usb/dev-bluetooth.c |2 +-
 hw/usb/dev-serial.c|2 +-
 hw/virtio-console.c|2 +-
 hw/xen_backend.c   |2 +-
 hw/xen_console.c   |2 +-
 hw/xenfb.c |2 +-
 hw/xgmac.c |2 +-
 hw/xilinx_uartlite.c   |2 +-
 hw/xtensa_lx60.c   |2 +-
 bt-host.h => include/bt/bt.h   |0
 qemu-char.h => include/char/char.h |0
 monitor.c  |2 +-
 net/slirp.c|2 +-
 qemu-char.c|2 +-
 qmp.c  |2 +-
 qtest.c|2 +-
 slirp/slirp.c  |2 +-
 spice-qemu-char.c  |2 +-
 ui/console.c   |2 +-
 vl.c   |4 ++--
 61 files changed, 61 insertions(+), 61 deletions(-)
 rename bt-host.h => include/bt/bt.h (100%)
 rename qemu-char.h => include/char/char.h (100%)

diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 3a7d1ec..fd41b53 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -11,7 +11,7 @@
  */
 
 #include "qemu/rng.h"
-#include "qemu-char.h"
+#include "char/char.h"
 #include "qapi/qmp/qerror.h"
 #include "hw/qdev.h" /* just for DEFINE_PROP_CHR */
 
diff --git a/bt-host.c b/bt-host.c
index 4f5f9f9..2092754 100644
--- a/bt-host.c
+++ b/bt-host.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu-common.h"
-#include "bt-host.h"
+#include "bt/bt.h"
 #include "qemu/main-loop.h"
 
 #ifndef _WIN32
diff --git a/bt-vhci.c b/bt-vhci.c
index f5d856a..a6a7ab0 100644
--- a/bt-vhci.c
+++ b/bt-vhci.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu-common.h"
-#include "bt-host.h"
+#include "bt/bt.h"
 #include "hw/bt.h"
 #include "qemu/main-loop.h"
 
diff --git a/event_notifier-posix.c b/event_notifier-posix.c
index a53b956..713d756 100644
--- a/event_notifier-posix.c
+++ b/event_notifier-posix.c
@@ -12,7 +12,7 @@
 
 #include "qemu-common.h"
 #include "qemu/event_notifier.h"
-#include "qemu-char.h"
+#include "char/char.h"
 #include "qemu/main-loop.h"
 
 #ifdef CONFIG_EVENTFD
diff --git a/gdbstub.c b/gdbstub.c
index 2fca1a7..a8dd437 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -30,7 +30,7 @@
 #include "qemu.h"
 #else
 #include "monitor/monitor.h"
-#include "qemu-char.h"
+#include "char/char.h"
 #include "sysemu/sysemu.h"
 #include "exec/gdbstub.h"
 #endif
diff --git a/hmp.c b/hmp.c
index 3d056b0..9e9e624 100644
--- a/hmp.c
+++ b/hmp.c
@@ -15,7 +15,7 @@
 
 #include "hmp.h"
 #include "net/net.h"
-#include "qemu-char.h"
+#include "char/char.h"
 #include "qemu/option.h"
 #include "qemu/timer.h"
 #include "qmp-commands.h"
diff --git a/hw/baum.c b/hw/baum.c
index 97d13ea..09dcb9c 100644
--- a/hw/baum.c
+++ b/hw/baum.c
@@ -22,7 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu-common.h"
-#include "qemu-char.h"
+#include "char/char.h"
 #include "qemu/timer.h"
 #include "usb.h"
 #include "baum.h"
diff --git a/hw/bt-hci-csr.c b/hw/bt-hci-csr.c
index e1dcb6d..2070b

[Qemu-devel] [PATCH 3/6] blkdebug: Implement suspend/resume of AIO requests

2012-12-06 Thread Kevin Wolf
This allows more systematic AIO testing. The patch adds three new
operations to blkdebug:

 * Setting a "breakpoint" on a blkdebug event. The next request that
   triggers this breakpoint is suspended and is tagged with a name.
   The breakpoint is removed after a request has triggered it.

 * A suspended request (identified by it's tag) can be resumed

 * It's possible to check whether a suspended request with a given
   tag exists. This can be used for waiting for an event.

Ideally, we would instead tag requests right when they are created and
set breakpoints for individual requests. However, at this point the
block layer doesn't allow this easily, and breakpoints that trigger for
any request already allow a lot of useful testing.

Signed-off-by: Kevin Wolf 
---
 block/blkdebug.c |  108 -
 1 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/block/blkdebug.c b/block/blkdebug.c
index 859792b..294e983 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -29,8 +29,10 @@
 typedef struct BDRVBlkdebugState {
 int state;
 int new_state;
+
 QLIST_HEAD(, BlkdebugRule) rules[BLKDBG_EVENT_MAX];
 QSIMPLEQ_HEAD(, BlkdebugRule) active_rules;
+QLIST_HEAD(, BlkdebugSuspendedReq) suspended_reqs;
 } BDRVBlkdebugState;
 
 typedef struct BlkdebugAIOCB {
@@ -39,6 +41,12 @@ typedef struct BlkdebugAIOCB {
 int ret;
 } BlkdebugAIOCB;
 
+typedef struct BlkdebugSuspendedReq {
+Coroutine *co;
+char *tag;
+QLIST_ENTRY(BlkdebugSuspendedReq) next;
+} BlkdebugSuspendedReq;
+
 static void blkdebug_aio_cancel(BlockDriverAIOCB *blockacb);
 
 static const AIOCBInfo blkdebug_aiocb_info = {
@@ -49,6 +57,7 @@ static const AIOCBInfo blkdebug_aiocb_info = {
 enum {
 ACTION_INJECT_ERROR,
 ACTION_SET_STATE,
+ACTION_SUSPEND,
 };
 
 typedef struct BlkdebugRule {
@@ -65,6 +74,9 @@ typedef struct BlkdebugRule {
 struct {
 int new_state;
 } set_state;
+struct {
+char *tag;
+} suspend;
 } options;
 QLIST_ENTRY(BlkdebugRule) next;
 QSIMPLEQ_ENTRY(BlkdebugRule) active_next;
@@ -226,6 +238,11 @@ static int add_rule(QemuOpts *opts, void *opaque)
 rule->options.set_state.new_state =
 qemu_opt_get_number(opts, "new_state", 0);
 break;
+
+case ACTION_SUSPEND:
+rule->options.suspend.tag =
+g_strdup(qemu_opt_get(opts, "tag"));
+break;
 };
 
 /* Add the rule */
@@ -240,6 +257,9 @@ static void remove_rule(BlkdebugRule *rule)
 case ACTION_INJECT_ERROR:
 case ACTION_SET_STATE:
 break;
+case ACTION_SUSPEND:
+g_free(rule->options.suspend.tag);
+break;
 }
 
 QLIST_REMOVE(rule, next);
@@ -406,6 +426,7 @@ static BlockDriverAIOCB 
*blkdebug_aio_writev(BlockDriverState *bs,
 return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
 }
 
+
 static void blkdebug_close(BlockDriverState *bs)
 {
 BDRVBlkdebugState *s = bs->opaque;
@@ -419,6 +440,27 @@ static void blkdebug_close(BlockDriverState *bs)
 }
 }
 
+static void suspend_request(BlockDriverState *bs, BlkdebugRule *rule)
+{
+BDRVBlkdebugState *s = bs->opaque;
+BlkdebugSuspendedReq r;
+
+r = (BlkdebugSuspendedReq) {
+.co = qemu_coroutine_self(),
+.tag= g_strdup(rule->options.suspend.tag),
+};
+
+remove_rule(rule);
+QLIST_INSERT_HEAD(&s->suspended_reqs, &r, next);
+
+printf("blkdebug: Suspended request '%s'\n", r.tag);
+qemu_coroutine_yield();
+printf("blkdebug: Resuming request '%s'\n", r.tag);
+
+QLIST_REMOVE(&r, next);
+g_free(r.tag);
+}
+
 static bool process_rule(BlockDriverState *bs, struct BlkdebugRule *rule,
 bool injected)
 {
@@ -442,6 +484,10 @@ static bool process_rule(BlockDriverState *bs, struct 
BlkdebugRule *rule,
 case ACTION_SET_STATE:
 s->new_state = rule->options.set_state.new_state;
 break;
+
+case ACTION_SUSPEND:
+suspend_request(bs, rule);
+break;
 }
 return injected;
 }
@@ -449,19 +495,72 @@ static bool process_rule(BlockDriverState *bs, struct 
BlkdebugRule *rule,
 static void blkdebug_debug_event(BlockDriverState *bs, BlkDebugEvent event)
 {
 BDRVBlkdebugState *s = bs->opaque;
-struct BlkdebugRule *rule;
+struct BlkdebugRule *rule, *next;
 bool injected;
 
 assert((int)event >= 0 && event < BLKDBG_EVENT_MAX);
 
 injected = false;
 s->new_state = s->state;
-QLIST_FOREACH(rule, &s->rules[event], next) {
+QLIST_FOREACH_SAFE(rule, &s->rules[event], next, next) {
 injected = process_rule(bs, rule, injected);
 }
 s->state = s->new_state;
 }
 
+static int blkdebug_debug_breakpoint(BlockDriverState *bs, const char *event,
+ const char *tag)
+{
+BDRVBlkdebugState *s = bs->opaque;
+struct BlkdebugRule *rule;
+BlkDebugEvent blkdebug_event;
+
+if (get_event_by_n

[Qemu-devel] [PATCH 4/6] qemu-io: Add AIO debugging commands

2012-12-06 Thread Kevin Wolf
This makes the blkdebug suspend/resume functionality available in
qemu-io. Use it like this:

  $ ./qemu-io blkdebug::/tmp/test.qcow2
  qemu-io> break write_aio req_a
  qemu-io> aio_write 0 4k
  qemu-io> blkdebug: Suspended request 'req_a'
  qemu-io> resume req_a
  blkdebug: Resuming request 'req_a'
  qemu-io> wrote 4096/4096 bytes at offset 0
  4 KiB, 1 ops; 0:00:30.71 (133.359788 bytes/sec and 0.0326 ops/sec)

Signed-off-by: Kevin Wolf 
---
 block.c |   39 +++
 block.h |5 
 block_int.h |6 +
 qemu-io.c   |   64 +++
 4 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c
index b3faf3a..0668c4b 100644
--- a/block.c
+++ b/block.c
@@ -3045,7 +3045,46 @@ void bdrv_debug_event(BlockDriverState *bs, 
BlkDebugEvent event)
 }
 
 drv->bdrv_debug_event(bs, event);
+}
+
+int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event,
+  const char *tag)
+{
+while (bs && bs->drv && !bs->drv->bdrv_debug_breakpoint) {
+bs = bs->file;
+}
+
+if (bs && bs->drv && bs->drv->bdrv_debug_breakpoint) {
+return bs->drv->bdrv_debug_breakpoint(bs, event, tag);
+}
+
+return -ENOTSUP;
+}
+
+int bdrv_debug_resume(BlockDriverState *bs, const char *tag)
+{
+while (bs && bs->drv && !bs->drv->bdrv_debug_resume) {
+bs = bs->file;
+}
 
+if (bs && bs->drv && bs->drv->bdrv_debug_resume) {
+return bs->drv->bdrv_debug_resume(bs, tag);
+}
+
+return -ENOTSUP;
+}
+
+bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag)
+{
+while (bs && bs->drv && !bs->drv->bdrv_debug_is_suspended) {
+bs = bs->file;
+}
+
+if (bs && bs->drv && bs->drv->bdrv_debug_is_suspended) {
+return bs->drv->bdrv_debug_is_suspended(bs, tag);
+}
+
+return false;
 }
 
 /**/
diff --git a/block.h b/block.h
index 24bea09..893448a 100644
--- a/block.h
+++ b/block.h
@@ -431,4 +431,9 @@ typedef enum {
 #define BLKDBG_EVENT(bs, evt) bdrv_debug_event(bs, evt)
 void bdrv_debug_event(BlockDriverState *bs, BlkDebugEvent event);
 
+int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event,
+   const char *tag);
+int bdrv_debug_resume(BlockDriverState *bs, const char *tag);
+bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag);
+
 #endif
diff --git a/block_int.h b/block_int.h
index 9deedb8..bf3f79b 100644
--- a/block_int.h
+++ b/block_int.h
@@ -190,6 +190,12 @@ struct BlockDriver {
 
 void (*bdrv_debug_event)(BlockDriverState *bs, BlkDebugEvent event);
 
+/* TODO Better pass a option string/QDict/QemuOpts to add any rule? */
+int (*bdrv_debug_breakpoint)(BlockDriverState *bs, const char *event,
+const char *tag);
+int (*bdrv_debug_resume)(BlockDriverState *bs, const char *tag);
+bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag);
+
 /*
  * Returns 1 if newly created images are guaranteed to contain only
  * zeros, 0 otherwise.
diff --git a/qemu-io.c b/qemu-io.c
index b4b0898..1637773 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1671,6 +1671,67 @@ static const cmdinfo_t map_cmd = {
.oneline= "prints the allocated areas of a file",
 };
 
+static int break_f(int argc, char **argv)
+{
+int ret;
+
+ret = bdrv_debug_breakpoint(bs, argv[1], argv[2]);
+if (ret < 0) {
+printf("Could not set breakpoint: %s\n", strerror(-ret));
+}
+
+return 0;
+}
+
+static const cmdinfo_t break_cmd = {
+   .name   = "break",
+   .argmin = 2,
+   .argmax = 2,
+   .cfunc  = break_f,
+   .args   = "event tag",
+   .oneline= "sets a breakpoint on event and tags the stopped "
+ "request as tag",
+};
+
+static int resume_f(int argc, char **argv)
+{
+int ret;
+
+ret = bdrv_debug_resume(bs, argv[1]);
+if (ret < 0) {
+printf("Could not resume request: %s\n", strerror(-ret));
+}
+
+return 0;
+}
+
+static const cmdinfo_t resume_cmd = {
+   .name   = "resume",
+   .argmin = 1,
+   .argmax = 1,
+   .cfunc  = resume_f,
+   .args   = "tag",
+   .oneline= "resumes the request tagged as tag",
+};
+
+static int wait_break_f(int argc, char **argv)
+{
+while (!bdrv_debug_is_suspended(bs, argv[1])) {
+qemu_aio_wait();
+}
+
+return 0;
+}
+
+static const cmdinfo_t wait_break_cmd = {
+   .name   = "wait_break",
+   .argmin = 1,
+   .argmax = 1,
+   .cfunc  = wait_break_f,
+   .args   = "tag",
+   .oneline= "waits for the suspension of a request",
+};
+
 static int abort_f(int argc, char **argv)
 {
 abort();
@@ -1934,6 +1995,9 @@ int main(int argc, char **argv)
 

[Qemu-devel] [PATCH 1/6] blkdebug: Allow usage without config file

2012-12-06 Thread Kevin Wolf
As soon as new rules can be set during runtime, as introduced by the
next patch, blkdebug makes sense even without a config file.

Signed-off-by: Kevin Wolf 
---
 block/blkdebug.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/block/blkdebug.c b/block/blkdebug.c
index d61ece8..c9041ec 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -240,6 +240,11 @@ static int read_config(BDRVBlkdebugState *s, const char 
*filename)
 int ret;
 struct add_rule_data d;
 
+/* Allow usage without config file */
+if (!*filename) {
+return 0;
+}
+
 f = fopen(filename, "r");
 if (f == NULL) {
 return -errno;
-- 
1.7.6.5




[Qemu-devel] [PATCH 2/6] blkdebug: Factor out remove_rule()

2012-12-06 Thread Kevin Wolf
The cleanup work to remove a rule depends on the type of the rule. It's
easy for the existing rules as there is no data that must be cleaned up
and is specific to a type yet, but the next patch will change this.

Signed-off-by: Kevin Wolf 
---
 block/blkdebug.c |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/block/blkdebug.c b/block/blkdebug.c
index c9041ec..859792b 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -234,6 +234,18 @@ static int add_rule(QemuOpts *opts, void *opaque)
 return 0;
 }
 
+static void remove_rule(BlkdebugRule *rule)
+{
+switch (rule->action) {
+case ACTION_INJECT_ERROR:
+case ACTION_SET_STATE:
+break;
+}
+
+QLIST_REMOVE(rule, next);
+g_free(rule);
+}
+
 static int read_config(BDRVBlkdebugState *s, const char *filename)
 {
 FILE *f;
@@ -402,8 +414,7 @@ static void blkdebug_close(BlockDriverState *bs)
 
 for (i = 0; i < BLKDBG_EVENT_MAX; i++) {
 QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) {
-QLIST_REMOVE(rule, next);
-g_free(rule);
+remove_rule(rule);
 }
 }
 }
-- 
1.7.6.5




[Qemu-devel] [PATCH 0/6] blkdebug/qcow2/qemu-iotests: Add some AIO testing

2012-12-06 Thread Kevin Wolf
The few existing test cases that involve AIO depend on luck for getting the
right order of requests so that they really test interesting cases. This series
allows a more systematic approach by stopping and resuming AIO requests at
given points.

Kevin Wolf (6):
  blkdebug: Allow usage without config file
  blkdebug: Factor out remove_rule()
  blkdebug: Implement suspend/resume of AIO requests
  qemu-io: Add AIO debugging commands
  qcow2: Move BLKDBG_EVENT out of the lock
  qemu-iotests: Test concurrent cluster allocations

 block.c|   39 
 block.h|5 +
 block/blkdebug.c   |  128 +-
 block/qcow2.c  |2 +-
 block_int.h|6 ++
 qemu-io.c  |   64 +
 tests/qemu-iotests/046 |  215 
 tests/qemu-iotests/046.out |  163 +
 tests/qemu-iotests/group   |1 +
 9 files changed, 617 insertions(+), 6 deletions(-)
 create mode 100755 tests/qemu-iotests/046
 create mode 100644 tests/qemu-iotests/046.out

-- 
1.7.6.5




Re: [Qemu-devel] [PATCH] tests: Add tests for fdsets

2012-12-06 Thread Kevin Wolf
Am 04.12.2012 16:31, schrieb Stefan Hajnoczi:
> On Wed, Nov 14, 2012 at 05:53:16PM -0500, Corey Bryant wrote:
>>
>> Signed-off-by: Corey Bryant 
>> ---
>>  tests/qemu-iotests/044| 129 
>> ++
>>  tests/qemu-iotests/044.out|   5 ++
>>  tests/qemu-iotests/group  |   1 +
>>  tests/qemu-iotests/iotests.py |  12 
>>  4 files changed, 147 insertions(+)
>>  create mode 100755 tests/qemu-iotests/044
>>  create mode 100644 tests/qemu-iotests/044.out
> 
> Thanks, applied to my block tree:
> https://github.com/stefanha/qemu/commits/block

Your conflict resolution put 045 before 044 in group. Can you fix that
before sending a pull request?

Kevin



Re: [Qemu-devel] [RFC 3/3] docs: document virtio-balloon stats

2012-12-06 Thread Daniel P. Berrange
On Tue, Dec 04, 2012 at 01:04:48PM -0200, Luiz Capitulino wrote:
> Signed-off-by: Luiz Capitulino 
> ---
>  docs/virtio-balloon-stats.txt | 73 
> +++
>  1 file changed, 73 insertions(+)
>  create mode 100644 docs/virtio-balloon-stats.txt
> 
> diff --git a/docs/virtio-balloon-stats.txt b/docs/virtio-balloon-stats.txt
> new file mode 100644
> index 000..7e7ddc4
> --- /dev/null
> +++ b/docs/virtio-balloon-stats.txt
> @@ -0,0 +1,73 @@
> +virtio balloon memory statistics
> +
> +
> +The virtio balloon driver supports guest memory statistics reporting. These
> +statistics are available to QEMU users as QOM (QEMU Obejct Model) device
> +properties via a polling mechanism.
> +
> +Basically, clients have to enable polling. Then they can query the available
> +statistics.
> +
> +There are two control properties and six memory statistics from the guest.
> +
> +The control properties are:
> +
> + o stats-polling-interval: a value greater than zero enables polling
> +   in the specified interval (in seconds). When value equals zero,
> +   polling is disabled. If polling is already enabled and a value
> +   greater than zero is written, the polling interval time is changed
> +
> + o stats-last-update: last stats update timestamp, in seconds
> +
> +The memory statistics are:
> +
> + o stat-swap-in
> + o stat-swap-out
> + o stat-major-faults
> + o stat-minor-faults
> + o stat-free-memory
> + o stat-total-memory
> +
> +All values are in bytes. A value of -1 means that the statistic isn't
> +available right now.
> +
> +Here are a few examples. The virtio-balloon device is assumed to be in the
> +'/machine/peripheral-anon/device[1]' QOM path.
> +
> +Enable polling with 2 seconds interval:
> +
> +{ "execute": "qom-set",
> + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> +  "property": "stats-polling-interval", "value": 2 } }
> +
> +{ "return": {} }
> +
> +Change polling to 10 seconds:
> +
> +{ "execute": "qom-set",
> + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> +  "property": "stats-polling-interval", "value": 10 } }
> +
> +{ "return": {} }
> +
> +Get last update timestamp and free memory stat:
> +
> +{ "execute": "qom-get",
> +  "arguments": { "path": "/machine/peripheral-anon/device[1]",
> +  "property": "stats-last-update" } }
> +
> +{ "return": 1354629634 }
> +
> +{ "execute": "qom-get",
> +  "arguments": { "path": "/machine/peripheral-anon/device[1]",
> +  "property": "stat-free-memory" } }
> +
> +{ "return": 845115392 }
> +
> +Disable polling:
> +
> +{ "execute": "qom-set",
> + "arguments": { "path": "/machine/peripheral-anon/device[1]",
> +  "property": "stats-polling-interval", "value": 0 } }
> +
> +{ "return": {} }


What sort of performance implications are there for enabling polling of
virtio stats. Is it the kind of thing that it is reasonable to just
enable for all VMs on a 10 second interval, so we'll always have stats
available without having to have thought to enable them ahead of time ?

eg, the use case I'm wondering is that someone comes along and just
runs   'virsh memstats $DOMAIN' and wants to see the latest data
right away. 

I'm not suggesting that libvirt would be actually asking QEMU for the
stats every 10 seconds. Only that libvirt tells QEMU to collect them.
Then libvirt can just ask for them whenver someone wants them.

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



[Qemu-devel] [PATCH 30/32] fpu: move public header file to include/fpu

2012-12-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure|2 +-
 fpu/softfloat.c  |2 +-
 {fpu => include/fpu}/softfloat.h |0
 include/qemu/bswap.h |2 +-
 linux-user/arm/nwfpe/double_cpdo.c   |2 +-
 linux-user/arm/nwfpe/extended_cpdo.c |2 +-
 linux-user/arm/nwfpe/fpa11.h |2 +-
 linux-user/arm/nwfpe/fpa11_cpdt.c|2 +-
 linux-user/arm/nwfpe/fpa11_cprt.c|2 +-
 linux-user/arm/nwfpe/fpopcode.c  |2 +-
 linux-user/arm/nwfpe/single_cpdo.c   |2 +-
 target-alpha/cpu.h   |2 +-
 target-alpha/fpu_helper.c|2 +-
 target-alpha/helper.c|2 +-
 target-alpha/translate.c |2 +-
 target-arm/cpu.h |2 +-
 target-i386/cpu.h|2 +-
 target-m68k/cpu.h|2 +-
 target-microblaze/cpu.h  |2 +-
 target-mips/cpu.h|2 +-
 target-openrisc/cpu.h|2 +-
 target-ppc/cpu.h |2 +-
 target-s390x/cpu.h   |2 +-
 target-sh4/cpu.h |4 +---
 target-sparc/cpu.h   |2 +-
 target-unicore32/cpu.h   |2 +-
 26 files changed, 25 insertions(+), 27 deletions(-)
 rename {fpu => include/fpu}/softfloat.h (100%)

diff --git a/configure b/configure
index ec07c76..2ef556a 100755
--- a/configure
+++ b/configure
@@ -269,7 +269,7 @@ QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
$QEMU_CFLAGS"
-QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include -I\$(SRC_PATH)/fpu"
+QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
 if test "$debug_info" = "yes"; then
 CFLAGS="-g $CFLAGS"
 LDFLAGS="-g $LDFLAGS"
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 8413146..0cfa6b4 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -40,7 +40,7 @@ these four paragraphs for those parts of this code that are 
retained.
  */
 #include "config.h"
 
-#include "softfloat.h"
+#include "fpu/softfloat.h"
 
 /*
 | Primitive arithmetic functions, including multi-word arithmetic, and
diff --git a/fpu/softfloat.h b/include/fpu/softfloat.h
similarity index 100%
rename from fpu/softfloat.h
rename to include/fpu/softfloat.h
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index cc7f84d..2006fcd 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -4,7 +4,7 @@
 #include "config-host.h"
 
 #include 
-#include "softfloat.h"
+#include "fpu/softfloat.h"
 
 #ifdef CONFIG_MACHINE_BSWAP_H
 #include 
diff --git a/linux-user/arm/nwfpe/double_cpdo.c 
b/linux-user/arm/nwfpe/double_cpdo.c
index 8e9b28f..41c28f3 100644
--- a/linux-user/arm/nwfpe/double_cpdo.c
+++ b/linux-user/arm/nwfpe/double_cpdo.c
@@ -19,7 +19,7 @@
 */
 
 #include "fpa11.h"
-#include "softfloat.h"
+#include "fpu/softfloat.h"
 #include "fpopcode.h"
 
 float64 float64_exp(float64 Fm);
diff --git a/linux-user/arm/nwfpe/extended_cpdo.c 
b/linux-user/arm/nwfpe/extended_cpdo.c
index 880ce03..48eca3b 100644
--- a/linux-user/arm/nwfpe/extended_cpdo.c
+++ b/linux-user/arm/nwfpe/extended_cpdo.c
@@ -19,7 +19,7 @@
 */
 
 #include "fpa11.h"
-#include "softfloat.h"
+#include "fpu/softfloat.h"
 #include "fpopcode.h"
 
 floatx80 floatx80_exp(floatx80 Fm);
diff --git a/linux-user/arm/nwfpe/fpa11.h b/linux-user/arm/nwfpe/fpa11.h
index 002b3cb..bb9ac65 100644
--- a/linux-user/arm/nwfpe/fpa11.h
+++ b/linux-user/arm/nwfpe/fpa11.h
@@ -43,7 +43,7 @@ extern CPUARMState *user_registers;
 
 /* includes */
 #include "fpsr.h"  /* FP control and status register definitions */
-#include "softfloat.h"
+#include "fpu/softfloat.h"
 
 #definetypeNone0x00
 #definetypeSingle  0x01
diff --git a/linux-user/arm/nwfpe/fpa11_cpdt.c 
b/linux-user/arm/nwfpe/fpa11_cpdt.c
index 3e7a938..007a3d6 100644
--- a/linux-user/arm/nwfpe/fpa11_cpdt.c
+++ b/linux-user/arm/nwfpe/fpa11_cpdt.c
@@ -20,7 +20,7 @@
 */
 
 #include "fpa11.h"
-#include "softfloat.h"
+#include "fpu/softfloat.h"
 #include "fpopcode.h"
 //#include "fpmodule.h"
 //#include "fpmodule.inl"
diff --git a/linux-user/arm/nwfpe/fpa11_cprt.c 
b/linux-user/arm/nwfpe/fpa11_cprt.c
index 8011897..7be93fa 100644
--- a/linux-user/arm/nwfpe/fpa11_cprt.c
+++ b/linux-user/arm/nwfpe/fpa11_cprt.c
@@ -20,7 +20,7 @@
 */
 
 #include "fpa11.h"
-#include "softfloat.h"
+#include "fpu/softfloat.h"
 #include "fpopcode.h"
 #include "fpa11.inl"
 //#include "fpmodule.h"
diff --git a/linux-user/arm/nwfpe/fpopcode.c b/linux-user/arm/nwfpe/fpopcode.c
index 82ac92f..0dc5c9c 100644
--- a/linux-user/arm/nwfpe/fpopcode.c
+++ b/linux-user/arm/nwfpe/fpopcode.c
@@ -19

  1   2   >