[Qemu-devel] Re: Endless loop in qcow2_alloc_cluster_offset

2010-05-07 Thread Kevin Wolf
Am 07.05.2010 03:19, schrieb Marcelo Tosatti:
 On Thu, Nov 19, 2009 at 01:19:55PM +0100, Jan Kiszka wrote:
 Hi,

 I just managed to push a qemu-kvm process (git rev. b496fe3431) into an
 endless loop in qcow2_alloc_cluster_offset, namely over
 QLIST_FOREACH(old_alloc, s-cluster_allocs, next_in_flight):

 (gdb) bt
 #0  0x0048614b in qcow2_alloc_cluster_offset (bs=0xc4e1d0, 
 offset=7417184256, n_start=0, n_end=16, num=0xcb351c, m=0xcb3568) at 
 /data/qemu-kvm/block/qcow2-cluster.c:750
 #1  0x004828d0 in qcow_aio_write_cb (opaque=0xcb34d0, ret=0) at 
 /data/qemu-kvm/block/qcow2.c:587
 #2  0x00482a44 in qcow_aio_writev (bs=value optimized out, 
 sector_num=value optimized out, qiov=value optimized out, 
 nb_sectors=value optimized out, cb=value optimized out, opaque=value 
 optimized out) at /data/qemu-kvm/block/qcow2.c:645
 #3  0x00470e89 in bdrv_aio_writev (bs=0xc4e1d0, sector_num=2, 
 qiov=0x7f48a9010ed0, nb_sectors=16, cb=0x470d20 bdrv_rw_em_cb, 
 opaque=0x7f48a9010f0c) at /data/qemu-kvm/block.c:1362
 #4  0x00472991 in bdrv_write_em (bs=0xc4e1d0, sector_num=14486688, 
 buf=0xd67200 H\a, nb_sectors=16) at /data/qemu-kvm/block.c:1736
 #5  0x00435581 in ide_sector_write (s=0xc92650) at 
 /data/qemu-kvm/hw/ide/core.c:622
 #6  0x00425fc2 in kvm_handle_io (env=value optimized out) at 
 /data/qemu-kvm/kvm-all.c:553
 #7  kvm_run (env=value optimized out) at /data/qemu-kvm/qemu-kvm.c:964
 #8  0x00426049 in kvm_cpu_exec (env=0x1000) at 
 /data/qemu-kvm/qemu-kvm.c:1651
 #9  0x0042627d in kvm_main_loop_cpu (_env=value optimized out) at 
 /data/qemu-kvm/qemu-kvm.c:1893
 #10 ap_main_loop (_env=value optimized out) at 
 /data/qemu-kvm/qemu-kvm.c:1943
 #11 0x7f48ae89d070 in start_thread () from /lib64/libpthread.so.0
 #12 0x7f48abf0711d in clone () from /lib64/libc.so.6
 #13 0x in ?? ()
 (gdb) print ((BDRVQcowState *)bs-opaque)-cluster_allocs.lh_first 
 $5 = (struct QCowL2Meta *) 0xcb3568
 (gdb) print *((BDRVQcowState *)bs-opaque)-cluster_allocs.lh_first 
 $6 = {offset = 7417176064, n_start = 0, nb_available = 16, nb_clusters = 0, 
 depends_on = 0xcb3568, dependent_requests = {lh_first = 0x0}, next_in_flight 
 = {le_next = 0xcb3568, le_prev = 0xc4ebd8}}

 So next == first.

 
 Seen the exact same bug twice in a row while installing FC12 with IDE
 disk, current qemu-kvm.git. 
 
 qemu-system-x86_64 -drive file=/root/images/fc12-ide.img,cache=writeback \
 -m 1000  -vnc :1 \
 -net nic,model=virtio \
 -net tap,script=/root/ifup.sh -serial stdio \
 -cdrom /root/iso/linux/Fedora-12-x86_64-DVD.iso -monitor
 telnet::4445,server,nowait -usbdevice tablet
 
 Can't reproduce though.

In current git master? That's interesting news. I had kind of expected
it would be fixed with c644db3d.

Kevin




[Qemu-devel] Re: [PATCH] vdi: Fix image opening and creation for odd disk sizes

2010-05-07 Thread Kevin Wolf
Am 06.05.2010 20:29, schrieb Stefan Weil:
 This patch fixes a regression introduced by commit
 95a2f9bc588c3f83375d87b0a9394f89a1bcfada.
 
 The fix is based on a patch from Kevin Wolf. Here his comment:
 
 The number of blocks needs to be rounded up to cover all of the virtual hard
 disk. Without this fix, we can't even open our own images if their size is not
 a multiple of the block size.
 
 While Kevin's patch addressed vdi_create, my modification also fixes
 vdi_open which now accepts any image which is large enough to hold
 the blocks.

Shouldn't it be the other way round? That is, an image which has some
unused blocks at its end makes sense, whereas an image with a virtual
disk size that can't be represented with the number of blocks doesn't?

 I also decided to keep the original code in vdi_create which rounds down.
 Rounding works in both directions, and there are good arguments for both,
 so I just left the original simple code.
 
 It is very important to use the rounded value for the new disk size, too -
 otherwise VirtualBox cannot open our disk image.

So you're saying that in VDI you can't represent disks with an odd size?
The one thing common across image formats seems to be that they are
broken...

Kevin




[Qemu-devel] Re: [PATCH] block/vdi: Allow disk images of size 0

2010-05-07 Thread Kevin Wolf
Am 06.05.2010 20:53, schrieb Stefan Weil:
 Even it is not very useful, users may create images of size 0.
 
 Without the special option CONFIG_ZERO_MALLOC, qemu_mallocz
 aborts execution when it is told to allocate 0 bytes,
 so avoid this kind of call.
 
 Cc: Kevin Wolf kw...@redhat.com
 Signed-off-by: Stefan Weil w...@mail.berlios.de

This stupid qemu_malloc behaviour only ever introduces bugs instead of
avoiding them... *sigh*

Thanks, applied to the block branch.

Kevin




[Qemu-devel] Re: Registering buffers with a qdict

2010-05-07 Thread Luiz Capitulino
On Fri, 07 May 2010 13:45:03 +0200
Jan Kiszka jan.kis...@siemens.com wrote:

 Hi Luiz,
 
 what is the recommended way of pushing larger buffers (up to 64K so far)
 into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought
 about hex-encoding the content first (series of %02X), then
 registering it as QSTRING. Or should we introduce a new type, QBUFFER?

 I don't think that hex-encoding the contents is so bad if your use case is
very specific and isolated.

 On the other hand, I do prefer a QBuffer type, specially because we can
have buffer operations.




[Qemu-devel] Registering buffers with a qdict

2010-05-07 Thread Jan Kiszka
Hi Luiz,

what is the recommended way of pushing larger buffers (up to 64K so far)
into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought
about hex-encoding the content first (series of %02X), then
registering it as QSTRING. Or should we introduce a new type, QBUFFER?

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux




[Qemu-devel] [PATCH 2/5] Add defines for PCI IDs.

2010-05-07 Thread Gerd Hoffmann
This patch allows to set PCI vendor and device IDs using defines
(PCI_VID and PCI_DID).  Use it for vgabios.bin.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 Makefile  |4 ++--
 vbe.c |6 +-
 vgabios.c |5 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index c3c744c..d440b93 100644
--- a/Makefile
+++ b/Makefile
@@ -31,8 +31,8 @@ VGA_FILES := vgabios.c vgabios.h vgafonts.h vgatables.h
 VBE_FILES := vbe.h vbe.c vbetables.h
 
 # build flags
-vgabios.bin  : VGAFLAGS := -DVBE
-vgabios.debug.bin: VGAFLAGS := -DVBE -DDEBUG
+vgabios.bin  : VGAFLAGS := -DVBE -DPCI_VID=0x1234
+vgabios.debug.bin: VGAFLAGS := -DVBE -DPCI_VID=0x1234 -DDEBUG
 vgabios-cirrus.bin   : VGAFLAGS := -DCIRRUS -DPCIBIOS 
 vgabios-cirrus.debug.bin : VGAFLAGS := -DCIRRUS -DPCIBIOS -DCIRRUS_DEBUG
 
diff --git a/vbe.c b/vbe.c
index f925c35..f9a77f0 100644
--- a/vbe.c
+++ b/vbe.c
@@ -925,7 +925,11 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
 if (using_lfb) {
   info.NumberOfBanks = 1;
 }
-lfb_addr = pci_get_lfb_addr(0x1234); // experimental vendor
+#ifdef PCI_VID
+lfb_addr = pci_get_lfb_addr(PCI_VID);
+#else
+lfb_addr = 0;
+#endif
 if (lfb_addr  0) {
   info.PhysBasePtr = ((Bit32u)lfb_addr  16);
 }
diff --git a/vgabios.c b/vgabios.c
index 3b09c92..a575b7b 100644
--- a/vgabios.c
+++ b/vgabios.c
@@ -210,8 +210,13 @@ vgabios_pci_data:
 .word 0x1013
 .word 0x00b8 // CLGD5446
 #else
+#ifdef PCI_VID
+.word PCI_VID
+.word PCI_DID
+#else
 #error Unknown PCI vendor and device id
 #endif
+#endif
 .word 0 // reserved
 .word 0x18 // dlen
 .byte 0 // revision
-- 
1.6.6.1





[Qemu-devel] Re: [PATCH] vdi: Fix image opening and creation for odd disk sizes

2010-05-07 Thread François Revol
Le Fri, 07 May 2010 09:55:23 +0200, Kevin Wolf a écrit :
 Am 06.05.2010 20:29, schrieb Stefan Weil:
  This patch fixes a regression introduced by commit
  95a2f9bc588c3f83375d87b0a9394f89a1bcfada.
 
  The fix is based on a patch from Kevin Wolf. Here his comment:
 
  The number of blocks needs to be rounded up to cover all of the
  virtual hard
  disk. Without this fix, we can't even open our own images if their
  size is not
  a multiple of the block size.
 
  While Kevin's patch addressed vdi_create, my modification also
  fixes
  vdi_open which now accepts any image which is large enough to hold
  the blocks.

 Shouldn't it be the other way round? That is, an image which has some
 unused blocks at its end makes sense, whereas an image with a virtual
 disk size that can't be represented with the number of blocks
 doesn't?

Exactly, else you don't create what you are asked for.

  I also decided to keep the original code in vdi_create which rounds
  down.
  Rounding works in both directions, and there are good arguments for
  both,
  so I just left the original simple code.
 
  It is very important to use the rounded value for the new disk
  size, too -
  otherwise VirtualBox cannot open our disk image.

 So you're saying that in VDI you can't represent disks with an odd
 size?
 The one thing common across image formats seems to be that they are
 broken...

VB works quite well with my converted laptop image which indeed doesn't
end on block boundary.

Was it because you were just setting size larger than the covered by
the blocks ?

François.




[Qemu-devel] spice/unstable status update.

2010-05-07 Thread Gerd Hoffmann

  Hi folks,

Here is a short status update about what is happening in spice land.

For those which don't know yet what spice is:  Spice is a remote desktop 
protocol.  It uses a paravirtual graphics card (qxl) for good 
performance.  The (slightly outdated) project website with background 
information is http://www.spice-space.org/  The download section has 
windows guest drivers.


Fedora packages are available from
http://kraxel.fedorapeople.org/spice/

Recommended reading:
   http://kraxel.fedorapeople.org/spice/README

Latest qemu patches are available here:
   http://cgit.freedesktop.org/spice/qemu/log/?h=spice.v5.1

These qemu patches depend on some spice changes not (yet) merged:
   http://cgit.freedesktop.org/~kraxel/spice/log/?h=api.v5

cheers,
  Gerd




[Qemu-devel] [PATCH 0/2] qcow2: Move BlockDriver definiton to the end of the file

2010-05-07 Thread Kevin Wolf
A recent build fix for OpenBSD moved the BlockDriver definition of qcow2 to
somewhere in the middle of the source file. This series tries to solve the
problem in a different way that allows the definition to stay where everyone
looks for it.

Blue Swirl, as I don't have an OpenBSD installation handy, can you try if this
works for you?

Kevin Wolf (2):
  Revert Fix OpenBSD build
  qcow2: Remove static forward declaration

 block/qcow2.c |  491 -
 1 files changed, 245 insertions(+), 246 deletions(-)





[Qemu-devel] [PATCH 1/5] Makefile cleanup

2010-05-07 Thread Gerd Hoffmann
Use a single rule for building bios binaries.
Use target specific variables to set compile flags.

This makes it more obvious what the differences between the versions
are.  It also makes it easier to add new bios binaries with slightly
different settings.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 Makefile |   76 +++--
 1 files changed, 34 insertions(+), 42 deletions(-)

diff --git a/Makefile b/Makefile
index 00e8c66..c3c744c 100644
--- a/Makefile
+++ b/Makefile
@@ -16,8 +16,7 @@ VGABIOS_DATE = -DVGABIOS_DATE=\$(RELDATE)\
 
 all: bios cirrus-bios
 
-
-bios: biossums vgabios.bin vgabios.debug.bin
+bios: vgabios.bin vgabios.debug.bin
 
 cirrus-bios: vgabios-cirrus.bin vgabios-cirrus.debug.bin
 
@@ -27,6 +26,39 @@ clean:
 
 dist-clean: clean
 
+# source files
+VGA_FILES := vgabios.c vgabios.h vgafonts.h vgatables.h
+VBE_FILES := vbe.h vbe.c vbetables.h
+
+# build flags
+vgabios.bin  : VGAFLAGS := -DVBE
+vgabios.debug.bin: VGAFLAGS := -DVBE -DDEBUG
+vgabios-cirrus.bin   : VGAFLAGS := -DCIRRUS -DPCIBIOS 
+vgabios-cirrus.debug.bin : VGAFLAGS := -DCIRRUS -DPCIBIOS -DCIRRUS_DEBUG
+
+# dist names
+vgabios.bin  : DISTNAME := VGABIOS-lgpl-latest.bin
+vgabios.debug.bin: DISTNAME := VGABIOS-lgpl-latest.debug.bin
+vgabios-cirrus.bin   : DISTNAME := VGABIOS-lgpl-latest.cirrus.bin
+vgabios-cirrus.debug.bin : DISTNAME := VGABIOS-lgpl-latest.cirrus.debug.bin
+
+# dependencies
+vgabios.bin  : $(VGA_FILES) $(VBE_FILES) biossums
+vgabios.debug.bin: $(VGA_FILES) $(VBE_FILES) biossums
+vgabios-cirrus.bin   : $(VGA_FILES) clext.c biossums
+vgabios-cirrus.debug.bin : $(VGA_FILES) clext.c biossums
+
+# build rule
+%.bin:
+   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) $(VGAFLAGS) $(VGABIOS_DATE)  
_$*_.c
+   $(BCC) -o $*.s -C-c -D__i86__ -S -0 _$*_.c
+   sed -e 's/^\.text//' -e 's/^\.data//' $*.s  _$*_.s
+   $(AS86) _$*_.s -b $*.bin -u -w- -g -0 -j -O -l $*.txt
+   rm -f _$*_.s _$*_.c $*.s
+   mv $*.bin $(DISTNAME)
+   ./biossums $(DISTNAME)
+   ls -l $(DISTNAME)
+
 release: 
VGABIOS_VERS=\-DVGABIOS_VERS=\\\$(RELVERS) make bios cirrus-bios
/bin/rm -f  *.o *.s *.ld86 \
@@ -37,46 +69,6 @@ release:
cp VGABIOS-lgpl-latest.cirrus.debug.bin ../$(RELEASE).cirrus.debug.bin
tar czvf ../$(RELEASE).tgz --exclude CVS -C .. $(RELEASE)/
 
-vgabios.bin: vgabios.c vgabios.h vgafonts.h vgatables.h vbe.h vbe.c vbetables.h
-   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DVBE $(VGABIOS_DATE)  
_vgabios_.c
-   $(BCC) -o vgabios.s -C-c -D__i86__ -S -0 _vgabios_.c
-   sed -e 's/^\.text//' -e 's/^\.data//' vgabios.s  _vgabios_.s
-   $(AS86) _vgabios_.s -b vgabios.bin -u -w- -g -0 -j -O -l vgabios.txt
-   rm -f _vgabios_.s _vgabios_.c vgabios.s
-   mv vgabios.bin VGABIOS-lgpl-latest.bin
-   ./biossums VGABIOS-lgpl-latest.bin
-   ls -l VGABIOS-lgpl-latest.bin
-
-vgabios.debug.bin: vgabios.c vgabios.h vgafonts.h vgatables.h vbe.h vbe.c 
vbetables.h
-   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DVBE -DDEBUG $(VGABIOS_DATE)  
_vgabios-debug_.c
-   $(BCC) -o vgabios-debug.s -C-c -D__i86__ -S -0 _vgabios-debug_.c
-   sed -e 's/^\.text//' -e 's/^\.data//' vgabios-debug.s  
_vgabios-debug_.s
-   $(AS86) _vgabios-debug_.s -b vgabios.debug.bin -u -w- -g -0 -j -O -l 
vgabios.debug.txt
-   rm -f _vgabios-debug_.s _vgabios-debug_.c vgabios-debug.s
-   mv vgabios.debug.bin VGABIOS-lgpl-latest.debug.bin
-   ./biossums VGABIOS-lgpl-latest.debug.bin
-   ls -l VGABIOS-lgpl-latest.debug.bin
-
-vgabios-cirrus.bin: vgabios.c vgabios.h vgafonts.h vgatables.h clext.c
-   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DCIRRUS -DPCIBIOS 
$(VGABIOS_DATE)  _vgabios-cirrus_.c
-   $(BCC) -o vgabios-cirrus.s -C-c -D__i86__ -S -0 _vgabios-cirrus_.c
-   sed -e 's/^\.text//' -e 's/^\.data//' vgabios-cirrus.s  
_vgabios-cirrus_.s
-   $(AS86) _vgabios-cirrus_.s -b vgabios-cirrus.bin -u -w- -g -0 -j -O -l 
vgabios.cirrus.txt
-   rm -f _vgabios-cirrus_.s _vgabios-cirrus_.c vgabios-cirrus.s
-   mv vgabios-cirrus.bin VGABIOS-lgpl-latest.cirrus.bin
-   ./biossums VGABIOS-lgpl-latest.cirrus.bin
-   ls -l VGABIOS-lgpl-latest.cirrus.bin
-
-vgabios-cirrus.debug.bin: vgabios.c vgabios.h vgafonts.h vgatables.h clext.c
-   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DCIRRUS -DCIRRUS_DEBUG 
-DPCIBIOS $(VGABIOS_DATE)  _vgabios-cirrus-debug_.c
-   $(BCC) -o vgabios-cirrus-debug.s -C-c -D__i86__ -S -0 
_vgabios-cirrus-debug_.c
-   sed -e 's/^\.text//' -e 's/^\.data//' vgabios-cirrus-debug.s  
_vgabios-cirrus-debug_.s
-   $(AS86) _vgabios-cirrus-debug_.s -b vgabios.cirrus.debug.bin -u -w- -g 
-0 -j -O -l vgabios.cirrus.debug.txt
-   rm -f _vgabios-cirrus-debug_.s _vgabios-cirrus-debug_.c 
vgabios-cirrus-debug.s
-   mv vgabios.cirrus.debug.bin VGABIOS-lgpl-latest.cirrus.debug.bin
-   ./biossums 

Re: [Qemu-devel] [PATCH 1/2] parallels: use pread

2010-05-07 Thread Kevin Wolf
Am 06.05.2010 22:04, schrieb Christoph Hellwig:
 
 Use pread instead of lseek + read in preparation of using the qemu
 block API.
 
 Signed-off-by: Christoph Hellwig h...@lst.de

Thanks, applied both patches to the block branch.

We'll probably have to live with the fact that we can't test changes to
the parallels driver and need to trust patch review.

Kevin




[Qemu-devel] Re: [PATCH 1/3] cursor: add cursor functions.

2010-05-07 Thread Paolo Bonzini

On 05/06/2010 08:12 PM, Blue Swirl wrote:

On 5/5/10, Gerd Hoffmannkra...@redhat.com  wrote:

Add a new cursor type to console.h and a bunch of functions to
  deal with cursors the (new) cursor.c file.

  Signed-off-by: Gerd Hoffmannkra...@redhat.com
  ---
   Makefile.objs |3 +-
   console.h |   24 ++-
   cursor.c  |  208 
+
   3 files changed, 232 insertions(+), 3 deletions(-)
   create mode 100644 cursor.c

  diff --git a/Makefile.objs b/Makefile.objs
  index ecdd53e..1ee6e9d 100644
  --- a/Makefile.objs
  +++ b/Makefile.objs
  @@ -48,7 +48,8 @@ common-obj-y = $(block-obj-y)
   common-obj-y += $(net-obj-y)
   common-obj-y += $(qobject-obj-y)
   common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
  -common-obj-y += readline.o console.o async.o qemu-error.o
  +common-obj-y += readline.o console.o cursor.o async.o qemu-error.o
  +
   common-obj-y += tcg-runtime.o host-utils.o
   common-obj-y += irq.o ioport.o input.o
   common-obj-$(CONFIG_PTIMER) += ptimer.o
  diff --git a/console.h b/console.h
  index 6def115..88861cb 100644
  --- a/console.h
  +++ b/console.h
  @@ -126,6 +126,27 @@ struct DisplaySurface {
  struct PixelFormat pf;
   };

  +/* cursor data format is 32bit RGBA */
  +typedef struct QEMUCursor {
  +int width, height;
  +int hot_x, hot_y;
  +int refcount;
  +uint32_tdata[];
  +} QEMUCursor;
  +
  +QEMUCursor *cursor_alloc(int width, int height);
  +void cursor_get(QEMUCursor *c);
  +void cursor_put(QEMUCursor *c);
  +QEMUCursor *cursor_builtin_hidden(void);
  +QEMUCursor *cursor_builtin_left_ptr(void);
  +void cursor_print_ascii_art(QEMUCursor *c, const char *prefix);
  +int cursor_get_mono_bpl(QEMUCursor *c);
  +void cursor_set_mono(QEMUCursor *c,
  + uint32_t foreground, uint32_t background, uint8_t 
*image,
  + int transparent, uint8_t *mask);
  +void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask);
  +void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask);
  +
   struct DisplayChangeListener {
  int idle;
  uint64_t gui_timer_interval;
  @@ -158,8 +179,7 @@ struct DisplayState {
  struct DisplayChangeListener* listeners;

  void (*mouse_set)(int x, int y, int on);
  -void (*cursor_define)(int width, int height, int bpp, int hot_x, int 
hot_y,
  -  uint8_t *image, uint8_t *mask);
  +void (*cursor_define)(QEMUCursor *cursor);

  struct DisplayState *next;
   };
  diff --git a/cursor.c b/cursor.c
  new file mode 100644
  index 000..3995a31
  --- /dev/null
  +++ b/cursor.c
  @@ -0,0 +1,208 @@
  +#include qemu-common.h
  +#include console.h
  +
  +static const char cursor_hidden_32[32*32];
  +static const char cursor_left_ptr_32[32*32] = {
  +
  + X  
  + XX 
  + X.X
  + X..X   
  + X...X  
  + XX 
  + X.X
  + X..X   
  + X...X  
  + XX 
  + X.X
  + X..X..X
  + X.X X..X   
  + XX  X..X   
  + XX..X  
  +  X..X  
  +   X..X 
  +   X..X 
  +XX  
  +
  +};


Is this format standard? How about using X bitmap format instead:
$ cat /usr/include/X11/bitmaps/left_ptr
#define left_ptr_width 16
#define left_ptr_height 16
#define left_ptr_x_hot 3
#define left_ptr_y_hot 1
static char left_ptr_bits[] = {
0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x38, 0x00, 0x78, 0x00, 0xf8, 0x00,
0xf8, 0x01, 0xf8, 0x03, 0xf8, 0x07, 0xf8, 0x00, 0xd8, 0x00, 0x88, 0x01,
0x80, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00};

Then there would be no need of parsing.


You would need _two_ bitmaps (e.g. mask and cursor, so that mask=1 gives 
transparent, mask=0 cursor=0 gives black and mask=0 cursor=1 gives white).


Paolo




[Qemu-devel] [PATCH 2/2] qcow2: Remove static forward declaration

2010-05-07 Thread Kevin Wolf
OpenBSDs gcc is said to generate warnings for this declaration, so don't
reference bdrv_qcow2 directly, but look it up using bdrv_find_format.

Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block/qcow2.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 15a6a2c..0ce7150 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -52,8 +52,6 @@ typedef struct {
 #define  QCOW_EXT_MAGIC_END 0
 #define  QCOW_EXT_MAGIC_BACKING_FORMAT 0xE2792ACA
 
-static BlockDriver bdrv_qcow2;
-
 static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
 {
 const QCowHeader *cow_header = (const void *)buf;
@@ -1018,8 +1016,9 @@ exit:
 /* Preallocate metadata */
 if (ret == 0  prealloc) {
 BlockDriverState *bs;
+BlockDriver *drv = bdrv_find_format(qcow2);
 bs = bdrv_new();
-bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR, bdrv_qcow2);
+bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR, drv);
 preallocate(bs);
 bdrv_close(bs);
 }
-- 
1.6.6.1





[Qemu-devel] [PATCH 4/5] update pci_get_lfb_addr for vmware vga

2010-05-07 Thread Gerd Hoffmann
vmware vga has the framebuffer at pci region 1 not 0.  This patch makes
pci_get_lfb_addr check region 1 too.  It also gives names to the
numbered labels to make the code more readable.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 vgabios.c |   23 ++-
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/vgabios.c b/vgabios.c
index a575b7b..ed89334 100644
--- a/vgabios.c
+++ b/vgabios.c
@@ -3852,26 +3852,31 @@ _pci_get_lfb_addr:
 mov dl, #0x00
 call pci_read_reg
 cmp ax, #0x
-jz pci_get_lfb_addr_5
- pci_get_lfb_addr_3:
+jz pci_get_lfb_addr_fail
+ pci_get_lfb_addr_next_dev:
 mov dl, #0x00
 call pci_read_reg
 cmp ax, bx ;; check vendor
-jz pci_get_lfb_addr_4
+jz pci_get_lfb_addr_found
 add cx, #0x8
 cmp cx, #0x200 ;; search bus #0 and #1
-jb pci_get_lfb_addr_3
- pci_get_lfb_addr_5:
+jb pci_get_lfb_addr_next_dev
+ pci_get_lfb_addr_fail:
 xor dx, dx ;; no LFB
-jmp pci_get_lfb_addr_6
- pci_get_lfb_addr_4:
+jmp pci_get_lfb_addr_return
+ pci_get_lfb_addr_found:
 mov dl, #0x10 ;; I/O space #0
 call pci_read_reg
 test ax, #0xfff1
-jnz pci_get_lfb_addr_5
+jz pci_get_lfb_addr_success
+mov dl, #0x14 ;; I/O space #1
+call pci_read_reg
+test ax, #0xfff1
+jnz pci_get_lfb_addr_fail
+ pci_get_lfb_addr_success:
 shr eax, #16
 mov dx, ax ;; LFB address
- pci_get_lfb_addr_6:
+ pci_get_lfb_addr_return:
   pop eax
   mov ax, dx
   pop dx
-- 
1.6.6.1





[Qemu-devel] [PATCH 1/2] switch keyboard led state notification to notifiers.

2010-05-07 Thread Gerd Hoffmann

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 console.h |   11 +++
 input.c   |   37 -
 vnc.c |   13 -
 vnc.h |2 +-
 4 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/console.h b/console.h
index 6def115..431410a 100644
--- a/console.h
+++ b/console.h
@@ -35,12 +35,6 @@ typedef struct QEMUPutMouseEntry {
 QTAILQ_ENTRY(QEMUPutMouseEntry) node;
 } QEMUPutMouseEntry;
 
-typedef struct QEMUPutLEDEntry {
-QEMUPutLEDEvent *put_led;
-void *opaque;
-QTAILQ_ENTRY(QEMUPutLEDEntry) next;
-} QEMUPutLEDEntry;
-
 void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
 QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
 void *opaque, int absolute,
@@ -48,11 +42,12 @@ QEMUPutMouseEntry 
*qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
 void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
 void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry);
 
-QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void 
*opaque);
-void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
+void qemu_add_led_event_notifier(Notifier *notify);
+void qemu_remove_led_event_notifier(Notifier *notify);
 
 void kbd_put_keycode(int keycode);
 void kbd_put_ledstate(int ledstate);
+int kbd_get_ledstate(void);
 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
 
 /* Does the current mouse generate absolute events */
diff --git a/input.c b/input.c
index 8f0941e..8f9ca62 100644
--- a/input.c
+++ b/input.c
@@ -30,11 +30,13 @@
 
 static QEMUPutKBDEvent *qemu_put_kbd_event;
 static void *qemu_put_kbd_event_opaque;
-static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = 
QTAILQ_HEAD_INITIALIZER(led_handlers);
 static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =
 QTAILQ_HEAD_INITIALIZER(mouse_handlers);
 static NotifierList mouse_mode_notifiers = 
 NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
+static NotifierList led_event_notifiers =
+NOTIFIER_LIST_INITIALIZER(led_event_notifiers);
+static int ledstate;
 
 void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
 {
@@ -100,25 +102,14 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry 
*entry)
 check_mode_change();
 }
 
-QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,
-void *opaque)
+void qemu_add_led_event_notifier(Notifier *notify)
 {
-QEMUPutLEDEntry *s;
-
-s = qemu_mallocz(sizeof(QEMUPutLEDEntry));
-
-s-put_led = func;
-s-opaque = opaque;
-QTAILQ_INSERT_TAIL(led_handlers, s, next);
-return s;
+notifier_list_add(led_event_notifiers, notify);
 }
 
-void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry)
+void qemu_remove_led_event_notifier(Notifier *notify)
 {
-if (entry == NULL)
-return;
-QTAILQ_REMOVE(led_handlers, entry, next);
-qemu_free(entry);
+notifier_list_remove(led_event_notifiers, notify);
 }
 
 void kbd_put_keycode(int keycode)
@@ -128,15 +119,19 @@ void kbd_put_keycode(int keycode)
 }
 }
 
-void kbd_put_ledstate(int ledstate)
+void kbd_put_ledstate(int l)
 {
-QEMUPutLEDEntry *cursor;
-
-QTAILQ_FOREACH(cursor, led_handlers, next) {
-cursor-put_led(cursor-opaque, ledstate);
+if (ledstate != l) {
+ledstate = l;
+notifier_list_notify(led_event_notifiers);
 }
 }
 
+int kbd_get_ledstate(void)
+{
+return ledstate;
+}
+
 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
 {
 QEMUPutMouseEntry *entry;
diff --git a/vnc.c b/vnc.c
index b1a3fdb..e497c70 100644
--- a/vnc.c
+++ b/vnc.c
@@ -939,7 +939,7 @@ static void vnc_disconnect_finish(VncState *vs)
 qemu_remove_mouse_mode_change_notifier(vs-mouse_mode_notifier);
 vnc_remove_timer(vs-vd);
 if (vs-vd-lock_key_sync)
-qemu_remove_led_event_handler(vs-led);
+qemu_remove_led_event_notifier(vs-led_notifier);
 qemu_free(vs);
 }
 
@@ -1332,9 +1332,10 @@ static void press_key(VncState *vs, int keysym)
 kbd_put_keycode(keycode | SCANCODE_UP);
 }
 
-static void kbd_leds(void *opaque, int ledstate)
+static void kbd_leds(Notifier *notifier)
 {
-VncState *vs = opaque;
+VncState *vs = container_of(notifier, VncState, led_notifier);
+int ledstate = kbd_get_ledstate();
 int caps, num;
 
 caps = ledstate  QEMU_CAPS_LOCK_LED ? 1 : 0;
@@ -2234,8 +2235,10 @@ static void vnc_connect(VncDisplay *vd, int csock)
 vnc_flush(vs);
 vnc_read_when(vs, protocol_version, 12);
 reset_keys(vs);
-if (vs-vd-lock_key_sync)
-vs-led = qemu_add_led_event_handler(kbd_leds, vs);
+if (vs-vd-lock_key_sync) {
+vs-led_notifier.notify = kbd_leds;
+qemu_add_led_event_notifier(vs-led_notifier);
+}
 
 vs-mouse_mode_notifier.notify = check_pointer_type_change;
 qemu_add_mouse_mode_change_notifier(vs-mouse_mode_notifier);
diff 

Re: [Qemu-devel] Call for 0.12.4

2010-05-07 Thread Aurelien Jarno
Anthony Liguori a écrit :
 On 05/06/2010 08:09 AM, Kevin Wolf wrote:
 Am 08.04.2010 20:37, schrieb Aurelien Jarno:

 Hi all,

 A number of fixes have been accumulated in the stable-0.12 branch, and
 I think it's time to release a new stable version. I would like to see
 that happening for the end of next week (around the 18th of April).

 If you want to see some patches included, please send a mail to the
 mailing list with the [STABLE] tag. I would clearly prefer patches that
 are already in HEAD (if the patch can simply be cherry-picked, there is
 no need to send a patch, just the commit number), though other patches
 might be considered too.
  
 Not sure if it's already too late for 0.12.4, but this one should be
 applied to the stable-0.12 branch:

 
 I've already tagged 0.12.4.
 

The tag doesn't seem to be in the git tree, are you sure you have pushed it?

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




[Qemu-devel] [PATCH 3/5] Add qemu stdvga pci bios

2010-05-07 Thread Gerd Hoffmann
Add PCI vgabios for the qemu standard vga (1234:).
Name it vgabios-stdvga.bin.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 Makefile |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index d440b93..58f064e 100644
--- a/Makefile
+++ b/Makefile
@@ -14,12 +14,14 @@ RELVERS = `pwd | sed s-.*/-- | sed s/vgabios// | sed 
s/-//`
 
 VGABIOS_DATE = -DVGABIOS_DATE=\$(RELDATE)\
 
-all: bios cirrus-bios
+all: bios cirrus-bios stdvga-bios
 
 bios: vgabios.bin vgabios.debug.bin
 
 cirrus-bios: vgabios-cirrus.bin vgabios-cirrus.debug.bin
 
+stdvga-bios: vgabios-stdvga.bin vgabios-stdvga.debug.bin
+
 clean:
/bin/rm -f  biossums vbetables-gen vbetables.h *.o *.s *.ld86 \
   temp.awk.* vgabios*.orig _vgabios_* _vgabios-debug_* core 
vgabios*.bin vgabios*.txt $(RELEASE).bin *.bak
@@ -35,18 +37,24 @@ vgabios.bin  : VGAFLAGS := -DVBE 
-DPCI_VID=0x1234
 vgabios.debug.bin: VGAFLAGS := -DVBE -DPCI_VID=0x1234 -DDEBUG
 vgabios-cirrus.bin   : VGAFLAGS := -DCIRRUS -DPCIBIOS 
 vgabios-cirrus.debug.bin : VGAFLAGS := -DCIRRUS -DPCIBIOS -DCIRRUS_DEBUG
+vgabios-stdvga.bin   : VGAFLAGS := -DVBE -DPCIBIOS -DPCI_VID=0x1234 
-DPCI_DID=0x
+vgabios-stdvga.debug.bin : VGAFLAGS := -DVBE -DPCIBIOS -DPCI_VID=0x1234 
-DPCI_DID=0x -DDEBUG
 
 # dist names
 vgabios.bin  : DISTNAME := VGABIOS-lgpl-latest.bin
 vgabios.debug.bin: DISTNAME := VGABIOS-lgpl-latest.debug.bin
 vgabios-cirrus.bin   : DISTNAME := VGABIOS-lgpl-latest.cirrus.bin
 vgabios-cirrus.debug.bin : DISTNAME := VGABIOS-lgpl-latest.cirrus.debug.bin
+vgabios-stdvga.bin   : DISTNAME := VGABIOS-lgpl-latest.stdvga.bin
+vgabios-stdvga.debug.bin : DISTNAME := VGABIOS-lgpl-latest.stdvga.debug.bin
 
 # dependencies
 vgabios.bin  : $(VGA_FILES) $(VBE_FILES) biossums
 vgabios.debug.bin: $(VGA_FILES) $(VBE_FILES) biossums
 vgabios-cirrus.bin   : $(VGA_FILES) clext.c biossums
 vgabios-cirrus.debug.bin : $(VGA_FILES) clext.c biossums
+vgabios-stdvga.bin   : $(VGA_FILES) $(VBE_FILES) biossums
+vgabios-stdvga.debug.bin : $(VGA_FILES) $(VBE_FILES) biossums
 
 # build rule
 %.bin:
-- 
1.6.6.1





[Qemu-devel] [PATCH 5/5] Add qemu vmware vga pci bios

2010-05-07 Thread Gerd Hoffmann
Add PCI vgabios for the qemu vmeare vga (15ad:0405).
Name it vgabios-vmware.bin.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 Makefile |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 58f064e..2a093e8 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ RELVERS = `pwd | sed s-.*/-- | sed s/vgabios// | sed 
s/-//`
 
 VGABIOS_DATE = -DVGABIOS_DATE=\$(RELDATE)\
 
-all: bios cirrus-bios stdvga-bios
+all: bios cirrus-bios stdvga-bios vmware-bios
 
 bios: vgabios.bin vgabios.debug.bin
 
@@ -22,6 +22,8 @@ cirrus-bios: vgabios-cirrus.bin vgabios-cirrus.debug.bin
 
 stdvga-bios: vgabios-stdvga.bin vgabios-stdvga.debug.bin
 
+vmware-bios: vgabios-vmware.bin vgabios-vmware.debug.bin
+
 clean:
/bin/rm -f  biossums vbetables-gen vbetables.h *.o *.s *.ld86 \
   temp.awk.* vgabios*.orig _vgabios_* _vgabios-debug_* core 
vgabios*.bin vgabios*.txt $(RELEASE).bin *.bak
@@ -39,6 +41,8 @@ vgabios-cirrus.bin   : VGAFLAGS := -DCIRRUS -DPCIBIOS
 vgabios-cirrus.debug.bin : VGAFLAGS := -DCIRRUS -DPCIBIOS -DCIRRUS_DEBUG
 vgabios-stdvga.bin   : VGAFLAGS := -DVBE -DPCIBIOS -DPCI_VID=0x1234 
-DPCI_DID=0x
 vgabios-stdvga.debug.bin : VGAFLAGS := -DVBE -DPCIBIOS -DPCI_VID=0x1234 
-DPCI_DID=0x -DDEBUG
+vgabios-vmware.bin   : VGAFLAGS := -DVBE -DPCIBIOS -DPCI_VID=0x15ad 
-DPCI_DID=0x0405
+vgabios-vmware.debug.bin : VGAFLAGS := -DVBE -DPCIBIOS -DPCI_VID=0x15ad 
-DPCI_DID=0x0405 -DDEBUG
 
 # dist names
 vgabios.bin  : DISTNAME := VGABIOS-lgpl-latest.bin
@@ -47,6 +51,8 @@ vgabios-cirrus.bin   : DISTNAME := 
VGABIOS-lgpl-latest.cirrus.bin
 vgabios-cirrus.debug.bin : DISTNAME := VGABIOS-lgpl-latest.cirrus.debug.bin
 vgabios-stdvga.bin   : DISTNAME := VGABIOS-lgpl-latest.stdvga.bin
 vgabios-stdvga.debug.bin : DISTNAME := VGABIOS-lgpl-latest.stdvga.debug.bin
+vgabios-vmware.bin   : DISTNAME := VGABIOS-lgpl-latest.vmware.bin
+vgabios-vmware.debug.bin : DISTNAME := VGABIOS-lgpl-latest.vmware.debug.bin
 
 # dependencies
 vgabios.bin  : $(VGA_FILES) $(VBE_FILES) biossums
@@ -55,6 +61,8 @@ vgabios-cirrus.bin   : $(VGA_FILES) clext.c biossums
 vgabios-cirrus.debug.bin : $(VGA_FILES) clext.c biossums
 vgabios-stdvga.bin   : $(VGA_FILES) $(VBE_FILES) biossums
 vgabios-stdvga.debug.bin : $(VGA_FILES) $(VBE_FILES) biossums
+vgabios-vmware.bin   : $(VGA_FILES) $(VBE_FILES) biossums
+vgabios-vmware.debug.bin : $(VGA_FILES) $(VBE_FILES) biossums
 
 # build rule
 %.bin:
-- 
1.6.6.1





[Qemu-devel] [PATCH] QMP: Add Downstream extension of QMP to spec

2010-05-07 Thread Markus Armbruster
Rules for how to extend QMP downstream (if you really have to) without
creating interoparability hassles.

Signed-off-by: Markus Armbruster arm...@redhat.com
---
Aside:

* Advice on downstream modifications, items 1. and 2. could use a
  rationale.

* Section '5 Compatibility Considerations' could use some love.

 QMP/qmp-spec.txt |   55 ++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/QMP/qmp-spec.txt b/QMP/qmp-spec.txt
index f3c0327..dc2eb4b 100644
--- a/QMP/qmp-spec.txt
+++ b/QMP/qmp-spec.txt
@@ -215,3 +215,58 @@ Additionally, Clients must not assume any particular:
 - Order of json-object members or json-array elements
 - Amount of errors generated by a command, that is, new errors can be added
   to any existing command in newer versions of the Server
+
+6. Downstream extension of QMP
+--
+
+We recommend that downstream consumers of QEMU do *not* modify QMP.
+Management tools should be able to support both upstream and downstream
+versions of QMP without special logic, and downstream extensions are
+inherently at odds with that.
+
+However, we recognize that it is sometimes impossible for downstreams to
+avoid modifying QMP.  Both upstream and downstream need to take care to
+preserve long-term compatibility and interoperability.
+
+To help with that, QMP reserves JSON object member names beginning with
+'__' (double underscore) for downstream use (downstream names).  This
+means upstream will never use any downstream names for its commands,
+arguments, errors, asynchronous events, and so forth.
+
+Any new names downstream wishes to add must begin with '__'.  To ensure
+compatibility with other downstreams, it is strongly recommended that
+you prefix the commands with '__RFQDN_' where RFQDN is a valid, reverse
+fully qualified domain name which you control.  For example, a qemu-kvm
+specific monitor command would be:
+
+(qemu) __org.linux-kvm_enable_irqchip
+
+Downstream must not change the server greeting (section 2.2) other than
+to offer additional capabilities.  But see below for why even that is
+discouraged.
+
+Section '5 Compatibility Considerations' applies to downstream as well
+as to upstream, obviously.  It follows that downstream must behave
+exactly like upstream for any input not containing members with
+downstream names (downstream members), except it may add members
+with downstream names to its output.
+
+Thus, a client should not be able to distinguish downstream from
+upstream as long as it doesn't send input with downstream members, and
+properly ignores any downstream members in the output it receives.
+
+Advice on downstream modifications:
+
+1. Introducing new commands is okay.  If you want to extend an existing
+   command, consider introducing a new one with the new behaviour
+   instead.
+
+2. Introducing new asynchronous messages is okay.  If you want to extend
+   an existing message, consider adding a new one instead.
+
+3. Introducing new errors for use in new commands is okay.  Adding new
+   errors to existing commands counts as extension, so 1. applies.
+
+4. New capabilities are strongly discouraged.  Capabilities are for
+   evolving the basic protocol, and multiple diverging basic protocol
+   dialects are most undesirable.
-- 
1.6.6.1





Re: [Qemu-devel] Call for 0.12.4

2010-05-07 Thread Anthony Liguori

On 05/07/2010 04:40 AM, Aurelien Jarno wrote:

Anthony Liguori a écrit :
   

On 05/06/2010 08:09 AM, Kevin Wolf wrote:
 

Am 08.04.2010 20:37, schrieb Aurelien Jarno:

   

Hi all,

A number of fixes have been accumulated in the stable-0.12 branch, and
I think it's time to release a new stable version. I would like to see
that happening for the end of next week (around the 18th of April).

If you want to see some patches included, please send a mail to the
mailing list with the [STABLE] tag. I would clearly prefer patches that
are already in HEAD (if the patch can simply be cherry-picked, there is
no need to send a patch, just the commit number), though other patches
might be considered too.

 

Not sure if it's already too late for 0.12.4, but this one should be
applied to the stable-0.12 branch:

   

I've already tagged 0.12.4.

 

The tag doesn't seem to be in the git tree, are you sure you have pushed it?
   


Yeah, I forgot to push the tag.  It's done now.

Regards,

Anthony Liguori






[Qemu-devel] [ANNOUNCE] Release 0.12.4 of QEMU

2010-05-07 Thread Anthony Liguori

The QEMU team is pleased to announce the availability of the 0.12.4
release.  This is a stable release of the 0.12 series and only contains 
bug fixes since 0.12.3.


It can be downloaded from Savannah at:

http://download.savannah.gnu.org/releases/qemu/qemu-0.12.4.tar.gz

On behalf of the QEMU team, I'd like to thank everyone who contributed
to make this release happen!

 - Workaround for broken OSS_GETVERSION on FreeBSD, part two (Juergen Lock)
 - oss: fix fragment setting (malc)
 - oss: issue OSS_GETVERSION ioctl only when needed (malc)
 - oss: refactor code around policy setting (malc)
 - oss: workaround for cases when OSS_GETVERSION is not defined (malc)
 - block: Free iovec arrays allocated by multiwrite_merge() (Stefan 
Hajnoczi)

 - lsi: fix segfault in lsi_command_complete (Gerd Hoffmann)
 - lsi: pass lsi_request to lsi_reselect (Gerd Hoffmann)
 - lsi: move dma_len+dma_buf into lsi_request (Gerd Hoffmann)
 - lsi: move current_dev into lsi_request (Gerd Hoffmann)
 - lsi: have lsi_request for the whole life time of the request. (Gerd 
Hoffmann)

 - lsi: use QTAILQ for lsi_queue (Gerd Hoffmann)
 - tcp/mips: Change TCG_AREG0 (fp - s0) (Stefan Weil)
 - sh_pci: fix memory and I/O access (Aurelien Jarno)
 - Fix incoming migration with iothread (Marcelo Tosatti)
 - Fix SIGFPE for vnc display of width/height = 1 (Chris Webb)
 - net: remove broken net_set_boot_mask() boot device validation 
(Eduardo Habkost)

 - qcow2: Remove request from in-flight list after error (Kevin Wolf)
 - qcow2: Don't ignore immediate read/write failures (Kevin Wolf)
 - block: Fix multiwrite memory leak in error case (Kevin Wolf)
 - block: Fix error code in multiwrite for immediate failures (Kevin Wolf)
 - block: Fix multiwrite error handling (Kevin Wolf)
 - scsi-disk: fix buffer overflow (Gerd Hoffmann)
 - qcow2: Rewrite alloc_refcount_block/grow_refcount_table (Kevin Wolf)
 - qcow2: Factor next_refcount_table_size out (Kevin Wolf)
 - block: avoid creating too large iovecs in multiwrite_merge 
(Christoph Hellwig)

 - json-parser: Fix segfault on malformed input (Kevin Wolf)
 - linux-user: switch default ppc64 CPU to 970fx from 970 (Aurelien Jarno)
 - target-sh4: MMU: fix store queue addresses (Aurelien Jarno)
 - target-sh4: MMU: fix ITLB priviledge check (Aurelien Jarno)
 - target-sh4: MMU: fix mem_idx computation (Aurelien Jarno)
 - sh7750: handle MMUCR TI bit (Aurelien Jarno)
 - UHCI spurious interrut fix (Paul Brook)
 - tcg/mips: fix branch offset during retranslation (Aurelien Jarno)
 - tcg/arm: correctly save/restore registers in prologue/epilogue 
(Aurelien Jarno)
 - workaround for cmd646 bmdma register access while no dma is active 
(Igor V. Kovalenko)

 - Fix corner case in chardev udp: parameter (Jan Kiszka)
 - Don't set default monitor when there is a mux'ed one (Jan Kiszka)
 - spelling typo (compatibilty) in hw/fw_cfg.c (Vagrant Cascadian)
 - fdc: fix drive property handling. (Gerd Hoffmann)
 - target-i386: fix commit c22549204a6edc431e8e4358e61bd56386ff6957 
(TeLeMan)

 - target-i386: fix SIB decoding with index = 4 (Aurelien Jarno)
 - Fix segfault with ram_size  4095M without kvm (Ryan Harper)
 - target-i386: Fix long jumps/calls in long mode with REX.W set (malc)
 - target-i386: fix lddqu SSE instruction (Aurelien Jarno)
 - qemu-char.c: drop debug printfs from qemu_chr_parse_compat (Jan Kiszka)
 - fix undefined shifts by 32 (Paolo Bonzini)
 - Fix qemu -net user,hostfwd= example (Aurelien Jarno)





[Qemu-devel] Re: Registering buffers with a qdict

2010-05-07 Thread Jan Kiszka
Luiz Capitulino wrote:
 On Fri, 07 May 2010 13:45:03 +0200
 Jan Kiszka jan.kis...@siemens.com wrote:
 
 Hi Luiz,

 what is the recommended way of pushing larger buffers (up to 64K so far)
 into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought
 about hex-encoding the content first (series of %02X), then
 registering it as QSTRING. Or should we introduce a new type, QBUFFER?
 
  I don't think that hex-encoding the contents is so bad if your use case is
 very specific and isolated.

The focus will be first on visualizing the buffer (user_print), but who
knows what happens once the services is also exposed via QMP.

 
  On the other hand, I do prefer a QBuffer type, specially because we can
 have buffer operations.

The qtype.c files look sufficiently simply, guess I will add a buffer
type. Still, hex-encoding is probably the best representation for QMP.

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux




Re: [Qemu-devel] [PATCH 1/5] Makefile cleanup

2010-05-07 Thread Isaku Yamahata
Hi. If gmake extension is allowed, nasty rm in the rule can be removed
by using intermediate file which is removed after build.
We can combine your cleanup with mine.

[PATCH] vgabios: Makefile: clean up using gmake extension.

clean up nasty rule by using gmake extension

Signed-off-by: Isaku Yamahata yamah...@valinux.co.jp
---
 Makefile |   92 +
 1 files changed, 44 insertions(+), 48 deletions(-)

diff --git a/Makefile b/Makefile
index 00e8c66..4ead342 100644
--- a/Makefile
+++ b/Makefile
@@ -17,13 +17,14 @@ VGABIOS_DATE = -DVGABIOS_DATE=\$(RELDATE)\
 all: bios cirrus-bios
 
 
-bios: biossums vgabios.bin vgabios.debug.bin
+bios: biossums VGABIOS-lgpl-latest.bin VGABIOS-lgpl-latest.debug.bin
 
-cirrus-bios: vgabios-cirrus.bin vgabios-cirrus.debug.bin
+cirrus-bios: VGABIOS-lgpl-latest.cirrus.bin 
VGABIOS-lgpl-latest.cirrus.debug.bin
 
 clean:
/bin/rm -f  biossums vbetables-gen vbetables.h *.o *.s *.ld86 \
-  temp.awk.* vgabios*.orig _vgabios_* _vgabios-debug_* core 
vgabios*.bin vgabios*.txt $(RELEASE).bin *.bak
+  temp.awk.* vgabios*.orig _vgabios_* _vgabios.*_* core \
+  VGABIOS-lgpl-latest*.bin vgabios*.bin vgabios*.txt $(RELEASE).bin 
*.bak
 
 dist-clean: clean
 
@@ -37,51 +38,46 @@ release:
cp VGABIOS-lgpl-latest.cirrus.debug.bin ../$(RELEASE).cirrus.debug.bin
tar czvf ../$(RELEASE).tgz --exclude CVS -C .. $(RELEASE)/
 
-vgabios.bin: vgabios.c vgabios.h vgafonts.h vgatables.h vbe.h vbe.c vbetables.h
-   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DVBE $(VGABIOS_DATE)  
_vgabios_.c
-   $(BCC) -o vgabios.s -C-c -D__i86__ -S -0 _vgabios_.c
-   sed -e 's/^\.text//' -e 's/^\.data//' vgabios.s  _vgabios_.s
-   $(AS86) _vgabios_.s -b vgabios.bin -u -w- -g -0 -j -O -l vgabios.txt
-   rm -f _vgabios_.s _vgabios_.c vgabios.s
-   mv vgabios.bin VGABIOS-lgpl-latest.bin
-   ./biossums VGABIOS-lgpl-latest.bin
-   ls -l VGABIOS-lgpl-latest.bin
-
-vgabios.debug.bin: vgabios.c vgabios.h vgafonts.h vgatables.h vbe.h vbe.c 
vbetables.h
-   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DVBE -DDEBUG $(VGABIOS_DATE)  
_vgabios-debug_.c
-   $(BCC) -o vgabios-debug.s -C-c -D__i86__ -S -0 _vgabios-debug_.c
-   sed -e 's/^\.text//' -e 's/^\.data//' vgabios-debug.s  
_vgabios-debug_.s
-   $(AS86) _vgabios-debug_.s -b vgabios.debug.bin -u -w- -g -0 -j -O -l 
vgabios.debug.txt
-   rm -f _vgabios-debug_.s _vgabios-debug_.c vgabios-debug.s
-   mv vgabios.debug.bin VGABIOS-lgpl-latest.debug.bin
-   ./biossums VGABIOS-lgpl-latest.debug.bin
-   ls -l VGABIOS-lgpl-latest.debug.bin
-
-vgabios-cirrus.bin: vgabios.c vgabios.h vgafonts.h vgatables.h clext.c
-   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DCIRRUS -DPCIBIOS 
$(VGABIOS_DATE)  _vgabios-cirrus_.c
-   $(BCC) -o vgabios-cirrus.s -C-c -D__i86__ -S -0 _vgabios-cirrus_.c
-   sed -e 's/^\.text//' -e 's/^\.data//' vgabios-cirrus.s  
_vgabios-cirrus_.s
-   $(AS86) _vgabios-cirrus_.s -b vgabios-cirrus.bin -u -w- -g -0 -j -O -l 
vgabios.cirrus.txt
-   rm -f _vgabios-cirrus_.s _vgabios-cirrus_.c vgabios-cirrus.s
-   mv vgabios-cirrus.bin VGABIOS-lgpl-latest.cirrus.bin
-   ./biossums VGABIOS-lgpl-latest.cirrus.bin
-   ls -l VGABIOS-lgpl-latest.cirrus.bin
-
-vgabios-cirrus.debug.bin: vgabios.c vgabios.h vgafonts.h vgatables.h clext.c
-   $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DCIRRUS -DCIRRUS_DEBUG 
-DPCIBIOS $(VGABIOS_DATE)  _vgabios-cirrus-debug_.c
-   $(BCC) -o vgabios-cirrus-debug.s -C-c -D__i86__ -S -0 
_vgabios-cirrus-debug_.c
-   sed -e 's/^\.text//' -e 's/^\.data//' vgabios-cirrus-debug.s  
_vgabios-cirrus-debug_.s
-   $(AS86) _vgabios-cirrus-debug_.s -b vgabios.cirrus.debug.bin -u -w- -g 
-0 -j -O -l vgabios.cirrus.debug.txt
-   rm -f _vgabios-cirrus-debug_.s _vgabios-cirrus-debug_.c 
vgabios-cirrus-debug.s
-   mv vgabios.cirrus.debug.bin VGABIOS-lgpl-latest.cirrus.debug.bin
-   ./biossums VGABIOS-lgpl-latest.cirrus.debug.bin
-   ls -l VGABIOS-lgpl-latest.cirrus.debug.bin
-
-biossums: biossums.c
-   $(CC) -o biossums biossums.c
-
-vbetables-gen: vbetables-gen.c
-   $(CC) -o vbetables-gen vbetables-gen.c
+define gcc-e-p
+   $(GCC) -E -P $ $(VGABIOS_VERS) $(EXTRA_DEFINES) $(VGABIOS_DATE)  $@
+endef
+
+_vgabios_.c: EXTRA_DEFINES = -DVBE
+_vgabios_.c: vgabios.c vgabios.h vgafonts.h vgatables.h vbe.h vbe.c vbetables.h
+   $(gcc-e-p)
+
+_vgabios.debug_.c: EXTRA_DEFINES = -DVBE -DDEBUG
+_vgabios.debug_.c: vgabios.c vgabios.h vgafonts.h vgatables.h vbe.h vbe.c 
vbetables.h
+   $(gcc-e-p)
+
+_vgabios.cirrus_.c: EXTRA_DEFINES = -DCIRRUS -DPCIBIOS
+_vgabios.cirrus_.c: vgabios.c vgabios.h vgafonts.h vgatables.h clext.c
+   $(gcc-e-p)
+
+_vgabios.cirrus.debug_.c: EXTRA_DEFINES = -DCIRRUS -DCIRRUS_DEBUG -DPCIBIOS
+_vgabios.cirrus.debug_.c: vgabios.c vgabios.h vgafonts.h vgatables.h clext.c
+   $(gcc-e-p)
+
+.INTERMEDIATE: _vgabios_.c 

[Qemu-devel] [PATCH 0/3] dmg updates

2010-05-07 Thread Christoph Hellwig
This patchset fixes a bug found through code inspection in dmg,
and converts it to the qemu block driver API.  Note that I have no
way to actually generate dmg images, so it's entirely tested.

And compared to the dmg2img tool it seems we're missing support for
a lot of features in the dmg format, so I'm not even sure images
generated on recent MacOS version will work at all.




[Qemu-devel] [PATCH 1/3] dmg: fix reading of uncompressed chunks

2010-05-07 Thread Christoph Hellwig
When dmg_read_chunk encounters an uncompressed chunk it currently
calls read without any previous adjustment of the file postion.

This seems very wrong, and the reference implementation in
dmg2img does a search to the same offset as done in the various
compression cases, so do the same here.

Signed-off-by: Christoph Hellwig h...@lst.de

Index: qemu-kevin/block/dmg.c
===
--- qemu-kevin.orig/block/dmg.c 2010-05-03 13:15:34.112253995 +0200
+++ qemu-kevin/block/dmg.c  2010-05-03 13:17:40.696287171 +0200
@@ -239,7 +239,8 @@ static inline int dmg_read_chunk(BDRVDMG
return -1;
break; }
case 1: /* copy */
-   ret = read(s-fd, s-uncompressed_chunk, s-lengths[chunk]);
+   ret = pread(s-fd, s-uncompressed_chunk, s-lengths[chunk],
+s-offsets[chunk]);
if (ret != s-lengths[chunk])
return -1;
break;




[Qemu-devel] [PATCH 2/3] dmg: use pread

2010-05-07 Thread Christoph Hellwig
Use pread instead of lseek + read in preparation of using the qemu
block API.  Note that dmg actually uses the implicit file offset
a lot in dmg_open, and we had to replace it with an offset variable.

Signed-off-by: Christoph Hellwig h...@lst.de

Index: qemu-kevin/block/dmg.c
===
--- qemu-kevin.orig/block/dmg.c 2010-05-03 13:17:40.696287171 +0200
+++ qemu-kevin/block/dmg.c  2010-05-03 13:29:39.560024006 +0200
@@ -58,18 +58,18 @@ static int dmg_probe(const uint8_t *buf,
 return 0;
 }
 
-static off_t read_off(int fd)
+static off_t read_off(int fd, int64_t offset)
 {
uint64_t buffer;
-   if(read(fd,buffer,8)8)
+   if (pread(fd, buffer, 8, offset)  8)
return 0;
return be64_to_cpu(buffer);
 }
 
-static off_t read_uint32(int fd)
+static off_t read_uint32(int fd, int64_t offset)
 {
uint32_t buffer;
-   if(read(fd,buffer,4)4)
+   if (pread(fd, buffer, 4, offset)  4)
return 0;
return be32_to_cpu(buffer);
 }
@@ -80,6 +80,7 @@ static int dmg_open(BlockDriverState *bs
 off_t info_begin,info_end,last_in_offset,last_out_offset;
 uint32_t count;
 uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i;
+int64_t offset;
 
 s-fd = open(filename, O_RDONLY | O_BINARY);
 if (s-fd  0)
@@ -89,38 +90,45 @@ static int dmg_open(BlockDriverState *bs
 s-offsets = s-lengths = s-sectors = s-sectorcounts = NULL;
 
 /* read offset of info blocks */
-if(lseek(s-fd,-0x1d8,SEEK_END)0) {
+offset = lseek(s-fd, -0x1d8, SEEK_END);
+if (offset  0) {
 goto fail;
 }
 
-info_begin=read_off(s-fd);
-if(info_begin==0)
-   goto fail;
-if(lseek(s-fd,info_begin,SEEK_SET)0)
-   goto fail;
-if(read_uint32(s-fd)!=0x100)
-   goto fail;
-if((count = read_uint32(s-fd))==0)
-   goto fail;
-info_end = info_begin+count;
-if(lseek(s-fd,0xf8,SEEK_CUR)0)
+info_begin = read_off(s-fd, offset);
+if (info_begin == 0) {
goto fail;
+}
+
+if (read_uint32(s-fd, info_begin) != 0x100) {
+goto fail;
+}
+
+count = read_uint32(s-fd, info_begin + 4);
+if (count == 0) {
+goto fail;
+}
+info_end = info_begin + count;
+
+offset = info_begin + 0xfc;
 
 /* read offsets */
 last_in_offset = last_out_offset = 0;
-while(lseek(s-fd,0,SEEK_CUR)info_end) {
+while (offset  info_end) {
 uint32_t type;
 
-   count = read_uint32(s-fd);
+   count = read_uint32(s-fd, offset);
if(count==0)
goto fail;
-   type = read_uint32(s-fd);
-   if(type!=0x6d697368 || count244)
-   lseek(s-fd,count-4,SEEK_CUR);
-   else {
+offset += 4;
+
+   type = read_uint32(s-fd, offset);
+   if (type == 0x6d697368  count = 244) {
int new_size, chunk_count;
-   if(lseek(s-fd,200,SEEK_CUR)0)
-   goto fail;
+
+offset += 4;
+offset += 200;
+
chunk_count = (count-204)/40;
new_size = sizeof(uint64_t) * (s-n_chunks + chunk_count);
s-types = qemu_realloc(s-types, new_size/2);
@@ -130,7 +138,8 @@ static int dmg_open(BlockDriverState *bs
s-sectorcounts = qemu_realloc(s-sectorcounts, new_size);
 
for(i=s-n_chunks;is-n_chunks+chunk_count;i++) {
-   s-types[i] = read_uint32(s-fd);
+   s-types[i] = read_uint32(s-fd, offset);
+   offset += 4;
if(s-types[i]!=0x8005  s-types[i]!=1  s-types[i]!=2) 
{
if(s-types[i]==0x) {
last_in_offset = s-offsets[i-1]+s-lengths[i-1];
@@ -138,15 +147,24 @@ static int dmg_open(BlockDriverState *bs
}
chunk_count--;
i--;
-   if(lseek(s-fd,36,SEEK_CUR)0)
-   goto fail;
+   offset += 36;
continue;
}
-   read_uint32(s-fd);
-   s-sectors[i] = last_out_offset+read_off(s-fd);
-   s-sectorcounts[i] = read_off(s-fd);
-   s-offsets[i] = last_in_offset+read_off(s-fd);
-   s-lengths[i] = read_off(s-fd);
+   read_uint32(s-fd, offset);
+   offset += 4;
+
+   s-sectors[i] = last_out_offset+read_off(s-fd, offset);
+   offset += 8;
+
+   s-sectorcounts[i] = read_off(s-fd, offset);
+   offset += 8;
+
+   s-offsets[i] = last_in_offset+read_off(s-fd, offset);
+   offset += 8;
+
+   s-lengths[i] = read_off(s-fd, offset);
+   offset += 8;
+
if(s-lengths[i]max_compressed_size)
max_compressed_size = s-lengths[i];
if(s-sectorcounts[i]max_sectors_per_chunk)
@@ -210,15 +228,12 @@ static inline int dmg_read_chunk(BDRVDMG
case 

[Qemu-devel] [PULL 00/11] Block patches

2010-05-07 Thread Kevin Wolf
The following changes since commit 2065061ede22d401aae2ce995c3af54db9d28639:
  Igor V. Kovalenko (1):
sparc64: handle asi referencing nucleus and secondary MMU contexts

are available in the git repository at:

  git://repo.or.cz/qemu/kevin.git for-anthony

Christoph Hellwig (4):
  cloop: use pread
  cloop: use qemu block API
  bochs: use pread
  bochs: use qemu block API

Kevin Wolf (4):
  ide: Fix ide_dma_cancel
  block: Avoid unchecked casts for AIOCBs
  block: Fix protocol detection for Windows devices
  block: Fix bdrv_commit

Ryota Ozaki (1):
  qemu-nbd: Improve error reporting

Stefan Hajnoczi (1):
  block: Remove semicolon in BDRV_SECTOR_MASK macro

Stefan Weil (1):
  block/vdi: Allow disk images of size 0

 block.c  |   19 +++-
 block.h  |2 +-
 block/blkdebug.c |4 +-
 block/bochs.c|   81 +++--
 block/cloop.c|   48 
 block/qcow.c |2 +-
 block/qcow2.c|2 +-
 block/vdi.c  |   11 +--
 hw/ide/core.c|8 ++--
 qemu-nbd.c   |   34 --
 10 files changed, 99 insertions(+), 112 deletions(-)




[Qemu-devel] [PATCH 04/11] cloop: use qemu block API

2010-05-07 Thread Kevin Wolf
From: Christoph Hellwig h...@lst.de

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig h...@lst.de
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block/cloop.c |   26 --
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/block/cloop.c b/block/cloop.c
index 9fe2a42..fe015c4 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -27,7 +27,6 @@
 #include zlib.h
 
 typedef struct BDRVCloopState {
-int fd;
 uint32_t block_size;
 uint32_t n_blocks;
 uint64_t* offsets;
@@ -51,23 +50,20 @@ static int cloop_probe(const uint8_t *buf, int buf_size, 
const char *filename)
 return 0;
 }
 
-static int cloop_open(BlockDriverState *bs, const char *filename, int flags)
+static int cloop_open(BlockDriverState *bs, int flags)
 {
 BDRVCloopState *s = bs-opaque;
 uint32_t offsets_size,max_compressed_block_size=1,i;
 
-s-fd = open(filename, O_RDONLY | O_BINARY);
-if (s-fd  0)
-return -errno;
 bs-read_only = 1;
 
 /* read header */
-if (pread(s-fd, s-block_size, 4, 128)  4) {
+if (bdrv_pread(bs-file, 128, s-block_size, 4)  4) {
 goto cloop_close;
 }
 s-block_size = be32_to_cpu(s-block_size);
 
-if (pread(s-fd, s-n_blocks, 4, 128 + 4)  4) {
+if (bdrv_pread(bs-file, 128 + 4, s-n_blocks, 4)  4) {
 goto cloop_close;
 }
 s-n_blocks = be32_to_cpu(s-n_blocks);
@@ -75,7 +71,8 @@ static int cloop_open(BlockDriverState *bs, const char 
*filename, int flags)
 /* read offsets */
 offsets_size = s-n_blocks * sizeof(uint64_t);
 s-offsets = qemu_malloc(offsets_size);
-if (pread(s-fd, s-offsets, offsets_size, 128 + 4 + 4)  offsets_size) {
+if (bdrv_pread(bs-file, 128 + 4 + 4, s-offsets, offsets_size) 
+offsets_size) {
goto cloop_close;
 }
 for(i=0;is-n_blocks;i++) {
@@ -99,17 +96,19 @@ static int cloop_open(BlockDriverState *bs, const char 
*filename, int flags)
 return 0;
 
 cloop_close:
-close(s-fd);
 return -1;
 }
 
-static inline int cloop_read_block(BDRVCloopState *s,int block_num)
+static inline int cloop_read_block(BlockDriverState *bs, int block_num)
 {
+BDRVCloopState *s = bs-opaque;
+
 if(s-current_block != block_num) {
int ret;
 uint32_t bytes = s-offsets[block_num+1]-s-offsets[block_num];
 
-ret = pread(s-fd, s-compressed_block, bytes, s-offsets[block_num]);
+ret = bdrv_pread(bs-file, s-offsets[block_num], s-compressed_block,
+ bytes);
 if (ret != bytes)
 return -1;
 
@@ -138,7 +137,7 @@ static int cloop_read(BlockDriverState *bs, int64_t 
sector_num,
 for(i=0;inb_sectors;i++) {
uint32_t sector_offset_in_block=((sector_num+i)%s-sectors_per_block),
block_num=(sector_num+i)/s-sectors_per_block;
-   if(cloop_read_block(s, block_num) != 0)
+   if(cloop_read_block(bs, block_num) != 0)
return -1;
memcpy(buf+i*512,s-uncompressed_block+sector_offset_in_block*512,512);
 }
@@ -148,7 +147,6 @@ static int cloop_read(BlockDriverState *bs, int64_t 
sector_num,
 static void cloop_close(BlockDriverState *bs)
 {
 BDRVCloopState *s = bs-opaque;
-close(s-fd);
 if(s-n_blocks0)
free(s-offsets);
 free(s-compressed_block);
@@ -160,7 +158,7 @@ static BlockDriver bdrv_cloop = {
 .format_name   = cloop,
 .instance_size = sizeof(BDRVCloopState),
 .bdrv_probe= cloop_probe,
-.bdrv_file_open= cloop_open,
+.bdrv_open = cloop_open,
 .bdrv_read = cloop_read,
 .bdrv_close= cloop_close,
 };
-- 
1.6.6.1





[Qemu-devel] [PATCH 02/11] qemu-nbd: Improve error reporting

2010-05-07 Thread Kevin Wolf
From: Ryota Ozaki ozaki.ry...@gmail.com

- use err(3) instead of errx(3) if errno is available
  to report why failed
- let fail prior to daemon(3) if opening a nbd file
  is likely to fail after daemonizing to avoid silent
  failure exit
- add missing 'ret = 1' when unix_socket_outgoing failed

Signed-off-by: Ryota Ozaki ozaki.ry...@gmail.com
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 qemu-nbd.c |   34 --
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 25aa913..4e607cf 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -112,9 +112,12 @@ static int find_partition(BlockDriverState *bs, int 
partition,
 uint8_t data[512];
 int i;
 int ext_partnum = 4;
+int ret;
 
-if (bdrv_read(bs, 0, data, 1))
-errx(EXIT_FAILURE, error while reading);
+if ((ret = bdrv_read(bs, 0, data, 1))  0) {
+errno = -ret;
+err(EXIT_FAILURE, error while reading);
+}
 
 if (data[510] != 0x55 || data[511] != 0xaa) {
 errno = -EINVAL;
@@ -132,8 +135,10 @@ static int find_partition(BlockDriverState *bs, int 
partition,
 uint8_t data1[512];
 int j;
 
-if (bdrv_read(bs, mbr[i].start_sector_abs, data1, 1))
-errx(EXIT_FAILURE, error while reading);
+if ((ret = bdrv_read(bs, mbr[i].start_sector_abs, data1, 1))  0) {
+errno = -ret;
+err(EXIT_FAILURE, error while reading);
+}
 
 for (j = 0; j  4; j++) {
 read_partition(data1[446 + 16 * j], ext[j]);
@@ -316,7 +321,7 @@ int main(int argc, char **argv)
 if (disconnect) {
 fd = open(argv[optind], O_RDWR);
 if (fd == -1)
-errx(EXIT_FAILURE, Cannot open %s, argv[optind]);
+err(EXIT_FAILURE, Cannot open %s, argv[optind]);
 
 nbd_disconnect(fd);
 
@@ -333,23 +338,30 @@ int main(int argc, char **argv)
 if (bs == NULL)
 return 1;
 
-if (bdrv_open(bs, argv[optind], flags, NULL)  0)
-return 1;
+if ((ret = bdrv_open(bs, argv[optind], flags, NULL))  0) {
+errno = -ret;
+err(EXIT_FAILURE, Failed to bdrv_open '%s', argv[optind]);
+}
 
 fd_size = bs-total_sectors * 512;
 
 if (partition != -1 
 find_partition(bs, partition, dev_offset, fd_size))
-errx(EXIT_FAILURE, Could not find partition %d, partition);
+err(EXIT_FAILURE, Could not find partition %d, partition);
 
 if (device) {
 pid_t pid;
 int sock;
 
+/* want to fail before daemonizing */
+if (access(device, R_OK|W_OK) == -1) {
+err(EXIT_FAILURE, Could not access '%s', device);
+}
+
 if (!verbose) {
 /* detach client and server */
 if (daemon(0, 0) == -1) {
-errx(EXIT_FAILURE, Failed to daemonize);
+err(EXIT_FAILURE, Failed to daemonize);
 }
 }
 
@@ -372,8 +384,10 @@ int main(int argc, char **argv)
 do {
 sock = unix_socket_outgoing(socket);
 if (sock == -1) {
-if (errno != ENOENT  errno != ECONNREFUSED)
+if (errno != ENOENT  errno != ECONNREFUSED) {
+ret = 1;
 goto out;
+}
 sleep(1);  /* wait children */
 }
 } while (sock == -1);
-- 
1.6.6.1





[Qemu-devel] [PATCH 03/11] cloop: use pread

2010-05-07 Thread Kevin Wolf
From: Christoph Hellwig h...@lst.de

Use pread instead of lseek + read in preparation of using the qemu
block API.

Signed-off-by: Christoph Hellwig h...@lst.de
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block/cloop.c |   32 +---
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/block/cloop.c b/block/cloop.c
index e4f995b..9fe2a42 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -62,23 +62,22 @@ static int cloop_open(BlockDriverState *bs, const char 
*filename, int flags)
 bs-read_only = 1;
 
 /* read header */
-if(lseek(s-fd,128,SEEK_SET)0) {
-cloop_close:
-   close(s-fd);
-   return -1;
+if (pread(s-fd, s-block_size, 4, 128)  4) {
+goto cloop_close;
 }
-if(read(s-fd,s-block_size,4)4)
-   goto cloop_close;
-s-block_size=be32_to_cpu(s-block_size);
-if(read(s-fd,s-n_blocks,4)4)
-   goto cloop_close;
-s-n_blocks=be32_to_cpu(s-n_blocks);
+s-block_size = be32_to_cpu(s-block_size);
+
+if (pread(s-fd, s-n_blocks, 4, 128 + 4)  4) {
+goto cloop_close;
+}
+s-n_blocks = be32_to_cpu(s-n_blocks);
 
 /* read offsets */
-offsets_size=s-n_blocks*sizeof(uint64_t);
-s-offsets=(uint64_t*)qemu_malloc(offsets_size);
-if(read(s-fd,s-offsets,offsets_size)offsets_size)
+offsets_size = s-n_blocks * sizeof(uint64_t);
+s-offsets = qemu_malloc(offsets_size);
+if (pread(s-fd, s-offsets, offsets_size, 128 + 4 + 4)  offsets_size) {
goto cloop_close;
+}
 for(i=0;is-n_blocks;i++) {
s-offsets[i]=be64_to_cpu(s-offsets[i]);
if(i0) {
@@ -98,6 +97,10 @@ cloop_close:
 s-sectors_per_block = s-block_size/512;
 bs-total_sectors = s-n_blocks*s-sectors_per_block;
 return 0;
+
+cloop_close:
+close(s-fd);
+return -1;
 }
 
 static inline int cloop_read_block(BDRVCloopState *s,int block_num)
@@ -106,8 +109,7 @@ static inline int cloop_read_block(BDRVCloopState *s,int 
block_num)
int ret;
 uint32_t bytes = s-offsets[block_num+1]-s-offsets[block_num];
 
-   lseek(s-fd, s-offsets[block_num], SEEK_SET);
-ret = read(s-fd, s-compressed_block, bytes);
+ret = pread(s-fd, s-compressed_block, bytes, s-offsets[block_num]);
 if (ret != bytes)
 return -1;
 
-- 
1.6.6.1





[Qemu-devel] [PATCH 06/11] bochs: use pread

2010-05-07 Thread Kevin Wolf
From: Christoph Hellwig h...@lst.de

Use pread instead of lseek + read in preparation of using the qemu
block API.

Signed-off-by: Christoph Hellwig h...@lst.de
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block/bochs.c |   63 ++--
 1 files changed, 20 insertions(+), 43 deletions(-)

diff --git a/block/bochs.c b/block/bochs.c
index e952670..b54f54d 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -125,7 +125,7 @@ static int bochs_open(BlockDriverState *bs, const char 
*filename, int flags)
 
 s-fd = fd;
 
-if (read(fd, bochs, sizeof(bochs)) != sizeof(bochs)) {
+if (pread(fd, bochs, sizeof(bochs), 0) != sizeof(bochs)) {
 goto fail;
 }
 
@@ -144,14 +144,10 @@ static int bochs_open(BlockDriverState *bs, const char 
*filename, int flags)
   bs-total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
 }
 
-if (lseek(s-fd, le32_to_cpu(bochs.header), SEEK_SET) == (off_t)-1) {
-goto fail;
-}
-
 s-catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
 s-catalog_bitmap = qemu_malloc(s-catalog_size * 4);
-if (read(s-fd, s-catalog_bitmap, s-catalog_size * 4) !=
-   s-catalog_size * 4)
+if (pread(s-fd, s-catalog_bitmap, s-catalog_size * 4,
+  le32_to_cpu(bochs.header)) != s-catalog_size * 4)
goto fail;
 for (i = 0; i  s-catalog_size; i++)
le32_to_cpus(s-catalog_bitmap[i]);
@@ -169,54 +165,35 @@ static int bochs_open(BlockDriverState *bs, const char 
*filename, int flags)
 return -1;
 }
 
-static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
+static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
 {
 BDRVBochsState *s = bs-opaque;
 int64_t offset = sector_num * 512;
-int64_t extent_index, extent_offset, bitmap_offset, block_offset;
+int64_t extent_index, extent_offset, bitmap_offset;
 char bitmap_entry;
 
 // seek to sector
 extent_index = offset / s-extent_size;
 extent_offset = (offset % s-extent_size) / 512;
 
-if (s-catalog_bitmap[extent_index] == 0x)
-{
-// fprintf(stderr, page not allocated [%x - %x:%x]\n,
-// sector_num, extent_index, extent_offset);
-   return -1; // not allocated
+if (s-catalog_bitmap[extent_index] == 0x) {
+   return -1; /* not allocated */
 }
 
 bitmap_offset = s-data_offset + (512 * s-catalog_bitmap[extent_index] *
(s-extent_blocks + s-bitmap_blocks));
-block_offset = bitmap_offset + (512 * (s-bitmap_blocks + extent_offset));
-
-//fprintf(stderr, sect: %x [ext i: %x o: %x] - %x bitmap: %x block: 
%x\n,
-// sector_num, extent_index, extent_offset,
-// le32_to_cpu(s-catalog_bitmap[extent_index]),
-// bitmap_offset, block_offset);
-
-// read in bitmap for current extent
-if (lseek(s-fd, bitmap_offset + (extent_offset / 8), SEEK_SET) ==
-(off_t)-1) {
-return -1;
-}
 
-if (read(s-fd, bitmap_entry, 1) != 1)
+/* read in bitmap for current extent */
+if (pread(s-fd, bitmap_entry, 1, bitmap_offset + (extent_offset / 8))
+!= 1) {
 return -1;
-
-if (!((bitmap_entry  (extent_offset % 8))  1))
-{
-// fprintf(stderr, sector (%x) in bitmap not allocated\n,
-// sector_num);
-   return -1; // not allocated
 }
 
-if (lseek(s-fd, block_offset, SEEK_SET) == (off_t)-1) {
-return -1;
+if (!((bitmap_entry  (extent_offset % 8))  1)) {
+   return -1; /* not allocated */
 }
 
-return 0;
+return bitmap_offset + (512 * (s-bitmap_blocks + extent_offset));
 }
 
 static int bochs_read(BlockDriverState *bs, int64_t sector_num,
@@ -226,13 +203,13 @@ static int bochs_read(BlockDriverState *bs, int64_t 
sector_num,
 int ret;
 
 while (nb_sectors  0) {
-   if (!seek_to_sector(bs, sector_num))
-   {
-   ret = read(s-fd, buf, 512);
-   if (ret != 512)
-   return -1;
-   }
-   else
+int64_t block_offset = seek_to_sector(bs, sector_num);
+if (block_offset = 0) {
+ret = pread(s-fd, buf, 512, block_offset);
+if (ret != 512) {
+return -1;
+}
+} else
 memset(buf, 0, 512);
 nb_sectors--;
 sector_num++;
-- 
1.6.6.1





[Qemu-devel] [PATCH 05/11] ide: Fix ide_dma_cancel

2010-05-07 Thread Kevin Wolf
When cancelling a request, bdrv_aio_cancel may decide that it waits for
completion of a request rather than for cancellation. IDE therefore can't
abandon its DMA status before calling bdrv_aio_cancel; otherwise the callback
of a completed request would use invalid data.

Signed-off-by: Kevin Wolf kw...@redhat.com
---
 hw/ide/core.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 0757528..3cd55e3 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2838,10 +2838,6 @@ static void ide_dma_restart(IDEState *s, int is_read)
 void ide_dma_cancel(BMDMAState *bm)
 {
 if (bm-status  BM_STATUS_DMAING) {
-bm-status = ~BM_STATUS_DMAING;
-/* cancel DMA request */
-bm-unit = -1;
-bm-dma_cb = NULL;
 if (bm-aiocb) {
 #ifdef DEBUG_AIO
 printf(aio_cancel\n);
@@ -2849,6 +2845,10 @@ void ide_dma_cancel(BMDMAState *bm)
 bdrv_aio_cancel(bm-aiocb);
 bm-aiocb = NULL;
 }
+bm-status = ~BM_STATUS_DMAING;
+/* cancel DMA request */
+bm-unit = -1;
+bm-dma_cb = NULL;
 }
 }
 
-- 
1.6.6.1





[Qemu-devel] [PATCH 10/11] block: Fix bdrv_commit

2010-05-07 Thread Kevin Wolf
When reopening the image, don't guess the driver, but use the same driver as
was used before. This is important if the format=... option was used for that
image.

Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 977d01f..c134c2b 100644
--- a/block.c
+++ b/block.c
@@ -701,12 +701,12 @@ int bdrv_commit(BlockDriverState *bs)
 bdrv_delete(bs-backing_hd);
 bs-backing_hd = NULL;
 bs_rw = bdrv_new();
-rw_ret = bdrv_open(bs_rw, filename, open_flags | BDRV_O_RDWR, NULL);
+rw_ret = bdrv_open(bs_rw, filename, open_flags | BDRV_O_RDWR, drv);
 if (rw_ret  0) {
 bdrv_delete(bs_rw);
 /* try to re-open read-only */
 bs_ro = bdrv_new();
-ret = bdrv_open(bs_ro, filename, open_flags  ~BDRV_O_RDWR, NULL);
+ret = bdrv_open(bs_ro, filename, open_flags  ~BDRV_O_RDWR, drv);
 if (ret  0) {
 bdrv_delete(bs_ro);
 /* drive not functional anymore */
@@ -758,7 +758,7 @@ ro_cleanup:
 bdrv_delete(bs-backing_hd);
 bs-backing_hd = NULL;
 bs_ro = bdrv_new();
-ret = bdrv_open(bs_ro, filename, open_flags  ~BDRV_O_RDWR, NULL);
+ret = bdrv_open(bs_ro, filename, open_flags  ~BDRV_O_RDWR, drv);
 if (ret  0) {
 bdrv_delete(bs_ro);
 /* drive not functional anymore */
-- 
1.6.6.1





[Qemu-devel] [PATCH 09/11] block: Fix protocol detection for Windows devices

2010-05-07 Thread Kevin Wolf
We can't assume the file protocol for Windows devices, they need the same
detection as other files for which an explicit protocol is not specified.

Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index 6345599..977d01f 100644
--- a/block.c
+++ b/block.c
@@ -287,16 +287,18 @@ static BlockDriver *find_protocol(const char *filename)
 char protocol[128];
 int len;
 const char *p;
+int is_drive;
 
 /* TODO Drivers without bdrv_file_open must be specified explicitly */
 
 #ifdef _WIN32
-if (is_windows_drive(filename) ||
-is_windows_drive_prefix(filename))
-return bdrv_find_format(file);
+is_drive = is_windows_drive(filename) ||
+is_windows_drive_prefix(filename);
+#else
+is_drive = 0;
 #endif
 p = strchr(filename, ':');
-if (!p) {
+if (!p || is_drive) {
 drv1 = find_hdev_driver(filename);
 if (!drv1) {
 drv1 = bdrv_find_format(file);
-- 
1.6.6.1





[Qemu-devel] [PATCH 07/11] bochs: use qemu block API

2010-05-07 Thread Kevin Wolf
From: Christoph Hellwig h...@lst.de

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig h...@lst.de
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block/bochs.c |   30 +-
 1 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/block/bochs.c b/block/bochs.c
index b54f54d..5fe2fa3 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -80,8 +80,6 @@ struct bochs_header {
 };
 
 typedef struct BDRVBochsState {
-int fd;
-
 uint32_t *catalog_bitmap;
 int catalog_size;
 
@@ -109,23 +107,16 @@ static int bochs_probe(const uint8_t *buf, int buf_size, 
const char *filename)
 return 0;
 }
 
-static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
+static int bochs_open(BlockDriverState *bs, int flags)
 {
 BDRVBochsState *s = bs-opaque;
-int fd, i;
+int i;
 struct bochs_header bochs;
 struct bochs_header_v1 header_v1;
 
-fd = open(filename, O_RDONLY | O_BINARY);
-if (fd  0) {
-return -1;
-}
-
 bs-read_only = 1; // no write support yet
 
-s-fd = fd;
-
-if (pread(fd, bochs, sizeof(bochs), 0) != sizeof(bochs)) {
+if (bdrv_pread(bs-file, 0, bochs, sizeof(bochs)) != sizeof(bochs)) {
 goto fail;
 }
 
@@ -146,8 +137,8 @@ static int bochs_open(BlockDriverState *bs, const char 
*filename, int flags)
 
 s-catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
 s-catalog_bitmap = qemu_malloc(s-catalog_size * 4);
-if (pread(s-fd, s-catalog_bitmap, s-catalog_size * 4,
-  le32_to_cpu(bochs.header)) != s-catalog_size * 4)
+if (bdrv_pread(bs-file, le32_to_cpu(bochs.header), s-catalog_bitmap,
+   s-catalog_size * 4) != s-catalog_size * 4)
goto fail;
 for (i = 0; i  s-catalog_size; i++)
le32_to_cpus(s-catalog_bitmap[i]);
@@ -161,7 +152,6 @@ static int bochs_open(BlockDriverState *bs, const char 
*filename, int flags)
 
 return 0;
  fail:
-close(fd);
 return -1;
 }
 
@@ -184,8 +174,8 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t 
sector_num)
(s-extent_blocks + s-bitmap_blocks));
 
 /* read in bitmap for current extent */
-if (pread(s-fd, bitmap_entry, 1, bitmap_offset + (extent_offset / 8))
-!= 1) {
+if (bdrv_pread(bs-file, bitmap_offset + (extent_offset / 8),
+   bitmap_entry, 1) != 1) {
 return -1;
 }
 
@@ -199,13 +189,12 @@ static int64_t seek_to_sector(BlockDriverState *bs, 
int64_t sector_num)
 static int bochs_read(BlockDriverState *bs, int64_t sector_num,
 uint8_t *buf, int nb_sectors)
 {
-BDRVBochsState *s = bs-opaque;
 int ret;
 
 while (nb_sectors  0) {
 int64_t block_offset = seek_to_sector(bs, sector_num);
 if (block_offset = 0) {
-ret = pread(s-fd, buf, 512, block_offset);
+ret = bdrv_pread(bs-file, block_offset, buf, 512);
 if (ret != 512) {
 return -1;
 }
@@ -222,14 +211,13 @@ static void bochs_close(BlockDriverState *bs)
 {
 BDRVBochsState *s = bs-opaque;
 qemu_free(s-catalog_bitmap);
-close(s-fd);
 }
 
 static BlockDriver bdrv_bochs = {
 .format_name   = bochs,
 .instance_size = sizeof(BDRVBochsState),
 .bdrv_probe= bochs_probe,
-.bdrv_file_open= bochs_open,
+.bdrv_open = bochs_open,
 .bdrv_read = bochs_read,
 .bdrv_close= bochs_close,
 };
-- 
1.6.6.1





[Qemu-devel] [PATCH 0/3] cow conversion to the block API

2010-05-07 Thread Christoph Hellwig
This series converts the cow image driver to the block API.  This fixes
a failure in qemu-iotests 012, and allows compiling it on window by
removing the dependency on mmap.  The downside is that it's possible
a lot slower for bitmap accesses, at least with the current naive
implementation.  Anyone who cares seriously enough about cow is welcome
to optimize the bitmap access.




[Qemu-devel] [PATCH 11/11] block/vdi: Allow disk images of size 0

2010-05-07 Thread Kevin Wolf
From: Stefan Weil w...@mail.berlios.de

Even it is not very useful, users may create images of size 0.

Without the special option CONFIG_ZERO_MALLOC, qemu_mallocz
aborts execution when it is told to allocate 0 bytes,
so avoid this kind of call.

Cc: Kevin Wolf kw...@redhat.com
Signed-off-by: Stefan Weil w...@mail.berlios.de
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block/vdi.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 2b4d2c2..3ea4103 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -435,7 +435,9 @@ static int vdi_open(BlockDriverState *bs, int flags)
 
 bmap_size = header.blocks_in_image * sizeof(uint32_t);
 bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
-s-bmap = qemu_malloc(bmap_size * SECTOR_SIZE);
+if (bmap_size  0) {
+s-bmap = qemu_malloc(bmap_size * SECTOR_SIZE);
+}
 if (bdrv_read(bs-file, s-bmap_sector, (uint8_t *)s-bmap, bmap_size)  
0) {
 goto fail_free_bmap;
 }
@@ -857,7 +859,10 @@ static int vdi_create(const char *filename, 
QEMUOptionParameter *options)
 result = -errno;
 }
 
-bmap = (uint32_t *)qemu_mallocz(bmap_size);
+bmap = NULL;
+if (bmap_size  0) {
+bmap = (uint32_t *)qemu_mallocz(bmap_size);
+}
 for (i = 0; i  blocks; i++) {
 if (image_type == VDI_TYPE_STATIC) {
 bmap[i] = i;
-- 
1.6.6.1





[Qemu-devel] [PATCH 1/3] cow: use pread/pwrite

2010-05-07 Thread Christoph Hellwig
Use pread/pwrite instead of lseek + read/write in preparation of using the
qemu block API.

Signed-off-by: Christoph Hellwig h...@lst.de

Index: qemu/block/cow.c
===
--- qemu.orig/block/cow.c   2010-05-04 19:11:24.897004616 +0200
+++ qemu/block/cow.c2010-05-04 19:12:29.010255070 +0200
@@ -78,7 +78,7 @@ static int cow_open(BlockDriverState *bs
 }
 s-fd = fd;
 /* see if it is a cow image */
-if (read(fd, cow_header, sizeof(cow_header)) != sizeof(cow_header)) {
+if (pread(fd, cow_header, sizeof(cow_header), 0) != sizeof(cow_header)) {
 goto fail;
 }
 
@@ -159,8 +159,8 @@ static int cow_read(BlockDriverState *bs
 
 while (nb_sectors  0) {
 if (is_changed(s-cow_bitmap, sector_num, nb_sectors, n)) {
-lseek(s-fd, s-cow_sectors_offset + sector_num * 512, SEEK_SET);
-ret = read(s-fd, buf, n * 512);
+ret = pread(s-fd, buf, n * 512,
+s-cow_sectors_offset + sector_num * 512);
 if (ret != n * 512)
 return -1;
 } else {
@@ -186,8 +186,8 @@ static int cow_write(BlockDriverState *b
 BDRVCowState *s = bs-opaque;
 int ret, i;
 
-lseek(s-fd, s-cow_sectors_offset + sector_num * 512, SEEK_SET);
-ret = write(s-fd, buf, nb_sectors * 512);
+ret = pwrite(s-fd, buf, nb_sectors * 512,
+ s-cow_sectors_offset + sector_num * 512);
 if (ret != nb_sectors * 512)
 return -1;
 for (i = 0; i  nb_sectors; i++)




[Qemu-devel] Re: [PATCH 1/3] cursor: add cursor functions.

2010-05-07 Thread Blue Swirl
On 5/7/10, Paolo Bonzini pbonz...@redhat.com wrote:
 On 05/06/2010 08:12 PM, Blue Swirl wrote:

  On 5/5/10, Gerd Hoffmannkra...@redhat.com  wrote:
 
   Add a new cursor type to console.h and a bunch of functions to
deal with cursors the (new) cursor.c file.
  
Signed-off-by: Gerd Hoffmannkra...@redhat.com
---
 Makefile.objs |3 +-
 console.h |   24 ++-
 cursor.c  |  208
 +
 3 files changed, 232 insertions(+), 3 deletions(-)
 create mode 100644 cursor.c
  
diff --git a/Makefile.objs b/Makefile.objs
index ecdd53e..1ee6e9d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -48,7 +48,8 @@ common-obj-y = $(block-obj-y)
 common-obj-y += $(net-obj-y)
 common-obj-y += $(qobject-obj-y)
 common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
-common-obj-y += readline.o console.o async.o qemu-error.o
+common-obj-y += readline.o console.o cursor.o async.o qemu-error.o
+
 common-obj-y += tcg-runtime.o host-utils.o
 common-obj-y += irq.o ioport.o input.o
 common-obj-$(CONFIG_PTIMER) += ptimer.o
diff --git a/console.h b/console.h
index 6def115..88861cb 100644
--- a/console.h
+++ b/console.h
@@ -126,6 +126,27 @@ struct DisplaySurface {
struct PixelFormat pf;
 };
  
+/* cursor data format is 32bit RGBA */
+typedef struct QEMUCursor {
+int width, height;
+int hot_x, hot_y;
+int refcount;
+uint32_tdata[];
+} QEMUCursor;
+
+QEMUCursor *cursor_alloc(int width, int height);
+void cursor_get(QEMUCursor *c);
+void cursor_put(QEMUCursor *c);
+QEMUCursor *cursor_builtin_hidden(void);
+QEMUCursor *cursor_builtin_left_ptr(void);
+void cursor_print_ascii_art(QEMUCursor *c, const char
 *prefix);
+int cursor_get_mono_bpl(QEMUCursor *c);
+void cursor_set_mono(QEMUCursor *c,
+ uint32_t foreground, uint32_t background, uint8_t
 *image,
+ int transparent, uint8_t *mask);
+void cursor_get_mono_image(QEMUCursor *c, int
 foreground, uint8_t *mask);
+void cursor_get_mono_mask(QEMUCursor *c, int
 transparent, uint8_t *mask);
+
 struct DisplayChangeListener {
int idle;
uint64_t gui_timer_interval;
@@ -158,8 +179,7 @@ struct DisplayState {
struct DisplayChangeListener* listeners;
  
void (*mouse_set)(int x, int y, int on);
-void (*cursor_define)(int width, int height, int bpp, int hot_x,
 int hot_y,
-  uint8_t *image, uint8_t *mask);
+void (*cursor_define)(QEMUCursor *cursor);
  
struct DisplayState *next;
 };
diff --git a/cursor.c b/cursor.c
new file mode 100644
index 000..3995a31
--- /dev/null
+++ b/cursor.c
@@ -0,0 +1,208 @@
+#include qemu-common.h
+#include console.h
+
+static const char cursor_hidden_32[32*32];
+static const char cursor_left_ptr_32[32*32] = {
+
+ X  
+ XX 
+ X.X
+ X..X   
+ X...X  
+ XX 
+ X.X
+ X..X   
+ X...X  
+ XX 
+ X.X
+ X..X..X
+ X.X X..X   
+ XX  X..X   
+ XX..X  
+  X..X  
+   X..X 
+   X..X 
+XX  
+
+};
  
 
  Is this format standard? How about using X bitmap format instead:
  $ cat /usr/include/X11/bitmaps/left_ptr
  #define left_ptr_width 16
  #define left_ptr_height 16
  #define left_ptr_x_hot 3
  #define left_ptr_y_hot 1
  static char left_ptr_bits[] = {
 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x38, 0x00, 0x78, 0x00, 0xf8, 0x00,
 0xf8, 0x01, 0xf8, 0x03, 0xf8, 0x07, 0xf8, 0x00, 0xd8, 0x00, 0x88, 0x01,
 0x80, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00};
 
  Then there would be no need of parsing.
 

  You would need _two_ bitmaps (e.g. mask and cursor, so that mask=1 gives
 transparent, mask=0 cursor=0 gives black and mask=0 cursor=1 gives white).

Yes, but it's still packed more efficiently.

There's yet another way:
#define _ 0,
#define X 0xff00,
#define o 0x,
{
 _ _ _ X o X _ _ _
}
#undef _
#undef X
#undef o

This would not allow any drawing tool use, but there are no
conversions at startup.




Re: [Qemu-devel] Re: [PATCH] Remove IO_MEM_SUBWIDTH.

2010-05-07 Thread Blue Swirl
On 5/6/10, Artyom Tarasenko atar4q...@googlemail.com wrote:
 2010/4/28 Artyom Tarasenko atar4q...@googlemail.com:

  2010/4/27 Richard Henderson r...@twiddle.net:
   On 04/26/2010 02:54 PM, Artyom Tarasenko wrote:
   This patch introduces a regression. qemu crashes on lance test:
  
   I'm not sure how to get to this, since the sparc-test images don't
   include ifconfig, and I havn't been able to find a sparc install
   image that works (doesn't support sparc32 or sparc64 fails to load).
  
   That said, try this and see if it works.
  
  
   r~
  
   ---
   diff --git a/exec.c b/exec.c
   index 14d1fd7..572d3fd 100644
   --- a/exec.c
   +++ b/exec.c
   @@ -3286,6 +3286,8 @@ static int cpu_register_io_memory_fixed(int 
 io_index,
   CPUWriteMemoryFunc * const 
 *mem_write,
   void *opaque)
{
   +int i;
   +
   if (io_index = 0) {
   io_index = get_free_io_mem_idx();
   if (io_index == -1)
   @@ -3296,8 +3298,14 @@ static int cpu_register_io_memory_fixed(int 
 io_index,
   return -1;
   }
  
   -memcpy(io_mem_read[io_index], mem_read, 3 * 
 sizeof(CPUReadMemoryFunc*));
   -memcpy(io_mem_write[io_index], mem_write, 3 * 
 sizeof(CPUWriteMemoryFunc*));
   +for (i = 0; i  3; ++i) {
   +io_mem_read[io_index][i]
   += (mem_read[i] ? mem_read[i] : unassigned_mem_read[i]);
   +}
   +for (i = 0; i  3; ++i) {
   +io_mem_write[io_index][i]
   += (mem_write[i] ? mem_write[i] : unassigned_mem_write[i]);
   +}
   io_mem_opaque[io_index] = opaque;
  
   return (io_index  IO_MEM_SHIFT);
  


 Why the fix didn't make it into the git?
  Does it introduce other problems?

A diff is not a patch, there is no commit description or SoB.

   Looks good, thanks.
  
   Acked-by: Artyom Tarasenko atar4q...@gmail.com
  

  --
  Regards,
  Artyom Tarasenko

  solaris/sparc under qemu blog: http://tyom.blogspot.com/





Re: [Qemu-devel] [PATCH 2/5] Add defines for PCI IDs.

2010-05-07 Thread Blue Swirl
On 5/7/10, Gerd Hoffmann kra...@redhat.com wrote:
 This patch allows to set PCI vendor and device IDs using defines
  (PCI_VID and PCI_DID).  Use it for vgabios.bin.

  Signed-off-by: Gerd Hoffmann kra...@redhat.com
  ---
   Makefile  |4 ++--
   vbe.c |6 +-
   vgabios.c |5 +
   3 files changed, 12 insertions(+), 3 deletions(-)

  diff --git a/Makefile b/Makefile
  index c3c744c..d440b93 100644
  --- a/Makefile
  +++ b/Makefile
  @@ -31,8 +31,8 @@ VGA_FILES := vgabios.c vgabios.h vgafonts.h vgatables.h
   VBE_FILES := vbe.h vbe.c vbetables.h

   # build flags
  -vgabios.bin  : VGAFLAGS := -DVBE
  -vgabios.debug.bin: VGAFLAGS := -DVBE -DDEBUG
  +vgabios.bin  : VGAFLAGS := -DVBE -DPCI_VID=0x1234
  +vgabios.debug.bin: VGAFLAGS := -DVBE -DPCI_VID=0x1234 -DDEBUG

-DPCI_DID missing...

   vgabios-cirrus.bin   : VGAFLAGS := -DCIRRUS -DPCIBIOS
   vgabios-cirrus.debug.bin : VGAFLAGS := -DCIRRUS -DPCIBIOS -DCIRRUS_DEBUG

  diff --git a/vbe.c b/vbe.c
  index f925c35..f9a77f0 100644
  --- a/vbe.c
  +++ b/vbe.c
  @@ -925,7 +925,11 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
  if (using_lfb) {
info.NumberOfBanks = 1;
  }
  -lfb_addr = pci_get_lfb_addr(0x1234); // experimental vendor
  +#ifdef PCI_VID
  +lfb_addr = pci_get_lfb_addr(PCI_VID);
  +#else
  +lfb_addr = 0;
  +#endif
  if (lfb_addr  0) {
info.PhysBasePtr = ((Bit32u)lfb_addr  16);
  }
  diff --git a/vgabios.c b/vgabios.c
  index 3b09c92..a575b7b 100644
  --- a/vgabios.c
  +++ b/vgabios.c
  @@ -210,8 +210,13 @@ vgabios_pci_data:
   .word 0x1013
   .word 0x00b8 // CLGD5446
   #else
  +#ifdef PCI_VID
  +.word PCI_VID
  +.word PCI_DID

... so this generates:
 .word 0x1234
 .word PCI_DID

I read only this patch, so sorry for the noise if I missed something.

  +#else
   #error Unknown PCI vendor and device id
   #endif
  +#endif
   .word 0 // reserved
   .word 0x18 // dlen
   .byte 0 // revision

 --
  1.6.6.1








[Qemu-devel] phys_page_find bug?

2010-05-07 Thread Artyom Tarasenko
phys_page_find (exec.c) returns sometimes a page for addresses where
nothing is connected.

One example, done with qemu-system-sparc -M SS-20

ok f130 2f spacec@ .

// The address translates correctly, in cpu_physical_memory_rw
// addr== 0xff130 (where nothing is connected)
// but then phys_page_find returns a nonzero and produces

Unassigned mem read access of 1 byte to 000ff150 from x

(note the 5 in the line above where 3 is expected)

I wonder if this is only true for non-wired addresses, or whether
phys_page_find can also
find wrong pages for the addresses where something is connected?

Or is my assumption is wrong and phys_page_find can return a page for
not-connected
addresses and the bug is actually in cpu_physical_memory_rw ?

Is the qemu algorithm of working with the physical address space
described somewhere?

-- 
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/




Re: [Qemu-devel] [PATCH] mips-dis: Add missing static attributes

2010-05-07 Thread Blue Swirl
On 5/6/10, Stefan Weil w...@mail.berlios.de wrote:
 mips_abi_choices and mips_arch_choices are only used locally.

  Signed-off-by: Stefan Weil w...@mail.berlios.de
  ---
   mips-dis.c |4 ++--
   1 files changed, 2 insertions(+), 2 deletions(-)

  diff --git a/mips-dis.c b/mips-dis.c
  index 56bffe5..4623a1c 100644
  --- a/mips-dis.c
  +++ b/mips-dis.c
  @@ -3035,7 +3035,7 @@ struct mips_abi_choice
const char * const *fpr_names;
   };

  -struct mips_abi_choice mips_abi_choices[] =
  +static struct mips_abi_choice mips_abi_choices[] =
   {
{ numeric, mips_gpr_names_numeric, mips_fpr_names_numeric },
{ 32, mips_gpr_names_oldabi, mips_fpr_names_32 },
  @@ -3086,7 +3086,7 @@ struct mips_arch_choice

   //~ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))

The patch does not apply because the line above does not match HEAD.

  -const struct mips_arch_choice mips_arch_choices[] =
  +static const struct mips_arch_choice mips_arch_choices[] =
   {
{ numeric, 0, 0, 0, 0,
  mips_cp0_names_numeric, NULL, 0, mips_hwr_names_numeric },

 --
  1.7.0








Re: [Qemu-devel] [PATCH] darwin-user: Add missing static attribute

2010-05-07 Thread Blue Swirl
Thanks, applied.

On 5/6/10, Stefan Weil w...@mail.berlios.de wrote:
 Function usage is only used locally, so add static.

  Signed-off-by: Stefan Weil w...@mail.berlios.de
  ---
   darwin-user/main.c |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)

  diff --git a/darwin-user/main.c b/darwin-user/main.c
  index ade7d48..175e12f 100644
  --- a/darwin-user/main.c
  +++ b/darwin-user/main.c
  @@ -704,7 +704,7 @@ void cpu_loop(CPUX86State *env)
   }
   #endif

  -void usage(void)
  +static void usage(void)
   {
  printf(qemu- TARGET_ARCH  version  QEMU_VERSION , Copyright (c) 
 2003-2004 Fabrice Bellard\n
 usage: qemu- TARGET_ARCH  [-h] [-d opts] [-L path] [-s size] 
 program [arguments...]\n

 --
  1.7.0








[Qemu-devel] Re: [PATCH 0/2] qcow2: Move BlockDriver definiton to the end of the file

2010-05-07 Thread Kevin Wolf
Am 07.05.2010 17:45, schrieb Blue Swirl:
 On 5/7/10, Kevin Wolf kw...@redhat.com wrote:
 A recent build fix for OpenBSD moved the BlockDriver definition of qcow2 to
  somewhere in the middle of the source file. This series tries to solve the
  problem in a different way that allows the definition to stay where everyone
  looks for it.

  Blue Swirl, as I don't have an OpenBSD installation handy, can you try if 
 this
  works for you?
 
 Seems to work. Should I commit them or do you want to use the block branch?

I don't mind. It's already in the block branch, so it would be part of
my next pull request anyway. If you commit it before that, that's no
problem either.

Kevin




[Qemu-devel] [PATCH] Fill in unassigned mem read/write callbacks.

2010-05-07 Thread Richard Henderson
Implement the functions may be omitted with NULL pointer
interface mentioned in the function block comment by transforming
NULL entries in the read/write arrays into calls to the
unassigned_mem family of functions.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 exec.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/exec.c b/exec.c
index e980788..3416aed 100644
--- a/exec.c
+++ b/exec.c
@@ -3262,6 +3262,8 @@ static int cpu_register_io_memory_fixed(int io_index,
 CPUWriteMemoryFunc * const *mem_write,
 void *opaque)
 {
+int i;
+
 if (io_index = 0) {
 io_index = get_free_io_mem_idx();
 if (io_index == -1)
@@ -3272,8 +3274,14 @@ static int cpu_register_io_memory_fixed(int io_index,
 return -1;
 }
 
-memcpy(io_mem_read[io_index], mem_read, 3 * sizeof(CPUReadMemoryFunc*));
-memcpy(io_mem_write[io_index], mem_write, 3 * sizeof(CPUWriteMemoryFunc*));
+for (i = 0; i  3; ++i) {
+io_mem_read[io_index][i]
+= (mem_read[i] ? mem_read[i] : unassigned_mem_read[i]);
+}
+for (i = 0; i  3; ++i) {
+io_mem_write[io_index][i]
+= (mem_write[i] ? mem_write[i] : unassigned_mem_write[i]);
+}
 io_mem_opaque[io_index] = opaque;
 
 return (io_index  IO_MEM_SHIFT);
-- 
1.6.6.1





[Qemu-devel] Re: [PATCH] Fill in unassigned mem read/write callbacks.

2010-05-07 Thread Blue Swirl
Thanks, applied.

On 5/7/10, Richard Henderson r...@twiddle.net wrote:
 Implement the functions may be omitted with NULL pointer
  interface mentioned in the function block comment by transforming
  NULL entries in the read/write arrays into calls to the
  unassigned_mem family of functions.

  Signed-off-by: Richard Henderson r...@twiddle.net
  ---
   exec.c |   12 ++--
   1 files changed, 10 insertions(+), 2 deletions(-)

  diff --git a/exec.c b/exec.c
  index e980788..3416aed 100644
  --- a/exec.c
  +++ b/exec.c
  @@ -3262,6 +3262,8 @@ static int cpu_register_io_memory_fixed(int io_index,
  CPUWriteMemoryFunc * const 
 *mem_write,
  void *opaque)
   {
  +int i;
  +
  if (io_index = 0) {
  io_index = get_free_io_mem_idx();
  if (io_index == -1)
  @@ -3272,8 +3274,14 @@ static int cpu_register_io_memory_fixed(int io_index,
  return -1;
  }

  -memcpy(io_mem_read[io_index], mem_read, 3 * sizeof(CPUReadMemoryFunc*));
  -memcpy(io_mem_write[io_index], mem_write, 3 * 
 sizeof(CPUWriteMemoryFunc*));
  +for (i = 0; i  3; ++i) {
  +io_mem_read[io_index][i]
  += (mem_read[i] ? mem_read[i] : unassigned_mem_read[i]);
  +}
  +for (i = 0; i  3; ++i) {
  +io_mem_write[io_index][i]
  += (mem_write[i] ? mem_write[i] : unassigned_mem_write[i]);
  +}
  io_mem_opaque[io_index] = opaque;

  return (io_index  IO_MEM_SHIFT);

 --
  1.6.6.1






[Qemu-devel] Re: [PATCH 0/2] qcow2: Move BlockDriver definiton to the end of the file

2010-05-07 Thread Blue Swirl
On 5/7/10, Kevin Wolf kw...@redhat.com wrote:
 Am 07.05.2010 17:45, schrieb Blue Swirl:

  On 5/7/10, Kevin Wolf kw...@redhat.com wrote:
   A recent build fix for OpenBSD moved the BlockDriver definition of qcow2 
 to
somewhere in the middle of the source file. This series tries to solve 
 the
problem in a different way that allows the definition to stay where 
 everyone
looks for it.
  
Blue Swirl, as I don't have an OpenBSD installation handy, can you try 
 if this
works for you?
  
   Seems to work. Should I commit them or do you want to use the block branch?


 I don't mind. It's already in the block branch, so it would be part of
  my next pull request anyway. If you commit it before that, that's no
  problem either.

I applied them then, thanks.




[Qemu-devel] [PATCH] tcg: Add missing 'static' attribute

2010-05-07 Thread Stefan Weil
tcg_out_reloc is only used locally (in */target.c which is
included in tcg.c).

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 tcg/tcg.c |4 ++--
 tcg/tcg.h |3 ---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/tcg/tcg.c b/tcg/tcg.c
index beceff0..f3c7909 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -100,8 +100,8 @@ static inline void tcg_out32(TCGContext *s, uint32_t v)
 
 /* label relocation processing */
 
-void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type, 
-   int label_index, long addend)
+static void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type, 
+  int label_index, long addend)
 {
 TCGLabel *l;
 TCGRelocation *r;
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 166c889..44856e1 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -477,9 +477,6 @@ TCGv_i64 tcg_const_i64(int64_t val);
 TCGv_i32 tcg_const_local_i32(int32_t val);
 TCGv_i64 tcg_const_local_i64(int64_t val);
 
-void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type, 
-   int label_index, long addend);
-
 extern uint8_t code_gen_prologue[];
 #if defined(_ARCH_PPC)  !defined(_ARCH_PPC64)
 #define tcg_qemu_tb_exec(tb_ptr) \
-- 
1.7.0





[Qemu-devel] Re: [PATCH] mcf: add simr/cimr registers to interrupt controller for 5208

2010-05-07 Thread Thadeu Lima de Souza Cascardo
On Tue, Mar 30, 2010 at 01:58:53PM -0300, Thadeu Lima de Souza Cascardo wrote:
 The registers SIMR and CIMR allow interrupts to be masked/unsmasked
 without a read-modify-write. Linux m68knommu port uses this for some
 platforms. Without this patch, a m5208evb_defconfig won't boot. With
 this patch, I could get Linux to boot and get some output in the serial.
 
 Signed-off-by: Thadeu Lima de Souza Cascardo casca...@holoscopio.com
 ---

Is there anyone who can take this?

Regards,
Cascardo.

  hw/mcf_intc.c |   18 ++
  1 files changed, 18 insertions(+), 0 deletions(-)
 
 diff --git a/hw/mcf_intc.c b/hw/mcf_intc.c
 index f01bd32..21c0f42 100644
 --- a/hw/mcf_intc.c
 +++ b/hw/mcf_intc.c
 @@ -62,6 +62,10 @@ static uint32_t mcf_intc_read(void *opaque, 
 target_phys_addr_t addr)
  return (uint32_t)(s-ifr  32);
  case 0x14:
  return (uint32_t)s-ifr;
 +/* Reading from SIMR and CIMR return 0 */
 +case 0x1c:
 +case 0x1d:
 +return 0;
  case 0xe0: /* SWIACK.  */
  return s-active_vector;
  case 0xe1: case 0xe2: case 0xe3: case 0xe4:
 @@ -98,6 +102,20 @@ static void mcf_intc_write(void *opaque, 
 target_phys_addr_t addr, uint32_t val)
  case 0x0c:
  s-imr = (s-imr  0xull) | (uint32_t)val;
  break;
 +/* SIMR allows to easily mask interrupts */
 +case 0x1c:
 +if (val  0x40)
 +s-imr = ~0ull;
 +else
 +s-imr |= (1  (val  0x3f));
 +break;
 +/* CIMR allows to easily unmask interrupts */
 +case 0x1d:
 +if (val  0x40)
 +s-imr = 0ull;
 +else
 +s-imr = ~(1  (val  0x3f));
 +break;
  default:
  hw_error(mcf_intc_write: Bad write offset %d\n, offset);
  break;
 -- 
 1.6.6.1
 


signature.asc
Description: Digital signature


Re: [Qemu-devel] Call for 0.12.4

2010-05-07 Thread Aurelien Jarno
Kevin Wolf a écrit :
 Am 08.04.2010 20:37, schrieb Aurelien Jarno:
 Hi all,

 A number of fixes have been accumulated in the stable-0.12 branch, and
 I think it's time to release a new stable version. I would like to see
 that happening for the end of next week (around the 18th of April).

 If you want to see some patches included, please send a mail to the
 mailing list with the [STABLE] tag. I would clearly prefer patches that 
 are already in HEAD (if the patch can simply be cherry-picked, there is
 no need to send a patch, just the commit number), though other patches
 might be considered too.
 
 Not sure if it's already too late for 0.12.4, but this one should be
 applied to the stable-0.12 branch:
 
 Commit: d6771bfa52744eb4f959198b4b0e59451463eebf
 qemu-img: use the heap instead of the huge stack array for win32
 
 On Windows, qemu-img convert is broken without this fix.
 

I have cherry-picked this patch in the stable-0.12 branch, it will be
for 0.12.5.


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




[Qemu-devel] [PATCH 2/2] vnc: sync lock modifier state on connect.

2010-05-07 Thread Gerd Hoffmann

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 vnc.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/vnc.c b/vnc.c
index e497c70..69f3816 100644
--- a/vnc.c
+++ b/vnc.c
@@ -2238,6 +2238,7 @@ static void vnc_connect(VncDisplay *vd, int csock)
 if (vs-vd-lock_key_sync) {
 vs-led_notifier.notify = kbd_leds;
 qemu_add_led_event_notifier(vs-led_notifier);
+kbd_leds(vs-led_notifier);
 }
 
 vs-mouse_mode_notifier.notify = check_pointer_type_change;
-- 
1.6.6.1





[Qemu-devel] [PATCH 3/3] dmg: use qemu block API

2010-05-07 Thread Christoph Hellwig
Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Dmg actually does an lseek to a negative offset in the open routine,
which we replace with offset arithmetics after doing a bdrv_getlength.

Signed-off-by: Christoph Hellwig h...@lst.de


Index: qemu-kevin/block/dmg.c
===
--- qemu-kevin.orig/block/dmg.c 2010-05-07 16:44:10.487253603 +0200
+++ qemu-kevin/block/dmg.c  2010-05-07 16:44:10.829253954 +0200
@@ -28,8 +28,6 @@
 #include zlib.h
 
 typedef struct BDRVDMGState {
-int fd;
-
 /* each chunk contains a certain number of sectors,
  * offsets[i] is the offset in the .dmg file,
  * lengths[i] is the length of the compressed chunk,
@@ -58,23 +56,23 @@ static int dmg_probe(const uint8_t *buf,
 return 0;
 }
 
-static off_t read_off(int fd, int64_t offset)
+static off_t read_off(BlockDriverState *bs, int64_t offset)
 {
uint64_t buffer;
-   if (pread(fd, buffer, 8, offset)  8)
+   if (bdrv_pread(bs-file, offset, buffer, 8)  8)
return 0;
return be64_to_cpu(buffer);
 }
 
-static off_t read_uint32(int fd, int64_t offset)
+static off_t read_uint32(BlockDriverState *bs, int64_t offset)
 {
uint32_t buffer;
-   if (pread(fd, buffer, 4, offset)  4)
+   if (bdrv_pread(bs-file, offset, buffer, 4)  4)
return 0;
return be32_to_cpu(buffer);
 }
 
-static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
+static int dmg_open(BlockDriverState *bs, int flags)
 {
 BDRVDMGState *s = bs-opaque;
 off_t info_begin,info_end,last_in_offset,last_out_offset;
@@ -82,29 +80,27 @@ static int dmg_open(BlockDriverState *bs
 uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i;
 int64_t offset;
 
-s-fd = open(filename, O_RDONLY | O_BINARY);
-if (s-fd  0)
-return -errno;
 bs-read_only = 1;
 s-n_chunks = 0;
 s-offsets = s-lengths = s-sectors = s-sectorcounts = NULL;
 
 /* read offset of info blocks */
-offset = lseek(s-fd, -0x1d8, SEEK_END);
+offset = bdrv_getlength(bs-file);
 if (offset  0) {
 goto fail;
 }
+offset -= 0x1d8;
 
-info_begin = read_off(s-fd, offset);
+info_begin = read_off(bs, offset);
 if (info_begin == 0) {
goto fail;
 }
 
-if (read_uint32(s-fd, info_begin) != 0x100) {
+if (read_uint32(bs, info_begin) != 0x100) {
 goto fail;
 }
 
-count = read_uint32(s-fd, info_begin + 4);
+count = read_uint32(bs, info_begin + 4);
 if (count == 0) {
 goto fail;
 }
@@ -117,12 +113,12 @@ static int dmg_open(BlockDriverState *bs
 while (offset  info_end) {
 uint32_t type;
 
-   count = read_uint32(s-fd, offset);
+   count = read_uint32(bs, offset);
if(count==0)
goto fail;
 offset += 4;
 
-   type = read_uint32(s-fd, offset);
+   type = read_uint32(bs, offset);
if (type == 0x6d697368  count = 244) {
int new_size, chunk_count;
 
@@ -138,7 +134,7 @@ static int dmg_open(BlockDriverState *bs
s-sectorcounts = qemu_realloc(s-sectorcounts, new_size);
 
for(i=s-n_chunks;is-n_chunks+chunk_count;i++) {
-   s-types[i] = read_uint32(s-fd, offset);
+   s-types[i] = read_uint32(bs, offset);
offset += 4;
if(s-types[i]!=0x8005  s-types[i]!=1  s-types[i]!=2) 
{
if(s-types[i]==0x) {
@@ -150,19 +146,19 @@ static int dmg_open(BlockDriverState *bs
offset += 36;
continue;
}
-   read_uint32(s-fd, offset);
+   read_uint32(bs, offset);
offset += 4;
 
-   s-sectors[i] = last_out_offset+read_off(s-fd, offset);
+   s-sectors[i] = last_out_offset+read_off(bs, offset);
offset += 8;
 
-   s-sectorcounts[i] = read_off(s-fd, offset);
+   s-sectorcounts[i] = read_off(bs, offset);
offset += 8;
 
-   s-offsets[i] = last_in_offset+read_off(s-fd, offset);
+   s-offsets[i] = last_in_offset+read_off(bs, offset);
offset += 8;
 
-   s-lengths[i] = read_off(s-fd, offset);
+   s-lengths[i] = read_off(bs, offset);
offset += 8;
 
if(s-lengths[i]max_compressed_size)
@@ -184,7 +180,6 @@ static int dmg_open(BlockDriverState *bs
 
 return 0;
 fail:
-close(s-fd);
 return -1;
 }
 
@@ -214,8 +209,10 @@ static inline uint32_t search_chunk(BDRV
 return s-n_chunks; /* error */
 }
 
-static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
+static inline int dmg_read_chunk(BlockDriverState *bs, int sector_num)
 {
+BDRVDMGState *s = bs-opaque;
+
 

Re: [Qemu-devel] [ANNOUNCE] Release 0.12.4 of QEMU

2010-05-07 Thread Natalia Portillo

El 07/05/2010, a las 14:54, Anthony Liguori escribió:

 The QEMU team is pleased to announce the availability of the 0.12.4
 release.  This is a stable release of the 0.12 series and only contains bug 
 fixes since 0.12.3.
 
 It can be downloaded from Savannah at:
 
 http://download.savannah.gnu.org/releases/qemu/qemu-0.12.4.tar.gz

Added to OS Support List



[Qemu-devel] Re: [PATCH] QMP: Add Downstream extension of QMP to spec

2010-05-07 Thread Luiz Capitulino
On Fri, 07 May 2010 11:49:42 +0200
Markus Armbruster arm...@redhat.com wrote:

 +Any new names downstream wishes to add must begin with '__'.  To ensure
 +compatibility with other downstreams, it is strongly recommended that
 +you prefix the commands with '__RFQDN_' where RFQDN is a valid, reverse
 +fully qualified domain name which you control.  For example, a qemu-kvm
 +specific monitor command would be:
 +
 +(qemu) __org.linux-kvm_enable_irqchip

 It's not only for commands, but for async messages and errors as well,
otherwise looks good to me.




[Qemu-devel] [PATCH 01/11] block: Remove semicolon in BDRV_SECTOR_MASK macro

2010-05-07 Thread Kevin Wolf
From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 block.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block.h b/block.h
index f87d24e..278259c 100644
--- a/block.h
+++ b/block.h
@@ -38,7 +38,7 @@ typedef struct QEMUSnapshotInfo {
 
 #define BDRV_SECTOR_BITS   9
 #define BDRV_SECTOR_SIZE   (1  BDRV_SECTOR_BITS)
-#define BDRV_SECTOR_MASK   ~(BDRV_SECTOR_SIZE - 1);
+#define BDRV_SECTOR_MASK   ~(BDRV_SECTOR_SIZE - 1)
 
 typedef enum {
 BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP
-- 
1.6.6.1





[Qemu-devel] [PATCH 2/3] cow: stop using mmap

2010-05-07 Thread Christoph Hellwig
We don't have an equivalent to mmap in the qemu block API, so read and
write the bitmap directly.  At least in the dumb implementation added
in this patch this is a lot less efficient, but it means cow can also
work on windows, and over nbd or curl.  And it fixes qemu-iotests testcase
012 which did not work properly due to issues with read-only mmap access.

In addition we can also get rid of the now unused get_mmap_addr function.

Signed-off-by: Christoph Hellwig h...@lst.de

Index: qemu/block/cow.c
===
--- qemu.orig/block/cow.c   2010-05-07 16:58:13.614003848 +0200
+++ qemu/block/cow.c2010-05-07 17:07:35.326034649 +0200
@@ -21,11 +21,9 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#ifndef _WIN32
 #include qemu-common.h
 #include block_int.h
 #include module.h
-#include sys/mman.h
 
 /**/
 /* COW block driver using file system holes */
@@ -45,9 +43,6 @@ struct cow_header_v2 {
 
 typedef struct BDRVCowState {
 int fd;
-uint8_t *cow_bitmap; /* if non NULL, COW mappings are used first */
-uint8_t *cow_bitmap_addr; /* mmap address of cow_bitmap */
-int cow_bitmap_size;
 int64_t cow_sectors_offset;
 } BDRVCowState;
 
@@ -68,6 +63,7 @@ static int cow_open(BlockDriverState *bs
 BDRVCowState *s = bs-opaque;
 int fd;
 struct cow_header_v2 cow_header;
+int bitmap_size;
 int64_t size;
 
 fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
@@ -94,61 +90,92 @@ static int cow_open(BlockDriverState *bs
 pstrcpy(bs-backing_file, sizeof(bs-backing_file),
 cow_header.backing_file);
 
-/* mmap the bitmap */
-s-cow_bitmap_size = ((bs-total_sectors + 7)  3) + sizeof(cow_header);
-s-cow_bitmap_addr = (void *)mmap(get_mmap_addr(s-cow_bitmap_size),
-  s-cow_bitmap_size,
-  PROT_READ | PROT_WRITE,
-  MAP_SHARED, s-fd, 0);
-if (s-cow_bitmap_addr == MAP_FAILED)
-goto fail;
-s-cow_bitmap = s-cow_bitmap_addr + sizeof(cow_header);
-s-cow_sectors_offset = (s-cow_bitmap_size + 511)  ~511;
+bitmap_size = ((bs-total_sectors + 7)  3) + sizeof(cow_header);
+s-cow_sectors_offset = (bitmap_size + 511)  ~511;
 return 0;
  fail:
 close(fd);
 return -1;
 }
 
-static inline void cow_set_bit(uint8_t *bitmap, int64_t bitnum)
+/*
+ * XXX(hch): right now these functions are extremly ineffcient.
+ * We should just read the whole bitmap we'll need in one go instead.
+ */
+static inline int cow_set_bit(BlockDriverState *bs, int64_t bitnum)
 {
-bitmap[bitnum / 8] |= (1  (bitnum%8));
+BDRVCowState *s = bs-opaque;
+uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8;
+uint8_t bitmap;
+
+if (pread(s-fd, bitmap, sizeof(bitmap), offset) !=
+   sizeof(bitmap)) {
+   return -errno;
+}
+
+bitmap |= (1  (bitnum % 8));
+
+if (pwrite(s-fd, bitmap, sizeof(bitmap), offset) !=
+   sizeof(bitmap)) {
+   return -errno;
+}
+return 0;
 }
 
-static inline int is_bit_set(const uint8_t *bitmap, int64_t bitnum)
+static inline int is_bit_set(BlockDriverState *bs, int64_t bitnum)
 {
-return !!(bitmap[bitnum / 8]  (1  (bitnum%8)));
-}
+BDRVCowState *s = bs-opaque;
+uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8;
+uint8_t bitmap;
+
+if (pread(s-fd, bitmap, sizeof(bitmap), offset) !=
+   sizeof(bitmap)) {
+   return -errno;
+}
 
+return !!(bitmap  (1  (bitnum % 8)));
+}
 
 /* Return true if first block has been changed (ie. current version is
  * in COW file).  Set the number of continuous blocks for which that
  * is true. */
-static inline int is_changed(uint8_t *bitmap,
- int64_t sector_num, int nb_sectors,
- int *num_same)
+static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,
+int nb_sectors, int *num_same)
 {
 int changed;
 
-if (!bitmap || nb_sectors == 0) {
+if (nb_sectors == 0) {
*num_same = nb_sectors;
return 0;
 }
 
-changed = is_bit_set(bitmap, sector_num);
+changed = is_bit_set(bs, sector_num);
+if (changed  0) {
+return 0; /* XXX: how to return I/O errors? */
+}
+
 for (*num_same = 1; *num_same  nb_sectors; (*num_same)++) {
-   if (is_bit_set(bitmap, sector_num + *num_same) != changed)
+   if (is_bit_set(bs, sector_num + *num_same) != changed)
break;
 }
 
 return changed;
 }
 
-static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,
-int nb_sectors, int *pnum)
+static void cow_update_bitmap(BlockDriverState *bs, int64_t sector_num,
+int nb_sectors)
 {
-BDRVCowState *s = bs-opaque;
-return is_changed(s-cow_bitmap, 

[Qemu-devel] [PATCH 3/3] cow: use qemu block API

2010-05-07 Thread Christoph Hellwig
Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig h...@lst.de

Index: qemu/block/cow.c
===
--- qemu.orig/block/cow.c   2010-05-07 17:07:56.0 +0200
+++ qemu/block/cow.c2010-05-07 17:11:11.498255489 +0200
@@ -42,7 +42,6 @@ struct cow_header_v2 {
 };
 
 typedef struct BDRVCowState {
-int fd;
 int64_t cow_sectors_offset;
 } BDRVCowState;
 
@@ -58,23 +57,16 @@ static int cow_probe(const uint8_t *buf,
 return 0;
 }
 
-static int cow_open(BlockDriverState *bs, const char *filename, int flags)
+static int cow_open(BlockDriverState *bs, int flags)
 {
 BDRVCowState *s = bs-opaque;
-int fd;
 struct cow_header_v2 cow_header;
 int bitmap_size;
 int64_t size;
 
-fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
-if (fd  0) {
-fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
-if (fd  0)
-return -1;
-}
-s-fd = fd;
 /* see if it is a cow image */
-if (pread(fd, cow_header, sizeof(cow_header), 0) != sizeof(cow_header)) {
+if (bdrv_pread(bs-file, 0, cow_header, sizeof(cow_header)) !=
+sizeof(cow_header)) {
 goto fail;
 }
 
@@ -94,7 +86,6 @@ static int cow_open(BlockDriverState *bs
 s-cow_sectors_offset = (bitmap_size + 511)  ~511;
 return 0;
  fail:
-close(fd);
 return -1;
 }
 
@@ -104,18 +95,17 @@ static int cow_open(BlockDriverState *bs
  */
 static inline int cow_set_bit(BlockDriverState *bs, int64_t bitnum)
 {
-BDRVCowState *s = bs-opaque;
 uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8;
 uint8_t bitmap;
 
-if (pread(s-fd, bitmap, sizeof(bitmap), offset) !=
+if (bdrv_pread(bs-file, offset, bitmap, sizeof(bitmap)) !=
sizeof(bitmap)) {
return -errno;
 }
 
 bitmap |= (1  (bitnum % 8));
 
-if (pwrite(s-fd, bitmap, sizeof(bitmap), offset) !=
+if (bdrv_pwrite(bs-file, offset, bitmap, sizeof(bitmap)) !=
sizeof(bitmap)) {
return -errno;
 }
@@ -124,11 +114,10 @@ static inline int cow_set_bit(BlockDrive
 
 static inline int is_bit_set(BlockDriverState *bs, int64_t bitnum)
 {
-BDRVCowState *s = bs-opaque;
 uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8;
 uint8_t bitmap;
 
-if (pread(s-fd, bitmap, sizeof(bitmap), offset) !=
+if (bdrv_pread(bs-file, offset, bitmap, sizeof(bitmap)) !=
sizeof(bitmap)) {
return -errno;
 }
@@ -186,8 +175,9 @@ static int cow_read(BlockDriverState *bs
 
 while (nb_sectors  0) {
 if (cow_is_allocated(bs, sector_num, nb_sectors, n)) {
-ret = pread(s-fd, buf, n * 512,
-s-cow_sectors_offset + sector_num * 512);
+ret = bdrv_pread(bs-file,
+s-cow_sectors_offset + sector_num * 512,
+buf, n * 512);
 if (ret != n * 512)
 return -1;
 } else {
@@ -213,8 +203,8 @@ static int cow_write(BlockDriverState *b
 BDRVCowState *s = bs-opaque;
 int ret;
 
-ret = pwrite(s-fd, buf, nb_sectors * 512,
- s-cow_sectors_offset + sector_num * 512);
+ret = bdrv_pwrite(bs-file, s-cow_sectors_offset + sector_num * 512,
+  buf, nb_sectors * 512);
 if (ret != nb_sectors * 512)
 return -1;
 
@@ -223,8 +213,6 @@ static int cow_write(BlockDriverState *b
 
 static void cow_close(BlockDriverState *bs)
 {
-BDRVCowState *s = bs-opaque;
-close(s-fd);
 }
 
 static int cow_create(const char *filename, QEMUOptionParameter *options)
@@ -294,8 +282,7 @@ exit:
 
 static void cow_flush(BlockDriverState *bs)
 {
-BDRVCowState *s = bs-opaque;
-qemu_fdatasync(s-fd);
+bdrv_flush(bs-file);
 }
 
 static QEMUOptionParameter cow_create_options[] = {
@@ -316,7 +303,7 @@ static BlockDriver bdrv_cow = {
 .format_name   = cow,
 .instance_size = sizeof(BDRVCowState),
 .bdrv_probe= cow_probe,
-.bdrv_file_open= cow_open,
+.bdrv_open = cow_open,
 .bdrv_read = cow_read,
 .bdrv_write= cow_write,
 .bdrv_close= cow_close,




[Qemu-devel] Re: Endless loop in qcow2_alloc_cluster_offset

2010-05-07 Thread Marcelo Tosatti
On Fri, May 07, 2010 at 09:37:22AM +0200, Kevin Wolf wrote:
 Am 07.05.2010 03:19, schrieb Marcelo Tosatti:
  On Thu, Nov 19, 2009 at 01:19:55PM +0100, Jan Kiszka wrote:
  Hi,
 
  I just managed to push a qemu-kvm process (git rev. b496fe3431) into an
  endless loop in qcow2_alloc_cluster_offset, namely over
  QLIST_FOREACH(old_alloc, s-cluster_allocs, next_in_flight):
 
  (gdb) bt
  #0  0x0048614b in qcow2_alloc_cluster_offset (bs=0xc4e1d0, 
  offset=7417184256, n_start=0, n_end=16, num=0xcb351c, m=0xcb3568) at 
  /data/qemu-kvm/block/qcow2-cluster.c:750
  #1  0x004828d0 in qcow_aio_write_cb (opaque=0xcb34d0, ret=0) at 
  /data/qemu-kvm/block/qcow2.c:587
  #2  0x00482a44 in qcow_aio_writev (bs=value optimized out, 
  sector_num=value optimized out, qiov=value optimized out, 
  nb_sectors=value optimized out, cb=value optimized out, opaque=value 
  optimized out) at /data/qemu-kvm/block/qcow2.c:645
  #3  0x00470e89 in bdrv_aio_writev (bs=0xc4e1d0, sector_num=2, 
  qiov=0x7f48a9010ed0, nb_sectors=16, cb=0x470d20 bdrv_rw_em_cb, 
  opaque=0x7f48a9010f0c) at /data/qemu-kvm/block.c:1362
  #4  0x00472991 in bdrv_write_em (bs=0xc4e1d0, sector_num=14486688, 
  buf=0xd67200 H\a, nb_sectors=16) at /data/qemu-kvm/block.c:1736
  #5  0x00435581 in ide_sector_write (s=0xc92650) at 
  /data/qemu-kvm/hw/ide/core.c:622
  #6  0x00425fc2 in kvm_handle_io (env=value optimized out) at 
  /data/qemu-kvm/kvm-all.c:553
  #7  kvm_run (env=value optimized out) at /data/qemu-kvm/qemu-kvm.c:964
  #8  0x00426049 in kvm_cpu_exec (env=0x1000) at 
  /data/qemu-kvm/qemu-kvm.c:1651
  #9  0x0042627d in kvm_main_loop_cpu (_env=value optimized out) 
  at /data/qemu-kvm/qemu-kvm.c:1893
  #10 ap_main_loop (_env=value optimized out) at 
  /data/qemu-kvm/qemu-kvm.c:1943
  #11 0x7f48ae89d070 in start_thread () from /lib64/libpthread.so.0
  #12 0x7f48abf0711d in clone () from /lib64/libc.so.6
  #13 0x in ?? ()
  (gdb) print ((BDRVQcowState *)bs-opaque)-cluster_allocs.lh_first 
  $5 = (struct QCowL2Meta *) 0xcb3568
  (gdb) print *((BDRVQcowState *)bs-opaque)-cluster_allocs.lh_first 
  $6 = {offset = 7417176064, n_start = 0, nb_available = 16, nb_clusters = 
  0, depends_on = 0xcb3568, dependent_requests = {lh_first = 0x0}, 
  next_in_flight = {le_next = 0xcb3568, le_prev = 0xc4ebd8}}
 
  So next == first.
 
  
  Seen the exact same bug twice in a row while installing FC12 with IDE
  disk, current qemu-kvm.git. 
  
  qemu-system-x86_64 -drive file=/root/images/fc12-ide.img,cache=writeback \
  -m 1000  -vnc :1 \
  -net nic,model=virtio \
  -net tap,script=/root/ifup.sh -serial stdio \
  -cdrom /root/iso/linux/Fedora-12-x86_64-DVD.iso -monitor
  telnet::4445,server,nowait -usbdevice tablet
  
  Can't reproduce though.
 
 In current git master? That's interesting news. I had kind of expected
 it would be fixed with c644db3d.

Yes, with 31b460256 more precisely. And the symptom was the same as Jan
reported, cluster_allocs.lh_first had le_next pointing to itself.

Perhaps you can add an assert there, so it abort()'s in that case along
with some useful information? I'll try to reproduce.





[Qemu-devel] Re: [PATCH 0/2] qcow2: Move BlockDriver definiton to the end of the file

2010-05-07 Thread Blue Swirl
On 5/7/10, Kevin Wolf kw...@redhat.com wrote:
 A recent build fix for OpenBSD moved the BlockDriver definition of qcow2 to
  somewhere in the middle of the source file. This series tries to solve the
  problem in a different way that allows the definition to stay where everyone
  looks for it.

  Blue Swirl, as I don't have an OpenBSD installation handy, can you try if 
 this
  works for you?

Seems to work. Should I commit them or do you want to use the block branch?




Re: [Qemu-devel] [PATCH] Add missing 'static' attribute

2010-05-07 Thread Blue Swirl
Thanks, applied.

On 5/6/10, Stefan Weil w...@mail.berlios.de wrote:
 Function usage() is only used locally.

  Signed-off-by: Stefan Weil w...@mail.berlios.de
  ---
   tests/qruncom.c |2 +-
   tests/runcom.c  |2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)

  diff --git a/tests/qruncom.c b/tests/qruncom.c
  index a8d0ef6..079f7a2 100644
  --- a/tests/qruncom.c
  +++ b/tests/qruncom.c
  @@ -89,7 +89,7 @@ int errno;

   #define COM_BASE_ADDR0x10100

  -void usage(void)
  +static void usage(void)
   {
  printf(qruncom version 0.1 (c) 2003 Fabrice Bellard\n
 usage: qruncom file.com\n
  diff --git a/tests/runcom.c b/tests/runcom.c
  index cbbaf31..6380566 100644
  --- a/tests/runcom.c
  +++ b/tests/runcom.c
  @@ -25,7 +25,7 @@ _syscall2(int, vm86, int, func, struct vm86plus_struct *, 
 v86)

   #define COM_BASE_ADDR0x10100

  -void usage(void)
  +static void usage(void)
   {
  printf(runcom version 0.1 (c) 2003 Fabrice Bellard\n
 usage: runcom file.com\n

 --
  1.7.0








[Qemu-devel] Re: Registering buffers with a qdict

2010-05-07 Thread Luiz Capitulino
On Fri, 07 May 2010 16:21:13 +0200
Jan Kiszka jan.kis...@siemens.com wrote:

 Luiz Capitulino wrote:
  On Fri, 07 May 2010 13:45:03 +0200
  Jan Kiszka jan.kis...@siemens.com wrote:
  
  Hi Luiz,
 
  what is the recommended way of pushing larger buffers (up to 64K so far)
  into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought
  about hex-encoding the content first (series of %02X), then
  registering it as QSTRING. Or should we introduce a new type, QBUFFER?
  
   I don't think that hex-encoding the contents is so bad if your use case is
  very specific and isolated.
 
 The focus will be first on visualizing the buffer (user_print), but who
 knows what happens once the services is also exposed via QMP.
 
  
   On the other hand, I do prefer a QBuffer type, specially because we can
  have buffer operations.
 
 The qtype.c files look sufficiently simply, guess I will add a buffer
 type. Still, hex-encoding is probably the best representation for QMP.

 Yes, either as a string or (as suggested by Markus) an array of numbers,
if you wish to expose this via QMP you (or any of us) will have to update
the parser to support it.




[Qemu-devel] Re: Commit 9c9bb6c89d4 breaks code execution from flash

2010-05-07 Thread Michael Walle

[sorry didn't see the CC to the mailinglist]

Am Friday 23 April 2010 09:23:49 schrieb Jan Kiszka:
 Michael Walle wrote:
  Hi Jan,
 
  your commit Optimize consecutive CFI02 writes by remapping memory
  lazily breaks the code execution from flash.
 
  If you write to the flash, the flash will switch into I/O mode. Now if
  code is executed from this flash, a cpu_abort will be raised (Trying to
  execute code outside RAM or ROM).

 Hmm, guess I didn't test execute-in-place back then. Do you happen to
 have a test case for this scenario? I'll look into this.
Only for my qemu-lm32 port.. But reading the flash id, while executing this 
code from flash should trigger the bug.

-- 
michael




Re: [Qemu-devel] [PATCH] tcg: Add missing 'static' attribute

2010-05-07 Thread Blue Swirl
Thanks, applied.

On 5/7/10, Stefan Weil w...@mail.berlios.de wrote:
 tcg_out_reloc is only used locally (in */target.c which is
  included in tcg.c).

  Signed-off-by: Stefan Weil w...@mail.berlios.de
  ---
   tcg/tcg.c |4 ++--
   tcg/tcg.h |3 ---
   2 files changed, 2 insertions(+), 5 deletions(-)

  diff --git a/tcg/tcg.c b/tcg/tcg.c
  index beceff0..f3c7909 100644
  --- a/tcg/tcg.c
  +++ b/tcg/tcg.c
  @@ -100,8 +100,8 @@ static inline void tcg_out32(TCGContext *s, uint32_t v)

   /* label relocation processing */

  -void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type,
  -   int label_index, long addend)
  +static void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type,
  +  int label_index, long addend)
   {
  TCGLabel *l;
  TCGRelocation *r;
  diff --git a/tcg/tcg.h b/tcg/tcg.h
  index 166c889..44856e1 100644
  --- a/tcg/tcg.h
  +++ b/tcg/tcg.h
  @@ -477,9 +477,6 @@ TCGv_i64 tcg_const_i64(int64_t val);
   TCGv_i32 tcg_const_local_i32(int32_t val);
   TCGv_i64 tcg_const_local_i64(int64_t val);

  -void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type,
  -   int label_index, long addend);
  -
   extern uint8_t code_gen_prologue[];
   #if defined(_ARCH_PPC)  !defined(_ARCH_PPC64)
   #define tcg_qemu_tb_exec(tb_ptr) \

 --
  1.7.0








[Qemu-devel] [PATCH] smbios: avoid counting io hole as ram

2010-05-07 Thread Alex Williamson
Avoid counting the io hole as part of ram, a vm started with 4G
should report 4G in smbios, not 4.5G.

Signed-off-by: Alex Williamson alex.william...@redhat.com
---

 src/smbios.c |   68 +-
 1 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/src/smbios.c b/src/smbios.c
index f948d78..7bcdcb3 100644
--- a/src/smbios.c
+++ b/src/smbios.c
@@ -246,7 +246,9 @@ smbios_init_type_16(void *start, u32 memory_size_mb, int 
nr_mem_devs)
 p-location = 0x01; /* other */
 p-use = 0x03; /* system memory */
 p-error_correction = 0x06; /* Multi-bit ECC to make Microsoft happy */
-p-maximum_capacity = memory_size_mb * 1024;
+/* 0x8000 = unknown, accept sizes  2TB - TODO multiple arrays */
+p-maximum_capacity = memory_size_mb  2  20 ?
+  memory_size_mb  10 : 0x8000;
 p-memory_error_information_handle = 0xfffe; /* none provided */
 p-number_of_memory_devices = nr_mem_devs;
 
@@ -258,7 +260,7 @@ smbios_init_type_16(void *start, u32 memory_size_mb, int 
nr_mem_devs)
 
 /* Type 17 -- Memory Device */
 static void *
-smbios_init_type_17(void *start, u32 memory_size_mb, int instance)
+smbios_init_type_17(void *start, u32 size_mb, int instance)
 {
 struct smbios_type_17 *p = (struct smbios_type_17 *)start;
 
@@ -270,7 +272,7 @@ smbios_init_type_17(void *start, u32 memory_size_mb, int 
instance)
 p-total_width = 64;
 p-data_width = 64;
 /* TODO: should assert in case something is wrong   ASSERT((memory_size_mb  
~0x7fff) == 0); */
-p-size = memory_size_mb;
+p-size = size_mb;
 p-form_factor = 0x09; /* DIMM */
 p-device_set = 0;
 p-device_locator_str = 1;
@@ -289,7 +291,7 @@ smbios_init_type_17(void *start, u32 memory_size_mb, int 
instance)
 
 /* Type 19 -- Memory Array Mapped Address */
 static void *
-smbios_init_type_19(void *start, u32 memory_size_mb, int instance)
+smbios_init_type_19(void *start, u32 start_mb, u32 size_mb, int instance)
 {
 struct smbios_type_19 *p = (struct smbios_type_19 *)start;
 
@@ -297,8 +299,8 @@ smbios_init_type_19(void *start, u32 memory_size_mb, int 
instance)
 p-header.length = sizeof(struct smbios_type_19);
 p-header.handle = 0x1300 + instance;
 
-p-starting_address = instance  24;
-p-ending_address = p-starting_address + (memory_size_mb  10) - 1;
+p-starting_address = start_mb  10;
+p-ending_address = p-starting_address + (size_mb  10) - 1;
 p-memory_array_handle = 0x1000;
 p-partition_width = 1;
 
@@ -310,7 +312,8 @@ smbios_init_type_19(void *start, u32 memory_size_mb, int 
instance)
 
 /* Type 20 -- Memory Device Mapped Address */
 static void *
-smbios_init_type_20(void *start, u32 memory_size_mb, int instance)
+smbios_init_type_20(void *start, u32 start_mb, u32 size_mb, int instance,
+int dev_handle, int array_handle)
 {
 struct smbios_type_20 *p = (struct smbios_type_20 *)start;
 
@@ -318,10 +321,10 @@ smbios_init_type_20(void *start, u32 memory_size_mb, int 
instance)
 p-header.length = sizeof(struct smbios_type_20);
 p-header.handle = 0x1400 + instance;
 
-p-starting_address = instance  24;
-p-ending_address = p-starting_address + (memory_size_mb  10) - 1;
-p-memory_device_handle = 0x1100 + instance;
-p-memory_array_mapped_address_handle = 0x1300 + instance;
+p-starting_address = start_mb  10;
+p-ending_address = p-starting_address + (size_mb  10) - 1;
+p-memory_device_handle = 0x1100 + dev_handle;
+p-memory_array_mapped_address_handle = 0x1300 + array_handle;
 p-partition_row_position = 1;
 p-interleave_position = 0;
 p-interleaved_data_depth = 0;
@@ -405,21 +408,36 @@ smbios_init(void)
 int cpu_num;
 for (cpu_num = 1; cpu_num = MaxCountCPUs; cpu_num++)
 add_struct(4, p, cpu_num);
-u64 memsize = RamSizeOver4G;
-if (memsize)
-memsize += 0x1ull;
-else
-memsize = RamSize;
-memsize = memsize / (1024 * 1024);
-int nr_mem_devs = (memsize + 0x3fff)  14;
-add_struct(16, p, memsize, nr_mem_devs);
-int i;
+
+int ram_mb = (RamSize + RamSizeOver4G)  20;
+int nr_mem_devs = (ram_mb + 0x3fff)  14;
+add_struct(16, p, ram_mb, nr_mem_devs);
+
+int i, j;
 for (i = 0; i  nr_mem_devs; i++) {
-u32 dev_memsize = ((i == (nr_mem_devs - 1))
-   ? (((memsize-1)  0x3fff)+1) : 0x4000);
-add_struct(17, p, dev_memsize, i);
-add_struct(19, p, dev_memsize, i);
-add_struct(20, p, dev_memsize, i);
+u32 dev_mb = ((i == (nr_mem_devs - 1))
+  ? (((ram_mb - 1)  0x3fff) + 1)
+  : 16384);
+add_struct(17, p, dev_mb, i);
+}
+
+add_struct(19, p, 0, RamSize  20, 0);
+if (RamSizeOver4G)
+add_struct(19, p, 4096, RamSizeOver4G  20, 1);
+
+add_struct(20, p, 0, RamSize  20, 0, 0, 0);
+if (RamSizeOver4G) {
+u32 start_mb = 4096;

[Qemu-devel] QLicense chaos

2010-05-07 Thread Jan Kiszka
Hi guys,

/*
 * QFloat Module
 *
 * Copyright (C) 2009 Red Hat Inc.
 *
 * Authors:
 *  Luiz Capitulino lcapitul...@redhat.com
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 *
 * Copyright IBM, Corp. 2009
 *
 * Authors:
 *  Anthony Liguori   aligu...@us.ibm.com
 *
 * 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.
 *
 */

Could you clean this up (and QBool)?

Moreover, some of the QObject files are LGPL, some GPL. I bet this was
also not intended. But what was the idea behind the LGPL? Some libqmp which
can be used by closed source apps? Then better establish the required
license soon. Postponing this will only once require tedious author
questionings.

Jan



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH] mips-dis: Add missing static attributes

2010-05-07 Thread Stefan Weil
mips_abi_choices and mips_arch_choices are only used locally.

Signed-off-by: Stefan Weil w...@mail.berlios.de
---
 mips-dis.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mips-dis.c b/mips-dis.c
index 169169c..ae64543 100644
--- a/mips-dis.c
+++ b/mips-dis.c
@@ -3035,7 +3035,7 @@ struct mips_abi_choice
   const char * const *fpr_names;
 };
 
-struct mips_abi_choice mips_abi_choices[] =
+static struct mips_abi_choice mips_abi_choices[] =
 {
   { numeric, mips_gpr_names_numeric, mips_fpr_names_numeric },
   { 32, mips_gpr_names_oldabi, mips_fpr_names_32 },
@@ -3086,7 +3086,7 @@ struct mips_arch_choice
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
 
-const struct mips_arch_choice mips_arch_choices[] =
+static const struct mips_arch_choice mips_arch_choices[] =
 {
   { numeric, 0, 0, 0, 0,
 mips_cp0_names_numeric, NULL, 0, mips_hwr_names_numeric },
-- 
1.7.0





[Qemu-devel] Missing mon in monitor_cur_is_qmp() and qerror_report()

2010-05-07 Thread Jan Kiszka
Luiz,

I missed this when the API was first proposed:

cur_mon is scheduled for removal (one day...). It's just an intermediate
step to convert all users to explicit 'mon' passing. Thus, new APIs
should not rely it.

I just realized that monitor_cur_is_qmp() does so. It should be
refactored to monitor_is_qmp(Monitor *mon). And qerror should be enhance
by a 'mon' argument as well. Callers that aren't passed a 'mon'
themselves should either be fixed at this chance or could fall back to
cur_mon for the time being.

So far for the theory - do you see any pitfalls in the existing usage?

Jan



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] vmstate: Useless post_save?

2010-05-07 Thread Jan Kiszka
Hi all,

I wondered why we have the post_save callback in vmstate. Conceptually,
it made no sense to me. So I grep'ed for its users - and found exactly
one: tmp105. As suspected, only strange code was found:

static void tmp105_post_save(void *opaque)
{
TMP105State *s = opaque;
s-faults = tmp105_faultq[(s-config  3)  3];/* F */
}

First, s-config cannot be changed by saving the state. And, second,
s-faults is only written by this driver, never read.

Anyone any concerns dropping 'faults' from tmp105 and then dropping the
post_save handler from vmstate?

Jan



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] QLicense chaos

2010-05-07 Thread Jamie Lokier
Jan Kiszka wrote:
 Moreover, some of the QObject files are LGPL, some GPL. I bet this was
 also not intended. But what was the idea behind the LGPL? Some libqmp which
 can be used by closed source apps?

I believe LGPL is needed for source apps that have GPLv2-incompatible
licensing.  E.g. GPLv3, Apache license, OpenSSL?  (I'm not sure exactly.)

And for those who want to keep their own apps BSD-like.

-- Jamie




Re: [Qemu-devel] QLicense chaos

2010-05-07 Thread Anthony Liguori

On 05/07/2010 02:39 PM, Jan Kiszka wrote:

Hi guys,

/*
  * QFloat Module
  *
  * Copyright (C) 2009 Red Hat Inc.
  *
  * Authors:
  *  Luiz Capitulinolcapitul...@redhat.com
  *
  * This work is licensed under the terms of the GNU GPL, version 2.  See
  * the COPYING file in the top-level directory.
  *
  * Copyright IBM, Corp. 2009
  *
  * Authors:
  *  Anthony Liguorialigu...@us.ibm.com
  *
  * 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.
  *
  */

Could you clean this up (and QBool)?

Moreover, some of the QObject files are LGPL, some GPL. I bet this was
also not intended. But what was the idea behind the LGPL? Some libqmp which
can be used by closed source apps? Then better establish the required
license soon. Postponing this will only once require tedious author
questionings.
   


So lgpl libraries (like libvirt) can use libqmp.

Regards,

Anthony Liguori


Jan

   






[Qemu-devel] Re: Bug in net/socket.c: info_str is overwritten

2010-05-07 Thread Luiz Capitulino
On Thu, 6 May 2010 10:42:10 -0300
Miguel Di Ciurcio Filho miguel.fi...@gmail.com wrote:

 Hi there,
 
 I'm working on the conversion of the 'info network' command do QMP,
 and I think I've found some problems.
 
 Running qemu like this: qemu -net socket,listen=:
 
 In net/socket.c, the function net_socket_listen_init() [1] is called
 and a listening socket is created. There is nothing registering this,
 so when using 'info network' as is, no information about this
 listening socket is shown.

 Right, not sure how important this info is but I'd expect it to
be shown.

 When a connection is accepted, the handler net_socket_accept() calls
 net_socket_fd_init(). If the socket is
 UDP/multicast net_socket_fd_init() calls net_socket_fd_init_dgram, if
 the socket is TCP it calls net_socket_fd_init_dgram_stream. [2]
 
 In both cases the info_str string is written inside
 net_socket_fd_init_(stream|dgram) [3], and after that, it is
 overwritten on a subsequent
 snprintf() in net_socket_accept() [4].

 Yes, those snprintf() in net_socket_fd_init_{stream,dgram} seems dead
code to me.

 Another problem is that info_str is not cleaned when the connection
is closed, which makes 'info network' keep saying that the connection is there.

 net_socket_fd_init_(stream|dgram) always puts into the info_str the fd
 number, and this information is overwritten latter. So, is the fd
 number
 relevant to be transmitted over QMP? Right now this information is
 being lost, IMHO.

 Only client writers can answer, I guess. But it's not a problem if we
don't include it now, as it's easy to extend the output later if needed.

 
 Same thing happens when qemu is run as a client:
 net_socket_connect_init() calls net_socket_fd_init_(dgram|stream) and
 latter overwrites info_str.
 
 [1] http://git.qemu.org/qemu.git/tree/net/socket.c#n375
 [2] http://git.qemu.org/qemu.git/tree/net/socket.c#n336
 [3] http://git.qemu.org/qemu.git/tree/net/socket.c#n310
 [4] http://git.qemu.org/qemu.git/tree/net/socket.c#n369