[Qemu-devel] Abnormal function exit message in Qemu block drivers code

2011-10-27 Thread shu ming

Hi,
  After reading the block driver code in,  it was found that the error 
exit code behaved in different ways.  Here are some examples.  It seems 
that way 3 is a better way to log the error message.  In fact,  It is 
pretty important for a administrator to know what is going on and be 
informed the error when that happens. I believe  we should convert all 
the error exit code to way 3 gradually and make all the new code to 
follow an unique standard.
  Further more, really, some errors can be ignored while others can 
not.  So we can have a more flexible function to classify the level of 
the error message like

error_report(log_level,  string format, string);

1)The error code exited silently.

case QCOW2_EXT_MAGIC_BACKING_FORMAT:
if (ext.len = sizeof(bs-backing_format)) {
fprintf(stderr, ERROR: ext_backing_format: len=%u too 
large

 (=%zu)\n,
ext.len, sizeof(bs-backing_format));
return 2;
}

2)  fprintf() to emit the error message

case QCOW2_EXT_MAGIC_BACKING_FORMAT:
if (ext.len = sizeof(bs-backing_format)) {
fprintf(stderr, ERROR: ext_backing_format: len=%u too 
large

 (=%zu)\n,
ext.len, sizeof(bs-backing_format));
return 2;

3) A error_report() function to emit the error message.

/* Find driver and parse its options */
drv = bdrv_find_format(fmt);
if (!drv) {
error_report(Unknown file format '%s', fmt);
ret = -EINVAL;
goto out;
}





[Qemu-devel] [PATCH] qcow2: fix some errors and typo in qcow2.txt

2011-10-27 Thread Zhi Yong Wu
Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com
---
 docs/specs/qcow2.txt |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/specs/qcow2.txt b/docs/specs/qcow2.txt
index 8fc3cb2..e792953 100644
--- a/docs/specs/qcow2.txt
+++ b/docs/specs/qcow2.txt
@@ -108,8 +108,8 @@ as follows:
 
 refcount_block_entries = (cluster_size / sizeof(uint16_t))
 
-refcount_block_index = (offset / cluster_size) % refcount_table_entries
-refcount_table_index = (offset / cluster_size) / refcount_table_entries
+refcount_block_index = (offset / cluster_size) % refcount_block_entries
+refcount_table_index = (offset / cluster_size) / refcount_block_entries
 
 refcount_block = load_cluster(refcount_table[refcount_table_index]);
 return refcount_block[refcount_block_index];
@@ -211,7 +211,7 @@ switch the active L1 table, so that a different set of host 
clusters are
 exposed to the guest.
 
 When creating a snapshot, the L1 table should be copied and the refcount of all
-L2 tables and clusters reachable form this L1 table must be increased, so that
+L2 tables and clusters reachable from this L1 table must be increased, so that
 a write causes a COW and isn't visible in other snapshots.
 
 When loading a snapshot, bit 63 of all entries in the new active L1 table and
-- 
1.7.6




[Qemu-devel] [PATCH v2] migration: flush migration data to disk.

2011-10-27 Thread Gerd Hoffmann
This patch increases robustness when migrating to a file with
two little changes:

 (1) Before closing the migration file handle checks if it happens to be
 a regular file and if so it issues a fsync.  This way the data is
 flushed to disk before qemu sends the migration completed event.
 (2) It adds error checking.  In case either fsync or close syscall
 fails pass up the error (and fail migration).

[ v2: return -errno instead of -1 ]

Cc: Juan Quintela quint...@redhat.com
Cc: Jiri Denemark jdene...@redhat.com
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 migration-fd.c |   23 ++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/migration-fd.c b/migration-fd.c
index d0aec89..6211124 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -42,10 +42,31 @@ static int fd_write(MigrationState *s, const void * buf, 
size_t size)
 
 static int fd_close(MigrationState *s)
 {
+struct stat st;
+int ret;
+
 DPRINTF(fd_close\n);
 if (s-fd != -1) {
-close(s-fd);
+ret = fstat(s-fd, st);
+if (ret == 0  S_ISREG(st.st_mode)) {
+/*
+ * If the file handle is a regular file make sure the
+ * data is flushed to disk before signaling success.
+ */
+ret = fsync(s-fd);
+if (ret != 0) {
+ret = -errno;
+perror(migration-fd: fsync);
+return ret;
+}
+}
+ret = close(s-fd);
 s-fd = -1;
+if (ret != 0) {
+ret = -errno;
+perror(migration-fd: close);
+return ret;
+}
 }
 return 0;
 }
-- 
1.7.1




Re: [Qemu-devel] [PATCH 4/7] ide: Fix off-by-one error in array index check

2011-10-27 Thread Paolo Bonzini

On 10/26/2011 02:31 PM, Kevin Wolf wrote:

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

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 280a117..29305d3 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2039,7 +2039,7 @@ static int ide_drive_pio_post_load(void *opaque, int 
version_id)
  {
  IDEState *s = opaque;

-if (s-end_transfer_fn_idx  ARRAY_SIZE(transfer_end_table)) {
+if (s-end_transfer_fn_idx= ARRAY_SIZE(transfer_end_table)) {
  return -EINVAL;
  }
  s-end_transfer_func = transfer_end_table[s-end_transfer_fn_idx];


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



Re: [Qemu-devel] [PATCH 3/7] qcow: Fix bdrv_write_compressed error handling

2011-10-27 Thread Paolo Bonzini

On 10/26/2011 02:31 PM, Kevin Wolf wrote:

Signed-off-by: Kevin Wolfkw...@redhat.com
---
  block/qcow.c |   30 +++---
  1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index ab36b29..35e21eb 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -736,8 +736,6 @@ static int qcow_write_compressed(BlockDriverState *bs, 
int64_t sector_num,
  return -EINVAL;

  out_buf = g_malloc(s-cluster_size + (s-cluster_size / 1000) + 128);
-if (!out_buf)
-return -1;

  /* best compression, small window, no zlib header */
  memset(strm, 0, sizeof(strm));
@@ -745,8 +743,8 @@ static int qcow_write_compressed(BlockDriverState *bs, 
int64_t sector_num,
 Z_DEFLATED, -12,
 9, Z_DEFAULT_STRATEGY);
  if (ret != 0) {
-g_free(out_buf);
-return -1;
+ret = -EINVAL;
+goto fail;
  }

  strm.avail_in = s-cluster_size;
@@ -756,9 +754,9 @@ static int qcow_write_compressed(BlockDriverState *bs, 
int64_t sector_num,

  ret = deflate(strm, Z_FINISH);
  if (ret != Z_STREAM_END  ret != Z_OK) {
-g_free(out_buf);
  deflateEnd(strm);
-return -1;
+ret = -EINVAL;
+goto fail;
  }
  out_len = strm.next_out - out_buf;

@@ -766,19 +764,29 @@ static int qcow_write_compressed(BlockDriverState *bs, 
int64_t sector_num,

  if (ret != Z_STREAM_END || out_len= s-cluster_size) {
  /* could not compress: write normal cluster */
-bdrv_write(bs, sector_num, buf, s-cluster_sectors);
+ret = bdrv_write(bs, sector_num, buf, s-cluster_sectors);
+if (ret  0) {
+goto fail;
+}
  } else {
  cluster_offset = get_cluster_offset(bs, sector_num  9, 2,
  out_len, 0, 0);
+if (cluster_offset == 0) {
+ret = -EIO;
+goto fail;
+}
+
  cluster_offset= s-cluster_offset_mask;
-if (bdrv_pwrite(bs-file, cluster_offset, out_buf, out_len) != 
out_len) {
-g_free(out_buf);
-return -1;
+ret = bdrv_pwrite(bs-file, cluster_offset, out_buf, out_len);
+if (ret  0) {
+goto fail;
  }
  }

+ret = 0;
+fail:
  g_free(out_buf);
-return 0;
+return ret;
  }

  static coroutine_fn int qcow_co_flush(BlockDriverState *bs)


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




[Qemu-devel] libacard build error

2011-10-27 Thread Jan Kiszka
Hi Alon,

I'm getting this with current qemu.git:

  CClibcacard/vcard_emul_nss.o
cc1: warnings being treated as errors
In file included from /usr/include/nss3/pkcs11t.h:1780:0,
 from /usr/include/nss3/keythi.h:41,
 from /usr/include/nss3/keyt.h:41,
 from /usr/include/nss3/pk11pub.h:43,
 from /data/qemu/libcacard/vcard_emul_nss.c:21:
/usr/include/nss3/pkcs11n.h:365:26: error: __GNUC_MINOR is not defined

Just dumping, haven't looked into details. Any patch to fix this already
queued?

Jan



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] libacard build error

2011-10-27 Thread Alon Levy
On Thu, Oct 27, 2011 at 09:33:50AM +0200, Jan Kiszka wrote:
 Hi Alon,
 
 I'm getting this with current qemu.git:
 
   CClibcacard/vcard_emul_nss.o
 cc1: warnings being treated as errors
 In file included from /usr/include/nss3/pkcs11t.h:1780:0,
  from /usr/include/nss3/keythi.h:41,
  from /usr/include/nss3/keyt.h:41,
  from /usr/include/nss3/pk11pub.h:43,
  from /data/qemu/libcacard/vcard_emul_nss.c:21:
 /usr/include/nss3/pkcs11n.h:365:26: error: __GNUC_MINOR is not defined
 
 Just dumping, haven't looked into details. Any patch to fix this already
 queued?
 

No, I haven't noticed this, thanks for letting me know. I don't get it here, I 
have this command line: (via V=1)

gcc -I/home/alon/src/qemu/slirp -I. -I/home/alon/src/qemu 
-I/home/alon/src/qemu/fpu -Werror -m64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
-fno-strict-aliasing -I/home/alon/spice/include  -fstack-protector-all 
-Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs 
-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers 
-Wold-style-declaration -Wold-style-definition -Wtype-limits 
-I/usr/include/libpng12   -I/home/alon/spice/include/spice-server 
-I/home/alon/spice/include/spice-1 -I/usr/include/pixman-1   
-I/home/alon/src/qemu/libcacard -I/usr/include/nss3 -I/usr/include/nspr4 
-pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -I../ -pthread 
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -MMD -MP -MT 
vcard_emul_nss.o -MF ./vcard_emul_nss.d -g  -c -o vcard_emul_nss.o 
vcard_emul_nss.c

$ rpm -qf /usr/include/nss3/pkcs11n.h
nss-util-devel-3.12.10-1.fc16.x86_64

grep GNU_MINOR /usr/include/nss3/pkcs11n.h
empty

What version of nss-util are you using?

 Jan
 





Re: [Qemu-devel] [QEMU : VVFAT] vvfat.c - help required for understanding/modification

2011-10-27 Thread Kevin Wolf
Am 26.10.2011 21:17, schrieb Pintu Kumar:
 Dear Mr. Johannes,
 
 I am sorry but I think you took me wrong. I never asked you to do things for 
 me.
 I just wanted few clarifications to proceed further as I was stuck
 after performing few experiments as below:

You are stuck because you still didn't think about the theory before
jumping to the code. Please do this before asking more questions. Both
Johannes and I have told you that it's not as easy as you seem to think.

When you have a design to solve the problem (and I believe it might be
better to start that from scratch rather than extending vvfat as it
would end up being a rewrite anyway), we can discuss that design. But it
doesn't make any sense to discuss detailed changes in vvfat when you
don't even seem to understand the problem.

 But there is one problem here if I use the above logic.
 When I issue ls command vvfat_read is not getting triggered.
 So I think there is some problem and I could figure out where to
 implement the dynamic scanning of sub-directory later.

Why do you expect that vvfat_read is called? If the guest OS has the
directory entries already cached, there's no reason for it to read them
from disk.

Kevin



Re: [Qemu-devel] Abnormal function exit message in Qemu block drivers code

2011-10-27 Thread Cao,Bing Bu

On 10/27/2011 02:16 PM, shu ming wrote:

Hi,
  After reading the block driver code in,  it was found that the error 
exit code behaved in different ways.  Here are some examples.  It 
seems that way 3 is a better way to log the error message.  In fact,  
It is pretty important for a administrator to know what is going on 
and be informed the error when that happens. I believe  we should 
convert all the error exit code to way 3 gradually and make all the 
new code to follow an unique standard.
  Further more, really, some errors can be ignored while others can 
not.  So we can have a more flexible function to classify the level of 
the error message like

error_report(log_level,  string format, string);

1)The error code exited silently.

case QCOW2_EXT_MAGIC_BACKING_FORMAT:
if (ext.len = sizeof(bs-backing_format)) {
fprintf(stderr, ERROR: ext_backing_format: len=%u too 
large

 (=%zu)\n,
ext.len, sizeof(bs-backing_format));
return 2;
}


The example of the first way looks like not correct.

case QCOW2_EXT_MAGIC_BACKING_FORMAT:
if (ext.len = sizeof(bs-backing_format)) {
-   fprintf(stderr, ERROR: ext_backing_format: len=%u too large
-   (=%zu)\n,
-   ext.len, sizeof(bs-backing_format));
return 2;
}


2)  fprintf() to emit the error message

case QCOW2_EXT_MAGIC_BACKING_FORMAT:
if (ext.len = sizeof(bs-backing_format)) {
fprintf(stderr, ERROR: ext_backing_format: len=%u too 
large

 (=%zu)\n,
ext.len, sizeof(bs-backing_format));
return 2;
3) A error_report() function to emit the error message.

/* Find driver and parse its options */
drv = bdrv_find_format(fmt);
if (!drv) {
error_report(Unknown file format '%s', fmt);
ret = -EINVAL;
goto out;
}








Re: [Qemu-devel] [Bug 824650] [NEW] Latest GIT assert error in arp_table.c

2011-10-27 Thread Jan Kiszka
On 2011-10-27 05:21, Roy Tam wrote:
 2011/10/27 Roy Tam roy...@gmail.com:
 Hi,

 2011/10/26 Jan Kiszka jan.kis...@siemens.com:
 On 2011-10-26 10:03, Roy Tam wrote:
 Hi,

 2011/9/15 Jan Kiszka jan.kis...@web.de:
 On 2011-09-15 15:20, Roy Tam wrote:
 2011/9/15 Jan Kiszka jan.kis...@web.de:
 On 2011-09-15 14:05, Roy Tam wrote:
 Here you go.

 sb16: warning: command 0xf,1 is not truly understood yet
 sb16: warning: command 0xe,2 is not truly understood yet
 [Switching to Thread 13840.0x3140]

 Breakpoint 1, arp_table_search (slirp=0x19f7380, ip_addr=4294967295,
 out_ethaddr=0x20af64a ) at slirp/arp_table.c:75
 75  //assert((ip_addr  htonl(~(0xf  28))) != 0);
 (gdb) c
 Continuing.
 [New Thread 13840.0x31b8]
 [Switching to Thread 13840.0x3628]

 Breakpoint 1, arp_table_search (slirp=0x19f7380, ip_addr=0,
 out_ethaddr=0x22f642 \) at slirp/arp_table.c:75
 75  //assert((ip_addr  htonl(~(0xf  28))) != 0);
 (gdb) bt
 #0  arp_table_search (slirp=0x19f7380, ip_addr=0, out_ethaddr=0x22f642 
 \)
 at slirp/arp_table.c:75
 #1  0x004bafbd in if_encap (slirp=0x19f7488, ifm=0x2255978)
 at slirp/slirp.c:709
 #2  0x004b8a73 in if_start (slirp=0x19f7380) at slirp/if.c:210
 #3  0x004b9c9e in ip_output (so=0x2255978, m0=0x0) at 
 slirp/ip_output.c:84
 #4  0x004bf737 in tcp_output (tp=0x1cac848) at slirp/tcp_output.c:456
 #5  0x004c09ad in tcp_drop (tp=0x1cac848, err=0) at 
 slirp/tcp_subr.c:225
 #6  0x004c1182 in tcp_timers (timer=optimized out, tp=optimized 
 out)
 at slirp/tcp_timer.c:287
 #7  tcp_slowtimo (slirp=0x0) at slirp/tcp_timer.c:88
 #8  0x004bb6f1 in slirp_select_poll (readfds=0x22fae0, 
 writefds=0x22f9dc,
 xfds=0x22f8d8, select_error=2291816) at slirp/slirp.c:433
 #9  0x0048fb87 in main_loop_wait (nonblocking=0)
 at C:/msys/home/User/qemu/vl.c:1436
 #10 0x00490d10 in main_loop () at C:/msys/home/User/qemu/vl.c:1466
 #11 qemu_main (argc=0, argv=0x19f5100, envp=0x0)
 at C:/msys/home/User/qemu/vl.c:3453
 #12 0x0049322d in SDL_main (argc=17, argv=0x19f5100)
 at C:/msys/home/User/qemu/vl.c:102
 #13 0x005eb784 in console_main ()
 #14 0x005eb844 in WinMain@16 ()
 #15 0x005eb068 in main ()
 (gdb) frame 4
 #4  0x004bf737 in tcp_output (tp=0x1cac848) at slirp/tcp_output.c:456
 456 error = ip_output(so, m);
 (gdb) print *tp
 $1 = {seg_next = 0x1cac848, seg_prev = 0x1cac848, t_state = 0, t_timer 
 = {0,
 0, 0, 0}, t_rxtshift = 0, t_rxtcur = 12, t_dupacks = 0, t_maxseg = 
 1460,
   t_force = 0 '\000', t_flags = 0, t_template = {ti_i = {ih_mbuf = {
 mptr = 0x0, dummy = 0}, ih_x1 = 0 '\000', ih_pr = 0 '\000',
   ih_len = 0, ih_src = {S_un = {S_un_b = {s_b1 = 0 '\000',
 s_b2 = 0 '\000', s_b3 = 0 '\000', s_b4 = 0 '\000'}, S_un_w 
 = {
 s_w1 = 0, s_w2 = 0}, S_addr = 0}}, ih_dst = {S_un = 
 {S_un_b = {
 s_b1 = 0 '\000', s_b2 = 0 '\000', s_b3 = 0 '\000',
 s_b4 = 0 '\000'}, S_un_w = {s_w1 = 0, s_w2 = 0}, S_addr = 
 0}}},

 That confirms my theory: the template is not yet initialized.

 A shot from the hips: does this patch help?


 Yeah the assertion doesn't fail anymore. Thanks.

 Now I just need to invent some good why this is correct... ;)

 Thanks for testing,

 I just have time now to make some tests about -net user.
 And I found that the User mode networking doesn't work anymore after
 your slirp patch series.

 Can you be more verbose? What precisely does not work? Same setup as
 before (host, guest, command line, steps to reproduce)? I'm not facing
 problems here ATM.


 QEMU Revision: 2011-10-12 (latest git give me an Assertion failed:
 alarm_has_dynticks(t), file qemu-timer.c, line 139. Since there is no
 change in slirp directory, it should apply to latest git)
 gcc version:$ gcc -v
 Target: mingw32
 Configured with: ../gcc-4.3.3/configure --prefix=/mingw
 --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,obj-c++
 --with-bugurl=http://www.tdragon.net/recentgcc/bugs.php --disable-nls
 --disable-win32-registry --enable-libgomp --disable-werror
 --enable-threads --disable-symvers
 --enable-cxx-flags='-fno-function-sections -fno-data-sections'
 --enable-fully-dynamic-string --enable-version-specific-runtime-libs
 --enable-sjlj-exceptions --with-pkgversion='4.3.3-tdm-1 mingw32'
 Thread model: win32
 gcc version 4.3.3 (4.3.3-tdm-1 mingw32)
 configure commandline: ./configure --target-list=i386-softmmu
 x86_64-softmmu mips64el-softmmu --audio-drv-list=sdl
 --audio-card-list=ac97,sb16,adlib --disable-linux-aio
 --enable-vnc-thread --disable-vnc-jpeg --extra-ldflags=-s
 QEMU Host: Windows XP SP3
 QEMU Guest: Windows XP SP3, Linux 2.6.38 (NIC: ne2k-pci, e1000)
 commandline: qemu-system-i386 -hda xp.vmdk -soundhw sb16 -m 320
 -localtime -usb -usbdevice tablet -net user -net nic,model=ne2k_pci

 Symptoms:
 Guest can lease IP from QEMU Virtual DHCP Server, but the outgoing
 traffic are not working:
 - 10.0.2.3 Virtual DNS Server doesn't respond any DNS query (nslookup
 www.google.com fails with timeout 

Re: [Qemu-devel] [PATCH] Documentation: add new section for device URL syntax for special files and describe the iSCSI URL with examples

2011-10-27 Thread Stefan Hajnoczi
On Wed, Oct 26, 2011 at 11:51:37PM +1100, Ronnie Sahlberg wrote:
 
 Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com
 ---
  qemu-options.hx |   42 ++
  1 files changed, 42 insertions(+), 0 deletions(-)

Good idea, thanks for adding documentation.

Reviewed-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com



Re: [Qemu-devel] [PATCH] Fix compiler warning (always return a value), introduce qemu_abort?

2011-10-27 Thread Stefan Hajnoczi
On Wed, Oct 26, 2011 at 06:35:08PM +0200, Stefan Weil wrote:
 Am 26.10.2011 14:54, schrieb Stefan Hajnoczi:
 On Mon, Oct 24, 2011 at 10:18:43PM +0200, Stefan Weil wrote:
 For compilations with -DNDEBUG, the default case did not return
 a value which caused a compiler warning.
 
 Signed-off-by: Stefan Weil s...@weilnetz.de
 ---
 hw/ppce500_spin.c | 11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)
 
 diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c
 index cccd940..5b5ffe0 100644
 --- a/hw/ppce500_spin.c
 +++ b/hw/ppce500_spin.c
 @@ -168,17 +168,22 @@ static uint64_t spin_read(void *opaque,
 target_phys_addr_t addr, unsigned len)
 {
 SpinState *s = opaque;
 uint8_t *spin_p = ((uint8_t*)s-spin)[addr];
 + uint64_t result = 0;
 
 switch (len) {
 case 1:
 - return ldub_p(spin_p);
 + result = ldub_p(spin_p);
 + break;
 case 2:
 - return lduw_p(spin_p);
 + result = lduw_p(spin_p);
 + break;
 case 4:
 - return ldl_p(spin_p);
 + result = ldl_p(spin_p);
 + break;
 default:
 assert(0);
 
 I would replace assert(3) with abort(3). If this ever happens the
 program is broken - returning 0 instead of an undefined value doesn't
 help.
 
 Stefan
 
 Alex, do you agree on replacing assert() by abort()?
 
 I personally don't like abort() because it does not show the
 reason for the failure.
 
 Most users don't know how to get a core dump or how to
 use gdb. And even for those who know, a crash caused
 by an abort() which cannot be reproduced usually happens
 on a system were ulimit disables core dumps...
 
 I'd like to have a qemu_abort() macro in qemu-common.h which
 replaces all abort() calls used today:

Sounds good.

Stefan



Re: [Qemu-devel] [Qemu-trivial] [PATCH] Teach block/vdi about discarded (no longer allocated) blocks

2011-10-27 Thread Stefan Hajnoczi
On Wed, Oct 26, 2011 at 03:51:18PM -0400, Eric Sunshine wrote:
 An entry in the VDI block map will hold an offset to the actual block if
 the block is allocated, or one of two specially-interpreted values if
 not allocated. Using VirtualBox terminology, value VDI_IMAGE_BLOCK_FREE
 (0x) represents a never-allocated block (semantically arbitrary
 content).  VDI_IMAGE_BLOCK_ZERO (0xfffe) represents a discarded
 block (semantically zero-filled).  block/vdi knows only about
 VDI_IMAGE_BLOCK_FREE.  Teach it about VDI_IMAGE_BLOCK_ZERO.
 
 Signed-off-by: Eric Sunshine sunsh...@sunshineco.com
 ---
 
 Without this patch, qemu-image check on a VDI image containing
 discarded blocks reports errors such as:
 
   ERROR: block index 3434 too large, is 4294967294
 
 Decimal 4294967294 is 0xfffe. Worse, qemu-image convert or direct
 access of the VDI image from qemu involves reads and writes of blocks at
 the bogus block offset 4294967294 within the image file.
 
 Cc: Stefan Weil w...@mail.berlios.de
 Cc: Kevin Wolf kw...@redhat.com
 
  block/vdi.c |   23 ++-
  1 files changed, 14 insertions(+), 9 deletions(-)

Good to see this improvement.  I recently talked to a CernVM developer
who had issues with vdi images.  This may fix the issue they were
seeing.

I think Kevin should take this through the block tree.  I won't apply it
to trivial-patches.

Stefan



Re: [Qemu-devel] [PATCH v3] add add-cow file format

2011-10-27 Thread Stefan Hajnoczi
On Wed, Oct 26, 2011 at 06:08:03PM +0800, Robert Wang wrote:
 Please find version 4 in the attachment.

Please send patches inline instead of attaching them.  It makes it
easier to reply with feedback.

If you want to add extra comments that should not be included in the git
commit you can add it below the '---' line in the patch.

Stefan



Re: [Qemu-devel] libacard build error

2011-10-27 Thread Jan Kiszka
On 2011-10-27 09:56, Alon Levy wrote:
 On Thu, Oct 27, 2011 at 09:33:50AM +0200, Jan Kiszka wrote:
 Hi Alon,

 I'm getting this with current qemu.git:

   CClibcacard/vcard_emul_nss.o
 cc1: warnings being treated as errors
 In file included from /usr/include/nss3/pkcs11t.h:1780:0,
  from /usr/include/nss3/keythi.h:41,
  from /usr/include/nss3/keyt.h:41,
  from /usr/include/nss3/pk11pub.h:43,
  from /data/qemu/libcacard/vcard_emul_nss.c:21:
 /usr/include/nss3/pkcs11n.h:365:26: error: __GNUC_MINOR is not defined

 Just dumping, haven't looked into details. Any patch to fix this already
 queued?

 
 No, I haven't noticed this, thanks for letting me know. I don't get it here, 
 I have this command line: (via V=1)
 
 gcc -I/home/alon/src/qemu/slirp -I. -I/home/alon/src/qemu 
 -I/home/alon/src/qemu/fpu -Werror -m64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE 
 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
 -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
 -fno-strict-aliasing -I/home/alon/spice/include  -fstack-protector-all 
 -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs 
 -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers 
 -Wold-style-declaration -Wold-style-definition -Wtype-limits 
 -I/usr/include/libpng12   -I/home/alon/spice/include/spice-server 
 -I/home/alon/spice/include/spice-1 -I/usr/include/pixman-1   
 -I/home/alon/src/qemu/libcacard -I/usr/include/nss3 -I/usr/include/nspr4 
 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -I../ 
 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -MMD -MP -MT 
 vcard_emul_nss.o -MF ./vcard_emul_nss.d -g  -c -o vcard_emul_nss.o 
 vcard_emul_nss.c
 
 $ rpm -qf /usr/include/nss3/pkcs11n.h
 nss-util-devel-3.12.10-1.fc16.x86_64
 
 grep GNU_MINOR /usr/include/nss3/pkcs11n.h

GNUC_MINOR :)

 empty
 
 What version of nss-util are you using?

mozilla-nss-devel-3.13.0-2.1.x86_64

Jan



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 0/4] add make check

2011-10-27 Thread Kevin Wolf
Am 26.10.2011 22:49, schrieb Anthony Liguori:
 On 10/25/2011 10:22 AM, Kevin Wolf wrote:
 Am 25.10.2011 17:03, schrieb Eduardo Habkost:
 I think qemu-iotests could be considered an instance of B)

 C) Functional tests that just need to run a small binary with no OS
 installed in the guest, but running a fully-feature qemu process.
 - The tests in the 'tests' directory do this, right? kvm-unittests
   does this, right?

 Not sure what test/ does, but for kvm-unittests yes. And this is also
 what I was talking about.
 
 Thinking more about this...
 
 We could add a new '-x-test-server CHR' option.  When this option is added, 
 it 
 would do the following:
 
 1) Open CHR character device
 2) Use /dev/shm for guest memory
 3) Listen for connections on CHR
 4) When something connects to CHR
   a) reset device model
   b) send /dev/shm fd over CHR
   c) register CPU physical memory client
  1. upon CPU physical memory changes, send the change info over CHR
   d) instead of doing [kvm_]cpu_exec(), block reading on CHR
 
 So when you launch qemu with -x-test-server, it'll sit there doing nothing 
 terribly useful.  But this lets you write a program that connects to CHR, and 
 then by mapping {out,in}[bwl] to RPCs over the connection, and accessing RAM 
 via 
 mmap()'ing the passed fd using the client mapping table, you can essentially 
 write kvm-unittest style tests while still having full access to libc.

IRQs need to go through the connection as well.

Oh, and you would finally have a C user for libqmp. The test cases
definitely need to be able to access the monitor. For example I would
really love to have test cases for the I/O error paths that stop the VM
(or actually it's the resume that must be tested).

 And since each test program can reset QEMU after running, you could very 
 nicely 
 tie into something like gtest as a unit test framework.  I think it's pretty 
 appealing from a debugability perspective too.
 
 It also means that it's possible to have 100% C test cases such that you 
 could 
 still build something like ppc64-softmmu and run it against the written test 
 cases without having to really understand ppc64 assembly or have a ppc64 
 build 
 environment (to generate native binaries to run under ppc64 TCG).
 
 I think this could work out fairly well as a unit test framework.

Sounds great, where are the patches? ;-)

Kevin



Re: [Qemu-devel] [Bug 824650] [NEW] Latest GIT assert error in arp_table.c

2011-10-27 Thread Roy Tam
2011/10/27 Jan Kiszka jan.kis...@siemens.com:
 On 2011-10-27 05:21, Roy Tam wrote:
 2011/10/27 Roy Tam roy...@gmail.com:
 Hi,

 2011/10/26 Jan Kiszka jan.kis...@siemens.com:
 On 2011-10-26 10:03, Roy Tam wrote:
 Hi,

 2011/9/15 Jan Kiszka jan.kis...@web.de:
 On 2011-09-15 15:20, Roy Tam wrote:
 2011/9/15 Jan Kiszka jan.kis...@web.de:
 On 2011-09-15 14:05, Roy Tam wrote:
 Here you go.

 sb16: warning: command 0xf,1 is not truly understood yet
 sb16: warning: command 0xe,2 is not truly understood yet
 [Switching to Thread 13840.0x3140]

 Breakpoint 1, arp_table_search (slirp=0x19f7380, ip_addr=4294967295,
     out_ethaddr=0x20af64a ) at slirp/arp_table.c:75
 75      //    assert((ip_addr  htonl(~(0xf  28))) != 0);
 (gdb) c
 Continuing.
 [New Thread 13840.0x31b8]
 [Switching to Thread 13840.0x3628]

 Breakpoint 1, arp_table_search (slirp=0x19f7380, ip_addr=0,
     out_ethaddr=0x22f642 \) at slirp/arp_table.c:75
 75      //    assert((ip_addr  htonl(~(0xf  28))) != 0);
 (gdb) bt
 #0  arp_table_search (slirp=0x19f7380, ip_addr=0, 
 out_ethaddr=0x22f642 \)
     at slirp/arp_table.c:75
 #1  0x004bafbd in if_encap (slirp=0x19f7488, ifm=0x2255978)
     at slirp/slirp.c:709
 #2  0x004b8a73 in if_start (slirp=0x19f7380) at slirp/if.c:210
 #3  0x004b9c9e in ip_output (so=0x2255978, m0=0x0) at 
 slirp/ip_output.c:84
 #4  0x004bf737 in tcp_output (tp=0x1cac848) at slirp/tcp_output.c:456
 #5  0x004c09ad in tcp_drop (tp=0x1cac848, err=0) at 
 slirp/tcp_subr.c:225
 #6  0x004c1182 in tcp_timers (timer=optimized out, tp=optimized 
 out)
     at slirp/tcp_timer.c:287
 #7  tcp_slowtimo (slirp=0x0) at slirp/tcp_timer.c:88
 #8  0x004bb6f1 in slirp_select_poll (readfds=0x22fae0, 
 writefds=0x22f9dc,
     xfds=0x22f8d8, select_error=2291816) at slirp/slirp.c:433
 #9  0x0048fb87 in main_loop_wait (nonblocking=0)
     at C:/msys/home/User/qemu/vl.c:1436
 #10 0x00490d10 in main_loop () at C:/msys/home/User/qemu/vl.c:1466
 #11 qemu_main (argc=0, argv=0x19f5100, envp=0x0)
     at C:/msys/home/User/qemu/vl.c:3453
 #12 0x0049322d in SDL_main (argc=17, argv=0x19f5100)
     at C:/msys/home/User/qemu/vl.c:102
 #13 0x005eb784 in console_main ()
 #14 0x005eb844 in WinMain@16 ()
 #15 0x005eb068 in main ()
 (gdb) frame 4
 #4  0x004bf737 in tcp_output (tp=0x1cac848) at slirp/tcp_output.c:456
 456             error = ip_output(so, m);
 (gdb) print *tp
 $1 = {seg_next = 0x1cac848, seg_prev = 0x1cac848, t_state = 0, 
 t_timer = {0,
     0, 0, 0}, t_rxtshift = 0, t_rxtcur = 12, t_dupacks = 0, t_maxseg 
 = 1460,
   t_force = 0 '\000', t_flags = 0, t_template = {ti_i = {ih_mbuf = {
         mptr = 0x0, dummy = 0}, ih_x1 = 0 '\000', ih_pr = 0 '\000',
       ih_len = 0, ih_src = {S_un = {S_un_b = {s_b1 = 0 '\000',
             s_b2 = 0 '\000', s_b3 = 0 '\000', s_b4 = 0 '\000'}, 
 S_un_w = {
             s_w1 = 0, s_w2 = 0}, S_addr = 0}}, ih_dst = {S_un = 
 {S_un_b = {
             s_b1 = 0 '\000', s_b2 = 0 '\000', s_b3 = 0 '\000',
             s_b4 = 0 '\000'}, S_un_w = {s_w1 = 0, s_w2 = 0}, S_addr = 
 0}}},

 That confirms my theory: the template is not yet initialized.

 A shot from the hips: does this patch help?


 Yeah the assertion doesn't fail anymore. Thanks.

 Now I just need to invent some good why this is correct... ;)

 Thanks for testing,

 I just have time now to make some tests about -net user.
 And I found that the User mode networking doesn't work anymore after
 your slirp patch series.

 Can you be more verbose? What precisely does not work? Same setup as
 before (host, guest, command line, steps to reproduce)? I'm not facing
 problems here ATM.


 QEMU Revision: 2011-10-12 (latest git give me an Assertion failed:
 alarm_has_dynticks(t), file qemu-timer.c, line 139. Since there is no
 change in slirp directory, it should apply to latest git)
 gcc version:$ gcc -v
 Target: mingw32
 Configured with: ../gcc-4.3.3/configure --prefix=/mingw
 --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,obj-c++
 --with-bugurl=http://www.tdragon.net/recentgcc/bugs.php --disable-nls
 --disable-win32-registry --enable-libgomp --disable-werror
 --enable-threads --disable-symvers
 --enable-cxx-flags='-fno-function-sections -fno-data-sections'
 --enable-fully-dynamic-string --enable-version-specific-runtime-libs
 --enable-sjlj-exceptions --with-pkgversion='4.3.3-tdm-1 mingw32'
 Thread model: win32
 gcc version 4.3.3 (4.3.3-tdm-1 mingw32)
 configure commandline: ./configure --target-list=i386-softmmu
 x86_64-softmmu mips64el-softmmu --audio-drv-list=sdl
 --audio-card-list=ac97,sb16,adlib --disable-linux-aio
 --enable-vnc-thread --disable-vnc-jpeg --extra-ldflags=-s
 QEMU Host: Windows XP SP3
 QEMU Guest: Windows XP SP3, Linux 2.6.38 (NIC: ne2k-pci, e1000)
 commandline: qemu-system-i386 -hda xp.vmdk -soundhw sb16 -m 320
 -localtime -usb -usbdevice tablet -net user -net nic,model=ne2k_pci

 Symptoms:
 Guest can lease IP from QEMU Virtual DHCP Server, but the outgoing
 traffic are not working:
 - 10.0.2.3 Virtual DNS Server doesn't respond any DNS query 

Re: [Qemu-devel] qemu/qemu-kvm floppy regression brought by 212ec7baa28cc9d819234fed1541fc1423cfe3d8

2011-10-27 Thread Stefan Hajnoczi
On Wed, Oct 26, 2011 at 03:19:17PM -0200, Lucas Meneghel Rodrigues wrote:
 On 10/26/2011 01:47 PM, Kevin Wolf wrote:
 Am 26.10.2011 16:41, schrieb Lucas Meneghel Rodrigues:
 Hi folks:
 
 We've captured a regression with floppy disk on recent qemu (and
 qemu-kvm, after a code merge). We bisected it to be caused by:
 
 commit 212ec7baa28cc9d819234fed1541fc1423cfe3d8
 Author: Richard Hendersonr...@twiddle.net
 Date:   Mon Aug 15 15:08:45 2011 -0700
 
   fdc: Convert to isa_register_portio_list
 
   Signed-off-by: Richard Hendersonr...@twiddle.net
   Signed-off-by: Avi Kivitya...@redhat.com
 
 Since this commit, the guest doesn't see a floppy disk attached to it
 anymore, blocking kvm autotest ability to install windows guests
 automatically. This is a big deal for kvm autotest (ruins our automated
 regression jobs), so please take a look at it.
 
 Can you please try again with the latest block branch? I think there is
 a patch queued that will fix it.
 
 Kevin, I did try with HEAD of your repo:
 
 git://repo.or.cz/qemu/kevin.git
 
 [lmr@freedom qemu-kwolf]$ git branch -r
   origin/HEAD - origin/master
   origin/blkqueue
   origin/blkqueue-v1
   origin/block
   origin/coroutine
   origin/coroutine-block
   origin/coroutine-devel
   origin/devel
   origin/ehci
   origin/for-anthony
   origin/for-stable-0.14
   origin/inplace-conversion
   origin/master
 
 With this repo, master branch, the problem persists. With the block
 branch, the problem persists.
 
 Now, with the blkqueue branch the problem is resolved. Cleber had
 the same results booting a FreeDOS floppy. So the fix is indeed in
 blkqueue.
 
 Oh, you might want to check the blkqueue branch, it does have quite
 a bunch of set but unused variables, which will cause compilation
 errors unless --disable-werror is passed to the configure script.

I think blkqueue is an older development branch of the block queue
feature that Kevin was working on.  It is not Kevin's block tree (see
his block branch).

Stefan



Re: [Qemu-devel] [PATCH 1/7] block: Remove dead code

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 09:37, schrieb Stefan Hajnoczi:
 On Wed, Oct 26, 2011 at 02:31:16PM +0200, Kevin Wolf wrote:
 @@ -2039,11 +2039,7 @@ const char 
 *bdrv_get_encrypted_filename(BlockDriverState *bs)
  void bdrv_get_backing_filename(BlockDriverState *bs,
 char *filename, int filename_size)
  {
 -if (!bs-backing_file) {
 -pstrcpy(filename, filename_size, );
 -} else {
 -pstrcpy(filename, filename_size, bs-backing_file);
 -}
 +pstrcpy(filename, filename_size, bs-backing_file);
  }
 
 I think this points to another problem:
 
 bs-backing_file[] is never cleared across bdrv_close()/bdrv_open().
 
 If we open an image file that uses a backing file, then close the
 BlockDriverState, and then open a file which does not use a backing file
 we're left with the old backing file!

Ouch! Care to send a fix?

Did you check if there are more fields in BlockDriverState that should
be cleared?

Kevin



Re: [Qemu-devel] libacard build error

2011-10-27 Thread Alon Levy
On Thu, Oct 27, 2011 at 09:56:46AM +0200, Alon Levy wrote:
 On Thu, Oct 27, 2011 at 09:33:50AM +0200, Jan Kiszka wrote:
  Hi Alon,
  
  I'm getting this with current qemu.git:
  
CClibcacard/vcard_emul_nss.o
  cc1: warnings being treated as errors
  In file included from /usr/include/nss3/pkcs11t.h:1780:0,
   from /usr/include/nss3/keythi.h:41,
   from /usr/include/nss3/keyt.h:41,
   from /usr/include/nss3/pk11pub.h:43,
   from /data/qemu/libcacard/vcard_emul_nss.c:21:
  /usr/include/nss3/pkcs11n.h:365:26: error: __GNUC_MINOR is not defined
  
  Just dumping, haven't looked into details. Any patch to fix this already
  queued?
  
 
 No, I haven't noticed this, thanks for letting me know. I don't get it here, 
 I have this command line: (via V=1)
 
 gcc -I/home/alon/src/qemu/slirp -I. -I/home/alon/src/qemu 
 -I/home/alon/src/qemu/fpu -Werror -m64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE 
 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
 -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
 -fno-strict-aliasing -I/home/alon/spice/include  -fstack-protector-all 
 -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs 
 -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers 
 -Wold-style-declaration -Wold-style-definition -Wtype-limits 
 -I/usr/include/libpng12   -I/home/alon/spice/include/spice-server 
 -I/home/alon/spice/include/spice-1 -I/usr/include/pixman-1   
 -I/home/alon/src/qemu/libcacard -I/usr/include/nss3 -I/usr/include/nspr4 
 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -I../ 
 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -MMD -MP -MT 
 vcard_emul_nss.o -MF ./vcard_emul_nss.d -g  -c -o vcard_emul_nss.o 
 vcard_emul_nss.c
 
 $ rpm -qf /usr/include/nss3/pkcs11n.h
 nss-util-devel-3.12.10-1.fc16.x86_64
 
 grep GNU_MINOR /usr/include/nss3/pkcs11n.h
 empty
Doh, should have been GNUC_MINOR. But that is empty too.

 
 What version of nss-util are you using?
 
  Jan
  
 
 
 



Re: [Qemu-devel] [PATCH] Fix compiler warning (always return a value), introduce qemu_abort?

2011-10-27 Thread Alexander Graf

On 26.10.2011, at 18:35, Stefan Weil s...@weilnetz.de wrote:

 Am 26.10.2011 14:54, schrieb Stefan Hajnoczi:
 On Mon, Oct 24, 2011 at 10:18:43PM +0200, Stefan Weil wrote:
 For compilations with -DNDEBUG, the default case did not return
 a value which caused a compiler warning.
 
 Signed-off-by: Stefan Weil s...@weilnetz.de
 ---
 hw/ppce500_spin.c | 11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)
 
 diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c
 index cccd940..5b5ffe0 100644
 --- a/hw/ppce500_spin.c
 +++ b/hw/ppce500_spin.c
 @@ -168,17 +168,22 @@ static uint64_t spin_read(void *opaque, 
 target_phys_addr_t addr, unsigned len)
 {
 SpinState *s = opaque;
 uint8_t *spin_p = ((uint8_t*)s-spin)[addr];
 + uint64_t result = 0;
 
 switch (len) {
 case 1:
 - return ldub_p(spin_p);
 + result = ldub_p(spin_p);
 + break;
 case 2:
 - return lduw_p(spin_p);
 + result = lduw_p(spin_p);
 + break;
 case 4:
 - return ldl_p(spin_p);
 + result = ldl_p(spin_p);
 + break;
 default:
 assert(0);
 
 I would replace assert(3) with abort(3). If this ever happens the
 program is broken - returning 0 instead of an undefined value doesn't
 help.
 
 Stefan
 
 Alex, do you agree on replacing assert() by abort()?

I honestly am pretty indifferent. IIRC I used assert(0) because it does show 
you the line of code it failed in.

Alex

 
 I personally don't like abort() because it does not show the
 reason for the failure.
 
 Most users don't know how to get a core dump or how to
 use gdb. And even for those who know, a crash caused
 by an abort() which cannot be reproduced usually happens
 on a system were ulimit disables core dumps...
 
 I'd like to have a qemu_abort() macro in qemu-common.h which
 replaces all abort() calls used today:
 
 #define qemu_abort() \
  do { \
fprintf(stderr, QEMU aborted in %s, %s:%u\n, __func__, __FILE__, 
 __LINE__);
abort();
  } while (0)
 
 (The macro could also call a function which handles fprintf and abort).
 
 Cheers,
 Stefan W.
 



Re: [Qemu-devel] Correct syntax for named snapshots

2011-10-27 Thread Philipp Hahn
Hello Ottaavio,

On Wednesday 26 October 2011 18:24:01 Ottavio wrote:
 According to the latest doc file you create a named snapshot like this:

 qemu-img snapshot [-l | -a snapshot | -c snapshot | -d snapshot]
 base-image.img

 Is this other following syntax still supported or deprecated:

 qemu-img create -f qcow2 -b base-image.img snapshot.img  ?

These are two different things:
The first one creates an *internal* snapshot, which is stored internally in a 
*single* qcow2 file.
The second one creates an *external* snapshot, which creates a *new second* 
qcow2 file.

The first functionality requires a lot more work for qcow2, which can easily 
corrupt your qcow2 file if something goes wrong. Because of this QED (one 
follow-up format of Qcow) IMHO dropped support for internal snapshots.
The second variante has the drawback, that for each snapshot your get an 
additional file, which your have to manage. Deleting one file from the middle 
of such a chain breaks all following snapshots, so be careful when you do 
delete files.

And yes, both are still supported.

Sincerely
Philipp
-- 
Philipp Hahn   Open Source Software Engineer  h...@univention.de
Univention GmbHLinux for Your Businessfon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen fax: +49 421 22 232-99
   http://www.univention.de/


signature.asc
Description: This is a digitally signed message part.


Re: [Qemu-devel] [PATCH 1/7] block: Remove dead code

2011-10-27 Thread Stefan Hajnoczi
On Wed, Oct 26, 2011 at 02:31:16PM +0200, Kevin Wolf wrote:
 @@ -2039,11 +2039,7 @@ const char 
 *bdrv_get_encrypted_filename(BlockDriverState *bs)
  void bdrv_get_backing_filename(BlockDriverState *bs,
 char *filename, int filename_size)
  {
 -if (!bs-backing_file) {
 -pstrcpy(filename, filename_size, );
 -} else {
 -pstrcpy(filename, filename_size, bs-backing_file);
 -}
 +pstrcpy(filename, filename_size, bs-backing_file);
  }

I think this points to another problem:

bs-backing_file[] is never cleared across bdrv_close()/bdrv_open().

If we open an image file that uses a backing file, then close the
BlockDriverState, and then open a file which does not use a backing file
we're left with the old backing file!

Stefan



Re: [Qemu-devel] [PATCH 1/1] Introduce a new bus ICC to connect APIC

2011-10-27 Thread liu ping fan
Hi,

I want to rework on it according to your comments. Before that, just want to 
make clear that I understand your meanings exactly :)

According to the previous discussion, I will model the system according the 
rule -- if there is APIC in the system (including UP and MP), ICC bus will be 
created, otherwise no.

But there is a special case in UP scene,that is, if we make 8259a connect 
directly to APIC without using IOAPIC, as showed by Figure 3-3 in intel's 
MultiProcessor Specification, I think the rule can also be suitable.

So in board level initialization--pc1_init(), I will check _cpuid_features_  
CPUID_APIC to judge whether to create ICC or not.

Any objection?

Thanks and regards,
ping fan


On Tue, Oct 25, 2011 at 08:24:21PM +, Blue Swirl wrote:
 On Tue, Oct 25, 2011 at 08:55, liu ping fan qemul...@gmail.com wrote:
  On Sun, Oct 23, 2011 at 12:40:08PM +, Blue Swirl wrote:
  On Wed, Oct 19, 2011 at 01:55,  pingf...@linux.vnet.ibm.com wrote:
   From: Liu Ping Fan pingf...@linux.vnet.ibm.com
  
   Introduce a new structure CPUS as the controller of ICC (INTERRUPT
   CONTROLLER COMMUNICATIONS), and new bus ICC to hold APIC,instead
   of sysbus. So we can support APIC hot-plug feature.
 
  Is this ICC bus or APIC hot plugging documented somewhere?
 
   Signed-off-by: liu ping fan pingf...@linux.vnet.ibm.com
   ---
    Makefile.target |    1 +
    hw/apic.c       |   25 +++
    hw/apic.h       |    1 +
    hw/icc_bus.c    |   91 
   +++
    hw/icc_bus.h    |   56 ++
    hw/pc.c         |   11 --
    6 files changed, 174 insertions(+), 11 deletions(-)
    create mode 100644 hw/icc_bus.c
    create mode 100644 hw/icc_bus.h
  
   diff --git a/Makefile.target b/Makefile.target
   index 9011f28..5607c6d 100644
   --- a/Makefile.target
   +++ b/Makefile.target
   @@ -241,6 +241,7 @@ obj-i386-$(CONFIG_KVM) += kvmclock.o
    obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
    obj-i386-y += testdev.o
    obj-i386-y += acpi.o acpi_piix4.o
   +obj-i386-y += icc_bus.o
  
    obj-i386-y += pcspk.o i8254.o
    obj-i386-$(CONFIG_KVM_PIT) += i8254-kvm.o
   diff --git a/hw/apic.c b/hw/apic.c
   index 69d6ac5..00d2297 100644
   --- a/hw/apic.c
   +++ b/hw/apic.c
   @@ -21,9 +21,10 @@
    #include ioapic.h
    #include qemu-timer.h
    #include host-utils.h
   -#include sysbus.h
   +#include icc_bus.h
    #include trace.h
    #include kvm.h
   +#include exec-memory.h
  
    /* APIC Local Vector Table */
    #define APIC_LVT_TIMER   0
   @@ -80,7 +81,7 @@
    typedef struct APICState APICState;
  
    struct APICState {
   -    SysBusDevice busdev;
   +    ICCBusDevice busdev;
       MemoryRegion io_memory;
       void *cpu_env;
       uint32_t apicbase;
   @@ -1104,9 +1105,20 @@ static const MemoryRegionOps apic_io_ops = {
       .endianness = DEVICE_NATIVE_ENDIAN,
    };
  
   -static int apic_init1(SysBusDevice *dev)
   +/**/
   +int apic_mmio_map(DeviceState *dev, target_phys_addr_t base)
    {
   -    APICState *s = FROM_SYSBUS(APICState, dev);
   +    APICState *s = DO_UPCAST(APICState, busdev.qdev, dev);
   +
   +    memory_region_add_subregion(get_system_memory(),
   +                                base,
   +                                s-io_memory);
   +    return 0;
   +}
   +
   +static int apic_init1(ICCBusDevice *dev)
   +{
   +    APICState *s = DO_UPCAST(APICState, busdev, dev);
       static int last_apic_idx;
  
       if (last_apic_idx = MAX_APICS) {
   @@ -1114,7 +1126,6 @@ static int apic_init1(SysBusDevice *dev)
       }
       memory_region_init_io(s-io_memory, apic_io_ops, s, apic,
                             MSI_ADDR_SIZE);
   -    sysbus_init_mmio_region(dev, s-io_memory);
  
       s-timer = qemu_new_timer_ns(vm_clock, apic_timer, s);
       s-idx = last_apic_idx++;
   @@ -1122,7 +1133,7 @@ static int apic_init1(SysBusDevice *dev)
       return 0;
    }
  
   -static SysBusDeviceInfo apic_info = {
   +static ICCBusDeviceInfo apic_info = {
       .init = apic_init1,
       .qdev.name = apic,
       .qdev.size = sizeof(APICState),
   @@ -1138,7 +1149,7 @@ static SysBusDeviceInfo apic_info = {
  
    static void apic_register_devices(void)
    {
   -    sysbus_register_withprop(apic_info);
   +    iccbus_register_devinfo(apic_info);
    }
  
    device_init(apic_register_devices)
   diff --git a/hw/apic.h b/hw/apic.h
   index c857d52..e2c0af5 100644
   --- a/hw/apic.h
   +++ b/hw/apic.h
   @@ -20,6 +20,7 @@ void cpu_set_apic_tpr(DeviceState *s, uint8_t val);
    uint8_t cpu_get_apic_tpr(DeviceState *s);
    void apic_init_reset(DeviceState *s);
    void apic_sipi(DeviceState *s);
   +int apic_mmio_map(DeviceState *dev, target_phys_addr_t base);
  
    /* pc.c */
    int cpu_is_bsp(CPUState *env);
   diff --git a/hw/icc_bus.c b/hw/icc_bus.c
   new file mode 100644
   index 000..61a408e
   --- /dev/null
   +++ b/hw/icc_bus.c
   @@ -0,0 +1,91 @@
   +/* icc_bus.c
   + * 

Re: [Qemu-devel] [PATCH] qemu-io: delete bs instead of leaking it

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 09:42, schrieb Stefan Hajnoczi:
 Using bdrv_close() is not enough to free a BlockDriverState.  Since we
 explicitly create it with bdrv_new(), use bdrv_delete() to close and
 delete it.
 
 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com

At the end of main() there's another bdrv_close() call that should be
changed.

Kevin



[Qemu-devel] [RFC v3 PATCH 0/4] Send gratuitous packets by guest

2011-10-27 Thread Jason Wang
We only track primary mac address in qemu and send rarp packets after
migration to notify the switch to update its mac address table. This
may not works when guest have complicated network configurations such
as tagged vlan or ipv6, those connections may be lost or stalled after
migration.

One method to handle them is snooping the network traffic in qemu and
recording use of mac, but this method would hurt performance and is
impossible for network backend such as vhost.

So the best method to address it is to let guest instead of qemu to
send gratuitous packet. This series first add a model specific
fucntion which can let nic model to implement its own announce
method and then implement a virtio-net specific function to
let guest send the gratitous packet.

Changes from v2:

- Conditionally send the notification interrupt to guest (only for
migration, cont, loadvm).
- Remove the unused patch of function export.
- Typos and other comments from Stefan Hajnoczi.
- Disable guest announce for compat machine types.

---

Jason Wang (4):
  announce self after vm start
  net: model specific announcing support
  virtio-net: notify guest to annouce itself
  virtio-net: compat guest announce support.


 gdbstub.c   |2 +-
 hw/pc_piix.c|   16 
 hw/virtio-net.c |   18 +-
 hw/virtio-net.h |3 +++
 migration.c |4 ++--
 monitor.c   |4 ++--
 net.h   |2 ++
 savevm.c|   10 ++
 sysemu.h|2 +-
 vl.c|7 +--
 10 files changed, 55 insertions(+), 13 deletions(-)

-- 
Jason Wang



[Qemu-devel] [RFC v3 PATCH 1/4] announce self after vm start

2011-10-27 Thread Jason Wang
This patch moves qemu_announce_self() to vm_start() and add a new
parameters to control whether sending gratuitous packet is needed.

This is bacause the following reasons:

- Gratuitous packet is also needed when we resume a stopped vm or
  successfuly load a state.
- The ability of sending gratuitous packet by guest may change the
  state of device, so we need to do it after vm is started.

Signed-off-by: Jason Wang jasow...@redhat.com
---
 gdbstub.c   |2 +-
 migration.c |4 ++--
 monitor.c   |4 ++--
 savevm.c|2 +-
 sysemu.h|2 +-
 vl.c|7 +--
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/gdbstub.c b/gdbstub.c
index 4009058..5f6238e 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -371,7 +371,7 @@ static inline void gdb_continue(GDBState *s)
 #ifdef CONFIG_USER_ONLY
 s-running_state = 1;
 #else
-vm_start();
+vm_start(false);
 #endif
 }
 
diff --git a/migration.c b/migration.c
index bdca72e..8580fa7 100644
--- a/migration.c
+++ b/migration.c
@@ -90,7 +90,7 @@ void process_incoming_migration(QEMUFile *f)
 DPRINTF(successfully loaded vm state\n);
 
 if (autostart) {
-vm_start();
+vm_start(true);
 } else {
 runstate_set(RUN_STATE_PRELAUNCH);
 }
@@ -308,7 +308,7 @@ static void migrate_fd_put_ready(void *opaque)
 }
 if (s-state != MIG_STATE_COMPLETED) {
 if (old_vm_running) {
-vm_start();
+vm_start(false);
 }
 }
 }
diff --git a/monitor.c b/monitor.c
index ffda0fe..633e2de 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1252,7 +1252,7 @@ static int do_cont(Monitor *mon, const QDict *qdict, 
QObject **ret_data)
 bdrv_iterate(encrypted_bdrv_it, context);
 /* only resume the vm if all keys are set and valid */
 if (!context.err) {
-vm_start();
+vm_start(true);
 return 0;
 } else {
 return -1;
@@ -2710,7 +2710,7 @@ static void do_loadvm(Monitor *mon, const QDict *qdict)
 vm_stop(RUN_STATE_RESTORE_VM);
 
 if (load_vmstate(name) == 0  saved_vm_running) {
-vm_start();
+vm_start(true);
 }
 }
 
diff --git a/savevm.c b/savevm.c
index f01838f..73ee6e2 100644
--- a/savevm.c
+++ b/savevm.c
@@ -2077,7 +2077,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
 
  the_end:
 if (saved_vm_running)
-vm_start();
+vm_start(false);
 }
 
 int load_vmstate(const char *name)
diff --git a/sysemu.h b/sysemu.h
index 22cd720..686f1ec 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -34,7 +34,7 @@ void vm_state_notify(int running, RunState state);
 #define VMRESET_SILENT   false
 #define VMRESET_REPORT   true
 
-void vm_start(void);
+void vm_start(bool announce);
 void vm_stop(RunState state);
 void vm_stop_force_state(RunState state);
 
diff --git a/vl.c b/vl.c
index 1ddb17b..e216966 100644
--- a/vl.c
+++ b/vl.c
@@ -1253,7 +1253,7 @@ void vm_state_notify(int running, RunState state)
 }
 }
 
-void vm_start(void)
+void vm_start(bool announce)
 {
 if (!runstate_is_running()) {
 cpu_enable_ticks();
@@ -1261,6 +1261,9 @@ void vm_start(void)
 vm_state_notify(1, RUN_STATE_RUNNING);
 resume_all_vcpus();
 monitor_protocol_event(QEVENT_RESUME, NULL);
+if (announce) {
+qemu_announce_self();
+}
 }
 }
 
@@ -3440,7 +3443,7 @@ int main(int argc, char **argv, char **envp)
 exit(ret);
 }
 } else if (autostart) {
-vm_start();
+vm_start(false);
 }
 
 os_setup_post();




[Qemu-devel] [RFC v3 PATCH 2/4] net: model specific announcing support

2011-10-27 Thread Jason Wang
This patch introduces a function pointer in NetClientInfo which is
called during self announcement to do the model specific announcing.

The first user would be virtio-net.

Signed-off-by: Jason Wang jasow...@redhat.com
---
 net.h|2 ++
 savevm.c |8 +---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/net.h b/net.h
index 9f633f8..7654769 100644
--- a/net.h
+++ b/net.h
@@ -46,6 +46,7 @@ typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t 
*, size_t);
 typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int);
 typedef void (NetCleanup) (VLANClientState *);
 typedef void (LinkStatusChanged)(VLANClientState *);
+typedef int (NetAnnounce)(VLANClientState *);
 
 typedef struct NetClientInfo {
 net_client_type type;
@@ -57,6 +58,7 @@ typedef struct NetClientInfo {
 NetCleanup *cleanup;
 LinkStatusChanged *link_status_changed;
 NetPoll *poll;
+NetAnnounce *announce;
 } NetClientInfo;
 
 struct VLANClientState {
diff --git a/savevm.c b/savevm.c
index 73ee6e2..46389b2 100644
--- a/savevm.c
+++ b/savevm.c
@@ -122,10 +122,12 @@ static void qemu_announce_self_iter(NICState *nic, void 
*opaque)
 {
 uint8_t buf[60];
 int len;
+NetAnnounce *func = nic-nc.info-announce;
 
-len = announce_self_create(buf, nic-conf-macaddr.a);
-
-qemu_send_packet_raw(nic-nc, buf, len);
+if (func == NULL || func(nic-nc) != 0) {
+len = announce_self_create(buf, nic-conf-macaddr.a);
+qemu_send_packet_raw(nic-nc, buf, len);
+}
 }
 
 




[Qemu-devel] [RFC v3 PATCH 3/4] virtio-net: notify guest to annouce itself

2011-10-27 Thread Jason Wang
It's hard to track all mac address and its usage (vlan, bondings,
ipv6) in qemu to send proper gratituous packet. The better choice is
let guest to do it.

The patch introduces a new rw config status bit of virtio-net,
VIRTIO_NET_S_ANNOUNCE which is used to notify guest to announce
presence of its link through config update interrupt. When gust have
done the annoucement, it should clear that bit.

The feature is negotiated by bit VIRTIO_NET_F_ANNOUNCE.

Signed-off-by: Jason Wang jasow...@redhat.com
---
 hw/virtio-net.c |   18 +-
 hw/virtio-net.h |3 +++
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 8c2f460..5451eec 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -95,6 +95,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const 
uint8_t *config)
 memcpy(n-mac, netcfg.mac, ETH_ALEN);
 qemu_format_nic_info_str(n-nic-nc, n-mac);
 }
+
+memcpy(n-status, netcfg.status, sizeof(n-status));
 }
 
 static bool virtio_net_started(VirtIONet *n, uint8_t status)
@@ -227,7 +229,7 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev, 
uint32_t features)
 {
 VirtIONet *n = to_virtio_net(vdev);
 
-features |= (1  VIRTIO_NET_F_MAC);
+features |= (1  VIRTIO_NET_F_MAC | 1  VIRTIO_NET_F_GUEST_ANNOUNCE);
 
 if (peer_has_vnet_hdr(n)) {
 tap_using_vnet_hdr(n-nic-nc.peer, 1);
@@ -983,6 +985,19 @@ static void virtio_net_cleanup(VLANClientState *nc)
 n-nic = NULL;
 }
 
+static int virtio_net_announce(VLANClientState *nc)
+{
+VirtIONet *n = DO_UPCAST(NICState, nc, nc)-opaque;
+
+if (n-vdev.guest_features  (0x1  VIRTIO_NET_F_GUEST_ANNOUNCE)) {
+n-status |= VIRTIO_NET_S_ANNOUNCE;
+virtio_notify_config(n-vdev);
+return 0;
+}
+
+return 1;
+}
+
 static NetClientInfo net_virtio_info = {
 .type = NET_CLIENT_TYPE_NIC,
 .size = sizeof(NICState),
@@ -990,6 +1005,7 @@ static NetClientInfo net_virtio_info = {
 .receive = virtio_net_receive,
 .cleanup = virtio_net_cleanup,
 .link_status_changed = virtio_net_set_link_status,
+.announce = virtio_net_announce,
 };
 
 VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 4468741..9f8cea7 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -44,8 +44,10 @@
 #define VIRTIO_NET_F_CTRL_RX18  /* Control channel RX mode support */
 #define VIRTIO_NET_F_CTRL_VLAN  19  /* Control channel VLAN filtering */
 #define VIRTIO_NET_F_CTRL_RX_EXTRA 20   /* Extra RX mode control support */
+#define VIRTIO_NET_F_GUEST_ANNOUNCE 21  /* Guest can announce itself */
 
 #define VIRTIO_NET_S_LINK_UP1   /* Link is up */
+#define VIRTIO_NET_S_ANNOUNCE   2   /* Announcement is needed */
 
 #define TX_TIMER_INTERVAL 15 /* 150 us */
 
@@ -176,6 +178,7 @@ struct virtio_net_ctrl_mac {
 DEFINE_PROP_BIT(guest_tso6, _state, _field, VIRTIO_NET_F_GUEST_TSO6, 
true), \
 DEFINE_PROP_BIT(guest_ecn, _state, _field, VIRTIO_NET_F_GUEST_ECN, 
true), \
 DEFINE_PROP_BIT(guest_ufo, _state, _field, VIRTIO_NET_F_GUEST_UFO, 
true), \
+DEFINE_PROP_BIT(guest_announce, _state, _field, 
VIRTIO_NET_F_GUEST_ANNOUNCE, true), \
 DEFINE_PROP_BIT(host_tso4, _state, _field, VIRTIO_NET_F_HOST_TSO4, 
true), \
 DEFINE_PROP_BIT(host_tso6, _state, _field, VIRTIO_NET_F_HOST_TSO6, 
true), \
 DEFINE_PROP_BIT(host_ecn, _state, _field, VIRTIO_NET_F_HOST_ECN, 
true), \




Re: [Qemu-devel] [PATCH] Documentation: add new section for device URL syntax for special files and describe the iSCSI URL with examples

2011-10-27 Thread Kevin Wolf
Am 26.10.2011 14:51, schrieb Ronnie Sahlberg:
 Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com
 ---
  qemu-options.hx |   42 ++
  1 files changed, 42 insertions(+), 0 deletions(-)

Thanks, applied to the block branch.

For future patches, please keep the subject lines short and place the
longer text in the body (first line in the git commit message is the
subject, the second one should stay empty, and the body starts at the
third line)

Kevin



[Qemu-devel] [RFC v3 PATCH 4/4] virtio-net: compat guest announce support.

2011-10-27 Thread Jason Wang
Disable guest announce for compat machine types.

Signed-off-by: Jason Wang jasow...@redhat.com
---
 hw/pc_piix.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 8c7f2b7..6ca50a6 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -340,6 +340,10 @@ static QEMUMachine pc_machine_v0_13 = {
 .driver   = virtio-net-pci,
 .property = event_idx,
 .value= off,
+},{
+.driver   = virtio-net-pci,
+.property = guest_announce,
+.value= off,
 },
 { /* end of list */ }
 },
@@ -383,6 +387,10 @@ static QEMUMachine pc_machine_v0_12 = {
 .driver   = virtio-net-pci,
 .property = event_idx,
 .value= off,
+},{
+.driver   = virtio-net-pci,
+.property = guest_announce,
+.value= off,
 },
 { /* end of list */ }
 }
@@ -434,6 +442,10 @@ static QEMUMachine pc_machine_v0_11 = {
 .driver   = virtio-net-pci,
 .property = event_idx,
 .value= off,
+},{
+.driver   = virtio-net-pci,
+.property = guest_announce,
+.value= off,
 },
 { /* end of list */ }
 }
@@ -497,6 +509,10 @@ static QEMUMachine pc_machine_v0_10 = {
 .driver   = virtio-net-pci,
 .property = event_idx,
 .value= off,
+},{
+.driver   = virtio-net-pci,
+.property = guest_announce,
+.value= off,
 },
 { /* end of list */ }
 },




Re: [Qemu-devel] Correct syntax for named snapshots

2011-10-27 Thread Stefan Hajnoczi
On Wed, Oct 26, 2011 at 05:24:01PM +0100, Ottavio wrote:
 According to the latest doc file you create a named snapshot like this:
 
 qemu-img snapshot [-l | -a snapshot | -c snapshot | -d snapshot] 
 base-image.img
 
 Is this other following syntax still supported or deprecated:
 
 qemu-img create -f qcow2 -b base-image.img snapshot.img  ?
 
 The latter is on the qemu wiki but not on the qemu-doc.html file.
 
 Can you cc: me please? Thanks

These two commands do different things.  There are two different
snapshot concepts: internal and external snapshot.

Internal snapshots can be created with qcow2 and can be manipulated with
the qemu-img snapshot command.  They are called internal because all
snapshot data is part of the same image file; you can have a single
qcow2 file that contains 10 different snapshots.

External snapshots can be created with any format that supports backing
files (qcow2, qed, vmdk, ...) and is created with qemu-img create -o
backing_file=base-image.img -f qcow2 vm001.qcow2 (or with the older -b
option).  They are called external snapshots because they involve
multiple files and data is stored separately.  In the command-line I
gave you could access base-image.img in read-only fashion - the base
image is the snapshot and the vm001.qcow2 image file contains data
written since creating the new image file.

The word snapshot is overloaded in QEMU, we use it for several
different things, but I hope this explanation helps.

Stefan



Re: [Qemu-devel] [PATCH] Teach block/vdi about discarded (no longer allocated) blocks

2011-10-27 Thread Kevin Wolf
Am 26.10.2011 21:51, schrieb Eric Sunshine:
 An entry in the VDI block map will hold an offset to the actual block if
 the block is allocated, or one of two specially-interpreted values if
 not allocated. Using VirtualBox terminology, value VDI_IMAGE_BLOCK_FREE
 (0x) represents a never-allocated block (semantically arbitrary
 content).  VDI_IMAGE_BLOCK_ZERO (0xfffe) represents a discarded
 block (semantically zero-filled).  block/vdi knows only about
 VDI_IMAGE_BLOCK_FREE.  Teach it about VDI_IMAGE_BLOCK_ZERO.
 
 Signed-off-by: Eric Sunshine sunsh...@sunshineco.com

Thanks, applied to the block branch.

Kevin



[Qemu-devel] [PATCH] qemu-io: delete bs instead of leaking it

2011-10-27 Thread Stefan Hajnoczi
Using bdrv_close() is not enough to free a BlockDriverState.  Since we
explicitly create it with bdrv_new(), use bdrv_delete() to close and
delete it.

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 qemu-io.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index e91af37..e8ac704 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1581,7 +1581,7 @@ static const cmdinfo_t map_cmd = {
 
 static int close_f(int argc, char **argv)
 {
-bdrv_close(bs);
+bdrv_delete(bs);
 bs = NULL;
 return 0;
 }
@@ -1610,6 +1610,7 @@ static int openfile(char *name, int flags, int growable)
 
 if (bdrv_open(bs, name, flags, NULL)  0) {
 fprintf(stderr, %s: can't open device %s\n, progname, name);
+bdrv_delete(bs);
 bs = NULL;
 return 1;
 }
-- 
1.7.7




Re: [Qemu-devel] [PATCH] qcow2: fix some errors and typo in qcow2.txt

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 08:58, schrieb Zhi Yong Wu:
 Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com
 ---
  docs/specs/qcow2.txt |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

Thanks, applied to the block branch.

Kevin



[Qemu-devel] [PATCH] Only flush queue or call sent callback on successful delivery

2011-10-27 Thread Mark Wu
Now queue flushing and sent callback could be invoked even on delivery
failure. We add a checking of receiver's return value to avoid this
case.

Signed-off-by: Mark Wu wu...@linux.vnet.ibm.com
---
 net/queue.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/queue.c b/net/queue.c
index 1ab5247..c9a027c 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -190,8 +190,9 @@ ssize_t qemu_net_queue_send(NetQueue *queue,
 qemu_net_queue_append(queue, sender, flags, data, size, sent_cb);
 return 0;
 }
-
-qemu_net_queue_flush(queue);
+if (ret  0) {
+qemu_net_queue_flush(queue);
+}
 
 return ret;
 }
@@ -214,8 +215,9 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
 qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, sent_cb);
 return 0;
 }
-
-qemu_net_queue_flush(queue);
+if (ret  0) {
+qemu_net_queue_flush(queue);
+}
 
 return ret;
 }
@@ -251,7 +253,7 @@ void qemu_net_queue_flush(NetQueue *queue)
 break;
 }
 
-if (packet-sent_cb) {
+if (ret  0  packet-sent_cb) {
 packet-sent_cb(packet-sender, ret);
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH v4] block:add-cow file format

2011-10-27 Thread Dong Xu Wang
Provide a new file format: add-cow. The usage can be found in add-cow.txt of
this patch.

Signed-off-by: Dong Xu Wang wdon...@linux.vnet.ibm.com
---
 Makefile.objs  |1 +
 block.c|2 +-
 block.h|1 +
 block/add-cow.c|  405 
 block_int.h|1 +
 docs/specs/add-cow.txt |   45 ++
 6 files changed, 454 insertions(+), 1 deletions(-)
 create mode 100644 block/add-cow.c
 create mode 100644 docs/specs/add-cow.txt

diff --git a/Makefile.objs b/Makefile.objs
index 01587c8..208c12c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -31,6 +31,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
 block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o 
vvfat.o
 block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o 
qcow2-cache.o
+block-nested-y += add-cow.o
 block-nested-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-nested-y += qed-check.o
 block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o
diff --git a/block.c b/block.c
index 70aab63..e343995 100644
--- a/block.c
+++ b/block.c
@@ -105,7 +105,7 @@ int is_windows_drive(const char *filename)
 #endif
 
 /* check if the path starts with protocol: */
-static int path_has_protocol(const char *path)
+int path_has_protocol(const char *path)
 {
 #ifdef _WIN32
 if (is_windows_drive(path) ||
diff --git a/block.h b/block.h
index 5a042c9..dff5197 100644
--- a/block.h
+++ b/block.h
@@ -271,6 +271,7 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, 
QEMUSnapshotInfo *sn);
 
 char *get_human_readable_size(char *buf, int buf_size, int64_t size);
 int path_is_absolute(const char *path);
+int path_has_protocol(const char *path);
 void path_combine(char *dest, int dest_size,
   const char *base_path,
   const char *filename);
diff --git a/block/add-cow.c b/block/add-cow.c
new file mode 100644
index 000..93d5b13
--- /dev/null
+++ b/block/add-cow.c
@@ -0,0 +1,405 @@
+#include qemu-common.h
+#include block_int.h
+#include module.h
+
+#define ADD_COW_MAGIC  (((uint64_t)'A'  56) | ((uint64_t)'D'  48) | \
+((uint64_t)'D'  40) | ((uint64_t)'_'  32) | \
+((uint64_t)'C'  24) | ((uint64_t)'O'  16) | \
+((uint64_t)'W'  8) | 0xFF)
+#define ADD_COW_VERSION 1
+#define ADD_COW_FILE_LEN 1024
+
+typedef struct AddCowHeader {
+uint64_t magic;
+uint32_t version;
+char backing_file[ADD_COW_FILE_LEN];
+char image_file[ADD_COW_FILE_LEN];
+uint64_t size;
+} QEMU_PACKED AddCowHeader;
+
+typedef struct BDRVAddCowState {
+char image_file[ADD_COW_FILE_LEN];
+BlockDriverState *image_hd;
+uint8_t *bitmap;
+uint64_t bitmap_size;
+CoMutex lock;
+} BDRVAddCowState;
+
+static int add_cow_probe(const uint8_t *buf, int buf_size, const char 
*filename)
+{
+const AddCowHeader *header = (const void *)buf;
+
+if (be64_to_cpu(header-magic) == ADD_COW_MAGIC 
+be32_to_cpu(header-version) == ADD_COW_VERSION) {
+return 100;
+} else {
+return 0;
+}
+}
+
+static int add_cow_open(BlockDriverState *bs, int flags)
+{
+AddCowHeader header;
+int64_t size;
+char image_filename[ADD_COW_FILE_LEN];
+int image_flags;
+BlockDriver *image_drv = NULL;
+int ret;
+BDRVAddCowState *state = (BDRVAddCowState *)(bs-opaque);
+
+ret = bdrv_pread(bs-file, 0, header, sizeof(header));
+if (ret != sizeof(header)) {
+goto fail;
+}
+
+if (be64_to_cpu(header.magic) != ADD_COW_MAGIC ||
+be32_to_cpu(header.version) != ADD_COW_VERSION) {
+ret = -1;
+goto fail;
+}
+
+size = be64_to_cpu(header.size);
+bs-total_sectors = size / BDRV_SECTOR_SIZE;
+
+QEMU_BUILD_BUG_ON(sizeof(state-image_file) != sizeof(header.image_file));
+pstrcpy(bs-backing_file, sizeof(bs-backing_file),
+header.backing_file);
+pstrcpy(state-image_file, sizeof(state-image_file),
+header.image_file);
+
+state-bitmap_size = ((bs-total_sectors + 7)  3);
+state-bitmap = g_malloc0(state-bitmap_size);
+
+ret = bdrv_pread(bs-file, sizeof(header), state-bitmap,
+state-bitmap_size);
+if (ret != state-bitmap_size) {
+goto fail;
+}
+   /* If there is a image_file, must be together with backing_file */
+if (state-image_file[0] != '\0') {
+state-image_hd = bdrv_new();
+/* Relative to image or working dir, need discussion */
+if (path_has_protocol(state-image_file)) {
+pstrcpy(image_filename, sizeof(image_filename),
+state-image_file);
+} else {
+path_combine(image_filename, sizeof(image_filename),
+ bs-filename, state-image_file);
+}
+
+image_drv = bdrv_find_format(raw);
+image_flags =
+ (flags  (~(BDRV_O_SNAPSHOT | 

Re: [Qemu-devel] [PATCH v3] add add-cow file format

2011-10-27 Thread Dong Xu Wang
Re-sent it, thanks.

2011/10/27 Stefan Hajnoczi stefa...@linux.vnet.ibm.com:
 On Wed, Oct 26, 2011 at 06:08:03PM +0800, Robert Wang wrote:
 Please find version 4 in the attachment.

 Please send patches inline instead of attaching them.  It makes it
 easier to reply with feedback.

 If you want to add extra comments that should not be included in the git
 commit you can add it below the '---' line in the patch.

 Stefan




-- 
Regards
Robert Wang



Re: [Qemu-devel] [PATCH v3] add add-cow file format

2011-10-27 Thread Robert Wang
I re-sent the patch and use bdrv_co_flush now, thanks.

2011/10/27 shu ming shum...@linux.vnet.ibm.com:
 Looks good to me.  A nit, it seems that bdrv_flush is not supported anymore
 in upstream.
 bdrv_co_flush should be used instead if you update your workspace to latest
 one.
 On 2011-10-26 18:08, Robert Wang wrote:

 Please find version 4 in the attachment.

 2011/10/23 shu mingshum...@linux.vnet.ibm.com:

 On 2011-10-13 0:23, Dong Xu Wang wrote:

 Add add-cow file format

 Signed-off-by: Dong Xu Wangwdon...@linux.vnet.ibm.com
 ---
  Makefile.objs          |    1 +
  block.c                |    2 +-
  block.h                |    1 +
  block/add-cow.c        |  412
 
  block_int.h            |    1 +
  docs/specs/add-cow.txt |   45 ++
  6 files changed, 461 insertions(+), 1 deletions(-)
  create mode 100644 block/add-cow.c
  create mode 100644 docs/specs/add-cow.txt

 diff --git a/Makefile.objs b/Makefile.objs
 index c849e51..624c04c 100644
 --- a/Makefile.objs
 +++ b/Makefile.objs
 @@ -31,6 +31,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o

  block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o
 vpc.o vvfat.o
  block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o
 qcow2-snapshot.o qcow2-cache.o
 +block-nested-y += add-cow.o
  block-nested-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o
 qed-cluster.o
  block-nested-y += qed-check.o
  block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o
 diff --git a/block.c b/block.c
 index e865fab..c25241d 100644
 --- a/block.c
 +++ b/block.c
 @@ -106,7 +106,7 @@ int is_windows_drive(const char *filename)
  #endif

  /* check if the path starts with protocol: */
 -static int path_has_protocol(const char *path)
 +int path_has_protocol(const char *path)
  {
  #ifdef _WIN32
      if (is_windows_drive(path) ||
 diff --git a/block.h b/block.h
 index 16bfa0a..8b09f12 100644
 --- a/block.h
 +++ b/block.h
 @@ -256,6 +256,7 @@ char *bdrv_snapshot_dump(char *buf, int buf_size,
 QEMUSnapshotInfo *sn);

  char *get_human_readable_size(char *buf, int buf_size, int64_t size);
  int path_is_absolute(const char *path);
 +int path_has_protocol(const char *path);
  void path_combine(char *dest, int dest_size,
                    const char *base_path,
                    const char *filename);
 diff --git a/block/add-cow.c b/block/add-cow.c
 new file mode 100644
 index 000..d2538a2
 --- /dev/null
 +++ b/block/add-cow.c
 @@ -0,0 +1,412 @@
 +#include qemu-common.h
 +#include block_int.h
 +#include module.h
 +
 +#define ADD_COW_MAGIC  (((uint64_t)'A'    56) | ((uint64_t)'D'
  48) | \
 +                        ((uint64_t)'D'    40) | ((uint64_t)'_'
  32) | \
 +                        ((uint64_t)'C'    24) | ((uint64_t)'O'
  16) | \
 +                        ((uint64_t)'W'    8) | 0xFF)
 +#define ADD_COW_VERSION 1
 +
 +typedef struct AddCowHeader {
 +    uint64_t magic;
 +    uint32_t version;
 +    char backing_file[1024];
 +    char image_file[1024];

 1024 is a magic number for me.  Can we have a meaningful macro?


 +    uint64_t size;
 +} QEMU_PACKED AddCowHeader;
 +
 +typedef struct BDRVAddCowState {
 +    char image_file[1024];
 +    BlockDriverState *image_hd;
 +    uint8_t *bitmap;
 +    uint64_t bitmap_size;
 +} BDRVAddCowState;
 +
 +static int add_cow_probe(const uint8_t *buf, int buf_size, const char
 *filename)
 +{
 +    const AddCowHeader *header = (const void *)buf;
 +
 +    if (be64_to_cpu(header-magic) == ADD_COW_MAGIC
 +        be32_to_cpu(header-version) == ADD_COW_VERSION) {
 +        return 100;
 +    } else {
 +        return 0;
 +    }
 +}
 +
 +static int add_cow_open(BlockDriverState *bs, int flags)
 +{
 +    AddCowHeader header;
 +    int64_t size;
 +    char image_filename[1024];
 +    int image_flags;
 +    BlockDriver *image_drv = NULL;
 +    int ret;
 +    BDRVAddCowState *state = (BDRVAddCowState *)(bs-opaque);
 +
 +    ret = bdrv_pread(bs-file, 0,header, sizeof(header));
 +    if (ret != sizeof(header)) {
 +        goto fail;
 +    }
 +
 +    if (be64_to_cpu(header.magic) != ADD_COW_MAGIC ||
 +        be32_to_cpu(header.version) != ADD_COW_VERSION) {
 +        ret = -1;
 +        goto fail;
 +    }
 +
 +    size = be64_to_cpu(header.size);
 +    bs-total_sectors = size / BDRV_SECTOR_SIZE;
 +
 +    QEMU_BUILD_BUG_ON(sizeof(state-image_file) !=
 sizeof(header.image_file));
 +    pstrcpy(bs-backing_file, sizeof(bs-backing_file),
 +            header.backing_file);
 +    pstrcpy(state-image_file, sizeof(state-image_file),
 +            header.image_file);
 +
 +    state-bitmap_size = ((bs-total_sectors + 7)    3);
 +    state-bitmap = g_malloc0(state-bitmap_size);
 +
 +    ret = bdrv_pread(bs-file, sizeof(header), state-bitmap,
 +            state-bitmap_size);
 +    if (ret != state-bitmap_size) {
 +        goto fail;
 +    }
 +   /* If there is a image_file, must be together with backing_file */
 +    if (state-image_file[0] != '\0') {
 +        state-image_hd 

[Qemu-devel] [RFC v3 PATCH 5/4 PATCH] virtio-net: send gratuitous packet when needed

2011-10-27 Thread Jason Wang
As hypervior does not have the knowledge of guest network
configuration, it's better to ask guest to send gratuitous packet when
needed.

This make let virtio-net driver can send gratuitous packet.

Guest check VIRTIO_NET_S_ANNOUNCE during config change interrupt. When
this bit is set, a workqueue would be scheduled to send gratuitous
packet through NETDEV_NOTIFY_PEERS.

This feature is negotiated through bit VIRTIO_NET_F_GUEST_ANNOUNCE.

Changes from v2:
- Fix the race between unregister_dev() and workqueue

Signed-off-by: Jason Wang jasow...@redhat.com
---
 drivers/net/virtio_net.c   |   32 ++--
 include/linux/virtio_net.h |2 ++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b8225f3..19ee718 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -71,6 +71,9 @@ struct virtnet_info {
/* Work struct for refilling if we run low on memory. */
struct delayed_work refill;
 
+   /* Work struct for sending gratituous packet. */
+   struct work_struct announce;
+
/* Chain pages by the private ptr. */
struct page *pages;
 
@@ -507,6 +510,13 @@ static void refill_work(struct work_struct *work)
schedule_delayed_work(vi-refill, HZ/2);
 }
 
+static void announce_work(struct work_struct *work)
+{
+   struct virtnet_info *vi = container_of(work, struct virtnet_info,
+  announce);
+   netif_notify_peers(vi-dev);
+}
+
 static int virtnet_poll(struct napi_struct *napi, int budget)
 {
struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi);
@@ -923,11 +933,23 @@ static void virtnet_update_status(struct virtnet_info *vi)
  v, sizeof(v));
 
/* Ignore unknown (future) status bits */
-   v = VIRTIO_NET_S_LINK_UP;
+   v = VIRTIO_NET_S_LINK_UP | VIRTIO_NET_S_ANNOUNCE;
 
if (vi-status == v)
return;
 
+   if (v  VIRTIO_NET_S_ANNOUNCE) {
+   v = ~VIRTIO_NET_S_ANNOUNCE;
+   vi-vdev-config-set(vi-vdev,
+ offsetof(struct virtio_net_config,
+  status),
+ v, sizeof(v));
+
+   if ((v  VIRTIO_NET_S_LINK_UP) 
+   virtio_has_feature(vi-vdev, VIRTIO_NET_F_GUEST_ANNOUNCE))
+   schedule_work(vi-announce);
+   }
+
vi-status = v;
 
if (vi-status  VIRTIO_NET_S_LINK_UP) {
@@ -1016,6 +1038,8 @@ static int virtnet_probe(struct virtio_device *vdev)
goto free;
 
INIT_DELAYED_WORK(vi-refill, refill_work);
+   if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE))
+   INIT_WORK(vi-announce, announce_work);
sg_init_table(vi-rx_sg, ARRAY_SIZE(vi-rx_sg));
sg_init_table(vi-tx_sg, ARRAY_SIZE(vi-tx_sg));
 
@@ -1075,6 +1099,8 @@ static int virtnet_probe(struct virtio_device *vdev)
return 0;
 
 unregister:
+   if (virtio_has_feature(vi-vdev, VIRTIO_NET_F_GUEST_ANNOUNCE))
+   cancel_work_sync(vi-announce);
unregister_netdev(dev);
cancel_delayed_work_sync(vi-refill);
 free_vqs:
@@ -1115,7 +1141,8 @@ static void __devexit virtnet_remove(struct virtio_device 
*vdev)
/* Stop all the virtqueues. */
vdev-config-reset(vdev);
 
-
+   if(virtio_has_feature(vi-vdev, VIRTIO_NET_F_GUEST_ANNOUNCE))
+   cancel_work_sync(vi-announce);
unregister_netdev(vi-dev);
cancel_delayed_work_sync(vi-refill);
 
@@ -1144,6 +1171,7 @@ static unsigned int features[] = {
VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO,
VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
+   VIRTIO_NET_F_GUEST_ANNOUNCE,
 };
 
 static struct virtio_driver virtio_net_driver = {
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 970d5a2..44a38d6 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -49,8 +49,10 @@
 #define VIRTIO_NET_F_CTRL_RX   18  /* Control channel RX mode support */
 #define VIRTIO_NET_F_CTRL_VLAN 19  /* Control channel VLAN filtering */
 #define VIRTIO_NET_F_CTRL_RX_EXTRA 20  /* Extra RX mode control support */
+#define VIRTIO_NET_F_GUEST_ANNOUNCE 21  /* Guest can send gratituous packet */
 
 #define VIRTIO_NET_S_LINK_UP   1   /* Link is up */
+#define VIRTIO_NET_S_ANNOUNCE   2   /* Announcement is needed */
 
 struct virtio_net_config {
/* The config defining mac address (if VIRTIO_NET_F_MAC) */




[Qemu-devel] [PATCH] net: Only flush queue or call sent callback on successful delivery

2011-10-27 Thread Mark Wu
Now queue flushing and sent callback could be invoked even on delivery
failure. We add a checking of receiver's return value to avoid this
case.

Signed-off-by: Mark Wu wu...@linux.vnet.ibm.com
---
 net/queue.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/queue.c b/net/queue.c
index 1ab5247..c9a027c 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -190,8 +190,9 @@ ssize_t qemu_net_queue_send(NetQueue *queue,
 qemu_net_queue_append(queue, sender, flags, data, size, sent_cb);
 return 0;
 }
-
-qemu_net_queue_flush(queue);
+if (ret  0) {
+qemu_net_queue_flush(queue);
+}
 
 return ret;
 }
@@ -214,8 +215,9 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
 qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, sent_cb);
 return 0;
 }
-
-qemu_net_queue_flush(queue);
+if (ret  0) {
+qemu_net_queue_flush(queue);
+}
 
 return ret;
 }
@@ -251,7 +253,7 @@ void qemu_net_queue_flush(NetQueue *queue)
 break;
 }
 
-if (packet-sent_cb) {
+if (ret  0  packet-sent_cb) {
 packet-sent_cb(packet-sender, ret);
 }
 
-- 
1.7.1




[Qemu-devel] [PATCH] block: fix qcow2_co_flush deadlock

2011-10-27 Thread Dong Xu Wang
If qcow2_cache_flush failed, s-lock will not be unlock.

Signed-off-by: Dong Xu Wang wdon...@linux.vnet.ibm.com
---
 block/qcow2.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index a181932..ef057d3 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1113,11 +1113,13 @@ static int qcow2_co_flush(BlockDriverState *bs)
 qemu_co_mutex_lock(s-lock);
 ret = qcow2_cache_flush(bs, s-l2_table_cache);
 if (ret  0) {
+qemu_co_mutex_unlock(s-lock);
 return ret;
 }
 
 ret = qcow2_cache_flush(bs, s-refcount_block_cache);
 if (ret  0) {
+qemu_co_mutex_unlock(s-lock);
 return ret;
 }
 qemu_co_mutex_unlock(s-lock);
-- 
1.7.5.4




[Qemu-devel] [PATCH 0/0] Add description on NBD URL to manpage

2011-10-27 Thread Ronnie Sahlberg
Please find a patch to add a description of the NBD URL to the manpage.
This describes both TCP and domain socket syntax.
(I could not actually test the domain syntax case since my nbd-server 
crashes:-( )

regards
ronnie sahlberg




[Qemu-devel] [PATCH] Documentation: Describe NBD URL syntax

2011-10-27 Thread Ronnie Sahlberg
This patch adds a short description of how to specify a NBD device
to QEMU.
Syntax for both TCP and Unix Domain Sockets are provided as well
as examples.

Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com
---
 qemu-options.hx |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 7c434f8..564ae3f 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1757,6 +1757,27 @@ qemu --drive 
file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
 iSCSI support is an optional feature of QEMU and only available when
 compiled and linked against libiscsi.
 
+@item NBD
+QEMU supports NBD (Network Block Devices) both using TCP protocol as well
+as Unix Domain Sockets.
+
+Syntax for specifying a NDB device using TCP
+``nbd:server-ip:port[:exportname=export]''
+
+Syntax for specifying a NDB device using Unix Domain Sockets
+``nbd:unix:domain-socket[:exportname=export]''
+
+
+Example for TCP
+@example
+qemu --drive file=nbd:192.0.2.1:3
+@end example
+
+Example for Unix Domain Sockets
+@example
+qemu --drive file=nbd:unix:/tmp/nbd-socket
+@end example
+
 @end table
 ETEXI
 
-- 
1.7.3.1




Re: [Qemu-devel] [PATCH] Documentation: add new section for device URL syntax for special files and describe the iSCSI URL with examples

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 09:14, schrieb Stefan Hajnoczi:
 On Wed, Oct 26, 2011 at 11:51:37PM +1100, Ronnie Sahlberg wrote:

 Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com
 ---
  qemu-options.hx |   42 ++
  1 files changed, 42 insertions(+), 0 deletions(-)
 
 Good idea, thanks for adding documentation.
 
 Reviewed-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com

Breaks the build. I'll amend the commit with the following changes:

diff --git a/qemu-options.hx b/qemu-options.hx
index 7c434f8..f967fb9 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1719,6 +1719,7 @@ Connect to a spice virtual machine channel, such
as vdiport.
 @end table
 ETEXI

+STEXI
 DEFHEADING()

 DEFHEADING(Device URL Syntax:)
@@ -1727,7 +1728,6 @@ In addition to using normal file images for the
emulated storage devices,
 QEMU can also use networked resources such as iSCSI devices. These are
 specified using a special URL syntax.

-STEXI
 @table @option
 @item iSCSI
 iSCSI support allows QEMU to access iSCSI resources directly and use as
@@ -1744,7 +1744,7 @@ qemu -cdrom
iscsi://192.0.2.1/iqn.2001-04.com.example/2 \

 Example (CHAP username/password via URL):
 @example
-qemu --drive file=iscsi://user%password@192.0.2.1/iqn.2001-04.com.example/1
+qemu --drive
file=iscsi://user%password@@192.0.2.1/iqn.2001-04.com.example/1
 @end example

 Example (CHAP username/password via environment variables):



Re: [Qemu-devel] balloon driver on winxp guest start failed

2011-10-27 Thread hkran

On 10/17/2011 08:55 PM, Vadim Rozenfeld wrote:

On Fri, 2011-10-14 at 17:49 +0800, hkran wrote:

On 10/14/2011 04:55 AM, Vadim Rozenfeld wrote:

On Thu, 2011-10-13 at 15:47 +0100, Stefan Hajnoczi wrote:

On Thu, Oct 13, 2011 at 5:00 AM, hkranhk...@vnet.linux.ibm.com   wrote:

On 10/12/2011 07:09 PM, hkran wrote:

I used balloon driver for windows  virtio-win-0.1-15.iso (from
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/)

following the install guard , I installed the balloon driver like this:

devcon.exe install d:\wxp\x86\balloon.inf
PCI\VEN_1AF4DEV_1002SUBSYS_00051AF4REV_00
   then reboot guest Os, but the status of driver installed is always
incorrect, that show me the driver start failed (code 10) in the device
manager.

Seems like a resource allocation problem

I typed the following cmds in the monitor command line:

(qemu) device_add virtio-balloon
(qemu) info balloon
balloon: actual=2048
(qemu) balloon 1024
(qemu) info balloon
balloon: actual=2048
(qemu) info balloon
balloon: actual=2048

And I also tried it by using qemu -balloon virtio param  when getting
qemu up, the status is worse, the winxp guest froze at boot screen.

Am I using balloon driver in a correct way?




For the boot failure case, I take more looks into it.  I open the trace
output and see the following when boot failed
Balloon driver, built on Oct 13 2011 10:46:59
^M-- DriverEntry
^Mfile z:\source\kvm-guest-drivers-windows\balloon\sys\driver.c line 151
^M--   BalloonDeviceAdd
^M-- BalloonDeviceAdd
^M--   BalloonEvtDevicePrepareHardware
^M-   Port   Resource [C0A0-C0C0]
^M-- BalloonEvtDevicePrepareHardware
^M--   BalloonEvtDeviceD0Entry
^M--   BalloonInit
^M--   VIRTIO_BALLOON_F_STATS_VQ
^M-- BalloonInit
^M--   BalloonInterruptEnable
^M-- BalloonInterruptEnable

here, the system is blocked.

I compare it with the logfile in the normal case that I hot-plugin the
balloon device, and then find the system blocked before calling at
BalloonInterruptDpc.


What about ISR? Can you try changing balloon size and check if balloon
ISR was invoked or not?

Is it meaning that we open the interrupt of balloon device too soon when
booting the system?

I suggest CCing Vadim on virtio Windows driver questions.  Not sure if
he sees every qemu-devel email.

Stefan



To make the issue clearer, I do more tests about that. Now I use the
package virtio-win-prewhql-0.1-15-sources.zip from
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/src/
The problem that the balloon driver status is incorrect was not
reproduced any longer, but boot failure still be there.
more tests told me as if the failure will occur only in the case where
virtio-serial and balloon are all attached when qemu booting:

(qemu) [huikai@oc0100708617 ~]$
/home/huikai/qemu15/bin/qemu-system-x86_64 --enable-kvm -m 2048   -drive
file=/home/huikai/xp_shanghai.img,if=virtio -net user  -net
nic,model=viga qxl -localtime -chardev stdio,id=muxstdio -mon
chardev=muxstdio -usb -usbdevice tablet -device virtio-serial,id=vs0
-chardev socket,path=/tmp/foo,server,nowait,id=foo -device
virtserialport,bus=vs0.0,chardev=foo,name=helloworld -serial
file:/tmp/xp_1014_6.log -balloon virtio,id=ball1

the trace:

Virtio-Serial driver started...built on Oct 14 2011 15:58:02
^M--  VIOSerialEvtDeviceAdd
^M--  VIOSerialInitInterruptHandling
^MBalloon driver, built on Oct 13 2011 17:34:56
^M-- DriverEntry
^M--  BalloonDeviceAdd
^M-- BalloonDeviceAdd
^M--  BalloonEvtDevicePrepareHardware
^M-  Port   Resource [C0A0-C0C0]
^M-- BalloonEvtDevicePrepareHardware
^M--  BalloonEvtDeviceD0Entry
^M--  BalloonInit
^M--  VIRTIO_BALLOON_F_STATS_VQ
^M-- BalloonInit
^M--  BalloonInterruptEnable
^M-- BalloonInterruptEnable
^M--  VIOSerialEvtDevicePrepareHardware
^MIO Port Info  [C080-C0A0]
^MWe have multiport host
^MVirtIOConsoleConfig-max_nr_ports 31
^M--  VIOSerialEvtDeviceD0Entry
^M--  VIOSerialInitAllQueues
^M--  VIOSerialFillQueue
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89B13A50
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89B13638
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89C07E08
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89C07C50
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89C07A98
... ...
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89BD14B8
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89B826E8
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89BE4450
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89BE2398
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89C53468
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89C37E18
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89C374C0
^M--  VIOSerialFreeBuffer  buf = 89C374C0, buf-va_buf = 89983000
^MVIOSerialRenewAllPorts
^M--  VIOSerialFillQueue
^M--  VIOSerialAllocateBuffer
^M--  VIOSerialAddInBuf  buf = 89C374C0
^M--  

[Qemu-devel] [PATCH 1/3] qemu-io: delete bs instead of leaking it

2011-10-27 Thread Stefan Hajnoczi
Using bdrv_close() is not enough to free a BlockDriverState.  Since we
explicitly create it with bdrv_new(), use bdrv_delete() to close and
delete it.

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 qemu-io.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index c45a413..5af887e 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1582,7 +1582,7 @@ static const cmdinfo_t map_cmd = {
 
 static int close_f(int argc, char **argv)
 {
-bdrv_close(bs);
+bdrv_delete(bs);
 bs = NULL;
 return 0;
 }
@@ -1611,6 +1611,7 @@ static int openfile(char *name, int flags, int growable)
 
 if (bdrv_open(bs, name, flags, NULL)  0) {
 fprintf(stderr, %s: can't open device %s\n, progname, name);
+bdrv_delete(bs);
 bs = NULL;
 return 1;
 }
@@ -1834,7 +1835,7 @@ int main(int argc, char **argv)
 qemu_aio_flush();
 
 if (bs) {
-bdrv_close(bs);
+bdrv_delete(bs);
 }
 return 0;
 }
-- 
1.7.7




[Qemu-devel] [PATCH 2/3] block: set bs-read_only before .bdrv_open()

2011-10-27 Thread Stefan Hajnoczi
Several block drivers set bs-read_only in .bdrv_open() but
block.c:bdrv_open_common() clobbers its value.  Additionally, QED uses
bdrv_is_read_only() in .bdrv_open() to decide whether to perform
consistency checks.

The correct ordering is to initialize bs-read_only from the open flags
before calling .bdrv_open().  This way block drivers can override it if
necessary and can use bdrv_is_read_only() in .bdrv_open().

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 block.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index 70aab63..3207e99 100644
--- a/block.c
+++ b/block.c
@@ -500,6 +500,8 @@ static int bdrv_open_common(BlockDriverState *bs, const 
char *filename,
 open_flags |= BDRV_O_RDWR;
 }
 
+bs-keep_read_only = bs-read_only = !(open_flags  BDRV_O_RDWR);
+
 /* Open the image, either directly or using a protocol */
 if (drv-bdrv_file_open) {
 ret = drv-bdrv_file_open(bs, filename, open_flags);
@@ -514,8 +516,6 @@ static int bdrv_open_common(BlockDriverState *bs, const 
char *filename,
 goto free_and_fail;
 }
 
-bs-keep_read_only = bs-read_only = !(open_flags  BDRV_O_RDWR);
-
 ret = refresh_total_sectors(bs, bs-total_sectors);
 if (ret  0) {
 goto free_and_fail;
-- 
1.7.7




[Qemu-devel] [PATCH 3/3] block: reinitialize across bdrv_close()/bdrv_open()

2011-10-27 Thread Stefan Hajnoczi
Several BlockDriverState fields are not being reinitialized across
bdrv_close()/bdrv_open().  Make sure they are reset to their default
values.

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 block.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index 3207e99..b5e2aff 100644
--- a/block.c
+++ b/block.c
@@ -472,10 +472,13 @@ static int bdrv_open_common(BlockDriverState *bs, const 
char *filename,
 bs-total_sectors = 0;
 bs-encrypted = 0;
 bs-valid_key = 0;
+bs-sg = 0;
 bs-open_flags = flags;
+bs-growable = 0;
 bs-buffer_alignment = 512;
 
 pstrcpy(bs-filename, sizeof(bs-filename), filename);
+bs-backing_file[0] = '\0';
 
 if (use_bdrv_whitelist  !bdrv_is_whitelisted(drv)) {
 return -ENOTSUP;
@@ -484,8 +487,7 @@ static int bdrv_open_common(BlockDriverState *bs, const 
char *filename,
 bs-drv = drv;
 bs-opaque = g_malloc0(drv-instance_size);
 
-if (flags  BDRV_O_CACHE_WB)
-bs-enable_write_cache = 1;
+bs-enable_write_cache = !!(flags  BDRV_O_CACHE_WB);
 
 /*
  * Clear flags that are internal to the block layer before opening the
-- 
1.7.7




Re: [Qemu-devel] [PATCH] Documentation: Describe NBD URL syntax

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 11:33, schrieb Ronnie Sahlberg:
 This patch adds a short description of how to specify a NBD device
 to QEMU.
 Syntax for both TCP and Unix Domain Sockets are provided as well
 as examples.
 
 Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com

Thanks, applied to the block branch.

Kevin



Re: [Qemu-devel] [PATCH] block: fix qcow2_co_flush deadlock

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 11:22, schrieb Dong Xu Wang:
 If qcow2_cache_flush failed, s-lock will not be unlock.
 
 Signed-off-by: Dong Xu Wang wdon...@linux.vnet.ibm.com

Thanks, applied to the block branch.

Kevin



Re: [Qemu-devel] [PATCH v2] fw_cfg: Use g_file_get_contents instead of multiple fread() calls

2011-10-27 Thread Pavel Borzenkov
Ping?

On Mon, Oct 24, 2011 at 3:31 PM, Pavel Borzenkov
pavel.borzen...@gmail.com wrote:
 Signed-off-by: Pavel Borzenkov pavel.borzen...@gmail.com
 ---
  hw/fw_cfg.c |  102 
 ++-
  1 files changed, 38 insertions(+), 64 deletions(-)

 diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
 index 8df265c..dbcb888 100644
 --- a/hw/fw_cfg.c
 +++ b/hw/fw_cfg.c
 @@ -60,71 +60,55 @@ struct FWCfgState {
  #define JPG_FILE 0
  #define BMP_FILE 1

 -static FILE *probe_splashfile(char *filename, int *file_sizep, int 
 *file_typep)
 +static char *read_splashfile(char *filename, int *file_sizep, int 
 *file_typep)
  {
 -    FILE *fp = NULL;
 -    int fop_ret;
 -    int file_size;
 +    GError *err = NULL;
 +    gboolean res;
 +    gchar *content;
     int file_type = -1;
 -    unsigned char buf[2] = {0, 0};
 -    unsigned int filehead_value = 0;
 +    unsigned int filehead = 0;
     int bmp_bpp;

 -    fp = fopen(filename, rb);
 -    if (fp == NULL) {
 -        error_report(failed to open file '%s'., filename);
 -        return fp;
 +    res = g_file_get_contents(filename, content, (gsize *)file_sizep, err);
 +    if (res == FALSE) {
 +        error_report(failed to read splash file '%s', filename);
 +        g_error_free(err);
 +        return NULL;
     }
 +
     /* check file size */
 -    fseek(fp, 0L, SEEK_END);
 -    file_size = ftell(fp);
 -    if (file_size  2) {
 -        error_report(file size is less than 2 bytes '%s'., filename);
 -        fclose(fp);
 -        fp = NULL;
 -        return fp;
 +    if (*file_sizep  30) {
 +        goto error;
     }
 +
     /* check magic ID */
 -    fseek(fp, 0L, SEEK_SET);
 -    fop_ret = fread(buf, 1, 2, fp);
 -    if (fop_ret != 2) {
 -        error_report(Could not read header from '%s': %s,
 -                     filename, strerror(errno));
 -        fclose(fp);
 -        fp = NULL;
 -        return fp;
 -    }
 -    filehead_value = (buf[0] + (buf[1]  8))  0x;
 -    if (filehead_value == 0xd8ff) {
 +    filehead = ((content[0]  0xff) + (content[1]  8))  0x;
 +    if (filehead == 0xd8ff) {
         file_type = JPG_FILE;
 +    } else if (filehead == 0x4d42) {
 +        file_type = BMP_FILE;
     } else {
 -        if (filehead_value == 0x4d42) {
 -            file_type = BMP_FILE;
 -        }
 -    }
 -    if (file_type  0) {
 -        error_report('%s' not jpg/bmp file,head:0x%x.,
 -                         filename, filehead_value);
 -        fclose(fp);
 -        fp = NULL;
 -        return fp;
 +        goto error;
     }
 +
     /* check BMP bpp */
     if (file_type == BMP_FILE) {
 -        fseek(fp, 28, SEEK_SET);
 -        fop_ret = fread(buf, 1, 2, fp);
 -        bmp_bpp = (buf[0] + (buf[1]  8))  0x;
 +        bmp_bpp = (content[28] + (content[29]  8))  0x;
         if (bmp_bpp != 24) {
 -            error_report(only 24bpp bmp file is supported.);
 -            fclose(fp);
 -            fp = NULL;
 -            return fp;
 +            goto error;
         }
     }
 +
     /* return values */
 -    *file_sizep = file_size;
     *file_typep = file_type;
 -    return fp;
 +
 +    return content;
 +
 +error:
 +    error_report(splash file '%s' format not recognized; must be JPEG 
 +                 or 24 bit BMP, filename);
 +    g_free(content);
 +    return NULL;
  }

  static void fw_cfg_bootsplash(FWCfgState *s)
 @@ -132,9 +116,7 @@ static void fw_cfg_bootsplash(FWCfgState *s)
     int boot_splash_time = -1;
     const char *boot_splash_filename = NULL;
     char *p;
 -    char *filename;
 -    FILE *fp;
 -    int fop_ret;
 +    char *filename, *file_data;
     int file_size;
     int file_type = -1;
     const char *temp;
 @@ -174,27 +156,19 @@ static void fw_cfg_bootsplash(FWCfgState *s)
             error_report(failed to find file '%s'., boot_splash_filename);
             return;
         }
 -        /* probing the file */
 -        fp = probe_splashfile(filename, file_size, file_type);
 -        if (fp == NULL) {
 +
 +        /* loading file data */
 +        file_data = read_splashfile(filename, file_size, file_type);
 +        if (file_data == NULL) {
             g_free(filename);
             return;
         }
 -        /* loading file data */
         if (boot_splash_filedata != NULL) {
             g_free(boot_splash_filedata);
         }
 -        boot_splash_filedata = g_malloc(file_size);
 +        boot_splash_filedata = (uint8_t *)file_data;
         boot_splash_filedata_size = file_size;
 -        fseek(fp, 0L, SEEK_SET);
 -        fop_ret = fread(boot_splash_filedata, 1, file_size, fp);
 -        if (fop_ret != file_size) {
 -            error_report(failed to read data from '%s'.,
 -                         boot_splash_filename);
 -            fclose(fp);
 -            return;
 -        }
 -        fclose(fp);
 +
         /* insert data */
         if (file_type == JPG_FILE) {
             fw_cfg_add_file(s, bootsplash.jpg,
 --
 1.7.0.4






Re: [Qemu-devel] [PATCH 2/3] block: set bs-read_only before .bdrv_open()

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 11:54, schrieb Stefan Hajnoczi:
 Several block drivers set bs-read_only in .bdrv_open() but
 block.c:bdrv_open_common() clobbers its value.  Additionally, QED uses
 bdrv_is_read_only() in .bdrv_open() to decide whether to perform
 consistency checks.
 
 The correct ordering is to initialize bs-read_only from the open flags
 before calling .bdrv_open().  This way block drivers can override it if
 necessary and can use bdrv_is_read_only() in .bdrv_open().
 
 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 ---
  block.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/block.c b/block.c
 index 70aab63..3207e99 100644
 --- a/block.c
 +++ b/block.c
 @@ -500,6 +500,8 @@ static int bdrv_open_common(BlockDriverState *bs, const 
 char *filename,
  open_flags |= BDRV_O_RDWR;
  }

Not directly related, but the context made me wonder when we're making a
BlockkDriverState writeable unconditionally. This is the full context:


/*
 * Snapshots should be writable.
 */
if (bs-is_temporary) {
open_flags |= BDRV_O_RDWR;
}

Does anyone understand what the point of this is? If the user requested
read-only, he certainly wants to have read-only, even if he specified
-snapshot as well.

 +bs-keep_read_only = bs-read_only = !(open_flags  BDRV_O_RDWR);
 +
  /* Open the image, either directly or using a protocol */
  if (drv-bdrv_file_open) {
  ret = drv-bdrv_file_open(bs, filename, open_flags);
 @@ -514,8 +516,6 @@ static int bdrv_open_common(BlockDriverState *bs, const 
 char *filename,
  goto free_and_fail;
  }
  
 -bs-keep_read_only = bs-read_only = !(open_flags  BDRV_O_RDWR);
 -

The assignment was already at the new place before 4dca4b6. Not sure if
there was any real reason for moving it, though.

Kevin



Re: [Qemu-devel] New Memory API Question

2011-10-27 Thread Avi Kivity
On 10/26/2011 03:52 PM, John Baboval wrote:
 Sorry for coming late to the party on this... I only read qemu-devel
 through a filter so I missed all the discussions on the new memory
 API. I have a question as to how it works and how it's supposed to
 work in certain scenarios.

 It's a question of flow. I'm following the code path through the
 creation of a new memory subregion. If I'm reading this properly, it
 would seem that a MemoryRegion - for example the ones used by VGA - go
 through the following flow:

 memory_region_init_ram()   - (mr-destructor is set to
 memory_region_destructor_ram)
 memory_region_add_subregion(system_memory, ...) -
memory_region_update_topology() -
   address_space_update_topology()
  address_space_update_topology_part()
 as_memory_range_add()   - through the ops vector
memory_region_prepare_ram_addr()


 At this point it seems that the destructor is overwritten with the
 memory_region_destructor_iomem(), and it loses track of the proper way
 to ever free the memory region. Is this correct, or am I missing
 something?

It's correct; this is a bug.


 Or does it not matter because nobody ever calls memory_region_destroy
 for system memory regions?

It can still happen via hotunplug of an ivshmem device, or memory
hotunplug (when it is eventually implemented).

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.




Re: [Qemu-devel] [PATCH 2/3] block: set bs-read_only before .bdrv_open()

2011-10-27 Thread Stefan Hajnoczi
On Thu, Oct 27, 2011 at 11:18 AM, Kevin Wolf kw...@redhat.com wrote:
 Am 27.10.2011 11:54, schrieb Stefan Hajnoczi:
 Several block drivers set bs-read_only in .bdrv_open() but
 block.c:bdrv_open_common() clobbers its value.  Additionally, QED uses
 bdrv_is_read_only() in .bdrv_open() to decide whether to perform
 consistency checks.

 The correct ordering is to initialize bs-read_only from the open flags
 before calling .bdrv_open().  This way block drivers can override it if
 necessary and can use bdrv_is_read_only() in .bdrv_open().

 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 ---
  block.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

 diff --git a/block.c b/block.c
 index 70aab63..3207e99 100644
 --- a/block.c
 +++ b/block.c
 @@ -500,6 +500,8 @@ static int bdrv_open_common(BlockDriverState *bs, const 
 char *filename,
          open_flags |= BDRV_O_RDWR;
      }
 +    bs-keep_read_only = bs-read_only = !(open_flags  BDRV_O_RDWR);
 +
      /* Open the image, either directly or using a protocol */
      if (drv-bdrv_file_open) {
          ret = drv-bdrv_file_open(bs, filename, open_flags);
 @@ -514,8 +516,6 @@ static int bdrv_open_common(BlockDriverState *bs, const 
 char *filename,
          goto free_and_fail;
      }

 -    bs-keep_read_only = bs-read_only = !(open_flags  BDRV_O_RDWR);
 -

 The assignment was already at the new place before 4dca4b6. Not sure if
 there was any real reason for moving it, though.

Naphtali: any ideas why your commit needed to move bs-read_only assignment?

Stefan



Re: [Qemu-devel] [PATCH 2/3] block: set bs-read_only before .bdrv_open()

2011-10-27 Thread Stefan Hajnoczi
On Thu, Oct 27, 2011 at 11:18 AM, Kevin Wolf kw...@redhat.com wrote:
 Am 27.10.2011 11:54, schrieb Stefan Hajnoczi:
 Several block drivers set bs-read_only in .bdrv_open() but
 block.c:bdrv_open_common() clobbers its value.  Additionally, QED uses
 bdrv_is_read_only() in .bdrv_open() to decide whether to perform
 consistency checks.

 The correct ordering is to initialize bs-read_only from the open flags
 before calling .bdrv_open().  This way block drivers can override it if
 necessary and can use bdrv_is_read_only() in .bdrv_open().

 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 ---
  block.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

 diff --git a/block.c b/block.c
 index 70aab63..3207e99 100644
 --- a/block.c
 +++ b/block.c
 @@ -500,6 +500,8 @@ static int bdrv_open_common(BlockDriverState *bs, const 
 char *filename,
          open_flags |= BDRV_O_RDWR;
      }

 Not directly related, but the context made me wonder when we're making a
 BlockkDriverState writeable unconditionally. This is the full context:


    /*
     * Snapshots should be writable.
     */
    if (bs-is_temporary) {
        open_flags |= BDRV_O_RDWR;
    }

 Does anyone understand what the point of this is? If the user requested
 read-only, he certainly wants to have read-only, even if he specified
 -snapshot as well.

Perhaps this is an attempt to support -drive
file=pristine.img,readonly=on,snapshot=on.  The idea being that the
user absolutely wants to keep pristine.img unmodified.  But the nature
of backing files means we should automatically get this.

Stefan



[Qemu-devel] virtio-scsi wiki feature page

2011-10-27 Thread Stefan Hajnoczi
Hi,
I have created a virtio-scsi wiki feature page with links to Paolo's
latest draft specification, our KVM Forum presentation, and code
repos:

http://wiki.qemu.org/Features/VirtioSCSI

Paolo: v3 had some comments, is it a good time for a new revision of
the draft specification?

Stefan



Re: [Qemu-devel] [PATCH 2/3] block: set bs-read_only before .bdrv_open()

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 12:45, schrieb Stefan Hajnoczi:
 On Thu, Oct 27, 2011 at 11:18 AM, Kevin Wolf kw...@redhat.com wrote:
 Am 27.10.2011 11:54, schrieb Stefan Hajnoczi:
 Several block drivers set bs-read_only in .bdrv_open() but
 block.c:bdrv_open_common() clobbers its value.  Additionally, QED uses
 bdrv_is_read_only() in .bdrv_open() to decide whether to perform
 consistency checks.

 The correct ordering is to initialize bs-read_only from the open flags
 before calling .bdrv_open().  This way block drivers can override it if
 necessary and can use bdrv_is_read_only() in .bdrv_open().

 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 ---
  block.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

 diff --git a/block.c b/block.c
 index 70aab63..3207e99 100644
 --- a/block.c
 +++ b/block.c
 @@ -500,6 +500,8 @@ static int bdrv_open_common(BlockDriverState *bs, const 
 char *filename,
  open_flags |= BDRV_O_RDWR;
  }

 Not directly related, but the context made me wonder when we're making a
 BlockkDriverState writeable unconditionally. This is the full context:


/*
 * Snapshots should be writable.
 */
if (bs-is_temporary) {
open_flags |= BDRV_O_RDWR;
}

 Does anyone understand what the point of this is? If the user requested
 read-only, he certainly wants to have read-only, even if he specified
 -snapshot as well.
 
 Perhaps this is an attempt to support -drive
 file=pristine.img,readonly=on,snapshot=on.  The idea being that the
 user absolutely wants to keep pristine.img unmodified.  But the nature
 of backing files means we should automatically get this.

I would have said that it breaks this command line. It all depends on
what your expectation of the semantics of these options is. Mine would
be that the disk is presented read-only to the guest (and the snapshot
is done but useless).

Kevin



Re: [Qemu-devel] virtio-scsi wiki feature page

2011-10-27 Thread Paolo Bonzini

On 10/27/2011 12:49 PM, Stefan Hajnoczi wrote:

I have created a virtio-scsi wiki feature page with links to Paolo's
latest draft specification, our KVM Forum presentation, and code
repos:

http://wiki.qemu.org/Features/VirtioSCSI

Paolo: v3 had some comments, is it a good time for a new revision of
the draft specification?


Yes.  I was waiting until I actually have an implementation, but anyway 
here it is, attached.  The changes are small:


- additional failure kinds mapping more or less to Linux driver_statuses

- defined the format of the LUN.  Unlike vSCSI, there's no support for 
generic hierarchical LUNs.  A single LUN format is specified, that 
supports 256 targets and 16384 LUNs per target.


- clarified multiqueue semantics

I'm planning to update your LLD code to support these changes, but I'll 
gladly accept that someone else does it. :)


Paolo
Virtio SCSI Host Device Spec


The virtio SCSI host device groups together one or more simple virtual
devices (ie. disk), and allows communicating to these devices using the
SCSI protocol.  An instance of the device represents a SCSI host with
possibly many buses (also known as channels or paths), targets and
LUNs attached.

The virtio SCSI device services two kinds of requests:

- command requests for a logical unit;

- task management functions related to a logical unit, target or
command.

The device is also able to send out notifications about added and removed
logical units.  Together, these capabilities provide a SCSI transport
protocol that uses virtqueues as the transfer medium.  In the transport
protocol, the virtio driver acts as the initiator, while the virtio SCSI
host provides one or more targets that receive and process the requests.

v1:
First public version

v2:
Merged all virtqueues into one, removed separate TARGET fields

v3:
Added configuration information and reworked descriptor structure.
Added back multiqueue on Avi's request, while still leaving TARGET
fields out.  Added dummy event and clarified some aspects of the
event protocol.  First version sent to a wider audience (linux-kernel
and virtio lists).

v4:
Clarified multiqueue semantics.  Specified format of LUN field.
Added more failure codes roughly corresponding to Linux driver_status
values.

Configuration
-

Subsystem Device ID
TBD

Virtqueues
0:controlq
1:eventq
2..n:request queues

Feature bits
VIRTIO_SCSI_F_INOUT (0) - Whether a single request can include both
read-only and write-only data buffers.

Device configuration layout
struct virtio_scsi_config {
u32 num_queues;
u32 event_info_size;
u32 sense_size;
u32 cdb_size;
}

num_queues is the total number of virtqueues exposed by the
device.  The driver is free to use only one request queue, or
it can use more to achieve better performance.

event_info_size is the maximum size that the device will fill
for buffers that the driver places in the eventq.  The
driver should always put buffers at least of this size.

sense_size is the maximum size of the sense data that the device
will write.  The default value is written by the device and
will always be 96, but the driver can modify it.

cdb_size is the maximum size of the CDB that the driver
will write.  The default value is written by the device and
will always be 32, but the driver can likewise modify it.

Device initialization
-

The initialization routine should first of all discover the device's
virtqueues.

The driver should then place at least a buffer in the eventq.
Buffers returned by the device on the eventq may be referred
to as events in the rest of the document.

The driver can immediately issue requests (for example, INQUIRY or
REPORT LUNS) or task management functions (for example, I_T RESET).

Device operation: request queues


The driver queues requests to an arbitrary request queue, and they are
used by the device on that same queue.  In this version of the spec,
commands placed on different queue will be consumed with _no_ order
constraints.

Requests have the following format:

struct virtio_scsi_req_cmd {
u8 lun[8];
u64 id;
u8 task_attr;
u8 prio;
u8 crn;
char cdb[cdb_size];
char dataout[];

u8 sense[sense_size];
u32 sense_len;
u32 residual;
u16 status_qualifier;
u8 status;
u8 response;
char datain[];
};

/* command-specific response values */
#define VIRTIO_SCSI_S_OK0
#define VIRTIO_SCSI_S_UNDERRUN  1
#define VIRTIO_SCSI_S_ABORTED   2
#define VIRTIO_SCSI_S_BAD_TARGET3
#define VIRTIO_SCSI_S_RESET 4
#define VIRTIO_SCSI_S_TRANSPORT_FAILURE 5
#define VIRTIO_SCSI_S_TARGET_FAILURE6
#define 

[Qemu-devel] [PATCH v9] block: add io throttling support

2011-10-27 Thread [Zhi Yong Wu
From: Zhi Yong Wu wu...@linux.vnet.ibm.com

For sync and co driver API, i have not found one good way to do test, so 
currently i do some testing for async api. If anyone has one good way, pls let 
me know. thanks.

Signed-off-by: Zhi Yong Wu wu...@linux.vnet.ibm.com
---
 Makefile.objs |2 +-
 block.c   |  546 ++---
 block.h   |   24 +++
 block/blk-queue.c |  201 
 block/blk-queue.h |   63 ++
 block_int.h   |   45 +
 blockdev.c|   83 
 blockdev.h|2 +
 hmp-commands.hx   |   15 ++
 qemu-config.c |   24 +++
 qemu-options.hx   |1 +
 qerror.c  |4 +
 qerror.h  |3 +
 qmp-commands.hx   |   53 +-
 14 files changed, 1041 insertions(+), 25 deletions(-)
 create mode 100644 block/blk-queue.c
 create mode 100644 block/blk-queue.h

diff --git a/Makefile.objs b/Makefile.objs
index 01587c8..98891b3 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -33,7 +33,7 @@ block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o 
dmg.o bochs.o vpc.o vv
 block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o 
qcow2-cache.o
 block-nested-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
 block-nested-y += qed-check.o
-block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o
+block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o 
blk-queue.o
 block-nested-$(CONFIG_WIN32) += raw-win32.o
 block-nested-$(CONFIG_POSIX) += raw-posix.o
 block-nested-$(CONFIG_CURL) += curl.o
diff --git a/block.c b/block.c
index 70aab63..022693f 100644
--- a/block.c
+++ b/block.c
@@ -30,6 +30,9 @@
 #include qemu-objects.h
 #include qemu-coroutine.h
 
+#include qemu-timer.h
+#include block/blk-queue.h
+
 #ifdef CONFIG_BSD
 #include sys/types.h
 #include sys/stat.h
@@ -60,9 +63,11 @@ static int coroutine_fn bdrv_co_writev_em(BlockDriverState 
*bs,
  int64_t sector_num, int nb_sectors,
  QEMUIOVector *iov);
 static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,
-int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
+int64_t sector_num, int nb_sectors, QEMUIOVector *qiov,
+void *opaque, BlockAPIType co_type);
 static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
-int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
+int64_t sector_num, int nb_sectors, QEMUIOVector *qiov,
+void *opaque, BlockAPIType co_type);
 static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs,
int64_t sector_num,
QEMUIOVector *qiov,
@@ -72,6 +77,13 @@ static BlockDriverAIOCB 
*bdrv_co_aio_rw_vector(BlockDriverState *bs,
bool is_write);
 static void coroutine_fn bdrv_co_do_rw(void *opaque);
 
+static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors,
+bool is_write, double elapsed_time, uint64_t *wait);
+static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write,
+double elapsed_time, uint64_t *wait);
+static bool bdrv_exceed_io_limits(BlockDriverState *bs, int nb_sectors,
+bool is_write, int64_t *wait);
+
 static QTAILQ_HEAD(, BlockDriverState) bdrv_states =
 QTAILQ_HEAD_INITIALIZER(bdrv_states);
 
@@ -104,6 +116,83 @@ int is_windows_drive(const char *filename)
 }
 #endif
 
+/* throttling disk I/O limits */
+void bdrv_io_limits_disable(BlockDriverState *bs)
+{
+bs-io_limits_enabled = false;
+
+if (bs-block_queue) {
+qemu_block_queue_submit(bs-block_queue, qemu_block_queue_cb);
+qemu_del_block_queue(bs-block_queue);
+
+bs-block_queue = NULL;
+}
+
+if (bs-block_timer) {
+qemu_del_timer(bs-block_timer);
+qemu_free_timer(bs-block_timer);
+bs-block_timer = NULL;
+}
+
+bs-slice_start   = 0;
+bs-slice_end = 0;
+bs-slice_time= 0;
+memset(bs-io_disps, 0, sizeof(bs-io_disps));
+}
+
+static void bdrv_block_timer(void *opaque)
+{
+BlockDriverState *bs = opaque;
+BlockQueue *queue= bs-block_queue;
+
+qemu_block_queue_submit(queue, qemu_block_queue_cb);
+}
+
+void bdrv_io_limits_enable(BlockDriverState *bs)
+{
+bs-io_limits_enabled = true;
+if (!bs-block_queue) {
+bs-block_queue   = qemu_new_block_queue();
+bs-block_timer   = qemu_new_timer_ns(vm_clock, bdrv_block_timer, bs);
+}
+
+bs-slice_time= 5 * BLOCK_IO_SLICE_TIME;
+bs-slice_start   = qemu_get_clock_ns(vm_clock);
+bs-slice_end = bs-slice_start + bs-slice_time;
+memset(bs-io_disps, 0, sizeof(bs-io_disps));
+}
+
+bool bdrv_io_limits_enabled(BlockDriverState *bs)
+{
+BlockIOLimit *io_limits = bs-io_limits;
+return io_limits-bps[BLOCK_IO_LIMIT_READ]
+ || io_limits-bps[BLOCK_IO_LIMIT_WRITE]
+ || 

[Qemu-devel] [PATCH v2 3/3] Make cpu_single_env thread-local

2011-10-27 Thread Peter Maydell
From: Paolo Bonzini pbonz...@redhat.com

Make cpu_single_env thread-local. This fixes a regression
in handling of multi-threaded programs in linux-user mode
(bug 823902).

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
[Peter Maydell: rename tls_cpu_single_env to cpu_single_env]
Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 cpu-all.h |4 +++-
 exec.c|2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 42a5fa0..5f47ab8 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -20,6 +20,7 @@
 #define CPU_ALL_H
 
 #include qemu-common.h
+#include qemu-tls.h
 #include cpu-common.h
 
 /* some important defines:
@@ -334,7 +335,8 @@ void cpu_dump_statistics(CPUState *env, FILE *f, 
fprintf_function cpu_fprintf,
 void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...)
 GCC_FMT_ATTR(2, 3);
 extern CPUState *first_cpu;
-extern CPUState *cpu_single_env;
+DECLARE_TLS(CPUState *,cpu_single_env);
+#define cpu_single_env get_tls(cpu_single_env)
 
 /* Flags for use in ENV-INTERRUPT_PENDING.
 
diff --git a/exec.c b/exec.c
index 9dc4edb..18e26cb 100644
--- a/exec.c
+++ b/exec.c
@@ -120,7 +120,7 @@ static MemoryRegion *system_io;
 CPUState *first_cpu;
 /* current CPU in the current thread. It is only valid inside
cpu_exec() */
-CPUState *cpu_single_env;
+DEFINE_TLS(CPUState *,cpu_single_env);
 /* 0 = Do not count executed instructions.
1 = Precise instruction counting.
2 = Adaptive rate instruction counting.  */
-- 
1.7.1




[Qemu-devel] [PATCH v2 0/3] TLS abstraction layer for thread-local cpu_single_env on Linux

2011-10-27 Thread Peter Maydell
These patches add enough of the TLS abstraction layer to allow us
to make cpu_single_env thread-local on Linux systems. This fixes
the regression described in bug 823902 for the 1.0 release; we
can add the Win32 and POSIX implementations later.

I haven't included Paolo's Prepare Windows port for thread-local
cpu_single_env patch -- it would be safe to do so but it isn't
necessary until we actually implement TLS for Win32.

Changes v1-v2:
 * fix Paolo's email address
 * split the darwin-user change out into a separate patch
 * drop the 'tls_' prefix from the cpu_single_env tls var name

Paolo Bonzini (2):
  darwin-user/main.c: Drop unused cpu_single_env definition
  Make cpu_single_env thread-local

Peter Maydell (1):
  qemu-tls.h: Add abstraction layer for TLS variables

 cpu-all.h  |4 +++-
 darwin-user/main.c |2 --
 exec.c |2 +-
 qemu-tls.h |   51 +++
 4 files changed, 55 insertions(+), 4 deletions(-)
 create mode 100644 qemu-tls.h




[Qemu-devel] [PATCH v2 2/3] darwin-user/main.c: Drop unused cpu_single_env definition

2011-10-27 Thread Peter Maydell
From: Paolo Bonzini pbonz...@redhat.com

Drop the cpu_single_env definition as it is unused.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 darwin-user/main.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/darwin-user/main.c b/darwin-user/main.c
index 1a881a0..c0f14f8 100644
--- a/darwin-user/main.c
+++ b/darwin-user/main.c
@@ -729,8 +729,6 @@ static void usage(void)
 
 /* XXX: currently only used for async signals (see signal.c) */
 CPUState *global_env;
-/* used only if single thread */
-CPUState *cpu_single_env = NULL;
 
 /* used to free thread contexts */
 TaskState *first_task_state;
-- 
1.7.1




[Qemu-devel] ping Re: [PULL v2 00/33] SCSI changes for 1.0, part 1 of 2

2011-10-27 Thread Paolo Bonzini

On 10/25/2011 12:40 PM, Paolo Bonzini wrote:

Kevin,

The following changes since commit 952e849c150b4f1b89f8728cba00f925c1d6e75b:

   Merge remote-tracking branch 'bonzini/split-main-loop-for-anthony' into 
staging (2011-10-24 10:51:12 -0500)

are available in the git repository at:

   git://github.com/bonzini/qemu.git scsi-for-kevin

All comments from you have been addressed.  I'll send separately patches
that require a new review.

v1-v2:
- rebased
- various fixes noted in individual patches
- dropped patches 20, 21, 35
- added a separate patch to fix preexisting coding style issues

Paolo Bonzini (33):
   scsi: pass correct sense code for ENOMEDIUM
   atapi/scsi: unify definitions for MMC
   atapi: move GESN definitions to scsi-defs.h
   atapi: cleanup/fix mode sense results
   scsi: notify the device when unit attention is reported
   scsi-disk: report media changed via unit attention sense codes
   scsi-disk: fix coding style issues (braces)
   scsi-disk: add stubs for more MMC commands
   scsi-disk: store valid mode pages in a table
   atapi/scsi-disk: make mode page values coherent between the two
   scsi-disk: support DVD profile in GET CONFIGURATION
   scsi-disk: support READ DVD STRUCTURE
   scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION
   scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)
   qdev: switch children device list to QTAILQ
   scsi: remove devs array from SCSIBus
   scsi: implement REPORT LUNS for arbitrary LUNs
   scsi: allow arbitrary LUNs
   scsi: add channel to addressing
   scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0
   scsi-disk: fix retrying a flush
   scsi-generic: drop SCSIGenericState
   scsi-generic: remove scsi_req_fixup
   scsi-generic: check ioctl statuses when SG_IO succeeds
   scsi-generic: look at host status
   scsi-generic: snoop READ CAPACITY commands to get block size
   scsi-disk: do not duplicate BlockDriverState member
   scsi-disk: remove cluster_size
   scsi-disk: small clean up to INQUIRY
   scsi: move max_lba to SCSIDevice
   scsi: make reqops const
   scsi: export scsi_generic_reqops
   scsi: pass cdb to alloc_req

  hw/acpi_piix4.c  |4 +-
  hw/esp.c |   16 +-
  hw/i2c.c |2 +-
  hw/ide/atapi.c   |  119 --
  hw/ide/core.c|4 +-
  hw/ide/internal.h|   71 +--
  hw/ide/macio.c   |2 +-
  hw/intel-hda.c   |6 +-
  hw/lsi53c895a.c  |   30 +--
  hw/qdev.c|   24 +-
  hw/qdev.h|4 +-
  hw/s390-virtio-bus.c |4 +-
  hw/scsi-bus.c|  204 -
  hw/scsi-defs.h   |   90 
  hw/scsi-disk.c   |  604 +-
  hw/scsi-generic.c|  154 +++---
  hw/scsi.h|   33 ++-
  hw/spapr_vio.c   |6 +-
  hw/spapr_vscsi.c |   54 -
  hw/ssi.c |6 +-
  hw/usb-msd.c |8 +-
  21 files changed, 931 insertions(+), 514 deletions(-)



Ping?

Paolo




Re: [Qemu-devel] [PATCH v2] fw_cfg: Use g_file_get_contents instead of multiple fread() calls

2011-10-27 Thread Peter Maydell
On 24 October 2011 12:31, Pavel Borzenkov pavel.borzen...@gmail.com wrote:
 Signed-off-by: Pavel Borzenkov pavel.borzen...@gmail.com

Reviewed-by: Peter Maydell peter.mayd...@linaro.org

-- PMM



[Qemu-devel] ping Re: [PATCH 0/6] misc vvfat fixes

2011-10-27 Thread Paolo Bonzini

On 10/05/2011 09:12 AM, Paolo Bonzini wrote:

It occurred to me that, if there's one thing vvfat ought to be good
at, it is creating disk images with qemu-img convert (a driver disk
in my case).

It turns out the use case is really broken.  qemu-img doesn't
complete at all, the resulting images often do not pass fsck,
and it's impossible to create a 1.44 MB disk image.  This
series fixes all of the small problems I found.

Coding standard in this file is such a pain that I hardly bothered
about it.


Paolo Bonzini (6):
   vvfat: fix out of bounds array_get usage
   vvfat: do not fail if the disk has spare sectors
   vvfat: need to use first_sectors_number to distinguish fdd/hdd
   vvfat: unify and correct computation of sector count
   vvfat: do not hardcode sector counts in error message
   vvfat: reorganize computation of disk geometry

  block/vvfat.c |   50 --
  3 files changed, 26 insertions(+), 28 deletions(-)



ping?

Paolo




[Qemu-devel] ping Re: [PATCH 0/5] My remaining block/SCSI patches for 1.0

2011-10-27 Thread Paolo Bonzini

On 10/25/2011 12:53 PM, Paolo Bonzini wrote:

The first three replace patches 20/21 and are basically rewritten with
input from Kevin.

The fourth is new.  I had it queued for 1.1, but it turns out it is
needed now or scsi-block might access some requests incorrectly when
restarting after an error.

The fifth is basically the same as patch 35 from the first submission.

The last three patches had been submitted Sep 20 and were lost at sea;
support for eject requests is required by udev 173.

Paolo Bonzini (8):
   scsi: do not call transfer_data after canceling a request
   scsi-disk: bump SCSIRequest reference count until aio completion runs
   scsi-generic: bump SCSIRequest reference count until aio completion runs
   scsi: push request restart to SCSIDevice
   scsi-disk: add scsi-block for device passthrough
   block: add eject request callback
   atapi: implement eject requests
   scsi-disk: implement eject requests

  block.c   |7 ++
  block.h   |7 ++
  blockdev.c|8 +-
  hw/ide/atapi.c|   11 ++-
  hw/ide/core.c |   13 +++
  hw/scsi-bus.c |   79 -
  hw/scsi-disk.c|  254 ++--
  hw/scsi-generic.c |   18 
  hw/scsi.h |6 ++
  trace-events  |1 +
  10 files changed, 325 insertions(+), 79 deletions(-)



Ping?

Paolo




Re: [Qemu-devel] [PATCH] qxl: create slots on post_load in vga state

2011-10-27 Thread Gerd Hoffmann
On 10/25/11 15:39, Alon Levy wrote:
 RHBZ 740547
 
 If we migrate when the device is in vga state the guest
 still believes the slots are created, and will cause operations
 that reference the slots, causing a panic: virtual address out of range
 on the first of them. Easy to see by migrating in vga mode with
 a driver loaded, for instance windows cmd window in full screen mode,
 and then exiting vga mode back to native mode will cause said panic.
 
 Fixed by doing the slot recreation in post_load for vga mode as well.
 Note that compat does not require any changes because it creates it's
 only slot by a side effect of QXL_IO_SET_MODE.
 
 Signed-off-by: Alon Levy al...@redhat.com
 ---
 v4:
  don't print unused delta in qxl_create_memslots
 v3:
  no need to create slots in compat mode, they are created by qxl_set_mode.
 

Patch added to spice patch queue.

thanks,
  Gerd



[Qemu-devel] [PATCH v2 1/3] qemu-tls.h: Add abstraction layer for TLS variables

2011-10-27 Thread Peter Maydell
Add an abstraction layer for defining and using thread-local
variables. For the moment this is implemented only for Linux,
which means they can only be used in restricted circumstances.
The abstraction layer allows us to add POSIX and Win32 support
later.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 qemu-tls.h |   51 +++
 1 files changed, 51 insertions(+), 0 deletions(-)
 create mode 100644 qemu-tls.h

diff --git a/qemu-tls.h b/qemu-tls.h
new file mode 100644
index 000..d96a159
--- /dev/null
+++ b/qemu-tls.h
@@ -0,0 +1,51 @@
+/*
+ * Abstraction layer for defining and using TLS variables
+ *
+ * Copyright (c) 2011 Red Hat, Inc, Linaro Limited
+ *
+ * Authors:
+ *  Paolo Bonzini pbonz...@redhat.com
+ *  Peter Maydell peter.mayd...@linaro.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef QEMU_TLS_GCC_H
+#define QEMU_TLS_GCC_H
+
+/* Per-thread variables. Note that we only have implementations
+ * which are really thread-local on Linux; the dummy implementations
+ * define plain global variables.
+ *
+ * This means that for the moment use should be restricted to
+ * per-VCPU variables, which are OK because:
+ *  - the only -user mode supporting multiple VCPU threads is linux-user
+ *  - TCG system mode is single-threaded regarding VCPUs
+ *  - KVM system mode is multi-threaded but limited to Linux
+ *
+ * TODO: proper implementations via Win32 .tls sections and
+ * POSIX pthread_getspecific.
+ */
+#ifdef __linux__
+#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x)
+#define DEFINE_TLS(type, x)  __thread __typeof__(type) tls__##x
+#define get_tls(x)   tls__##x
+#else
+/* Dummy implementations which define plain global variables */
+#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x)
+#define DEFINE_TLS(type, x)  __typeof__(type) tls__##x
+#define get_tls(x)   tls__##x
+#endif
+
+#endif
-- 
1.7.1




[Qemu-devel] [PATCH 10/10] ppc64-linux-user: Fix syscall return type.

2011-10-27 Thread riku . voipio
From: Richard Henderson r...@twiddle.net

Use target_ulong instead of hard-coded uint32_t.
Remove the disabled printf's that are redundant with -strace.

Signed-off-by: Richard Henderson r...@twiddle.net
Signed-off-by: Riku Voipio riku.voi...@linaro.org
---
 linux-user/main.c |   13 +++--
 1 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index c36a8af..d1bbc57 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1341,7 +1341,7 @@ void cpu_loop(CPUPPCState *env)
 {
 target_siginfo_t info;
 int trapnr;
-uint32_t ret;
+target_ulong ret;
 
 for(;;) {
 cpu_exec_start(env);
@@ -1704,27 +1704,20 @@ void cpu_loop(CPUPPCState *env)
  * PPC ABI uses overflow flag in cr0 to signal an error
  * in syscalls.
  */
-#if 0
-printf(syscall %d 0x%08x 0x%08x 0x%08x 0x%08x\n, env-gpr[0],
-   env-gpr[3], env-gpr[4], env-gpr[5], env-gpr[6]);
-#endif
 env-crf[0] = ~0x1;
 ret = do_syscall(env, env-gpr[0], env-gpr[3], env-gpr[4],
  env-gpr[5], env-gpr[6], env-gpr[7],
  env-gpr[8], 0, 0);
-if (ret == (uint32_t)(-TARGET_QEMU_ESIGRETURN)) {
+if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN)) {
 /* Returning from a successful sigreturn syscall.
Avoid corrupting register state.  */
 break;
 }
-if (ret  (uint32_t)(-515)) {
+if (ret  (target_ulong)(-515)) {
 env-crf[0] |= 0x1;
 ret = -ret;
 }
 env-gpr[3] = ret;
-#if 0
-printf(syscall returned 0x%08x (%d)\n, ret, ret);
-#endif
 break;
 case POWERPC_EXCP_STCX:
 if (do_store_exclusive(env)) {
-- 
1.7.5.4




[Qemu-devel] [PATCH 06/10] sparc-linux-user: Handle SIGILL.

2011-10-27 Thread riku . voipio
From: Richard Henderson r...@twiddle.net

Signed-off-by: Richard Henderson r...@twiddle.net
Signed-off-by: Riku Voipio riku.voi...@linaro.org
---
 linux-user/main.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index e7dad54..2bc10ed 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1191,6 +1191,15 @@ void cpu_loop (CPUSPARCState *env)
 case EXCP_INTERRUPT:
 /* just indicate that signals should be handled asap */
 break;
+case TT_ILL_INSN:
+{
+info.si_signo = TARGET_SIGILL;
+info.si_errno = 0;
+info.si_code = TARGET_ILL_ILLOPC;
+info._sifields._sigfault._addr = env-pc;
+queue_signal(env, info.si_signo, info);
+}
+break;
 case EXCP_DEBUG:
 {
 int sig;
-- 
1.7.5.4




[Qemu-devel] [PATCH 07/10] sparc-linux-user: Fixup sending SIGSEGV

2011-10-27 Thread riku . voipio
From: Richard Henderson r...@twiddle.net

Signed-off-by: Richard Henderson r...@twiddle.net
Signed-off-by: Riku Voipio riku.voi...@linaro.org
---
 linux-user/main.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 2bc10ed..c36a8af 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1148,7 +1148,7 @@ void cpu_loop (CPUSPARCState *env)
 case TT_TFAULT:
 case TT_DFAULT:
 {
-info.si_signo = SIGSEGV;
+info.si_signo = TARGET_SIGSEGV;
 info.si_errno = 0;
 /* XXX: check env-error_code */
 info.si_code = TARGET_SEGV_MAPERR;
@@ -1166,7 +1166,7 @@ void cpu_loop (CPUSPARCState *env)
 case TT_TFAULT:
 case TT_DFAULT:
 {
-info.si_signo = SIGSEGV;
+info.si_signo = TARGET_SIGSEGV;
 info.si_errno = 0;
 /* XXX: check env-error_code */
 info.si_code = TARGET_SEGV_MAPERR;
-- 
1.7.5.4




[Qemu-devel] [PATCH 1/6] kvm: Add tool for querying VMX capabilities

2011-10-27 Thread Marcelo Tosatti
From: Jan Kiszka jan.kis...@siemens.com

Taken from original qemu-kvm/kvm/scripts/vmxcap.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Avi Kivity a...@redhat.com
---
 scripts/kvm/vmxcap |  224 
 1 files changed, 224 insertions(+), 0 deletions(-)
 create mode 100755 scripts/kvm/vmxcap

diff --git a/scripts/kvm/vmxcap b/scripts/kvm/vmxcap
new file mode 100755
index 000..a74ce71
--- /dev/null
+++ b/scripts/kvm/vmxcap
@@ -0,0 +1,224 @@
+#!/usr/bin/python
+#
+# tool for querying VMX capabilities
+#
+# Copyright 2009-2010 Red Hat, Inc.
+#
+# Authors:
+#  Avi Kivity a...@redhat.com
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+
+MSR_IA32_VMX_BASIC = 0x480
+MSR_IA32_VMX_PINBASED_CTLS = 0x481
+MSR_IA32_VMX_PROCBASED_CTLS = 0x482
+MSR_IA32_VMX_EXIT_CTLS = 0x483
+MSR_IA32_VMX_ENTRY_CTLS = 0x484
+MSR_IA32_VMX_MISC_CTLS = 0x485
+MSR_IA32_VMX_PROCBASED_CTLS2 = 0x48B
+MSR_IA32_VMX_EPT_VPID_CAP = 0x48C
+MSR_IA32_VMX_TRUE_PINBASED_CTLS = 0x48D
+MSR_IA32_VMX_TRUE_PROCBASED_CTLS = 0x48E
+MSR_IA32_VMX_TRUE_EXIT_CTLS = 0x48F
+MSR_IA32_VMX_TRUE_ENTRY_CTLS = 0x490
+
+class msr(object):
+def __init__(self):
+try:
+self.f = file('/dev/cpu/0/msr')
+except:
+self.f = file('/dev/msr0')
+def read(self, index, default = None):
+import struct
+self.f.seek(index)
+try:
+return struct.unpack('Q', self.f.read(8))[0]
+except:
+return default
+
+class Control(object):
+def __init__(self, name, bits, cap_msr, true_cap_msr = None):
+self.name = name
+self.bits = bits
+self.cap_msr = cap_msr
+self.true_cap_msr = true_cap_msr
+def read2(self, nr):
+m = msr()
+val = m.read(nr, 0)
+return (val  0x, val  32)
+def show(self):
+print self.name
+mbz, mb1 = self.read2(self.cap_msr)
+tmbz, tmb1 = 0, 0
+if self.true_cap_msr:
+tmbz, tmb1 = self.read2(self.true_cap_msr)
+for bit in sorted(self.bits.keys()):
+zero = not (mbz  (1  bit))
+one = mb1  (1  bit)
+true_zero = not (tmbz  (1  bit))
+true_one = tmb1  (1  bit)
+s= '?'
+if (self.true_cap_msr and true_zero and true_one
+and one and not zero):
+s = 'default'
+elif zero and not one:
+s = 'no'
+elif one and not zero:
+s = 'forced'
+elif one and zero:
+s = 'yes'
+print '  %-40s %s' % (self.bits[bit], s)
+
+class Misc(object):
+def __init__(self, name, bits, msr):
+self.name = name
+self.bits = bits
+self.msr = msr
+def show(self):
+print self.name
+value = msr().read(self.msr, 0)
+def first_bit(key):
+if type(key) is tuple:
+return key[0]
+else:
+return key
+for bits in sorted(self.bits.keys(), key = first_bit):
+if type(bits) is tuple:
+lo, hi = bits
+fmt = int
+else:
+lo = hi = bits
+def fmt(x):
+return { True: 'yes', False: 'no' }[x]
+v = (value  lo)  ((1  (hi - lo + 1)) - 1)
+print '  %-40s %s' % (self.bits[bits], fmt(v))
+
+controls = [
+Control(
+name = 'pin-based controls',
+bits = {
+0: 'External interrupt exiting',
+3: 'NMI exiting',
+5: 'Virtual NMIs',
+6: 'Activate VMX-preemption timer',
+},
+cap_msr = MSR_IA32_VMX_PINBASED_CTLS,
+true_cap_msr = MSR_IA32_VMX_TRUE_PINBASED_CTLS,
+),
+
+Control(
+name = 'primary processor-based controls',
+bits = {
+2: 'Interrupt window exiting',
+3: 'Use TSC offsetting',
+7: 'HLT exiting',
+9: 'INVLPG exiting',
+10: 'MWAIT exiting',
+11: 'RDPMC exiting',
+12: 'RDTSC exiting',
+15: 'CR3-load exiting',
+16: 'CR3-store exiting',
+19: 'CR8-load exiting',
+20: 'CR8-store exiting',
+21: 'Use TPR shadow',
+22: 'NMI-window exiting',
+23: 'MOV-DR exiting',
+24: 'Unconditional I/O exiting',
+25: 'Use I/O bitmaps',
+27: 'Monitor trap flag',
+28: 'Use MSR bitmaps',
+29: 'MONITOR exiting',
+30: 'PAUSE exiting',
+31: 'Activate secondary control',
+},
+cap_msr = MSR_IA32_VMX_PROCBASED_CTLS,
+true_cap_msr = MSR_IA32_VMX_TRUE_PROCBASED_CTLS,
+),
+
+Control(
+name = 'secondary processor-based controls',
+bits = {
+0: 

[Qemu-devel] [PATCH 3/6] kvm: avoid reentring kvm_flush_coalesced_mmio_buffer()

2011-10-27 Thread Marcelo Tosatti
From: Avi Kivity a...@redhat.com

mmio callbacks invoked by kvm_flush_coalesced_mmio_buffer() may
themselves indirectly call kvm_flush_coalesced_mmio_buffer().
Prevent reentering the function by checking a flag that indicates
we're processing coalesced mmio requests.

Signed-off-by: Avi Kivity a...@redhat.com
---
 kvm-all.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index e7faf5c..c09ddf7 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -64,6 +64,7 @@ struct KVMState
 int vmfd;
 int coalesced_mmio;
 struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
+bool coalesced_flush_in_progress;
 int broken_set_mem_region;
 int migration_log;
 int vcpu_events;
@@ -876,6 +877,13 @@ static int kvm_handle_internal_error(CPUState *env, struct 
kvm_run *run)
 void kvm_flush_coalesced_mmio_buffer(void)
 {
 KVMState *s = kvm_state;
+
+if (s-coalesced_flush_in_progress) {
+return;
+}
+
+s-coalesced_flush_in_progress = true;
+
 if (s-coalesced_mmio_ring) {
 struct kvm_coalesced_mmio_ring *ring = s-coalesced_mmio_ring;
 while (ring-first != ring-last) {
@@ -888,6 +896,8 @@ void kvm_flush_coalesced_mmio_buffer(void)
 ring-first = (ring-first + 1) % KVM_COALESCED_MMIO_MAX;
 }
 }
+
+s-coalesced_flush_in_progress = false;
 }
 
 static void do_kvm_cpu_synchronize_state(void *_env)
-- 
1.7.5.4




[Qemu-devel] [PATCH 5/6] kvm: support TSC deadline MSR with subsection

2011-10-27 Thread Marcelo Tosatti
From: Liu, Jinsong jinsong@intel.com

KVM add emulation of lapic tsc deadline timer for guest.
This patch is co-operation work at qemu side.

Use subsections to save/restore the field (mtosatti).

Signed-off-by: Liu, Jinsong jinsong@intel.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com
---
 target-i386/cpu.h |2 ++
 target-i386/kvm.c |   14 ++
 target-i386/machine.c |   21 +
 3 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index ae36489..29412dc 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -283,6 +283,7 @@
 #define MSR_IA32_APICBASE_BSP   (18)
 #define MSR_IA32_APICBASE_ENABLE(111)
 #define MSR_IA32_APICBASE_BASE  (0xf12)
+#define MSR_IA32_TSCDEADLINE0x6e0
 
 #define MSR_MTRRcap0xfe
 #define MSR_MTRRcap_VCNT   8
@@ -687,6 +688,7 @@ typedef struct CPUX86State {
 uint64_t async_pf_en_msr;
 
 uint64_t tsc;
+uint64_t tsc_deadline;
 
 uint64_t mcg_status;
 
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index b6eef04..90a6ffb 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -59,6 +59,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 
 static bool has_msr_star;
 static bool has_msr_hsave_pa;
+static bool has_msr_tsc_deadline;
 static bool has_msr_async_pf_en;
 static int lm_capable_kernel;
 
@@ -568,6 +569,10 @@ static int kvm_get_supported_msrs(KVMState *s)
 has_msr_hsave_pa = true;
 continue;
 }
+if (kvm_msr_list-indices[i] == MSR_IA32_TSCDEADLINE) {
+has_msr_tsc_deadline = true;
+continue;
+}
 }
 }
 
@@ -881,6 +886,9 @@ static int kvm_put_msrs(CPUState *env, int level)
 if (has_msr_hsave_pa) {
 kvm_msr_entry_set(msrs[n++], MSR_VM_HSAVE_PA, env-vm_hsave);
 }
+if (has_msr_tsc_deadline) {
+kvm_msr_entry_set(msrs[n++], MSR_IA32_TSCDEADLINE, env-tsc_deadline);
+}
 #ifdef TARGET_X86_64
 if (lm_capable_kernel) {
 kvm_msr_entry_set(msrs[n++], MSR_CSTAR, env-cstar);
@@ -1127,6 +1135,9 @@ static int kvm_get_msrs(CPUState *env)
 if (has_msr_hsave_pa) {
 msrs[n++].index = MSR_VM_HSAVE_PA;
 }
+if (has_msr_tsc_deadline) {
+msrs[n++].index = MSR_IA32_TSCDEADLINE;
+}
 
 if (!env-tsc_valid) {
 msrs[n++].index = MSR_IA32_TSC;
@@ -1195,6 +1206,9 @@ static int kvm_get_msrs(CPUState *env)
 case MSR_IA32_TSC:
 env-tsc = msrs[i].data;
 break;
+case MSR_IA32_TSCDEADLINE:
+env-tsc_deadline = msrs[i].data;
+break;
 case MSR_VM_HSAVE_PA:
 env-vm_hsave = msrs[i].data;
 break;
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 9aca8e0..176d372 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -310,6 +310,24 @@ static const VMStateDescription vmstate_fpop_ip_dp = {
 }
 };
 
+static bool tscdeadline_needed(void *opaque)
+{
+CPUState *env = opaque;
+
+return env-tsc_deadline != 0;
+}
+
+static const VMStateDescription vmstate_msr_tscdeadline = {
+.name = cpu/msr_tscdeadline,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField []) {
+VMSTATE_UINT64(tsc_deadline, CPUState),
+VMSTATE_END_OF_LIST()
+}
+};
+
 static const VMStateDescription vmstate_cpu = {
 .name = cpu,
 .version_id = CPU_SAVE_VERSION,
@@ -420,6 +438,9 @@ static const VMStateDescription vmstate_cpu = {
 } , {
 .vmsd = vmstate_fpop_ip_dp,
 .needed = fpop_ip_dp_needed,
+}, {
+.vmsd = vmstate_msr_tscdeadline,
+.needed = tscdeadline_needed,
 } , {
 /* empty */
 }
-- 
1.7.5.4




[Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue

2011-10-27 Thread Marcelo Tosatti
The following changes since commit 952e849c150b4f1b89f8728cba00f925c1d6e75b:

  Merge remote-tracking branch 'bonzini/split-main-loop-for-anthony' into 
staging (2011-10-24 10:51:12 -0500)

are available in the git repository at:

  git://github.com/avikivity/qemu.git uq/master

Avi Kivity (2):
  kvm: avoid reentring kvm_flush_coalesced_mmio_buffer()
  i386: wire up MSR_IA32_MISC_ENABLE

Jan Kiszka (2):
  kvm: Add tool for querying VMX capabilities
  kvm: Add top-like kvm statistics script

Liu, Jinsong (1):
  kvm: support TSC deadline MSR with subsection

Marcelo Tosatti (1):
  Revert kvm: support TSC deadline MSR

 kvm-all.c   |   10 +
 scripts/kvm/kvm_stat|  480 +++
 scripts/kvm/vmxcap  |  224 ++
 target-i386/cpu.h   |7 +-
 target-i386/helper.c|1 +
 target-i386/kvm.c   |   15 ++
 target-i386/machine.c   |   43 -
 target-i386/op_helper.c |6 +
 8 files changed, 784 insertions(+), 2 deletions(-)
 create mode 100755 scripts/kvm/kvm_stat
 create mode 100755 scripts/kvm/vmxcap



[Qemu-devel] [PATCH 2/6] kvm: Add top-like kvm statistics script

2011-10-27 Thread Marcelo Tosatti
From: Jan Kiszka jan.kis...@siemens.com

Taken from original qemu-kvm/kvm/kvm_stat.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Avi Kivity a...@redhat.com
---
 scripts/kvm/kvm_stat |  480 ++
 1 files changed, 480 insertions(+), 0 deletions(-)
 create mode 100755 scripts/kvm/kvm_stat

diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
new file mode 100755
index 000..56d2bd7
--- /dev/null
+++ b/scripts/kvm/kvm_stat
@@ -0,0 +1,480 @@
+#!/usr/bin/python
+#
+# top-like utility for displaying kvm statistics
+#
+# Copyright 2006-2008 Qumranet Technologies
+# Copyright 2008-2011 Red Hat, Inc.
+#
+# Authors:
+#  Avi Kivity a...@redhat.com
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+
+import curses
+import sys, os, time, optparse
+
+class DebugfsProvider(object):
+def __init__(self):
+self.base = '/sys/kernel/debug/kvm'
+self._fields = os.listdir(self.base)
+def fields(self):
+return self._fields
+def select(self, fields):
+self._fields = fields
+def read(self):
+def val(key):
+return int(file(self.base + '/' + key).read())
+return dict([(key, val(key)) for key in self._fields])
+
+vmx_exit_reasons = {
+0: 'EXCEPTION_NMI',
+1: 'EXTERNAL_INTERRUPT',
+2: 'TRIPLE_FAULT',
+7: 'PENDING_INTERRUPT',
+8: 'NMI_WINDOW',
+9: 'TASK_SWITCH',
+10: 'CPUID',
+12: 'HLT',
+14: 'INVLPG',
+15: 'RDPMC',
+16: 'RDTSC',
+18: 'VMCALL',
+19: 'VMCLEAR',
+20: 'VMLAUNCH',
+21: 'VMPTRLD',
+22: 'VMPTRST',
+23: 'VMREAD',
+24: 'VMRESUME',
+25: 'VMWRITE',
+26: 'VMOFF',
+27: 'VMON',
+28: 'CR_ACCESS',
+29: 'DR_ACCESS',
+30: 'IO_INSTRUCTION',
+31: 'MSR_READ',
+32: 'MSR_WRITE',
+33: 'INVALID_STATE',
+36: 'MWAIT_INSTRUCTION',
+39: 'MONITOR_INSTRUCTION',
+40: 'PAUSE_INSTRUCTION',
+41: 'MCE_DURING_VMENTRY',
+43: 'TPR_BELOW_THRESHOLD',
+44: 'APIC_ACCESS',
+48: 'EPT_VIOLATION',
+49: 'EPT_MISCONFIG',
+54: 'WBINVD',
+55: 'XSETBV',
+}
+
+svm_exit_reasons = {
+0x000: 'READ_CR0',
+0x003: 'READ_CR3',
+0x004: 'READ_CR4',
+0x008: 'READ_CR8',
+0x010: 'WRITE_CR0',
+0x013: 'WRITE_CR3',
+0x014: 'WRITE_CR4',
+0x018: 'WRITE_CR8',
+0x020: 'READ_DR0',
+0x021: 'READ_DR1',
+0x022: 'READ_DR2',
+0x023: 'READ_DR3',
+0x024: 'READ_DR4',
+0x025: 'READ_DR5',
+0x026: 'READ_DR6',
+0x027: 'READ_DR7',
+0x030: 'WRITE_DR0',
+0x031: 'WRITE_DR1',
+0x032: 'WRITE_DR2',
+0x033: 'WRITE_DR3',
+0x034: 'WRITE_DR4',
+0x035: 'WRITE_DR5',
+0x036: 'WRITE_DR6',
+0x037: 'WRITE_DR7',
+0x040: 'EXCP_BASE',
+0x060: 'INTR',
+0x061: 'NMI',
+0x062: 'SMI',
+0x063: 'INIT',
+0x064: 'VINTR',
+0x065: 'CR0_SEL_WRITE',
+0x066: 'IDTR_READ',
+0x067: 'GDTR_READ',
+0x068: 'LDTR_READ',
+0x069: 'TR_READ',
+0x06a: 'IDTR_WRITE',
+0x06b: 'GDTR_WRITE',
+0x06c: 'LDTR_WRITE',
+0x06d: 'TR_WRITE',
+0x06e: 'RDTSC',
+0x06f: 'RDPMC',
+0x070: 'PUSHF',
+0x071: 'POPF',
+0x072: 'CPUID',
+0x073: 'RSM',
+0x074: 'IRET',
+0x075: 'SWINT',
+0x076: 'INVD',
+0x077: 'PAUSE',
+0x078: 'HLT',
+0x079: 'INVLPG',
+0x07a: 'INVLPGA',
+0x07b: 'IOIO',
+0x07c: 'MSR',
+0x07d: 'TASK_SWITCH',
+0x07e: 'FERR_FREEZE',
+0x07f: 'SHUTDOWN',
+0x080: 'VMRUN',
+0x081: 'VMMCALL',
+0x082: 'VMLOAD',
+0x083: 'VMSAVE',
+0x084: 'STGI',
+0x085: 'CLGI',
+0x086: 'SKINIT',
+0x087: 'RDTSCP',
+0x088: 'ICEBP',
+0x089: 'WBINVD',
+0x08a: 'MONITOR',
+0x08b: 'MWAIT',
+0x08c: 'MWAIT_COND',
+0x400: 'NPF',
+}
+
+vendor_exit_reasons = {
+'vmx': vmx_exit_reasons,
+'svm': svm_exit_reasons,
+}
+
+exit_reasons = None
+
+for line in file('/proc/cpuinfo').readlines():
+if line.startswith('flags'):
+for flag in line.split():
+if flag in vendor_exit_reasons:
+exit_reasons = vendor_exit_reasons[flag]
+
+filters = {
+'kvm_exit': ('exit_reason', exit_reasons)
+}
+
+def invert(d):
+return dict((x[1], x[0]) for x in d.iteritems())
+
+for f in filters:
+filters[f] = (filters[f][0], invert(filters[f][1]))
+
+import ctypes, struct, array
+
+libc = ctypes.CDLL('libc.so.6')
+syscall = libc.syscall
+class perf_event_attr(ctypes.Structure):
+_fields_ = [('type', ctypes.c_uint32),
+('size', ctypes.c_uint32),
+('config', ctypes.c_uint64),
+('sample_freq', ctypes.c_uint64),
+('sample_type', ctypes.c_uint64),
+('read_format', ctypes.c_uint64),
+('flags', ctypes.c_uint64),
+('wakeup_events', ctypes.c_uint32),
+('bp_type', ctypes.c_uint32),
+('bp_addr', 

[Qemu-devel] [PATCH 6/6] i386: wire up MSR_IA32_MISC_ENABLE

2011-10-27 Thread Marcelo Tosatti
From: Avi Kivity a...@redhat.com

It's needed for its default value - bit 0 specifies that rep movs is
good enough for memcpy, and Linux may use a slower memcpu if it is not set,
depending on cpu family/model.

Signed-off-by: Avi Kivity a...@redhat.com
Signed-off-by: Marcelo Tosatti mtosa...@redhat.com
---
 target-i386/cpu.h   |5 +
 target-i386/helper.c|1 +
 target-i386/kvm.c   |   15 +++
 target-i386/machine.c   |   21 +
 target-i386/op_helper.c |6 ++
 5 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 29412dc..a08ce9d 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -300,6 +300,10 @@
 
 #define MSR_IA32_PERF_STATUS0x198
 
+#define MSR_IA32_MISC_ENABLE   0x1a0
+/* Indicates good rep/movs microcode on some processors: */
+#define MSR_IA32_MISC_ENABLE_DEFAULT1
+
 #define MSR_MTRRphysBase(reg)  (0x200 + 2 * (reg))
 #define MSR_MTRRphysMask(reg)  (0x200 + 2 * (reg) + 1)
 
@@ -691,6 +695,7 @@ typedef struct CPUX86State {
 uint64_t tsc_deadline;
 
 uint64_t mcg_status;
+uint64_t msr_ia32_misc_enable;
 
 /* exception/interrupt handling */
 int error_code;
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 5df40d4..6c6a167 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -98,6 +98,7 @@ void cpu_reset(CPUX86State *env)
 env-mxcsr = 0x1f80;
 
 env-pat = 0x0007040600070406ULL;
+env-msr_ia32_misc_enable = MSR_IA32_MISC_ENABLE_DEFAULT;
 
 memset(env-dr, 0, sizeof(env-dr));
 env-dr[6] = DR6_FIXED_1;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 90a6ffb..ddd115c 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -61,6 +61,7 @@ static bool has_msr_star;
 static bool has_msr_hsave_pa;
 static bool has_msr_tsc_deadline;
 static bool has_msr_async_pf_en;
+static bool has_msr_misc_enable;
 static int lm_capable_kernel;
 
 static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
@@ -573,6 +574,10 @@ static int kvm_get_supported_msrs(KVMState *s)
 has_msr_tsc_deadline = true;
 continue;
 }
+if (kvm_msr_list-indices[i] == MSR_IA32_MISC_ENABLE) {
+has_msr_misc_enable = true;
+continue;
+}
 }
 }
 
@@ -889,6 +894,10 @@ static int kvm_put_msrs(CPUState *env, int level)
 if (has_msr_tsc_deadline) {
 kvm_msr_entry_set(msrs[n++], MSR_IA32_TSCDEADLINE, env-tsc_deadline);
 }
+if (has_msr_misc_enable) {
+kvm_msr_entry_set(msrs[n++], MSR_IA32_MISC_ENABLE,
+  env-msr_ia32_misc_enable);
+}
 #ifdef TARGET_X86_64
 if (lm_capable_kernel) {
 kvm_msr_entry_set(msrs[n++], MSR_CSTAR, env-cstar);
@@ -1138,6 +1147,9 @@ static int kvm_get_msrs(CPUState *env)
 if (has_msr_tsc_deadline) {
 msrs[n++].index = MSR_IA32_TSCDEADLINE;
 }
+if (has_msr_misc_enable) {
+msrs[n++].index = MSR_IA32_MISC_ENABLE;
+}
 
 if (!env-tsc_valid) {
 msrs[n++].index = MSR_IA32_TSC;
@@ -1224,6 +1236,9 @@ static int kvm_get_msrs(CPUState *env)
 case MSR_MCG_CTL:
 env-mcg_ctl = msrs[i].data;
 break;
+case MSR_IA32_MISC_ENABLE:
+env-msr_ia32_misc_enable = msrs[i].data;
+break;
 default:
 if (msrs[i].index = MSR_MC0_CTL 
 msrs[i].index  MSR_MC0_CTL + (env-mcg_cap  0xff) * 4) {
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 176d372..d6e98ff 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -328,6 +328,24 @@ static const VMStateDescription vmstate_msr_tscdeadline = {
 }
 };
 
+static bool misc_enable_needed(void *opaque)
+{
+CPUState *env = opaque;
+
+return env-msr_ia32_misc_enable != MSR_IA32_MISC_ENABLE_DEFAULT;
+}
+
+static const VMStateDescription vmstate_msr_ia32_misc_enable = {
+.name = cpu/msr_ia32_misc_enable,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields  = (VMStateField []) {
+VMSTATE_UINT64(msr_ia32_misc_enable, CPUState),
+VMSTATE_END_OF_LIST()
+}
+};
+
 static const VMStateDescription vmstate_cpu = {
 .name = cpu,
 .version_id = CPU_SAVE_VERSION,
@@ -441,6 +459,9 @@ static const VMStateDescription vmstate_cpu = {
 }, {
 .vmsd = vmstate_msr_tscdeadline,
 .needed = tscdeadline_needed,
+}, {
+.vmsd = vmstate_msr_ia32_misc_enable,
+.needed = misc_enable_needed,
 } , {
 /* empty */
 }
diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c
index 3bb5a91..c89e4a4 100644
--- a/target-i386/op_helper.c
+++ b/target-i386/op_helper.c
@@ -3280,6 +3280,9 @@ void helper_wrmsr(void)
 case MSR_TSC_AUX:
 env-tsc_aux = val;
 

[Qemu-devel] [PATCH 01/10] linux-user: fix TARGET_RLIM_INFINITY declaration

2011-10-27 Thread riku . voipio
From: Matthias Braun ma...@braunis.de

Signed-off-by: Matthias Braun ma...@braunis.de
Signed-off-by: Riku Voipio riku.voi...@linaro.org
---
 linux-user/syscall_defs.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 15c44d4..1bc54c7 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -690,7 +690,7 @@ struct target_rlimit {
 #elif defined(TARGET_MIPS) || defined(TARGET_SPARC)
 #define TARGET_RLIM_INFINITY   0x7fffUL
 #else
-#define TARGET_RLIM_INFINITY   ((target_ulong)~0UL)
+#define TARGET_RLIM_INFINITY   ((abi_ulong)-1)
 #endif
 
 #if defined(TARGET_MIPS)
-- 
1.7.5.4




Re: [Qemu-devel] virtio-scsi wiki feature page

2011-10-27 Thread Stefan Hajnoczi
On Thu, Oct 27, 2011 at 12:19 PM, Paolo Bonzini pbonz...@redhat.com wrote:
 On 10/27/2011 12:49 PM, Stefan Hajnoczi wrote:

 I have created a virtio-scsi wiki feature page with links to Paolo's
 latest draft specification, our KVM Forum presentation, and code
 repos:

 http://wiki.qemu.org/Features/VirtioSCSI

 Paolo: v3 had some comments, is it a good time for a new revision of
 the draft specification?

 Yes.  I was waiting until I actually have an implementation, but anyway here
 it is, attached.  The changes are small:

 - additional failure kinds mapping more or less to Linux driver_statuses

 - defined the format of the LUN.  Unlike vSCSI, there's no support for
 generic hierarchical LUNs.  A single LUN format is specified, that supports
 256 targets and 16384 LUNs per target.

 - clarified multiqueue semantics

 I'm planning to update your LLD code to support these changes, but I'll
 gladly accept that someone else does it. :)

Okay, that sounds great.  As I get back into virtio-scsi I'll let you
know so we don't duplicate work.

Stefan



[Qemu-devel] [PATCH 04/10] linux-user: fix openat

2011-10-27 Thread riku . voipio
From: Alexander Graf ag...@suse.de

When running openat using qemu-arm, we stumbled over invalid permissions
on the created files. The reason for this is that the mode parameter gets
treates as an O_... flag, which it isn't - it's a permission bitmask.

This patch removes the needless translation of the mode parameter,
rendering permission passing of openat() to work with linux-user.

Reported-by: Dirk Mueller dmuel...@suse.de
Signed-off-by: Alexander Graf ag...@suse.de
Signed-off-by: Riku Voipio riku.voi...@iki.fi
---
 linux-user/syscall.c |   14 +-
 1 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9a63357..6159571 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -379,25 +379,13 @@ static int sys_mknodat(int dirfd, const char *pathname, 
mode_t mode,
 }
 #endif
 #ifdef TARGET_NR_openat
-static int sys_openat(int dirfd, const char *pathname, int flags, ...)
+static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode)
 {
   /*
* open(2) has extra parameter 'mode' when called with
* flag O_CREAT.
*/
   if ((flags  O_CREAT) != 0) {
-  va_list ap;
-  mode_t mode;
-
-  /*
-   * Get the 'mode' parameter and translate it to
-   * host bits.
-   */
-  va_start(ap, flags);
-  mode = va_arg(ap, mode_t);
-  mode = target_to_host_bitmask(mode, fcntl_flags_tbl);
-  va_end(ap);
-
   return (openat(dirfd, pathname, flags, mode));
   }
   return (openat(dirfd, pathname, flags));
-- 
1.7.5.4




[Qemu-devel] QEMU 1.0 test day - November 7th

2011-10-27 Thread Paolo Bonzini

Hi all,

QEMU 1.0 test day will be held on November 7th.  Any kind of testing 
that you can contribute will be appreciated---including testing your 
favorite hypervisor, desktop virtualization or management stack together 
with the new release.


You are also welcome to add testing hints at 
http://wiki.qemu.org/Planning/1.0/Testing for people to try out.


People participating in the test day should also:

- hang out if possible on the QEMU IRC channel (irc.oftc.org, #qemu)

- record the results of their testing at 
http://wiki.qemu.org/Planning/1.0/Testing


Regards,

Paolo



[Qemu-devel] [PATCH 02/10] linux-user: fix rlimit syscalls on sparc(64)

2011-10-27 Thread riku . voipio
From: Matthias Braun ma...@braunis.de

Signed-off-by: Matthias Braun ma...@braunis.de
Signed-off-by: Riku Voipio riku.voi...@iki.fi
---
 linux-user/syscall_defs.h |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 1bc54c7..5fd4c9c 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -687,7 +687,7 @@ struct target_rlimit {
 
 #if defined(TARGET_ALPHA)
 #define TARGET_RLIM_INFINITY   0x7fffull
-#elif defined(TARGET_MIPS) || defined(TARGET_SPARC)
+#elif defined(TARGET_MIPS) || (defined(TARGET_SPARC)  TARGET_ABI_BITS == 32)
 #define TARGET_RLIM_INFINITY   0x7fffUL
 #else
 #define TARGET_RLIM_INFINITY   ((abi_ulong)-1)
@@ -716,8 +716,13 @@ struct target_rlimit {
 #define TARGET_RLIMIT_STACK3
 #define TARGET_RLIMIT_CORE 4
 #define TARGET_RLIMIT_RSS  5
+#if defined(TARGET_SPARC)
+#define TARGET_RLIMIT_NOFILE   6
+#define TARGET_RLIMIT_NPROC7
+#else
 #define TARGET_RLIMIT_NPROC6
 #define TARGET_RLIMIT_NOFILE   7
+#endif
 #define TARGET_RLIMIT_MEMLOCK  8
 #define TARGET_RLIMIT_AS   9
 #define TARGET_RLIMIT_LOCKS10
-- 
1.7.5.4




Re: [Qemu-devel] ping Re: [PATCH 0/6] misc vvfat fixes

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 13:46, schrieb Paolo Bonzini:
 On 10/05/2011 09:12 AM, Paolo Bonzini wrote:
 It occurred to me that, if there's one thing vvfat ought to be good
 at, it is creating disk images with qemu-img convert (a driver disk
 in my case).

 It turns out the use case is really broken.  qemu-img doesn't
 complete at all, the resulting images often do not pass fsck,
 and it's impossible to create a 1.44 MB disk image.  This
 series fixes all of the small problems I found.

 Coding standard in this file is such a pain that I hardly bothered
 about it.


 Paolo Bonzini (6):
vvfat: fix out of bounds array_get usage
vvfat: do not fail if the disk has spare sectors
vvfat: need to use first_sectors_number to distinguish fdd/hdd
vvfat: unify and correct computation of sector count
vvfat: do not hardcode sector counts in error message
vvfat: reorganize computation of disk geometry

   block/vvfat.c |   50 --
   3 files changed, 26 insertions(+), 28 deletions(-)

 
 ping?

Looked at it a week or two ago, didn't immediately understand the first
patch and decided that there's more important stuff for 1.0...

Not sure what to do with it. The subject clearly says fixes, so it
should qualify for 1.0, but someone must review it.

Kevin



[Qemu-devel] [PATCH 4/6] Revert kvm: support TSC deadline MSR

2011-10-27 Thread Marcelo Tosatti
This reverts commit bfc2455ddbb41148494a084d15777e6bed7533c3.
New patch with subsections will follow.

Signed-off-by: Marcelo Tosatti mtosa...@redhat.com
---
 target-i386/cpu.h |4 +---
 target-i386/kvm.c |   14 --
 target-i386/machine.c |1 -
 3 files changed, 1 insertions(+), 18 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index a973f2e..ae36489 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -283,7 +283,6 @@
 #define MSR_IA32_APICBASE_BSP   (18)
 #define MSR_IA32_APICBASE_ENABLE(111)
 #define MSR_IA32_APICBASE_BASE  (0xf12)
-#define MSR_IA32_TSCDEADLINE0x6e0
 
 #define MSR_MTRRcap0xfe
 #define MSR_MTRRcap_VCNT   8
@@ -688,7 +687,6 @@ typedef struct CPUX86State {
 uint64_t async_pf_en_msr;
 
 uint64_t tsc;
-uint64_t tsc_deadline;
 
 uint64_t mcg_status;
 
@@ -949,7 +947,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define cpu_list_id x86_cpu_list
 #define cpudef_setup   x86_cpudef_setup
 
-#define CPU_SAVE_VERSION 13
+#define CPU_SAVE_VERSION 12
 
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 90a6ffb..b6eef04 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -59,7 +59,6 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 
 static bool has_msr_star;
 static bool has_msr_hsave_pa;
-static bool has_msr_tsc_deadline;
 static bool has_msr_async_pf_en;
 static int lm_capable_kernel;
 
@@ -569,10 +568,6 @@ static int kvm_get_supported_msrs(KVMState *s)
 has_msr_hsave_pa = true;
 continue;
 }
-if (kvm_msr_list-indices[i] == MSR_IA32_TSCDEADLINE) {
-has_msr_tsc_deadline = true;
-continue;
-}
 }
 }
 
@@ -886,9 +881,6 @@ static int kvm_put_msrs(CPUState *env, int level)
 if (has_msr_hsave_pa) {
 kvm_msr_entry_set(msrs[n++], MSR_VM_HSAVE_PA, env-vm_hsave);
 }
-if (has_msr_tsc_deadline) {
-kvm_msr_entry_set(msrs[n++], MSR_IA32_TSCDEADLINE, env-tsc_deadline);
-}
 #ifdef TARGET_X86_64
 if (lm_capable_kernel) {
 kvm_msr_entry_set(msrs[n++], MSR_CSTAR, env-cstar);
@@ -1135,9 +1127,6 @@ static int kvm_get_msrs(CPUState *env)
 if (has_msr_hsave_pa) {
 msrs[n++].index = MSR_VM_HSAVE_PA;
 }
-if (has_msr_tsc_deadline) {
-msrs[n++].index = MSR_IA32_TSCDEADLINE;
-}
 
 if (!env-tsc_valid) {
 msrs[n++].index = MSR_IA32_TSC;
@@ -1206,9 +1195,6 @@ static int kvm_get_msrs(CPUState *env)
 case MSR_IA32_TSC:
 env-tsc = msrs[i].data;
 break;
-case MSR_IA32_TSCDEADLINE:
-env-tsc_deadline = msrs[i].data;
-break;
 case MSR_VM_HSAVE_PA:
 env-vm_hsave = msrs[i].data;
 break;
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 25fa97d..9aca8e0 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -410,7 +410,6 @@ static const VMStateDescription vmstate_cpu = {
 VMSTATE_UINT64_V(xcr0, CPUState, 12),
 VMSTATE_UINT64_V(xstate_bv, CPUState, 12),
 VMSTATE_YMMH_REGS_VARS(ymmh_regs, CPUState, CPU_NB_REGS, 12),
-VMSTATE_UINT64_V(tsc_deadline, CPUState, 13),
 VMSTATE_END_OF_LIST()
 /* The above list is not sorted /wrt version numbers, watch out! */
 },
-- 
1.7.5.4




[Qemu-devel] [PATCH 00/10] Linux-user patches for 1.0

2011-10-27 Thread riku . voipio
From: Riku Voipio riku.voi...@linaro.org

Fixes related linux-user qemu targetting 1.0. please ping
If I have missed any.

Patches are also available in the git repository at:

  git://git.linaro.org/people/rikuvoipio/qemu.git linux-user-for-upstream

Alexander Graf (2):
  linux-user: fix openat
  linux-user: implement reboot syscall

Matthias Braun (3):
  linux-user: fix TARGET_RLIM_INFINITY declaration
  linux-user: fix rlimit syscalls on sparc(64)
  linux-user: fix abi_(u)long, target_ulong mismatch

Richard Henderson (5):
  sparc-linux-user: Handle SIGILL.
  sparc-linux-user: Fixup sending SIGSEGV
  sparc-linux-user: Add some missing syscall numbers
  ppc64-linux-user: Properly interpret the entry function descriptor.
  ppc64-linux-user: Fix syscall return type.

 linux-user/elfload.c  |8 +-
 linux-user/main.c |   26 ++--
 linux-user/qemu-types.h   |   12 ++
 linux-user/signal.c   |   22 ++--
 linux-user/sparc/syscall_nr.h |3 +
 linux-user/strace.c   |4 +-
 linux-user/syscall.c  |  272 -
 linux-user/syscall_defs.h |   17 ++-
 linux-user/vm86.c |4 +-
 9 files changed, 193 insertions(+), 175 deletions(-)

-- 
1.7.5.4




[Qemu-devel] [PATCH 09/10] ppc64-linux-user: Properly interpret the entry function descriptor.

2011-10-27 Thread riku . voipio
From: Richard Henderson r...@twiddle.net

Don't confuse the load address with the load bias.  They're equal
for ET_DYN objects (i.e. ld.so) but different for ET_EXEC objects
(i.e. statically linked).

Signed-off-by: Richard Henderson r...@twiddle.net
Signed-off-by: Riku Voipio riku.voi...@linaro.org
---
 linux-user/elfload.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 8677bba..a413976 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -618,8 +618,8 @@ static inline void init_thread(struct target_pt_regs 
*_regs, struct image_info *
 {
 _regs-gpr[1] = infop-start_stack;
 #if defined(TARGET_PPC64)  !defined(TARGET_ABI32)
-_regs-gpr[2] = ldq_raw(infop-entry + 8) + infop-load_addr;
-infop-entry = ldq_raw(infop-entry) + infop-load_addr;
+_regs-gpr[2] = ldq_raw(infop-entry + 8) + infop-load_bias;
+infop-entry = ldq_raw(infop-entry) + infop-load_bias;
 #endif
 _regs-nip = infop-entry;
 }
@@ -1884,11 +1884,11 @@ int load_elf_binary(struct linux_binprm * bprm, struct 
target_pt_regs * regs,
 info-start_stack = bprm-p;
 
 /* If we have an interpreter, set that as the program's entry point.
-   Copy the load_addr as well, to help PPC64 interpret the entry
+   Copy the load_bias as well, to help PPC64 interpret the entry
point as a function descriptor.  Do this after creating elf tables
so that we copy the original program entry point into the AUXV.  */
 if (elf_interpreter) {
-info-load_addr = interp_info.load_addr;
+info-load_bias = interp_info.load_bias;
 info-entry = interp_info.entry;
 free(elf_interpreter);
 }
-- 
1.7.5.4




[Qemu-devel] [PATCH 08/10] sparc-linux-user: Add some missing syscall numbers

2011-10-27 Thread riku . voipio
From: Richard Henderson r...@twiddle.net

Signed-off-by: Richard Henderson r...@twiddle.net
Signed-off-by: Riku Voipio riku.voi...@iki.fi
---
 linux-user/sparc/syscall_nr.h |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/linux-user/sparc/syscall_nr.h b/linux-user/sparc/syscall_nr.h
index be503f2..f201f9f 100644
--- a/linux-user/sparc/syscall_nr.h
+++ b/linux-user/sparc/syscall_nr.h
@@ -136,6 +136,7 @@
 #define TARGET_NR_utimes 138 /* SunOS Specific 
 */
 #define TARGET_NR_stat64   139 /* Linux sparc32 Specific   
   */
 #define TARGET_NR_getpeername141 /* Common 
 */
+#define TARGET_NR_futex  142 /* gethostid under SunOS  
 */
 #define TARGET_NR_gettid 143 /* ENOSYS under SunOS 
 */
 #define TARGET_NR_getrlimit  144 /* Common 
 */
 #define TARGET_NR_setrlimit  145 /* Common 
 */
@@ -153,6 +154,7 @@
 #define TARGET_NR_getdomainname  162 /* SunOS Specific 
 */
 #define TARGET_NR_setdomainname  163 /* Common 
 */
 #define TARGET_NR_quotactl   165 /* Common 
 */
+#define TARGET_NR_set_tid_address166 /* Linux specific, exportfs under 
SunOS*/
 #define TARGET_NR_mount  167 /* Common 
 */
 #define TARGET_NR_ustat  168 /* Common 
 */
 #define TARGET_NR_getdents   174 /* Common 
 */
@@ -177,6 +179,7 @@
 #define TARGET_NR_readahead  205 /* Linux Specific 
 */
 #define TARGET_NR_socketcall 206 /* Linux Specific 
 */
 #define TARGET_NR_syslog 207 /* Linux Specific 
 */
+#define TARGET_NR_tgkill 211 /* Linux Specific 
 */
 #define TARGET_NR_waitpid212 /* Linux Specific 
 */
 #define TARGET_NR_swapoff213 /* Linux Specific 
 */
 #define TARGET_NR_sysinfo214 /* Linux Specific 
 */
-- 
1.7.5.4




[Qemu-devel] [PATCH 03/10] linux-user: fix abi_(u)long, target_ulong mismatch

2011-10-27 Thread riku . voipio
From: Matthias Braun ma...@braunis.de

abi_(u)long might be different from target_ulong, so don't use tswapl
but introduce a new tswapal

Signed-off-by: Matthias Braun ma...@braunis.de
Signed-off-by: Riku Voipio riku.voi...@iki.fi
---
 linux-user/qemu-types.h   |   12 ++
 linux-user/signal.c   |   22 ++--
 linux-user/strace.c   |4 +-
 linux-user/syscall.c  |  250 +++--
 linux-user/syscall_defs.h |8 +-
 linux-user/vm86.c |4 +-
 6 files changed, 157 insertions(+), 143 deletions(-)

diff --git a/linux-user/qemu-types.h b/linux-user/qemu-types.h
index 1adda9f..fe7f662 100644
--- a/linux-user/qemu-types.h
+++ b/linux-user/qemu-types.h
@@ -9,6 +9,12 @@ typedef int32_t abi_long;
 #define TARGET_ABI_FMT_ld %d
 #define TARGET_ABI_FMT_lu %u
 #define TARGET_ABI_BITS 32
+
+static inline abi_ulong tswapal(abi_ulong v)
+{
+return tswap32(v);
+}
+
 #else
 typedef target_ulong abi_ulong;
 typedef target_long abi_long;
@@ -20,5 +26,11 @@ typedef target_long abi_long;
 #if TARGET_ABI_BITS == 32
 #define TARGET_ABI32 1
 #endif
+
+static inline abi_ulong tswapal(abi_ulong v)
+{
+return tswapl(v);
+}
+
 #endif
 #endif
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 40c5eb1..e4addcd 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -152,7 +152,7 @@ void host_to_target_sigset(target_sigset_t *d, const 
sigset_t *s)
 
 host_to_target_sigset_internal(d1, s);
 for(i = 0;i  TARGET_NSIG_WORDS; i++)
-d-sig[i] = tswapl(d1.sig[i]);
+d-sig[i] = tswapal(d1.sig[i]);
 }
 
 static void target_to_host_sigset_internal(sigset_t *d,
@@ -173,7 +173,7 @@ void target_to_host_sigset(sigset_t *d, const 
target_sigset_t *s)
 int i;
 
 for(i = 0;i  TARGET_NSIG_WORDS; i++)
-s1.sig[i] = tswapl(s-sig[i]);
+s1.sig[i] = tswapal(s-sig[i]);
 target_to_host_sigset_internal(d, s1);
 }
 
@@ -234,14 +234,14 @@ static void tswap_siginfo(target_siginfo_t *tinfo,
 if (sig == SIGILL || sig == SIGFPE || sig == SIGSEGV ||
 sig == SIGBUS || sig == SIGTRAP) {
 tinfo-_sifields._sigfault._addr =
-tswapl(info-_sifields._sigfault._addr);
+tswapal(info-_sifields._sigfault._addr);
 } else if (sig == SIGIO) {
tinfo-_sifields._sigpoll._fd = tswap32(info-_sifields._sigpoll._fd);
 } else if (sig = TARGET_SIGRTMIN) {
 tinfo-_sifields._rt._pid = tswap32(info-_sifields._rt._pid);
 tinfo-_sifields._rt._uid = tswap32(info-_sifields._rt._uid);
 tinfo-_sifields._rt._sigval.sival_ptr =
-tswapl(info-_sifields._rt._sigval.sival_ptr);
+tswapal(info-_sifields._rt._sigval.sival_ptr);
 }
 }
 
@@ -262,7 +262,7 @@ void target_to_host_siginfo(siginfo_t *info, const 
target_siginfo_t *tinfo)
 info-si_pid = tswap32(tinfo-_sifields._rt._pid);
 info-si_uid = tswap32(tinfo-_sifields._rt._uid);
 info-si_value.sival_ptr =
-(void *)(long)tswapl(tinfo-_sifields._rt._sigval.sival_ptr);
+(void *)(long)tswapal(tinfo-_sifields._rt._sigval.sival_ptr);
 }
 
 static int fatal_signal (int sig)
@@ -586,19 +586,19 @@ int do_sigaction(int sig, const struct target_sigaction 
*act,
 sig, act, oact);
 #endif
 if (oact) {
-oact-_sa_handler = tswapl(k-_sa_handler);
-oact-sa_flags = tswapl(k-sa_flags);
+oact-_sa_handler = tswapal(k-_sa_handler);
+oact-sa_flags = tswapal(k-sa_flags);
 #if !defined(TARGET_MIPS)
-oact-sa_restorer = tswapl(k-sa_restorer);
+oact-sa_restorer = tswapal(k-sa_restorer);
 #endif
 oact-sa_mask = k-sa_mask;
 }
 if (act) {
 /* FIXME: This is not threadsafe.  */
-k-_sa_handler = tswapl(act-_sa_handler);
-k-sa_flags = tswapl(act-sa_flags);
+k-_sa_handler = tswapal(act-_sa_handler);
+k-sa_flags = tswapal(act-sa_flags);
 #if !defined(TARGET_MIPS)
-k-sa_restorer = tswapl(act-sa_restorer);
+k-sa_restorer = tswapal(act-sa_restorer);
 #endif
 k-sa_mask = act-sa_mask;
 
diff --git a/linux-user/strace.c b/linux-user/strace.c
index fe9326a..90027a1 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -169,7 +169,7 @@ print_fdset(int n, abi_ulong target_fds_addr)
 return;
 
 for (i=n; i=0; i--) {
-if ((tswapl(target_fds[i / TARGET_ABI_BITS])  (i  
(TARGET_ABI_BITS - 1)))  1)
+if ((tswapal(target_fds[i / TARGET_ABI_BITS])  (i  
(TARGET_ABI_BITS - 1)))  1)
 gemu_log(%d,, i );
 }
 unlock_user(target_fds, target_fds_addr, 0);
@@ -245,7 +245,7 @@ print_execve(const struct syscallname *name,
arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
 if (!arg_ptr)
 return;
-   arg_addr = tswapl(*arg_ptr);
+arg_addr = tswapal(*arg_ptr);
unlock_user(arg_ptr, arg_ptr_addr, 0);
 if (!arg_addr)
 break;
diff --git 

[Qemu-devel] [PATCH 05/10] linux-user: implement reboot syscall

2011-10-27 Thread riku . voipio
From: Alexander Graf ag...@suse.de

For OBS, we're running a full cross-guest inside of a VM. When a build
is done there, we reboot the guest as shutdown mechanism.

Unfortunately, reboot is not implemented in linux-user. So this mechanism
fails, spilling unpretty warnings. This patch implements sys_reboot()
emulation.

Signed-off-by: Alexander Graf ag...@suse.de
Signed-off-by: Riku Voipio riku.voi...@iki.fi
---
 linux-user/syscall.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6159571..9f5da36 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -248,6 +248,8 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned 
int, len,
 #define __NR_sys_sched_setaffinity __NR_sched_setaffinity
 _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len,
   unsigned long *, user_mask_ptr);
+_syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd,
+  void *, arg);
 
 static bitmask_transtbl fcntl_flags_tbl[] = {
   { TARGET_O_ACCMODE,   TARGET_O_WRONLY,O_ACCMODE,   O_WRONLY,},
@@ -5872,7 +5874,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 break;
 #endif
 case TARGET_NR_reboot:
-goto unimplemented;
+if (!(p = lock_user_string(arg4)))
+goto efault;
+ret = reboot(arg1, arg2, arg3, p);
+unlock_user(p, arg4, 0);
+break;
 #ifdef TARGET_NR_readdir
 case TARGET_NR_readdir:
 goto unimplemented;
-- 
1.7.5.4




Re: [Qemu-devel] [PATCH 1/1 V6 resent ] qemu-kvm: fix improper nmi emulation

2011-10-27 Thread Marcelo Tosatti
On Tue, Oct 25, 2011 at 05:55:28PM +0800, Lai Jiangshan wrote:
 Previous discussions:
  
   Which approach you prefer to?
   I need to know the result before wasting too much time to respin
   the approach.
   
   Yes, sorry about the slow and sometimes conflicting feedback.
   
   1) Fix KVM_NMI emulation approach  (which is v3 patchset)
   - It directly fixes the problem and matches the
 real hard ware more, but it changes KVM_NMI bahavior.
   - Require both kernel-site and userspace-site fix.
  
   2) Get the LAPIC state from kernel irqchip, and inject NMI if it is 
   allowed
  (which is v4 patchset)
   - Simple, don't changes any kernel behavior.
   - Only need the userspace-site fix
  
   3) Add KVM_SET_LINT1 approach (which is v5 patchset)
   - don't changes the kernel's KVM_NMI behavior.
   - much complex
   - Require both kernel-site and userspace-site fix.
   - userspace-site should also handle the !KVM_SET_LINT1
 condition, it uses all the 2) approach' code. it means
 this approach equals the 2) approach + KVM_SET_LINT1 ioctl.
  
   This is an urgent bug of us, we need to settle it down soo
   
   While (1) is simple, it overloads a single ioctl with two meanings,
   that's not so good.
   
   Whether we do (1) or (3), we need (2) as well, for older kernels.
   
   So I recommend first focusing on (2) and merging it, then doing (3).
   
   (note an additional issue with 3 is whether to make it a vm or vcpu
   ioctl - we've been assuming vcpu ioctl but it's not necessarily the best
   choice).
   
 It is the 2) approach.
 It only changes the user space site, the kernel site is not touched.
 It is changed from previous v4 patch, fixed problems found by Jan.
 end previous discussions
 
 
 From: Lai Jiangshan la...@cn.fujitsu.com
 
 
 Currently, NMI interrupt is blindly sent to all the vCPUs when NMI
 button event happens. This doesn't properly emulate real hardware on
 which NMI button event triggers LINT1. Because of this, NMI is sent to
 the processor even when LINT1 is maskied in LVT. For example, this
 causes the problem that kdump initiated by NMI sometimes doesn't work
 on KVM, because kdump assumes NMI is masked on CPUs other than CPU0.
 
 With this patch, inject-nmi request is handled as follows.
 
 - When in-kernel irqchip is disabled, deliver LINT1 instead of NMI
   interrupt.
 - When in-kernel irqchip is enabled, get the in-kernel LAPIC states
   and test the APIC_LVT_MASKED, if LINT1 is unmasked, and then
   delivering the NMI directly. (Suggested by Jan Kiszka)
 
 Changed from old version:
   re-implement it by the Jan's suggestion.
   fix the race found by Jan.
 
 Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com
 Reported-by: Kenji Kaneshige kaneshige.ke...@jp.fujitsu.com
 Acked-by: Avi Kivity a...@redhat.com
 Acked-by: Jan Kiszka jan.kis...@web.de

Please rebase.




Re: [Qemu-devel] about NPIV with qemu-kvm.

2011-10-27 Thread ya su
hi, hannes

  I really appreciate your clarify of my daze.

  as to improve vm's storage io perfomance as nearly hardware's,
it seems the only way is something like sr-iov by hba card.  NPIV can
not achieve this goal.

  I remember that LSI released some kind SAS controller(IR 2008?)
which support sr-iov , but there is not any document which describes
the steps to config. I wonder if your have any clues to help? thanks.

Regards.

Suya.

2011/10/26, Hannes Reinecke h...@suse.de:
 On 10/26/2011 06:40 AM, ya su wrote:
 hi, hannes:

 I want to use NPIV with qemu-kvm, I issued the following command:

 echo ':' 
 /sys/class/fc_host/host0/vport_create

 and it will produce a new host6 and one vport succesfully, but it
 does not create any virtual hba pci device. so I don't know how to
 assign the virtual host to qemu-kvm.

 Well, you can't. There is no mechanism for. When using NPIV you need
 to pass in the individual LUNs via eg virtio-blk.

 from your this mail, does array will first need to assign a lun to
 this vport? and through this new created disk, like device /dev/sdf,
 then I add qemu-kvm with -drive file=/dev/sdf,if=virtio... arguments?

 Yes. That's what you need to do.

 Cheers,

 Hannes
 --
 Dr. Hannes Reinecke  zSeries  Storage
 h...@suse.de  +49 911 74053 688
 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
 GF: Markus Rex, HRB 16746 (AG Nürnberg)




[Qemu-devel] Assigning a new virtio block device (-drive)

2011-10-27 Thread Leib, David
Hi,
I am trying to assign a new virtio block device in addition to a normal virtio 
block device who are accessing exactly the same cdrom drive (/dev/sr0) 
because I additionaly want to access the block device in my way by manually 
calling the virtqueue_pop and virtqueue_push and not the normal way they are 
called.
At the kvm startup I am assigning this additional qemu rblock device in the 
vm_config_groups by adding a new QemuOptsList:

static QemuOptsList qemu_ablock_opts = {
.name = ablock,
.head = QTAILQ_HEAD_INITIALIZER(qemu_ablock_opts.head),
.desc = {
. normal options like the original virtio block 
device .
{ /* end of list */ }
},
};

and insert the same data like the normal virtio block device (file=/dev/sr0 
and if=virtio) in qemu_config.c.
After that I am calling the normal drive_init_func  (vl.c) with this command :

qemu_opts_foreach(qemu_find_opts(ablock), drive_init_func, 
machine-use_scsi, 1);

I also added PCIDeviceInfo to the virtio_info array who looks like this:
{
.qdev.name = additional_blk_pci,
.qdev.alias = additional-blk,
.qdev.size = sizeof(VirtIOPCIProxy),
.init  = virtio_blk_init_pci_additional,
.exit  = virtio_blk_exit_pci,
.vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
.device_id = PCI_DEVICE_ID_VIRTIO_BLOCK,
.revision  = VIRTIO_PCI_ABI_VERSION,
.class_id  = PCI_CLASS_STORAGE_SCSI,
.qdev.props = (Property[]) {
DEFINE_PROP_HEX32(class, VirtIOPCIProxy, class_code, 
0),
DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy, block),
DEFINE_PROP_STRING(serial, VirtIOPCIProxy, 
block_serial),
DEFINE_PROP_BIT(ioeventfd, VirtIOPCIProxy, flags,

VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
DEFINE_PROP_UINT32(vectors, VirtIOPCIProxy, nvectors, 
2),
DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, 
host_features),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
},
It is completely the same like the normal virtio-blk-pci except the .init 
function that I replaced with my own init-function.
My problem now is that this init-function is never called when I am starting up 
the kvm. It only calling the the init-function of virtio-blk-pci two times 
and my PCIDeviceInfo init-function is completely ignored.
The initialisation of all virtio_info's in virtio-pci.c works fine but my 
init-function is never used.
I tried to initialise only my additional-virtio-blk-pci device but is still 
calling the init-function from virtio-blk-pci.
I hope somebody can give me idea where the problem is.
Many thanks,


David Leib
SAP Research Belfast
SAP (UK) Limited   I   The Concourse   I   Queen's Road   I   Queen's Island   
I   Belfast BT3 9DT

mailto: david.l...@sap.commailto:mary.cla...@sap.com  I   
www.sap.com/researchhttp://www.sap.com/research

--
This communication contains information which is confidential and may also be 
privileged. It is for the exclusive use of the addressee. If you are not the 
addressee please contact us immediately and also delete the communication from 
your computer. Steps have been taken to ensure this e-mail is free from 
computer viruses but the recipient is responsible for ensuring that it is 
actually virus free before opening it or any attachments. Any views and/or 
opinions expressed in this e-mail are of the author only and do not represent 
the views of SAP.

SAP (UK) Limited, Registered in England No. 2152073. Registered Office: 
Clockhouse Place, Bedfont Road, Feltham, Middlesex, TW14 8HD
---





Re: [Qemu-devel] ping Re: [PATCH 0/6] misc vvfat fixes

2011-10-27 Thread Paolo Bonzini

On 10/27/2011 02:38 PM, Kevin Wolf wrote:

Am 27.10.2011 13:46, schrieb Paolo Bonzini:

On 10/05/2011 09:12 AM, Paolo Bonzini wrote:

It occurred to me that, if there's one thing vvfat ought to be good
at, it is creating disk images with qemu-img convert (a driver disk
in my case).

It turns out the use case is really broken.  qemu-img doesn't
complete at all, the resulting images often do not pass fsck,
and it's impossible to create a 1.44 MB disk image.  This
series fixes all of the small problems I found.

Coding standard in this file is such a pain that I hardly bothered
about it.


Paolo Bonzini (6):
vvfat: fix out of bounds array_get usage
vvfat: do not fail if the disk has spare sectors the
vvfat: need to use first_sectors_number to distinguish fdd/hdd
vvfat: unify and correct computation of sector count
vvfat: do not hardcode sector counts in error message
vvfat: reorganize computation of disk geometry

   block/vvfat.c |   50 --
   3 files changed, 26 insertions(+), 28 deletions(-)



ping?


Looked at it a week or two ago, didn't immediately understand the first
patch and decided that there's more important stuff for 1.0...


Yeah.  It can probably go in during the freeze.

Regarding the first patch, we simply fail this assert:

static inline void* array_get(array_t* array,unsigned int index) {
assert(index  array-next);
return array-pointer + index * array-item_size;
}

so you need to first set s-directory.next like array_get_next does.

Paolo



Re: [Qemu-devel] [PATCH v2 2/3] darwin-user/main.c: Drop unused cpu_single_env definition

2011-10-27 Thread Andreas Färber
Am 27.10.2011 13:37, schrieb Peter Maydell:
 From: Paolo Bonzini pbonz...@redhat.com
 
 Drop the cpu_single_env definition as it is unused.
 
 Signed-off-by: Paolo Bonzini pbonz...@redhat.com

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

 ---
  darwin-user/main.c |2 --
  1 files changed, 0 insertions(+), 2 deletions(-)
 
 diff --git a/darwin-user/main.c b/darwin-user/main.c
 index 1a881a0..c0f14f8 100644
 --- a/darwin-user/main.c
 +++ b/darwin-user/main.c
 @@ -729,8 +729,6 @@ static void usage(void)
  
  /* XXX: currently only used for async signals (see signal.c) */
  CPUState *global_env;
 -/* used only if single thread */
 -CPUState *cpu_single_env = NULL;
  
  /* used to free thread contexts */
  TaskState *first_task_state;


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



Re: [Qemu-devel] [PATCH v2] block: avoid SIGUSR2

2011-10-27 Thread Kevin Wolf
Am 19.09.2011 16:37, schrieb Frediano Ziglio:
 Now that iothread is always compiled sending a signal seems only an
 additional step. This patch also avoid writing to two pipe (one from signal
 and one in qemu_service_io).
 
 Work with kvm enabled or disabled. strace output is more readable (less 
 syscalls).
 
 Signed-off-by: Frediano Ziglio fredd...@gmail.com

Something in this change has bad effects, in the sense that it seems to
break bdrv_read_em.

To be precise, what I'm testing is booting from a DOS installation
floppy (interestingly, on my laptop it just works, but on my other test
box it fails). The first attempt of git bisect pointed at the commit
where we converted bdrv_read/write to coroutines.

However, it turned out that the conversion commit only caused problems
because instead of using a synchronous read() it now goes through
posix-aio-compat.c. The problem is reproducible in pre-coroutine
versions by just commenting out .bdrv_read/.bdrv_write in raw-posix.

Going back a bit more showed that this did work fine a while ago, and
the removal of SIGUSR2 is the first commit in which bdrv_read_em didn't
provide the same behaviour as bdrv_read any more.

I have no idea yet what's really going wrong, but maybe it rings a bell
for one of you?

Kevin

 ---
  cpus.c |5 -
  posix-aio-compat.c |   29 +
  2 files changed, 9 insertions(+), 25 deletions(-)
 
 diff --git a/cpus.c b/cpus.c
 index 54c188c..d0cfe91 100644
 --- a/cpus.c
 +++ b/cpus.c
 @@ -380,11 +380,6 @@ static int qemu_signal_init(void)
  int sigfd;
  sigset_t set;
  
 -/* SIGUSR2 used by posix-aio-compat.c */
 -sigemptyset(set);
 -sigaddset(set, SIGUSR2);
 -pthread_sigmask(SIG_UNBLOCK, set, NULL);
 -
  /*
   * SIG_IPI must be blocked in the main thread and must not be caught
   * by sigwait() in the signal thread. Otherwise, the cpu thread will
 diff --git a/posix-aio-compat.c b/posix-aio-compat.c
 index 3193dbf..185d5b2 100644
 --- a/posix-aio-compat.c
 +++ b/posix-aio-compat.c
 @@ -42,7 +42,6 @@ struct qemu_paiocb {
  int aio_niov;
  size_t aio_nbytes;
  #define aio_ioctl_cmd   aio_nbytes /* for QEMU_AIO_IOCTL */
 -int ev_signo;
  off_t aio_offset;
  
  QTAILQ_ENTRY(qemu_paiocb) node;
 @@ -309,6 +308,8 @@ static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb)
  return nbytes;
  }
  
 +static void posix_aio_notify_event(void);
 +
  static void *aio_thread(void *unused)
  {
  pid_t pid;
 @@ -381,7 +382,7 @@ static void *aio_thread(void *unused)
  aiocb-ret = ret;
  mutex_unlock(lock);
  
 -if (kill(pid, aiocb-ev_signo)) die(kill failed);
 +posix_aio_notify_event();
  }
  
  cur_threads--;
 @@ -548,18 +549,14 @@ static int posix_aio_flush(void *opaque)
  
  static PosixAioState *posix_aio_state;
  
 -static void aio_signal_handler(int signum)
 +static void posix_aio_notify_event(void)
  {
 -if (posix_aio_state) {
 -char byte = 0;
 -ssize_t ret;
 -
 -ret = write(posix_aio_state-wfd, byte, sizeof(byte));
 -if (ret  0  errno != EAGAIN)
 -die(write());
 -}
 +char byte = 0;
 +ssize_t ret;
  
 -qemu_service_io();
 +ret = write(posix_aio_state-wfd, byte, sizeof(byte));
 +if (ret  0  errno != EAGAIN)
 +die(write());
  }
  
  static void paio_remove(struct qemu_paiocb *acb)
 @@ -623,7 +620,6 @@ BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int 
 fd,
  return NULL;
  acb-aio_type = type;
  acb-aio_fildes = fd;
 -acb-ev_signo = SIGUSR2;
  
  if (qiov) {
  acb-aio_iov = qiov-iov;
 @@ -651,7 +647,6 @@ BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
  return NULL;
  acb-aio_type = QEMU_AIO_IOCTL;
  acb-aio_fildes = fd;
 -acb-ev_signo = SIGUSR2;
  acb-aio_offset = 0;
  acb-aio_ioctl_buf = buf;
  acb-aio_ioctl_cmd = req;
 @@ -665,7 +660,6 @@ BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
  
  int paio_init(void)
  {
 -struct sigaction act;
  PosixAioState *s;
  int fds[2];
  int ret;
 @@ -675,11 +669,6 @@ int paio_init(void)
  
  s = g_malloc(sizeof(PosixAioState));
  
 -sigfillset(act.sa_mask);
 -act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
 -act.sa_handler = aio_signal_handler;
 -sigaction(SIGUSR2, act, NULL);
 -
  s-first_aio = NULL;
  if (qemu_pipe(fds) == -1) {
  fprintf(stderr, failed to create pipe\n);




Re: [Qemu-devel] ping Re: [PATCH 0/6] misc vvfat fixes

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 15:10, schrieb Paolo Bonzini:
 On 10/27/2011 02:38 PM, Kevin Wolf wrote:
 Am 27.10.2011 13:46, schrieb Paolo Bonzini:
 On 10/05/2011 09:12 AM, Paolo Bonzini wrote:
 It occurred to me that, if there's one thing vvfat ought to be good
 at, it is creating disk images with qemu-img convert (a driver disk
 in my case).

 It turns out the use case is really broken.  qemu-img doesn't
 complete at all, the resulting images often do not pass fsck,
 and it's impossible to create a 1.44 MB disk image.  This
 series fixes all of the small problems I found.

 Coding standard in this file is such a pain that I hardly bothered
 about it.


 Paolo Bonzini (6):
 vvfat: fix out of bounds array_get usage
 vvfat: do not fail if the disk has spare sectors the
 vvfat: need to use first_sectors_number to distinguish fdd/hdd
 vvfat: unify and correct computation of sector count
 vvfat: do not hardcode sector counts in error message
 vvfat: reorganize computation of disk geometry

block/vvfat.c |   50 --
3 files changed, 26 insertions(+), 28 deletions(-)


 ping?

 Looked at it a week or two ago, didn't immediately understand the first
 patch and decided that there's more important stuff for 1.0...
 
 Yeah.  It can probably go in during the freeze.
 
 Regarding the first patch, we simply fail this assert:
 
 static inline void* array_get(array_t* array,unsigned int index) {
  assert(index  array-next);
  return array-pointer + index * array-item_size;
 }
 
 so you need to first set s-directory.next like array_get_next does.

So is this combination of array_ensure_allocated(), setting
s-directory.next and memset() basically an open-coded array_set_size()
that initialises new elements with zeros?

Kevin



Re: [Qemu-devel] [PATCH v2] block: avoid SIGUSR2

2011-10-27 Thread Stefan Hajnoczi
On Thu, Oct 27, 2011 at 03:26:23PM +0200, Kevin Wolf wrote:
 Am 19.09.2011 16:37, schrieb Frediano Ziglio:
  Now that iothread is always compiled sending a signal seems only an
  additional step. This patch also avoid writing to two pipe (one from signal
  and one in qemu_service_io).
  
  Work with kvm enabled or disabled. strace output is more readable (less 
  syscalls).
  
  Signed-off-by: Frediano Ziglio fredd...@gmail.com
 
 Something in this change has bad effects, in the sense that it seems to
 break bdrv_read_em.

How does it break bdrv_read_em?  Are you seeing QEMU hung with 100% CPU
utilization or deadlocked?

One interesting thing is that qemu_aio_wait() does not release the QEMU
mutex, so we cannot write to a pipe with the mutex held and then spin
waiting for the iothread to do work for us.

Exactly how kill and qemu_notify_event() were different I'm not sure
right now but it could be a factor.

Stefan



Re: [Qemu-devel] [PATCH] Documentation: Describe NBD URL syntax

2011-10-27 Thread Eric Sunshine

On Oct 27, 2011, at 5:33 AM, Ronnie Sahlberg wrote:

This patch adds a short description of how to specify a NBD device
to QEMU.
Syntax for both TCP and Unix Domain Sockets are provided as well
as examples.

Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com
---
qemu-options.hx |   21 +
1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 7c434f8..564ae3f 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1757,6 +1757,27 @@ qemu --drive file=iscsi://192.0.2.1/iqn. 
2001-04.com.example/1

iSCSI support is an optional feature of QEMU and only available when
compiled and linked against libiscsi.

+@item NBD
+QEMU supports NBD (Network Block Devices) both using TCP protocol  
as well

+as Unix Domain Sockets.
+
+Syntax for specifying a NDB device using TCP
+``nbd:server-ip:port[:exportname=export]''
+
+Syntax for specifying a NDB device using Unix Domain Sockets
+``nbd:unix:domain-socket[:exportname=export]''


On the two Syntax for... lines: s/NDB/NBD/

-- ES




Re: [Qemu-devel] [PATCH v2] block: avoid SIGUSR2

2011-10-27 Thread Kevin Wolf
Am 27.10.2011 15:57, schrieb Stefan Hajnoczi:
 On Thu, Oct 27, 2011 at 03:26:23PM +0200, Kevin Wolf wrote:
 Am 19.09.2011 16:37, schrieb Frediano Ziglio:
 Now that iothread is always compiled sending a signal seems only an
 additional step. This patch also avoid writing to two pipe (one from signal
 and one in qemu_service_io).

 Work with kvm enabled or disabled. strace output is more readable (less 
 syscalls).

 Signed-off-by: Frediano Ziglio fredd...@gmail.com

 Something in this change has bad effects, in the sense that it seems to
 break bdrv_read_em.
 
 How does it break bdrv_read_em?  Are you seeing QEMU hung with 100% CPU
 utilization or deadlocked?

Sorry, I should have been more detailed here.

No, it's nothing obvious, it must be some subtle side effect. The result
of bdrv_read_em itself seems to be correct (return value and checksum of
the read buffer).

However instead of booting into the DOS setup I only get an error
message Kein System oder Laufwerksfehler (don't know how it reads in
English DOS versions), which seems to be produced by the boot sector.

I excluded all of the minor changes, so I'm sure that it's caused by the
switch from kill() to a direct call of the function that writes into the
pipe.

 One interesting thing is that qemu_aio_wait() does not release the QEMU
 mutex, so we cannot write to a pipe with the mutex held and then spin
 waiting for the iothread to do work for us.
 
 Exactly how kill and qemu_notify_event() were different I'm not sure
 right now but it could be a factor.

This would cause a hang, right? Then it isn't what I'm seeing.

Kevin



  1   2   >