Skip to contentSkip to conversation

Block patches

GIT PULL Applied Kevin Wolf 2 participants 20 messages Feb 9, 2014 – Feb 12, 2014 Block layer

lore
Share & tools
lore
author
#1 lore raw

[Qemu-devel] [PULL 02/18] block: add native support for NFS

In reply to Kevin Wolf

From: Peter Lieven <[email protected]>

This patch adds native support for accessing images on NFS shares without the requirement to actually mount the entire NFS share on the host.

NFS Images can simply be specified by an url of the form:
nfs://<host>/<export>/<filename>[?param=value[&param2=value2[&...]]]

For example:
qemu-img create -f qcow2 nfs://10.0.0.1/qemu-images/test.qcow2

You need LibNFS from Ronnie Sahlberg available at:
git://github.com/sahlberg/libnfs.git
for this to work.

During configure it is automatically probed for libnfs and support is enabled on-the-fly. You can forbid or enforce libnfs support with --disable-libnfs or --enable-libnfs respectively.

Due to NFS restrictions you might need to execute your binaries as root, allow them to open priviledged ports (<1024) or specify insecure option on the NFS server.

For additional information on ROOT vs. non-ROOT operation and URL format + parameters see:
https://raw.github.com/sahlberg/libnfs/master/README

Supported by qemu are the uid, gid and tcp-syncnt URL parameters.

LibNFS currently support NFS version 3 only.

---
 MAINTAINERS         |   5 +
 block/Makefile.objs |   1 +
 block/nfs.c         | 439 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure           |  26 ++++
 qapi-schema.json    |   1 +
 5 files changed, 472 insertions(+)
 create mode 100644 block/nfs.c
MAINTAINERS +5 -0
index adc5973..026ea4f 100644
@@ -937,6 +937,11 @@ M: Peter Lieven <[email protected]>
 S: Supported
 F: block/iscsi.c
 
+NFS
+M: Peter Lieven <[email protected]>
+S: Maintained
+F: block/nfs.c
+
 SSH
 M: Richard W.M. Jones <[email protected]>
 S: Supported
block/Makefile.objs +1 -0
index 4e8c91e..e254a21 100644
@@ -12,6 +12,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 ifeq ($(CONFIG_POSIX),y)
 block-obj-y += nbd.o nbd-client.o sheepdog.o
 block-obj-$(CONFIG_LIBISCSI) += iscsi.o
+block-obj-$(CONFIG_LIBNFS) += nfs.o
 block-obj-$(CONFIG_CURL) += curl.o
 block-obj-$(CONFIG_RBD) += rbd.o
 block-obj-$(CONFIG_GLUSTERFS) += gluster.o
block/nfs.c new file +439 -0

439 lines not on this page · raw message

configure +26 -0
index 236764a..5b20ce6 100755
@@ -251,6 +251,7 @@ vss_win32_sdk=""
 win_sdk="no"
 want_tools="yes"
 libiscsi=""
+libnfs=""
 coroutine=""
 coroutine_pool=""
 seccomp=""
@@ -840,6 +841,10 @@ for opt do
   ;;
   --enable-libiscsi) libiscsi="yes"
   ;;
+  --disable-libnfs) libnfs="no"
+  ;;
+  --enable-libnfs) libnfs="yes"
+  ;;
   --enable-profiler) profiler="yes"
   ;;
   --disable-cocoa) cocoa="no"
@@ -1229,6 +1234,8 @@ Advanced options (experts only):
   --enable-rbd             enable building the rados block device (rbd)
   --disable-libiscsi       disable iscsi support
   --enable-libiscsi        enable iscsi support
+  --disable-libnfs         disable nfs support
+  --enable-libnfs          enable nfs support
   --disable-smartcard-nss  disable smartcard nss support
   --enable-smartcard-nss   enable smartcard nss support
   --disable-libusb         disable libusb (for usb passthrough)
@@ -3600,6 +3607,20 @@ elif test "$debug" = "no" ; then
   CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
 fi
 
+##########################################
+# Do we have libnfs
+if test "$libnfs" != "no" ; then
+  if $pkg_config --atleast-version=1.9.2 libnfs; then
+    libnfs="yes"
+    libnfs_libs=$($pkg_config --libs libnfs)
+    LIBS="$LIBS $libnfs_libs"
+  else
+    if test "$libnfs" = "yes" ; then
+      feature_not_found "libnfs"
+    fi
+    libnfs="no"
+  fi
+fi
 
 # Disable zero malloc errors for official releases unless explicitly told to
 # enable/disable
@@ -3829,6 +3850,7 @@ echo "libiscsi support  $libiscsi (1.4.0)"
 else
 echo "libiscsi support  $libiscsi"
 fi
+echo "libnfs support    $libnfs"
 echo "build guest agent $guest_agent"
 echo "QGA VSS support   $guest_agent_with_vss"
 echo "seccomp support   $seccomp"
@@ -4165,6 +4187,10 @@ if test "$libiscsi" = "yes" ; then
   fi
 fi
 
+if test "$libnfs" = "yes" ; then
+  echo "CONFIG_LIBNFS=y" >> $config_host_mak
+fi
+
 if test "$seccomp" = "yes"; then
   echo "CONFIG_SECCOMP=y" >> $config_host_mak
 fi
qapi-schema.json +1 -0
index 05ced9d..7cfb5e5 100644
@@ -4371,6 +4371,7 @@
 # TODO gluster: Wait for structured options
 # TODO iscsi: Wait for structured options
 # TODO nbd: Should take InetSocketAddress for 'host'?
+# TODO nfs: Wait for structured options
 # TODO rbd: Wait for structured options
 # TODO sheepdog: Wait for structured options
 # TODO ssh: Should take InetSocketAddress for 'host'?
Signature · 1 line
1.8.1.4

Kevin Wolf

author
#0 lore raw

The following changes since commit 1f6b12f75f2c22f861d0202374033a7594c91707:

Merge remote-tracking branch 'remotes/mwalle/tags/lm32-fixes/20140204' into staging (2014-02-08 15:57:51 +0000)

are available in the git repository at:

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

for you to fetch changes up to e96126ffa53d36ec75a1ee900a6b7e7c82d9bb9c:

block: Fix 32 bit truncation in mark_request_serialising() (2014-02-09 09:12:39 +0100)

----------------------------------------------------------------
Block patches

----------------------------------------------------------------
Hu Tao (4):
qcow2: remove n_start and n_end of qcow2_alloc_cluster_offset()
qcow2: fix offset overflow in qcow2_alloc_clusters_at()
qcow2: check for NULL l2meta
qemu-iotests: add test for qcow2 preallocation with different cluster sizes

Kevin Wolf (8):
qemu-iotest: Make 077 raw-only
block: Fail gracefully with missing filename
raw: Fix BlockLimits passthrough
block: Fix memory leaks in bdrv_co_do_pwritev()
block: bdrv_aligned_pwritev: Assert overlap range
block: Don't call ROUND_UP with negative values
blkdebug: Don't leak bs->file on failure
block: Fix 32 bit truncation in mark_request_serialising()

Peter Lieven (6):
block: add native support for NFS
qemu-iotests: change _supported_proto to file for various tests
qemu-iotests: blacklist test 020 for NFS protocol
qemu-iotests: enable test 016 and 025 to work with NFS protocol
qemu-iotests: enable support for NFS protocol block/iscsi: always fill bs->bl.opt_transfer_length

 MAINTAINERS                  |   5 +
 block.c                      |  27 +--
 block/Makefile.objs          |   1 +
 block/blkdebug.c             |  14 +-
 block/iscsi.c                |   5 +-
 block/nfs.c                  | 439 +++++++++++++++++++++++++++++++++++++++++++
 block/qcow2-cluster.c        |  14 +-
 block/qcow2-refcount.c       |   8 +-
 block/qcow2.c                |  44 ++---
 block/qcow2.h                |   2 +-
 block/raw_bsd.c              |   8 +-
 configure                    |  26 +++
 qapi-schema.json             |   1 +
 tests/qemu-iotests/013       |   2 +-
 tests/qemu-iotests/014       |   2 +-
 tests/qemu-iotests/016       |   2 +-
 tests/qemu-iotests/018       |   2 +-
 tests/qemu-iotests/019       |   2 +-
 tests/qemu-iotests/020       |   5 +
 tests/qemu-iotests/023       |   2 +-
 tests/qemu-iotests/024       |   2 +-
 tests/qemu-iotests/025       |   2 +-
 tests/qemu-iotests/026       |   2 +-
 tests/qemu-iotests/028       |   2 +-
 tests/qemu-iotests/031       |   2 +-
 tests/qemu-iotests/034       |   2 +-
 tests/qemu-iotests/036       |   2 +-
 tests/qemu-iotests/037       |   2 +-
 tests/qemu-iotests/038       |   2 +-
 tests/qemu-iotests/039       |   2 +-
 tests/qemu-iotests/043       |   2 +-
 tests/qemu-iotests/046       |   2 +-
 tests/qemu-iotests/051       |  12 ++
 tests/qemu-iotests/051.out   |  24 +++
 tests/qemu-iotests/052       |   2 +-
 tests/qemu-iotests/054       |   2 +-
 tests/qemu-iotests/059       |   2 +-
 tests/qemu-iotests/060       |   2 +-
 tests/qemu-iotests/061       |   2 +-
 tests/qemu-iotests/063       |   2 +-
 tests/qemu-iotests/069       |   2 +-
 tests/qemu-iotests/071       |   2 +-
 tests/qemu-iotests/072       |   2 +-
 tests/qemu-iotests/077       |   2 +-
 tests/qemu-iotests/079       |  63 +++++++
 tests/qemu-iotests/079.out   |  32 ++++
 tests/qemu-iotests/common    |  22 ++-
 tests/qemu-iotests/common.rc |   3 +
 tests/qemu-iotests/group     |   1 +
 trace-events                 |   2 +-
 50 files changed, 730 insertions(+), 84 deletions(-)
 create mode 100644 block/nfs.c
 create mode 100755 tests/qemu-iotests/079
 create mode 100644 tests/qemu-iotests/079.out
author
#2 lore raw

[Qemu-devel] [PULL 01/18] qemu-iotest: Make 077 raw-only

The qemu-io command sequences make the assumption that an unaligned request on the format layer will be unaligned on the blkdebug layer as well. This doesn't necessarily hold true for drivers other than raw.

---
 tests/qemu-iotests/077 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/077 +1 -1
index bbf7b51..4dd1bdd 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.rc
 . ./common.filter
 
-_supported_fmt generic
+_supported_fmt raw
 _supported_proto generic
 _supported_os Linux
 
Signature · 1 line
1.8.1.4
author
#3 lore raw

[Qemu-devel] [PULL 03/18] qemu-iotests: change _supported_proto to file for various tests

In reply to Kevin Wolf

From: Peter Lieven <[email protected]>

all these tests do anything of the following and thus fail with any protocol other than file:
- the tests use rm, cp or mv shell commands which only work on file
- the tests use qcow2.py
- the images construct new filenames (e.g. backing file names) and the logic is broken for anything else than file

---
 tests/qemu-iotests/013 | 2 +-
 tests/qemu-iotests/014 | 2 +-
 tests/qemu-iotests/018 | 2 +-
 tests/qemu-iotests/019 | 2 +-
 tests/qemu-iotests/023 | 2 +-
 tests/qemu-iotests/024 | 2 +-
 tests/qemu-iotests/026 | 2 +-
 tests/qemu-iotests/028 | 2 +-
 tests/qemu-iotests/031 | 2 +-
 tests/qemu-iotests/034 | 2 +-
 tests/qemu-iotests/036 | 2 +-
 tests/qemu-iotests/037 | 2 +-
 tests/qemu-iotests/038 | 2 +-
 tests/qemu-iotests/039 | 2 +-
 tests/qemu-iotests/043 | 2 +-
 tests/qemu-iotests/046 | 2 +-
 tests/qemu-iotests/052 | 2 +-
 tests/qemu-iotests/054 | 2 +-
 tests/qemu-iotests/059 | 2 +-
 tests/qemu-iotests/060 | 2 +-
 tests/qemu-iotests/061 | 2 +-
 tests/qemu-iotests/063 | 2 +-
 tests/qemu-iotests/069 | 2 +-
 tests/qemu-iotests/071 | 2 +-
 tests/qemu-iotests/072 | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)
tests/qemu-iotests/013 +1 -1
index 389f4b8..ea3cab9 100755
@@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # much of this could be generic for any format supporting compression.
 _supported_fmt qcow qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 TEST_OFFSETS="0 4294967296"
tests/qemu-iotests/014 +1 -1
index 0edeb4b..b23c2db 100755
@@ -43,7 +43,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # much of this could be generic for any format supporting snapshots
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 TEST_OFFSETS="0 4294967296"
tests/qemu-iotests/018 +1 -1
index 6f7f054..d8a7d43 100755
@@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # Any format supporting backing files
 _supported_fmt qcow qcow2 vmdk qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
 
tests/qemu-iotests/019 +1 -1
index b43e70f..e67445c 100755
@@ -45,7 +45,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # Any format supporting backing files
 _supported_fmt qcow qcow2 vmdk qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts "subformat=monolithicFlat" \
                      "subformat=twoGbMaxExtentFlat" \
tests/qemu-iotests/023 +1 -1
index 090ed23..9ad06b9 100755
@@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # much of this could be generic for any format supporting compression.
 _supported_fmt qcow qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 TEST_OFFSETS="0 4294967296"
tests/qemu-iotests/024 +1 -1
index be974f0..9bf99e1 100755
@@ -43,7 +43,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # Currently only qcow2 and qed support rebasing
 _supported_fmt qcow2 qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 CLUSTER_SIZE=65536
tests/qemu-iotests/026 +1 -1
index c9c5f83..df2884b 100755
@@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # Currently only qcow2 supports rebasing
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _default_cache_mode "writethrough"
 _supported_cache_modes "writethrough" "none"
tests/qemu-iotests/028 +1 -1
index 93a9fa6..a99e4fa 100755
@@ -45,7 +45,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 # Any format supporting backing files except vmdk and qcow which do not support
 # smaller backing files.
 _supported_fmt qcow2 qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 # Choose a size that is not necessarily a cluster size multiple for image
tests/qemu-iotests/031 +1 -1
index c9070b0..1d920ea 100755
@@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # This tests qcow2-specific low-level functionality
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 CLUSTER_SIZE=65536
tests/qemu-iotests/034 +1 -1
index 7349789..69c7858 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow qcow2 vmdk qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts "subformat=monolithicFlat" \
                      "subformat=twoGbMaxExtentFlat" \
tests/qemu-iotests/036 +1 -1
index e049a64..03b6aa9 100755
@@ -44,7 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # This tests qcow2-specific low-level functionality
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 # Only qcow2v3 and later supports feature bits
tests/qemu-iotests/037 +1 -1
index e444349..9171d8c 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow qcow2 vmdk qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts "subformat=monolithicFlat" \
                      "subformat=twoGbMaxExtentFlat" \
tests/qemu-iotests/038 +1 -1
index 7bb7906..cfaf00a 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2 qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 CLUSTER_SIZE=2M
tests/qemu-iotests/039 +1 -1
index 6abf472..9b355c0 100755
@@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _default_cache_mode "writethrough"
 _supported_cache_modes "writethrough"
tests/qemu-iotests/043 +1 -1
index d7f1231..b316b97 100755
@@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # Any format supporting backing files
 _supported_fmt qcow2 qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 
tests/qemu-iotests/046 +1 -1
index 3f17ceb..2d44bbb 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 CLUSTER_SIZE=64k
tests/qemu-iotests/052 +1 -1
index 4d4e411..6bdae92 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt generic
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _default_cache_mode "writethrough"
 _supported_cache_modes "writethrough"
tests/qemu-iotests/054 +1 -1
index 5a0d1b1..c8b7082 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 echo
tests/qemu-iotests/059 +1 -1
index 2d604d3..ca5aa16 100755
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # This tests vmdk-specific low-level functionality
 _supported_fmt vmdk
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts "subformat=monolithicFlat" \
                      "subformat=twoGbMaxExtentFlat" \
tests/qemu-iotests/060 +1 -1
index bbb1909..af8ed9f 100755
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # This tests qocw2-specific low-level functionality
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 rt_offset=65536  # 0x10000 (XXX: just an assumption)
tests/qemu-iotests/061 +1 -1
index e42f9bd..d3a6b38 100755
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # This tests qocw2-specific low-level functionality
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 echo
tests/qemu-iotests/063 +1 -1
index 77503a2..a47493a 100755
@@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.pattern
 
 _supported_fmt qcow qcow2 vmdk qed raw
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts "subformat=monolithicFlat" \
                      "subformat=twoGbMaxExtentFlat" \
tests/qemu-iotests/069 +1 -1
index 50347d9..e661598 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt cow qed qcow qcow2 vmdk
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
 
tests/qemu-iotests/071 +1 -1
index dbc07c6..3924e51 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 function do_run_qemu()
tests/qemu-iotests/072 +1 -1
index a3876c2..58faa8b 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow cow
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 IMG_SIZE=64M
Signature · 1 line
1.8.1.4
author
#4 lore raw

[Qemu-devel] [PULL 04/18] qemu-iotests: blacklist test 020 for NFS protocol

In reply to Kevin Wolf

From: Peter Lieven <[email protected]>

reopening is currently not supported.

---
 tests/qemu-iotests/020 | 5 +++++
 1 file changed, 5 insertions(+)
tests/qemu-iotests/020 +5 -0
index 73a0429..2f258dc 100755
@@ -49,6 +49,11 @@ _unsupported_imgopts "subformat=monolithicFlat" \
                      "subformat=twoGbMaxExtentFlat" \
                      "subformat=twoGbMaxExtentSparse"
 
+# NFS does not support bdrv_reopen_prepare thus qemu-img commit fails.
+if [ "$IMGPROTO" = "nfs" ]; then
+    _notrun "image protocol $IMGPROTO does not support bdrv_commit"
+fi
+
 TEST_OFFSETS="0 4294967296"
 
 _make_test_img 6G
Signature · 1 line
1.8.1.4
author
#5 lore raw

[Qemu-devel] [PULL 05/18] qemu-iotests: enable test 016 and 025 to work with NFS protocol

In reply to Kevin Wolf

From: Peter Lieven <[email protected]>

---
 tests/qemu-iotests/016 | 2 +-
 tests/qemu-iotests/025 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/qemu-iotests/016 +1 -1
index b87a32b..7ea9e94 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt raw
-_supported_proto file sheepdog
+_supported_proto file sheepdog nfs
 _supported_os Linux
 
 
tests/qemu-iotests/025 +1 -1
index 9426c93..a5f45b4 100755
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.pattern
 
 _supported_fmt raw qcow2 qed
-_supported_proto file sheepdog rbd
+_supported_proto file sheepdog rbd nfs
 _supported_os Linux
 
 echo "=== Creating image"
Signature · 1 line
1.8.1.4
author
#6 lore raw

[Qemu-devel] [PULL 06/18] qemu-iotests: enable support for NFS protocol

In reply to Kevin Wolf

From: Peter Lieven <[email protected]>

---
 tests/qemu-iotests/common    | 22 +++++++++++++++++++---
 tests/qemu-iotests/common.rc |  3 +++
 2 files changed, 22 insertions(+), 3 deletions(-)
tests/qemu-iotests/common +19 -3
index 8b4e22c..5795358 100644
@@ -144,10 +144,12 @@ check options
     -vpc                test vpc
     -vhdx               test vhdx
     -vmdk               test vmdk
+    -file               test file (default)
     -rbd                test rbd
     -sheepdog           test sheepdog
     -nbd                test nbd
     -ssh                test ssh
+    -nfs                test nfs
     -xdiff              graphical mode diff
     -nocache            use O_DIRECT on backing file
     -misalign           misalign memory allocations
@@ -211,22 +213,36 @@ testlist options
             xpand=false
             ;;
 
+        -file)
+            IMGPROTO=file
+            xpand=false
+            ;;
+
         -rbd)
             IMGPROTO=rbd
             xpand=false
             ;;
+
         -sheepdog)
             IMGPROTO=sheepdog
             xpand=false
             ;;
+
         -nbd)
             IMGPROTO=nbd
             xpand=false
             ;;
+
         -ssh)
             IMGPROTO=ssh
             xpand=false
             ;;
+
+        -nfs)
+            IMGPROTO=nfs
+            xpand=false
+            ;;
+
         -nocache)
             CACHEMODE="none"
             CACHEMODE_IS_DEFAULT=false
@@ -238,10 +254,10 @@ testlist options
             xpand=false
             ;;
 
-    -valgrind)
-        valgrind=true
+        -valgrind)
+            valgrind=true
             xpand=false
-        ;;
+            ;;
 
         -g)        # -g group ... pick from group file
             group=true
tests/qemu-iotests/common.rc +3 -0
index 0f68156..71e9a74 100644
@@ -61,6 +61,9 @@ elif [ "$IMGPROTO" = "nbd" ]; then
 elif [ "$IMGPROTO" = "ssh" ]; then
     TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
     TEST_IMG="ssh://127.0.0.1$TEST_IMG_FILE"
+elif [ "$IMGPROTO" = "nfs" ]; then
+    TEST_DIR="nfs://127.0.0.1/$TEST_DIR"
+    TEST_IMG=$TEST_DIR/t.$IMGFMT
 else
     TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
 fi
Signature · 1 line
1.8.1.4
author
#7 lore raw

[Qemu-devel] [PULL 09/18] qcow2: remove n_start and n_end of qcow2_alloc_cluster_offset()

In reply to Kevin Wolf

From: Hu Tao <[email protected]>

n_start can be actually calculated from offset. The number of sectors to be allocated(n_end - n_start) can be passed in in num. By removing n_start and n_end, we can save two parameters.

The side effect is there is a bug in qcow2.c:preallocate() that passes incorrect n_start to qcow2_alloc_cluster_offset() is fixed. The bug can be triggerred by a larger cluster size than the default value(65536), for example:

./qemu-img create -f qcow2 \
-o 'cluster_size=131072,preallocation=metadata' file.img 4G

---
 block/qcow2-cluster.c | 14 ++++++--------
 block/qcow2.c         | 13 +++++++------
 block/qcow2.h         |  2 +-
 trace-events          |  2 +-
 4 files changed, 15 insertions(+), 16 deletions(-)
block/qcow2-cluster.c +6 -8
index 8534084..c57f39d 100644
@@ -1182,7 +1182,7 @@ fail:
  * Return 0 on success and -errno in error cases
  */
 int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
-    int n_start, int n_end, int *num, uint64_t *host_offset, QCowL2Meta **m)
+    int *num, uint64_t *host_offset, QCowL2Meta **m)
 {
     BDRVQcowState *s = bs->opaque;
     uint64_t start, remaining;
@@ -1190,15 +1190,13 @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
     uint64_t cur_bytes;
     int ret;
 
-    trace_qcow2_alloc_clusters_offset(qemu_coroutine_self(), offset,
-                                      n_start, n_end);
+    trace_qcow2_alloc_clusters_offset(qemu_coroutine_self(), offset, *num);
 
-    assert(n_start * BDRV_SECTOR_SIZE == offset_into_cluster(s, offset));
-    offset = start_of_cluster(s, offset);
+    assert((offset & ~BDRV_SECTOR_MASK) == 0);
 
 again:
-    start = offset + (n_start << BDRV_SECTOR_BITS);
-    remaining = (n_end - n_start) << BDRV_SECTOR_BITS;
+    start = offset;
+    remaining = *num << BDRV_SECTOR_BITS;
     cluster_offset = 0;
     *host_offset = 0;
     cur_bytes = 0;
@@ -1284,7 +1282,7 @@ again:
         }
     }
 
-    *num = (n_end - n_start) - (remaining >> BDRV_SECTOR_BITS);
+    *num -= remaining >> BDRV_SECTOR_BITS;
     assert(*num > 0);
     assert(*host_offset != 0);
 
block/qcow2.c +7 -6
index 99a1ad1..a274d5f 100644
@@ -1000,7 +1000,6 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs,
 {
     BDRVQcowState *s = bs->opaque;
     int index_in_cluster;
-    int n_end;
     int ret;
     int cur_nr_sectors; /* number of sectors in current iteration */
     uint64_t cluster_offset;
@@ -1024,14 +1023,16 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs,
 
         trace_qcow2_writev_start_part(qemu_coroutine_self());
         index_in_cluster = sector_num & (s->cluster_sectors - 1);
-        n_end = index_in_cluster + remaining_sectors;
+        cur_nr_sectors = remaining_sectors;
         if (s->crypt_method &&
-            n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors) {
-            n_end = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors;
+            cur_nr_sectors >
+            QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors - index_in_cluster) {
+            cur_nr_sectors =
+                QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors - index_in_cluster;
         }
 
         ret = qcow2_alloc_cluster_offset(bs, sector_num << 9,
-            index_in_cluster, n_end, &cur_nr_sectors, &cluster_offset, &l2meta);
+            &cur_nr_sectors, &cluster_offset, &l2meta);
         if (ret < 0) {
             goto fail;
         }
@@ -1408,7 +1409,7 @@ static int preallocate(BlockDriverState *bs)
 
     while (nb_sectors) {
         num = MIN(nb_sectors, INT_MAX >> 9);
-        ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num,
+        ret = qcow2_alloc_cluster_offset(bs, offset, &num,
                                          &host_offset, &meta);
         if (ret < 0) {
             return ret;
block/qcow2.h +1 -1
index b5b7d13..0b0eac8 100644
@@ -468,7 +468,7 @@ void qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
 int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
     int *num, uint64_t *cluster_offset);
 int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
-    int n_start, int n_end, int *num, uint64_t *host_offset, QCowL2Meta **m);
+    int *num, uint64_t *host_offset, QCowL2Meta **m);
 uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
                                          uint64_t offset,
                                          int compressed_size);
trace-events +1 -1
index 1b668d1..ab11f97 100644
@@ -495,7 +495,7 @@ qcow2_writev_done_part(void *co, int cur_nr_sectors) "co %p cur_nr_sectors %d"
 qcow2_writev_data(void *co, uint64_t offset) "co %p offset %" PRIx64
 
 # block/qcow2-cluster.c
-qcow2_alloc_clusters_offset(void *co, uint64_t offset, int n_start, int n_end) "co %p offet %" PRIx64 " n_start %d n_end %d"
+qcow2_alloc_clusters_offset(void *co, uint64_t offset, int num) "co %p offet %" PRIx64 " num %d"
 qcow2_handle_copied(void *co, uint64_t guest_offset, uint64_t host_offset, uint64_t bytes) "co %p guest_offet %" PRIx64 " host_offset %" PRIx64 " bytes %" PRIx64
 qcow2_handle_alloc(void *co, uint64_t guest_offset, uint64_t host_offset, uint64_t bytes) "co %p guest_offet %" PRIx64 " host_offset %" PRIx64 " bytes %" PRIx64
 qcow2_do_alloc_clusters_offset(void *co, uint64_t guest_offset, uint64_t host_offset, int nb_clusters) "co %p guest_offet %" PRIx64 " host_offset %" PRIx64 " nb_clusters %d"
Signature · 1 line
1.8.1.4
author
#8 lore raw

[Qemu-devel] [PULL 08/18] block/iscsi: always fill bs->bl.opt_transfer_length

In reply to Kevin Wolf

From: Peter Lieven <[email protected]>

the opt_transfer_length has nothing to do with logical block provisioning stuff so always copy it from the block limits VPD page.

---
 block/iscsi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
block/iscsi.c +2 -3
index 6f4af72..8d0f966 100644
@@ -1330,10 +1330,9 @@ static int iscsi_refresh_limits(BlockDriverState *bs)
         }
         bs->bl.write_zeroes_alignment = sector_lun2qemu(iscsilun->bl.opt_unmap_gran,
                                                         iscsilun);
-
-        bs->bl.opt_transfer_length = sector_lun2qemu(iscsilun->bl.opt_xfer_len,
-                                                     iscsilun);
     }
+    bs->bl.opt_transfer_length = sector_lun2qemu(iscsilun->bl.opt_xfer_len,
+                                                 iscsilun);
     return 0;
 }
 
Signature · 1 line
1.8.1.4
author
#9 lore raw

[Qemu-devel] [PULL 10/18] qcow2: fix offset overflow in qcow2_alloc_clusters_at()

In reply to Kevin Wolf

From: Hu Tao <[email protected]>

When cluster size is big enough it can lead to an offset overflow in qcow2_alloc_clusters_at(). This patch fixes it.

The allocation is stopped each time at L2 table boundary (see handle_alloc()), so the possible maximum bytes could be

2^(cluster_bits - 3 + cluster_bits)

cluster_bits - 3 is used to compute the number of entry by L2 and the additional cluster_bits is to take into account each clusters referenced by the L2 entries.

so int is safe for cluster_bits<=17, unsafe otherwise.

---
 block/qcow2-refcount.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
block/qcow2-refcount.c +7 -1
index c974abe..8712d8b 100644
@@ -676,7 +676,13 @@ int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
     BDRVQcowState *s = bs->opaque;
     uint64_t cluster_index;
     uint64_t old_free_cluster_index;
-    int i, refcount, ret;
+    uint64_t i;
+    int refcount, ret;
+
+    assert(nb_clusters >= 0);
+    if (nb_clusters == 0) {
+        return 0;
+    }
 
     /* Check how many clusters there are free */
     cluster_index = offset >> s->cluster_bits;
Signature · 1 line
1.8.1.4
author
#10 lore raw

[Qemu-devel] [PULL 07/18] block: Fail gracefully with missing filename

In reply to Kevin Wolf

This fixes a regression introduced in commit 2a05cbe42 ('block: Allow block devices without files'):

$ qemu-system-x86_64 -drive driver=file
qemu-system-x86_64: block.c:892: bdrv_open_common: Assertion
`!drv->bdrv_needs_filename || filename != ((void *)0)' failed.

Now the respective check must be performed not only in bdrv_file_open(), but also in bdrv_open().

---
 block.c                    | 11 ++++++-----
 tests/qemu-iotests/051     | 12 ++++++++++++
 tests/qemu-iotests/051.out | 24 ++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 5 deletions(-)
block.c +6 -5
index cb21a5f..ac0ccac 100644
@@ -832,6 +832,12 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
         filename = qdict_get_try_str(options, "filename");
     }
 
+    if (drv->bdrv_needs_filename && !filename) {
+        error_setg(errp, "The '%s' block driver requires a file name",
+                   drv->format_name);
+        return -EINVAL;
+    }
+
     trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
 
     node_name = qdict_get_try_str(options, "node-name");
@@ -1031,11 +1037,6 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
             goto fail;
         }
         qdict_del(options, "filename");
-    } else if (drv->bdrv_needs_filename && !filename) {
-        error_setg(errp, "The '%s' block driver requires a file name",
-                   drv->format_name);
-        ret = -EINVAL;
-        goto fail;
     }
 
     if (!drv->bdrv_file_open) {
tests/qemu-iotests/051 +12 -0
index b23d91b..46345fb 100755
@@ -172,6 +172,18 @@ run_qemu -drive file="$TEST_IMG",file.driver=file
 run_qemu -drive file="$TEST_IMG",file.driver=qcow2
 
 echo
+echo === Leaving out required options ===
+echo
+
+run_qemu -drive driver=file
+run_qemu -drive driver=nbd
+run_qemu -drive driver=raw
+run_qemu -drive file.driver=file
+run_qemu -drive file.driver=nbd
+run_qemu -drive file.driver=raw
+run_qemu -drive foo=bar
+
+echo
 echo === Parsing protocol from file name ===
 echo
 
tests/qemu-iotests/051.out +24 -0
index d0c5173..30e2dbd 100644
@@ -225,6 +225,30 @@ Testing: -drive file=TEST_DIR/t.qcow2,file.driver=qcow2
 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,file.driver=qcow2: could not open disk image TEST_DIR/t.qcow2: Block format 'qcow2' used by device '' doesn't support the option 'filename'
 
 
+=== Leaving out required options ===
+
+Testing: -drive driver=file
+QEMU_PROG: -drive driver=file: could not open disk image ide0-hd0: The 'file' block driver requires a file name
+
+Testing: -drive driver=nbd
+QEMU_PROG: -drive driver=nbd: could not open disk image ide0-hd0: Could not open image: Invalid argument
+
+Testing: -drive driver=raw
+QEMU_PROG: -drive driver=raw: could not open disk image ide0-hd0: Can't use 'raw' as a block driver for the protocol level
+
+Testing: -drive file.driver=file
+QEMU_PROG: -drive file.driver=file: could not open disk image ide0-hd0: The 'file' block driver requires a file name
+
+Testing: -drive file.driver=nbd
+QEMU_PROG: -drive file.driver=nbd: could not open disk image ide0-hd0: Could not open image: Invalid argument
+
+Testing: -drive file.driver=raw
+QEMU_PROG: -drive file.driver=raw: could not open disk image ide0-hd0: Can't use 'raw' as a block driver for the protocol level
+
+Testing: -drive foo=bar
+QEMU_PROG: -drive foo=bar: could not open disk image ide0-hd0: Must specify either driver or file
+
+
 === Parsing protocol from file name ===
 
 Testing: -hda foo:bar
Signature · 1 line
1.8.1.4
author
#11 lore raw

[Qemu-devel] [PULL 11/18] qcow2: check for NULL l2meta

In reply to Kevin Wolf

From: Hu Tao <[email protected]>

In the case of a metadata preallocation with a large cluster size, qcow2_alloc_cluster_offset() can allocate nothing and returns a NULL l2meta. This patch checks for it and link2 l2 with only valid l2meta.

Replace 9 and 512 with BDRV_SECTOR_BITS, BDRV_SECTOR_SIZE respectively while at the function.

---
 block/qcow2.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)
block/qcow2.c +16 -15
index a274d5f..0b4335c 100644
@@ -1404,34 +1404,34 @@ static int preallocate(BlockDriverState *bs)
     int ret;
     QCowL2Meta *meta;
 
-    nb_sectors = bdrv_getlength(bs) >> 9;
+    nb_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
     offset = 0;
 
     while (nb_sectors) {
-        num = MIN(nb_sectors, INT_MAX >> 9);
+        num = MIN(nb_sectors, INT_MAX >> BDRV_SECTOR_BITS);
         ret = qcow2_alloc_cluster_offset(bs, offset, &num,
                                          &host_offset, &meta);
         if (ret < 0) {
             return ret;
         }
 
-        ret = qcow2_alloc_cluster_link_l2(bs, meta);
-        if (ret < 0) {
-            qcow2_free_any_clusters(bs, meta->alloc_offset, meta->nb_clusters,
-                                    QCOW2_DISCARD_NEVER);
-            return ret;
-        }
-
-        /* There are no dependent requests, but we need to remove our request
-         * from the list of in-flight requests */
         if (meta != NULL) {
+            ret = qcow2_alloc_cluster_link_l2(bs, meta);
+            if (ret < 0) {
+                qcow2_free_any_clusters(bs, meta->alloc_offset,
+                                        meta->nb_clusters, QCOW2_DISCARD_NEVER);
+                return ret;
+            }
+
+            /* There are no dependent requests, but we need to remove our
+             * request from the list of in-flight requests */
             QLIST_REMOVE(meta, next_in_flight);
         }
 
         /* TODO Preallocate data if requested */
 
         nb_sectors -= num;
-        offset += num << 9;
+        offset += num << BDRV_SECTOR_BITS;
     }
 
     /*
@@ -1440,9 +1440,10 @@ static int preallocate(BlockDriverState *bs)
      * EOF). Extend the image to the last allocated sector.
      */
     if (host_offset != 0) {
-        uint8_t buf[512];
-        memset(buf, 0, 512);
-        ret = bdrv_write(bs->file, (host_offset >> 9) + num - 1, buf, 1);
+        uint8_t buf[BDRV_SECTOR_SIZE];
+        memset(buf, 0, BDRV_SECTOR_SIZE);
+        ret = bdrv_write(bs->file, (host_offset >> BDRV_SECTOR_BITS) + num - 1,
+                         buf, 1);
         if (ret < 0) {
             return ret;
         }
Signature · 1 line
1.8.1.4
author
#12 lore raw

[Qemu-devel] [PULL 12/18] qemu-iotests: add test for qcow2 preallocation with different cluster sizes

In reply to Kevin Wolf

From: Hu Tao <[email protected]>

---
 tests/qemu-iotests/079     | 63 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/079.out | 32 +++++++++++++++++++++++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 96 insertions(+)
 create mode 100755 tests/qemu-iotests/079
 create mode 100644 tests/qemu-iotests/079.out
tests/qemu-iotests/079 new file +63 -0
new file mode 100755
index 0000000..2142bbb
@@ -0,0 +1,63 @@
+#!/bin/bash
+#
+# Test qcow2 preallocation with different cluster_sizes
+#
+# Copyright (C) 2014 Fujitsu.
+#
+# 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
[email protected]
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+	_cleanup_test_img
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_supported_fmt qcow2
+_supported_proto file
+_supported_os Linux
+
+function test_qemu_img()
+{
+    echo qemu-img "$@" | _filter_testdir
+    $QEMU_IMG "$@" 2>&1 | _filter_testdir
+    echo
+}
+
+echo "=== Check option preallocation and cluster_size ==="
+echo
+cluster_sizes="16384 32768 65536 131072 262144 524288 1048576 2097152 4194304"
+
+for s in $cluster_sizes; do
+    test_qemu_img create -f $IMGFMT -o preallocation=metadata,cluster_size=$s "$TEST_IMG" 4G
+done
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
tests/qemu-iotests/079.out new file +32 -0
new file mode 100644
index 0000000..ef4b8c9
@@ -0,0 +1,32 @@
+QA output created by 079
+=== Check option preallocation and cluster_size ===
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=16384 TEST_DIR/t.qcow2 4G
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=16384 preallocation='metadata' lazy_refcounts=off
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=32768 TEST_DIR/t.qcow2 4G
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=32768 preallocation='metadata' lazy_refcounts=off
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=65536 TEST_DIR/t.qcow2 4G
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=65536 preallocation='metadata' lazy_refcounts=off
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=131072 TEST_DIR/t.qcow2 4G
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=131072 preallocation='metadata' lazy_refcounts=off
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=262144 TEST_DIR/t.qcow2 4G
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=262144 preallocation='metadata' lazy_refcounts=off
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=524288 TEST_DIR/t.qcow2 4G
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=524288 preallocation='metadata' lazy_refcounts=off
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=1048576 TEST_DIR/t.qcow2 4G
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=1048576 preallocation='metadata' lazy_refcounts=off
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=2097152 TEST_DIR/t.qcow2 4G
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=2097152 preallocation='metadata' lazy_refcounts=off
+
+qemu-img create -f qcow2 -o preallocation=metadata,cluster_size=4194304 TEST_DIR/t.qcow2 4G
+qemu-img: TEST_DIR/t.qcow2: Cluster size must be a power of two between 512 and 2048k
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=4194304 preallocation='metadata' lazy_refcounts=off
+
+*** done
tests/qemu-iotests/group +1 -0
index 03c762f..d8be74a 100644
@@ -82,3 +82,4 @@
 073 rw auto
 074 rw auto
 077 rw auto
+079 rw auto
Signature · 1 line
1.8.1.4
author
#13 lore raw

[Qemu-devel] [PULL 13/18] raw: Fix BlockLimits passthrough

In reply to Kevin Wolf

raw copies over the BlockLimits of bs->file during bdrv_open(). However, since commit d34682cd it is immediately overwritten during bdrv_refresh_limits(). This caused all fields except for opt_transfer_length and opt_mem_alignment (which happen to be correctly inherited in generic code) to be zeroed.

Move the BlockLimit assignment to a .bdrv_refresh_limits() callback to make it work again for all fields.

---
 block/raw_bsd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
block/raw_bsd.c +7 -1
index 978ae7a..af8706d 100644
@@ -90,6 +90,12 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
     return bdrv_get_info(bs->file, bdi);
 }
 
+static int raw_refresh_limits(BlockDriverState *bs)
+{
+    bs->bl = bs->file->bl;
+    return 0;
+}
+
 static int raw_truncate(BlockDriverState *bs, int64_t offset)
 {
     return bdrv_truncate(bs->file, offset);
@@ -150,7 +156,6 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
                     Error **errp)
 {
     bs->sg = bs->file->sg;
-    bs->bl = bs->file->bl;
     return 0;
 }
 
@@ -182,6 +187,7 @@ static BlockDriver bdrv_raw = {
     .bdrv_getlength       = &raw_getlength,
     .has_variable_length  = true,
     .bdrv_get_info        = &raw_get_info,
+    .bdrv_refresh_limits  = &raw_refresh_limits,
     .bdrv_is_inserted     = &raw_is_inserted,
     .bdrv_media_changed   = &raw_media_changed,
     .bdrv_eject           = &raw_eject,
Signature · 1 line
1.8.1.4
author
#14 lore raw

[Qemu-devel] [PULL 14/18] block: Fix memory leaks in bdrv_co_do_pwritev()

In reply to Kevin Wolf

The error path for a failure in one of the two bdrv_aligned_preadv() calls leaked head_buf or tail_buf, respectively. This fixes the memory leak.

---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block.c +2 -2
index ac0ccac..c1d1f74 100644
@@ -3279,9 +3279,9 @@ fail:
 
     if (use_local_qiov) {
         qemu_iovec_destroy(&local_qiov);
-        qemu_vfree(head_buf);
-        qemu_vfree(tail_buf);
     }
+    qemu_vfree(head_buf);
+    qemu_vfree(tail_buf);
 
     return ret;
 }
Signature · 1 line
1.8.1.4
author
#15 lore raw

[Qemu-devel] [PULL 15/18] block: bdrv_aligned_pwritev: Assert overlap range

In reply to Kevin Wolf

This adds assertions that the request that we actually end up passing to the block driver (which includes RMW data and has therefore potentially been rounded to alignment boundaries) is fully covered by the overlap_{offset,size} fields of the associated BdrvTrackedRequest.

---
 block.c | 2 ++
 1 file changed, 2 insertions(+)
block.c +2 -0
index c1d1f74..a027823 100644
@@ -3134,6 +3134,8 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs,
 
     waited = wait_serialising_requests(req);
     assert(!waited || !req->serialising);
+    assert(req->overlap_offset <= offset);
+    assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
 
     ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
 
Signature · 1 line
1.8.1.4
author
#16 lore raw

[Qemu-devel] [PULL 16/18] block: Don't call ROUND_UP with negative values

In reply to Kevin Wolf

The behaviour of the ROUND_UP macro with negative numbers isn't obvious. It happens to do the right thing in this please, but better avoid it.

---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block.c +2 -2
index a027823..b0c5025 100644
@@ -2915,8 +2915,8 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
         }
 
         total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
-        max_nb_sectors = MAX(0, ROUND_UP(total_sectors - sector_num,
-                                         align >> BDRV_SECTOR_BITS));
+        max_nb_sectors = ROUND_UP(MAX(0, total_sectors - sector_num),
+                                  align >> BDRV_SECTOR_BITS);
         if (max_nb_sectors > 0) {
             ret = drv->bdrv_co_readv(bs, sector_num,
                                      MIN(nb_sectors, max_nb_sectors), qiov);
Signature · 1 line
1.8.1.4
author
#17 lore raw

[Qemu-devel] [PULL 17/18] blkdebug: Don't leak bs->file on failure

In reply to Kevin Wolf
---
 block/blkdebug.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
block/blkdebug.c +9 -5
index 56c4cd0..8eb0db0 100644
@@ -396,14 +396,14 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
     if (error_is_set(&local_err)) {
         error_propagate(errp, local_err);
         ret = -EINVAL;
-        goto fail;
+        goto out;
     }
 
     /* Read rules from config file or command line options */
     config = qemu_opt_get(opts, "config");
     ret = read_config(s, config, options, errp);
     if (ret) {
-        goto fail;
+        goto out;
     }
 
     /* Set initial state */
@@ -414,7 +414,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
                           flags, true, false, &local_err);
     if (ret < 0) {
         error_propagate(errp, local_err);
-        goto fail;
+        goto out;
     }
 
     /* Set request alignment */
@@ -424,11 +424,15 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
     } else {
         error_setg(errp, "Invalid alignment");
         ret = -EINVAL;
-        goto fail;
+        goto fail_unref;
     }
 
     ret = 0;
-fail:
+    goto out;
+
+fail_unref:
+    bdrv_unref(bs->file);
+out:
     qemu_opts_del(opts);
     return ret;
 }
Signature · 1 line
1.8.1.4
author
#18 lore raw

[Qemu-devel] [PULL 18/18] block: Fix 32 bit truncation in mark_request_serialising()

In reply to Kevin Wolf

On 32 bit hosts, size_t is too small for align as the bitmask ~(align - 1) will zero out the higher 32 bits of the offset.

While at it, change the local overlap_bytes variable to unsigned to match the field in BdrvTrackedRequest.

---
 block.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
block.c +3 -3
index b0c5025..636aa11 100644
@@ -2240,11 +2240,11 @@ static void tracked_request_begin(BdrvTrackedRequest *req,
     QLIST_INSERT_HEAD(&bs->tracked_requests, req, list);
 }
 
-static void mark_request_serialising(BdrvTrackedRequest *req, size_t align)
+static void mark_request_serialising(BdrvTrackedRequest *req, uint64_t align)
 {
     int64_t overlap_offset = req->offset & ~(align - 1);
-    int overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
-                      - overlap_offset;
+    unsigned int overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
+                               - overlap_offset;
 
     if (!req->serialising) {
         req->bs->serialising_in_flight++;
Signature · 1 line
1.8.1.4
#19 lore raw
In reply to Kevin Wolf
Quoted 4 lines · Kevin Wolf

The following changes since commit 1f6b12f75f2c22f861d0202374033a7594c91707:

Merge remote-tracking branch 'remotes/mwalle/tags/lm32-fixes/20140204' into staging (2014-02-08 15:57:51 +0000)

Quoted 8 lines

are available in the git repository at:

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

for you to fetch changes up to e96126ffa53d36ec75a1ee900a6b7e7c82d9bb9c:

block: Fix 32 bit truncation in mark_request_serialising() (2014-02-09 09:12:39 +0100)

Applied, thanks.

-- PMM