* [Qemu-devel] [PULL 00/17] Block patches
@ 2013-10-29 16:30 Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 01/17] qapi: fix documentation example Kevin Wolf
` (16 more replies)
0 siblings, 17 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:30 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
The following changes since commit fc8ead74674b7129e8f31c2595c76658e5622197:
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging (2013-10-18 10:03:24 -0700)
are available in the git repository at:
git://repo.or.cz/qemu/kevin.git tags/for-anthony
for you to fetch changes up to a7cf03d4e150abec88f5837461242dc8a0eee189:
qemu-iotests: Fix 051 reference output (2013-10-29 17:05:35 +0100)
----------------------------------------------------------------
Block patches for 1.7.0-rc0
----------------------------------------------------------------
Alexander Graf (1):
ahci: fix win7 hang on boot
Eric Blake (1):
qapi: fix documentation example
Kevin Wolf (5):
exec: Fix bounce buffer allocation in address_space_map()
ide-test: Check what happens with bus mastering disabled
tests: Multiboot mmap test case
block: Avoid unecessary drv->bdrv_getlength() calls
qemu-iotests: Fix 051 reference output
Liu Yuan (2):
sheepdog: explicitly set copies as type uint8_t
sheepdog: pass copy_policy in the request
Max Reitz (5):
qcow2: Restore total_sectors value in save_vmstate
qcow2: Unset zero_beyond_eof in save_vmstate
qemu-iotests: Test for loading VM state from qcow2
qcow2: Flush image after creation
block: Don't copy backing file name on error
Peter Lieven (2):
qemu-img: add special exit code if bdrv_check is not supported
block/vpc: check that the image has not been truncated
Thibaut LAURENT (1):
block: Disable BDRV_O_COPY_ON_READ for the backing file
block.c | 14 +++--
block/qcow2.c | 19 ++++++
block/raw-posix.c | 9 ++-
block/raw-win32.c | 4 +-
block/raw_bsd.c | 1 +
block/sheepdog.c | 30 ++++++----
block/vpc.c | 7 +++
docs/qapi-code-gen.txt | 2 +-
exec.c | 4 +-
hw/ide/ahci.c | 3 +-
include/block/block_int.h | 3 +
qemu-img.c | 2 +-
tests/ide-test.c | 26 +++++++++
tests/multiboot/Makefile | 18 ++++++
tests/multiboot/libc.c | 139 ++++++++++++++++++++++++++++++++++++++++++++
tests/multiboot/libc.h | 61 +++++++++++++++++++
tests/multiboot/link.ld | 19 ++++++
tests/multiboot/mmap.c | 56 ++++++++++++++++++
tests/multiboot/mmap.out | 93 +++++++++++++++++++++++++++++
tests/multiboot/multiboot.h | 66 +++++++++++++++++++++
tests/multiboot/run_test.sh | 81 ++++++++++++++++++++++++++
tests/multiboot/start.S | 51 ++++++++++++++++
tests/qemu-iotests/051.out | 2 +-
tests/qemu-iotests/068 | 65 +++++++++++++++++++++
tests/qemu-iotests/068.out | 11 ++++
tests/qemu-iotests/group | 1 +
26 files changed, 761 insertions(+), 26 deletions(-)
create mode 100644 tests/multiboot/Makefile
create mode 100644 tests/multiboot/libc.c
create mode 100644 tests/multiboot/libc.h
create mode 100644 tests/multiboot/link.ld
create mode 100644 tests/multiboot/mmap.c
create mode 100644 tests/multiboot/mmap.out
create mode 100644 tests/multiboot/multiboot.h
create mode 100755 tests/multiboot/run_test.sh
create mode 100644 tests/multiboot/start.S
create mode 100755 tests/qemu-iotests/068
create mode 100644 tests/qemu-iotests/068.out
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 01/17] qapi: fix documentation example
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
@ 2013-10-29 16:30 ` Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 02/17] qcow2: Restore total_sectors value in save_vmstate Kevin Wolf
` (15 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:30 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Eric Blake <eblake@redhat.com>
The QMP wire format uses "", not '', around strings.
* docs/qapi-code-gen.txt: Fix typo.
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
docs/qapi-code-gen.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt
index 91f44d0..0728f36 100644
--- a/docs/qapi-code-gen.txt
+++ b/docs/qapi-code-gen.txt
@@ -164,7 +164,7 @@ This example allows using both of the following example objects:
{ "file": "my_existing_block_device_id" }
{ "file": { "driver": "file",
"readonly": false,
- 'filename': "/tmp/mydisk.qcow2" } }
+ "filename": "/tmp/mydisk.qcow2" } }
=== Commands ===
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 02/17] qcow2: Restore total_sectors value in save_vmstate
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 01/17] qapi: fix documentation example Kevin Wolf
@ 2013-10-29 16:30 ` Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 03/17] qcow2: Unset zero_beyond_eof " Kevin Wolf
` (14 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:30 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Max Reitz <mreitz@redhat.com>
Since df2a6f29a5, bdrv_co_do_writev increases the total_sectors value of
a growable block devices on writes after the current end. This leads to
the virtual disk apparently growing in qcow2_save_vmstate, which in turn
affects the disk size captured by the internal snapshot taken directly
afterwards through e.g. the HMP savevm command. Such a "grown" snapshot
cannot be loaded after reopening the qcow2 image, since its disk size
differs from the actual virtual disk size (writing a VM state does not
actually increase the virtual disk size).
Fix this by restoring total_sectors at the end of qcow2_save_vmstate.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qcow2.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index c1abaff..4a3e8b4 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1939,6 +1939,7 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
int64_t pos)
{
BDRVQcowState *s = bs->opaque;
+ int64_t total_sectors = bs->total_sectors;
int growable = bs->growable;
int ret;
@@ -1947,6 +1948,11 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);
bs->growable = growable;
+ /* bdrv_co_do_writev will have increased the total_sectors value to include
+ * the VM state - the VM state is however not an actual part of the block
+ * device, therefore, we need to restore the old value. */
+ bs->total_sectors = total_sectors;
+
return ret;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 03/17] qcow2: Unset zero_beyond_eof in save_vmstate
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 01/17] qapi: fix documentation example Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 02/17] qcow2: Restore total_sectors value in save_vmstate Kevin Wolf
@ 2013-10-29 16:30 ` Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 04/17] qemu-img: add special exit code if bdrv_check is not supported Kevin Wolf
` (13 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:30 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Max Reitz <mreitz@redhat.com>
Saving the VM state is done using bdrv_pwrite. This function may perform
a read-modify-write, which in this case results in data being read from
beyond the end of the virtual disk. Since we are actually trying to
access an area which is not a part of the virtual disk, zero_beyond_eof
has to be set to false before performing the partial write, otherwise
the VM state may become corrupted.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qcow2.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index 4a3e8b4..01269f9 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1941,12 +1941,15 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
BDRVQcowState *s = bs->opaque;
int64_t total_sectors = bs->total_sectors;
int growable = bs->growable;
+ bool zero_beyond_eof = bs->zero_beyond_eof;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
bs->growable = 1;
+ bs->zero_beyond_eof = false;
ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);
bs->growable = growable;
+ bs->zero_beyond_eof = zero_beyond_eof;
/* bdrv_co_do_writev will have increased the total_sectors value to include
* the VM state - the VM state is however not an actual part of the block
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 04/17] qemu-img: add special exit code if bdrv_check is not supported
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (2 preceding siblings ...)
2013-10-29 16:30 ` [Qemu-devel] [PULL 03/17] qcow2: Unset zero_beyond_eof " Kevin Wolf
@ 2013-10-29 16:30 ` Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 05/17] block/vpc: check that the image has not been truncated Kevin Wolf
` (12 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:30 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Peter Lieven <pl@kamp.de>
currently it is not possible to distinguish by exitcode if there
has been an error or if bdrv_check is not supported by the image
format. Change the exitcode from 1 to 63 for the latter case.
Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-img.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
index 926f0a0..bf3fb4f 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -607,7 +607,7 @@ static int img_check(int argc, char **argv)
if (output_format == OFORMAT_HUMAN) {
error_report("This image format does not support checks");
}
- ret = 1;
+ ret = 63;
goto fail;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 05/17] block/vpc: check that the image has not been truncated
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (3 preceding siblings ...)
2013-10-29 16:30 ` [Qemu-devel] [PULL 04/17] qemu-img: add special exit code if bdrv_check is not supported Kevin Wolf
@ 2013-10-29 16:30 ` Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 06/17] qemu-iotests: Test for loading VM state from qcow2 Kevin Wolf
` (11 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:30 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Peter Lieven <pl@kamp.de>
this adds a check that a dynamic VHD file has not been
accidently truncated (e.g. during transfer or upload).
Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/vpc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/block/vpc.c b/block/vpc.c
index b5dca39..627d11c 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -260,6 +260,13 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
}
}
+ if (s->free_data_block_offset > bdrv_getlength(bs->file)) {
+ error_setg(errp, "block-vpc: free_data_block_offset points after "
+ "the end of file. The image has been truncated.");
+ ret = -EINVAL;
+ goto fail;
+ }
+
s->last_bitmap_offset = (int64_t) -1;
#ifdef CACHE
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 06/17] qemu-iotests: Test for loading VM state from qcow2
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (4 preceding siblings ...)
2013-10-29 16:30 ` [Qemu-devel] [PULL 05/17] block/vpc: check that the image has not been truncated Kevin Wolf
@ 2013-10-29 16:30 ` Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 07/17] qcow2: Flush image after creation Kevin Wolf
` (10 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:30 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Max Reitz <mreitz@redhat.com>
Add a test for saving a VM state from a qcow2 image and loading it back
(with having restarted qemu in between); this should work without any
problems.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/068 | 65 ++++++++++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/068.out | 11 ++++++++
tests/qemu-iotests/group | 1 +
3 files changed, 77 insertions(+)
create mode 100755 tests/qemu-iotests/068
create mode 100644 tests/qemu-iotests/068.out
diff --git a/tests/qemu-iotests/068 b/tests/qemu-iotests/068
new file mode 100755
index 0000000..b72e555
--- /dev/null
+++ b/tests/qemu-iotests/068
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+# Test case for loading a saved VM state from a qcow2 image
+#
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+# creator
+owner=mreitz@redhat.com
+
+seq="$(basename $0)"
+echo "QA output created by $seq"
+
+here="$PWD"
+tmp=/tmp/$$
+status=1 # failure is the default!
+
+_cleanup()
+{
+ _cleanup_test_img
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# This tests qocw2-specific low-level functionality
+_supported_fmt qcow2
+_supported_proto generic
+_supported_os Linux
+
+IMGOPTS="compat=1.1"
+IMG_SIZE=128K
+
+echo
+echo "=== Saving and reloading a VM state to/from a qcow2 image ==="
+echo
+_make_test_img $IMG_SIZE
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' |\
+ $QEMU -nographic -monitor stdio -serial none -hda "$TEST_IMG" |\
+ _filter_qemu
+# Now try to continue from that VM state (this should just work)
+echo quit |\
+ $QEMU -nographic -monitor stdio -serial none -hda "$TEST_IMG" -loadvm 0 |\
+ _filter_qemu
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
diff --git a/tests/qemu-iotests/068.out b/tests/qemu-iotests/068.out
new file mode 100644
index 0000000..abe35a9
--- /dev/null
+++ b/tests/qemu-iotests/068.out
@@ -0,0 +1,11 @@
+QA output created by 068
+
+=== Saving and reloading a VM state to/from a qcow2 image ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) s^[[K^[[Dsa^[[K^[[D^[[Dsav^[[K^[[D^[[D^[[Dsave^[[K^[[D^[[D^[[D^[[Dsavev^[[K^[[D^[[D^[[D^[[D^[[Dsavevm^[[K^[[D^[[D^[[D^[[D^[[D^[[Dsavevm ^[[K^[[D^[[D^[[D^[[D^[[D^[[D^[[Dsavevm 0^[[K
+(qemu) q^[[K^[[Dqu^[[K^[[D^[[Dqui^[[K^[[D^[[D^[[Dquit^[[K
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) q^[[K^[[Dqu^[[K^[[D^[[Dqui^[[K^[[D^[[D^[[Dquit^[[K
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 13c5500..3ca9cba 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -73,3 +73,4 @@
065 rw auto
066 rw auto
067 rw auto
+068 rw auto
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 07/17] qcow2: Flush image after creation
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (5 preceding siblings ...)
2013-10-29 16:30 ` [Qemu-devel] [PULL 06/17] qemu-iotests: Test for loading VM state from qcow2 Kevin Wolf
@ 2013-10-29 16:30 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 08/17] exec: Fix bounce buffer allocation in address_space_map() Kevin Wolf
` (9 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:30 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Max Reitz <mreitz@redhat.com>
Opening the qcow2 image with BDRV_O_NO_FLUSH prevents any flushes during
the image creation. This means that the image has not yet been flushed
to disk when qemu-img create exits. This flush is delayed until the next
operation on the image involving opening it without BDRV_O_NO_FLUSH and
closing (or directly flushing) it. For large images and/or images with a
small cluster size and preallocated metadata, this flush may take a
significant amount of time and may occur unexpectedly.
Reopening the image without BDRV_O_NO_FLUSH right before the end of
qcow2_create2() results in hoisting the potentially costly flush into
the image creation, which is expected to take some time (whereas
successive image operations may be not).
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qcow2.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index 01269f9..6e5d98d 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1584,6 +1584,16 @@ static int qcow2_create2(const char *filename, int64_t total_size,
}
}
+ bdrv_close(bs);
+
+ /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
+ ret = bdrv_open(bs, filename, NULL,
+ BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
+ if (error_is_set(&local_err)) {
+ error_propagate(errp, local_err);
+ goto out;
+ }
+
ret = 0;
out:
bdrv_unref(bs);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 08/17] exec: Fix bounce buffer allocation in address_space_map()
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (6 preceding siblings ...)
2013-10-29 16:30 ` [Qemu-devel] [PULL 07/17] qcow2: Flush image after creation Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 09/17] ide-test: Check what happens with bus mastering disabled Kevin Wolf
` (8 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
This fixes a regression introduced by commit e3127ae0c, which kept the
allocation size of the bounce buffer limited to one page in order to
avoid unbounded allocations (as explained in the commit message of
6d16c2f88), but broke the reporting of the shortened bounce buffer to
the caller. The caller therefore assumes that the full requested size
was provided and causes memory corruption when writing beyond the end of
the actually allocated buffer.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
exec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/exec.c b/exec.c
index 2e31ffc..b453713 100644
--- a/exec.c
+++ b/exec.c
@@ -2099,7 +2099,9 @@ void *address_space_map(AddressSpace *as,
if (bounce.buffer) {
return NULL;
}
- bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE);
+ /* Avoid unbounded allocations */
+ l = MIN(l, TARGET_PAGE_SIZE);
+ bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, l);
bounce.addr = addr;
bounce.len = l;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 09/17] ide-test: Check what happens with bus mastering disabled
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (7 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 08/17] exec: Fix bounce buffer allocation in address_space_map() Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 10/17] tests: Multiboot mmap test case Kevin Wolf
` (7 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
The main goal is that qemu doesn't crash.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/ide-test.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/tests/ide-test.c b/tests/ide-test.c
index 7307f1d..bc824a8 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -81,6 +81,7 @@ enum {
CMD_IDENTIFY = 0xec,
CMDF_ABORT = 0x100,
+ CMDF_NO_BM = 0x200,
};
enum {
@@ -192,6 +193,11 @@ static int send_dma_request(int cmd, uint64_t sector, int nb_sectors,
g_assert_not_reached();
}
+ if (flags & CMDF_NO_BM) {
+ qpci_config_writew(dev, PCI_COMMAND,
+ PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
+ }
+
/* Select device 0 */
outb(IDE_BASE + reg_device, 0 | LBA);
@@ -352,6 +358,25 @@ static void test_bmdma_long_prdt(void)
assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR);
}
+static void test_bmdma_no_busmaster(void)
+{
+ uint8_t status;
+
+ /* No PRDT_EOT, each entry addr 0/size 64k, and in theory qemu shouldn't be
+ * able to access it anyway because the Bus Master bit in the PCI command
+ * register isn't set. This is complete nonsense, but it used to be pretty
+ * good at confusing and occasionally crashing qemu. */
+ PrdtEntry prdt[4096] = { };
+
+ status = send_dma_request(CMD_READ_DMA | CMDF_NO_BM, 0, 512,
+ prdt, ARRAY_SIZE(prdt));
+
+ /* Not entirely clear what the expected result is, but this is what we get
+ * in practice. At least we want to be aware of any changes. */
+ g_assert_cmphex(status, ==, BM_STS_ACTIVE | BM_STS_INTR);
+ assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR);
+}
+
static void test_bmdma_setup(void)
{
ide_test_start(
@@ -493,6 +518,7 @@ int main(int argc, char **argv)
qtest_add_func("/ide/bmdma/simple_rw", test_bmdma_simple_rw);
qtest_add_func("/ide/bmdma/short_prdt", test_bmdma_short_prdt);
qtest_add_func("/ide/bmdma/long_prdt", test_bmdma_long_prdt);
+ qtest_add_func("/ide/bmdma/no_busmaster", test_bmdma_no_busmaster);
qtest_add_func("/ide/bmdma/teardown", test_bmdma_teardown);
qtest_add_func("/ide/flush", test_flush);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 10/17] tests: Multiboot mmap test case
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (8 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 09/17] ide-test: Check what happens with bus mastering disabled Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 11/17] block: Don't copy backing file name on error Kevin Wolf
` (6 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
This adds a test case for Multiboot memory map in the tests/multiboot
directory, where future i386 test kernels can be dropped. Because this
requires an x86 build host and an installed 32 bit libgcc, the test is
not part of a regular 'make check'.
The reference output for the test is verified against test runs of the
same multiboot kernel booted by some GRUB 0.97.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/multiboot/Makefile | 18 ++++++
tests/multiboot/libc.c | 139 ++++++++++++++++++++++++++++++++++++++++++++
tests/multiboot/libc.h | 61 +++++++++++++++++++
tests/multiboot/link.ld | 19 ++++++
tests/multiboot/mmap.c | 56 ++++++++++++++++++
tests/multiboot/mmap.out | 93 +++++++++++++++++++++++++++++
tests/multiboot/multiboot.h | 66 +++++++++++++++++++++
tests/multiboot/run_test.sh | 81 ++++++++++++++++++++++++++
tests/multiboot/start.S | 51 ++++++++++++++++
9 files changed, 584 insertions(+)
create mode 100644 tests/multiboot/Makefile
create mode 100644 tests/multiboot/libc.c
create mode 100644 tests/multiboot/libc.h
create mode 100644 tests/multiboot/link.ld
create mode 100644 tests/multiboot/mmap.c
create mode 100644 tests/multiboot/mmap.out
create mode 100644 tests/multiboot/multiboot.h
create mode 100755 tests/multiboot/run_test.sh
create mode 100644 tests/multiboot/start.S
diff --git a/tests/multiboot/Makefile b/tests/multiboot/Makefile
new file mode 100644
index 0000000..34cdd81
--- /dev/null
+++ b/tests/multiboot/Makefile
@@ -0,0 +1,18 @@
+CC=gcc
+CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc -fno-builtin
+ASFLAGS=-m32
+
+LD=ld
+LDFLAGS=-melf_i386 -T link.ld
+LIBS=$(shell $(CC) $(CCFLAGS) -print-libgcc-file-name)
+
+all: mmap.elf
+
+mmap.elf: start.o mmap.o libc.o
+ $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+%.o: %.c
+ $(CC) $(CCFLAGS) -c -o $@ $^
+
+%.o: %.S
+ $(CC) $(ASFLAGS) -c -o $@ $^
diff --git a/tests/multiboot/libc.c b/tests/multiboot/libc.c
new file mode 100644
index 0000000..05abbd9
--- /dev/null
+++ b/tests/multiboot/libc.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "libc.h"
+
+static void print_char(char c)
+{
+ outb(0xe9, c);
+}
+
+static void print_str(char *s)
+{
+ while (*s) {
+ print_char(*s++);
+ }
+}
+
+static void print_num(uint64_t value, int base)
+{
+ char digits[] = "0123456789abcdef";
+ char buf[32] = { 0 };
+ int i = sizeof(buf) - 2;
+
+ do {
+ buf[i--] = digits[value % base];
+ value /= base;
+ } while (value);
+
+ print_str(&buf[i + 1]);
+}
+
+void printf(const char *fmt, ...)
+{
+ va_list ap;
+ uint64_t val;
+ char *str;
+ int base;
+ int has_long;
+ int alt_form;
+
+ va_start(ap, fmt);
+
+ for (; *fmt; fmt++) {
+ if (*fmt != '%') {
+ print_char(*fmt);
+ continue;
+ }
+ fmt++;
+
+ if (*fmt == '#') {
+ fmt++;
+ alt_form = 1;
+ } else {
+ alt_form = 0;
+ }
+
+ if (*fmt == 'l') {
+ fmt++;
+ if (*fmt == 'l') {
+ fmt++;
+ has_long = 2;
+ } else {
+ has_long = 1;
+ }
+ } else {
+ has_long = 0;
+ }
+
+ switch (*fmt) {
+ case 'x':
+ case 'p':
+ base = 16;
+ goto convert_number;
+ case 'd':
+ case 'i':
+ case 'u':
+ base = 10;
+ goto convert_number;
+ case 'o':
+ base = 8;
+ goto convert_number;
+
+ convert_number:
+ switch (has_long) {
+ case 0:
+ val = va_arg(ap, unsigned int);
+ break;
+ case 1:
+ val = va_arg(ap, unsigned long);
+ break;
+ case 2:
+ val = va_arg(ap, unsigned long long);
+ break;
+ }
+
+ if (alt_form && base == 16) {
+ print_str("0x");
+ }
+
+ print_num(val, base);
+ break;
+
+ case 's':
+ str = va_arg(ap, char*);
+ print_str(str);
+ break;
+ case '%':
+ print_char(*fmt);
+ break;
+ default:
+ print_char('%');
+ print_char(*fmt);
+ break;
+ }
+ }
+
+ va_end(ap);
+}
+
+
diff --git a/tests/multiboot/libc.h b/tests/multiboot/libc.h
new file mode 100644
index 0000000..80eec5b
--- /dev/null
+++ b/tests/multiboot/libc.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef LIBC_H
+#define LIBC_H
+
+/* Integer types */
+
+typedef unsigned long long uint64_t;
+typedef unsigned int uint32_t;
+typedef unsigned short uint16_t;
+typedef unsigned char uint8_t;
+
+typedef signed long long int64_t;
+typedef signed int int32_t;
+typedef signed short int16_t;
+typedef signed char int8_t;
+
+typedef uint32_t uintptr_t;
+
+
+/* stdarg.h */
+
+typedef __builtin_va_list va_list;
+#define va_start(ap, X) __builtin_va_start(ap, X)
+#define va_arg(ap, type) __builtin_va_arg(ap, type)
+#define va_end(ap) __builtin_va_end(ap)
+
+
+/* Port I/O functions */
+
+static inline void outb(uint16_t port, uint8_t data)
+{
+ asm volatile ("outb %0, %1" : : "a" (data), "Nd" (port));
+}
+
+
+/* Misc functions */
+
+void printf(const char *fmt, ...);
+
+#endif
diff --git a/tests/multiboot/link.ld b/tests/multiboot/link.ld
new file mode 100644
index 0000000..3d49b58
--- /dev/null
+++ b/tests/multiboot/link.ld
@@ -0,0 +1,19 @@
+ENTRY(_start)
+
+SECTIONS
+{
+ . = 0x100000;
+ .text : {
+ *(multiboot)
+ *(.text)
+ }
+ .data ALIGN(4096) : {
+ *(.data)
+ }
+ .rodata ALIGN(4096) : {
+ *(.rodata)
+ }
+ .bss ALIGN(4096) : {
+ *(.bss)
+ }
+}
diff --git a/tests/multiboot/mmap.c b/tests/multiboot/mmap.c
new file mode 100644
index 0000000..766b003
--- /dev/null
+++ b/tests/multiboot/mmap.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "libc.h"
+#include "multiboot.h"
+
+int test_main(uint32_t magic, struct mb_info *mbi)
+{
+ uintptr_t entry_addr;
+ struct mb_mmap_entry *entry;
+
+ (void) magic;
+
+ printf("Lower memory: %dk\n", mbi->mem_lower);
+ printf("Upper memory: %dk\n", mbi->mem_upper);
+
+ printf("\ne820 memory map:\n");
+
+ for (entry_addr = mbi->mmap_addr;
+ entry_addr < mbi->mmap_addr + mbi->mmap_length;
+ entry_addr += entry->size + 4)
+ {
+ entry = (struct mb_mmap_entry*) entry_addr;
+
+ printf("%#llx - %#llx: type %d [entry size: %d]\n",
+ entry->base_addr,
+ entry->base_addr + entry->length,
+ entry->type,
+ entry->size);
+ }
+
+ printf("\nmmap start: %#x\n", mbi->mmap_addr);
+ printf("mmap end: %#x\n", mbi->mmap_addr + mbi->mmap_length);
+ printf("real mmap end: %#x\n", entry_addr);
+
+ return 0;
+}
diff --git a/tests/multiboot/mmap.out b/tests/multiboot/mmap.out
new file mode 100644
index 0000000..e70b6eb
--- /dev/null
+++ b/tests/multiboot/mmap.out
@@ -0,0 +1,93 @@
+
+
+
+=== Running test case: mmap.elf ===
+
+Lower memory: 639k
+Upper memory: 130040k
+
+e820 memory map:
+0x0 - 0x9fc00: type 1 [entry size: 20]
+0x9fc00 - 0xa0000: type 2 [entry size: 20]
+0xf0000 - 0x100000: type 2 [entry size: 20]
+0x100000 - 0x7ffe000: type 1 [entry size: 20]
+0x7ffe000 - 0x8000000: type 2 [entry size: 20]
+0xfffc0000 - 0x100000000: type 2 [entry size: 20]
+
+mmap start: 0x9000
+mmap end: 0x9090
+real mmap end: 0x9090
+
+
+=== Running test case: mmap.elf -m 1.1M ===
+
+Lower memory: 639k
+Upper memory: 96k
+
+e820 memory map:
+0x0 - 0x9fc00: type 1 [entry size: 20]
+0x9fc00 - 0xa0000: type 2 [entry size: 20]
+0xf0000 - 0x100000: type 2 [entry size: 20]
+0x100000 - 0x118000: type 1 [entry size: 20]
+0x118000 - 0x11a000: type 2 [entry size: 20]
+0xfffc0000 - 0x100000000: type 2 [entry size: 20]
+
+mmap start: 0x9000
+mmap end: 0x9090
+real mmap end: 0x9090
+
+
+=== Running test case: mmap.elf -m 2G ===
+
+Lower memory: 639k
+Upper memory: 2096120k
+
+e820 memory map:
+0x0 - 0x9fc00: type 1 [entry size: 20]
+0x9fc00 - 0xa0000: type 2 [entry size: 20]
+0xf0000 - 0x100000: type 2 [entry size: 20]
+0x100000 - 0x7fffe000: type 1 [entry size: 20]
+0x7fffe000 - 0x80000000: type 2 [entry size: 20]
+0xfffc0000 - 0x100000000: type 2 [entry size: 20]
+
+mmap start: 0x9000
+mmap end: 0x9090
+real mmap end: 0x9090
+
+
+=== Running test case: mmap.elf -m 4G ===
+
+Lower memory: 639k
+Upper memory: 3668984k
+
+e820 memory map:
+0x0 - 0x9fc00: type 1 [entry size: 20]
+0x9fc00 - 0xa0000: type 2 [entry size: 20]
+0xf0000 - 0x100000: type 2 [entry size: 20]
+0x100000 - 0xdfffe000: type 1 [entry size: 20]
+0xdfffe000 - 0xe0000000: type 2 [entry size: 20]
+0xfffc0000 - 0x100000000: type 2 [entry size: 20]
+0x100000000 - 0x120000000: type 1 [entry size: 20]
+
+mmap start: 0x9000
+mmap end: 0x90a8
+real mmap end: 0x90a8
+
+
+=== Running test case: mmap.elf -m 8G ===
+
+Lower memory: 639k
+Upper memory: 3668984k
+
+e820 memory map:
+0x0 - 0x9fc00: type 1 [entry size: 20]
+0x9fc00 - 0xa0000: type 2 [entry size: 20]
+0xf0000 - 0x100000: type 2 [entry size: 20]
+0x100000 - 0xdfffe000: type 1 [entry size: 20]
+0xdfffe000 - 0xe0000000: type 2 [entry size: 20]
+0xfffc0000 - 0x100000000: type 2 [entry size: 20]
+0x100000000 - 0x220000000: type 1 [entry size: 20]
+
+mmap start: 0x9000
+mmap end: 0x90a8
+real mmap end: 0x90a8
diff --git a/tests/multiboot/multiboot.h b/tests/multiboot/multiboot.h
new file mode 100644
index 0000000..4eb1fbe
--- /dev/null
+++ b/tests/multiboot/multiboot.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MULTIBOOT_H
+#define MULTIBOOT_H
+
+#include "libc.h"
+
+struct mb_info {
+ uint32_t flags;
+ uint32_t mem_lower;
+ uint32_t mem_upper;
+ uint32_t boot_device;
+ uint32_t cmdline;
+ uint32_t mods_count;
+ uint32_t mods_addr;
+ char syms[16];
+ uint32_t mmap_length;
+ uint32_t mmap_addr;
+ uint32_t drives_length;
+ uint32_t drives_addr;
+ uint32_t config_table;
+ uint32_t boot_loader_name;
+ uint32_t apm_table;
+ uint32_t vbe_control_info;
+ uint32_t vbe_mode_info;
+ uint16_t vbe_mode;
+ uint16_t vbe_interface_seg;
+ uint16_t vbe_interface_off;
+ uint16_t vbe_interface_len;
+} __attribute__((packed));
+
+struct mb_module {
+ uint32_t mod_start;
+ uint32_t mod_end;
+ uint32_t string;
+ uint32_t reserved;
+} __attribute__((packed));
+
+struct mb_mmap_entry {
+ uint32_t size;
+ uint64_t base_addr;
+ uint64_t length;
+ uint32_t type;
+} __attribute__((packed));
+
+#endif
diff --git a/tests/multiboot/run_test.sh b/tests/multiboot/run_test.sh
new file mode 100755
index 0000000..97a9a49
--- /dev/null
+++ b/tests/multiboot/run_test.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+# Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+QEMU=${QEMU:-"../../x86_64-softmmu/qemu-system-x86_64"}
+
+run_qemu() {
+ local kernel=$1
+ shift
+
+ echo -e "\n\n=== Running test case: $kernel $@ ===\n" >> test.log
+
+ $QEMU \
+ -kernel $kernel \
+ -display none \
+ -device isa-debugcon,chardev=stdio \
+ -chardev file,path=test.out,id=stdio \
+ -device isa-debug-exit,iobase=0xf4,iosize=0x4 \
+ "$@"
+ ret=$?
+
+ cat test.out >> test.log
+}
+
+mmap() {
+ run_qemu mmap.elf
+ run_qemu mmap.elf -m 1.1M
+ run_qemu mmap.elf -m 2G
+ run_qemu mmap.elf -m 4G
+ run_qemu mmap.elf -m 8G
+}
+
+
+make all
+
+for t in mmap; do
+
+ echo > test.log
+ $t
+
+ debugexit=$((ret & 0x1))
+ ret=$((ret >> 1))
+ pass=1
+
+ if [ $debugexit != 1 ]; then
+ echo -e "\e[31m ?? \e[0m $t (no debugexit used, exit code $ret)"
+ pass=0
+ elif [ $ret != 0 ]; then
+ echo -e "\e[31mFAIL\e[0m $t (exit code $ret)"
+ pass=0
+ fi
+
+ if ! diff $t.out test.log > /dev/null 2>&1; then
+ echo -e "\e[31mFAIL\e[0m $t (output difference)"
+ diff -u $t.out test.log
+ pass=0
+ fi
+
+ if [ $pass == 1 ]; then
+ echo -e "\e[32mPASS\e[0m $t"
+ fi
+
+done
diff --git a/tests/multiboot/start.S b/tests/multiboot/start.S
new file mode 100644
index 0000000..7d33959
--- /dev/null
+++ b/tests/multiboot/start.S
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+.section multiboot
+
+#define MB_MAGIC 0x1badb002
+#define MB_FLAGS 0x0
+#define MB_CHECKSUM -(MB_MAGIC + MB_FLAGS)
+
+.align 4
+.int MB_MAGIC
+.int MB_FLAGS
+.int MB_CHECKSUM
+
+.section .text
+.global _start
+_start:
+ mov $stack, %esp
+ push %ebx
+ push %eax
+ call test_main
+
+ /* Test device exit */
+ outl %eax, $0xf4
+
+ cli
+ hlt
+ jmp .
+
+.section bss
+.space 8192
+stack:
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 11/17] block: Don't copy backing file name on error
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (9 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 10/17] tests: Multiboot mmap test case Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 12/17] sheepdog: explicitly set copies as type uint8_t Kevin Wolf
` (5 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Max Reitz <mreitz@redhat.com>
bdrv_open_backing_file() tries to copy the backing file name using
pstrcpy directly after calling bdrv_open() to open the backing file
without checking whether that was actually successful. If it was not,
ps->backing_hd->file will probably be NULL and qemu will crash.
Fix this by moving pstrcpy after checking whether bdrv_open() succeeded.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Amos Kong <kongjianjun@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index fd05a80..366999b 100644
--- a/block.c
+++ b/block.c
@@ -1004,8 +1004,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
ret = bdrv_open(bs->backing_hd,
*backing_filename ? backing_filename : NULL, options,
back_flags, back_drv, &local_err);
- pstrcpy(bs->backing_file, sizeof(bs->backing_file),
- bs->backing_hd->file->filename);
if (ret < 0) {
bdrv_unref(bs->backing_hd);
bs->backing_hd = NULL;
@@ -1013,6 +1011,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
error_propagate(errp, local_err);
return ret;
}
+ pstrcpy(bs->backing_file, sizeof(bs->backing_file),
+ bs->backing_hd->file->filename);
return 0;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 12/17] sheepdog: explicitly set copies as type uint8_t
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (10 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 11/17] block: Don't copy backing file name on error Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 13/17] sheepdog: pass copy_policy in the request Kevin Wolf
` (4 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Liu Yuan <namei.unix@gmail.com>
'copies' is actually uint8_t since day one, but request headers and some helper
functions parameterize it as uint32_t for unknown reasons and effectively
reserve 24 bytes for possible future use. This patch explicitly set the correct
for copies and reserve the left bytes.
This is a preparation patch that allow passing copy_policy in request header.
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Acked-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/sheepdog.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 5f81c93..b8a2985 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -125,8 +125,8 @@ typedef struct SheepdogObjReq {
uint32_t data_length;
uint64_t oid;
uint64_t cow_oid;
- uint32_t copies;
- uint32_t rsvd;
+ uint8_t copies;
+ uint8_t reserved[7];
uint64_t offset;
} SheepdogObjReq;
@@ -138,7 +138,8 @@ typedef struct SheepdogObjRsp {
uint32_t id;
uint32_t data_length;
uint32_t result;
- uint32_t copies;
+ uint8_t copies;
+ uint8_t reserved[3];
uint32_t pad[6];
} SheepdogObjRsp;
@@ -151,7 +152,8 @@ typedef struct SheepdogVdiReq {
uint32_t data_length;
uint64_t vdi_size;
uint32_t vdi_id;
- uint32_t copies;
+ uint8_t copies;
+ uint8_t reserved[3];
uint32_t snapid;
uint32_t pad[3];
} SheepdogVdiReq;
@@ -1081,7 +1083,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
return 0;
}
-static int read_write_object(int fd, char *buf, uint64_t oid, int copies,
+static int read_write_object(int fd, char *buf, uint64_t oid, uint8_t copies,
unsigned int datalen, uint64_t offset,
bool write, bool create, uint32_t cache_flags)
{
@@ -1129,7 +1131,7 @@ static int read_write_object(int fd, char *buf, uint64_t oid, int copies,
}
}
-static int read_object(int fd, char *buf, uint64_t oid, int copies,
+static int read_object(int fd, char *buf, uint64_t oid, uint8_t copies,
unsigned int datalen, uint64_t offset,
uint32_t cache_flags)
{
@@ -1137,7 +1139,7 @@ static int read_object(int fd, char *buf, uint64_t oid, int copies,
false, cache_flags);
}
-static int write_object(int fd, char *buf, uint64_t oid, int copies,
+static int write_object(int fd, char *buf, uint64_t oid, uint8_t copies,
unsigned int datalen, uint64_t offset, bool create,
uint32_t cache_flags)
{
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 13/17] sheepdog: pass copy_policy in the request
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (11 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 12/17] sheepdog: explicitly set copies as type uint8_t Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 14/17] ahci: fix win7 hang on boot Kevin Wolf
` (3 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Liu Yuan <namei.unix@gmail.com>
Currently copy_policy isn't used. Recent sheepdog supports erasure coding, which
make use of copy_policy internally, but require client explicitly passing
copy_policy from base inode to newly creately inode for snapshot related
operations.
If connected sheep daemon doesn't utilize copy_policy, passing it to sheep
daemon is just one extra null effect operation. So no compatibility problem.
With this patch, sheepdog can provide erasure coded volume for QEMU VM.
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Acked-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/sheepdog.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index b8a2985..9f0757b 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -126,7 +126,8 @@ typedef struct SheepdogObjReq {
uint64_t oid;
uint64_t cow_oid;
uint8_t copies;
- uint8_t reserved[7];
+ uint8_t copy_policy;
+ uint8_t reserved[6];
uint64_t offset;
} SheepdogObjReq;
@@ -139,7 +140,8 @@ typedef struct SheepdogObjRsp {
uint32_t data_length;
uint32_t result;
uint8_t copies;
- uint8_t reserved[3];
+ uint8_t copy_policy;
+ uint8_t reserved[2];
uint32_t pad[6];
} SheepdogObjRsp;
@@ -153,7 +155,8 @@ typedef struct SheepdogVdiReq {
uint64_t vdi_size;
uint32_t vdi_id;
uint8_t copies;
- uint8_t reserved[3];
+ uint8_t copy_policy;
+ uint8_t reserved[2];
uint32_t snapid;
uint32_t pad[3];
} SheepdogVdiReq;
@@ -1346,7 +1349,8 @@ out:
}
static int do_sd_create(BDRVSheepdogState *s, char *filename, int64_t vdi_size,
- uint32_t base_vid, uint32_t *vdi_id, int snapshot)
+ uint32_t base_vid, uint32_t *vdi_id, int snapshot,
+ uint8_t copy_policy)
{
SheepdogVdiReq hdr;
SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr;
@@ -1376,6 +1380,7 @@ static int do_sd_create(BDRVSheepdogState *s, char *filename, int64_t vdi_size,
hdr.data_length = wlen;
hdr.vdi_size = vdi_size;
+ hdr.copy_policy = copy_policy;
ret = do_req(fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen);
@@ -1528,7 +1533,8 @@ static int sd_create(const char *filename, QEMUOptionParameter *options,
bdrv_unref(bs);
}
- ret = do_sd_create(s, vdi, vdi_size, base_vid, &vid, 0);
+ /* TODO: allow users to specify copy number */
+ ret = do_sd_create(s, vdi, vdi_size, base_vid, &vid, 0, 0);
if (!prealloc || ret) {
goto out;
}
@@ -1718,7 +1724,7 @@ static int sd_create_branch(BDRVSheepdogState *s)
*/
deleted = sd_delete(s);
ret = do_sd_create(s, s->name, s->inode.vdi_size, s->inode.vdi_id, &vid,
- !deleted);
+ !deleted, s->inode.copy_policy);
if (ret) {
goto out;
}
@@ -2008,7 +2014,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
}
ret = do_sd_create(s, s->name, s->inode.vdi_size, s->inode.vdi_id, &new_vid,
- 1);
+ 1, s->inode.copy_policy);
if (ret < 0) {
error_report("failed to create inode for snapshot. %s",
strerror(errno));
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 14/17] ahci: fix win7 hang on boot
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (12 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 13/17] sheepdog: pass copy_policy in the request Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 15/17] block: Disable BDRV_O_COPY_ON_READ for the backing file Kevin Wolf
` (2 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Alexander Graf <agraf@suse.de>
When AHCI executes an asynchronous IDE command, it checked DRDY without
checking either DRQ or BSY. This sometimes caused interrupt to be sent
before command is actually completed.
This resulted in a race condition: if guest then managed to access the
device before command has completed, it would hang waiting for an
interrupt.
This was observed with windows 7 guests.
To fix, check for DRQ or BSY in additiona to DRDY, if set,
the command is asynchronous so delay the interrupt until
asynchronous done callback is invoked.
Reported-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/ide/ahci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index a8be62c..fbea9e8 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -961,7 +961,8 @@ static int handle_cmd(AHCIState *s, int port, int slot)
/* We're ready to process the command in FIS byte 2. */
ide_exec_cmd(&s->dev[port].port, cmd_fis[2]);
- if (s->dev[port].port.ifs[0].status & READY_STAT) {
+ if ((s->dev[port].port.ifs[0].status & (READY_STAT|DRQ_STAT|BUSY_STAT)) ==
+ READY_STAT) {
ahci_write_fis_d2h(&s->dev[port], cmd_fis);
}
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 15/17] block: Disable BDRV_O_COPY_ON_READ for the backing file
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (13 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 14/17] ahci: fix win7 hang on boot Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 16/17] block: Avoid unecessary drv->bdrv_getlength() calls Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 17/17] qemu-iotests: Fix 051 reference output Kevin Wolf
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Thibaut LAURENT <thibaut.laurent@gmail.com>
Since commit 0ebd24e0a203cf2852c310b59fbe050190dc6c8c,
bdrv_open_common will throw an error when trying to open a file
read-only with the BDRV_O_COPY_ON_READ flag set.
Although BDRV_O_RDWR is unset for the backing files,
BDRV_O_COPY_ON_READ is still passed on if copy-on-read was requested
for the drive. Let's unset this flag too before opening the backing
file, or bdrv_open_common will fail.
Signed-off-by: Thibaut LAURENT <thibaut.laurent@gmail.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 366999b..61795fe 100644
--- a/block.c
+++ b/block.c
@@ -999,7 +999,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
}
/* backing files always opened read-only */
- back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);
+ back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT |
+ BDRV_O_COPY_ON_READ);
ret = bdrv_open(bs->backing_hd,
*backing_filename ? backing_filename : NULL, options,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 16/17] block: Avoid unecessary drv->bdrv_getlength() calls
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (14 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 15/17] block: Disable BDRV_O_COPY_ON_READ for the backing file Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 17/17] qemu-iotests: Fix 051 reference output Kevin Wolf
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
The block layer generally keeps the size of an image cached in
bs->total_sectors so that it doesn't have to perform expensive
operations to get the size whenever it needs it.
This doesn't work however when using a backend that can change its size
without qemu being aware of it, i.e. passthrough of removable media like
CD-ROMs or floppy disks. For this reason, the caching is disabled when a
removable device is used.
It is obvious that checking whether the _guest_ device has removable
media isn't the right thing to do when we want to know whether the size
of the host backend can change. To make things worse, non-top-level
BlockDriverStates never have any device attached, which makes qemu
assume they are removable, so drv->bdrv_getlength() is always called on
the protocol layer. In the case of raw-posix, this causes unnecessary
lseek() system calls, which turned out to be rather expensive.
This patch completely changes the logic and disables bs->total_sectors
caching only for certain block driver types, for which a size change is
expected: host_cdrom and host_floppy on POSIX, host_device on win32; also
the raw format in case it sits on top of one of these protocols, but in
the common case the nested bdrv_getlength() call on the protocol driver
will use the cache again and avoid an expensive drv->bdrv_getlength()
call.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
block.c | 7 ++++---
block/raw-posix.c | 9 ++++++---
block/raw-win32.c | 4 +++-
block/raw_bsd.c | 1 +
include/block/block_int.h | 3 +++
5 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/block.c b/block.c
index 61795fe..58efb5b 100644
--- a/block.c
+++ b/block.c
@@ -2869,9 +2869,10 @@ int64_t bdrv_getlength(BlockDriverState *bs)
if (!drv)
return -ENOMEDIUM;
- if (bdrv_dev_has_removable_media(bs)) {
- if (drv->bdrv_getlength) {
- return drv->bdrv_getlength(bs);
+ if (drv->has_variable_length) {
+ int ret = refresh_total_sectors(bs, bs->total_sectors);
+ if (ret < 0) {
+ return ret;
}
}
return bs->total_sectors * BDRV_SECTOR_SIZE;
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 6f03fbf..f6d48bb 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1715,7 +1715,8 @@ static BlockDriver bdrv_host_floppy = {
.bdrv_aio_flush = raw_aio_flush,
.bdrv_truncate = raw_truncate,
- .bdrv_getlength = raw_getlength,
+ .bdrv_getlength = raw_getlength,
+ .has_variable_length = true,
.bdrv_get_allocated_file_size
= raw_get_allocated_file_size,
@@ -1824,7 +1825,8 @@ static BlockDriver bdrv_host_cdrom = {
.bdrv_aio_flush = raw_aio_flush,
.bdrv_truncate = raw_truncate,
- .bdrv_getlength = raw_getlength,
+ .bdrv_getlength = raw_getlength,
+ .has_variable_length = true,
.bdrv_get_allocated_file_size
= raw_get_allocated_file_size,
@@ -1951,7 +1953,8 @@ static BlockDriver bdrv_host_cdrom = {
.bdrv_aio_flush = raw_aio_flush,
.bdrv_truncate = raw_truncate,
- .bdrv_getlength = raw_getlength,
+ .bdrv_getlength = raw_getlength,
+ .has_variable_length = true,
.bdrv_get_allocated_file_size
= raw_get_allocated_file_size,
diff --git a/block/raw-win32.c b/block/raw-win32.c
index 676b570..2741e4d 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -616,7 +616,9 @@ static BlockDriver bdrv_host_device = {
.bdrv_aio_writev = raw_aio_writev,
.bdrv_aio_flush = raw_aio_flush,
- .bdrv_getlength = raw_getlength,
+ .bdrv_getlength = raw_getlength,
+ .has_variable_length = true,
+
.bdrv_get_allocated_file_size
= raw_get_allocated_file_size,
};
diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index 0078c1b..2265dcc 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -178,6 +178,7 @@ static BlockDriver bdrv_raw = {
.bdrv_co_get_block_status = &raw_co_get_block_status,
.bdrv_truncate = &raw_truncate,
.bdrv_getlength = &raw_getlength,
+ .has_variable_length = true,
.bdrv_get_info = &raw_get_info,
.bdrv_is_inserted = &raw_is_inserted,
.bdrv_media_changed = &raw_media_changed,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index a48731d..1666066 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -156,8 +156,11 @@ struct BlockDriver {
const char *protocol_name;
int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset);
+
int64_t (*bdrv_getlength)(BlockDriverState *bs);
+ bool has_variable_length;
int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs);
+
int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PULL 17/17] qemu-iotests: Fix 051 reference output
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
` (15 preceding siblings ...)
2013-10-29 16:31 ` [Qemu-devel] [PULL 16/17] block: Avoid unecessary drv->bdrv_getlength() calls Kevin Wolf
@ 2013-10-29 16:31 ` Kevin Wolf
16 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2013-10-29 16:31 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
Commit 684b254 forgot to update it.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/051.out | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
index 2839e32..15deef6 100644
--- a/tests/qemu-iotests/051.out
+++ b/tests/qemu-iotests/051.out
@@ -24,7 +24,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
(qemu) i^[[K^[[Din^[[K^[[D^[[Dinf^[[K^[[D^[[D^[[Dinfo^[[K^[[D^[[D^[[D^[[Dinfo ^[[K^[[D^[[D^[[D^[[D^[[Dinfo b^[[K^[[D^[[D^[[D^[[D^[[D^[[Dinfo bl^[[K^[[D^[[D^[[D^[[D^[[D^[[D^[[Dinfo blo^[[K^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[Dinfo bloc^[[K^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[Dinfo block^[[K
ide0-hd0: TEST_DIR/t.qcow2 (qcow2)
Backing file: TEST_DIR/t.qcow2.orig (chain depth: 1)
- [not inserted](qemu) q^[[K^[[Dqu^[[K^[[D^[[Dqui^[[K^[[D^[[D^[[Dquit^[[K
+(qemu) q^[[K^[[Dqu^[[K^[[D^[[Dqui^[[K^[[D^[[D^[[Dquit^[[K
=== Enable and disable lazy refcounting on the command line, plus some invalid values ===
--
1.8.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
end of thread, other threads:[~2013-10-29 16:31 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-29 16:30 [Qemu-devel] [PULL 00/17] Block patches Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 01/17] qapi: fix documentation example Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 02/17] qcow2: Restore total_sectors value in save_vmstate Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 03/17] qcow2: Unset zero_beyond_eof " Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 04/17] qemu-img: add special exit code if bdrv_check is not supported Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 05/17] block/vpc: check that the image has not been truncated Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 06/17] qemu-iotests: Test for loading VM state from qcow2 Kevin Wolf
2013-10-29 16:30 ` [Qemu-devel] [PULL 07/17] qcow2: Flush image after creation Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 08/17] exec: Fix bounce buffer allocation in address_space_map() Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 09/17] ide-test: Check what happens with bus mastering disabled Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 10/17] tests: Multiboot mmap test case Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 11/17] block: Don't copy backing file name on error Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 12/17] sheepdog: explicitly set copies as type uint8_t Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 13/17] sheepdog: pass copy_policy in the request Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 14/17] ahci: fix win7 hang on boot Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 15/17] block: Disable BDRV_O_COPY_ON_READ for the backing file Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 16/17] block: Avoid unecessary drv->bdrv_getlength() calls Kevin Wolf
2013-10-29 16:31 ` [Qemu-devel] [PULL 17/17] qemu-iotests: Fix 051 reference output Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).