[Qemu-devel] Re: [PATCH] w32: Fix compilation of new code

2011-04-01 Thread Paolo Bonzini

On 03/31/2011 10:58 PM, Stefan Weil wrote:

Some recently added new code did not compile for w32 targets.

The functions qemu_iohandler_fill and qemu_iohandler_poll need
data type fd_set which is declared in winsock2.h for w32 targets.

Moving the functions from qemu-common.h to qemu_socket.h fixes
compilations for w32 without adding a new include file to qemu-common.h.

Cc: Paolo Bonzini
Cc: Anthony Liguori
Signed-off-by: Stefan Weil
---
  iohandler.c   |1 +
  qemu-common.h |3 ---
  qemu_socket.h |4 
  3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/iohandler.c b/iohandler.c
index 2b82421..bf1ba5c 100644
--- a/iohandler.c
+++ b/iohandler.c
@@ -26,6 +26,7 @@
  #include "qemu-common.h"
  #include "qemu-char.h"
  #include "qemu-queue.h"
+#include "qemu_socket.h"

  #ifndef _WIN32
  #include
diff --git a/qemu-common.h b/qemu-common.h
index 8ecb488..eb2c96a 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -228,9 +228,6 @@ typedef void IOReadHandler(void *opaque, const uint8_t 
*buf, int size);
  typedef int IOCanReadHandler(void *opaque);
  typedef void IOHandler(void *opaque);

-void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set 
*xfds);
-void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int 
rc);
-
  struct ParallelIOArg {
  void *buffer;
  int count;
diff --git a/qemu_socket.h b/qemu_socket.h
index 180e4db..4a6ef82 100644
--- a/qemu_socket.h
+++ b/qemu_socket.h
@@ -32,6 +32,10 @@ int inet_aton(const char *cp, struct in_addr *ia);

  #include "qemu-option.h"

+/* Functions from iohandler.c. */
+void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set 
*xfds);
+void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int 
rc);
+
  /* misc helpers */
  int qemu_socket(int domain, int type, int protocol);
  int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);


Acked-by: Paolo Bonzini 

Paolo



Re: [Qemu-devel] [PATCH RFC] vga: flag vga ram for notifiers

2011-04-01 Thread Peter Maydell
On 31 March 2011 22:38, Michael S. Tsirkin  wrote:
> On Thu, Mar 31, 2011 at 10:32:11PM +0100, Peter Maydell wrote:
>> On 31 March 2011 21:23, Anthony Liguori  wrote:
>> > Maybe the right approach here is to just use a virtio specific API and
>> > register RAM as register_virtio_dma_area().
>>
>> That seems like a clearer API, yes. I think it makes it much more
>> obvious what it's trying to achieve.

> Maybe register_dma_area - its' not 100% virtio specific.

Presumably it is specific to virtualisation-aware devices
though? Guest DMA has to just work to all the locations you
can DMA to/from on hardware, right?

-- PMM



[Qemu-devel] Re: [PATCH V3] floppy: save and restore DIR register

2011-04-01 Thread Paolo Bonzini

On 04/01/2011 08:22 AM, Jason Wang wrote:

+
+if (drive->bs == NULL) {
+return 1;


Is it okay to return 1 here?  Have you tested the case when both the 
source and the target drives have no floppy?


(The "media_changed == 2" in my sample code was basically a way to save 
the "media present" state of the drive on the source).



+} else {
+drive->bs->media_changed = drive->media_changed;
+return 0;
+}


The code is also missing the case of a pc-0.14 machine.  The problem 
here is that the pc-0.15 machine hasn't been created yet, you get the 
honor. :(


Paolo



[Qemu-devel] Re: [RFC PATCH] qed: add support for Copy-on-Read

2011-04-01 Thread Stefan Hajnoczi
On Wed, Mar 30, 2011 at 08:08:34PM -0500, Anthony Liguori wrote:
> When creating an image using qemu-img, just pass '-o copy_on_read' and then
> whenever QED reads from a backing file, it will write the block to the QED
> file after the read completes ensuring that you only fetch from the backing
> device once.
> 
> This is very useful for streaming images over a slow connection.
> 
> This isn't ready for merge yet as it's not playing nice with synchronize I/O.

What is the issue here?  Streaming had issues with aio contexts and
synchronous I/O emulation but copy-on-read by itself looks safe to me.

> I think it's fairly easy to do the same thing in qcow2 by just hooking adding
> some logic after bdrv_aio_write() to call back into qcow2 with a synchronous
> I/O write in the backing file case.   Thoughts on whether that would actually
> work?

Why not do the follow-up .bdrv_aio_writev() for qcow2 too?  I don't see
a reason to do it synchronously.

Stefan



[Qemu-devel] Re: [RFC][PATCH v1 10/12] guest agent: qemu-ga daemon

2011-04-01 Thread Jes Sorensen
On 03/25/11 20:47, Michael Roth wrote:
> This is the actual guest daemon, it listens for requests over a
> virtio-serial/isa-serial/unix socket channel and routes them through
> to dispatch routines, and writes the results back to the channel in
> a manner similar to Qmp.
> 
> This is currently horribly broken, only the unix-listen channel method
> is working at the moment (likely due to mis-use of gio channel
> interfaces), and the code is in overall rough shape.
> 
> Signed-off-by: Michael Roth 
> ---
>  qemu-ga.c |  522 
> +
>  1 files changed, 522 insertions(+), 0 deletions(-)
>  create mode 100644 qemu-ga.c
> 
> diff --git a/qemu-ga.c b/qemu-ga.c
> new file mode 100644
> index 000..435a1fc
> --- /dev/null
> +++ b/qemu-ga.c
> @@ -0,0 +1,522 @@
> +/*
> + * QEMU Guest Agent
> + *
> + * Copyright IBM Corp. 2011
> + *
> + * Authors:
> + *  Adam Litke
> + *  Michael Roth  
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "qemu_socket.h"
> +#include "json-streamer.h"
> +#include "json-parser.h"
> +#include "guest-agent.h"
> +
> +#define QGA_VERSION "1.0"
> +#define QGA_GUEST_PATH_VIRTIO_DEFAULT "/dev/virtio-ports/va"
> +#define QGA_PIDFILE_DEFAULT "/var/run/qemu-va.pid"
> +#define QGA_BAUDRATE_DEFAULT B38400 /* for isa-serial channels */
> +
> +bool verbose_enabled = false;
> +
> +typedef struct GAState {
> +bool active;
> +int session_id;
> +const char *proxy_path;
> +JSONMessageParser parser;
> +GMainLoop *main_loop;
> +guint conn_id;
> +GSocket *conn_sock;
> +GIOChannel *conn_channel;
> +guint listen_id;
> +GSocket *listen_sock;
> +GIOChannel *listen_channel;
> +const char *path;
> +const char *method;
> +} GAState;
> +
> +static void usage(const char *cmd)
> +{
> +printf(
> +"Usage: %s -c \n"
> +"QEMU virtagent guest agent %s\n"
> +"\n"
> +"  -c, --channel channel method: one of unix-connect, virtio-serial, 
> or\n"
> +"isa-serial\n"
> +"  -p, --pathchannel path\n"
> +"  -v, --verbose display extra debugging information\n"
> +"  -d, --daemonize   become a daemon\n"
> +"  -h, --helpdisplay this help and exit\n"
> +"\n"
> +"Report bugs to \n"
> +, cmd, QGA_VERSION);
> +}
> +
> +static void conn_channel_close(GAState *s);
> +
> +static void become_daemon(void)
> +{
> +pid_t pid, sid;
> +int pidfd;
> +char *pidstr;
> +
> +pid = fork();
> +if (pid < 0)
> +exit(EXIT_FAILURE);

There's a pile of missing braces in this file - please go through it and
fix them before the next version.

Cheers,
Jes



[Qemu-devel] Re: [PATCH V3] floppy: save and restore DIR register

2011-04-01 Thread Jason Wang
Paolo Bonzini writes:
 > On 04/01/2011 08:22 AM, Jason Wang wrote:
 > > +
 > > +if (drive->bs == NULL) {
 > > +return 1;
 > 
 > Is it okay to return 1 here?  Have you tested the case when both the 
 > source and the target drives have no floppy?
 > 

Thanks for the reminding, and it could be fixed by put all pre/post callbacks
into the subsections.

 > (The "media_changed == 2" in my sample code was basically a way to save 
 > the "media present" state of the drive on the source).
 > 

Right, but it would make subsection saving be the common case (consider most of
the vm may just have one floppy but we have two drives). A better solution 
maybe:

1 Set default_migration_media_changed be 0 for 0.15 and 1 for elder
2 Unconditiaonlly send subsection when it was 0, and do not send subsection when
it was 1
3 Set media_changed to default_migration_media_changed in pre_load()
4 Let all pre/post to be in subsection

After those, we can make sure the migration between 0.15 could get correct
media_changed, also make sure the seamless migration between 0.15 and older
machine types.

Any suggestions?

 > > +} else {
 > > +drive->bs->media_changed = drive->media_changed;
 > > +return 0;
 > > +}
 > 
 > The code is also missing the case of a pc-0.14 machine.  The problem 
 > here is that the pc-0.15 machine hasn't been created yet, you get the 
 > honor. :(
 > 

Would create such one :)

 > Paolo



Re: [Qemu-devel] [RFC PATCH] qed: add support for Copy-on-Read

2011-04-01 Thread Kevin Wolf
Am 31.03.2011 03:08, schrieb Anthony Liguori:
> When creating an image using qemu-img, just pass '-o copy_on_read' and then
> whenever QED reads from a backing file, it will write the block to the QED
> file after the read completes ensuring that you only fetch from the backing
> device once.

As you probably know, I don't agree with the interface. Copy on read
should be first and foremost a runtime option. It's okay to fetch the
default for this option from the image file, but it's not the right
primary interface.

> This is very useful for streaming images over a slow connection.
> 
> This isn't ready for merge yet as it's not playing nice with synchronize I/O.

Like Stefan I'm not sure what you mean here.

One problem that I see is that if you have a concurrent write request
from the guest, the COR write request may overwrite the guest's request,
which is obviously wrong. Is this what you mean?

> I think it's fairly easy to do the same thing in qcow2 by just hooking adding
> some logic after bdrv_aio_write() to call back into qcow2 with a synchronous
> I/O write in the backing file case.   Thoughts on whether that would actually
> work?

I can't see a reason why it wouldn't work. Except that it has the same
problem that I described above. A synchronous write isn't going to solve
this, you'd additionally need a qemu_aio_flush() if you want to avoid
proper locking. But that's really the same for QED and qcow2.

Kevin



Re: [Qemu-devel] [PATCH RFC] vga: flag vga ram for notifiers

2011-04-01 Thread Michael S. Tsirkin
On Fri, Apr 01, 2011 at 08:12:48AM +0100, Peter Maydell wrote:
> On 31 March 2011 22:38, Michael S. Tsirkin  wrote:
> > On Thu, Mar 31, 2011 at 10:32:11PM +0100, Peter Maydell wrote:
> >> On 31 March 2011 21:23, Anthony Liguori  wrote:
> >> > Maybe the right approach here is to just use a virtio specific API and
> >> > register RAM as register_virtio_dma_area().
> >>
> >> That seems like a clearer API, yes. I think it makes it much more
> >> obvious what it's trying to achieve.
> 
> > Maybe register_dma_area - its' not 100% virtio specific.
> 
> Presumably it is specific to virtualisation-aware devices
> though? Guest DMA has to just work to all the locations you
> can DMA to/from on hardware, right?
> 
> -- PMM

I guess so, yes.  But it might not be possible e.g. for a PCI device
to DMA into an ISA device.

-- 
MST



[Qemu-devel] Re: [PATCH V3] floppy: save and restore DIR register

2011-04-01 Thread Paolo Bonzini

On 04/01/2011 12:03 PM, Jason Wang wrote:

Paolo Bonzini writes:
  >  On 04/01/2011 08:22 AM, Jason Wang wrote:
  >  >  +
  >  >  +if (drive->bs == NULL) {
  >  >  +return 1;
  >
  >  Is it okay to return 1 here?  Have you tested the case when both the
  >  source and the target drives have no floppy?
  >

Thanks for the reminding, and it could be fixed by put all pre/post callbacks
into the subsections.


Not sure that works, post callbacks are not called for subsections that 
are not needed.



  >  (The "media_changed == 2" in my sample code was basically a way to save
  >  the "media present" state of the drive on the source).

Right, but it would make subsection saving be the common case (consider most of
the vm may just have one floppy but we have two drives).


Hmm, right, there's 2 bits involved---media present and media changed.


1 Set default_migration_media_changed be 0 for 0.15 and 1 for elder
2 Unconditionally send subsection when it was 0, and do not send subsection when
it was 1


Which means, never send it for pc-0.14 and always for pc-0.15.  At this 
point I'm starting to think that this new-to-old migration business is a 
lost cause, and it's easier to bump the version number and just default 
the field to 1 if the version is old. :(


The problem here is that you're solving a different problem than what 
subsections were supposed to help with.  Subsections help with "the 
value that old versions used is usually but not always correct".  Here 
you have "the value that old versions used is usually *in*correct, but 
nobody noticed so far".


Michael/Amit, as you were the ones proposing stronger new-to-old 
support, can you read the thread and see if you have any ideas?


Paolo



[Qemu-devel] [PATCH v7 4/4] piix_pci: load path clean up

2011-04-01 Thread Isaku Yamahata
The previous patch didn't change the behavior when load,
it resulted in ugly code. This patch cleans it up.

With this patch, pic irq lines are manipulated when loaded.
It is expected that it won't change the behaviour because
the interrupts are level: at the moment e.g. pci devices already
reassert interrupts on load.

Test:
- rung linux as guest and use flooding ping (ping -f) to host
  in order to trigger interrupts for e1000 emulated.
- savevm/loadvm and see guest kept running after loadvm.

To be honest, I'm not sure that ping -f caused enough interrupts
because Linux e1000 driver supports NAPI.
TODO: test more OSes, stress test with save/load, live-migration

Signed-off-by: Isaku Yamahata 
---
Changes v3 -> v4:
- newly introduced
---
 hw/piix_pci.c |   12 
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 7ffb821..5f0d92f 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -281,8 +281,7 @@ static void piix3_set_irq_pic(PIIX3State *piix3, int 
pic_irq)
  (pic_irq * PIIX_NUM_PIRQS;
 }
 
-static void piix3_set_irq_level(PIIX3State *piix3, int pirq, int level,
-bool propagate)
+static void piix3_set_irq_level(PIIX3State *piix3, int pirq, int level)
 {
 int pic_irq;
 uint64_t mask;
@@ -296,15 +295,13 @@ static void piix3_set_irq_level(PIIX3State *piix3, int 
pirq, int level,
 piix3->pic_levels &= ~mask;
 piix3->pic_levels |= mask * !!level;
 
-if (propagate) {
-piix3_set_irq_pic(piix3, pic_irq);
-}
+piix3_set_irq_pic(piix3, pic_irq);
 }
 
 static void piix3_set_irq(void *opaque, int pirq, int level)
 {
 PIIX3State *piix3 = opaque;
-piix3_set_irq_level(piix3, pirq, level, true);
+piix3_set_irq_level(piix3, pirq, level);
 }
 
 /* irq routing is changed. so rebuild bitmap */
@@ -315,8 +312,7 @@ static void piix3_update_irq_levels(PIIX3State *piix3)
 piix3->pic_levels = 0;
 for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) {
 piix3_set_irq_level(piix3, pirq,
-pci_bus_get_irq_level(piix3->dev.bus, pirq),
-false);
+pci_bus_get_irq_level(piix3->dev.bus, pirq));
 }
 }
 
-- 
1.7.1.1




[Qemu-devel] [PATCH v7 1/4] pci: add accessor function to get irq levels

2011-04-01 Thread Isaku Yamahata
Introduce accessor function to know INTx levels.
It will be used later by q35.
Although piix_pci tracks the intx line levels, it can be eliminated
by this helper function.

Cc: Michael S. Tsirkin 
Signed-off-by: Isaku Yamahata 
---
 hw/pci.c |7 +++
 hw/pci.h |1 +
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 6b577e1..3ee4871 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -126,6 +126,13 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int 
irq_num, int change)
 bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
 }
 
+int pci_bus_get_irq_level(PCIBus *bus, int irq_num)
+{
+assert(irq_num >= 0);
+assert(irq_num < bus->nirq);
+return !!bus->irq_count[irq_num];
+}
+
 /* Update interrupt status bit in config space on interrupt
  * state change. */
 static void pci_update_irq_status(PCIDevice *dev)
diff --git a/hw/pci.h b/hw/pci.h
index 52ee8c9..a5f875d 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -234,6 +234,7 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
 PCIBus *pci_bus_new(DeviceState *parent, const char *name, uint8_t devfn_min);
 void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
   void *irq_opaque, int nirq);
+int pci_bus_get_irq_level(PCIBus *bus, int irq_num);
 void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *dev);
 PCIBus *pci_register_bus(DeviceState *parent, const char *name,
  pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
-- 
1.7.1.1




[Qemu-devel] [PATCH v7 2/4] piix_pci: eliminate PIIX3State::pci_irq_levels

2011-04-01 Thread Isaku Yamahata
PIIX3State::pci_irq_levels are redundant which is already tracked by
PCIBus layer. So eliminate them.

Cc: Juan Quintela 
Cc: Michael S. Tsirkin 
Signed-off-by: Isaku Yamahata 
---
Changes v3 -> v4:
- use PCI_NUM_PINS instead of magic number 4

Changes v2 -> v3:
- rename member s/dummy_for_save_load_compat/pci_irq_levels_vmstate/g
---
 hw/piix_pci.c |   38 +++---
 1 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 358da58..35e420c 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -37,10 +37,14 @@
 
 typedef PCIHostState I440FXState;
 
+#define PIIX_NUM_PIRQS  4ULL/* PIRQ[A-D] */
+
 typedef struct PIIX3State {
 PCIDevice dev;
-int pci_irq_levels[4];
 qemu_irq *pic;
+
+/* This member isn't used. Just for save/load compatibility */
+int32_t pci_irq_levels_vmstate[PIIX_NUM_PIRQS];
 } PIIX3State;
 
 struct PCII440FXState {
@@ -162,9 +166,11 @@ static int i440fx_load_old(QEMUFile* f, void *opaque, int 
version_id)
 i440fx_update_memory_mappings(d);
 qemu_get_8s(f, &d->smm_enabled);
 
-if (version_id == 2)
-for (i = 0; i < 4; i++)
-d->piix3->pci_irq_levels[i] = qemu_get_be32(f);
+if (version_id == 2) {
+for (i = 0; i < PIIX_NUM_PIRQS; i++) {
+qemu_get_be32(f); /* dummy load for compatibility */
+}
+}
 
 return 0;
 }
@@ -236,7 +242,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int 
*piix3_devfn, qemu_irq *
 piix3 = DO_UPCAST(PIIX3State, dev,
   pci_create_simple_multifunction(b, -1, true, "PIIX3"));
 piix3->pic = pic;
-pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, 4);
+pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, PIIX_NUM_PIRQS);
 (*pi440fx_state)->piix3 = piix3;
 
 *piix3_devfn = piix3->dev.devfn;
@@ -256,8 +262,6 @@ static void piix3_set_irq(void *opaque, int irq_num, int 
level)
 int i, pic_irq, pic_level;
 PIIX3State *piix3 = opaque;
 
-piix3->pci_irq_levels[irq_num] = level;
-
 /* now we change the pic irq level according to the piix irq mappings */
 /* XXX: optimize */
 pic_irq = piix3->dev.config[0x60 + irq_num];
@@ -266,8 +270,9 @@ static void piix3_set_irq(void *opaque, int irq_num, int 
level)
to it */
 pic_level = 0;
 for (i = 0; i < 4; i++) {
-if (pic_irq == piix3->dev.config[0x60 + i])
-pic_level |= piix3->pci_irq_levels[i];
+if (pic_irq == piix3->dev.config[0x60 + i]) {
+pic_level |= pci_bus_get_irq_level(piix3->dev.bus, i);
+}
 }
 qemu_set_irq(piix3->pic[pic_irq], pic_level);
 }
@@ -309,8 +314,17 @@ static void piix3_reset(void *opaque)
 pci_conf[0xab] = 0x00;
 pci_conf[0xac] = 0x00;
 pci_conf[0xae] = 0x00;
+}
 
-memset(d->pci_irq_levels, 0, sizeof(d->pci_irq_levels));
+static void piix3_pre_save(void *opaque)
+{
+int i;
+PIIX3State *piix3 = opaque;
+
+for (i = 0; i < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); i++) {
+piix3->pci_irq_levels_vmstate[i] =
+pci_bus_get_irq_level(piix3->dev.bus, i);
+}
 }
 
 static const VMStateDescription vmstate_piix3 = {
@@ -318,9 +332,11 @@ static const VMStateDescription vmstate_piix3 = {
 .version_id = 3,
 .minimum_version_id = 2,
 .minimum_version_id_old = 2,
+.pre_save = piix3_pre_save,
 .fields  = (VMStateField []) {
 VMSTATE_PCI_DEVICE(dev, PIIX3State),
-VMSTATE_INT32_ARRAY_V(pci_irq_levels, PIIX3State, 4, 3),
+VMSTATE_INT32_ARRAY_V(pci_irq_levels_vmstate, PIIX3State,
+  PIIX_NUM_PIRQS, 3),
 VMSTATE_END_OF_LIST()
 }
 };
-- 
1.7.1.1




[Qemu-devel] [PATCH v7 0/4] piix_pci: optimize irq data path

2011-04-01 Thread Isaku Yamahata
Here is v7 which are rebased to pci branch.

I tested this patch series as follows. please see the commit message
for details.
- 3/4 piix_pci: optimize set irq path
  Run linux as guest with 4 e1000 emulated devices.
  And confirmed that each PIRQ[A-D] are able to assert interrupts.
- 4/4 piix_pci: load path clean up
  Run linux as guest with one e1000 emulated device.
  savevm/loadvm guest with runing ping -f in guest.

To be honest, the patch, "4/4 piix_pci: load path clean up", needs more
extensive tests. For example live migration and stress test.
But for now I don't have plan to further testing in near future. Sorry.
So please feel free to pick or drop the last patch.

patch description:
This patch series optimizes irq data path of piix_pci.
So far piix3 tracks each pirq level and checks whether a given pic pins is
asserted by seeing if each pirq is mapped into the pic pin.
This is independent on irq routing, but data path is on slow path.

Given that irq routing is rarely changed and asserting pic pins is on
data path, the path that asserts pic pins should be optimized and
chainging irq routing should be on slow path.
The new behavior with this patch series is to use bitmap which is addressed
by pirq and pic pins with a given irq routing.
When pirq is asserted, the bitmap is set and see if the pic pins is
asserted by checking the bitmaps.
When irq routing is changed, rebuild the bitmap and re-assert pic pins.

Changes v6 -> v7:
- rebased to pci branch
- added how to test to the commit message

Changes v5 -> v6:
- fixed piix3_set_irq_pic()

Changes v4 -> v5:
- typo

Changes v3 -> v4:
- use pirq, pci_intx instead of irq_num in piix_pci.c
- use symbolic constant PIC_NUM_PINS
- introduced new patch 4/4 which cleans up a bit.

Changes v2 -> v3:
- s/dummy_for_save_load_compat/pci_irq_levels_vmstate/g
- move down unused member of pci_irq_levels_vmstate in the structure
  for cache efficiency

Changes v1 -> v2:
- addressed review comments.

Isaku Yamahata (4):
  pci: add accessor function to get irq levels
  piix_pci: eliminate PIIX3State::pci_irq_levels
  piix_pci: optimize set irq path
  piix_pci: load path clean up

 hw/pci.c  |7 +++
 hw/pci.h  |1 +
 hw/piix_pci.c |  129 ++---
 3 files changed, 112 insertions(+), 25 deletions(-)




[Qemu-devel] [PATCH v7 3/4] piix_pci: optimize set irq path

2011-04-01 Thread Isaku Yamahata
optimize irq routing in piix_pic.c which has been a TODO.
So far piix3 tracks each pirq level and checks whether a given pic pins is
asserted by seeing if each pirq is mapped into the pic pin.
This is independent on irq routing, but data path is on slow path.

Given that irq routing is rarely changed and asserting pic pins is on
data path, the path that asserts pic pins should be optimized and
chainging irq routing should be on slow path.
The new behavior with this patch series is to use bitmap which is addressed
by pirq and pic pins with a given irq routing.
When pirq is asserted, the bitmap is set and see if the pic pins is
asserted by checking the bitmaps.
When irq routing is changed, rebuild the bitmap and re-assert pic pins.

test:
- create VM with 4 e1000 nics in different pci slots
  (i.e. fn=0 for each e1000)
  Thus those e1000's INTA are connected to each PIRQ[A-D].
- run linux as guest and saw each devices triggers interrupt
  by seeing /proc/interrupts. And then confirmed that each PIRQ[A-D]
  surely asserted interrupts.
  Because irq 10 and 11 are shared by 4 e1000's, it only one NIC is activated
  with ifconfig ethN up/down when counting interrupts.

Cc: Michael S. Tsirkin 
Signed-off-by: Isaku Yamahata 
---
Changes v4 -> v5:
- fix piix_set_irq_pic()

Changes v3 -> v4:
- replace irq_num with pirq or pci_intx

Changes v1 -> v2:
- some minor clean ups
- commit log message
---
 hw/piix_pci.c |  101 +++-
 1 files changed, 84 insertions(+), 17 deletions(-)

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 35e420c..7ffb821 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -37,10 +37,27 @@
 
 typedef PCIHostState I440FXState;
 
+#define PIIX_NUM_PIC_IRQS   16  /* i8259 * 2 */
 #define PIIX_NUM_PIRQS  4ULL/* PIRQ[A-D] */
+#define PIIX_PIRQC  0x60
 
 typedef struct PIIX3State {
 PCIDevice dev;
+
+/*
+ * bitmap to track pic levels.
+ * The pic level is the logical OR of all the PCI irqs mapped to it
+ * So one PIC level is tracked by PIIX_NUM_PIRQS bits.
+ *
+ * PIRQ is mapped to PIC pins, we track it by
+ * PIIX_NUM_PIRQS * PIIX_NUM_PIC_IRQS = 64 bits with
+ * pic_irq * PIIX_NUM_PIRQS + pirq
+ */
+#if PIIX_NUM_PIC_IRQS * PIIX_NUM_PIRQS > 64
+#error "unable to encode pic state in 64bit in pic_levels."
+#endif
+uint64_t pic_levels;
+
 qemu_irq *pic;
 
 /* This member isn't used. Just for save/load compatibility */
@@ -59,16 +76,16 @@ struct PCII440FXState {
 #define I440FX_PAM_SIZE 7
 #define I440FX_SMRAM0x72
 
-static void piix3_set_irq(void *opaque, int irq_num, int level);
+static void piix3_set_irq(void *opaque, int pirq, int level);
 
 /* return the global irq number corresponding to a given device irq
pin. We could also use the bus number to have a more precise
mapping. */
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
+static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
 {
 int slot_addend;
 slot_addend = (pci_dev->devfn >> 3) - 1;
-return (irq_num + slot_addend) & 3;
+return (pci_intx + slot_addend) & 3;
 }
 
 static void update_pam(PCII440FXState *d, uint32_t start, uint32_t end, int r)
@@ -256,25 +273,64 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int 
*piix3_devfn, qemu_irq *
 }
 
 /* PIIX3 PCI to ISA bridge */
+static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
+{
+qemu_set_irq(piix3->pic[pic_irq],
+ !!(piix3->pic_levels &
+(((1UL << PIIX_NUM_PIRQS) - 1) <<
+ (pic_irq * PIIX_NUM_PIRQS;
+}
 
-static void piix3_set_irq(void *opaque, int irq_num, int level)
+static void piix3_set_irq_level(PIIX3State *piix3, int pirq, int level,
+bool propagate)
+{
+int pic_irq;
+uint64_t mask;
+
+pic_irq = piix3->dev.config[PIIX_PIRQC + pirq];
+if (pic_irq >= PIIX_NUM_PIC_IRQS) {
+return;
+}
+
+mask = 1ULL << ((pic_irq * PIIX_NUM_PIRQS) + pirq);
+piix3->pic_levels &= ~mask;
+piix3->pic_levels |= mask * !!level;
+
+if (propagate) {
+piix3_set_irq_pic(piix3, pic_irq);
+}
+}
+
+static void piix3_set_irq(void *opaque, int pirq, int level)
 {
-int i, pic_irq, pic_level;
 PIIX3State *piix3 = opaque;
+piix3_set_irq_level(piix3, pirq, level, true);
+}
 
-/* now we change the pic irq level according to the piix irq mappings */
-/* XXX: optimize */
-pic_irq = piix3->dev.config[0x60 + irq_num];
-if (pic_irq < 16) {
-/* The pic level is the logical OR of all the PCI irqs mapped
-   to it */
-pic_level = 0;
-for (i = 0; i < 4; i++) {
-if (pic_irq == piix3->dev.config[0x60 + i]) {
-pic_level |= pci_bus_get_irq_level(piix3->dev.bus, i);
-}
+/* irq routing is changed. so rebuild bitmap */
+static void piix3_update_irq_levels(PIIX3State *piix3)
+{
+int pirq;
+
+pi

[Qemu-devel] Re: [RFC PATCH] qed: add support for Copy-on-Read

2011-04-01 Thread Anthony Liguori

On 04/01/2011 04:42 AM, Stefan Hajnoczi wrote:

On Wed, Mar 30, 2011 at 08:08:34PM -0500, Anthony Liguori wrote:

When creating an image using qemu-img, just pass '-o copy_on_read' and then
whenever QED reads from a backing file, it will write the block to the QED
file after the read completes ensuring that you only fetch from the backing
device once.

This is very useful for streaming images over a slow connection.

This isn't ready for merge yet as it's not playing nice with synchronize I/O.

What is the issue here?  Streaming had issues with aio contexts and
synchronous I/O emulation but copy-on-read by itself looks safe to me.


Here's the scenario that fails for me although I'm starting to suspect 
block/curl as the real culprit.


qemu-img create -f qed -o copy_on_read -b 
http://linux.nssl.noaa.gov/fedora/fedora/linux/releases/14/Fedora/x86_64/iso/Fedora-14-x86_64-DVD.iso 
cached_iso.img


qemu -cdrom cache_iso.img -boot d

And I have a patch that does a bunch of synchronous reads of the disk.


I think it's fairly easy to do the same thing in qcow2 by just hooking adding
some logic after bdrv_aio_write() to call back into qcow2 with a synchronous
I/O write in the backing file case.   Thoughts on whether that would actually
work?

Why not do the follow-up .bdrv_aio_writev() for qcow2 too?  I don't see
a reason to do it synchronously.


Oh, I assumed with coroutines that that would be the preference in 
qcow2.  If not, AIO is just as good for me :-)


Regards,

Anthony Liguori


Stefan





Re: [Qemu-devel] [RFC PATCH] qed: add support for Copy-on-Read

2011-04-01 Thread Anthony Liguori

On 04/01/2011 06:11 AM, Kevin Wolf wrote:

Am 31.03.2011 03:08, schrieb Anthony Liguori:

When creating an image using qemu-img, just pass '-o copy_on_read' and then
whenever QED reads from a backing file, it will write the block to the QED
file after the read completes ensuring that you only fetch from the backing
device once.

As you probably know, I don't agree with the interface. Copy on read
should be first and foremost a runtime option. It's okay to fetch the
default for this option from the image file, but it's not the right
primary interface.


That's the main reason I posted this.  I wanted to revisit that 
discussion and see if we're any close to having a primary interface for 
this.


I think blockdev is still a ways off.  Would a -drive 
file=image.img,cor=on make sense as an intermediate mechanism?



This is very useful for streaming images over a slow connection.

This isn't ready for merge yet as it's not playing nice with synchronize I/O.

Like Stefan I'm not sure what you mean here.

One problem that I see is that if you have a concurrent write request
from the guest, the COR write request may overwrite the guest's request,
which is obviously wrong. Is this what you mean?


Yes, I think you're right here but I don't think this is the issue.  But 
surely the semantics of a simultaneous read/write are undefined at least 
on the read side.  I guess having the write be undefined is unexpected.


Regards,

Anthony Liguori


Kevin





Re: [Qemu-devel] [RFC PATCH] qed: add support for Copy-on-Read

2011-04-01 Thread Kevin Wolf
Am 01.04.2011 14:36, schrieb Anthony Liguori:
> On 04/01/2011 06:11 AM, Kevin Wolf wrote:
>> Am 31.03.2011 03:08, schrieb Anthony Liguori:
>>> When creating an image using qemu-img, just pass '-o copy_on_read' and then
>>> whenever QED reads from a backing file, it will write the block to the QED
>>> file after the read completes ensuring that you only fetch from the backing
>>> device once.
>> As you probably know, I don't agree with the interface. Copy on read
>> should be first and foremost a runtime option. It's okay to fetch the
>> default for this option from the image file, but it's not the right
>> primary interface.
> 
> That's the main reason I posted this.  I wanted to revisit that 
> discussion and see if we're any close to having a primary interface for 
> this.
> 
> I think blockdev is still a ways off.  Would a -drive 
> file=image.img,cor=on make sense as an intermediate mechanism?

I don't like it much (and I think neither do you), but I agree that
blockdev won't be there tomorrow, so I wouldn't object to it.

>>> This is very useful for streaming images over a slow connection.
>>>
>>> This isn't ready for merge yet as it's not playing nice with synchronize 
>>> I/O.
>> Like Stefan I'm not sure what you mean here.
>>
>> One problem that I see is that if you have a concurrent write request
>> from the guest, the COR write request may overwrite the guest's request,
>> which is obviously wrong. Is this what you mean?
> 
> Yes, I think you're right here but I don't think this is the issue.  But 
> surely the semantics of a simultaneous read/write are undefined at least 
> on the read side.  I guess having the write be undefined is unexpected.

Yes and no. If you have the read and the write to same sector, then it
would be undefined whether the read returns the old or the new data. But
if the write completes successfully, the sector must have been updated.
I doubt that this is something that guests usually do.

However, we're not operating on a sector level, but on a cluster level
here. So the guest could actually access two different sectors and still
get its write request overwritten by the COR.

Kevin



Re: [Qemu-devel] [PATCH v24 00/10] usb-ccid

2011-04-01 Thread Anthony Liguori

On 03/28/2011 11:11 AM, Alon Levy wrote:

This patchset adds three new devices, usb-ccid, ccid-card-passthru and
ccid-card-emulated, providing a CCID bus, a simple passthru protocol
implementing card requiring a client, and a standalone emulated card.

It also introduces a new directory libcaccard with CAC card emulation,
CAC is a type of ISO 7816 smart card.

Tree for pull: git://anongit.freedesktop.org/~alon/qemu usb_ccid.v23


CC libcacard/cac.o
In file included from /home/anthony/git/qemu/libcacard/cac.c:8:
/home/anthony/git/qemu/qemu-common.h:5:25: error: config-host.h: No such 
file or directory

In file included from /home/anthony/git/qemu/libcacard/cac.c:8:
/home/anthony/git/qemu/qemu-common.h:63: error: redefinition of ‘struct 
iovec’

make[1]: *** [cac.o] Error 1
make: *** [subdir-libcacard] Error 2

This is building from a separate directory. Let me know if you can't 
reproduce.


Regards,

Anthony Liguori


v23->v24 changes:
  * libcacard:
   = changed patches: (that need re-review)
* 6 - libcacard: initial commit
* 7 - libcacard: add vscclient
* 5 - ccid: add passthru card device
   * drop "libcacard add passthru" patch, not ready, not used.
   * remove unrequired includes
   * use stderr in vscclient for printing errors
   * cosmetic fixes

v22->v23 changes:
  * libcacard
   * configure fixes: (reported by Stefan Hajnoczi)
* test a = b, not a == b (second isn't portable)
* quote $source_path in case it contains spaces
 - this doesn't really help since there are many other places
   that need similar fixes, not introduced by this patch.

v21->v22 changes:
  * libcacard:
   * fix configure to not link libcacard if nss not found
  (reported by Stefan Hajnoczi)
   * fix vscclient linkage with simpletrace backend
  (reported by Stefan Hajnoczi)
   * card_7816.c: add missing break in ERROR_DATA_NOT_FOUND
  (reported by William van de Velde)

v20->v21 changes:
  * all: cosmetics
  * libcacard, ccid-card-passthru:
   * use qemu-{malloc,free} and qemu-thread, error_report
  * libcacard:
   * split to multiple patches

v19->v20 changes:
  * checkpatch.pl. Here are the remaining errors with explanation:
   * ignored 5 macro errors of the type
"ERROR: Macros with complex values should be enclosed in parenthesis"
because fixing them breaks current code, if it really bothers someone
I can fix it.
* four of them are in libcacard/card_7816t.h:
/* give the subfields a unified look */
..
#define a_cla a_header->ah_cla /* class */
#define a_ins a_header->ah_ins /* instruction */
#define a_p1 a_header->ah_p1   /* parameter 1 */
#define a_p2 a_header->ah_p2   /* parameter 2 */
* and the fifth:
#4946: FILE: libcacard/vcardt.h:31:
+#define VCARD_ATR_PREFIX(size) 0x3b, 0x66+(size), 0x00, 0xff, \
+   'V', 'C', 'A', 'R', 'D', '_'
   * Ignored this warning since I couldn't figure it out, and it's a test
file:
WARNING: externs should be avoided in .c files
#2343: FILE: libcacard/link_test.c:7:
+VCardStatus cac_card_init(const char *flags, VCard *card,

v18-v19 changes:
  * more merges, down to a single digit number of patches.
  * drop enumeration property, use string.
  * rebased (trivial)

v17-v18 changes:
  * merge vscard_common.h patches.
  * actually provide a tree to pull.

v16-v17 changes:
  * merged all the "v15->v16" patches
  * merged some more wherever it was easy (all same file commits).
  * added signed off by to first four patches
  * ccid.h: added copyright, removed underscore in defines, and replaced
  non C89 comments

v15-v16 changes:
  * split vscard_common introducing patch for ease of review
  * sum of commit logs for the v15-v16 commits: (whitespace fixes
 removed for space, see original commit messages in later patches)
   * usb-ccid:
* fix abort on client answer after card remove
* enable migration
* remove side affect code from asserts
* return consistent self-powered state
* mask out reserved bits in ccid_set_parameters
* add missing abRFU in SetParameters (no affect on linux guest)
   * vscard_common.h protocol change:
* VSCMsgInit capabilities and magic
* removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
* added Flush and FlushComplete, remove Reconnect.
* define VSCARD_MAGIC
* added error code VSC_SUCCESS.
   * ccid-card-passthru
* return correct size
* return error instead of assert if client sent too large ATR
* don't assert if client sent too large a size, but add asserts for indices 
to buffer
* reset vscard_in indices on chardev disconnect
* handle init from client
* error if no chardev supplied
* use ntoh, hton
* eradicate reader_id_t
* remove Reconnect usage (removed from VSCARD protocol)
* send VSC_SUCCESS on card insert/remove and reader add/remove
   * ccid-card-emulated
* fix error reporting in initfn

v14-v15 changes:
  * add patch with --enable-smartcard and --disable-

Re: [Qemu-devel] Re: [PATCH v2] qemu-img: Initial progress printing support

2011-04-01 Thread Jes Sorensen
On 03/31/11 13:49, Stefan Hajnoczi wrote:
> On Thu, Mar 31, 2011 at 12:38 PM, Kevin Wolf  wrote:
>> Am 31.03.2011 13:15, schrieb Jes Sorensen:
>>> On 03/31/11 12:38, Kevin Wolf wrote:
>>> I have been a little reluctant to do this because it will break the ABI
>>> for tools running qemu-img from a GUI etc.
>>
>> That's the reason for the "from a terminal" part. If we check for
>> isatty(), we should handle these cases just fine.
> 
> Yes, I think checking for a tty is enough precaution and allows users
> to get the benefit of the progress bar.  TBH I'd probably forget to
> add -p half the time :).

Ok, this is fine with me - however how do you suggest we offer the
option to disable it on the command line, an additional flag?

Jes



[Qemu-devel] [PATCH 09/10] target-arm: Don't leak TCG temp for UNDEFs in Neon load/store space

2011-04-01 Thread Peter Maydell
Move the allocation and freeing of the TCG temp used for the address for
Neon load/store instructions so that we don't allocate the temporary
until we've done enough decoding to know that the instruction is not
an UNDEF pattern; this avoids leaking the TCG temp in these cases.

Signed-off-by: Peter Maydell 
---
 target-arm/translate.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index e79ea03..527e260 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -3810,7 +3810,6 @@ static int disas_neon_ls_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 rn = (insn >> 16) & 0xf;
 rm = insn & 0xf;
 load = (insn & (1 << 21)) != 0;
-addr = tcg_temp_new_i32();
 if ((insn & (1 << 23)) == 0) {
 /* Load store all elements.  */
 op = (insn >> 8) & 0xf;
@@ -3822,6 +3821,7 @@ static int disas_neon_ls_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 spacing = neon_ls_element_type[op].spacing;
 if (size == 3 && (interleave | spacing) != 1)
 return 1;
+addr = tcg_temp_new_i32();
 load_reg_var(s, addr, rn);
 stride = (1 << size) * interleave;
 for (reg = 0; reg < nregs; reg++) {
@@ -3907,6 +3907,7 @@ static int disas_neon_ls_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 }
 rd += spacing;
 }
+tcg_temp_free_i32(addr);
 stride = nregs * 8;
 } else {
 size = (insn >> 10) & 3;
@@ -3932,6 +3933,7 @@ static int disas_neon_ls_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 if (nregs == 3 && a == 1) {
 return 1;
 }
+addr = tcg_temp_new_i32();
 load_reg_var(s, addr, rn);
 if (nregs == 1) {
 /* VLD1 to all lanes: bit 5 indicates how many Dregs to write 
*/
@@ -3955,6 +3957,7 @@ static int disas_neon_ls_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 rd += stride;
 }
 }
+tcg_temp_free_i32(addr);
 stride = (1 << size) * nregs;
 } else {
 /* Single element.  */
@@ -3976,6 +3979,7 @@ static int disas_neon_ls_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 abort();
 }
 nregs = ((insn >> 8) & 3) + 1;
+addr = tcg_temp_new_i32();
 load_reg_var(s, addr, rn);
 for (reg = 0; reg < nregs; reg++) {
 if (load) {
@@ -4017,10 +4021,10 @@ static int disas_neon_ls_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 rd += stride;
 tcg_gen_addi_i32(addr, addr, 1 << size);
 }
+tcg_temp_free_i32(addr);
 stride = nregs * (1 << size);
 }
 }
-tcg_temp_free_i32(addr);
 if (rm != 15) {
 TCGv base;
 
-- 
1.7.1




[Qemu-devel] [PATCH 02/10] target-arm/neon_helper.c: Use make_float32/float32_val macros

2011-04-01 Thread Peter Maydell
Use the softfloat make_float32 and float32_val macros to convert between
softfloat's float32 type and raw uint32_t types, rather than private
conversion functions.

Signed-off-by: Peter Maydell 
Reviewed-by: Nathan Froyd 
---
 target-arm/neon_helper.c |   56 ++
 1 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 97bc1e6..4039036 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -20,29 +20,6 @@
 
 #define NFS (&env->vfp.standard_fp_status)
 
-/* Helper routines to perform bitwise copies between float and int.  */
-static inline float32 vfp_itos(uint32_t i)
-{
-union {
-uint32_t i;
-float32 s;
-} v;
-
-v.i = i;
-return v.s;
-}
-
-static inline uint32_t vfp_stoi(float32 s)
-{
-union {
-uint32_t i;
-float32 s;
-} v;
-
-v.s = s;
-return v.i;
-}
-
 #define NEON_TYPE1(name, type) \
 typedef struct \
 { \
@@ -1795,50 +1772,51 @@ uint32_t HELPER(neon_qneg_s32)(CPUState *env, uint32_t 
x)
 /* NEON Float helpers.  */
 uint32_t HELPER(neon_min_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-float32 f0 = vfp_itos(a);
-float32 f1 = vfp_itos(b);
+float32 f0 = make_float32(a);
+float32 f1 = make_float32(b);
 return (float32_compare_quiet(f0, f1, NFS) == -1) ? a : b;
 }
 
 uint32_t HELPER(neon_max_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-float32 f0 = vfp_itos(a);
-float32 f1 = vfp_itos(b);
+float32 f0 = make_float32(a);
+float32 f1 = make_float32(b);
 return (float32_compare_quiet(f0, f1, NFS) == 1) ? a : b;
 }
 
 uint32_t HELPER(neon_abd_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-float32 f0 = vfp_itos(a);
-float32 f1 = vfp_itos(b);
-return vfp_stoi((float32_compare_quiet(f0, f1, NFS) == 1)
+float32 f0 = make_float32(a);
+float32 f1 = make_float32(b);
+return float32_val((float32_compare_quiet(f0, f1, NFS) == 1)
 ? float32_sub(f0, f1, NFS)
 : float32_sub(f1, f0, NFS));
 }
 
 uint32_t HELPER(neon_add_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-return vfp_stoi(float32_add(vfp_itos(a), vfp_itos(b), NFS));
+return float32_val(float32_add(make_float32(a), make_float32(b), NFS));
 }
 
 uint32_t HELPER(neon_sub_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-return vfp_stoi(float32_sub(vfp_itos(a), vfp_itos(b), NFS));
+return float32_val(float32_sub(make_float32(a), make_float32(b), NFS));
 }
 
 uint32_t HELPER(neon_mul_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-return vfp_stoi(float32_mul(vfp_itos(a), vfp_itos(b), NFS));
+return float32_val(float32_mul(make_float32(a), make_float32(b), NFS));
 }
 
 /* Floating point comparisons produce an integer result.  */
 #define NEON_VOP_FCMP(name, cmp) \
 uint32_t HELPER(neon_##name)(CPUState *env, uint32_t a, uint32_t b) \
 { \
-if (float32_compare_quiet(vfp_itos(a), vfp_itos(b), NFS) cmp 0) \
+if (float32_compare_quiet(make_float32(a), make_float32(b), NFS) cmp 0) { \
 return ~0; \
-else \
+} else { \
 return 0; \
+} \
 }
 
 NEON_VOP_FCMP(ceq_f32, ==)
@@ -1847,15 +1825,15 @@ NEON_VOP_FCMP(cgt_f32, >)
 
 uint32_t HELPER(neon_acge_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-float32 f0 = float32_abs(vfp_itos(a));
-float32 f1 = float32_abs(vfp_itos(b));
+float32 f0 = float32_abs(make_float32(a));
+float32 f1 = float32_abs(make_float32(b));
 return (float32_compare_quiet(f0, f1,NFS) >= 0) ? ~0 : 0;
 }
 
 uint32_t HELPER(neon_acgt_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-float32 f0 = float32_abs(vfp_itos(a));
-float32 f1 = float32_abs(vfp_itos(b));
+float32 f0 = float32_abs(make_float32(a));
+float32 f1 = float32_abs(make_float32(b));
 return (float32_compare_quiet(f0, f1, NFS) > 0) ? ~0 : 0;
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH 06/10] softfloat: Add float*_min() and float*_max() functions

2011-04-01 Thread Peter Maydell
Add min and max operations to softfloat. This allows us to implement
propagation of NaNs and handling of negative zero correctly (unlike
the approach of having target helper routines return one of the operands
based on the result of a comparison op).

Signed-off-by: Peter Maydell 
---
 fpu/softfloat.c |   49 +
 fpu/softfloat.h |4 
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 08e4ae0..03fb948 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -6057,6 +6057,55 @@ int float128_compare_quiet( float128 a, float128 b 
STATUS_PARAM )
 return float128_compare_internal(a, b, 1 STATUS_VAR);
 }
 
+/* min() and max() functions. These can't be implemented as
+ * 'compare and pick one input' because that would mishandle
+ * NaNs and +0 vs -0.
+ */
+#define MINMAX(s, nan_exp)  \
+INLINE float ## s float ## s ## _minmax(float ## s a, float ## s b, \
+int ismin STATUS_PARAM )\
+{   \
+flag aSign, bSign;  \
+uint ## s ## _t av, bv; \
+a = float ## s ## _squash_input_denormal(a STATUS_VAR); \
+b = float ## s ## _squash_input_denormal(b STATUS_VAR); \
+if (float ## s ## _is_any_nan(a) || \
+float ## s ## _is_any_nan(b)) { \
+return propagateFloat ## s ## NaN(a, b STATUS_VAR); \
+}   \
+aSign = extractFloat ## s ## Sign(a);   \
+bSign = extractFloat ## s ## Sign(b);   \
+av = float ## s ## _val(a); \
+bv = float ## s ## _val(b); \
+if (aSign != bSign) {   \
+if (ismin) {\
+return aSign ? a : b;   \
+} else {\
+return aSign ? b : a;   \
+}   \
+} else {\
+if (ismin) {\
+return (aSign ^ (av < bv)) ? a : b; \
+} else {\
+return (aSign ^ (av < bv)) ? b : a; \
+}   \
+}   \
+}   \
+\
+float ## s float ## s ## _min(float ## s a, float ## s b STATUS_PARAM)  \
+{   \
+return float ## s ## _minmax(a, b, 1 STATUS_VAR);   \
+}   \
+\
+float ## s float ## s ## _max(float ## s a, float ## s b STATUS_PARAM)  \
+{   \
+return float ## s ## _minmax(a, b, 0 STATUS_VAR);   \
+}
+
+MINMAX(32, 0xff)
+MINMAX(64, 0x7ff)
+
+
 /* Multiply A by 2 raised to the power N.  */
 float32 float32_scalbn( float32 a, int n STATUS_PARAM )
 {
diff --git a/fpu/softfloat.h b/fpu/softfloat.h
index 5d05fa5..90f4250 100644
--- a/fpu/softfloat.h
+++ b/fpu/softfloat.h
@@ -324,6 +324,8 @@ int float32_le_quiet( float32, float32 STATUS_PARAM );
 int float32_lt_quiet( float32, float32 STATUS_PARAM );
 int float32_compare( float32, float32 STATUS_PARAM );
 int float32_compare_quiet( float32, float32 STATUS_PARAM );
+float32 float32_min(float32, float32 STATUS_PARAM);
+float32 float32_max(float32, float32 STATUS_PARAM);
 int float32_is_quiet_nan( float32 );
 int float32_is_signaling_nan( float32 );
 float32 float32_maybe_silence_nan( float32 );
@@ -436,6 +438,8 @@ int float64_le_quiet( float64, float64 STATUS_PARAM );
 int float64_lt_quiet( float64, float64 STATUS_PARAM );
 int float64_compare( float64, float64 STATUS_PARAM );
 int float64_compare_quiet( float64, float64 STATUS_PARAM );
+float64 float64_min(float64, float64 STATUS_PARAM);
+float64 float64_max(float64, float64 STATUS_PARAM);
 int float64_is_quiet_nan( float64 a );
 int float64_is_signaling_nan( float64 );
 float64 float64_m

[Qemu-devel] [PATCH 04/10] target-arm: Fix VCLE.F32 #0, VCLT.F32 #0 NaN handling

2011-04-01 Thread Peter Maydell
Implementing the floating-point versions of VCLE #0 and VCLT #0 by
doing a GT comparison and inverting the result gives the wrong
result if the input is a NaN. Implement as a GT comparison with the
operands swapped instead.

Signed-off-by: Peter Maydell 
---
 target-arm/translate.c |   18 --
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index cf2440e..6ce8b7a 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -5641,25 +5641,31 @@ static int disas_neon_data_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 gen_neon_rsb(size, tmp, tmp2);
 tcg_temp_free(tmp2);
 break;
-case 24: case 27: /* Float VCGT #0, Float VCLE #0 */
+case 24: /* Float VCGT #0 */
 tmp2 = tcg_const_i32(0);
 gen_helper_neon_cgt_f32(tmp,  cpu_env, tmp, tmp2);
 tcg_temp_free(tmp2);
-if (op == 27)
-tcg_gen_not_i32(tmp, tmp);
 break;
-case 25: case 28: /* Float VCGE #0, Float VCLT #0 */
+case 25: /* Float VCGE #0 */
 tmp2 = tcg_const_i32(0);
 gen_helper_neon_cge_f32(tmp,  cpu_env, tmp, tmp2);
 tcg_temp_free(tmp2);
-if (op == 28)
-tcg_gen_not_i32(tmp, tmp);
 break;
 case 26: /* Float VCEQ #0 */
 tmp2 = tcg_const_i32(0);
 gen_helper_neon_ceq_f32(tmp,  cpu_env, tmp, tmp2);
 tcg_temp_free(tmp2);
 break;
+case 27: /* Float VCLE #0 */
+tmp2 = tcg_const_i32(0);
+gen_helper_neon_cge_f32(tmp,  cpu_env, tmp2, tmp);
+tcg_temp_free(tmp2);
+break;
+case 28: /* Float VCLT #0 */
+tmp2 = tcg_const_i32(0);
+gen_helper_neon_cgt_f32(tmp,  cpu_env, tmp2, tmp);
+tcg_temp_free(tmp2);
+break;
 case 30: /* Float VABS */
 gen_vfp_abs(0);
 break;
-- 
1.7.1




[Qemu-devel] [PATCH 00/10] [PULL] ARM Neon fixes

2011-04-01 Thread Peter Maydell
This is a pull request for a set of patches fixing various minor Neon
problems for ARM targets, which I sent to the list a couple of weeks ago.
A few of them got reviewed-by Nathan, one had some minor discussion which
didn't amount to a request for any change, the rest had no comments.

The softfloat patch includes a trivial change since the original
posted version: the MINMAX macro now has a "uint ## s ## _t" rather than
a "bits ## s" since the bits32/bits64 types were removed in commit bb98fe4.

The following changes since commit a5086f95421e43c7b9e1b28a111aae0be4848117:

  lm32: use lookup table for opcodes (2011-03-31 08:54:05 +0200)

are available in the git repository at:
  git://git.linaro.org/people/pmaydell/qemu-arm.git for-upstream

Peter Maydell (10):
  target-arm: Make Neon helper routines use correct FP status
  target-arm/neon_helper.c: Use make_float32/float32_val macros
  target-arm: Return right result for Neon comparison with NaNs
  target-arm: Fix VCLE.F32 #0, VCLT.F32 #0 NaN handling
  target-arm: Correct ABD's handling of negative zeroes
  softfloat: Add float*_min() and float*_max() functions
  target-arm: Use new softfloat min/max functions for VMAX, VMIN
  target-arm: Fix VLD of single element to all lanes
  target-arm: Don't leak TCG temp for UNDEFs in Neon load/store space
  target-arm/helper.c: For float-int conversion helpers pass ints as ints

 fpu/softfloat.c  |   49 +++
 fpu/softfloat.h  |4 +
 target-arm/helper.c  |  155 -
 target-arm/helpers.h |   82 
 target-arm/neon_helper.c |  103 --
 target-arm/translate.c   |  152 +
 6 files changed, 289 insertions(+), 256 deletions(-)



[Qemu-devel] [PATCH 07/10] target-arm: Use new softfloat min/max functions for VMAX, VMIN

2011-04-01 Thread Peter Maydell
Use the new softfloat min/max functions to implement the Neon VMAX
and VMIN instructions. This allows us to get the right behaviour
for NaN and negative zero.

Signed-off-by: Peter Maydell 
---
 target-arm/neon_helper.c |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 1905545..19784ab 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -1772,16 +1772,12 @@ uint32_t HELPER(neon_qneg_s32)(CPUState *env, uint32_t 
x)
 /* NEON Float helpers.  */
 uint32_t HELPER(neon_min_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-float32 f0 = make_float32(a);
-float32 f1 = make_float32(b);
-return (float32_compare_quiet(f0, f1, NFS) == -1) ? a : b;
+return float32_val(float32_min(make_float32(a), make_float32(b), NFS));
 }
 
 uint32_t HELPER(neon_max_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
-float32 f0 = make_float32(a);
-float32 f1 = make_float32(b);
-return (float32_compare_quiet(f0, f1, NFS) == 1) ? a : b;
+return float32_val(float32_max(make_float32(a), make_float32(b), NFS));
 }
 
 uint32_t HELPER(neon_abd_f32)(CPUState *env, uint32_t a, uint32_t b)
-- 
1.7.1




[Qemu-devel] [PATCH 10/10] target-arm/helper.c: For float-int conversion helpers pass ints as ints

2011-04-01 Thread Peter Maydell
Correct the argument and return types for the float<->int conversion helper
functions so that integer arguments and return values are declared as
uint32_t/uint64_t, not float32/float64. This allows us to remove the
hand-rolled functions which were doing bitwise copies between the types
via unions.

Signed-off-by: Peter Maydell 
Reviewed-by: Nathan Froyd 
---
 target-arm/helper.c  |  155 ++
 target-arm/helpers.h |   60 ++--
 2 files changed, 85 insertions(+), 130 deletions(-)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index 78f3d39..6788a4c 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -2486,135 +2486,90 @@ DO_VFP_cmp(s, float32)
 DO_VFP_cmp(d, float64)
 #undef DO_VFP_cmp
 
-/* Helper routines to perform bitwise copies between float and int.  */
-static inline float32 vfp_itos(uint32_t i)
-{
-union {
-uint32_t i;
-float32 s;
-} v;
-
-v.i = i;
-return v.s;
-}
-
-static inline uint32_t vfp_stoi(float32 s)
-{
-union {
-uint32_t i;
-float32 s;
-} v;
-
-v.s = s;
-return v.i;
-}
-
-static inline float64 vfp_itod(uint64_t i)
-{
-union {
-uint64_t i;
-float64 d;
-} v;
-
-v.i = i;
-return v.d;
-}
-
-static inline uint64_t vfp_dtoi(float64 d)
-{
-union {
-uint64_t i;
-float64 d;
-} v;
-
-v.d = d;
-return v.i;
-}
-
 /* Integer to float conversion.  */
-float32 VFP_HELPER(uito, s)(float32 x, CPUState *env)
+float32 VFP_HELPER(uito, s)(uint32_t x, CPUState *env)
 {
-return uint32_to_float32(vfp_stoi(x), &env->vfp.fp_status);
+return uint32_to_float32(x, &env->vfp.fp_status);
 }
 
-float64 VFP_HELPER(uito, d)(float32 x, CPUState *env)
+float64 VFP_HELPER(uito, d)(uint32_t x, CPUState *env)
 {
-return uint32_to_float64(vfp_stoi(x), &env->vfp.fp_status);
+return uint32_to_float64(x, &env->vfp.fp_status);
 }
 
-float32 VFP_HELPER(sito, s)(float32 x, CPUState *env)
+float32 VFP_HELPER(sito, s)(uint32_t x, CPUState *env)
 {
-return int32_to_float32(vfp_stoi(x), &env->vfp.fp_status);
+return int32_to_float32(x, &env->vfp.fp_status);
 }
 
-float64 VFP_HELPER(sito, d)(float32 x, CPUState *env)
+float64 VFP_HELPER(sito, d)(uint32_t x, CPUState *env)
 {
-return int32_to_float64(vfp_stoi(x), &env->vfp.fp_status);
+return int32_to_float64(x, &env->vfp.fp_status);
 }
 
 /* Float to integer conversion.  */
-float32 VFP_HELPER(toui, s)(float32 x, CPUState *env)
+uint32_t VFP_HELPER(toui, s)(float32 x, CPUState *env)
 {
 if (float32_is_any_nan(x)) {
-return float32_zero;
+return 0;
 }
-return vfp_itos(float32_to_uint32(x, &env->vfp.fp_status));
+return float32_to_uint32(x, &env->vfp.fp_status);
 }
 
-float32 VFP_HELPER(toui, d)(float64 x, CPUState *env)
+uint32_t VFP_HELPER(toui, d)(float64 x, CPUState *env)
 {
 if (float64_is_any_nan(x)) {
-return float32_zero;
+return 0;
 }
-return vfp_itos(float64_to_uint32(x, &env->vfp.fp_status));
+return float64_to_uint32(x, &env->vfp.fp_status);
 }
 
-float32 VFP_HELPER(tosi, s)(float32 x, CPUState *env)
+uint32_t VFP_HELPER(tosi, s)(float32 x, CPUState *env)
 {
 if (float32_is_any_nan(x)) {
-return float32_zero;
+return 0;
 }
-return vfp_itos(float32_to_int32(x, &env->vfp.fp_status));
+return float32_to_int32(x, &env->vfp.fp_status);
 }
 
-float32 VFP_HELPER(tosi, d)(float64 x, CPUState *env)
+uint32_t VFP_HELPER(tosi, d)(float64 x, CPUState *env)
 {
 if (float64_is_any_nan(x)) {
-return float32_zero;
+return 0;
 }
-return vfp_itos(float64_to_int32(x, &env->vfp.fp_status));
+return float64_to_int32(x, &env->vfp.fp_status);
 }
 
-float32 VFP_HELPER(touiz, s)(float32 x, CPUState *env)
+uint32_t VFP_HELPER(touiz, s)(float32 x, CPUState *env)
 {
 if (float32_is_any_nan(x)) {
-return float32_zero;
+return 0;
 }
-return vfp_itos(float32_to_uint32_round_to_zero(x, &env->vfp.fp_status));
+return float32_to_uint32_round_to_zero(x, &env->vfp.fp_status);
 }
 
-float32 VFP_HELPER(touiz, d)(float64 x, CPUState *env)
+uint32_t VFP_HELPER(touiz, d)(float64 x, CPUState *env)
 {
 if (float64_is_any_nan(x)) {
-return float32_zero;
+return 0;
 }
-return vfp_itos(float64_to_uint32_round_to_zero(x, &env->vfp.fp_status));
+return float64_to_uint32_round_to_zero(x, &env->vfp.fp_status);
 }
 
-float32 VFP_HELPER(tosiz, s)(float32 x, CPUState *env)
+uint32_t VFP_HELPER(tosiz, s)(float32 x, CPUState *env)
 {
 if (float32_is_any_nan(x)) {
-return float32_zero;
+return 0;
 }
-return vfp_itos(float32_to_int32_round_to_zero(x, &env->vfp.fp_status));
+return float32_to_int32_round_to_zero(x, &env->vfp.fp_status);
 }
 
-float32 VFP_HELPER(tosiz, d)(float64 x, CPUState *env)
+uint32_t VFP_HELPER(tosiz, d)(float64 x, CPUState *env)
 {
 if (float64_is_any_na

[Qemu-devel] [PATCH 01/10] target-arm: Make Neon helper routines use correct FP status

2011-04-01 Thread Peter Maydell
Make the Neon helper routines use the correct FP status from
the CPUEnv rather than using a dummy static one. This means
they will correctly handle denormals and NaNs and will set
FPSCR exception bits properly.

Signed-off-by: Peter Maydell 
---
 target-arm/helpers.h |   22 +++---
 target-arm/neon_helper.c |   21 ++---
 target-arm/translate.c   |   42 ++
 3 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/target-arm/helpers.h b/target-arm/helpers.h
index bd6977c..e2260b6 100644
--- a/target-arm/helpers.h
+++ b/target-arm/helpers.h
@@ -350,17 +350,17 @@ DEF_HELPER_2(neon_qneg_s8, i32, env, i32)
 DEF_HELPER_2(neon_qneg_s16, i32, env, i32)
 DEF_HELPER_2(neon_qneg_s32, i32, env, i32)
 
-DEF_HELPER_2(neon_min_f32, i32, i32, i32)
-DEF_HELPER_2(neon_max_f32, i32, i32, i32)
-DEF_HELPER_2(neon_abd_f32, i32, i32, i32)
-DEF_HELPER_2(neon_add_f32, i32, i32, i32)
-DEF_HELPER_2(neon_sub_f32, i32, i32, i32)
-DEF_HELPER_2(neon_mul_f32, i32, i32, i32)
-DEF_HELPER_2(neon_ceq_f32, i32, i32, i32)
-DEF_HELPER_2(neon_cge_f32, i32, i32, i32)
-DEF_HELPER_2(neon_cgt_f32, i32, i32, i32)
-DEF_HELPER_2(neon_acge_f32, i32, i32, i32)
-DEF_HELPER_2(neon_acgt_f32, i32, i32, i32)
+DEF_HELPER_3(neon_min_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_max_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_abd_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_add_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_sub_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_mul_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_ceq_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_cge_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_cgt_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_acge_f32, i32, env, i32, i32)
+DEF_HELPER_3(neon_acgt_f32, i32, env, i32, i32)
 
 /* iwmmxt_helper.c */
 DEF_HELPER_2(iwmmxt_maddsq, i64, i64, i64)
diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 002a9c1..97bc1e6 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -18,8 +18,7 @@
 
 #define SET_QC() env->vfp.xregs[ARM_VFP_FPSCR] = CPSR_Q
 
-static float_status neon_float_status;
-#define NFS &neon_float_status
+#define NFS (&env->vfp.standard_fp_status)
 
 /* Helper routines to perform bitwise copies between float and int.  */
 static inline float32 vfp_itos(uint32_t i)
@@ -1794,21 +1793,21 @@ uint32_t HELPER(neon_qneg_s32)(CPUState *env, uint32_t 
x)
 }
 
 /* NEON Float helpers.  */
-uint32_t HELPER(neon_min_f32)(uint32_t a, uint32_t b)
+uint32_t HELPER(neon_min_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 float32 f0 = vfp_itos(a);
 float32 f1 = vfp_itos(b);
 return (float32_compare_quiet(f0, f1, NFS) == -1) ? a : b;
 }
 
-uint32_t HELPER(neon_max_f32)(uint32_t a, uint32_t b)
+uint32_t HELPER(neon_max_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 float32 f0 = vfp_itos(a);
 float32 f1 = vfp_itos(b);
 return (float32_compare_quiet(f0, f1, NFS) == 1) ? a : b;
 }
 
-uint32_t HELPER(neon_abd_f32)(uint32_t a, uint32_t b)
+uint32_t HELPER(neon_abd_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 float32 f0 = vfp_itos(a);
 float32 f1 = vfp_itos(b);
@@ -1817,24 +1816,24 @@ uint32_t HELPER(neon_abd_f32)(uint32_t a, uint32_t b)
 : float32_sub(f1, f0, NFS));
 }
 
-uint32_t HELPER(neon_add_f32)(uint32_t a, uint32_t b)
+uint32_t HELPER(neon_add_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 return vfp_stoi(float32_add(vfp_itos(a), vfp_itos(b), NFS));
 }
 
-uint32_t HELPER(neon_sub_f32)(uint32_t a, uint32_t b)
+uint32_t HELPER(neon_sub_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 return vfp_stoi(float32_sub(vfp_itos(a), vfp_itos(b), NFS));
 }
 
-uint32_t HELPER(neon_mul_f32)(uint32_t a, uint32_t b)
+uint32_t HELPER(neon_mul_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 return vfp_stoi(float32_mul(vfp_itos(a), vfp_itos(b), NFS));
 }
 
 /* Floating point comparisons produce an integer result.  */
 #define NEON_VOP_FCMP(name, cmp) \
-uint32_t HELPER(neon_##name)(uint32_t a, uint32_t b) \
+uint32_t HELPER(neon_##name)(CPUState *env, uint32_t a, uint32_t b) \
 { \
 if (float32_compare_quiet(vfp_itos(a), vfp_itos(b), NFS) cmp 0) \
 return ~0; \
@@ -1846,14 +1845,14 @@ NEON_VOP_FCMP(ceq_f32, ==)
 NEON_VOP_FCMP(cge_f32, >=)
 NEON_VOP_FCMP(cgt_f32, >)
 
-uint32_t HELPER(neon_acge_f32)(uint32_t a, uint32_t b)
+uint32_t HELPER(neon_acge_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 float32 f0 = float32_abs(vfp_itos(a));
 float32 f1 = float32_abs(vfp_itos(b));
 return (float32_compare_quiet(f0, f1,NFS) >= 0) ? ~0 : 0;
 }
 
-uint32_t HELPER(neon_acgt_f32)(uint32_t a, uint32_t b)
+uint32_t HELPER(neon_acgt_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 float32 f0 = float32_abs(vfp_itos(a));
 float32 f1 = float32_abs(vfp_itos(b));
diff --git a/target-arm/translate.c b/target-arm/translate.c
index f69912f..cf2440e 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -4519,56 +4519,56 @@ static int d

[Qemu-devel] [PATCH 05/10] target-arm: Correct ABD's handling of negative zeroes

2011-04-01 Thread Peter Maydell
Implement ABD by taking the absolute value of the difference
of the operands (as the ARM ARM specifies) rather than by
flipping the order of the operands to the subtract based
on the results of a comparison. The latter approch gives
the wrong answers for some edge cases like negative zero.

Signed-off-by: Peter Maydell 
---
 target-arm/neon_helper.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 8eb4cef..1905545 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -1788,9 +1788,7 @@ uint32_t HELPER(neon_abd_f32)(CPUState *env, uint32_t a, 
uint32_t b)
 {
 float32 f0 = make_float32(a);
 float32 f1 = make_float32(b);
-return float32_val((float32_compare_quiet(f0, f1, NFS) == 1)
-? float32_sub(f0, f1, NFS)
-: float32_sub(f1, f0, NFS));
+return float32_val(float32_abs(float32_sub(f0, f1, NFS)));
 }
 
 uint32_t HELPER(neon_add_f32)(CPUState *env, uint32_t a, uint32_t b)
-- 
1.7.1




[Qemu-devel] Re: [PATCH v7 0/4] piix_pci: optimize irq data path

2011-04-01 Thread Michael S. Tsirkin
On Fri, Apr 01, 2011 at 08:43:20PM +0900, Isaku Yamahata wrote:
> Here is v7 which are rebased to pci branch.
> 
> I tested this patch series as follows. please see the commit message
> for details.
> - 3/4 piix_pci: optimize set irq path
>   Run linux as guest with 4 e1000 emulated devices.
>   And confirmed that each PIRQ[A-D] are able to assert interrupts.
> - 4/4 piix_pci: load path clean up
>   Run linux as guest with one e1000 emulated device.
>   savevm/loadvm guest with runing ping -f in guest.
> 
> To be honest, the patch, "4/4 piix_pci: load path clean up", needs more
> extensive tests. For example live migration and stress test.
> But for now I don't have plan to further testing in near future. Sorry.
> So please feel free to pick or drop the last patch.

Applied, I will hit it with autotest.

> patch description:
> This patch series optimizes irq data path of piix_pci.
> So far piix3 tracks each pirq level and checks whether a given pic pins is
> asserted by seeing if each pirq is mapped into the pic pin.
> This is independent on irq routing, but data path is on slow path.
> 
> Given that irq routing is rarely changed and asserting pic pins is on
> data path, the path that asserts pic pins should be optimized and
> chainging irq routing should be on slow path.
> The new behavior with this patch series is to use bitmap which is addressed
> by pirq and pic pins with a given irq routing.
> When pirq is asserted, the bitmap is set and see if the pic pins is
> asserted by checking the bitmaps.
> When irq routing is changed, rebuild the bitmap and re-assert pic pins.
> 
> Changes v6 -> v7:
> - rebased to pci branch
> - added how to test to the commit message
> 
> Changes v5 -> v6:
> - fixed piix3_set_irq_pic()
> 
> Changes v4 -> v5:
> - typo
> 
> Changes v3 -> v4:
> - use pirq, pci_intx instead of irq_num in piix_pci.c
> - use symbolic constant PIC_NUM_PINS
> - introduced new patch 4/4 which cleans up a bit.
> 
> Changes v2 -> v3:
> - s/dummy_for_save_load_compat/pci_irq_levels_vmstate/g
> - move down unused member of pci_irq_levels_vmstate in the structure
>   for cache efficiency
> 
> Changes v1 -> v2:
> - addressed review comments.
> 
> Isaku Yamahata (4):
>   pci: add accessor function to get irq levels
>   piix_pci: eliminate PIIX3State::pci_irq_levels
>   piix_pci: optimize set irq path
>   piix_pci: load path clean up
> 
>  hw/pci.c  |7 +++
>  hw/pci.h  |1 +
>  hw/piix_pci.c |  129 
> ++---
>  3 files changed, 112 insertions(+), 25 deletions(-)



Re: [Qemu-devel] Re: [PATCH v2 3/3] raw-posix: Re-open host CD-ROM after media change

2011-04-01 Thread Stefan Hajnoczi
On Thu, Mar 31, 2011 at 11:05 AM, Kevin Wolf  wrote:
> The other thing is that I'm not sure if everything in raw-posix is
> prepared to deal with a -1 fd. At the very least, I think we'll get
> -EBADF errors instead of the expected -ENOMEDIUM.

Not all of block.c checks for !bdrv_is_inserted() so you are right, I
missed cases where we should return -ENOMEDIUM.

We have a similar scenario with floppy disks where fd_open() can
return leaving s->fd == -1.  I would like to unify these floppy and
CD-ROM open cases.

Stefan



Re: [Qemu-devel] Re: [PATCH v2] qemu-img: Initial progress printing support

2011-04-01 Thread Stefan Hajnoczi
On Fri, Apr 1, 2011 at 2:41 PM, Jes Sorensen  wrote:
> On 03/31/11 13:49, Stefan Hajnoczi wrote:
>> On Thu, Mar 31, 2011 at 12:38 PM, Kevin Wolf  wrote:
>>> Am 31.03.2011 13:15, schrieb Jes Sorensen:
 On 03/31/11 12:38, Kevin Wolf wrote:
 I have been a little reluctant to do this because it will break the ABI
 for tools running qemu-img from a GUI etc.
>>>
>>> That's the reason for the "from a terminal" part. If we check for
>>> isatty(), we should handle these cases just fine.
>>
>> Yes, I think checking for a tty is enough precaution and allows users
>> to get the benefit of the progress bar.  TBH I'd probably forget to
>> add -p half the time :).
>
> Ok, this is fine with me - however how do you suggest we offer the
> option to disable it on the command line, an additional flag?

That would be safest, good idea.

Stefan



[Qemu-devel] [PATCH 03/10] target-arm: Return right result for Neon comparison with NaNs

2011-04-01 Thread Peter Maydell
Fix the helper functions implementing the Neon floating point comparison
ops (VCGE, VCGT, VCEQ, VACGT, VACGE) to return the right answer when
one of the values being compared is a NaN.

Signed-off-by: Peter Maydell 
---
 target-arm/neon_helper.c |   28 ++--
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
index 4039036..8eb4cef 100644
--- a/target-arm/neon_helper.c
+++ b/target-arm/neon_helper.c
@@ -1809,32 +1809,40 @@ uint32_t HELPER(neon_mul_f32)(CPUState *env, uint32_t 
a, uint32_t b)
 }
 
 /* Floating point comparisons produce an integer result.  */
-#define NEON_VOP_FCMP(name, cmp) \
+#define NEON_VOP_FCMP(name, ok) \
 uint32_t HELPER(neon_##name)(CPUState *env, uint32_t a, uint32_t b) \
 { \
-if (float32_compare_quiet(make_float32(a), make_float32(b), NFS) cmp 0) { \
-return ~0; \
-} else { \
-return 0; \
+switch (float32_compare_quiet(make_float32(a), make_float32(b), NFS)) { \
+ok return ~0; \
+default: return 0; \
 } \
 }
 
-NEON_VOP_FCMP(ceq_f32, ==)
-NEON_VOP_FCMP(cge_f32, >=)
-NEON_VOP_FCMP(cgt_f32, >)
+NEON_VOP_FCMP(ceq_f32, case float_relation_equal:)
+NEON_VOP_FCMP(cge_f32, case float_relation_equal: case float_relation_greater:)
+NEON_VOP_FCMP(cgt_f32, case float_relation_greater:)
 
 uint32_t HELPER(neon_acge_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 float32 f0 = float32_abs(make_float32(a));
 float32 f1 = float32_abs(make_float32(b));
-return (float32_compare_quiet(f0, f1,NFS) >= 0) ? ~0 : 0;
+switch (float32_compare_quiet(f0, f1, NFS)) {
+case float_relation_equal:
+case float_relation_greater:
+return ~0;
+default:
+return 0;
+}
 }
 
 uint32_t HELPER(neon_acgt_f32)(CPUState *env, uint32_t a, uint32_t b)
 {
 float32 f0 = float32_abs(make_float32(a));
 float32 f1 = float32_abs(make_float32(b));
-return (float32_compare_quiet(f0, f1, NFS) > 0) ? ~0 : 0;
+if (float32_compare_quiet(f0, f1, NFS) == float_relation_greater) {
+return ~0;
+}
+return 0;
 }
 
 #define ELEM(V, N, SIZE) (((V) >> ((N) * (SIZE))) & ((1ull << (SIZE)) - 1))
-- 
1.7.1




[Qemu-devel] [PATCH 08/10] target-arm: Fix VLD of single element to all lanes

2011-04-01 Thread Peter Maydell
Fix several bugs in VLD of single element to all lanes:

The "single element to all lanes" form of VLD1 differs from those for
VLD2, VLD3 and VLD4 in that bit 5 indicates whether the loaded element
should be written to one or two Dregs (rather than being a register
stride). Handle this by special-casing VLD1 rather than trying to
have one loop which deals with both VLD1 and 2/3/4.

Handle VLD4.32 with 16 byte alignment specified, rather than UNDEFfing.

UNDEF for the invalid size and alignment combinations.

Signed-off-by: Peter Maydell 
---
 target-arm/translate.c |   84 +--
 1 files changed, 59 insertions(+), 25 deletions(-)

diff --git a/target-arm/translate.c b/target-arm/translate.c
index 6ce8b7a..e79ea03 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -2648,6 +2648,28 @@ static void gen_neon_dup_high16(TCGv var)
 tcg_temp_free_i32(tmp);
 }
 
+static TCGv gen_load_and_replicate(DisasContext *s, TCGv addr, int size)
+{
+/* Load a single Neon element and replicate into a 32 bit TCG reg */
+TCGv tmp;
+switch (size) {
+case 0:
+tmp = gen_ld8u(addr, IS_USER(s));
+gen_neon_dup_u8(tmp, 0);
+break;
+case 1:
+tmp = gen_ld16u(addr, IS_USER(s));
+gen_neon_dup_low16(tmp);
+break;
+case 2:
+tmp = gen_ld32(addr, IS_USER(s));
+break;
+default: /* Avoid compiler warnings.  */
+abort();
+}
+return tmp;
+}
+
 /* Disassemble a VFP instruction.  Returns nonzero if an error occured
(ie. an undefined instruction).  */
 static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
@@ -3890,36 +3912,48 @@ static int disas_neon_ls_insn(CPUState * env, 
DisasContext *s, uint32_t insn)
 size = (insn >> 10) & 3;
 if (size == 3) {
 /* Load single element to all lanes.  */
-if (!load)
+int a = (insn >> 4) & 1;
+if (!load) {
 return 1;
+}
 size = (insn >> 6) & 3;
 nregs = ((insn >> 8) & 3) + 1;
-stride = (insn & (1 << 5)) ? 2 : 1;
-load_reg_var(s, addr, rn);
-for (reg = 0; reg < nregs; reg++) {
-switch (size) {
-case 0:
-tmp = gen_ld8u(addr, IS_USER(s));
-gen_neon_dup_u8(tmp, 0);
-break;
-case 1:
-tmp = gen_ld16u(addr, IS_USER(s));
-gen_neon_dup_low16(tmp);
-break;
-case 2:
-tmp = gen_ld32(addr, IS_USER(s));
-break;
-case 3:
+
+if (size == 3) {
+if (nregs != 4 || a == 0) {
 return 1;
-default: /* Avoid compiler warnings.  */
-abort();
 }
-tcg_gen_addi_i32(addr, addr, 1 << size);
-tmp2 = tcg_temp_new_i32();
-tcg_gen_mov_i32(tmp2, tmp);
-neon_store_reg(rd, 0, tmp2);
-neon_store_reg(rd, 1, tmp);
-rd += stride;
+/* For VLD4 size==3 a == 1 means 32 bits at 16 byte alignment 
*/
+size = 2;
+}
+if (nregs == 1 && a == 1 && size == 0) {
+return 1;
+}
+if (nregs == 3 && a == 1) {
+return 1;
+}
+load_reg_var(s, addr, rn);
+if (nregs == 1) {
+/* VLD1 to all lanes: bit 5 indicates how many Dregs to write 
*/
+tmp = gen_load_and_replicate(s, addr, size);
+tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 0));
+tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 1));
+if (insn & (1 << 5)) {
+tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd + 1, 0));
+tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd + 1, 1));
+}
+tcg_temp_free_i32(tmp);
+} else {
+/* VLD2/3/4 to all lanes: bit 5 indicates register stride */
+stride = (insn & (1 << 5)) ? 2 : 1;
+for (reg = 0; reg < nregs; reg++) {
+tmp = gen_load_and_replicate(s, addr, size);
+tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 0));
+tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 1));
+tcg_temp_free_i32(tmp);
+tcg_gen_addi_i32(addr, addr, 1 << size);
+rd += stride;
+}
 }
 stride = (1 << size) * nregs;
 } else {
-- 
1.7.1




[Qemu-devel] [PATCH v25 02/10] qemu-thread.h: include inttypes.h

2011-04-01 Thread Alon Levy
qemu-thread.h relies on uint64_t being defined, but doesn't include
inttypes.h explicitly. This makes it easier to use it from vscclient (part
of libcacard).
---
 qemu-thread.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/qemu-thread.h b/qemu-thread.h
index edc7ab6..0a73d50 100644
--- a/qemu-thread.h
+++ b/qemu-thread.h
@@ -1,6 +1,8 @@
 #ifndef __QEMU_THREAD_H
 #define __QEMU_THREAD_H 1
 
+#include 
+
 typedef struct QemuMutex QemuMutex;
 typedef struct QemuCond QemuCond;
 typedef struct QemuThread QemuThread;
-- 
1.7.4.2




[Qemu-devel] [PATCH v25 04/10] introduce libcacard/vscard_common.h

2011-04-01 Thread Alon Levy
---

Signed-off-by: Alon Levy 

v20->v21 changes: (Jes Sorensen review)
 * license set to 2+
 * long comment fixes, remove empty line at eof.
 * add reference to COPYING

v19->v20 changes:
 * checkpatch.pl

v15->v16 changes:

Protocol change:
 * VSCMsgInit capabilities and magic
 * removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
 * adaded Flush and FlushComplete, remove Reconnect.
 * define VSCARD_MAGIC
 * added error code VSC_SUCCESS.

Fixes:
 * update VSCMsgInit comment
 * fix message type enum
 * remove underscore from wrapping define
 * update copyright
 * updated comments.
 * Header comment updated
 * remove C++ style comment
 * fix comment for VSCMsgError
 * give names to enums in typedefs
---
 libcacard/vscard_common.h |  178 +
 1 files changed, 178 insertions(+), 0 deletions(-)
 create mode 100644 libcacard/vscard_common.h

diff --git a/libcacard/vscard_common.h b/libcacard/vscard_common.h
new file mode 100644
index 000..bebd52d
--- /dev/null
+++ b/libcacard/vscard_common.h
@@ -0,0 +1,178 @@
+/* Virtual Smart Card protocol definition
+ *
+ * This protocol is between a host using virtual smart card readers,
+ * and a client providing the smart cards, perhaps by emulating them or by
+ * access to real cards.
+ *
+ * Definitions for this protocol:
+ *  Host   - user of the card
+ *  Client - owner of the card
+ *
+ * The current implementation passes the raw APDU's from 7816 and additionally
+ * contains messages to setup and teardown readers, handle insertion and
+ * removal of cards, negotiate the protocol via capabilities and provide
+ * for error responses.
+ *
+ * Copyright (c) 2011 Red Hat.
+ *
+ * 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 VSCARD_COMMON_H
+#define VSCARD_COMMON_H
+
+#include 
+
+#define VERSION_MAJOR_BITS 11
+#define VERSION_MIDDLE_BITS 11
+#define VERSION_MINOR_BITS 10
+
+#define MAKE_VERSION(major, middle, minor) \
+ ((major  << (VERSION_MINOR_BITS + VERSION_MIDDLE_BITS)) \
+  | (middle <<  VERSION_MINOR_BITS) \
+  | (minor))
+
+/*
+ * IMPORTANT NOTE on VERSION
+ *
+ * The version below MUST be changed whenever a change in this file is made.
+ *
+ * The last digit, the minor, is for bug fix changes only.
+ *
+ * The middle digit is for backward / forward compatible changes, updates
+ * to the existing messages, addition of fields.
+ *
+ * The major digit is for a breaking change of protocol, presumably
+ * something that cannot be accomodated with the existing protocol.
+ */
+
+#define VSCARD_VERSION MAKE_VERSION(0, 0, 2)
+
+typedef enum VSCMsgType {
+VSC_Init = 1,
+VSC_Error,
+VSC_ReaderAdd,
+VSC_ReaderRemove,
+VSC_ATR,
+VSC_CardRemove,
+VSC_APDU,
+VSC_Flush,
+VSC_FlushComplete
+} VSCMsgType;
+
+typedef enum VSCErrorCode {
+VSC_SUCCESS = 0,
+VSC_GENERAL_ERROR = 1,
+VSC_CANNOT_ADD_MORE_READERS,
+VSC_CARD_ALREAY_INSERTED,
+} VSCErrorCode;
+
+#define VSCARD_UNDEFINED_READER_ID  0x
+#define VSCARD_MINIMAL_READER_ID0
+
+#define VSCARD_MAGIC (*(uint32_t *)"VSCD")
+
+/*
+ * Header
+ * Each message starts with the header.
+ * type - message type
+ * reader_id - used by messages that are reader specific
+ * length - length of payload (not including header, i.e. zero for
+ *  messages containing empty payloads)
+ */
+typedef struct VSCMsgHeader {
+uint32_t   type;
+uint32_t   reader_id;
+uint32_t   length;
+uint8_tdata[0];
+} VSCMsgHeader;
+
+/*
+ * VSCMsgInit   Client <-> Host
+ * Client sends it on connection, with its own capabilities.
+ * Host replies with VSCMsgInit filling in its capabilities.
+ *
+ * It is not meant to be used for negotiation, i.e. sending more then
+ * once from any side, but could be used for that in the future.
+ */
+typedef struct VSCMsgInit {
+uint32_t   magic;
+uint32_t   version;
+uint32_t   capabilities[1]; /* receiver must check length,
+   array may grow in the future*/
+} VSCMsgInit;
+
+/*
+ * VSCMsgError  Client <-> Host
+ * This message is a response to any of:
+ *  Reader Add
+ *  Reader Remove
+ *  Card Remove
+ * If the operation was successful then VSC_SUCCESS
+ * is returned, other wise a specific error code.
+ */
+typedef struct VSCMsgError {
+uint32_t   code;
+} VSCMsgError;
+
+/*
+ * VSCMsgReaderAdd  Client -> Host
+ * Host replies with allocated reader id in VSCMsgError with code==SUCCESS.
+ *
+ * name - name of the reader on client side, UTF-8 encoded. Only used
+ *  for client presentation (may be translated to the device presented to the
+ *  guest), protocol wise only reader_id is important.
+ */
+typedef struct VSCMsgReaderAdd {
+uint8_tname[0];
+} VSCMsgReaderAdd;
+
+/*
+ * VSCMsgReaderRemove   Client -> Host
+ * The client's reader has been removed.
+ */
+typedef struct VSC

[Qemu-devel] [PATCH v25 01/10] trace: move trace objects from Makefile to Makefile.objs

2011-04-01 Thread Alon Levy
---
 Makefile  |   32 
 Makefile.objs |   32 
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/Makefile b/Makefile
index 89e88b4..209e14d 100644
--- a/Makefile
+++ b/Makefile
@@ -112,38 +112,6 @@ ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
 
 bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
 
-ifeq ($(TRACE_BACKEND),dtrace)
-trace.h: trace.h-timestamp trace-dtrace.h
-else
-trace.h: trace.h-timestamp
-endif
-trace.h-timestamp: $(SRC_PATH)/trace-events config-host.mak
-   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -h < $< > $@,"  GEN   trace.h")
-   @cmp -s $@ trace.h || cp $@ trace.h
-
-trace.c: trace.c-timestamp
-trace.c-timestamp: $(SRC_PATH)/trace-events config-host.mak
-   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -c < $< > $@,"  GEN   trace.c")
-   @cmp -s $@ trace.c || cp $@ trace.c
-
-trace.o: trace.c $(GENERATED_HEADERS)
-
-trace-dtrace.h: trace-dtrace.dtrace
-   $(call quiet-command,dtrace -o $@ -h -s $<, "  GEN   trace-dtrace.h")
-
-# Normal practice is to name DTrace probe file with a '.d' extension
-# but that gets picked up by QEMU's Makefile as an external dependancy
-# rule file. So we use '.dtrace' instead
-trace-dtrace.dtrace: trace-dtrace.dtrace-timestamp
-trace-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events config-host.mak
-   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -d < $< > $@,"  GEN   trace-dtrace.dtrace")
-   @cmp -s $@ trace-dtrace.dtrace || cp $@ trace-dtrace.dtrace
-
-trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS)
-   $(call quiet-command,dtrace -o $@ -G -s $<, "  GEN trace-dtrace.o")
-
-simpletrace.o: simpletrace.c $(GENERATED_HEADERS)
-
 version.o: $(SRC_PATH)/version.rc config-host.mak
$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC$(TARGET_DIR)$@")
 
diff --git a/Makefile.objs b/Makefile.objs
index 42301fd..d906a8e 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -310,6 +310,38 @@ libdis-$(CONFIG_SPARC_DIS) += sparc-dis.o
 # trace
 
 ifeq ($(TRACE_BACKEND),dtrace)
+trace.h: trace.h-timestamp trace-dtrace.h
+else
+trace.h: trace.h-timestamp
+endif
+trace.h-timestamp: $(SRC_PATH)/trace-events config-host.mak
+   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -h < $< > $@,"  GEN   trace.h")
+   @cmp -s $@ trace.h || cp $@ trace.h
+
+trace.c: trace.c-timestamp
+trace.c-timestamp: $(SRC_PATH)/trace-events config-host.mak
+   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -c < $< > $@,"  GEN   trace.c")
+   @cmp -s $@ trace.c || cp $@ trace.c
+
+trace.o: trace.c $(GENERATED_HEADERS)
+
+trace-dtrace.h: trace-dtrace.dtrace
+   $(call quiet-command,dtrace -o $@ -h -s $<, "  GEN   trace-dtrace.h")
+
+# Normal practice is to name DTrace probe file with a '.d' extension
+# but that gets picked up by QEMU's Makefile as an external dependancy
+# rule file. So we use '.dtrace' instead
+trace-dtrace.dtrace: trace-dtrace.dtrace-timestamp
+trace-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events config-host.mak
+   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -d < $< > $@,"  GEN   trace-dtrace.dtrace")
+   @cmp -s $@ trace-dtrace.dtrace || cp $@ trace-dtrace.dtrace
+
+trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS)
+   $(call quiet-command,dtrace -o $@ -G -s $<, "  GEN trace-dtrace.o")
+
+simpletrace.o: simpletrace.c $(GENERATED_HEADERS)
+
+ifeq ($(TRACE_BACKEND),dtrace)
 trace-obj-y = trace-dtrace.o
 else
 trace-obj-y = trace.o
-- 
1.7.4.2




[Qemu-devel] [PATCH v25 00/10] usb-ccid

2011-04-01 Thread Alon Levy
This patchset adds three new devices, usb-ccid, ccid-card-passthru and
ccid-card-emulated, providing a CCID bus, a simple passthru protocol
implementing card requiring a client, and a standalone emulated card.

It also introduces a new directory libcaccard with CAC card emulation,
CAC is a type of ISO 7816 smart card.

Tree for pull: git://anongit.freedesktop.org/~alon/qemu usb_ccid.v25.clean

v24->v25 changes:
 * libcacard:
  * Fix out of tree build
  * Fix build for linux-user targets

v23->v24 changes:
 * libcacard:
  = changed patches: (that need re-review)
   * 6 - libcacard: initial commit
   * 7 - libcacard: add vscclient
  = changed but trust me don't need rereview:
   * 5 - ccid: add passthru card device (removed a duplicate line
in the header, had two licenses).
  * drop "libcacard add passthru" patch, not ready, not used.
  * remove unrequired includes
  * use stderr in vscclient for printing errors
  * cosmetic fixes

v22->v23 changes:
 * libcacard
  * configure fixes: (reported by Stefan Hajnoczi)
   * test a = b, not a == b (second isn't portable)
   * quote $source_path in case it contains spaces
- this doesn't really help since there are many other places
  that need similar fixes, not introduced by this patch.

v21->v22 changes:
 * libcacard:
  * fix configure to not link libcacard if nss not found
 (reported by Stefan Hajnoczi)
  * fix vscclient linkage with simpletrace backend
 (reported by Stefan Hajnoczi)
  * card_7816.c: add missing break in ERROR_DATA_NOT_FOUND
 (reported by William van de Velde)

v20->v21 changes:
 * all: cosmetics
 * libcacard, ccid-card-passthru:
  * use qemu-{malloc,free} and qemu-thread, error_report
 * libcacard:
  * split to multiple patches

v19->v20 changes:
 * checkpatch.pl. Here are the remaining errors with explanation:
  * ignored 5 macro errors of the type
   "ERROR: Macros with complex values should be enclosed in parenthesis"
   because fixing them breaks current code, if it really bothers someone
   I can fix it.
   * four of them are in libcacard/card_7816t.h:
   /* give the subfields a unified look */
   ..
#define a_cla a_header->ah_cla /* class */
#define a_ins a_header->ah_ins /* instruction */
#define a_p1 a_header->ah_p1   /* parameter 1 */
#define a_p2 a_header->ah_p2   /* parameter 2 */
   * and the fifth:
#4946: FILE: libcacard/vcardt.h:31:
+#define VCARD_ATR_PREFIX(size) 0x3b, 0x66+(size), 0x00, 0xff, \
+   'V', 'C', 'A', 'R', 'D', '_'
  * Ignored this warning since I couldn't figure it out, and it's a test
   file:
WARNING: externs should be avoided in .c files
#2343: FILE: libcacard/link_test.c:7:
+VCardStatus cac_card_init(const char *flags, VCard *card,

v18-v19 changes:
 * more merges, down to a single digit number of patches.
 * drop enumeration property, use string.
 * rebased (trivial)

v17-v18 changes:
 * merge vscard_common.h patches.
 * actually provide a tree to pull.

v16-v17 changes:
 * merged all the "v15->v16" patches
 * merged some more wherever it was easy (all same file commits).
 * added signed off by to first four patches
 * ccid.h: added copyright, removed underscore in defines, and replaced
 non C89 comments

v15-v16 changes:
 * split vscard_common introducing patch for ease of review
 * sum of commit logs for the v15-v16 commits: (whitespace fixes
removed for space, see original commit messages in later patches)
  * usb-ccid:
   * fix abort on client answer after card remove
   * enable migration
   * remove side affect code from asserts
   * return consistent self-powered state
   * mask out reserved bits in ccid_set_parameters
   * add missing abRFU in SetParameters (no affect on linux guest)
  * vscard_common.h protocol change:
   * VSCMsgInit capabilities and magic
   * removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
   * added Flush and FlushComplete, remove Reconnect.
   * define VSCARD_MAGIC
   * added error code VSC_SUCCESS.
  * ccid-card-passthru
   * return correct size
   * return error instead of assert if client sent too large ATR
   * don't assert if client sent too large a size, but add asserts for indices 
to buffer
   * reset vscard_in indices on chardev disconnect
   * handle init from client
   * error if no chardev supplied
   * use ntoh, hton
   * eradicate reader_id_t
   * remove Reconnect usage (removed from VSCARD protocol)
   * send VSC_SUCCESS on card insert/remove and reader add/remove
  * ccid-card-emulated
   * fix error reporting in initfn

v14-v15 changes:
 * add patch with --enable-smartcard and --disable-smartcard and only
  disable ccid-card-emulated if nss not found.
 * add patch with description strings
 * s/libcaccard/libcacard/ in docs/ccid.txt

v13-v14 changes:
 - support device_del/device_add on ccid-card-* and usb-ccid
 * usb-ccid:
  * lose card reference when card device deleted
  * check slot number and deny adding a slot if one is already added.
 * ccid-card-*: use qdev_simple_unplug_cb in both 

[Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Michael Roth
Was playing around with Stefan's git hook for checkpatch.pl:

http://blog.vmsplice.net/2011/03/how-to-automatically-run-checkpatchpl.html

which seems really useful butter-finger coders such as myself. But some of 
warnings/errors that have carried over from the kernel have made this approach 
somewhat prohibitive for QEMU code.

These patches add a flag that let's checkpatch.pl exit successfully when we 
only have warnings, while still printing them and encouraging users to fix them.

We also make C99 //comments a warning instead of an error, since they don't 
actually violate QEMU's coding guidelines.




[Qemu-devel] [PATCH v25 03/10] usb-ccid: add CCID bus

2011-04-01 Thread Alon Levy
A CCID device is a smart card reader. It is a USB device, defined at [1].
This patch introduces the usb-ccid device that is a ccid bus. Next patches will
introduce two card types to use it, a passthru card and an emulated card.

 [1] http://www.usb.org/developers/devclass_docs/DWG_Smart-Card_CCID_Rev110.

Signed-off-by: Alon Levy 

---

changes from v20->v21: (Jes Sorenson review)
 * cosmetic changes - fix multi line comments.
 * reorder fields in USBCCIDState
 * add reference to COPYING
 * add --enable-smartcard and --disable-smartcard here (moved
 from last patch)

changes from v19->v20:
 * checkpatch.pl

changes from v18->v19:
 * merged: ccid.h: add copyright, fix define and remove non C89 comments
 * add qdev.desc

changes from v15->v16:

Behavioral changes:
 * fix abort on client answer after card remove
 * enable migration
 * remove side affect code from asserts
 * return consistent self-powered state
 * mask out reserved bits in ccid_set_parameters
 * add missing abRFU in SetParameters (no affect on linux guest)

whitefixes / comments / consts defines:
 * remove stale comment
 * remove ccid_print_pending_answers if no DEBUG_CCID
 * replace printf's with DPRINTF, remove DEBUG_CCID, add verbosity defines
 * use error_report
 * update copyright (most of the code is not original)
 * reword known bug comment
 * add missing closing quote in comment
 * add missing whitespace on one line
 * s/CCID_SetParameter/CCID_SetParameters/
 * add comments
 * use define for max packet size

Comment for "return consistent self-powered state":

the Configuration Descriptor bmAttributes claims we are self powered,
but we were returning not self powered to USB_REQ_GET_STATUS control message.

In practice, this message is not sent by a linux 2.6.35.10-74.fc14.x86_64
guest (not tested on other guests), unless you issue lsusb -v as root (for
example).
---
 Makefile.objs |1 +
 configure |   11 +
 hw/ccid.h |   59 +++
 hw/usb-ccid.c | 1419 +
 4 files changed, 1490 insertions(+), 0 deletions(-)
 create mode 100644 hw/ccid.h
 create mode 100644 hw/usb-ccid.c

diff --git a/Makefile.objs b/Makefile.objs
index d906a8e..7fdfc48 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -200,6 +200,7 @@ hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o
 hw-obj-$(CONFIG_DMA) += dma.o
 hw-obj-$(CONFIG_HPET) += hpet.o
 hw-obj-$(CONFIG_APPLESMC) += applesmc.o
+hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o
 
 # PPC devices
 hw-obj-$(CONFIG_OPENPIC) += openpic.o
diff --git a/configure b/configure
index 5a5827f..159549d 100755
--- a/configure
+++ b/configure
@@ -175,6 +175,7 @@ trace_backend="nop"
 trace_file="trace"
 spice=""
 rbd=""
+smartcard=""
 
 # parse CC options first
 for opt do
@@ -724,6 +725,10 @@ for opt do
   ;;
   --enable-rbd) rbd="yes"
   ;;
+  --disable-smartcard) smartcard="no"
+  ;;
+  --enable-smartcard) smartcard="yes"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -921,6 +926,8 @@ echo "   Default:trace-"
 echo "  --disable-spice  disable spice"
 echo "  --enable-spice   enable spice"
 echo "  --enable-rbd enable building the rados block device (rbd)"
+echo "  --disable-smartcard  disable smartcard support"
+echo "  --enable-smartcard   enable smartcard support"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
@@ -2822,6 +2829,10 @@ if test "$spice" = "yes" ; then
   echo "CONFIG_SPICE=y" >> $config_host_mak
 fi
 
+if test "$smartcard" = "yes" ; then
+  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
+fi
+
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
   echo "CONFIG_BSD=y" >> $config_host_mak
diff --git a/hw/ccid.h b/hw/ccid.h
new file mode 100644
index 000..dbfc13c
--- /dev/null
+++ b/hw/ccid.h
@@ -0,0 +1,59 @@
+/*
+ * CCID Passthru Card Device emulation
+ *
+ * Copyright (c) 2011 Red Hat.
+ * Written by Alon Levy.
+ *
+ * This code is licenced under the GNU LGPL, version 2 or later.
+ */
+
+#ifndef CCID_H
+#define CCID_H
+
+#include "qdev.h"
+
+typedef struct CCIDCardState CCIDCardState;
+typedef struct CCIDCardInfo CCIDCardInfo;
+
+/*
+ * state of the CCID Card device (i.e. hw/ccid-card-*.c)
+ */
+struct CCIDCardState {
+DeviceState qdev;
+uint32_tslot; /* For future use with multiple slot reader. */
+};
+
+/*
+ * callbacks to be used by the CCID device (hw/usb-ccid.c) to call
+ * into the smartcard device (hw/ccid-card-*.c)
+ */
+struct CCIDCardInfo {
+DeviceInfo qdev;
+void (*print)(Monitor *mon, CCIDCardState *card, int indent);
+const uint8_t *(*get_atr)(CCIDCardState *card, uint32_t *len);
+void (*apdu_from_guest)(CCIDCardState *card,
+const uint8_t *apdu,
+uint32_t len);
+int (*exitfn)(CCIDCardState *card);
+int (*initfn)(CCIDCardState *card);
+};
+
+/*
+ * API for smartcard calling the CCID device (used by hw/ccid-card-*.c)

Re: [Qemu-devel] GSoC: Improved image format compatibility

2011-04-01 Thread Lyu Mitnick
Hello Stefan

Hello Mitnick,
>
> asynchronous i/o is also missing in block/vpc.c.
>
> All newer block drivers support asynchronous reads and writes,
> only some old drivers don't.
>
> So adding asynchronous i/o to at least some of the old drivers
> would improve their usability.
>
> Look for "aio" in block/*.c to get a starting point.
>
> Regards
> Stefan (W.)
>
>
I look for "aio" in block/*.c as a starting point of asynchronous i/o.
And I
found that there isn't any "aio" keywords in block/vmdk.c. block/vmdk.c
is used as block driver for the VMDK format. Is it means that asynchronous
i/o is also missing in VMDK format?

thanks

Mitnick


[Qemu-devel] [PATCH v25 05/10] ccid: add passthru card device

2011-04-01 Thread Alon Levy
The passthru ccid card is a device sitting on the usb-ccid bus and
using a chardevice to communicate with a remote device using the
VSCard protocol defined in libcacard/vscard_common.h

Usage docs available in following patch in docs/ccid.txt

Signed-off-by: Alon Levy 

---

Changes from v23->v24:
 * fixed double license line in header.

Changes from v20->v21: (Jes Sorensen review)
 * add reference to COPYING in header
 * long comment reformatting

Changes from v19->v20:
 * checkpatch.pl

Changes from v18->v19:
 * add qdev.desc
 * remove .qdev.unplug (no hot unplug support for ccid bus)

Changes from v16->v17:
 * fix wrong cast when receiving VSC_Error
 * ccid-card-passthru: force chardev user wakeup by sending Init
   see lengthy comment below.

Changes from v15->v16:

Behavioral changes:
 * return correct size
 * return error instead of assert if client sent too large ATR
 * don't assert if client sent too large a size, but add asserts for indices to 
buffer
 * reset vscard_in indices on chardev disconnect
 * handle init from client
 * error if no chardev supplied
 * use ntoh, hton
 * eradicate reader_id_t
 * remove Reconnect usage (removed from VSCARD protocol)
 * send VSC_SUCCESS on card insert/remove and reader add/remove

Style fixes:
 * width of line fix
 * update copyright
 * remove old TODO's
 * update file header comment
 * use macros for debug levels
 * c++ style comment replacement
 * update copyright license
 * fix ATR size comment
 * fix whitespace in struct def
 * fix DPRINTF prefix
 * line width fix

ccid-card-passthru: force chardev user wakeup by sending Init

The problem: how to wakeup the user of the smartcard when the smartcard
device is initialized?

Long term solution: have a callback interface. This was done via
the deprecated so called chardev ioctl interface.

Short term solution: do a write. Specifically we write an Init message.
And we change the client to send it's own Init message regardless of
receiving this one. Additional Init messages will be regarded as
acceptable, the first one received after connection establishment is
the determining one wrt capabilities.
---
 Makefile.objs   |2 +-
 hw/ccid-card-passthru.c |  340 +++
 2 files changed, 341 insertions(+), 1 deletions(-)
 create mode 100644 hw/ccid-card-passthru.c

diff --git a/Makefile.objs b/Makefile.objs
index 7fdfc48..07063f1 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -200,7 +200,7 @@ hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o
 hw-obj-$(CONFIG_DMA) += dma.o
 hw-obj-$(CONFIG_HPET) += hpet.o
 hw-obj-$(CONFIG_APPLESMC) += applesmc.o
-hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o
+hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o
 
 # PPC devices
 hw-obj-$(CONFIG_OPENPIC) += openpic.o
diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c
new file mode 100644
index 000..8506fed
--- /dev/null
+++ b/hw/ccid-card-passthru.c
@@ -0,0 +1,340 @@
+/*
+ * CCID Passthru Card Device emulation
+ *
+ * Copyright (c) 2011 Red Hat.
+ * Written by Alon Levy.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include 
+
+#include "qemu-char.h"
+#include "monitor.h"
+#include "hw/ccid.h"
+#include "libcacard/vscard_common.h"
+
+#define DPRINTF(card, lvl, fmt, ...)\
+do {\
+if (lvl <= card->debug) {   \
+printf("ccid-card-passthru: " fmt , ## __VA_ARGS__); \
+}   \
+} while (0)
+
+#define D_WARN 1
+#define D_INFO 2
+#define D_MORE_INFO 3
+#define D_VERBOSE 4
+
+/* TODO: do we still need this? */
+uint8_t DEFAULT_ATR[] = {
+/*
+ * From some example somewhere
+ * 0x3B, 0xB0, 0x18, 0x00, 0xD1, 0x81, 0x05, 0xB1, 0x40, 0x38, 0x1F, 0x03, 0x28
+ */
+
+/* From an Athena smart card */
+ 0x3B, 0xD5, 0x18, 0xFF, 0x80, 0x91, 0xFE, 0x1F, 0xC3, 0x80, 0x73, 0xC8, 0x21,
+ 0x13, 0x08
+};
+
+
+#define PASSTHRU_DEV_NAME "ccid-card-passthru"
+#define VSCARD_IN_SIZE 65536
+
+/* maximum size of ATR - from 7816-3 */
+#define MAX_ATR_SIZE40
+
+typedef struct PassthruState PassthruState;
+
+struct PassthruState {
+CCIDCardState base;
+CharDriverState *cs;
+uint8_t  vscard_in_data[VSCARD_IN_SIZE];
+uint32_t vscard_in_pos;
+uint32_t vscard_in_hdr;
+uint8_t  atr[MAX_ATR_SIZE];
+uint8_t  atr_length;
+uint8_t  debug;
+};
+
+/*
+ * VSCard protocol over chardev
+ * This code should not depend on the card type.
+ */
+
+static void ccid_card_vscard_send_msg(PassthruState *s,
+VSCMsgType type, uint32_t reader_id,
+const uint8_t *payload, uint32_t length)
+{
+VSCMsgHeader scr_msg_header;
+
+scr_msg_header.type = htonl(type);
+scr_msg_header.reader_id = htonl(reader_id);
+scr_msg_header.length = htonl(length);
+qemu_chr_write(s->cs, (uint8_t *)&scr_msg_header, sizeof(VS

[Qemu-devel] [PATCH 1/2] checkpatch.pl: add --no-fail-on-warn option

2011-04-01 Thread Michael Roth
checkpatch.pl complains about some things that are not strictly against
QEMU's coding style guidelines. It's good to print these, but we
shouldn't force a fail on these as it makes it difficult to automate
checkpatch.pl runs. If we're supposed to fail on these cases, they
should be handled as errors rather than warnings.

For now, however, just add a flag that enables this behavior.

Any functionality triggered by $clean = 0 is still handled as it was
previously.

Signed-off-by: Michael Roth 
---
 scripts/checkpatch.pl |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 075b614..770d534 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -28,6 +28,7 @@ my $mailback = 0;
 my $summary_file = 0;
 my $root;
 my %debug;
+my $no_fail_on_warn = 0;
 my $help = 0;
 
 sub help {
@@ -55,6 +56,7 @@ Options:
  is all off)
   --test-only=WORD   report only warnings/errors containing WORD
  literally
+  --no-fail-on-warn  print warnings, but don't fail on them
   -h, --help, --version  display this help and exit
 
 When FILE is - read standard input.
@@ -80,6 +82,7 @@ GetOptions(
 
'debug=s'   => \%debug,
'test-only=s'   => \$tst_only,
+   'no-fail-on-warn' => \$no_fail_on_warn,
'h|help'=> \$help,
'version'   => \$help
 ) or help(1);
@@ -1104,18 +1107,23 @@ sub report_dump {
 sub ERROR {
if (report("ERROR: $_[0]\n")) {
our $clean = 0;
+   our $passable = 0;
our $cnt_error++;
}
 }
 sub WARN {
if (report("WARNING: $_[0]\n")) {
our $clean = 0;
+   if ($no_fail_on_warn == 0) {
+   our $passable = 0;
+   }
our $cnt_warn++;
}
 }
 sub CHK {
if ($check && report("CHECK: $_[0]\n")) {
our $clean = 0;
+   our $passable = 0;
our $cnt_chk++;
}
 }
@@ -1162,6 +1170,7 @@ sub process {
my $stashindent=0;
 
our $clean = 1;
+   our $passable = 1;
my $signoff = 0;
my $is_patch = 0;
 
@@ -2906,5 +2915,5 @@ sub process {
print "CHECKPATCH in MAINTAINERS.\n";
}
 
-   return $clean;
+   return $passable;
 }
-- 
1.7.0.4




[Qemu-devel] [PATCH v25 04/10] introduce libcacard/vscard_common.h

2011-04-01 Thread Alon Levy
---

Signed-off-by: Alon Levy 

v20->v21 changes: (Jes Sorensen review)
 * license set to 2+
 * long comment fixes, remove empty line at eof.
 * add reference to COPYING

v19->v20 changes:
 * checkpatch.pl

v15->v16 changes:

Protocol change:
 * VSCMsgInit capabilities and magic
 * removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
 * adaded Flush and FlushComplete, remove Reconnect.
 * define VSCARD_MAGIC
 * added error code VSC_SUCCESS.

Fixes:
 * update VSCMsgInit comment
 * fix message type enum
 * remove underscore from wrapping define
 * update copyright
 * updated comments.
 * Header comment updated
 * remove C++ style comment
 * fix comment for VSCMsgError
 * give names to enums in typedefs
---
 libcacard/vscard_common.h |  178 +
 1 files changed, 178 insertions(+), 0 deletions(-)
 create mode 100644 libcacard/vscard_common.h

diff --git a/libcacard/vscard_common.h b/libcacard/vscard_common.h
new file mode 100644
index 000..bebd52d
--- /dev/null
+++ b/libcacard/vscard_common.h
@@ -0,0 +1,178 @@
+/* Virtual Smart Card protocol definition
+ *
+ * This protocol is between a host using virtual smart card readers,
+ * and a client providing the smart cards, perhaps by emulating them or by
+ * access to real cards.
+ *
+ * Definitions for this protocol:
+ *  Host   - user of the card
+ *  Client - owner of the card
+ *
+ * The current implementation passes the raw APDU's from 7816 and additionally
+ * contains messages to setup and teardown readers, handle insertion and
+ * removal of cards, negotiate the protocol via capabilities and provide
+ * for error responses.
+ *
+ * Copyright (c) 2011 Red Hat.
+ *
+ * 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 VSCARD_COMMON_H
+#define VSCARD_COMMON_H
+
+#include 
+
+#define VERSION_MAJOR_BITS 11
+#define VERSION_MIDDLE_BITS 11
+#define VERSION_MINOR_BITS 10
+
+#define MAKE_VERSION(major, middle, minor) \
+ ((major  << (VERSION_MINOR_BITS + VERSION_MIDDLE_BITS)) \
+  | (middle <<  VERSION_MINOR_BITS) \
+  | (minor))
+
+/*
+ * IMPORTANT NOTE on VERSION
+ *
+ * The version below MUST be changed whenever a change in this file is made.
+ *
+ * The last digit, the minor, is for bug fix changes only.
+ *
+ * The middle digit is for backward / forward compatible changes, updates
+ * to the existing messages, addition of fields.
+ *
+ * The major digit is for a breaking change of protocol, presumably
+ * something that cannot be accomodated with the existing protocol.
+ */
+
+#define VSCARD_VERSION MAKE_VERSION(0, 0, 2)
+
+typedef enum VSCMsgType {
+VSC_Init = 1,
+VSC_Error,
+VSC_ReaderAdd,
+VSC_ReaderRemove,
+VSC_ATR,
+VSC_CardRemove,
+VSC_APDU,
+VSC_Flush,
+VSC_FlushComplete
+} VSCMsgType;
+
+typedef enum VSCErrorCode {
+VSC_SUCCESS = 0,
+VSC_GENERAL_ERROR = 1,
+VSC_CANNOT_ADD_MORE_READERS,
+VSC_CARD_ALREAY_INSERTED,
+} VSCErrorCode;
+
+#define VSCARD_UNDEFINED_READER_ID  0x
+#define VSCARD_MINIMAL_READER_ID0
+
+#define VSCARD_MAGIC (*(uint32_t *)"VSCD")
+
+/*
+ * Header
+ * Each message starts with the header.
+ * type - message type
+ * reader_id - used by messages that are reader specific
+ * length - length of payload (not including header, i.e. zero for
+ *  messages containing empty payloads)
+ */
+typedef struct VSCMsgHeader {
+uint32_t   type;
+uint32_t   reader_id;
+uint32_t   length;
+uint8_tdata[0];
+} VSCMsgHeader;
+
+/*
+ * VSCMsgInit   Client <-> Host
+ * Client sends it on connection, with its own capabilities.
+ * Host replies with VSCMsgInit filling in its capabilities.
+ *
+ * It is not meant to be used for negotiation, i.e. sending more then
+ * once from any side, but could be used for that in the future.
+ */
+typedef struct VSCMsgInit {
+uint32_t   magic;
+uint32_t   version;
+uint32_t   capabilities[1]; /* receiver must check length,
+   array may grow in the future*/
+} VSCMsgInit;
+
+/*
+ * VSCMsgError  Client <-> Host
+ * This message is a response to any of:
+ *  Reader Add
+ *  Reader Remove
+ *  Card Remove
+ * If the operation was successful then VSC_SUCCESS
+ * is returned, other wise a specific error code.
+ */
+typedef struct VSCMsgError {
+uint32_t   code;
+} VSCMsgError;
+
+/*
+ * VSCMsgReaderAdd  Client -> Host
+ * Host replies with allocated reader id in VSCMsgError with code==SUCCESS.
+ *
+ * name - name of the reader on client side, UTF-8 encoded. Only used
+ *  for client presentation (may be translated to the device presented to the
+ *  guest), protocol wise only reader_id is important.
+ */
+typedef struct VSCMsgReaderAdd {
+uint8_tname[0];
+} VSCMsgReaderAdd;
+
+/*
+ * VSCMsgReaderRemove   Client -> Host
+ * The client's reader has been removed.
+ */
+typedef struct VSC

[Qemu-devel] [PATCH v25 05/10] ccid: add passthru card device

2011-04-01 Thread Alon Levy
The passthru ccid card is a device sitting on the usb-ccid bus and
using a chardevice to communicate with a remote device using the
VSCard protocol defined in libcacard/vscard_common.h

Usage docs available in following patch in docs/ccid.txt

Signed-off-by: Alon Levy 

---

Changes from v23->v24:
 * fixed double license line in header.

Changes from v20->v21: (Jes Sorensen review)
 * add reference to COPYING in header
 * long comment reformatting

Changes from v19->v20:
 * checkpatch.pl

Changes from v18->v19:
 * add qdev.desc
 * remove .qdev.unplug (no hot unplug support for ccid bus)

Changes from v16->v17:
 * fix wrong cast when receiving VSC_Error
 * ccid-card-passthru: force chardev user wakeup by sending Init
   see lengthy comment below.

Changes from v15->v16:

Behavioral changes:
 * return correct size
 * return error instead of assert if client sent too large ATR
 * don't assert if client sent too large a size, but add asserts for indices to 
buffer
 * reset vscard_in indices on chardev disconnect
 * handle init from client
 * error if no chardev supplied
 * use ntoh, hton
 * eradicate reader_id_t
 * remove Reconnect usage (removed from VSCARD protocol)
 * send VSC_SUCCESS on card insert/remove and reader add/remove

Style fixes:
 * width of line fix
 * update copyright
 * remove old TODO's
 * update file header comment
 * use macros for debug levels
 * c++ style comment replacement
 * update copyright license
 * fix ATR size comment
 * fix whitespace in struct def
 * fix DPRINTF prefix
 * line width fix

ccid-card-passthru: force chardev user wakeup by sending Init

The problem: how to wakeup the user of the smartcard when the smartcard
device is initialized?

Long term solution: have a callback interface. This was done via
the deprecated so called chardev ioctl interface.

Short term solution: do a write. Specifically we write an Init message.
And we change the client to send it's own Init message regardless of
receiving this one. Additional Init messages will be regarded as
acceptable, the first one received after connection establishment is
the determining one wrt capabilities.
---
 Makefile.objs   |2 +-
 hw/ccid-card-passthru.c |  340 +++
 2 files changed, 341 insertions(+), 1 deletions(-)
 create mode 100644 hw/ccid-card-passthru.c

diff --git a/Makefile.objs b/Makefile.objs
index 7fdfc48..07063f1 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -200,7 +200,7 @@ hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o
 hw-obj-$(CONFIG_DMA) += dma.o
 hw-obj-$(CONFIG_HPET) += hpet.o
 hw-obj-$(CONFIG_APPLESMC) += applesmc.o
-hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o
+hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o
 
 # PPC devices
 hw-obj-$(CONFIG_OPENPIC) += openpic.o
diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c
new file mode 100644
index 000..8506fed
--- /dev/null
+++ b/hw/ccid-card-passthru.c
@@ -0,0 +1,340 @@
+/*
+ * CCID Passthru Card Device emulation
+ *
+ * Copyright (c) 2011 Red Hat.
+ * Written by Alon Levy.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include 
+
+#include "qemu-char.h"
+#include "monitor.h"
+#include "hw/ccid.h"
+#include "libcacard/vscard_common.h"
+
+#define DPRINTF(card, lvl, fmt, ...)\
+do {\
+if (lvl <= card->debug) {   \
+printf("ccid-card-passthru: " fmt , ## __VA_ARGS__); \
+}   \
+} while (0)
+
+#define D_WARN 1
+#define D_INFO 2
+#define D_MORE_INFO 3
+#define D_VERBOSE 4
+
+/* TODO: do we still need this? */
+uint8_t DEFAULT_ATR[] = {
+/*
+ * From some example somewhere
+ * 0x3B, 0xB0, 0x18, 0x00, 0xD1, 0x81, 0x05, 0xB1, 0x40, 0x38, 0x1F, 0x03, 0x28
+ */
+
+/* From an Athena smart card */
+ 0x3B, 0xD5, 0x18, 0xFF, 0x80, 0x91, 0xFE, 0x1F, 0xC3, 0x80, 0x73, 0xC8, 0x21,
+ 0x13, 0x08
+};
+
+
+#define PASSTHRU_DEV_NAME "ccid-card-passthru"
+#define VSCARD_IN_SIZE 65536
+
+/* maximum size of ATR - from 7816-3 */
+#define MAX_ATR_SIZE40
+
+typedef struct PassthruState PassthruState;
+
+struct PassthruState {
+CCIDCardState base;
+CharDriverState *cs;
+uint8_t  vscard_in_data[VSCARD_IN_SIZE];
+uint32_t vscard_in_pos;
+uint32_t vscard_in_hdr;
+uint8_t  atr[MAX_ATR_SIZE];
+uint8_t  atr_length;
+uint8_t  debug;
+};
+
+/*
+ * VSCard protocol over chardev
+ * This code should not depend on the card type.
+ */
+
+static void ccid_card_vscard_send_msg(PassthruState *s,
+VSCMsgType type, uint32_t reader_id,
+const uint8_t *payload, uint32_t length)
+{
+VSCMsgHeader scr_msg_header;
+
+scr_msg_header.type = htonl(type);
+scr_msg_header.reader_id = htonl(reader_id);
+scr_msg_header.length = htonl(length);
+qemu_chr_write(s->cs, (uint8_t *)&scr_msg_header, sizeof(VS

[Qemu-devel] [PATCH v25 02/10] qemu-thread.h: include inttypes.h

2011-04-01 Thread Alon Levy
qemu-thread.h relies on uint64_t being defined, but doesn't include
inttypes.h explicitly. This makes it easier to use it from vscclient (part
of libcacard).
---
 qemu-thread.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/qemu-thread.h b/qemu-thread.h
index edc7ab6..0a73d50 100644
--- a/qemu-thread.h
+++ b/qemu-thread.h
@@ -1,6 +1,8 @@
 #ifndef __QEMU_THREAD_H
 #define __QEMU_THREAD_H 1
 
+#include 
+
 typedef struct QemuMutex QemuMutex;
 typedef struct QemuCond QemuCond;
 typedef struct QemuThread QemuThread;
-- 
1.7.4.2




[Qemu-devel] [PATCH 2/2] checkpatch.pl: make C99 comments a warning, not error

2011-04-01 Thread Michael Roth
C99 comments are pretty heavilly used in QEMU, and don't violate
anything mentioned in HACKING/CODING_STYLE. Make them warnings instead.

Signed-off-by: Michael Roth 
---
 scripts/checkpatch.pl |2 +-
 test.c|5 +
 2 files changed, 6 insertions(+), 1 deletions(-)
 create mode 100644 test.c

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 770d534..2aab4e9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1799,7 +1799,7 @@ sub process {
 
 # no C99 // comments
if ($line =~ m{//}) {
-   ERROR("do not use C99 // comments\n" . $herecurr);
+   WARN("do not use C99 // comments\n" . $herecurr);
}
# Remove C99 comments.
$line =~ s@//.*@@;
diff --git a/test.c b/test.c
new file mode 100644
index 000..fe3b163
--- /dev/null
+++ b/test.c
@@ -0,0 +1,5 @@
+//stuff
+static int blah(void)
+{
+return 1;
+}
-- 
1.7.0.4




[Qemu-devel] [PATCH v25 00/10] usb-ccid

2011-04-01 Thread Alon Levy
This patchset adds three new devices, usb-ccid, ccid-card-passthru and
ccid-card-emulated, providing a CCID bus, a simple passthru protocol
implementing card requiring a client, and a standalone emulated card.

It also introduces a new directory libcaccard with CAC card emulation,
CAC is a type of ISO 7816 smart card.

Tree for pull: git://anongit.freedesktop.org/~alon/qemu usb_ccid.v25.clean

v24->v25 changes:
 * libcacard:
  * Fix out of tree build
  * Fix build for linux-user targets

v23->v24 changes:
 * libcacard:
  = changed patches: (that need re-review)
   * 6 - libcacard: initial commit
   * 7 - libcacard: add vscclient
  = changed but trust me don't need rereview:
   * 5 - ccid: add passthru card device (removed a duplicate line
in the header, had two licenses).
  * drop "libcacard add passthru" patch, not ready, not used.
  * remove unrequired includes
  * use stderr in vscclient for printing errors
  * cosmetic fixes

v22->v23 changes:
 * libcacard
  * configure fixes: (reported by Stefan Hajnoczi)
   * test a = b, not a == b (second isn't portable)
   * quote $source_path in case it contains spaces
- this doesn't really help since there are many other places
  that need similar fixes, not introduced by this patch.

v21->v22 changes:
 * libcacard:
  * fix configure to not link libcacard if nss not found
 (reported by Stefan Hajnoczi)
  * fix vscclient linkage with simpletrace backend
 (reported by Stefan Hajnoczi)
  * card_7816.c: add missing break in ERROR_DATA_NOT_FOUND
 (reported by William van de Velde)

v20->v21 changes:
 * all: cosmetics
 * libcacard, ccid-card-passthru:
  * use qemu-{malloc,free} and qemu-thread, error_report
 * libcacard:
  * split to multiple patches

v19->v20 changes:
 * checkpatch.pl. Here are the remaining errors with explanation:
  * ignored 5 macro errors of the type
   "ERROR: Macros with complex values should be enclosed in parenthesis"
   because fixing them breaks current code, if it really bothers someone
   I can fix it.
   * four of them are in libcacard/card_7816t.h:
   /* give the subfields a unified look */
   ..
#define a_cla a_header->ah_cla /* class */
#define a_ins a_header->ah_ins /* instruction */
#define a_p1 a_header->ah_p1   /* parameter 1 */
#define a_p2 a_header->ah_p2   /* parameter 2 */
   * and the fifth:
#4946: FILE: libcacard/vcardt.h:31:
+#define VCARD_ATR_PREFIX(size) 0x3b, 0x66+(size), 0x00, 0xff, \
+   'V', 'C', 'A', 'R', 'D', '_'
  * Ignored this warning since I couldn't figure it out, and it's a test
   file:
WARNING: externs should be avoided in .c files
#2343: FILE: libcacard/link_test.c:7:
+VCardStatus cac_card_init(const char *flags, VCard *card,

v18-v19 changes:
 * more merges, down to a single digit number of patches.
 * drop enumeration property, use string.
 * rebased (trivial)

v17-v18 changes:
 * merge vscard_common.h patches.
 * actually provide a tree to pull.

v16-v17 changes:
 * merged all the "v15->v16" patches
 * merged some more wherever it was easy (all same file commits).
 * added signed off by to first four patches
 * ccid.h: added copyright, removed underscore in defines, and replaced
 non C89 comments

v15-v16 changes:
 * split vscard_common introducing patch for ease of review
 * sum of commit logs for the v15-v16 commits: (whitespace fixes
removed for space, see original commit messages in later patches)
  * usb-ccid:
   * fix abort on client answer after card remove
   * enable migration
   * remove side affect code from asserts
   * return consistent self-powered state
   * mask out reserved bits in ccid_set_parameters
   * add missing abRFU in SetParameters (no affect on linux guest)
  * vscard_common.h protocol change:
   * VSCMsgInit capabilities and magic
   * removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
   * added Flush and FlushComplete, remove Reconnect.
   * define VSCARD_MAGIC
   * added error code VSC_SUCCESS.
  * ccid-card-passthru
   * return correct size
   * return error instead of assert if client sent too large ATR
   * don't assert if client sent too large a size, but add asserts for indices 
to buffer
   * reset vscard_in indices on chardev disconnect
   * handle init from client
   * error if no chardev supplied
   * use ntoh, hton
   * eradicate reader_id_t
   * remove Reconnect usage (removed from VSCARD protocol)
   * send VSC_SUCCESS on card insert/remove and reader add/remove
  * ccid-card-emulated
   * fix error reporting in initfn

v14-v15 changes:
 * add patch with --enable-smartcard and --disable-smartcard and only
  disable ccid-card-emulated if nss not found.
 * add patch with description strings
 * s/libcaccard/libcacard/ in docs/ccid.txt

v13-v14 changes:
 - support device_del/device_add on ccid-card-* and usb-ccid
 * usb-ccid:
  * lose card reference when card device deleted
  * check slot number and deny adding a slot if one is already added.
 * ccid-card-*: use qdev_simple_unplug_cb in both 

[Qemu-devel] Re: [PATCH 2/2] checkpatch.pl: make C99 comments a warning, not error

2011-04-01 Thread Michael Roth

On 04/01/2011 10:20 AM, Michael Roth wrote:

C99 comments are pretty heavilly used in QEMU, and don't violate
anything mentioned in HACKING/CODING_STYLE. Make them warnings instead.

Signed-off-by: Michael Roth
---
  scripts/checkpatch.pl |2 +-
  test.c|5 +
  2 files changed, 6 insertions(+), 1 deletions(-)
  create mode 100644 test.c

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 770d534..2aab4e9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1799,7 +1799,7 @@ sub process {

  # no C99 // comments
if ($line =~ m{//}) {
-   ERROR("do not use C99 // comments\n" . $herecurr);
+   WARN("do not use C99 // comments\n" . $herecurr);
}
# Remove C99 comments.
$line =~ s@//.*@@;
diff --git a/test.c b/test.c
new file mode 100644
index 000..fe3b163
--- /dev/null
+++ b/test.c
@@ -0,0 +1,5 @@
+//stuff
+static int blah(void)
+{
+return 1;
+}


Ugh, please ignore this test.c addition. Let me know if I should resend





Re: [Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Peter Maydell
On 1 April 2011 16:20, Michael Roth  wrote:
> We also make C99 //comments a warning instead of an error, since they
> don't actually violate QEMU's coding guidelines.

We should either update the guidelines or fix the script...

-- PMM



[Qemu-devel] [PATCH v25 10/10] ccid: add docs

2011-04-01 Thread Alon Levy
Add documentation for the usb-ccid device and accompanying two card
devices, ccid-card-emulated and ccid-card-passthru.

Signed-off-by: Alon Levy 
---
 docs/ccid.txt |  135 +
 1 files changed, 135 insertions(+), 0 deletions(-)
 create mode 100644 docs/ccid.txt

diff --git a/docs/ccid.txt b/docs/ccid.txt
new file mode 100644
index 000..b8e504a
--- /dev/null
+++ b/docs/ccid.txt
@@ -0,0 +1,135 @@
+Qemu CCID Device Documentation.
+
+Contents
+1. USB CCID device
+2. Building
+3. Using ccid-card-emulated with hardware
+4. Using ccid-card-emulated with certificates
+5. Using ccid-card-passthru with client side hardware
+6. Using ccid-card-passthru with client side certificates
+7. Passthrough protocol scenario
+8. libcacard
+
+1. USB CCID device
+
+The USB CCID device is a USB device implementing the CCID specification, which
+lets one connect smart card readers that implement the same spec. For more
+information see the specification:
+
+ Universal Serial Bus
+ Device Class: Smart Card
+ CCID
+ Specification for
+ Integrated Circuit(s) Cards Interface Devices
+ Revision 1.1
+ April 22rd, 2005
+
+Smartcard are used for authentication, single sign on, decryption in
+public/private schemes and digital signatures. A smartcard reader on the client
+cannot be used on a guest with simple usb passthrough since it will then not be
+available on the client, possibly locking the computer when it is "removed". On
+the other hand this device can let you use the smartcard on both the client and
+the guest machine. It is also possible to have a completely virtual smart card
+reader and smart card (i.e. not backed by a physical device) using this device.
+
+2. Building
+
+The cryptographic functions and access to the physical card is done via NSS.
+
+Installing NSS:
+
+In redhat/fedora:
+yum install nss-devel
+In ubuntu/debian:
+apt-get install libnss3-dev
+(not tested on ubuntu)
+
+Configuring and building:
+./configure --enable-smartcard && make
+
+3. Using ccid-card-emulated with hardware
+
+Assuming you have a working smartcard on the host with the current
+user, using NSS, qemu acts as another NSS client using ccid-card-emulated:
+
+qemu -usb -device usb-ccid -device ccid-card-emualated
+
+4. Using ccid-card-emulated with certificates
+
+You must create the certificates. This is a one time process. We use NSS
+certificates:
+
+certutil -d /etc/pki/nssdb -x -t "CT,CT,CT" -S -s "CN=cert1" -n cert1
+
+Note: you must have exactly three certificates.
+
+Assuming the current user can access the certificates (use certutil -L to
+verify), you can use the emulated card type with the certificates backend:
+
+qemu -usb -device usb-ccid -device 
ccid-card-emulated,backend=certificates,cert1=cert1,cert2=cert2,cert3=cert3
+
+5. Using ccid-card-passthru with client side hardware
+
+on the host specify the ccid-card-passthru device with a suitable chardev:
+
+qemu -chardev socket,server,host=0.0.0.0,port=2001,id=ccid,nowait -usb 
-device usb-ccid -device ccid-card-passthru,chardev=ccid
+
+on the client run vscclient, built when you built the libcacard library:
+libcacard/vscclient  2001
+
+6. Using ccid-card-passthru with client side certificates
+
+Run qemu as per #5, and run vscclient as follows:
+(Note: vscclient command line interface is in a state of change)
+
+libcacard/vscclient -e "db=\"/etc/pki/nssdb\" use_hw=no 
soft=(,Test,CAC,,cert1,cert2,cert3)"  2001
+
+7. Passthrough protocol scenario
+
+This is a typical interchange of messages when using the passthru card device.
+usb-ccid is a usb device. It defaults to an unattached usb device on startup.
+usb-ccid expects a chardev and expects the protocol defined in
+cac_card/vscard_common.h to be passed over that.
+The usb-ccid device can be in one of three modes:
+ * detached
+ * attached with no card
+ * attached with card
+
+A typical interchange is: (the arrow shows who started each exchange, it can 
be client
+originated or guest originated)
+
+client event  |  vscclient   |passthru| usb-ccid  
|  guest event
+--
+  |  VSC_Init||   |
+  |  VSC_ReaderAdd   || attach|
+  |  ||   
|  sees new usb device.
+card inserted ->  |  ||   |
+  |  VSC_ATR |   insert   | insert
|  see new card
+  |  ||   |
+  |  VSC_APDU|   VSC_APDU |   
| <- guest sends APDU
+client<->physical |  ||   |
+card APDU exchange|  |  

Re: [Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Stefan Hajnoczi
On Fri, Apr 1, 2011 at 4:52 PM, Peter Maydell  wrote:
> On 1 April 2011 16:20, Michael Roth  wrote:
>> We also make C99 //comments a warning instead of an error, since they
>> don't actually violate QEMU's coding guidelines.
>
> We should either update the guidelines or fix the script...

There are a whole bunch of // in the codebase.  I prefer /* */ but as
it stands I think // should not even raise a warning.

Stefan



[Qemu-devel] [PATCH v25 09/10] ccid: add ccid-card-emulated device

2011-04-01 Thread Alon Levy
This devices uses libcacard (internal) to emulate a smartcard conforming
to the CAC standard. It attaches to the usb-ccid bus. Usage instructions
(example command lines) are in the following patch in docs/ccid.txt. It
uses libcacard which uses nss, so it can work with both hw cards and
certificates (files).

Signed-off-by: Alon Levy 

---

changes from v20->v21: (Jes Sorenson review)
 * cosmetics
 * use qemu-thread and qemu_malloc/qemu_free

changes from v19->v20:
 * checkpatch.pl

changes from v18->v19:
 * add qdev.desc
 * backend: drop the enumeration property, back to using a string one.

changes from v16->v17:
 * use PROP_TYPE_ENUM for backend

changes from v15->v16:
 * fix error reporting in initfn
 * bump copyright year
 * update copyright license

changes from v1:
 * remove stale comments, use only c-style comments
 * bugfix, forgot to set recv_len
 * change reader name to 'Virtual Reader'
---
 Makefile.objs   |1 +
 hw/ccid-card-emulated.c |  595 +++
 2 files changed, 596 insertions(+), 0 deletions(-)
 create mode 100644 hw/ccid-card-emulated.c

diff --git a/Makefile.objs b/Makefile.objs
index 8c42524..c05f5e5 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -201,6 +201,7 @@ hw-obj-$(CONFIG_DMA) += dma.o
 hw-obj-$(CONFIG_HPET) += hpet.o
 hw-obj-$(CONFIG_APPLESMC) += applesmc.o
 hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o
+hw-obj-$(CONFIG_SMARTCARD_NSS) += ccid-card-emulated.o
 
 # PPC devices
 hw-obj-$(CONFIG_OPENPIC) += openpic.o
diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c
new file mode 100644
index 000..0b07184
--- /dev/null
+++ b/hw/ccid-card-emulated.c
@@ -0,0 +1,595 @@
+/*
+ * CCID Card Device. Emulated card.
+ *
+ * Copyright (c) 2011 Red Hat.
+ * Written by Alon Levy.
+ *
+ * This code is licenced under the GNU LGPL, version 2 or later.
+ */
+
+/*
+ * It can be used to provide access to the local hardware in a non exclusive
+ * way, or it can use certificates. It requires the usb-ccid bus.
+ *
+ * Usage 1: standard, mirror hardware reader+card:
+ * qemu .. -usb -device usb-ccid -device ccid-card-emulated
+ *
+ * Usage 2: use certificates, no hardware required
+ * one time: create the certificates:
+ *  for i in 1 2 3; do
+ *  certutil -d /etc/pki/nssdb -x -t "CT,CT,CT" -S -s "CN=user$i" -n user$i
+ *  done
+ * qemu .. -usb -device usb-ccid \
+ *  -device ccid-card-emulated,cert1=user1,cert2=user2,cert3=user3
+ *
+ * If you use a non default db for the certificates you can specify it using
+ * the db parameter.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "qemu-thread.h"
+#include "qemu-char.h"
+#include "monitor.h"
+#include "hw/ccid.h"
+
+#define DPRINTF(card, lvl, fmt, ...) \
+do {\
+if (lvl <= card->debug) {\
+printf("ccid-card-emul: %s: " fmt , __func__, ## __VA_ARGS__);\
+} \
+} while (0)
+
+#define EMULATED_DEV_NAME "ccid-card-emulated"
+
+#define BACKEND_NSS_EMULATED_NAME "nss-emulated"
+#define BACKEND_CERTIFICATES_NAME "certificates"
+
+enum {
+BACKEND_NSS_EMULATED = 1,
+BACKEND_CERTIFICATES
+};
+
+#define DEFAULT_BACKEND BACKEND_NSS_EMULATED
+
+typedef struct EmulatedState EmulatedState;
+
+enum {
+EMUL_READER_INSERT = 0,
+EMUL_READER_REMOVE,
+EMUL_CARD_INSERT,
+EMUL_CARD_REMOVE,
+EMUL_GUEST_APDU,
+EMUL_RESPONSE_APDU,
+EMUL_ERROR,
+};
+
+static const char *emul_event_to_string(uint32_t emul_event)
+{
+switch (emul_event) {
+case EMUL_READER_INSERT:
+return "EMUL_READER_INSERT";
+case EMUL_READER_REMOVE:
+return "EMUL_READER_REMOVE";
+case EMUL_CARD_INSERT:
+return "EMUL_CARD_INSERT";
+case EMUL_CARD_REMOVE:
+return "EMUL_CARD_REMOVE";
+case EMUL_GUEST_APDU:
+return "EMUL_GUEST_APDU";
+case EMUL_RESPONSE_APDU:
+return "EMUL_RESPONSE_APDU";
+case EMUL_ERROR:
+return "EMUL_ERROR";
+}
+return "UNKNOWN";
+}
+
+typedef struct EmulEvent {
+QSIMPLEQ_ENTRY(EmulEvent) entry;
+union {
+struct {
+uint32_t type;
+} gen;
+struct {
+uint32_t type;
+uint64_t code;
+} error;
+struct {
+uint32_t type;
+uint32_t len;
+uint8_t data[];
+} data;
+} p;
+} EmulEvent;
+
+#define MAX_ATR_SIZE 40
+struct EmulatedState {
+CCIDCardState base;
+uint8_t  debug;
+char*backend_str;
+uint32_t backend;
+char*cert1;
+char*cert2;
+char*cert3;
+char*db;
+uint8_t  atr[MAX_ATR_SIZE];
+uint8_t  atr_length;
+QSIMPLEQ_HEAD(event_list, EmulEvent) event_list;
+QemuMutex event_list_mutex;
+VReader *reader;
+QSIMPLEQ_HEAD(guest_apdu_list, EmulEvent) guest_apdu_list;
+QemuMutex vreader_mutex; /* and guest_apdu_list mutex */
+QemuMutex handle_apdu_mutex;
+QemuCond handle_apdu_cond;
+int  pipe[2];
+int  quit_apdu_thread;
+QemuMutex a

Re: [Qemu-devel] [PATCH 2/2] checkpatch.pl: make C99 comments a warning, not error

2011-04-01 Thread Stefan Hajnoczi
On Fri, Apr 1, 2011 at 4:20 PM, Michael Roth  wrote:
> C99 comments are pretty heavilly used in QEMU, and don't violate
> anything mentioned in HACKING/CODING_STYLE. Make them warnings instead.
>
> Signed-off-by: Michael Roth 
> ---
>  scripts/checkpatch.pl |    2 +-
>  test.c                |    5 +
>  2 files changed, 6 insertions(+), 1 deletions(-)
>  create mode 100644 test.c

Reviewed-by: Stefan Hajnoczi 



[Qemu-devel] [PATCH v25 07/10] libcacard: add vscclient

2011-04-01 Thread Alon Levy
From: Robert Relyea 

client to talk to ccid-card-passthru and use smartcard on client to
perform actual operations.

v23->v24 changes: (Jes Sorensen review 2)
 * use qemu_socket instead of socket
 * use fprintf(stderr,..) for errors
 * remove unneccessary includes since using qemu_common.h
---
 libcacard/Makefile|7 +-
 libcacard/vscclient.c |  652 +
 2 files changed, 658 insertions(+), 1 deletions(-)
 create mode 100644 libcacard/vscclient.c

diff --git a/libcacard/Makefile b/libcacard/Makefile
index 0211eac..4010029 100644
--- a/libcacard/Makefile
+++ b/libcacard/Makefile
@@ -15,6 +15,11 @@ QEMU_OBJS=$(addprefix ../, $(QEMU_THREAD) $(oslib-obj-y) 
$(trace-obj-y) qemu-mal
 
 QEMU_CFLAGS+=-I../
 
+vscclient: $(libcacard-y) $(QEMU_OBJS) vscclient.o
+   $(call quiet-command,$(CC) $(libcacard_libs) -lrt -o $@ $^,"  LINK  
$(TARGET_DIR)$@")
+
+all: vscclient
+
 clean:
-   rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~
+   rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient
 
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
new file mode 100644
index 000..ce33f5a
--- /dev/null
+++ b/libcacard/vscclient.c
@@ -0,0 +1,652 @@
+/*
+ * Tester for VSCARD protocol, client side.
+ *
+ * Can be used with ccid-card-passthru.
+ *
+ * Copyright (c) 2011 Red Hat.
+ * Written by Alon Levy.
+ *
+ * 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.
+ */
+
+#include 
+
+#include "qemu-common.h"
+#include "qemu-thread.h"
+#include "qemu_socket.h"
+
+#include "vscard_common.h"
+
+#include "vreader.h"
+#include "vcard_emul.h"
+#include "vevent.h"
+
+int verbose;
+
+int sock;
+
+static void
+print_byte_array(
+uint8_t *arrBytes,
+unsigned int nSize
+) {
+int i;
+for (i = 0; i < nSize; i++) {
+printf("%02X ", arrBytes[i]);
+}
+printf("\n");
+}
+
+static void
+print_usage(void) {
+printf("vscclient [-c  .. -e  -d %s] "
+" \n",
+#ifdef USE_PASSTHRU
+" -p");
+printf(" -p use passthrough mode\n");
+#else
+   "");
+#endif
+vcard_emul_usage();
+}
+
+static QemuMutex write_lock;
+
+static int
+send_msg(
+VSCMsgType type,
+uint32_t reader_id,
+const void *msg,
+unsigned int length
+) {
+int rv;
+VSCMsgHeader mhHeader;
+
+qemu_mutex_lock(&write_lock);
+
+if (verbose > 10) {
+printf("sending type=%d id=%d, len =%d (0x%x)\n",
+   type, reader_id, length, length);
+}
+
+mhHeader.type = htonl(type);
+mhHeader.reader_id = 0;
+mhHeader.length = htonl(length);
+rv = write(sock, &mhHeader, sizeof(mhHeader));
+if (rv < 0) {
+/* Error */
+fprintf(stderr, "write header error\n");
+close(sock);
+qemu_mutex_unlock(&write_lock);
+return 16;
+}
+rv = write(sock, msg, length);
+if (rv < 0) {
+/* Error */
+fprintf(stderr, "write error\n");
+close(sock);
+qemu_mutex_unlock(&write_lock);
+return 16;
+}
+qemu_mutex_unlock(&write_lock);
+
+return 0;
+}
+
+static VReader *pending_reader;
+static QemuMutex pending_reader_lock;
+static QemuCond pending_reader_condition;
+
+#define MAX_ATR_LEN 40
+static void *
+event_thread(void *arg)
+{
+unsigned char atr[MAX_ATR_LEN];
+int atr_len = MAX_ATR_LEN;
+VEvent *event = NULL;
+unsigned int reader_id;
+
+
+while (1) {
+const char *reader_name;
+
+event = vevent_wait_next_vevent();
+if (event == NULL) {
+break;
+}
+reader_id = vreader_get_id(event->reader);
+if (reader_id == VSCARD_UNDEFINED_READER_ID &&
+event->type != VEVENT_READER_INSERT) {
+/* ignore events from readers qemu has rejected */
+/* if qemu is still deciding on this reader, wait to see if need to
+ * forward this event */
+qemu_mutex_lock(&pending_reader_lock);
+if (!pending_reader || (pending_reader != event->reader)) {
+/* wasn't for a pending reader, this reader has already been
+ * rejected by qemu */
+qemu_mutex_unlock(&pending_reader_lock);
+vevent_delete(event);
+continue;
+}
+/* this reader hasn't been told it's status from qemu yet, wait for
+ * that status */
+while (pending_reader != NULL) {
+qemu_cond_wait(&pending_reader_condition, 
&pending_reader_lock);
+}
+qemu_mutex_unlock(&pending_reader_lock);
+/* now recheck the id */
+reader_id = vreader_get_id(event->reader);
+if (reader_id == VSCARD_UNDEFINED_READER_ID) {
+/* this reader was rejected */
+vevent_delete(event);
+continue;
+}
+/* reader was accepted, now forward the event

[Qemu-devel] Re: [0/27] Implement emulation of pSeries logical partitions (v6)

2011-04-01 Thread Alexander Graf

On 01.04.2011, at 06:15, David Gibson wrote:

> This patch series adds a "pseries" machine to qemu, allowing it to
> emulate IBM pSeries logical partitions.  More specifically it
> implements the interface defined by the "PowerPC Architecture Platform
> Requirements" document (PAPR, or sPAPR for short).
> 
> Along the way we add a bunch of support for more modern ppc CPUs than
> are currently supported.  It also makes some significant cleanups to
> the translation code for hash page table based ppc MMUs.
> 
> Please apply.

Anyone with commit rights able to merge this? Full series is:

Acked-by: Alexander Graf 


Alex




Re: [Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Peter Maydell
On 1 April 2011 16:59, Stefan Hajnoczi  wrote:
> On Fri, Apr 1, 2011 at 4:52 PM, Peter Maydell  
> wrote:
>> On 1 April 2011 16:20, Michael Roth  wrote:
>>> We also make C99 //comments a warning instead of an error, since they
>>> don't actually violate QEMU's coding guidelines.
>>
>> We should either update the guidelines or fix the script...
>
> There are a whole bunch of // in the codebase.  I prefer /* */ but as
> it stands I think // should not even raise a warning.

I don't care much either, really. I just don't think we should be
introducing random coding standards rules by the back door because
checkpatch happens to complain about them.

-- PMM



[Qemu-devel] [PATCH v25 03/10] usb-ccid: add CCID bus

2011-04-01 Thread Alon Levy
A CCID device is a smart card reader. It is a USB device, defined at [1].
This patch introduces the usb-ccid device that is a ccid bus. Next patches will
introduce two card types to use it, a passthru card and an emulated card.

 [1] http://www.usb.org/developers/devclass_docs/DWG_Smart-Card_CCID_Rev110.

Signed-off-by: Alon Levy 

---

changes from v20->v21: (Jes Sorenson review)
 * cosmetic changes - fix multi line comments.
 * reorder fields in USBCCIDState
 * add reference to COPYING
 * add --enable-smartcard and --disable-smartcard here (moved
 from last patch)

changes from v19->v20:
 * checkpatch.pl

changes from v18->v19:
 * merged: ccid.h: add copyright, fix define and remove non C89 comments
 * add qdev.desc

changes from v15->v16:

Behavioral changes:
 * fix abort on client answer after card remove
 * enable migration
 * remove side affect code from asserts
 * return consistent self-powered state
 * mask out reserved bits in ccid_set_parameters
 * add missing abRFU in SetParameters (no affect on linux guest)

whitefixes / comments / consts defines:
 * remove stale comment
 * remove ccid_print_pending_answers if no DEBUG_CCID
 * replace printf's with DPRINTF, remove DEBUG_CCID, add verbosity defines
 * use error_report
 * update copyright (most of the code is not original)
 * reword known bug comment
 * add missing closing quote in comment
 * add missing whitespace on one line
 * s/CCID_SetParameter/CCID_SetParameters/
 * add comments
 * use define for max packet size

Comment for "return consistent self-powered state":

the Configuration Descriptor bmAttributes claims we are self powered,
but we were returning not self powered to USB_REQ_GET_STATUS control message.

In practice, this message is not sent by a linux 2.6.35.10-74.fc14.x86_64
guest (not tested on other guests), unless you issue lsusb -v as root (for
example).
---
 Makefile.objs |1 +
 configure |   11 +
 hw/ccid.h |   59 +++
 hw/usb-ccid.c | 1419 +
 4 files changed, 1490 insertions(+), 0 deletions(-)
 create mode 100644 hw/ccid.h
 create mode 100644 hw/usb-ccid.c

diff --git a/Makefile.objs b/Makefile.objs
index d906a8e..7fdfc48 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -200,6 +200,7 @@ hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o
 hw-obj-$(CONFIG_DMA) += dma.o
 hw-obj-$(CONFIG_HPET) += hpet.o
 hw-obj-$(CONFIG_APPLESMC) += applesmc.o
+hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o
 
 # PPC devices
 hw-obj-$(CONFIG_OPENPIC) += openpic.o
diff --git a/configure b/configure
index 5a5827f..159549d 100755
--- a/configure
+++ b/configure
@@ -175,6 +175,7 @@ trace_backend="nop"
 trace_file="trace"
 spice=""
 rbd=""
+smartcard=""
 
 # parse CC options first
 for opt do
@@ -724,6 +725,10 @@ for opt do
   ;;
   --enable-rbd) rbd="yes"
   ;;
+  --disable-smartcard) smartcard="no"
+  ;;
+  --enable-smartcard) smartcard="yes"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -921,6 +926,8 @@ echo "   Default:trace-"
 echo "  --disable-spice  disable spice"
 echo "  --enable-spice   enable spice"
 echo "  --enable-rbd enable building the rados block device (rbd)"
+echo "  --disable-smartcard  disable smartcard support"
+echo "  --enable-smartcard   enable smartcard support"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
@@ -2822,6 +2829,10 @@ if test "$spice" = "yes" ; then
   echo "CONFIG_SPICE=y" >> $config_host_mak
 fi
 
+if test "$smartcard" = "yes" ; then
+  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
+fi
+
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
   echo "CONFIG_BSD=y" >> $config_host_mak
diff --git a/hw/ccid.h b/hw/ccid.h
new file mode 100644
index 000..dbfc13c
--- /dev/null
+++ b/hw/ccid.h
@@ -0,0 +1,59 @@
+/*
+ * CCID Passthru Card Device emulation
+ *
+ * Copyright (c) 2011 Red Hat.
+ * Written by Alon Levy.
+ *
+ * This code is licenced under the GNU LGPL, version 2 or later.
+ */
+
+#ifndef CCID_H
+#define CCID_H
+
+#include "qdev.h"
+
+typedef struct CCIDCardState CCIDCardState;
+typedef struct CCIDCardInfo CCIDCardInfo;
+
+/*
+ * state of the CCID Card device (i.e. hw/ccid-card-*.c)
+ */
+struct CCIDCardState {
+DeviceState qdev;
+uint32_tslot; /* For future use with multiple slot reader. */
+};
+
+/*
+ * callbacks to be used by the CCID device (hw/usb-ccid.c) to call
+ * into the smartcard device (hw/ccid-card-*.c)
+ */
+struct CCIDCardInfo {
+DeviceInfo qdev;
+void (*print)(Monitor *mon, CCIDCardState *card, int indent);
+const uint8_t *(*get_atr)(CCIDCardState *card, uint32_t *len);
+void (*apdu_from_guest)(CCIDCardState *card,
+const uint8_t *apdu,
+uint32_t len);
+int (*exitfn)(CCIDCardState *card);
+int (*initfn)(CCIDCardState *card);
+};
+
+/*
+ * API for smartcard calling the CCID device (used by hw/ccid-card-*.c)

[Qemu-devel] [PATCH v25 08/10] libcacard: add docs

2011-04-01 Thread Alon Levy
From: Robert Relyea 

---
 docs/libcacard.txt |  483 
 1 files changed, 483 insertions(+), 0 deletions(-)
 create mode 100644 docs/libcacard.txt

diff --git a/docs/libcacard.txt b/docs/libcacard.txt
new file mode 100644
index 000..5dee6fa
--- /dev/null
+++ b/docs/libcacard.txt
@@ -0,0 +1,483 @@
+This file documents the CAC (Common Access Card) library in the libcacard
+subdirectory.
+
+Virtual Smart Card Emulator
+
+This emulator is designed to provide emulation of actual smart cards to a
+virtual card reader running in a guest virtual machine. The emulated smart
+cards can be representations of real smart cards, where the necessary functions
+such as signing, card removal/insertion, etc. are mapped to real, physical
+cards which are shared with the client machine the emulator is running on, or
+the cards could be pure software constructs.
+
+The emulator is structured to allow multiple replacable or additional pieces,
+so it can be easily modified for future requirements. The primary envisioned
+modifications are:
+
+1) The socket connection to the virtual card reader (presumably a CCID reader,
+but other ISO-7816 compatible readers could be used). The code that handles
+this is in vscclient.c.
+
+2) The virtual card low level emulation. This is currently supplied by using
+NSS. This emulation could be replaced by implementations based on other
+security libraries, including but not limitted to openssl+pkcs#11 library,
+raw pkcs#11, Microsoft CAPI, direct opensc calls, etc. The code that handles
+this is in vcard_emul_nss.c.
+
+3) Emulation for new types of cards. The current implementation emulates the
+original DoD CAC standard with separate pki containers. This emulator lives in
+cac.c. More than one card type emulator could be included. Other cards could
+be emulated as well, including PIV, newer versions of CAC, PKCS #15, etc.
+
+
+Replacing the Socket Based Virtual Reader Interface.
+
+The current implementation contains a replacable module vscclient.c. The
+current vscclient.c implements a sockets interface to the virtual ccid reader
+on the guest. CCID commands that are pertinent to emulation are passed
+across the socket, and their responses are passed back along that same socket.
+The protocol that vscclient uses is defined in vscard_common.h and connects
+to a qemu ccid usb device. Since this socket runs as a client, vscclient.c
+implements a program with a main entry. It also handles argument parsing for
+the emulator.
+
+An application that wants to use the virtual reader can replace vscclient.c
+with it's own implementation that connects to it's own CCID reader.  The calls
+that the CCID reader can call are:
+
+  VReaderList * vreader_get_reader_list();
+
+  This function returns a list of virtual readers.  These readers may map to
+  physical devices, or simulated devices depending on vcard the back end. Each
+  reader in the list should represent a reader to the virtual machine. Virtual
+  USB address mapping is left to the CCID reader front end. This call can be
+  made any time to get an updated list. The returned list is a copy of the
+  internal list that can be referenced by the caller without locking. This copy
+  must be freed by the caller with vreader_list_delete when it is no longer
+  needed.
+
+  VReaderListEntry *vreader_list_get_first(VReaderList *);
+
+  This function gets the first entry on the reader list. Along with
+  vreader_list_get_next(), vreader_list_get_first() can be used to walk the
+  reader list returned from vreader_get_reader_list(). VReaderListEntries are
+  part of the list themselves and do not need to be freed separately from the
+  list. If there are no entries on the list, it will return NULL.
+
+  VReaderListEntry *vreader_list_get_next(VReaderListEntry *);
+
+  This function gets the next entry in the list. If there are no more entries
+  it will return NULL.
+
+  VReader * vreader_list_get_reader(VReaderListEntry *)
+
+  This function returns the reader stored in the reader List entry. Caller gets
+  a new reference to a reader. The caller must free it's reference when it is
+  finished with vreader_free().
+
+  void vreader_free(VReader *reader);
+
+   This function frees a reference to a reader. Reader's are reference counted
+   and are automatically deleted when the last reference is freed.
+
+  void vreader_list_delete(VReaderList *list);
+
+   This function frees the list, all the elements on the list, and all the
+   reader references held by the list.
+
+  VReaderStatus vreader_power_on(VReader *reader, char *atr, int *len);
+
+  This functions simulates a card power on. Virtual cards do not care about
+  the actual voltage and other physical parameters, but it does care that the
+  card is actually on or off. Cycling the card causes the card to reset. If
+  the caller provides enough space, vreader_power_on will return the ATR of
+  the vi

[Qemu-devel] [Bug 741887] Re: virsh snapshot-create too slow (kvm, qcow2, savevm)

2011-04-01 Thread Kevin Wolf
In qemu 0.14 cache=writeback and cache=none are expected to perform
well. The default cache=writethrough is a very conservative setting
which is slow by design. I'm pretty sure that it has always been slow,
even before 0.12.5.

I think that the specific problem with savevm may be related to the VM
state being saved in too small chunks. With cache=writethrough this will
hurt most.

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

Title:
  virsh snapshot-create too slow (kvm, qcow2, savevm)

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

Bug description:
  Action
  ==
  # time virsh snapshot-create 1

  * Taking snapshot of a running KVM virtual machine

  Result
  ==
  Domain snapshot 1300983161 created
  real4m46.994s
  user0m0.000s
  sys 0m0.010s

  Expected result
  ===
  * Snapshot taken after few seconds instead of minutes.

  Environment
  ===
  * Ubuntu Natty Narwhal upgraded from Lucid and Meerkat, fully updated.

  * Stock natty packages of libvirt and qemu installed (libvirt-bin
  0.8.8-1ubuntu5; libvirt0 0.8.8-1ubuntu5; qemu-common 0.14.0+noroms-
  0ubuntu3; qemu-kvm 0.14.0+noroms-0ubuntu3).

  * Virtual machine disk format is qcow2 (debian 5 installed)
  image: /storage/debian.qcow2
  file format: qcow2
  virtual size: 10G (10737418240 bytes)
  disk size: 1.2G
  cluster_size: 65536
  Snapshot list:
  IDTAG VM SIZEDATE   VM CLOCK
  1 snap01  48M 2011-03-24 09:46:33   00:00:58.899
  2 1300979368  58M 2011-03-24 11:09:28   00:01:03.589
  3 1300983161  57M 2011-03-24 12:12:41   00:00:51.905

  * qcow2 disk is stored on ext4 filesystem, without RAID or LVM or any
  special setup.

  * running guest VM takes about 40M RAM from inside, from outside 576M
  are given to that machine

  * host has fast dual-core pentium cpu with virtualization support,
  around 8G of RAM and 7200rpm harddrive (dd from urandom to file gives
  about 20M/s)

  * running processes: sshd, atd (empty), crond (empty), libvirtd, tmux,
  bash, rsyslogd, upstart-socket-bridge, udevd, dnsmasq, iotop (python)

  * networking is done by bridging and bonding

  
  Detail description
  ==

  * Under root, command 'virsh create-snapshot 1' is issued on booted
  and running KVM machine with debian inside.

  * After about four minutes, the process is done.

  * 'iotop' shows two 'kvm' processes reading/writing to disk. First one
  has IO around 1500 K/s, second one has around 400 K/s. That takes
  about three minutes. Then first process grabs about 3 M/s of IO and
  suddenly dissapears (1-2 sec). Then second process does about 7.5 M/s
  of IO for around a 1-2 minutes.

  * Snapshot is successfuly created and is usable for reverting or
  extracting.

  * Pretty much the same behaviour occurs when command 'savevm' is
  issued directly from qemu monitor, without using libvirt at all
  (actually, virsh snapshot-create just calls 'savevm' to the monitor
  socket).

  * This behaviour was observed on lucid, meerkat, natty and even with
  git version of libvirt (f44bfb7fb978c9313ce050a1c4149bf04aa0a670).
  Also slowsave packages from
  https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/524447 gave
  this issue.

  
  Thank you for helping to solve this issue!

  ProblemType: Bug
  DistroRelease: Ubuntu 11.04
  Package: libvirt-bin 0.8.8-1ubuntu5
  ProcVersionSignature: Ubuntu 2.6.38-7.38-server 2.6.38
  Uname: Linux 2.6.38-7-server x86_64
  Architecture: amd64
  Date: Thu Mar 24 12:19:41 2011
  InstallationMedia: Ubuntu-Server 10.04.2 LTS "Lucid Lynx" - Release amd64 
(20110211.1)
  ProcEnviron:
   LANG=en_US.UTF-8
   SHELL=/bin/bash
  SourcePackage: libvirt
  UpgradeStatus: No upgrade log present (probably fresh install)



[Qemu-devel] Re: [0/27] Implement emulation of pSeries logical partitions (v6)

2011-04-01 Thread Alexander Graf

On 01.04.2011, at 18:22, Anthony Liguori wrote:

> On 04/01/2011 11:18 AM, Alexander Graf wrote:
>> On 01.04.2011, at 06:15, David Gibson wrote:
>> 
>>> This patch series adds a "pseries" machine to qemu, allowing it to
>>> emulate IBM pSeries logical partitions.  More specifically it
>>> implements the interface defined by the "PowerPC Architecture Platform
>>> Requirements" document (PAPR, or sPAPR for short).
>>> 
>>> Along the way we add a bunch of support for more modern ppc CPUs than
>>> are currently supported.  It also makes some significant cleanups to
>>> the translation code for hash page table based ppc MMUs.
>>> 
>>> Please apply.
>> Anyone with commit rights able to merge this? Full series is:
> 
> Yup, ideally I'd prefer to get a pull request from you with a Signed-off-by 
> though.
> 
> If it's too much trouble, I'll do it myself.

Ah, sure, I can do that.


Alex




[Qemu-devel] Re: [0/27] Implement emulation of pSeries logical partitions (v6)

2011-04-01 Thread Anthony Liguori

On 04/01/2011 11:18 AM, Alexander Graf wrote:

On 01.04.2011, at 06:15, David Gibson wrote:


This patch series adds a "pseries" machine to qemu, allowing it to
emulate IBM pSeries logical partitions.  More specifically it
implements the interface defined by the "PowerPC Architecture Platform
Requirements" document (PAPR, or sPAPR for short).

Along the way we add a bunch of support for more modern ppc CPUs than
are currently supported.  It also makes some significant cleanups to
the translation code for hash page table based ppc MMUs.

Please apply.

Anyone with commit rights able to merge this? Full series is:


Yup, ideally I'd prefer to get a pull request from you with a 
Signed-off-by though.


If it's too much trouble, I'll do it myself.

Regards,

Anthony Liguori


Acked-by: Alexander Graf


Alex






Re: [Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Michael Roth

On 04/01/2011 11:16 AM, Peter Maydell wrote:

On 1 April 2011 16:59, Stefan Hajnoczi  wrote:

On Fri, Apr 1, 2011 at 4:52 PM, Peter Maydell  wrote:

On 1 April 2011 16:20, Michael Roth  wrote:

We also make C99 //comments a warning instead of an error, since they
don't actually violate QEMU's coding guidelines.


We should either update the guidelines or fix the script...


There are a whole bunch of // in the codebase.  I prefer /* */ but as
it stands I think // should not even raise a warning.


I don't care much either, really. I just don't think we should be
introducing random coding standards rules by the back door because
checkpatch happens to complain about them.


Whether or not // comments should also be a warning...I'm not sure. It 
seems like a reasonable "suggestion" to make though, since mixed comment 
styles makes code look nastier. I could also go either way though...


But there *are* some warnings that make sense to complain about without 
saying "you can't do this", like extern's in .c files: some cases are 
exceptional.


I'd prefer to only document "strict" guidelines, and treat checkpatch.pl 
warnings ("suggestions") as an extra "reward" you get for taking the 
time to run it.




-- PMM





Re: [Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Peter Maydell
On 1 April 2011 17:55, Michael Roth  wrote:
> But there *are* some warnings that make sense to complain about without
> saying "you can't do this", like extern's in .c files: some cases are
> exceptional.

I'd treat everything checkpatch says as a warning anyway, because it gets
confused by things like macros often enough that you can't guarantee
that everything it thinks is an error is truly an error.

-- PMM



[Qemu-devel] GSoC: Xen.org project to implement PV driver frontend for SeaBIOS

2011-04-01 Thread Ian Campbell
Hi,

(I was unsure what the appropriate mailing list for this was, apologies
for the cross post)

You may or may not be aware that Xen intends to switch to using SeaBIOS
as part of switching to using upstream qemu as our device model
(hopefully in our next major release later this year). The switch to
SeaBIOS is currently a WIP by Anthony Perard (who did the Xen port to
upstream qemu).

This is mainly a heads up that we have several students interested in a
project which I am mentoring to add Xen PV frontends (particularly disk)
to SeaBIOS . You can see a brief description of the project near the end
of the table at http://wiki.xen.org/xenwiki/GSoC_2011_ideas. Obviously
one of the main goals will be to work with the SeaBIOS (and if necessary
qemu) communities as well as Xen.org in order to produce patches which
can can be submitted to the relevant upstreams.

If/when we have an actual student assigned to the project I will ask
them introduce themselves too.

If anyone want to be more involved with this work (e.g. as a backup
mentor or whatever) then please do let me know.

Cheers,
Ian.




Re: [Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Stefan Hajnoczi
On Fri, Apr 01, 2011 at 11:55:39AM -0500, Michael Roth wrote:
> I'd prefer to only document "strict" guidelines, and treat
> checkpatch.pl warnings ("suggestions") as an extra "reward" you get
> for taking the time to run it.

I don't want to be punished for running checkpatch.pl like I'm supposed
to while those who don't can get away with more.

A --pedantic mode would be fine although probably no one besides the
author would use it :).

The stuff that gets reported by the default invocation needs to matter,
otherwise checkpatch.pl isn't useful and people will bypass it.

Stefan



Re: [Qemu-devel] GSoC: Improved image format compatibility

2011-04-01 Thread Stefan Weil

Am 01.04.2011 17:15, schrieb Lyu Mitnick:

Hello Stefan

Hello Mitnick,

asynchronous i/o is also missing in block/vpc.c.

All newer block drivers support asynchronous reads and writes,
only some old drivers don't.

So adding asynchronous i/o to at least some of the old drivers
would improve their usability.

Look for "aio" in block/*.c to get a starting point.

Regards
Stefan (W.)


I look for "aio" in block/*.c as a starting point of asynchronous i/o. 
And I

found that there isn't any "aio" keywords in block/vmdk.c. block/vmdk.c
is used as block driver for the VMDK format. Is it means 
that asynchronous

i/o is also missing in VMDK format?

thanks

Mitnick



Yes, it's also missing for VMDK.

Stefan (W.)


[Qemu-devel] [PULL] PowerPC patch queue

2011-04-01 Thread Alexander Graf
Howdy,

this is the current patch queue for PowerPC. I'm very excited this time,
as we finally have a real PPC64 target machine available to play with!

I also included a patch from Aurelien that he seems to have forgotten to
push.

Alex


The following changes since commit a5086f95421e43c7b9e1b28a111aae0be4848117:
  Michael Walle (1):
lm32: use lookup table for opcodes

are available in the git repository at:

  git://repo.or.cz/qemu/agraf.git ppc-next

Aurelien Jarno (1):
  target-ppc: ext32u instead of andi with constant

Ben Herrenschmidt (3):
  Implement PAPR CRQ hypercalls
  Implement PAPR virtual SCSI interface (ibmvscsi)
  Add a PAPR TCE-bypass mechanism for the pSeries machine

David Gibson (24):
  Clean up PowerPC SLB handling code
  Allow qemu_devtree_setprop() to take arbitrary values
  Add a hook to allow hypercalls to be emulated on PowerPC
  Implement PowerPC slbmfee and slbmfev instructions
  Implement missing parts of the logic for the POWER PURR
  Correct ppc popcntb logic, implement popcntw and popcntd
  Clean up slb_lookup() function
  Parse SDR1 on mtspr instead of at translate time
  Use "hash" more consistently in ppc mmu code
  Better factor the ppc hash translation path
  Support 1T segments on ppc
  Add POWER7 support for ppc
  Start implementing pSeries logical partition machine
  Implement the bus structure for PAPR virtual IO
  Virtual hash page table handling on pSeries machine
  Implement hcall based RTAS for pSeries machines
  Implement assorted pSeries hcalls and RTAS methods
  Implement the PAPR (pSeries) virtualized interrupt controller (xics)
  Add PAPR H_VIO_SIGNAL hypercall and infrastructure for VIO interrupts
  Add (virtual) interrupt to PAPR virtual tty device
  Implement TCE translation for sPAPR VIO
  Implement sPAPR Virtual LAN (ibmveth)
  Implement PAPR VPA functions for pSeries shared processor partitions
  Add SLOF-based partition firmware for pSeries machine, allowing more boot 
options

 .gitmodules |3 +
 Makefile|3 +-
 Makefile.target |5 +
 configure   |4 +-
 device_tree.c   |2 +-
 device_tree.h   |2 +-
 hw/ppc-viosrp.h |  216 +
 hw/ppc.c|   35 ++
 hw/ppc.h|1 +
 hw/spapr.c  |  456 ++
 hw/spapr.h  |  294 
 hw/spapr_hcall.c|  525 +
 hw/spapr_llan.c |  521 +
 hw/spapr_rtas.c |  278 +++
 hw/spapr_vio.c  |  731 +
 hw/spapr_vio.h  |  112 +
 hw/spapr_vscsi.c|  988 +++
 hw/spapr_vty.c  |  159 +++
 hw/srp.h|  240 ++
 hw/xics.c   |  486 +++
 hw/xics.h   |   39 ++
 monitor.c   |2 +-
 pc-bios/README  |5 +
 pc-bios/slof.bin|  Bin 0 -> 579072 bytes
 pc-bios/spapr-rtas.bin  |  Bin 0 -> 20 bytes
 pc-bios/spapr-rtas/Makefile |   24 +
 pc-bios/spapr-rtas/spapr-rtas.S |   37 ++
 roms/SLOF   |1 +
 target-ppc/cpu.h|   84 -
 target-ppc/helper.c |  451 +--
 target-ppc/helper.h |7 +-
 target-ppc/kvm.c|2 +-
 target-ppc/kvm_ppc.h|   11 +
 target-ppc/machine.c|6 +-
 target-ppc/op_helper.c  |   87 +++-
 target-ppc/translate.c  |   61 ++-
 target-ppc/translate_init.c |  122 +-
 37 files changed, 5723 insertions(+), 277 deletions(-)
 create mode 100644 hw/ppc-viosrp.h
 create mode 100644 hw/spapr.c
 create mode 100644 hw/spapr.h
 create mode 100644 hw/spapr_hcall.c
 create mode 100644 hw/spapr_llan.c
 create mode 100644 hw/spapr_rtas.c
 create mode 100644 hw/spapr_vio.c
 create mode 100644 hw/spapr_vio.h
 create mode 100644 hw/spapr_vscsi.c
 create mode 100644 hw/spapr_vty.c
 create mode 100644 hw/srp.h
 create mode 100644 hw/xics.c
 create mode 100644 hw/xics.h
 create mode 100644 pc-bios/slof.bin
 create mode 100755 pc-bios/spapr-rtas.bin
 create mode 100644 pc-bios/spapr-rtas/Makefile
 create mode 100644 pc-bios/spapr-rtas/spapr-rtas.S
 create mode 16 roms/SLOF



Re: [Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Michael Roth

On 04/01/2011 11:58 AM, Peter Maydell wrote:

On 1 April 2011 17:55, Michael Roth  wrote:

But there *are* some warnings that make sense to complain about without
saying "you can't do this", like extern's in .c files: some cases are
exceptional.


I'd treat everything checkpatch says as a warning anyway, because it gets
confused by things like macros often enough that you can't guarantee
that everything it thinks is an error is truly an error.


Well, we always have the option of ignoring the return code and just 
looking at the output. Would be nice to be able to automate the check 
somewhat reliably though, and just override the false positives when 
they pop up.




-- PMM





Re: [Qemu-devel] checkpatch.pl: warn on C99 comments, but don't fail

2011-04-01 Thread Michael Roth

On 04/01/2011 12:01 PM, Stefan Hajnoczi wrote:

On Fri, Apr 01, 2011 at 11:55:39AM -0500, Michael Roth wrote:

I'd prefer to only document "strict" guidelines, and treat
checkpatch.pl warnings ("suggestions") as an extra "reward" you get
for taking the time to run it.


I don't want to be punished for running checkpatch.pl like I'm supposed
to while those who don't can get away with more.


You're not! These are extra morsels of goodness :)



A --pedantic mode would be fine although probably no one besides the
author would use it :).


True :) But you're right, this is probably the better approach. How bout:

--warnings: print coding style warnings in addition to errors, and exit 
failure if encountered


Then default to suppressing warning statements, and --no-fail-on-warn 
behavior.




The stuff that gets reported by the default invocation needs to matter,
otherwise checkpatch.pl isn't useful and people will bypass it.

Stefan





Re: [Qemu-devel] [0/27] Implement emulation of pSeries logical partitions (v6)

2011-04-01 Thread Anthony Liguori

On 03/31/2011 11:15 PM, David Gibson wrote:

This patch series adds a "pseries" machine to qemu, allowing it to
emulate IBM pSeries logical partitions.  More specifically it
implements the interface defined by the "PowerPC Architecture Platform
Requirements" document (PAPR, or sPAPR for short).

Along the way we add a bunch of support for more modern ppc CPUs than
are currently supported.  It also makes some significant cleanups to
the translation code for hash page table based ppc MMUs.

Please apply.


So what's a typical invocation for this?  Is:

qemu-system-ppc64 -m pseries foo.img -nographics

Enough or is something more sophisticated required?

Regards,

Anthony Liguori


---

Changes since v5 of this series:
  * Include source for SLOF as a git submodule
  * Move our private hcalls (well. only one so far) to a range
explicitly reserved by PAPR for this purpose.
  * Allocate an ample 1024 irqs in the XICS controller, rather than
having a somewhat dubious calculation of precisely how many we
need.

Changes since v4 of this series:
  * Fix build breakages for powerpc targets other than ppc64 full system.
  * Since the pseries platform requires libfdt, only compile it when
configured with --enable-fdt
  * Give an informative error if invoked with insufficient guest RAM to
run the partition firmware.  Without this, giving insufficient RAM
- such as qemu's default 64M - would lead to the firmware failing
cryptically partway through boot.

Changes since v3 of this series:
  * Many, many checkpatch fixups
  * Integrated feedback from qemu-devel list
  * Added in-partition SLOF firmware

Changes since v2 of this series:
  * Assorted bugfixes and cleanups.

Changes since v1 of this series:
  * numerous coding style fixups
  * incorporated most review comments from initial version
  * moved to a wholly dynamic hypercall registration scheme
  * assorted other cleanups
  * many more patches implementing VIO devices






Re: [Qemu-devel] GSoC: Improved image format compatibility

2011-04-01 Thread Kevin Wolf
Am 01.04.2011 17:15, schrieb Lyu Mitnick:
> Hello Stefan
> 
> Hello Mitnick,
> 
> asynchronous i/o is also missing in block/vpc.c.
> 
> All newer block drivers support asynchronous reads and writes,
> only some old drivers don't.
> 
> So adding asynchronous i/o to at least some of the old drivers
> would improve their usability.
> 
> Look for "aio" in block/*.c to get a starting point.
> 
> Regards
> Stefan (W.)
> 
> 
> I look for "aio" in block/*.c as a starting point of asynchronous i/o.
> And I 
> found that there isn't any "aio" keywords in block/vmdk.c. block/vmdk.c
> is used as block driver for the VMDK format. Is it means that asynchronous 
> i/o is also missing in VMDK format?

Yes, the VMDK implementation is completely synchronous.

Kevin



Re: [Qemu-devel] [PULL] PowerPC patch queue

2011-04-01 Thread Anthony Liguori

On 04/01/2011 11:43 AM, Alexander Graf wrote:

Howdy,

this is the current patch queue for PowerPC. I'm very excited this time,
as we finally have a real PPC64 target machine available to play with!

I also included a patch from Aurelien that he seems to have forgotten to
push.

Alex


The following changes since commit a5086f95421e43c7b9e1b28a111aae0be4848117:
   Michael Walle (1):
 lm32: use lookup table for opcodes

are available in the git repository at:

   git://repo.or.cz/qemu/agraf.git ppc-next


Pulled.  Thanks.

Regards,

Anthony Liguori


Aurelien Jarno (1):
   target-ppc: ext32u instead of andi with constant

Ben Herrenschmidt (3):
   Implement PAPR CRQ hypercalls
   Implement PAPR virtual SCSI interface (ibmvscsi)
   Add a PAPR TCE-bypass mechanism for the pSeries machine

David Gibson (24):
   Clean up PowerPC SLB handling code
   Allow qemu_devtree_setprop() to take arbitrary values
   Add a hook to allow hypercalls to be emulated on PowerPC
   Implement PowerPC slbmfee and slbmfev instructions
   Implement missing parts of the logic for the POWER PURR
   Correct ppc popcntb logic, implement popcntw and popcntd
   Clean up slb_lookup() function
   Parse SDR1 on mtspr instead of at translate time
   Use "hash" more consistently in ppc mmu code
   Better factor the ppc hash translation path
   Support 1T segments on ppc
   Add POWER7 support for ppc
   Start implementing pSeries logical partition machine
   Implement the bus structure for PAPR virtual IO
   Virtual hash page table handling on pSeries machine
   Implement hcall based RTAS for pSeries machines
   Implement assorted pSeries hcalls and RTAS methods
   Implement the PAPR (pSeries) virtualized interrupt controller (xics)
   Add PAPR H_VIO_SIGNAL hypercall and infrastructure for VIO interrupts
   Add (virtual) interrupt to PAPR virtual tty device
   Implement TCE translation for sPAPR VIO
   Implement sPAPR Virtual LAN (ibmveth)
   Implement PAPR VPA functions for pSeries shared processor partitions
   Add SLOF-based partition firmware for pSeries machine, allowing more 
boot options

  .gitmodules |3 +
  Makefile|3 +-
  Makefile.target |5 +
  configure   |4 +-
  device_tree.c   |2 +-
  device_tree.h   |2 +-
  hw/ppc-viosrp.h |  216 +
  hw/ppc.c|   35 ++
  hw/ppc.h|1 +
  hw/spapr.c  |  456 ++
  hw/spapr.h  |  294 
  hw/spapr_hcall.c|  525 +
  hw/spapr_llan.c |  521 +
  hw/spapr_rtas.c |  278 +++
  hw/spapr_vio.c  |  731 +
  hw/spapr_vio.h  |  112 +
  hw/spapr_vscsi.c|  988 +++
  hw/spapr_vty.c  |  159 +++
  hw/srp.h|  240 ++
  hw/xics.c   |  486 +++
  hw/xics.h   |   39 ++
  monitor.c   |2 +-
  pc-bios/README  |5 +
  pc-bios/slof.bin|  Bin 0 ->  579072 bytes
  pc-bios/spapr-rtas.bin  |  Bin 0 ->  20 bytes
  pc-bios/spapr-rtas/Makefile |   24 +
  pc-bios/spapr-rtas/spapr-rtas.S |   37 ++
  roms/SLOF   |1 +
  target-ppc/cpu.h|   84 -
  target-ppc/helper.c |  451 +--
  target-ppc/helper.h |7 +-
  target-ppc/kvm.c|2 +-
  target-ppc/kvm_ppc.h|   11 +
  target-ppc/machine.c|6 +-
  target-ppc/op_helper.c  |   87 +++-
  target-ppc/translate.c  |   61 ++-
  target-ppc/translate_init.c |  122 +-
  37 files changed, 5723 insertions(+), 277 deletions(-)
  create mode 100644 hw/ppc-viosrp.h
  create mode 100644 hw/spapr.c
  create mode 100644 hw/spapr.h
  create mode 100644 hw/spapr_hcall.c
  create mode 100644 hw/spapr_llan.c
  create mode 100644 hw/spapr_rtas.c
  create mode 100644 hw/spapr_vio.c
  create mode 100644 hw/spapr_vio.h
  create mode 100644 hw/spapr_vscsi.c
  create mode 100644 hw/spapr_vty.c
  create mode 100644 hw/srp.h
  create mode 100644 hw/xics.c
  create mode 100644 hw/xics.h
  create mode 100644 pc-bios/slof.bin
  create mode 100755 pc-bios/spapr-rtas.bin
  create mode 100644 pc-bios/spapr-rtas/Makefile
  create mode 100644 pc-bios/spapr-rtas/spapr-rtas.S
  create mode 16 roms/SLOF







[Qemu-devel] Re: [PATCH 8/9] eepro100: Pad received short frames

2011-04-01 Thread Stefan Weil

Am 31.03.2011 23:41, schrieb Michael S. Tsirkin:

On Thu, Mar 31, 2011 at 10:33:30PM +0200, Stefan Weil wrote:

QEMU sends frames smaller than 60 bytes to ethernet nics.
This should be fixed in the networking code because normally
such frames are rejected by real NICs and their emulations.
To avoid this behaviour, other NIC emulations pad received
frames. This patch enables this workaround for eepro100, too.

All related code is marked with CONFIG_PAD_RECEIVED_FRAMES,
so emulation of the correct handling for short frames can
be restored as soon as QEMU's networking code is fixed.

Signed-off-by: Stefan Weil 


qemu networking core isn't ethernet-specific
(slirp is). That's why we don't do this in core,
so the uglification isn't worth it.


Technically it is possible to add the padding needed for ethernet frames
in slirp code (a patch was already sent to qemu-devel) and any other
code location. Ethernet devices could also set a flag about their padding
requirements, so unnecessary padding could be avoided for non-ethernet
devices like virtio.

The last time when padding was discussed here, not everybody was happy
with the current solution: it was simply the solution which required
the least efforts.

I don't think that the current solution will last forever, simply
because it does not allow testing systems which do create short frames
because they want to test the reaction on short frames or for any
other reason.

That's why I want to be able to disable the padding in the device
emulation.





---
hw/eepro100.c | 25 -
1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 500a3af..a740d2e 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -47,6 +47,14 @@
#include "eeprom93xx.h"
#include "sysemu.h"

+/* QEMU sends frames smaller than 60 bytes to ethernet nics.
+ * This should be fixed in the networking code because normally
+ * such frames are rejected by real nics and their emulations.
+ * To avoid this behaviour, other nic emulations pad received
+ * frames. The following definition enables this workaround for
+ * eepro100, too. */
+#define CONFIG_PAD_RECEIVED_FRAMES
+
#define KiB 1024

/* Debug EEPRO100 card. */
@@ -1756,19 +1764,32 @@ static ssize_t nic_receive(VLANClientState 
*nc, const uint8_t * buf, size_t size

*/
EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
uint16_t rfd_status = 0xa000;
+#if defined(CONFIG_PAD_RECEIVED_FRAMES)
+ uint8_t min_buf[60];
+#endif
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };

+#if defined(CONFIG_PAD_RECEIVED_FRAMES)
+ /* Pad to minimum Ethernet frame length */
+ if (size < sizeof(min_buf)) {
+ memcpy(min_buf, buf, size);
+ memset(&min_buf[size], 0, sizeof(min_buf) - size);
+ buf = min_buf;
+ size = sizeof(min_buf);
+ }
+#endif
+
if (s->configuration[8] & 0x80) {
/* CSMA is disabled. */
logout("%p received while CSMA is disabled\n", s);
return -1;
+#if !defined(CONFIG_PAD_RECEIVED_FRAMES)
} else if (size < 64 && (s->configuration[7] & BIT(0))) {
/* Short frame and configuration byte 7/0 (discard short receive) set:
* Short frame is discarded */
logout("%p received short frame (%zu byte)\n", s, size);
s->statistics.rx_short_frame_errors++;
-#if 0
return -1;
#endif
} else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] 
& BIT(3))) {
@@ -1847,9 +1868,11 @@ static ssize_t nic_receive(VLANClientState 
*nc, const uint8_t * buf, size_t size

"(%zu bytes); data truncated\n", rfd_size, size);
size = rfd_size;
}
+#if !defined(CONFIG_PAD_RECEIVED_FRAMES)
if (size < 64) {
rfd_status |= 0x0080;
}
+#endif
TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size 
%u\n",

rfd_command, rx.link, rx.rx_buf_addr, rfd_size));
stw_le_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status),
--
1.7.2.5







Re: [Qemu-devel] [PULL] PowerPC patch queue

2011-04-01 Thread Scott Wood
On Fri, 1 Apr 2011 18:43:33 +0200
Alexander Graf  wrote:

> Howdy,
> 
> this is the current patch queue for PowerPC. I'm very excited this time,
> as we finally have a real PPC64 target machine available to play with!

How about http://patchwork.ozlabs.org/patch/66743/?

-Scott




Re: [Qemu-devel] [PULL] PowerPC patch queue

2011-04-01 Thread Alexander Graf

On 01.04.2011, at 19:44, Scott Wood wrote:

> On Fri, 1 Apr 2011 18:43:33 +0200
> Alexander Graf  wrote:
> 
>> Howdy,
>> 
>> this is the current patch queue for PowerPC. I'm very excited this time,
>> as we finally have a real PPC64 target machine available to play with!
> 
> How about http://patchwork.ozlabs.org/patch/66743/?

Oh? Do you have more of these? :)
I'll put it into my ppc-next queue, so we'll get it next time around.


Alex




[Qemu-devel] Re: [PATCH 2/9] eepro100: Fix endianness issues

2011-04-01 Thread Stefan Weil

Am 31.03.2011 23:52, schrieb Michael S. Tsirkin:

On Thu, Mar 31, 2011 at 10:33:24PM +0200, Stefan Weil wrote:

Like other Intel devices, e100 (eepro100) uses little endian byte order.

This patch was tested with these combinations:

i386 host, i386 + mipsel guests (le-le)
mipsel host, i386 guest (le-le)
i386 host, mips + ppc guests (le-be)
mips host, i386 guest (be-le)

mips and mipsel hosts were emulated machines.

Signed-off-by: Stefan Weil 
---
hw/eepro100.c | 113 
-

1 files changed, 80 insertions(+), 33 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index f89ff17..c789767 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -20,11 +20,10 @@
* along with this program. If not, see .
*
* Tested features (i82559):
- * PXE boot (i386) ok
+ * PXE boot (i386 guest, i386 / mips / mipsel / ppc host) ok
* Linux networking (i386) ok
*
* Untested:
- * non-i386 platforms
* Windows networking
*
* References:
@@ -130,7 +129,7 @@ typedef struct {

/* Offsets to the various registers.
All accesses need not be longword aligned. */
-enum speedo_offsets {
+typedef enum {
SCBStatus = 0, /* Status Word. */
SCBAck = 1,
SCBCmd = 2, /* Rx/Command Unit command and status. */
@@ -145,7 +144,7 @@ enum speedo_offsets {
SCBpmdr = 27, /* Power Management Driver. */
SCBgctrl = 28, /* General Control. */
SCBgstat = 29, /* General Status. */
-};
+} E100RegisterOffset;

/* A speedo3 transmit buffer descriptor with two buffers... */
typedef struct {
@@ -307,7 +306,32 @@ static const uint16_t eepro100_mdi_mask[] = {
0x, 0x, 0x, 0x, 0x, 0x, 0x, 0x,
};

-/* XXX: optimize */
+/* Read a 16 bit little endian value from physical memory. */
+static uint16_t lduw_le_phys(target_phys_addr_t addr)
+{
+ /* Load 16 bit (little endian) word from emulated hardware. */
+ uint16_t val;
+ cpu_physical_memory_read(addr, (uint8_t *)&val, sizeof(val));
+ return le16_to_cpu(val);
+}
+
+/* Read a 32 bit little endian value from physical memory. */
+static uint32_t ldl_le_phys(target_phys_addr_t addr)
+{
+ /* Load 32 bit (little endian) word from emulated hardware. */
+ uint32_t val;
+ cpu_physical_memory_read(addr, (uint8_t *)&val, sizeof(val));
+ return le32_to_cpu(val);
+}
+
+/* Write a 16 bit little endian value to physical memory. */
+static void stw_le_phys(target_phys_addr_t addr, uint16_t val)
+{
+ val = cpu_to_le16(val);
+ cpu_physical_memory_write(addr, (const uint8_t *)&val, sizeof(val));
+}
+
+/* Write a 32 bit little endian value to physical memory. */


So why not opencode e.g.
le32_to_cpu(ldl_phys(addr))

wrappers really worth it? What do I miss?

If you insist on these online wrappers, pls prefix
them with eepro100_.
Also, why not use lduw_phys and friends internally?
cpu_physical_ is slower ...


static void stl_le_phys(target_phys_addr_t addr, uint32_t val)
{
val = cpu_to_le32(val);
@@ -339,6 +363,32 @@ static unsigned compute_mcast_idx(const uint8_t 
* ep)

return (crc & BITS(7, 2)) >> 2;
}

+/* Read a 16 bit control/status (CSR) register. */
+static uint16_t e100_read_reg2(EEPRO100State *s, E100RegisterOffset 
addr)

+{
+ return le16_to_cpup((uint16_t *)&s->mem[addr]);
+}
+
+/* Read a 32 bit control/status (CSR) register. */
+static uint32_t e100_read_reg4(EEPRO100State *s, E100RegisterOffset 
addr)

+{
+ return le32_to_cpup((uint32_t *)&s->mem[addr]);
+}
+
+/* Write a 16 bit control/status (CSR) register. */
+static void e100_write_reg2(EEPRO100State *s, E100RegisterOffset addr,
+ uint16_t val)
+{
+ cpu_to_le16w((uint16_t *)&s->mem[addr], val);
+}
+
+/* Read a 32 bit control/status (CSR) register. */
+static void e100_write_reg4(EEPRO100State *s, E100RegisterOffset addr,
+ uint32_t val)
+{
+ cpu_to_le32w((uint32_t *)&s->mem[addr], val);
+}
+


Note that cpu_to_le32w requires an aligned address, unlike
memcpy, and there's no guarantee
addr is aligned apparently?

If true you need to memcpy to a 32 bit variable, then
cpu_to_le32w ther result.



[snip]

Thank you for your review, especially for the hints at lduw_phys
and potential alignment issues. I'll apply them to a new version
of this patch.

There was already a function without prefix (stl_le_phys),
and the new ones belong to the same "family". There is nothing
e100 specific in them, so they might be added to qemu-common.h
as well. That was (and is) the reason why I did not add a prefix.




Re: [Qemu-devel] [PULL] PowerPC patch queue

2011-04-01 Thread Scott Wood
On Fri, 1 Apr 2011 19:49:35 +0200
Alexander Graf  wrote:

> 
> On 01.04.2011, at 19:44, Scott Wood wrote:
> 
> > On Fri, 1 Apr 2011 18:43:33 +0200
> > Alexander Graf  wrote:
> > 
> >> Howdy,
> >> 
> >> this is the current patch queue for PowerPC. I'm very excited this time,
> >> as we finally have a real PPC64 target machine available to play with!
> > 
> > How about http://patchwork.ozlabs.org/patch/66743/?
> 
> Oh? Do you have more of these? :)

Soon. :-)

> I'll put it into my ppc-next queue, so we'll get it next time around.

OK.

-Scott




Re: [Qemu-devel] [PATCH 06/27] Correct ppc popcntb logic, implement popcntw and popcntd

2011-04-01 Thread Aurelien Jarno
On Fri, Apr 01, 2011 at 03:15:13PM +1100, David Gibson wrote:
> From: David Gibson 
> 
> qemu already includes support for the popcntb instruction introduced
> in POWER5 (although it doesn't actually allow you to choose POWER5).
> 
> However, the logic is slightly incorrect: it will generate results
> truncated to 32-bits when the CPU is in 32-bit mode.  This is not
> normal for powerpc - generally arithmetic instructions on a 64-bit
> powerpc cpu will generate full 64 bit results, it's just that only the
> low 32 bits will be significant for condition codes.
> 
> This patch corrects this nit, which actually simplifies the code slightly.
> 
> In addition, this patch implements the popcntw and popcntd
> instructions added in POWER7, in preparation for allowing POWER7 as an
> emulated CPU.
> 
> Signed-off-by: David Gibson 
> ---
>  target-ppc/cpu.h   |2 +
>  target-ppc/helper.h|3 +-
>  target-ppc/op_helper.c |   55 +++
>  target-ppc/translate.c |   20 +
>  4 files changed, 69 insertions(+), 11 deletions(-)
> 
> diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
> index f293f85..37dde39 100644
> --- a/target-ppc/cpu.h
> +++ b/target-ppc/cpu.h
> @@ -1505,6 +1505,8 @@ enum {
>  PPC_DCRX   = 0x2000ULL,
>  /* user-mode DCR access, implemented in PowerPC 460  
> */
>  PPC_DCRUX  = 0x4000ULL,
> +/* popcntw and popcntd instructions  
> */
> +PPC_POPCNTWD   = 0x8000ULL,
>  };
>  
>  
> /*/
> diff --git a/target-ppc/helper.h b/target-ppc/helper.h
> index 2b4744d..7c02be9 100644
> --- a/target-ppc/helper.h
> +++ b/target-ppc/helper.h
> @@ -38,10 +38,11 @@ DEF_HELPER_2(mulldo, i64, i64, i64)
>  
>  DEF_HELPER_FLAGS_1(cntlzw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>  DEF_HELPER_FLAGS_1(popcntb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
> +DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>  DEF_HELPER_2(sraw, tl, tl, tl)
>  #if defined(TARGET_PPC64)
>  DEF_HELPER_FLAGS_1(cntlzd, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
> -DEF_HELPER_FLAGS_1(popcntb_64, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
> +DEF_HELPER_FLAGS_1(popcntd, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>  DEF_HELPER_2(srad, tl, tl, tl)
>  #endif
>  
> diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
> index aa2e8ba..b1b883d 100644
> --- a/target-ppc/op_helper.c
> +++ b/target-ppc/op_helper.c
> @@ -499,6 +499,50 @@ target_ulong helper_srad (target_ulong value, 
> target_ulong shift)
>  }
>  #endif
>  
> +#if defined(TARGET_PPC64)
> +target_ulong helper_popcntb (target_ulong val)
> +{
> +val = (val & 0xULL) + ((val >>  1) &
> +   0xULL);
> +val = (val & 0xULL) + ((val >>  2) &
> +   0xULL);
> +val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >>  4) &
> +   0x0f0f0f0f0f0f0f0fULL);
> +return val;
> +}
> +
> +target_ulong helper_popcntw (target_ulong val)
> +{
> +val = (val & 0xULL) + ((val >>  1) &
> +   0xULL);
> +val = (val & 0xULL) + ((val >>  2) &
> +   0xULL);
> +val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >>  4) &
> +   0x0f0f0f0f0f0f0f0fULL);
> +val = (val & 0x00ff00ff00ff00ffULL) + ((val >>  8) &
> +   0x00ff00ff00ff00ffULL);
> +val = (val & 0xULL) + ((val >> 16) &
> +   0xULL);
> +return val;
> +}
> +
> +target_ulong helper_popcntd (target_ulong val)
> +{
> +val = (val & 0xULL) + ((val >>  1) &
> +   0xULL);
> +val = (val & 0xULL) + ((val >>  2) &
> +   0xULL);
> +val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >>  4) &
> +   0x0f0f0f0f0f0f0f0fULL);
> +val = (val & 0x00ff00ff00ff00ffULL) + ((val >>  8) &
> +   0x00ff00ff00ff00ffULL);
> +val = (val & 0xULL) + ((val >> 16) &
> +   0xULL);
> +val = (val & 0xULL) + ((val >> 32) &
> +   0xULL);
> +return val;
> +}

I probably arrive a bit late, but note that for this one you can use
ctpop64() (from host-utils.h), which also uses a GCC builtin when
available.

> +#else
>  target_ulong helper_popcntb (target_ulong val)
>

Re: [Qemu-devel] [PATCH 06/27] Correct ppc popcntb logic, implement popcntw and popcntd

2011-04-01 Thread Alexander Graf

On 01.04.2011, at 19:58, Aurelien Jarno wrote:

> On Fri, Apr 01, 2011 at 03:15:13PM +1100, David Gibson wrote:
>> From: David Gibson 
>> 
>> qemu already includes support for the popcntb instruction introduced
>> in POWER5 (although it doesn't actually allow you to choose POWER5).
>> 
>> However, the logic is slightly incorrect: it will generate results
>> truncated to 32-bits when the CPU is in 32-bit mode.  This is not
>> normal for powerpc - generally arithmetic instructions on a 64-bit
>> powerpc cpu will generate full 64 bit results, it's just that only the
>> low 32 bits will be significant for condition codes.
>> 
>> This patch corrects this nit, which actually simplifies the code slightly.
>> 
>> In addition, this patch implements the popcntw and popcntd
>> instructions added in POWER7, in preparation for allowing POWER7 as an
>> emulated CPU.
>> 
>> Signed-off-by: David Gibson 
>> ---
>> target-ppc/cpu.h   |2 +
>> target-ppc/helper.h|3 +-
>> target-ppc/op_helper.c |   55 +++
>> target-ppc/translate.c |   20 +
>> 4 files changed, 69 insertions(+), 11 deletions(-)
>> 
>> diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
>> index f293f85..37dde39 100644
>> --- a/target-ppc/cpu.h
>> +++ b/target-ppc/cpu.h
>> @@ -1505,6 +1505,8 @@ enum {
>> PPC_DCRX   = 0x2000ULL,
>> /* user-mode DCR access, implemented in PowerPC 460  
>> */
>> PPC_DCRUX  = 0x4000ULL,
>> +/* popcntw and popcntd instructions 
>>  */
>> +PPC_POPCNTWD   = 0x8000ULL,
>> };
>> 
>> /*/
>> diff --git a/target-ppc/helper.h b/target-ppc/helper.h
>> index 2b4744d..7c02be9 100644
>> --- a/target-ppc/helper.h
>> +++ b/target-ppc/helper.h
>> @@ -38,10 +38,11 @@ DEF_HELPER_2(mulldo, i64, i64, i64)
>> 
>> DEF_HELPER_FLAGS_1(cntlzw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>> DEF_HELPER_FLAGS_1(popcntb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>> +DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>> DEF_HELPER_2(sraw, tl, tl, tl)
>> #if defined(TARGET_PPC64)
>> DEF_HELPER_FLAGS_1(cntlzd, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>> -DEF_HELPER_FLAGS_1(popcntb_64, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>> +DEF_HELPER_FLAGS_1(popcntd, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
>> DEF_HELPER_2(srad, tl, tl, tl)
>> #endif
>> 
>> diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
>> index aa2e8ba..b1b883d 100644
>> --- a/target-ppc/op_helper.c
>> +++ b/target-ppc/op_helper.c
>> @@ -499,6 +499,50 @@ target_ulong helper_srad (target_ulong value, 
>> target_ulong shift)
>> }
>> #endif
>> 
>> +#if defined(TARGET_PPC64)
>> +target_ulong helper_popcntb (target_ulong val)
>> +{
>> +val = (val & 0xULL) + ((val >>  1) &
>> +   0xULL);
>> +val = (val & 0xULL) + ((val >>  2) &
>> +   0xULL);
>> +val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >>  4) &
>> +   0x0f0f0f0f0f0f0f0fULL);
>> +return val;
>> +}
>> +
>> +target_ulong helper_popcntw (target_ulong val)
>> +{
>> +val = (val & 0xULL) + ((val >>  1) &
>> +   0xULL);
>> +val = (val & 0xULL) + ((val >>  2) &
>> +   0xULL);
>> +val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >>  4) &
>> +   0x0f0f0f0f0f0f0f0fULL);
>> +val = (val & 0x00ff00ff00ff00ffULL) + ((val >>  8) &
>> +   0x00ff00ff00ff00ffULL);
>> +val = (val & 0xULL) + ((val >> 16) &
>> +   0xULL);
>> +return val;
>> +}
>> +
>> +target_ulong helper_popcntd (target_ulong val)
>> +{
>> +val = (val & 0xULL) + ((val >>  1) &
>> +   0xULL);
>> +val = (val & 0xULL) + ((val >>  2) &
>> +   0xULL);
>> +val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >>  4) &
>> +   0x0f0f0f0f0f0f0f0fULL);
>> +val = (val & 0x00ff00ff00ff00ffULL) + ((val >>  8) &
>> +   0x00ff00ff00ff00ffULL);
>> +val = (val & 0xULL) + ((val >> 16) &
>> +   0xULL);
>> +val = (val & 0xULL) + ((val >> 32) &
>> +   0xULL);
>> +return val;
>> +}
> 
> I probably arrive a bit late, but note that for this one you can use

[Qemu-devel] [Bug 747583] [NEW] Windows 2008 Time Zone Change Even When Using -locatime

2011-04-01 Thread Preston Connors
Public bug reported:

* What cpu model : Intel(R) Xeon(R) CPU E5620  @ 2.40GHz
* What kvm version you are using. : qemu-kvm-0.12.3
* The host kernel version : 2.6.32-30-server
* What host kernel arch you are using (i386 or x86_64) : x86_64
* What guest you are using, including OS type: Windows 2008 Enterprise x86_64
* The qemu command line you are using to start the guest : /usr/bin/kvm -S -M 
pc-0.12 -enable-kvm -m 1024 -smp 1 -name 2-6176 -uuid 
4d1d56b1-d0b7-506b-31a5-a87c8cb0560b -chardev 
socket,id=monitor,path=/var/lib/libvirt/qemu/2-6176.monitor,server,nowait 
-monitor chardev:monitor -localtime -boot c -drive 
file=/dev/disk/by-id/scsi-3600144f05c1109004d9602950073,if=virtio,index=0,boot=on,format=raw
 -drive 
file=/dev/disk/by-id/scsi-3600144f0eae881004c7bb0920037,if=ide,media=cdrom,index=2,format=raw
 -net nic,macaddr=00:00:d1:d0:3f:5e,vlan=0,name=nic.1 -net 
tap,fd=212,vlan=0,name=tap.1 -net 
nic,macaddr=00:00:0a:d0:3f:5e,vlan=1,name=nic.1 -net 
tap,fd=213,vlan=1,name=tap.1 -chardev pty,id=serial0 -serial chardev:serial0 
-parallel none -usb -usbdevice tablet -vnc 0.0.0.0:394,password -k en-us -vga 
cirrus
* Whether the problem goes away if using the -no-kvm-irqchip or -no-kvm-pit 
switch. : Unable to test
* Whether the problem also appears with the -no-kvm switch. : Unable to test

Host time zone: EDT Guest time zone: PDT

Steps to reproduce:
1) Set time zone to (GMT-08:00) Pacific Time (US & Canada) on guest
2) Power off Windows 2008 Enterprise x86_64 guest completely. Ensure the kvm 
process exits.
3) Power on Windows 2008 Enterprise x86_64 guest using virsh start 
4) Server will show EDT time but have the time zone still set to (GMT-08:00) 
Pacific Time (US & Canada).

Syncing the time after stopping and starting the kvm process using
Windows "Internet Time" ntp time sync will sync the time to the correct
PDT time.

Doing a reboot from within the guest's operating system where kvm does
not exit will not cause the timezone shift to happen.

** 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/747583

Title:
  Windows 2008 Time Zone Change Even When Using -locatime

Status in QEMU:
  New

Bug description:
  * What cpu model : Intel(R) Xeon(R) CPU E5620  @ 2.40GHz
  * What kvm version you are using. : qemu-kvm-0.12.3
  * The host kernel version : 2.6.32-30-server
  * What host kernel arch you are using (i386 or x86_64) : x86_64
  * What guest you are using, including OS type: Windows 2008 Enterprise x86_64
  * The qemu command line you are using to start the guest : /usr/bin/kvm -S -M 
pc-0.12 -enable-kvm -m 1024 -smp 1 -name 2-6176 -uuid 
4d1d56b1-d0b7-506b-31a5-a87c8cb0560b -chardev 
socket,id=monitor,path=/var/lib/libvirt/qemu/2-6176.monitor,server,nowait 
-monitor chardev:monitor -localtime -boot c -drive 
file=/dev/disk/by-id/scsi-3600144f05c1109004d9602950073,if=virtio,index=0,boot=on,format=raw
 -drive 
file=/dev/disk/by-id/scsi-3600144f0eae881004c7bb0920037,if=ide,media=cdrom,index=2,format=raw
 -net nic,macaddr=00:00:d1:d0:3f:5e,vlan=0,name=nic.1 -net 
tap,fd=212,vlan=0,name=tap.1 -net 
nic,macaddr=00:00:0a:d0:3f:5e,vlan=1,name=nic.1 -net 
tap,fd=213,vlan=1,name=tap.1 -chardev pty,id=serial0 -serial chardev:serial0 
-parallel none -usb -usbdevice tablet -vnc 0.0.0.0:394,password -k en-us -vga 
cirrus
  * Whether the problem goes away if using the -no-kvm-irqchip or -no-kvm-pit 
switch. : Unable to test
  * Whether the problem also appears with the -no-kvm switch. : Unable to test

  Host time zone: EDT Guest time zone: PDT

  Steps to reproduce:
  1) Set time zone to (GMT-08:00) Pacific Time (US & Canada) on guest
  2) Power off Windows 2008 Enterprise x86_64 guest completely. Ensure the kvm 
process exits.
  3) Power on Windows 2008 Enterprise x86_64 guest using virsh start 
  4) Server will show EDT time but have the time zone still set to (GMT-08:00) 
Pacific Time (US & Canada).

  Syncing the time after stopping and starting the kvm process using
  Windows "Internet Time" ntp time sync will sync the time to the
  correct PDT time.

  Doing a reboot from within the guest's operating system where kvm does
  not exit will not cause the timezone shift to happen.



[Qemu-devel] [PATCH v25 01/10] trace: move trace objects from Makefile to Makefile.objs

2011-04-01 Thread Alon Levy
---
 Makefile  |   32 
 Makefile.objs |   32 
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/Makefile b/Makefile
index 89e88b4..209e14d 100644
--- a/Makefile
+++ b/Makefile
@@ -112,38 +112,6 @@ ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
 
 bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
 
-ifeq ($(TRACE_BACKEND),dtrace)
-trace.h: trace.h-timestamp trace-dtrace.h
-else
-trace.h: trace.h-timestamp
-endif
-trace.h-timestamp: $(SRC_PATH)/trace-events config-host.mak
-   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -h < $< > $@,"  GEN   trace.h")
-   @cmp -s $@ trace.h || cp $@ trace.h
-
-trace.c: trace.c-timestamp
-trace.c-timestamp: $(SRC_PATH)/trace-events config-host.mak
-   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -c < $< > $@,"  GEN   trace.c")
-   @cmp -s $@ trace.c || cp $@ trace.c
-
-trace.o: trace.c $(GENERATED_HEADERS)
-
-trace-dtrace.h: trace-dtrace.dtrace
-   $(call quiet-command,dtrace -o $@ -h -s $<, "  GEN   trace-dtrace.h")
-
-# Normal practice is to name DTrace probe file with a '.d' extension
-# but that gets picked up by QEMU's Makefile as an external dependancy
-# rule file. So we use '.dtrace' instead
-trace-dtrace.dtrace: trace-dtrace.dtrace-timestamp
-trace-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events config-host.mak
-   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -d < $< > $@,"  GEN   trace-dtrace.dtrace")
-   @cmp -s $@ trace-dtrace.dtrace || cp $@ trace-dtrace.dtrace
-
-trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS)
-   $(call quiet-command,dtrace -o $@ -G -s $<, "  GEN trace-dtrace.o")
-
-simpletrace.o: simpletrace.c $(GENERATED_HEADERS)
-
 version.o: $(SRC_PATH)/version.rc config-host.mak
$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC$(TARGET_DIR)$@")
 
diff --git a/Makefile.objs b/Makefile.objs
index 42301fd..d906a8e 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -310,6 +310,38 @@ libdis-$(CONFIG_SPARC_DIS) += sparc-dis.o
 # trace
 
 ifeq ($(TRACE_BACKEND),dtrace)
+trace.h: trace.h-timestamp trace-dtrace.h
+else
+trace.h: trace.h-timestamp
+endif
+trace.h-timestamp: $(SRC_PATH)/trace-events config-host.mak
+   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -h < $< > $@,"  GEN   trace.h")
+   @cmp -s $@ trace.h || cp $@ trace.h
+
+trace.c: trace.c-timestamp
+trace.c-timestamp: $(SRC_PATH)/trace-events config-host.mak
+   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -c < $< > $@,"  GEN   trace.c")
+   @cmp -s $@ trace.c || cp $@ trace.c
+
+trace.o: trace.c $(GENERATED_HEADERS)
+
+trace-dtrace.h: trace-dtrace.dtrace
+   $(call quiet-command,dtrace -o $@ -h -s $<, "  GEN   trace-dtrace.h")
+
+# Normal practice is to name DTrace probe file with a '.d' extension
+# but that gets picked up by QEMU's Makefile as an external dependancy
+# rule file. So we use '.dtrace' instead
+trace-dtrace.dtrace: trace-dtrace.dtrace-timestamp
+trace-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events config-host.mak
+   $(call quiet-command,sh $(SRC_PATH)/scripts/tracetool 
--$(TRACE_BACKEND) -d < $< > $@,"  GEN   trace-dtrace.dtrace")
+   @cmp -s $@ trace-dtrace.dtrace || cp $@ trace-dtrace.dtrace
+
+trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS)
+   $(call quiet-command,dtrace -o $@ -G -s $<, "  GEN trace-dtrace.o")
+
+simpletrace.o: simpletrace.c $(GENERATED_HEADERS)
+
+ifeq ($(TRACE_BACKEND),dtrace)
 trace-obj-y = trace-dtrace.o
 else
 trace-obj-y = trace.o
-- 
1.7.4.2




Re: [Qemu-devel] [0/27] Implement emulation of pSeries logical partitions (v6)

2011-04-01 Thread Alexander Graf

On 01.04.2011, at 19:28, Anthony Liguori wrote:

> On 03/31/2011 11:15 PM, David Gibson wrote:
>> This patch series adds a "pseries" machine to qemu, allowing it to
>> emulate IBM pSeries logical partitions.  More specifically it
>> implements the interface defined by the "PowerPC Architecture Platform
>> Requirements" document (PAPR, or sPAPR for short).
>> 
>> Along the way we add a bunch of support for more modern ppc CPUs than
>> are currently supported.  It also makes some significant cleanups to
>> the translation code for hash page table based ppc MMUs.
>> 
>> Please apply.
> 
> So what's a typical invocation for this?  Is:
> 
> qemu-system-ppc64 -m pseries foo.img -nographics

If you run an image that requires firmare, you also need to pass in -m with at 
least 512MB, otherwise yes, that's how it works :).


Alex




Re: [Qemu-devel] [PATCH V2 4/9] Add tpm_tis driver to build process

2011-04-01 Thread Blue Swirl
On Wed, Mar 30, 2011 at 10:42 PM, Stefan Berger
 wrote:
> The TPM interface (tpm_tis) needs to be explicitly enabled via
> ./configure --enable-tpm. This restricts the building of the
> TPM support to i386 and x86_64 targets since both backends I know
> of, the Xen backend and the libtpms-based backend, will likely only
> be available for these targets, at least initially. The list can be
> easily extend. This measure prevents that one will end up with support
> for a frontend but no available backend.
>
> Signed-off-by: Stefan Berger 
>
> Index:qemu/Makefile.target
> ===
> ---
>  Makefile.target |    7 +++
>  configure       |   20 
>  2 files changed, 27 insertions(+)
>
> Index: qemu-git/Makefile.target
> ===
> --- qemu-git.orig/Makefile.target
> +++ qemu-git/Makefile.target
> @@ -303,6 +303,13 @@ obj-sparc-y += cs4231.o eccmemctl.o sbi.
>
>  # GRLIB
>  obj-sparc-y += grlib_gptimer.o grlib_irqmp.o grlib_apbuart.o
> +
> +ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),i386 x86_64))

The ifeq above is not needed since the line below uses obj-i386.

> +
> +obj-i386-$(CONFIG_TPM) += tpm_tis.o
> +
> +endif
> +
>  endif
>
>  obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o
> Index: qemu-git/configure
> ===
> --- qemu-git.orig/configure
> +++ qemu-git/configure
> @@ -175,6 +175,7 @@ trace_backend="nop"
>  trace_file="trace"
>  spice=""
>  rbd=""
> +tpm="no"
>
>  # parse CC options first
>  for opt do
> @@ -708,6 +709,8 @@ for opt do
>   ;;
>   --kerneldir=*) kerneldir="$optarg"
>   ;;
> +  --enable-tpm) tpm="yes"
> +  ;;
>   --with-pkgversion=*) pkgversion=" ($optarg)"
>   ;;
>   --disable-docs) docs="no"
> @@ -921,6 +924,7 @@ echo "                           Default
>  echo "  --disable-spice          disable spice"
>  echo "  --enable-spice           enable spice"
>  echo "  --enable-rbd             enable building the rados block device 
> (rbd)"
> +echo "  --enable-tpm             enables an emulated TPM"
>  echo ""
>  echo "NOTE: The object files are built at the place where configure is 
> launched"
>  exit 1
> @@ -2540,6 +2544,7 @@ echo "Trace output file $trace_file-  echo "spice support     $spice"
>  echo "rbd support       $rbd"
>  echo "xfsctl support    $xfs"
> +echo "TPM support       $tpm"
>
>  if test $sdl_too_old = "yes"; then
>  echo "-> Your SDL version is too old - please upgrade to have SDL support"
> @@ -3324,6 +3329,21 @@ if test "$gprof" = "yes" ; then
>   fi
>  fi
>
> +if test "$linux" = "yes" && test "$tpm" = "yes"; then
> +  has_tpm=0
> +  if test "$target_softmmu" = "yes" ; then
> +    case "$TARGET_BASE_ARCH" in
> +    i386)
> +      has_tpm=1

This is not a real compile test, please try to build a dummy program
that depends on TPM headers like for example preadv probe. Then it is
not needed to check for Linux or i386 explicitly.



Re: [Qemu-devel] [PATCH 01/10] target-arm: Make Neon helper routines use correct FP status

2011-04-01 Thread Blue Swirl
On Fri, Apr 1, 2011 at 5:30 PM, Peter Maydell  wrote:
> Make the Neon helper routines use the correct FP status from
> the CPUEnv rather than using a dummy static one. This means
> they will correctly handle denormals and NaNs and will set
> FPSCR exception bits properly.
>
> Signed-off-by: Peter Maydell 
> ---
>  target-arm/helpers.h     |   22 +++---
>  target-arm/neon_helper.c |   21 ++---
>  target-arm/translate.c   |   42 ++
>  3 files changed, 43 insertions(+), 42 deletions(-)
>
> diff --git a/target-arm/helpers.h b/target-arm/helpers.h
> index bd6977c..e2260b6 100644
> --- a/target-arm/helpers.h
> +++ b/target-arm/helpers.h
> @@ -350,17 +350,17 @@ DEF_HELPER_2(neon_qneg_s8, i32, env, i32)
>  DEF_HELPER_2(neon_qneg_s16, i32, env, i32)
>  DEF_HELPER_2(neon_qneg_s32, i32, env, i32)
>
> -DEF_HELPER_2(neon_min_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_max_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_abd_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_add_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_sub_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_mul_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_ceq_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_cge_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_cgt_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_acge_f32, i32, i32, i32)
> -DEF_HELPER_2(neon_acgt_f32, i32, i32, i32)
> +DEF_HELPER_3(neon_min_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_max_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_abd_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_add_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_sub_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_mul_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_ceq_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_cge_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_cgt_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_acge_f32, i32, env, i32, i32)
> +DEF_HELPER_3(neon_acgt_f32, i32, env, i32, i32)
>
>  /* iwmmxt_helper.c */
>  DEF_HELPER_2(iwmmxt_maddsq, i64, i64, i64)
> diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c
> index 002a9c1..97bc1e6 100644
> --- a/target-arm/neon_helper.c
> +++ b/target-arm/neon_helper.c
> @@ -18,8 +18,7 @@
>
>  #define SET_QC() env->vfp.xregs[ARM_VFP_FPSCR] = CPSR_Q
>
> -static float_status neon_float_status;
> -#define NFS &neon_float_status
> +#define NFS (&env->vfp.standard_fp_status)
>
>  /* Helper routines to perform bitwise copies between float and int.  */
>  static inline float32 vfp_itos(uint32_t i)
> @@ -1794,21 +1793,21 @@ uint32_t HELPER(neon_qneg_s32)(CPUState *env, 
> uint32_t x)
>  }
>
>  /* NEON Float helpers.  */
> -uint32_t HELPER(neon_min_f32)(uint32_t a, uint32_t b)
> +uint32_t HELPER(neon_min_f32)(CPUState *env, uint32_t a, uint32_t b)

I didn't check, but if neon_helper.c is compiled like op_helper.c,
passing env should not be needed. If that is not the case, the
functions could be moved to op_helper.c.



[Qemu-devel] [Bug 720787] Re: Fails to compile on MacOS

2011-04-01 Thread Nigel Horne
It's moved on a bit.  Qemu still fails to compile, but this is the
latest error:

  CCi386-darwin-user/main.o
cc1: warning: /Users/nigel/src/qemu/darwin-user/i386: No such file or directory

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

Title:
  Fails to compile on MacOS

Status in QEMU:
  New

Bug description:
  Make fails with:

  qemu-thread.c: In function 'qemu_mutex_timedlock':
  qemu-thread.c:75: warning: implicit declaration of function 'clock_gettime'
  qemu-thread.c:75: warning: nested extern declaration of 'clock_gettime'
  qemu-thread.c:75: error: 'CLOCK_REALTIME' undeclared (first use in this 
function)
  qemu-thread.c:75: error: (Each undeclared identifier is reported only once
  qemu-thread.c:75: error: for each function it appears in.)
  qemu-thread.c:78: warning: implicit declaration of function 
'pthread_mutex_timedlock'
  qemu-thread.c:78: warning: nested extern declaration of 
'pthread_mutex_timedlock'
  qemu-thread.c: In function 'qemu_cond_timedwait':
  qemu-thread.c:143: error: 'CLOCK_REALTIME' undeclared (first use in this 
function)
  make: *** [qemu-thread.o] Error 1

  On Git commit commit 79f2b6fcdb7c06cdce6eccc796f5651f3efb843e

  Using "configure --enable-io-thread"



Re: [Qemu-devel] GSoC: Improved image format compatibility

2011-04-01 Thread Lyu Mitnick
Hello

I have some question about asynchronous i/o in QEMU block driver: Why a file
format with asynchronous i/o support(ex. qcow) doesn't need to register
bdrv_read/bdrv_write which is registered in vhd file format?? Would qcow
block driver
also support synchronous i/o??

thanks a lot

Mitnick

2011/4/2 Kevin Wolf 

> Am 01.04.2011 17:15, schrieb Lyu Mitnick:
> > Hello Stefan
> >
> > Hello Mitnick,
> >
> > asynchronous i/o is also missing in block/vpc.c.
> >
> > All newer block drivers support asynchronous reads and writes,
> > only some old drivers don't.
> >
> > So adding asynchronous i/o to at least some of the old drivers
> > would improve their usability.
> >
> > Look for "aio" in block/*.c to get a starting point.
> >
> > Regards
> > Stefan (W.)
> >
> >
> > I look for "aio" in block/*.c as a starting point of asynchronous i/o.
> > And I
> > found that there isn't any "aio" keywords in block/vmdk.c. block/vmdk.c
> > is used as block driver for the VMDK format. Is it means that
> asynchronous
> > i/o is also missing in VMDK format?
>
> Yes, the VMDK implementation is completely synchronous.
>
> Kevin
>


Re: [Qemu-devel] [PATCH 10/10] target-arm/helper.c: For float-int conversion helpers pass ints as ints

2011-04-01 Thread Blue Swirl
On Fri, Apr 1, 2011 at 5:30 PM, Peter Maydell  wrote:
> Correct the argument and return types for the float<->int conversion helper
> functions so that integer arguments and return values are declared as
> uint32_t/uint64_t, not float32/float64. This allows us to remove the
> hand-rolled functions which were doing bitwise copies between the types
> via unions.
>
> Signed-off-by: Peter Maydell 
> Reviewed-by: Nathan Froyd 
> ---
>  target-arm/helper.c  |  155 
> ++
>  target-arm/helpers.h |   60 ++--
>  2 files changed, 85 insertions(+), 130 deletions(-)
>
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index 78f3d39..6788a4c 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -2486,135 +2486,90 @@ DO_VFP_cmp(s, float32)
>  DO_VFP_cmp(d, float64)
>  #undef DO_VFP_cmp
>
> -/* Helper routines to perform bitwise copies between float and int.  */
> -static inline float32 vfp_itos(uint32_t i)
> -{
> -    union {
> -        uint32_t i;
> -        float32 s;
> -    } v;
> -
> -    v.i = i;
> -    return v.s;
> -}
> -
> -static inline uint32_t vfp_stoi(float32 s)
> -{
> -    union {
> -        uint32_t i;
> -        float32 s;
> -    } v;
> -
> -    v.s = s;
> -    return v.i;
> -}
> -
> -static inline float64 vfp_itod(uint64_t i)
> -{
> -    union {
> -        uint64_t i;
> -        float64 d;
> -    } v;
> -
> -    v.i = i;
> -    return v.d;
> -}
> -
> -static inline uint64_t vfp_dtoi(float64 d)
> -{
> -    union {
> -        uint64_t i;
> -        float64 d;
> -    } v;
> -
> -    v.d = d;
> -    return v.i;
> -}
> -
>  /* Integer to float conversion.  */
> -float32 VFP_HELPER(uito, s)(float32 x, CPUState *env)
> +float32 VFP_HELPER(uito, s)(uint32_t x, CPUState *env)

If you moved these functions to op_helper.c, passing env would not be
needed anymore.

Another possible optimization is that maybe the softfloat functions
could be used directly as helpers if type of fp_status could be
changed to something that can be passed in a register, like uint32_t.
This would be useful for most targets.



Re: [Qemu-devel] [PATCH 2/2] checkpatch.pl: make C99 comments a warning, not error

2011-04-01 Thread Blue Swirl
On Fri, Apr 1, 2011 at 6:20 PM, Michael Roth  wrote:
> C99 comments are pretty heavilly used in QEMU, and don't violate
> anything mentioned in HACKING/CODING_STYLE. Make them warnings instead.
>
> Signed-off-by: Michael Roth 
> ---
>  scripts/checkpatch.pl |    2 +-
>  test.c                |    5 +
>  2 files changed, 6 insertions(+), 1 deletions(-)
>  create mode 100644 test.c
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 770d534..2aab4e9 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1799,7 +1799,7 @@ sub process {
>
>  # no C99 // comments
>                if ($line =~ m{//}) {
> -                       ERROR("do not use C99 // comments\n" . $herecurr);
> +                       WARN("do not use C99 // comments\n" . $herecurr);

I think the only reasonable use for C99 comments is
//#define DEBUG_xyz
for quickly enabling debugging printfs.

But even this pattern should be replaced by tracepoints, since they
are much better. So I'd prefer to keep the ERROR.



[Qemu-devel] [PATCH] virtio-9p: Return ENOSYS for unhandled requests.

2011-04-01 Thread Kusanagi Kouichi
Linux 2.6.39-rc1 guest causes qemu to abort when it sync or umount
a rw 9p mount.

Signed-off-by: Kusanagi Kouichi 
---
 hw/virtio-9p.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 7c59988..03cd957 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -3597,9 +3597,11 @@ static void submit_pdu(V9fsState *s, V9fsPDU *pdu)
 BUG_ON(pdu->id >= ARRAY_SIZE(pdu_handlers));
 
 handler = pdu_handlers[pdu->id];
-BUG_ON(handler == NULL);
-
-handler(s, pdu);
+if (handler == NULL) {
+complete_pdu(s, pdu, ENOSYS);
+} else {
+handler(s, pdu);
+}
 }
 
 static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
-- 
1.7.4.1




Re: [Qemu-devel] [0/27] Implement emulation of pSeries logical partitions (v6)

2011-04-01 Thread Anthony Liguori

On 04/01/2011 01:01 PM, Alexander Graf wrote:

On 01.04.2011, at 19:28, Anthony Liguori wrote:


On 03/31/2011 11:15 PM, David Gibson wrote:

This patch series adds a "pseries" machine to qemu, allowing it to
emulate IBM pSeries logical partitions.  More specifically it
implements the interface defined by the "PowerPC Architecture Platform
Requirements" document (PAPR, or sPAPR for short).

Along the way we add a bunch of support for more modern ppc CPUs than
are currently supported.  It also makes some significant cleanups to
the translation code for hash page table based ppc MMUs.

Please apply.

So what's a typical invocation for this?  Is:

qemu-system-ppc64 -m pseries foo.img -nographics

If you run an image that requires firmare, you also need to pass in -m with at 
least 512MB, otherwise yes, that's how it works :).


FYI, trying to do a Debian install results in:

Trying to write invalid spr 536 218 at 014034d4

Followed by a tight loop of writing empty characters to the serial port.

My command is:

ppc64-softmmu/qemu-system-ppc64 -cdrom 
~/isos/debian-6.0.1a-powerpc-DVD-1.iso -boot d -m 512 -serial vc 
-monitor stdio -M pseries


Regards,

Anthony Liguori


Alex







Re: [Qemu-devel] [0/27] Implement emulation of pSeries logical partitions (v6)

2011-04-01 Thread Anthony Liguori

On 04/01/2011 01:01 PM, Alexander Graf wrote:

On 01.04.2011, at 19:28, Anthony Liguori wrote:


On 03/31/2011 11:15 PM, David Gibson wrote:

This patch series adds a "pseries" machine to qemu, allowing it to
emulate IBM pSeries logical partitions.  More specifically it
implements the interface defined by the "PowerPC Architecture Platform
Requirements" document (PAPR, or sPAPR for short).

Along the way we add a bunch of support for more modern ppc CPUs than
are currently supported.  It also makes some significant cleanups to
the translation code for hash page table based ppc MMUs.

Please apply.

So what's a typical invocation for this?  Is:

qemu-system-ppc64 -m pseries foo.img -nographics

If you run an image that requires firmare, you also need to pass in -m with at 
least 512MB, otherwise yes, that's how it works :).



Here's the output on the serial console.  Looks like it's in a tight 
loop probably writing \r or something and redrawing the prompt which our 
console emulation doesn't like.


E3406: Client application returned an error:undefined word

..`. .. ...  ..   ..  ...
..`...`''.`'. .''``..''.   .`''```''`.  `''``
   .`` .:' ': `''.  .''.   ''` .''..''...
 ``.':.';. ``''`.''.  .''.  ''``''`'`
 ``.':':`   .`''.`'`.. `'`.`''.`'`
.`.`'``   .'`'`.  ``''  ``''`'''`. `'`
  Type 'boot'  and press return  to  continue  booting  the system.
  Type 'reset-all'  and  press  return  to   reboot   the   system.



( 700 ) Program Exception [ 1 ]


R0 .. R7   R8 .. R15 R16 .. R23 R24 .. R31
0e14c0b8      0e952e14   0e952e16
0e952da0      0001   0e952e18
0e10e680         0e953020
   0e950008   0001   
   4824   0e1069d0   
0001      0e952e15   0e952f17
0e138020      0e952e10   0008
0e14c0c8   0e950010   0003   60002c05

CR / XER   LR / CTR  SRR0 / SRR1DAR / DSISR
8822   0028   0049c33c   
2000      00082000   


Regards,

Anthony Liguori


Alex







Re: [Qemu-devel] [PATCH v3] ui/sdl: Load optional QEMU icon

2011-04-01 Thread Aurelien Jarno
On Wed, Feb 16, 2011 at 09:15:40PM +0100, Stefan Weil wrote:
> Load an optional QEMU icon file. If there is no icon file named
> qemu.bmp in QEMU's default search path, QEMU will run with
> the usual system default icon.
> 
> A matching icon file  will be loaded and used by X Windows managers
> or MS Windows while a QEMU instance is running.
> 
> SDL requires icon files in 32x32x4 bmp format.
> 
> v2:
> The first version of this patch also included qemu-icon.bmp
> and rules to handle this file. That part will now be published
> in a separate patch as soon as the QEMU community has chosen
> a common QEMU icon. The SDL code here is useful to try
> different icons.
> 
> v3:
> White pixels are now used for transparency.
> This needs a 16 colour bmp file.
> 
> Cc: Anthony Liguori 
> Signed-off-by: Stefan Weil 
> ---
>  ui/sdl.c |   13 +
>  1 files changed, 13 insertions(+), 0 deletions(-)

Thanks, applied.

> diff --git a/ui/sdl.c b/ui/sdl.c
> index 47ac49c..f5dbc93 100644
> --- a/ui/sdl.c
> +++ b/ui/sdl.c
> @@ -816,6 +816,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, 
> int no_frame)
>  uint8_t data = 0;
>  DisplayAllocator *da;
>  const SDL_VideoInfo *vi;
> +char *filename;
>  
>  #if defined(__APPLE__)
>  /* always use generic keymaps */
> @@ -848,6 +849,18 @@ void sdl_display_init(DisplayState *ds, int full_screen, 
> int no_frame)
>  vi = SDL_GetVideoInfo();
>  host_format = *(vi->vfmt);
>  
> +/* Load a 32x32x4 image. White pixels are transparent. */
> +filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
> +if (filename) {
> +SDL_Surface *image = SDL_LoadBMP(filename);
> +if (image) {
> +uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
> +SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
> +SDL_WM_SetIcon(image, NULL);
> +}
> +qemu_free(filename);
> +}
> +
>  dcl = qemu_mallocz(sizeof(DisplayChangeListener));
>  dcl->dpy_update = sdl_update;
>  dcl->dpy_resize = sdl_resize;
> -- 
> 1.7.2.3
> 
> 
> 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH V2 4/9] Add tpm_tis driver to build process

2011-04-01 Thread Stefan Berger

On 04/01/2011 02:14 PM, Blue Swirl wrote:

On Wed, Mar 30, 2011 at 10:42 PM, Stefan Berger
  wrote:

The TPM interface (tpm_tis) needs to be explicitly enabled via
./configure --enable-tpm. This restricts the building of the
TPM support to i386 and x86_64 targets since both backends I know
of, the Xen backend and the libtpms-based backend, will likely only
be available for these targets, at least initially. The list can be
easily extend. This measure prevents that one will end up with support
for a frontend but no available backend.

Signed-off-by: Stefan Berger

Index:qemu/Makefile.target
===
---
  Makefile.target |7 +++
  configure   |   20 
  2 files changed, 27 insertions(+)

Index: qemu-git/Makefile.target
===
--- qemu-git.orig/Makefile.target
+++ qemu-git/Makefile.target
@@ -303,6 +303,13 @@ obj-sparc-y += cs4231.o eccmemctl.o sbi.

  # GRLIB
  obj-sparc-y += grlib_gptimer.o grlib_irqmp.o grlib_apbuart.o
+
+ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),i386 x86_64))

The ifeq above is not needed since the line below uses obj-i386.


Will remove.

+
+obj-i386-$(CONFIG_TPM) += tpm_tis.o
+
+endif
+
  endif

  obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o
Index: qemu-git/configure
===
--- qemu-git.orig/configure
+++ qemu-git/configure
@@ -175,6 +175,7 @@ trace_backend="nop"
  trace_file="trace"
  spice=""
  rbd=""
+tpm="no"

  # parse CC options first
  for opt do
@@ -708,6 +709,8 @@ for opt do
   ;;
   --kerneldir=*) kerneldir="$optarg"
   ;;
+  --enable-tpm) tpm="yes"
+  ;;
   --with-pkgversion=*) pkgversion=" ($optarg)"
   ;;
   --disable-docs) docs="no"
@@ -921,6 +924,7 @@ echo "   Default
  echo "  --disable-spice  disable spice"
  echo "  --enable-spice   enable spice"
  echo "  --enable-rbd enable building the rados block device (rbd)"
+echo "  --enable-tpm enables an emulated TPM"
  echo ""
  echo "NOTE: The object files are built at the place where configure is 
launched"
  exit 1
@@ -2540,6 +2544,7 @@ echo "Trace output file $trace_file-  Your SDL version is too old - please upgrade to have SDL support"
@@ -3324,6 +3329,21 @@ if test "$gprof" = "yes" ; then
   fi
  fi

+if test "$linux" = "yes"&&  test "$tpm" = "yes"; then
+  has_tpm=0
+  if test "$target_softmmu" = "yes" ; then
+case "$TARGET_BASE_ARCH" in
+i386)
+  has_tpm=1

This is not a real compile test, please try to build a dummy program
that depends on TPM headers like for example preadv probe. Then it is
not needed to check for Linux or i386 explicitly.
At this point there is no compile test needed since all code is 'there'. 
It's merely adding the front-end,i.e., the TPM TIS emulation to be 
compiled. The (libtpms-based) backend is then added later in patch 
[9/9]. There you then find this here:


   if test "$has_tpm" = "1"; then
+  if test -r /usr/include/libtpms/tpm_library.h ; then
+  echo "CONFIG_TPM_BUILTIN=y">>  $config_target_mak
+  fi
   echo "CONFIG_TPM=y">>  $config_host_mak
   fi
 fi


So this is then trying to test for the libtpms-devel package, and if 
found, adds the tpm_builtin.c to the build.
Now did it look wrong for patch 4 and it does make sense in combination 
with patch 9?


Stefan




Re: [Qemu-devel] [PATCH] Register only one qbus_reset_all_fn() for system bus

2011-04-01 Thread Aurelien Jarno
On Mon, Feb 21, 2011 at 02:08:53AM +0300, Dmitry Eremin-Solenikov wrote:
> Currently reset handler is registered for System bus twice: once during
> bus creation and once in vl.c. Remove the second qemu_register_reset()
> invocation. Also while we are at it, remove incorrect check at
> qbus_create_inplace(): when system bus is created, main_system_bus is
> NULL (as it's not yet created, it cannot be set), so the check is just
> wrong.
> 
> Signed-off-by: Dmitry Eremin-Solenikov 
> ---
>  hw/qdev.c |2 +-
>  vl.c  |3 ---
>  2 files changed, 1 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 1aa1ea0..0a3c8ce 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -762,7 +762,7 @@ void qbus_create_inplace(BusState *bus, BusInfo *info,
>  if (parent) {
>  QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
>  parent->num_child_bus++;
> -} else if (bus != main_system_bus) {
> +} else {
>  /* TODO: once all bus devices are qdevified,
> only reset handler for main_system_bus should be registered here. 
> */
>  qemu_register_reset(qbus_reset_all_fn, bus);
> diff --git a/vl.c b/vl.c
> index 91be92e..24923db 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3120,9 +3120,6 @@ int main(int argc, char **argv, char **envp)
>  exit(1);
>  }
>  
> -/* TODO: once all bus devices are qdevified, this should be done
> - * when bus is created by qdev.c */
> -qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
>  qemu_run_machine_init_done_notifiers();
>  
>  qemu_system_reset();

Have you verified that all bus devices have been qdevified since this
code has been added? I wouldn't bet it is the case.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH] fix build errors when we enable acpi_piix4 debug

2011-04-01 Thread Aurelien Jarno
On Mon, Feb 28, 2011 at 10:22:33AM +0800, Wen Congyang wrote:
> I enable acpi_piix4 debug, and got the following build errors:
> # make
>   CClibhw64/acpi_piix4.o
> cc1: warnings being treated as errors
> /home/wency/source/qemu/hw/acpi_piix4.c: In function ‘pm_ioport_write’:
> /home/wency/source/qemu/hw/acpi_piix4.c:193: error: format ‘%04x’ expects 
> type ‘unsigned int’, but argument 2 has type ‘uint64_t’
> /home/wency/source/qemu/hw/acpi_piix4.c:193: error: format ‘%04x’ expects 
> type ‘unsigned int’, but argument 3 has type ‘uint64_t’
> /home/wency/source/qemu/hw/acpi_piix4.c: In function ‘pm_ioport_read’:
> /home/wency/source/qemu/hw/acpi_piix4.c:219: error: format ‘%04x’ expects 
> type ‘unsigned int’, but argument 2 has type ‘uint64_t’
> make[1]: *** [acpi_piix4.o] Error 1
> make: *** [subdir-libhw64] Error 2
> 
> Signed-off-by: Wen Congyang 
> 
> ---
>  hw/acpi_piix4.c |5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)

Thanks, applied.

> diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
> index 5bbc2b5..b5a2762 100644
> --- a/hw/acpi_piix4.c
> +++ b/hw/acpi_piix4.c
> @@ -190,7 +190,8 @@ static void pm_ioport_write(IORange *ioport, uint64_t 
> addr, unsigned width,
>  default:
>  break;
>  }
> -PIIX4_DPRINTF("PM writew port=0x%04x val=0x%04x\n", addr, val);
> +PIIX4_DPRINTF("PM writew port=0x%04x val=0x%04x\n", (unsigned int)addr,
> +  (unsigned int)val);
>  }
>  
>  static void pm_ioport_read(IORange *ioport, uint64_t addr, unsigned width,
> @@ -216,7 +217,7 @@ static void pm_ioport_read(IORange *ioport, uint64_t 
> addr, unsigned width,
>  val = 0;
>  break;
>  }
> -PIIX4_DPRINTF("PM readw port=0x%04x val=0x%04x\n", addr, val);
> +PIIX4_DPRINTF("PM readw port=0x%04x val=0x%04x\n", (unsigned int)addr, 
> val);
>  *data = val;
>  }
>  
> -- 
> 1.7.1
> 
> 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



[Qemu-devel] Re: lsi53c895a: add support for ABORT messages

2011-04-01 Thread Aurelien Jarno
On Mon, Sep 06, 2010 at 04:42:54AM -, Bernhard Kohl wrote:
> If these messages are not handled correctly the guest driver may hang.
> 
> Always mandatory:
> - ABORT
> - BUS DEVICE RESET
> 
> Mandatory if tagged queuing is implemented (which disks usually do):
> - ABORT TAG
> - CLEAR QUEUE
> 
> Signed-off-by: Bernhard Kohl 
> 
> ---
> hw/lsi53c895a.c |   57 +++
>  1 files changed, 57 insertions(+), 0 deletions(-)

Thanks, applied.

> diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
> index 5eaf69e..40f2d10 100644
> --- a/hw/lsi53c895a.c
> +++ b/hw/lsi53c895a.c
> @@ -846,6 +846,18 @@ static void lsi_do_msgout(LSIState *s)
>  {
>  uint8_t msg;
>  int len;
> +uint32_t current_tag;
> +SCSIDevice *current_dev;
> +lsi_request *p, *p_next;
> +int id;
> +
> +if (s->current) {
> +current_tag = s->current->tag;
> +} else {
> +current_tag = s->select_tag;
> +}
> +id = (current_tag >> 8) & 0xf;
> +current_dev = s->bus.devs[id];
>  
>  DPRINTF("MSG out len=%d\n", s->dbc);
>  while (s->dbc) {
> @@ -890,6 +902,51 @@ static void lsi_do_msgout(LSIState *s)
>  BADF("ORDERED queue not implemented\n");
>  s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
>  break;
> +case 0x0d:
> +/* The ABORT TAG message clears the current I/O process only. */
> +DPRINTF("MSG: ABORT TAG tag=0x%x\n", current_tag);
> +current_dev->info->cancel_io(current_dev, current_tag);
> +lsi_disconnect(s);
> +break;
> +case 0x06:
> +case 0x0e:
> +case 0x0c:
> +/* The ABORT message clears all I/O processes for the selecting
> +   initiator on the specified logical unit of the target. */
> +if (msg == 0x06) {
> +DPRINTF("MSG: ABORT tag=0x%x\n", current_tag);
> +}
> +/* The CLEAR QUEUE message clears all I/O processes for all
> +   initiators on the specified logical unit of the target. */
> +if (msg == 0x0e) {
> +DPRINTF("MSG: CLEAR QUEUE tag=0x%x\n", current_tag);
> +}
> +/* The BUS DEVICE RESET message clears all I/O processes for all
> +   initiators on all logical units of the target. */
> +if (msg == 0x0c) {
> +DPRINTF("MSG: BUS DEVICE RESET tag=0x%x\n", current_tag);
> +}
> +
> +/* clear the current I/O process */
> +current_dev->info->cancel_io(current_dev, current_tag);
> +
> +/* As the current implemented devices scsi_disk and scsi_generic
> +   only support one LUN, we don't need to keep track of LUNs.
> +   Clearing I/O processes for other initiators could be possible
> +   for scsi_generic by sending a SG_SCSI_RESET to the /dev/sgX
> +   device, but this is currently not implemented (and seems not
> +   to be really necessary). So let's simply clear all queued
> +   commands for the current device: */
> +id = current_tag & 0xff00;
> +QTAILQ_FOREACH_SAFE(p, &s->queue, next, p_next) {
> +if ((p->tag & 0xff00) == id) {
> +current_dev->info->cancel_io(current_dev, p->tag);
> +QTAILQ_REMOVE(&s->queue, p, next);
> +}
> +}
> +
> +lsi_disconnect(s);
> +break;
>  default:
>  if ((msg & 0x80) == 0) {
>  goto bad;

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



[Qemu-devel] [Bug 731344] Re: When accessing to disk with qemu-system-arm Error occours

2011-04-01 Thread Aurelien Jarno
** Changed in: qemu
   Status: New => Fix Committed

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

Title:
  When accessing to disk with qemu-system-arm Error occours

Status in QEMU:
  Fix Committed

Bug description:
  
  when trying to install debian squeeze:
  qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd 
initrd.gz -hda hda.img -m 256

  2.6.35-27-generic #48-Ubuntu SMP Tue Feb 22 20:25:46 UTC 2011 x86_64 GNU/Linux
  qemu 0.12 & 0.14

  Error Message:
  lsi_scsi: error: Unimplemented message 0x0c



Re: [Qemu-devel] [PATCH] get rid of private bitmap functions in block/sheepdog.c, use generic ones

2011-04-01 Thread Aurelien Jarno
On Thu, Mar 10, 2011 at 05:03:41PM +0300, Michael Tokarev wrote:
> qemu now has generic bitmap functions,
> so don't redefine them in sheepdog.c,
> use common header instead.  A small cleanup.
> 
> Here's only one function which is actually
> used in sheepdog and gets replaced with
> a generic one (simplified):
> 
> - static inline int test_bit(int nr, const volatile unsigned long *addr)
> + static inline int test_bit(int nr, const unsigned long *addr)
>  {
> -  return ((1UL << (nr % BITS_PER_LONG))
> & ((unsigned long*)addr)[nr / BITS_PER_LONG])) != 0;
> +  return 1UL & (addr[nr / BITS_PER_LONG] >> (nr & (BITS_PER_LONG-1)));
>  }
> 
> The body is equivalent, but the argument is not: there's
> "volatile" in there.  Why it is used for - I'm not sure.
> 
> Signed-off-by: Michael Tokarev 

Thanks, applied.

> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index a54e0de..98946d7 100644
> --- a/block/sheepdog.c
> +++ b/block/sheepdog.c
> @@ -13,6 +13,7 @@
>  #include "qemu-error.h"
>  #include "qemu_socket.h"
>  #include "block_int.h"
> +#include "bitops.h"
>  
>  #define SD_PROTO_VER 0x01
>  
> @@ -1829,20 +1830,6 @@ static int sd_snapshot_delete(BlockDriverState *bs, 
> const char *snapshot_id)
>  return 0;
>  }
>  
> -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
> -#define BITS_PER_BYTE8
> -#define BITS_TO_LONGS(nr)DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
> -#define DECLARE_BITMAP(name,bits)   \
> -unsigned long name[BITS_TO_LONGS(bits)]
> -
> -#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long))
> -
> -static inline int test_bit(unsigned int nr, const unsigned long *addr)
> -{
> -return ((1UL << (nr % BITS_PER_LONG)) &
> -(((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0;
> -}
> -
>  static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
>  {
>  BDRVSheepdogState *s = bs->opaque;
> 
> 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



Re: [Qemu-devel] [PATCH RESEND(REBASED)] Fix trivial "endianness bugs"

2011-04-01 Thread Aurelien Jarno
On Sun, Mar 13, 2011 at 03:44:02PM +0100, Stefan Weil wrote:
> Replace endianess -> endianness.

Given it concerns code and not comments, I am reluctant for this kind of
patches unless we have a very good reason.

Do you have some pointers about "endianness" being the correct wording?
It seems both are accepted, even if in the last years people seems to
use more often "endianness" than "endianess".

Maybe a native speaker can help us here.

> Signed-off-by: Stefan Weil 
> ---
>  audio/sdlaudio.c  |   20 ++--
>  block/vdi.c   |4 ++--
>  target-microblaze/translate.c |2 +-
>  target-mips/cpu.h |2 +-
>  usb-bsd.c |2 +-
>  5 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
> index b74dcfa..04fb9f4 100644
> --- a/audio/sdlaudio.c
> +++ b/audio/sdlaudio.c
> @@ -139,36 +139,36 @@ static int aud_to_sdlfmt (audfmt_e fmt)
>  }
>  }
>  
> -static int sdl_to_audfmt (int sdlfmt, audfmt_e *fmt, int *endianess)
> +static int sdl_to_audfmt(int sdlfmt, audfmt_e *fmt, int *endianness)
>  {
>  switch (sdlfmt) {
>  case AUDIO_S8:
> -*endianess = 0;
> +*endianness = 0;
>  *fmt = AUD_FMT_S8;
>  break;
>  
>  case AUDIO_U8:
> -*endianess = 0;
> +*endianness = 0;
>  *fmt = AUD_FMT_U8;
>  break;
>  
>  case AUDIO_S16LSB:
> -*endianess = 0;
> +*endianness = 0;
>  *fmt = AUD_FMT_S16;
>  break;
>  
>  case AUDIO_U16LSB:
> -*endianess = 0;
> +*endianness = 0;
>  *fmt = AUD_FMT_U16;
>  break;
>  
>  case AUDIO_S16MSB:
> -*endianess = 1;
> +*endianness = 1;
>  *fmt = AUD_FMT_S16;
>  break;
>  
>  case AUDIO_U16MSB:
> -*endianess = 1;
> +*endianness = 1;
>  *fmt = AUD_FMT_U16;
>  break;
>  
> @@ -338,7 +338,7 @@ static int sdl_init_out (HWVoiceOut *hw, struct 
> audsettings *as)
>  SDLVoiceOut *sdl = (SDLVoiceOut *) hw;
>  SDLAudioState *s = &glob_sdl;
>  SDL_AudioSpec req, obt;
> -int endianess;
> +int endianness;
>  int err;
>  audfmt_e effective_fmt;
>  struct audsettings obt_as;
> @@ -354,7 +354,7 @@ static int sdl_init_out (HWVoiceOut *hw, struct 
> audsettings *as)
>  return -1;
>  }
>  
> -err = sdl_to_audfmt (obt.format, &effective_fmt, &endianess);
> +err = sdl_to_audfmt(obt.format, &effective_fmt, &endianness);
>  if (err) {
>  sdl_close (s);
>  return -1;
> @@ -363,7 +363,7 @@ static int sdl_init_out (HWVoiceOut *hw, struct 
> audsettings *as)
>  obt_as.freq = obt.freq;
>  obt_as.nchannels = obt.channels;
>  obt_as.fmt = effective_fmt;
> -obt_as.endianness = endianess;
> +obt_as.endianness = endianness;
>  
>  audio_pcm_init_info (&hw->info, &obt_as);
>  hw->samples = obt.samples;
> diff --git a/block/vdi.c b/block/vdi.c
> index 116b25b..083266e 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -113,7 +113,7 @@ void uuid_unparse(const uuid_t uu, char *out);
>   */
>  #define VDI_TEXT "<<< QEMU VM Virtual Disk Image >>>\n"
>  
> -/* Unallocated blocks use this index (no need to convert endianess). */
> +/* Unallocated blocks use this index (no need to convert endianness). */
>  #define VDI_UNALLOCATED UINT32_MAX
>  
>  #if !defined(CONFIG_UUID)
> @@ -194,7 +194,7 @@ typedef struct {
>  uint32_t block_sectors;
>  /* First sector of block map. */
>  uint32_t bmap_sector;
> -/* VDI header (converted to host endianess). */
> +/* VDI header (converted to host endianness). */
>  VdiHeader header;
>  } BDRVVdiState;
>  
> diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
> index fdb2b40..b54b169 100644
> --- a/target-microblaze/translate.c
> +++ b/target-microblaze/translate.c
> @@ -923,7 +923,7 @@ static void dec_load(DisasContext *dc)
>  /*
>   * When doing reverse accesses we need to do two things.
>   *
> - * 1. Reverse the address wrt endianess.
> + * 1. Reverse the address wrt endianness.
>   * 2. Byteswap the data lanes on the way back into the CPU core.
>   */
>  if (rev && size != 4) {
> diff --git a/target-mips/cpu.h b/target-mips/cpu.h
> index 2419aa9..0b98d10 100644
> --- a/target-mips/cpu.h
> +++ b/target-mips/cpu.h
> @@ -63,7 +63,7 @@ union fpr_t {
>  uint32_t w[2]; /* binary single fixed-point */
>  };
>  /* define FP_ENDIAN_IDX to access the same location
> - * in the fpr_t union regardless of the host endianess
> + * in the fpr_t union regardless of the host endianness
>   */
>  #if defined(HOST_WORDS_BIGENDIAN)
>  #  define FP_ENDIAN_IDX 1
> diff --git a/usb-bsd.c b/usb-bsd.c
> index abcb60c..e561e1f 100644
> --- a/usb-bsd.c
> +++ b/usb-bsd.c
> @@ -464,7 +464,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
>  printf("usb_host_scan: couldn't

Re: [Qemu-devel] [PATCH] vnc: added missing name->keysym pairs for Polish national characters

2011-04-01 Thread Aurelien Jarno
On Mon, Mar 14, 2011 at 10:30:08AM +0100, Leszek Grzegorek wrote:
> Hi,
> 
> There are no { name, keysym } values in name2keysym[] array for Polish
> national characters so "-k pl" option has no effect.
> 
> Regards,
> Leszek
> 
> 
> Signed-off-by: Leszek Grzegorek 
> ---

Thanks, applied.

> diff --git a/ui/vnc_keysym.h b/ui/vnc_keysym.h
> index 55cb87e..df33cfe 100644
> --- a/ui/vnc_keysym.h
> +++ b/ui/vnc_keysym.h
> @@ -202,6 +202,24 @@ static const name2keysym_t name2keysym[]={
>  { "ydiaeresis",   0x0ff},
>  {"EuroSign", 0x20ac},  /* XK_EuroSign */
> 
> +/* latin 2 - Polish national characters */
> +{ "eogonek",  0x1ea},
> +{ "Eogonek",  0x1ca},
> +{ "aogonek",  0x1b1},
> +{ "Aogonek",  0x1a1},
> +{ "sacute",   0x1b6},
> +{ "Sacute",   0x1a6},
> +{ "lstroke",  0x1b3},
> +{ "Lstroke",  0x1a3},
> +{ "zabovedot",0x1bf},
> +{ "Zabovedot",0x1af},
> +{ "zacute",   0x1bc},
> +{ "Zacute",   0x1ac},
> +{ "cacute",   0x1e6},
> +{ "Cacute",   0x1c6},
> +{ "nacute",   0x1f1},
> +{ "Nacute",   0x1d1},
> +
>  /* modifiers */
>  {"ISO_Level3_Shift", 0xfe03}, /* XK_ISO_Level3_Shift */
>  {"Control_L", 0xffe3}, /* XK_Control_L */
> 
> 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



  1   2   >