All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/23] Block layer patches
@ 2016-10-27 18:08 Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 01/23] block: Use blk_co_flush() for all BB level flushes Kevin Wolf
                   ` (23 more replies)
  0 siblings, 24 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

The following changes since commit 5929d7e8a0e1f43333bc3528b50397ae8dd0fd6b:

  Merge remote-tracking branch 'remotes/rth/tags/pull-atomic-20161026' into staging (2016-10-27 14:06:34 +0100)

are available in the git repository at:


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

for you to fetch changes up to b74fc7f78e0dd54fbae67d46552cebf81b59ae9f:

  iotests: Add test for NBD's blockdev-add interface (2016-10-27 19:05:23 +0200)

----------------------------------------------------------------
Block layer patches

----------------------------------------------------------------
Kevin Wolf (10):
      block: Use blk_co_flush() for all BB level flushes
      block: Use blk_co_pdiscard() for all BB level discard
      block: Remove bdrv_aio_pdiscard()
      block: Use blk_co_ioctl() for all BB level ioctls
      raw-posix: Don't use bdrv_ioctl()
      block: Remove bdrv_ioctl()
      block: Introduce .bdrv_co_ioctl() driver callback
      raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl
      block: Remove bdrv_aio_ioctl()
      qemu-iotests: Fix typo for NFS with IMGOPTSSYNTAX

Max Reitz (13):
      block/nbd: Drop trailing "." in error messages
      block/nbd: Reject port parameter without host
      block/nbd: Default port in nbd_refresh_filename()
      block/nbd: Use qdict_put()
      block/nbd: Add nbd_has_filename_options_conflict()
      block/nbd: Accept SocketAddress
      block/nbd: Use SocketAddress options
      qapi: Allow blockdev-add for NBD
      iotests.py: Add qemu_nbd function
      iotests.py: Allow concurrent qemu instances
      socket_scm_helper: Accept fd directly
      iotests: Add assert_json_filename_equal() method
      iotests: Add test for NBD's blockdev-add interface

 block/block-backend.c                  |  94 +++++++++----
 block/io.c                             | 111 ++--------------
 block/nbd.c                            | 234 +++++++++++++++++++++------------
 block/raw-posix.c                      |  16 ++-
 block/raw_bsd.c                        |   9 +-
 block/trace-events                     |   1 -
 include/block/block.h                  |   8 +-
 include/block/block_int.h              |   2 +
 include/sysemu/block-backend.h         |   1 +
 qapi/block-core.json                   |  27 +++-
 tests/qemu-iotests/051.out             |   4 +-
 tests/qemu-iotests/051.pc.out          |   4 +-
 tests/qemu-iotests/147                 | 195 +++++++++++++++++++++++++++
 tests/qemu-iotests/147.out             |   5 +
 tests/qemu-iotests/common.rc           |   2 +-
 tests/qemu-iotests/group               |   1 +
 tests/qemu-iotests/iotests.py          |  34 ++++-
 tests/qemu-iotests/socket_scm_helper.c |  29 ++--
 18 files changed, 527 insertions(+), 250 deletions(-)
 create mode 100755 tests/qemu-iotests/147
 create mode 100644 tests/qemu-iotests/147.out

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 01/23] block: Use blk_co_flush() for all BB level flushes
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 02/23] block: Use blk_co_pdiscard() for all BB level discard Kevin Wolf
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

All read/write functions already have a single coroutine-based function
on the BlockBackend level through which all requests go (no matter what
API style the external caller used) and which passes the requests down
to the block node level.

This patch extends this mode of operation to flushes.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/block-backend.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/block/block-backend.c b/block/block-backend.c
index 1a724a8..96bb634 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1099,14 +1099,19 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset,
                         blk_aio_write_entry, flags, cb, opaque);
 }
 
+static void blk_aio_flush_entry(void *opaque)
+{
+    BlkAioEmAIOCB *acb = opaque;
+    BlkRwCo *rwco = &acb->rwco;
+
+    rwco->ret = blk_co_flush(rwco->blk);
+    blk_aio_complete(acb);
+}
+
 BlockAIOCB *blk_aio_flush(BlockBackend *blk,
                           BlockCompletionFunc *cb, void *opaque)
 {
-    if (!blk_is_available(blk)) {
-        return blk_abort_aio_request(blk, cb, opaque, -ENOMEDIUM);
-    }
-
-    return bdrv_aio_flush(blk_bs(blk), cb, opaque);
+    return blk_aio_prwv(blk, 0, 0, NULL, blk_aio_flush_entry, 0, cb, opaque);
 }
 
 BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk,
@@ -1169,13 +1174,15 @@ int blk_co_flush(BlockBackend *blk)
     return bdrv_co_flush(blk_bs(blk));
 }
 
-int blk_flush(BlockBackend *blk)
+static void blk_flush_entry(void *opaque)
 {
-    if (!blk_is_available(blk)) {
-        return -ENOMEDIUM;
-    }
+    BlkRwCo *rwco = opaque;
+    rwco->ret = blk_co_flush(rwco->blk);
+}
 
-    return bdrv_flush(blk_bs(blk));
+int blk_flush(BlockBackend *blk)
+{
+    return blk_prw(blk, 0, NULL, 0, blk_flush_entry, 0);
 }
 
 void blk_drain(BlockBackend *blk)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 02/23] block: Use blk_co_pdiscard() for all BB level discard
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 01/23] block: Use blk_co_flush() for all BB level flushes Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 03/23] block: Remove bdrv_aio_pdiscard() Kevin Wolf
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

All read/write functions already have a single coroutine-based function
on the BlockBackend level through which all requests go (no matter what
API style the external caller used) and which passes the requests down
to the block node level.

This patch extends this mode of operation to discards.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/block-backend.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/block/block-backend.c b/block/block-backend.c
index 96bb634..39336de 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1114,16 +1114,21 @@ BlockAIOCB *blk_aio_flush(BlockBackend *blk,
     return blk_aio_prwv(blk, 0, 0, NULL, blk_aio_flush_entry, 0, cb, opaque);
 }
 
+static void blk_aio_pdiscard_entry(void *opaque)
+{
+    BlkAioEmAIOCB *acb = opaque;
+    BlkRwCo *rwco = &acb->rwco;
+
+    rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, acb->bytes);
+    blk_aio_complete(acb);
+}
+
 BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk,
                              int64_t offset, int count,
                              BlockCompletionFunc *cb, void *opaque)
 {
-    int ret = blk_check_byte_request(blk, offset, count);
-    if (ret < 0) {
-        return blk_abort_aio_request(blk, cb, opaque, ret);
-    }
-
-    return bdrv_aio_pdiscard(blk_bs(blk), offset, count, cb, opaque);
+    return blk_aio_prwv(blk, offset, count, NULL, blk_aio_pdiscard_entry, 0,
+                        cb, opaque);
 }
 
 void blk_aio_cancel(BlockAIOCB *acb)
@@ -1562,14 +1567,15 @@ int blk_truncate(BlockBackend *blk, int64_t offset)
     return bdrv_truncate(blk_bs(blk), offset);
 }
 
-int blk_pdiscard(BlockBackend *blk, int64_t offset, int count)
+static void blk_pdiscard_entry(void *opaque)
 {
-    int ret = blk_check_byte_request(blk, offset, count);
-    if (ret < 0) {
-        return ret;
-    }
+    BlkRwCo *rwco = opaque;
+    rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, rwco->qiov->size);
+}
 
-    return bdrv_pdiscard(blk_bs(blk), offset, count);
+int blk_pdiscard(BlockBackend *blk, int64_t offset, int count)
+{
+    return blk_prw(blk, offset, NULL, count, blk_pdiscard_entry, 0);
 }
 
 int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 03/23] block: Remove bdrv_aio_pdiscard()
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 01/23] block: Use blk_co_flush() for all BB level flushes Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 02/23] block: Use blk_co_pdiscard() for all BB level discard Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 04/23] block: Use blk_co_ioctl() for all BB level ioctls Kevin Wolf
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

It is unused now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/io.c            | 29 -----------------------------
 block/trace-events    |  1 -
 include/block/block.h |  3 ---
 3 files changed, 33 deletions(-)

diff --git a/block/io.c b/block/io.c
index b136c89..ff93ba1 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2196,35 +2196,6 @@ BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
     return &acb->common;
 }
 
-static void coroutine_fn bdrv_aio_pdiscard_co_entry(void *opaque)
-{
-    BlockAIOCBCoroutine *acb = opaque;
-    BlockDriverState *bs = acb->common.bs;
-
-    acb->req.error = bdrv_co_pdiscard(bs, acb->req.offset, acb->req.bytes);
-    bdrv_co_complete(acb);
-}
-
-BlockAIOCB *bdrv_aio_pdiscard(BlockDriverState *bs, int64_t offset, int count,
-                              BlockCompletionFunc *cb, void *opaque)
-{
-    Coroutine *co;
-    BlockAIOCBCoroutine *acb;
-
-    trace_bdrv_aio_pdiscard(bs, offset, count, opaque);
-
-    acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
-    acb->need_bh = true;
-    acb->req.error = -EINPROGRESS;
-    acb->req.offset = offset;
-    acb->req.bytes = count;
-    co = qemu_coroutine_create(bdrv_aio_pdiscard_co_entry, acb);
-    qemu_coroutine_enter(co);
-
-    bdrv_co_maybe_schedule_bh(acb);
-    return &acb->common;
-}
-
 void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
                    BlockCompletionFunc *cb, void *opaque)
 {
diff --git a/block/trace-events b/block/trace-events
index 05fa13c..aff8a96 100644
--- a/block/trace-events
+++ b/block/trace-events
@@ -9,7 +9,6 @@ blk_co_preadv(void *blk, void *bs, int64_t offset, unsigned int bytes, int flags
 blk_co_pwritev(void *blk, void *bs, int64_t offset, unsigned int bytes, int flags) "blk %p bs %p offset %"PRId64" bytes %u flags %x"
 
 # block/io.c
-bdrv_aio_pdiscard(void *bs, int64_t offset, int count, void *opaque) "bs %p offset %"PRId64" count %d opaque %p"
 bdrv_aio_flush(void *bs, void *opaque) "bs %p opaque %p"
 bdrv_aio_readv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
 bdrv_aio_writev(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
diff --git a/include/block/block.h b/include/block/block.h
index 107c603..99a15a6 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -314,9 +314,6 @@ BlockAIOCB *bdrv_aio_writev(BdrvChild *child, int64_t sector_num,
                             BlockCompletionFunc *cb, void *opaque);
 BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
                            BlockCompletionFunc *cb, void *opaque);
-BlockAIOCB *bdrv_aio_pdiscard(BlockDriverState *bs,
-                              int64_t offset, int count,
-                              BlockCompletionFunc *cb, void *opaque);
 void bdrv_aio_cancel(BlockAIOCB *acb);
 void bdrv_aio_cancel_async(BlockAIOCB *acb);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 04/23] block: Use blk_co_ioctl() for all BB level ioctls
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (2 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 03/23] block: Remove bdrv_aio_pdiscard() Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 05/23] raw-posix: Don't use bdrv_ioctl() Kevin Wolf
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

All read/write functions already have a single coroutine-based function
on the BlockBackend level through which all requests go (no matter what
API style the external caller used) and which passes the requests down
to the block node level.

This patch exports a bdrv_co_ioctl() function and uses it to extend this
mode of operation to ioctls.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/block-backend.c          | 39 +++++++++++++++++++++++++++++++++------
 block/io.c                     |  8 ++++----
 include/block/block.h          |  1 +
 include/sysemu/block-backend.h |  1 +
 4 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/block/block-backend.c b/block/block-backend.c
index 39336de..c53ca30 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1141,23 +1141,50 @@ void blk_aio_cancel_async(BlockAIOCB *acb)
     bdrv_aio_cancel_async(acb);
 }
 
-int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf)
+int blk_co_ioctl(BlockBackend *blk, unsigned long int req, void *buf)
 {
     if (!blk_is_available(blk)) {
         return -ENOMEDIUM;
     }
 
-    return bdrv_ioctl(blk_bs(blk), req, buf);
+    return bdrv_co_ioctl(blk_bs(blk), req, buf);
+}
+
+static void blk_ioctl_entry(void *opaque)
+{
+    BlkRwCo *rwco = opaque;
+    rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset,
+                             rwco->qiov->iov[0].iov_base);
+}
+
+int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf)
+{
+    return blk_prw(blk, req, buf, 0, blk_ioctl_entry, 0);
+}
+
+static void blk_aio_ioctl_entry(void *opaque)
+{
+    BlkAioEmAIOCB *acb = opaque;
+    BlkRwCo *rwco = &acb->rwco;
+
+    rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset,
+                             rwco->qiov->iov[0].iov_base);
+    blk_aio_complete(acb);
 }
 
 BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf,
                           BlockCompletionFunc *cb, void *opaque)
 {
-    if (!blk_is_available(blk)) {
-        return blk_abort_aio_request(blk, cb, opaque, -ENOMEDIUM);
-    }
+    QEMUIOVector qiov;
+    struct iovec iov;
+
+    iov = (struct iovec) {
+        .iov_base = buf,
+        .iov_len = 0,
+    };
+    qemu_iovec_init_external(&qiov, &iov, 1);
 
-    return bdrv_aio_ioctl(blk_bs(blk), req, buf, cb, opaque);
+    return blk_aio_prwv(blk, req, 0, &qiov, blk_aio_ioctl_entry, 0, cb, opaque);
 }
 
 int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int count)
diff --git a/block/io.c b/block/io.c
index ff93ba1..7c119d5 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2492,7 +2492,7 @@ int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int count)
     return rwco.ret;
 }
 
-static int bdrv_co_do_ioctl(BlockDriverState *bs, int req, void *buf)
+int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf)
 {
     BlockDriver *drv = bs->drv;
     BdrvTrackedRequest tracked_req;
@@ -2528,7 +2528,7 @@ typedef struct {
 static void coroutine_fn bdrv_co_ioctl_entry(void *opaque)
 {
     BdrvIoctlCoData *data = opaque;
-    data->ret = bdrv_co_do_ioctl(data->bs, data->req, data->buf);
+    data->ret = bdrv_co_ioctl(data->bs, data->req, data->buf);
 }
 
 /* needed for generic scsi interface */
@@ -2558,8 +2558,8 @@ int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
 static void coroutine_fn bdrv_co_aio_ioctl_entry(void *opaque)
 {
     BlockAIOCBCoroutine *acb = opaque;
-    acb->req.error = bdrv_co_do_ioctl(acb->common.bs,
-                                      acb->req.req, acb->req.buf);
+    acb->req.error = bdrv_co_ioctl(acb->common.bs,
+                                   acb->req.req, acb->req.buf);
     bdrv_co_complete(acb);
 }
 
diff --git a/include/block/block.h b/include/block/block.h
index 99a15a6..e06db62 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -318,6 +318,7 @@ void bdrv_aio_cancel(BlockAIOCB *acb);
 void bdrv_aio_cancel_async(BlockAIOCB *acb);
 
 /* sg packet commands */
+int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf);
 int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf);
 BlockAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
         unsigned long int req, void *buf,
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index b07159b..6444e41 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -146,6 +146,7 @@ BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, int64_t offset, int count,
                              BlockCompletionFunc *cb, void *opaque);
 void blk_aio_cancel(BlockAIOCB *acb);
 void blk_aio_cancel_async(BlockAIOCB *acb);
+int blk_co_ioctl(BlockBackend *blk, unsigned long int req, void *buf);
 int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf);
 BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf,
                           BlockCompletionFunc *cb, void *opaque);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 05/23] raw-posix: Don't use bdrv_ioctl()
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (3 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 04/23] block: Use blk_co_ioctl() for all BB level ioctls Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 06/23] block: Remove bdrv_ioctl() Kevin Wolf
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

Instead of letting raw-posix use the bdrv_ioctl() abstraction to issue
an ioctl to itself, just call ioctl() directly.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/raw-posix.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index f481e57..247e47b 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -2069,13 +2069,23 @@ static bool hdev_is_sg(BlockDriverState *bs)
 
 #if defined(__linux__)
 
+    BDRVRawState *s = bs->opaque;
     struct stat st;
     struct sg_scsi_id scsiid;
     int sg_version;
+    int ret;
+
+    if (stat(bs->filename, &st) < 0 || !S_ISCHR(st.st_mode)) {
+        return false;
+    }
 
-    if (stat(bs->filename, &st) >= 0 && S_ISCHR(st.st_mode) &&
-        !bdrv_ioctl(bs, SG_GET_VERSION_NUM, &sg_version) &&
-        !bdrv_ioctl(bs, SG_GET_SCSI_ID, &scsiid)) {
+    ret = ioctl(s->fd, SG_GET_VERSION_NUM, &sg_version);
+    if (ret < 0) {
+        return false;
+    }
+
+    ret = ioctl(s->fd, SG_GET_SCSI_ID, &scsiid);
+    if (ret >= 0) {
         DPRINTF("SG device found: type=%d, version=%d\n",
             scsiid.scsi_type, sg_version);
         return true;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 06/23] block: Remove bdrv_ioctl()
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (4 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 05/23] raw-posix: Don't use bdrv_ioctl() Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 07/23] block: Introduce .bdrv_co_ioctl() driver callback Kevin Wolf
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

It is unused now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/io.c            | 37 -------------------------------------
 include/block/block.h |  1 -
 2 files changed, 38 deletions(-)

diff --git a/block/io.c b/block/io.c
index 7c119d5..35fdcca 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2518,43 +2518,6 @@ out:
     return co.ret;
 }
 
-typedef struct {
-    BlockDriverState *bs;
-    int req;
-    void *buf;
-    int ret;
-} BdrvIoctlCoData;
-
-static void coroutine_fn bdrv_co_ioctl_entry(void *opaque)
-{
-    BdrvIoctlCoData *data = opaque;
-    data->ret = bdrv_co_ioctl(data->bs, data->req, data->buf);
-}
-
-/* needed for generic scsi interface */
-int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
-{
-    BdrvIoctlCoData data = {
-        .bs = bs,
-        .req = req,
-        .buf = buf,
-        .ret = -EINPROGRESS,
-    };
-
-    if (qemu_in_coroutine()) {
-        /* Fast-path if already in coroutine context */
-        bdrv_co_ioctl_entry(&data);
-    } else {
-        Coroutine *co = qemu_coroutine_create(bdrv_co_ioctl_entry, &data);
-
-        qemu_coroutine_enter(co);
-        while (data.ret == -EINPROGRESS) {
-            aio_poll(bdrv_get_aio_context(bs), true);
-        }
-    }
-    return data.ret;
-}
-
 static void coroutine_fn bdrv_co_aio_ioctl_entry(void *opaque)
 {
     BlockAIOCBCoroutine *acb = opaque;
diff --git a/include/block/block.h b/include/block/block.h
index e06db62..e0a54aa 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -319,7 +319,6 @@ void bdrv_aio_cancel_async(BlockAIOCB *acb);
 
 /* sg packet commands */
 int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf);
-int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf);
 BlockAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
         unsigned long int req, void *buf,
         BlockCompletionFunc *cb, void *opaque);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 07/23] block: Introduce .bdrv_co_ioctl() driver callback
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (5 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 06/23] block: Remove bdrv_ioctl() Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 08/23] raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl Kevin Wolf
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

This allows drivers to implement ioctls in a coroutine-based way.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/io.c                | 16 ++++++++++------
 include/block/block_int.h |  2 ++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/block/io.c b/block/io.c
index 35fdcca..370c7d8 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2502,17 +2502,21 @@ int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf)
     BlockAIOCB *acb;
 
     tracked_request_begin(&tracked_req, bs, 0, 0, BDRV_TRACKED_IOCTL);
-    if (!drv || !drv->bdrv_aio_ioctl) {
+    if (!drv || (!drv->bdrv_aio_ioctl && !drv->bdrv_co_ioctl)) {
         co.ret = -ENOTSUP;
         goto out;
     }
 
-    acb = drv->bdrv_aio_ioctl(bs, req, buf, bdrv_co_io_em_complete, &co);
-    if (!acb) {
-        co.ret = -ENOTSUP;
-        goto out;
+    if (drv->bdrv_co_ioctl) {
+        co.ret = drv->bdrv_co_ioctl(bs, req, buf);
+    } else {
+        acb = drv->bdrv_aio_ioctl(bs, req, buf, bdrv_co_io_em_complete, &co);
+        if (!acb) {
+            co.ret = -ENOTSUP;
+            goto out;
+        }
+        qemu_coroutine_yield();
     }
-    qemu_coroutine_yield();
 out:
     tracked_request_end(&tracked_req);
     return co.ret;
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 3e79228..e96e9ad 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -244,6 +244,8 @@ struct BlockDriver {
     BlockAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs,
         unsigned long int req, void *buf,
         BlockCompletionFunc *cb, void *opaque);
+    int coroutine_fn (*bdrv_co_ioctl)(BlockDriverState *bs,
+                                      unsigned long int req, void *buf);
 
     /* List of options for creating images, terminated by name == NULL */
     QemuOptsList *create_opts;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 08/23] raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (6 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 07/23] block: Introduce .bdrv_co_ioctl() driver callback Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 09/23] block: Remove bdrv_aio_ioctl() Kevin Wolf
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

It's the simpler interface to use for the raw format driver.

Apart from that, this removes the last user of the AIO emulation
implemented by bdrv_aio_ioctl().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/raw_bsd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index 588d408..fc16ec1 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -176,12 +176,9 @@ static void raw_lock_medium(BlockDriverState *bs, bool locked)
     bdrv_lock_medium(bs->file->bs, locked);
 }
 
-static BlockAIOCB *raw_aio_ioctl(BlockDriverState *bs,
-                                 unsigned long int req, void *buf,
-                                 BlockCompletionFunc *cb,
-                                 void *opaque)
+static int raw_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
 {
-    return bdrv_aio_ioctl(bs->file->bs, req, buf, cb, opaque);
+    return bdrv_co_ioctl(bs->file->bs, req, buf);
 }
 
 static int raw_has_zero_init(BlockDriverState *bs)
@@ -261,7 +258,7 @@ BlockDriver bdrv_raw = {
     .bdrv_media_changed   = &raw_media_changed,
     .bdrv_eject           = &raw_eject,
     .bdrv_lock_medium     = &raw_lock_medium,
-    .bdrv_aio_ioctl       = &raw_aio_ioctl,
+    .bdrv_co_ioctl        = &raw_co_ioctl,
     .create_opts          = &raw_create_opts,
     .bdrv_has_zero_init   = &raw_has_zero_init
 };
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 09/23] block: Remove bdrv_aio_ioctl()
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (7 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 08/23] raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 10/23] qemu-iotests: Fix typo for NFS with IMGOPTSSYNTAX Kevin Wolf
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

It is unused now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/io.c            | 27 ---------------------------
 include/block/block.h |  3 ---
 2 files changed, 30 deletions(-)

diff --git a/block/io.c b/block/io.c
index 370c7d8..79cbbdf 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2522,33 +2522,6 @@ out:
     return co.ret;
 }
 
-static void coroutine_fn bdrv_co_aio_ioctl_entry(void *opaque)
-{
-    BlockAIOCBCoroutine *acb = opaque;
-    acb->req.error = bdrv_co_ioctl(acb->common.bs,
-                                   acb->req.req, acb->req.buf);
-    bdrv_co_complete(acb);
-}
-
-BlockAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
-        unsigned long int req, void *buf,
-        BlockCompletionFunc *cb, void *opaque)
-{
-    BlockAIOCBCoroutine *acb = qemu_aio_get(&bdrv_em_co_aiocb_info,
-                                            bs, cb, opaque);
-    Coroutine *co;
-
-    acb->need_bh = true;
-    acb->req.error = -EINPROGRESS;
-    acb->req.req = req;
-    acb->req.buf = buf;
-    co = qemu_coroutine_create(bdrv_co_aio_ioctl_entry, acb);
-    qemu_coroutine_enter(co);
-
-    bdrv_co_maybe_schedule_bh(acb);
-    return &acb->common;
-}
-
 void *qemu_blockalign(BlockDriverState *bs, size_t size)
 {
     return qemu_memalign(bdrv_opt_mem_align(bs), size);
diff --git a/include/block/block.h b/include/block/block.h
index e0a54aa..398a050 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -319,9 +319,6 @@ void bdrv_aio_cancel_async(BlockAIOCB *acb);
 
 /* sg packet commands */
 int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf);
-BlockAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
-        unsigned long int req, void *buf,
-        BlockCompletionFunc *cb, void *opaque);
 
 /* Invalidate any cached metadata used by image formats */
 void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 10/23] qemu-iotests: Fix typo for NFS with IMGOPTSSYNTAX
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (8 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 09/23] block: Remove bdrv_aio_ioctl() Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 11/23] block/nbd: Drop trailing "." in error messages Kevin Wolf
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

Commit 076003f5 added configuration for NFS with IMGOPTSSYNTAX enabled,
but it didn't use the right variable name: $TEST_DIR_OPTS doesn't exist.
This fixes the mistake.

However, this doesn't make anything work that was broken before: The
only way to get IMGOPTSSYNTAX is with -luks, but the combination of
-luks and -nfs doesn't get qemu-img create commands right (because
qemu-img create doesn't support --image-opts yet), so even after this
fix some more work would be required to make the tests pass.

Reported-by: Tomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/common.rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 126bd67..3213765 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -69,7 +69,7 @@ if [ "$IMGOPTSSYNTAX" = "true" ]; then
         TEST_IMG="$DRIVER,file.driver=ssh,file.host=127.0.0.1,file.path=$TEST_IMG_FILE"
     elif [ "$IMGPROTO" = "nfs" ]; then
         TEST_DIR="$DRIVER,file.driver=nfs,file.filename=nfs://127.0.0.1/$TEST_DIR"
-        TEST_IMG=$TEST_DIR_OPTS/t.$IMGFMT
+        TEST_IMG=$TEST_DIR/t.$IMGFMT
     elif [ "$IMGPROTO" = "archipelago" ]; then
         TEST_IMG="$DRIVER,file.driver=archipelago,file.volume=:at.$IMGFMT"
     else
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 11/23] block/nbd: Drop trailing "." in error messages
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (9 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 10/23] qemu-iotests: Fix typo for NFS with IMGOPTSSYNTAX Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 12/23] block/nbd: Reject port parameter without host Kevin Wolf
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/nbd.c                   | 4 ++--
 tests/qemu-iotests/051.out    | 4 ++--
 tests/qemu-iotests/051.pc.out | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index 6bc06d6..ce7c14f 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -200,9 +200,9 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp)
 
     if (!s->path == !s->host) {
         if (s->path) {
-            error_setg(errp, "path and host may not be used at the same time.");
+            error_setg(errp, "path and host may not be used at the same time");
         } else {
-            error_setg(errp, "one of path and host must be specified.");
+            error_setg(errp, "one of path and host must be specified");
         }
         return NULL;
     }
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
index 408d613..9e584fe 100644
--- a/tests/qemu-iotests/051.out
+++ b/tests/qemu-iotests/051.out
@@ -222,7 +222,7 @@ Testing: -drive driver=file
 QEMU_PROG: -drive driver=file: The 'file' block driver requires a file name
 
 Testing: -drive driver=nbd
-QEMU_PROG: -drive driver=nbd: one of path and host must be specified.
+QEMU_PROG: -drive driver=nbd: one of path and host must be specified
 
 Testing: -drive driver=raw
 QEMU_PROG: -drive driver=raw: Can't use 'raw' as a block driver for the protocol level
@@ -231,7 +231,7 @@ Testing: -drive file.driver=file
 QEMU_PROG: -drive file.driver=file: The 'file' block driver requires a file name
 
 Testing: -drive file.driver=nbd
-QEMU_PROG: -drive file.driver=nbd: one of path and host must be specified.
+QEMU_PROG: -drive file.driver=nbd: one of path and host must be specified
 
 Testing: -drive file.driver=raw
 QEMU_PROG: -drive file.driver=raw: Can't use 'raw' as a block driver for the protocol level
diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
index ec6d222..6395a30 100644
--- a/tests/qemu-iotests/051.pc.out
+++ b/tests/qemu-iotests/051.pc.out
@@ -316,7 +316,7 @@ Testing: -drive driver=file
 QEMU_PROG: -drive driver=file: The 'file' block driver requires a file name
 
 Testing: -drive driver=nbd
-QEMU_PROG: -drive driver=nbd: one of path and host must be specified.
+QEMU_PROG: -drive driver=nbd: one of path and host must be specified
 
 Testing: -drive driver=raw
 QEMU_PROG: -drive driver=raw: Can't use 'raw' as a block driver for the protocol level
@@ -325,7 +325,7 @@ Testing: -drive file.driver=file
 QEMU_PROG: -drive file.driver=file: The 'file' block driver requires a file name
 
 Testing: -drive file.driver=nbd
-QEMU_PROG: -drive file.driver=nbd: one of path and host must be specified.
+QEMU_PROG: -drive file.driver=nbd: one of path and host must be specified
 
 Testing: -drive file.driver=raw
 QEMU_PROG: -drive file.driver=raw: Can't use 'raw' as a block driver for the protocol level
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 12/23] block/nbd: Reject port parameter without host
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (10 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 11/23] block/nbd: Drop trailing "." in error messages Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 13/23] block/nbd: Default port in nbd_refresh_filename() Kevin Wolf
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Currently, a port that is passed along with a UNIX socket path is
silently ignored. That is not exactly ideal, it should be an error
instead.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/nbd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index ce7c14f..eaca33c 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -197,6 +197,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp)
 
     s->path = g_strdup(qemu_opt_get(opts, "path"));
     s->host = g_strdup(qemu_opt_get(opts, "host"));
+    s->port = g_strdup(qemu_opt_get(opts, "port"));
 
     if (!s->path == !s->host) {
         if (s->path) {
@@ -206,6 +207,10 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp)
         }
         return NULL;
     }
+    if (s->port && !s->host) {
+        error_setg(errp, "port may not be used without host");
+        return NULL;
+    }
 
     saddr = g_new0(SocketAddress, 1);
 
@@ -217,8 +222,6 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp)
     } else {
         InetSocketAddress *inet;
 
-        s->port = g_strdup(qemu_opt_get(opts, "port"));
-
         saddr->type = SOCKET_ADDRESS_KIND_INET;
         inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);
         inet->host = g_strdup(s->host);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 13/23] block/nbd: Default port in nbd_refresh_filename()
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (11 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 12/23] block/nbd: Reject port parameter without host Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 14/23] block/nbd: Use qdict_put() Kevin Wolf
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Instead of not emitting the port in nbd_refresh_filename(), just set it
to the default if the user did not specify it. This makes the logic a
bit simpler.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/nbd.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index eaca33c..c77a969 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -444,6 +444,7 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
 {
     BDRVNBDState *s = bs->opaque;
     QDict *opts = qdict_new();
+    const char *port = s->port ?: stringify(NBD_DEFAULT_PORT);
 
     qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("nbd")));
 
@@ -453,27 +454,19 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
     } else if (s->path && !s->export) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
                  "nbd+unix://?socket=%s", s->path);
-    } else if (!s->path && s->export && s->port) {
+    } else if (!s->path && s->export) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
-                 "nbd://%s:%s/%s", s->host, s->port, s->export);
-    } else if (!s->path && s->export && !s->port) {
+                 "nbd://%s:%s/%s", s->host, port, s->export);
+    } else if (!s->path && !s->export) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
-                 "nbd://%s/%s", s->host, s->export);
-    } else if (!s->path && !s->export && s->port) {
-        snprintf(bs->exact_filename, sizeof(bs->exact_filename),
-                 "nbd://%s:%s", s->host, s->port);
-    } else if (!s->path && !s->export && !s->port) {
-        snprintf(bs->exact_filename, sizeof(bs->exact_filename),
-                 "nbd://%s", s->host);
+                 "nbd://%s:%s", s->host, port);
     }
 
     if (s->path) {
         qdict_put_obj(opts, "path", QOBJECT(qstring_from_str(s->path)));
-    } else if (s->port) {
-        qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(s->host)));
-        qdict_put_obj(opts, "port", QOBJECT(qstring_from_str(s->port)));
     } else {
         qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(s->host)));
+        qdict_put_obj(opts, "port", QOBJECT(qstring_from_str(port)));
     }
     if (s->export) {
         qdict_put_obj(opts, "export", QOBJECT(qstring_from_str(s->export)));
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 14/23] block/nbd: Use qdict_put()
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (12 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 13/23] block/nbd: Default port in nbd_refresh_filename() Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:08 ` [Qemu-devel] [PULL 15/23] block/nbd: Add nbd_has_filename_options_conflict() Kevin Wolf
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Instead of inlining this nice macro (i.e. resorting to
qdict_put_obj(..., QOBJECT(...))), use it.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/nbd.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index c77a969..c539fb5 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -446,7 +446,7 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
     QDict *opts = qdict_new();
     const char *port = s->port ?: stringify(NBD_DEFAULT_PORT);
 
-    qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("nbd")));
+    qdict_put(opts, "driver", qstring_from_str("nbd"));
 
     if (s->path && s->export) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
@@ -463,17 +463,16 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
     }
 
     if (s->path) {
-        qdict_put_obj(opts, "path", QOBJECT(qstring_from_str(s->path)));
+        qdict_put(opts, "path", qstring_from_str(s->path));
     } else {
-        qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(s->host)));
-        qdict_put_obj(opts, "port", QOBJECT(qstring_from_str(port)));
+        qdict_put(opts, "host", qstring_from_str(s->host));
+        qdict_put(opts, "port", qstring_from_str(port));
     }
     if (s->export) {
-        qdict_put_obj(opts, "export", QOBJECT(qstring_from_str(s->export)));
+        qdict_put(opts, "export", qstring_from_str(s->export));
     }
     if (s->tlscredsid) {
-        qdict_put_obj(opts, "tls-creds",
-                      QOBJECT(qstring_from_str(s->tlscredsid)));
+        qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid));
     }
 
     bs->full_open_options = opts;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 15/23] block/nbd: Add nbd_has_filename_options_conflict()
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (13 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 14/23] block/nbd: Use qdict_put() Kevin Wolf
@ 2016-10-27 18:08 ` Kevin Wolf
  2016-10-27 18:09 ` [Qemu-devel] [PULL 16/23] block/nbd: Accept SocketAddress Kevin Wolf
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Right now, we have four possible options that conflict with specifying
an NBD filename, and a future patch will add another one ("address").
This future option is a nested QDict that is flattened at this point,
requiring us to test each option whether its key has an "address."
prefix. Therefore, we will then need to iterate through all options
(including the "export" option which was not covered so far).

Adding this iteration logic now will simplify adding the new option
later. A nice side effect is that the user will not receive a long list
of five options which are not supposed to be specified with a filename,
but we can actually print the problematic option.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/nbd.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index c539fb5..cdab20f 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -123,6 +123,25 @@ out:
     return ret;
 }
 
+static bool nbd_has_filename_options_conflict(QDict *options, Error **errp)
+{
+    const QDictEntry *e;
+
+    for (e = qdict_first(options); e; e = qdict_next(options, e)) {
+        if (!strcmp(e->key, "host") ||
+            !strcmp(e->key, "port") ||
+            !strcmp(e->key, "path") ||
+            !strcmp(e->key, "export"))
+        {
+            error_setg(errp, "Option '%s' cannot be used with a file name",
+                       e->key);
+            return true;
+        }
+    }
+
+    return false;
+}
+
 static void nbd_parse_filename(const char *filename, QDict *options,
                                Error **errp)
 {
@@ -131,12 +150,7 @@ static void nbd_parse_filename(const char *filename, QDict *options,
     const char *host_spec;
     const char *unixpath;
 
-    if (qdict_haskey(options, "host")
-        || qdict_haskey(options, "port")
-        || qdict_haskey(options, "path"))
-    {
-        error_setg(errp, "host/port/path and a file name may not be specified "
-                         "at the same time");
+    if (nbd_has_filename_options_conflict(options, errp)) {
         return;
     }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 16/23] block/nbd: Accept SocketAddress
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (14 preceding siblings ...)
  2016-10-27 18:08 ` [Qemu-devel] [PULL 15/23] block/nbd: Add nbd_has_filename_options_conflict() Kevin Wolf
@ 2016-10-27 18:09 ` Kevin Wolf
  2016-10-27 18:09 ` [Qemu-devel] [PULL 17/23] block/nbd: Use SocketAddress options Kevin Wolf
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Add a new option "server" to the NBD block driver which accepts a
SocketAddress.

"path", "host" and "port" are still supported as legacy options and are
mapped to their corresponding SocketAddress representation.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/nbd.c                   | 175 +++++++++++++++++++++++++++---------------
 tests/qemu-iotests/051.out    |   4 +-
 tests/qemu-iotests/051.pc.out |   4 +-
 3 files changed, 117 insertions(+), 66 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index cdab20f..a778692 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -32,6 +32,9 @@
 #include "qemu/uri.h"
 #include "block/block_int.h"
 #include "qemu/module.h"
+#include "qapi-visit.h"
+#include "qapi/qobject-input-visitor.h"
+#include "qapi/qobject-output-visitor.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qint.h"
@@ -44,7 +47,8 @@ typedef struct BDRVNBDState {
     NbdClientSession client;
 
     /* For nbd_refresh_filename() */
-    char *path, *host, *port, *export, *tlscredsid;
+    SocketAddress *saddr;
+    char *export, *tlscredsid;
 } BDRVNBDState;
 
 static int nbd_parse_uri(const char *filename, QDict *options)
@@ -131,7 +135,8 @@ static bool nbd_has_filename_options_conflict(QDict *options, Error **errp)
         if (!strcmp(e->key, "host") ||
             !strcmp(e->key, "port") ||
             !strcmp(e->key, "path") ||
-            !strcmp(e->key, "export"))
+            !strcmp(e->key, "export") ||
+            strstart(e->key, "server.", NULL))
         {
             error_setg(errp, "Option '%s' cannot be used with a file name",
                        e->key);
@@ -205,50 +210,81 @@ out:
     g_free(file);
 }
 
-static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp)
+static bool nbd_process_legacy_socket_options(QDict *output_options,
+                                              QemuOpts *legacy_opts,
+                                              Error **errp)
 {
-    SocketAddress *saddr;
+    const char *path = qemu_opt_get(legacy_opts, "path");
+    const char *host = qemu_opt_get(legacy_opts, "host");
+    const char *port = qemu_opt_get(legacy_opts, "port");
+    const QDictEntry *e;
 
-    s->path = g_strdup(qemu_opt_get(opts, "path"));
-    s->host = g_strdup(qemu_opt_get(opts, "host"));
-    s->port = g_strdup(qemu_opt_get(opts, "port"));
+    if (!path && !host && !port) {
+        return true;
+    }
 
-    if (!s->path == !s->host) {
-        if (s->path) {
-            error_setg(errp, "path and host may not be used at the same time");
-        } else {
-            error_setg(errp, "one of path and host must be specified");
+    for (e = qdict_first(output_options); e; e = qdict_next(output_options, e))
+    {
+        if (strstart(e->key, "server.", NULL)) {
+            error_setg(errp, "Cannot use 'server' and path/host/port at the "
+                       "same time");
+            return false;
         }
-        return NULL;
     }
-    if (s->port && !s->host) {
-        error_setg(errp, "port may not be used without host");
-        return NULL;
+
+    if (path && host) {
+        error_setg(errp, "path and host may not be used at the same time");
+        return false;
+    } else if (path) {
+        if (port) {
+            error_setg(errp, "port may not be used without host");
+            return false;
+        }
+
+        qdict_put(output_options, "server.type", qstring_from_str("unix"));
+        qdict_put(output_options, "server.data.path", qstring_from_str(path));
+    } else if (host) {
+        qdict_put(output_options, "server.type", qstring_from_str("inet"));
+        qdict_put(output_options, "server.data.host", qstring_from_str(host));
+        qdict_put(output_options, "server.data.port",
+                  qstring_from_str(port ?: stringify(NBD_DEFAULT_PORT)));
     }
 
-    saddr = g_new0(SocketAddress, 1);
+    return true;
+}
 
-    if (s->path) {
-        UnixSocketAddress *q_unix;
-        saddr->type = SOCKET_ADDRESS_KIND_UNIX;
-        q_unix = saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
-        q_unix->path = g_strdup(s->path);
-    } else {
-        InetSocketAddress *inet;
-
-        saddr->type = SOCKET_ADDRESS_KIND_INET;
-        inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);
-        inet->host = g_strdup(s->host);
-        inet->port = g_strdup(s->port);
-        if (!inet->port) {
-            inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT);
-        }
+static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, Error **errp)
+{
+    SocketAddress *saddr = NULL;
+    QDict *addr = NULL;
+    QObject *crumpled_addr = NULL;
+    Visitor *iv = NULL;
+    Error *local_err = NULL;
+
+    qdict_extract_subqdict(options, &addr, "server.");
+    if (!qdict_size(addr)) {
+        error_setg(errp, "NBD server address missing");
+        goto done;
     }
 
-    s->client.is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
+    crumpled_addr = qdict_crumple(addr, errp);
+    if (!crumpled_addr) {
+        goto done;
+    }
 
-    s->export = g_strdup(qemu_opt_get(opts, "export"));
+    iv = qobject_input_visitor_new(crumpled_addr, true);
+    visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        goto done;
+    }
 
+    s->client.is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
+
+done:
+    QDECREF(addr);
+    qobject_decref(crumpled_addr);
+    visit_free(iv);
     return saddr;
 }
 
@@ -349,7 +385,6 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
     QemuOpts *opts = NULL;
     Error *local_err = NULL;
     QIOChannelSocket *sioc = NULL;
-    SocketAddress *saddr = NULL;
     QCryptoTLSCreds *tlscreds = NULL;
     const char *hostname = NULL;
     int ret = -EINVAL;
@@ -361,12 +396,19 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
         goto error;
     }
 
+    /* Translate @host, @port, and @path to a SocketAddress */
+    if (!nbd_process_legacy_socket_options(options, opts, errp)) {
+        goto error;
+    }
+
     /* Pop the config into our state object. Exit if invalid. */
-    saddr = nbd_config(s, opts, errp);
-    if (!saddr) {
+    s->saddr = nbd_config(s, options, errp);
+    if (!s->saddr) {
         goto error;
     }
 
+    s->export = g_strdup(qemu_opt_get(opts, "export"));
+
     s->tlscredsid = g_strdup(qemu_opt_get(opts, "tls-creds"));
     if (s->tlscredsid) {
         tlscreds = nbd_get_tls_creds(s->tlscredsid, errp);
@@ -374,17 +416,17 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
             goto error;
         }
 
-        if (saddr->type != SOCKET_ADDRESS_KIND_INET) {
+        if (s->saddr->type != SOCKET_ADDRESS_KIND_INET) {
             error_setg(errp, "TLS only supported over IP sockets");
             goto error;
         }
-        hostname = saddr->u.inet.data->host;
+        hostname = s->saddr->u.inet.data->host;
     }
 
     /* establish TCP connection, return error if it fails
      * TODO: Configurable retry-until-timeout behaviour.
      */
-    sioc = nbd_establish_connection(saddr, errp);
+    sioc = nbd_establish_connection(s->saddr, errp);
     if (!sioc) {
         ret = -ECONNREFUSED;
         goto error;
@@ -401,13 +443,10 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
         object_unref(OBJECT(tlscreds));
     }
     if (ret < 0) {
-        g_free(s->path);
-        g_free(s->host);
-        g_free(s->port);
+        qapi_free_SocketAddress(s->saddr);
         g_free(s->export);
         g_free(s->tlscredsid);
     }
-    qapi_free_SocketAddress(saddr);
     qemu_opts_del(opts);
     return ret;
 }
@@ -429,9 +468,7 @@ static void nbd_close(BlockDriverState *bs)
 
     nbd_client_close(bs);
 
-    g_free(s->path);
-    g_free(s->host);
-    g_free(s->port);
+    qapi_free_SocketAddress(s->saddr);
     g_free(s->export);
     g_free(s->tlscredsid);
 }
@@ -458,30 +495,43 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
 {
     BDRVNBDState *s = bs->opaque;
     QDict *opts = qdict_new();
-    const char *port = s->port ?: stringify(NBD_DEFAULT_PORT);
+    QObject *saddr_qdict;
+    Visitor *ov;
+    const char *host = NULL, *port = NULL, *path = NULL;
+
+    if (s->saddr->type == SOCKET_ADDRESS_KIND_INET) {
+        const InetSocketAddress *inet = s->saddr->u.inet.data;
+        if (!inet->has_ipv4 && !inet->has_ipv6 && !inet->has_to) {
+            host = inet->host;
+            port = inet->port;
+        }
+    } else if (s->saddr->type == SOCKET_ADDRESS_KIND_UNIX) {
+        path = s->saddr->u.q_unix.data->path;
+    }
 
     qdict_put(opts, "driver", qstring_from_str("nbd"));
 
-    if (s->path && s->export) {
+    if (path && s->export) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
-                 "nbd+unix:///%s?socket=%s", s->export, s->path);
-    } else if (s->path && !s->export) {
+                 "nbd+unix:///%s?socket=%s", s->export, path);
+    } else if (path && !s->export) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
-                 "nbd+unix://?socket=%s", s->path);
-    } else if (!s->path && s->export) {
+                 "nbd+unix://?socket=%s", path);
+    } else if (host && s->export) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
-                 "nbd://%s:%s/%s", s->host, port, s->export);
-    } else if (!s->path && !s->export) {
+                 "nbd://%s:%s/%s", host, port, s->export);
+    } else if (host && !s->export) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
-                 "nbd://%s:%s", s->host, port);
+                 "nbd://%s:%s", host, port);
     }
 
-    if (s->path) {
-        qdict_put(opts, "path", qstring_from_str(s->path));
-    } else {
-        qdict_put(opts, "host", qstring_from_str(s->host));
-        qdict_put(opts, "port", qstring_from_str(port));
-    }
+    ov = qobject_output_visitor_new(&saddr_qdict);
+    visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort);
+    visit_complete(ov, &saddr_qdict);
+    assert(qobject_type(saddr_qdict) == QTYPE_QDICT);
+
+    qdict_put_obj(opts, "server", saddr_qdict);
+
     if (s->export) {
         qdict_put(opts, "export", qstring_from_str(s->export));
     }
@@ -489,6 +539,7 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
         qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid));
     }
 
+    qdict_flatten(opts);
     bs->full_open_options = opts;
 }
 
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
index 9e584fe..42bf416 100644
--- a/tests/qemu-iotests/051.out
+++ b/tests/qemu-iotests/051.out
@@ -222,7 +222,7 @@ Testing: -drive driver=file
 QEMU_PROG: -drive driver=file: The 'file' block driver requires a file name
 
 Testing: -drive driver=nbd
-QEMU_PROG: -drive driver=nbd: one of path and host must be specified
+QEMU_PROG: -drive driver=nbd: NBD server address missing
 
 Testing: -drive driver=raw
 QEMU_PROG: -drive driver=raw: Can't use 'raw' as a block driver for the protocol level
@@ -231,7 +231,7 @@ Testing: -drive file.driver=file
 QEMU_PROG: -drive file.driver=file: The 'file' block driver requires a file name
 
 Testing: -drive file.driver=nbd
-QEMU_PROG: -drive file.driver=nbd: one of path and host must be specified
+QEMU_PROG: -drive file.driver=nbd: NBD server address missing
 
 Testing: -drive file.driver=raw
 QEMU_PROG: -drive file.driver=raw: Can't use 'raw' as a block driver for the protocol level
diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
index 6395a30..603bb76 100644
--- a/tests/qemu-iotests/051.pc.out
+++ b/tests/qemu-iotests/051.pc.out
@@ -316,7 +316,7 @@ Testing: -drive driver=file
 QEMU_PROG: -drive driver=file: The 'file' block driver requires a file name
 
 Testing: -drive driver=nbd
-QEMU_PROG: -drive driver=nbd: one of path and host must be specified
+QEMU_PROG: -drive driver=nbd: NBD server address missing
 
 Testing: -drive driver=raw
 QEMU_PROG: -drive driver=raw: Can't use 'raw' as a block driver for the protocol level
@@ -325,7 +325,7 @@ Testing: -drive file.driver=file
 QEMU_PROG: -drive file.driver=file: The 'file' block driver requires a file name
 
 Testing: -drive file.driver=nbd
-QEMU_PROG: -drive file.driver=nbd: one of path and host must be specified
+QEMU_PROG: -drive file.driver=nbd: NBD server address missing
 
 Testing: -drive file.driver=raw
 QEMU_PROG: -drive file.driver=raw: Can't use 'raw' as a block driver for the protocol level
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 17/23] block/nbd: Use SocketAddress options
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (15 preceding siblings ...)
  2016-10-27 18:09 ` [Qemu-devel] [PULL 16/23] block/nbd: Accept SocketAddress Kevin Wolf
@ 2016-10-27 18:09 ` Kevin Wolf
  2016-10-27 18:09 ` [Qemu-devel] [PULL 18/23] qapi: Allow blockdev-add for NBD Kevin Wolf
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Drop the use of legacy options in favor of the SocketAddress
representation, even for internal use (i.e. for storing the result of
the filename parsing).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/nbd.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index a778692..8ef1438 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -94,9 +94,13 @@ static int nbd_parse_uri(const char *filename, QDict *options)
             ret = -EINVAL;
             goto out;
         }
-        qdict_put(options, "path", qstring_from_str(qp->p[0].value));
+        qdict_put(options, "server.type", qstring_from_str("unix"));
+        qdict_put(options, "server.data.path",
+                  qstring_from_str(qp->p[0].value));
     } else {
         QString *host;
+        char *port_str;
+
         /* nbd[+tcp]://host[:port]/export */
         if (!uri->server) {
             ret = -EINVAL;
@@ -111,12 +115,12 @@ static int nbd_parse_uri(const char *filename, QDict *options)
             host = qstring_from_str(uri->server);
         }
 
-        qdict_put(options, "host", host);
-        if (uri->port) {
-            char* port_str = g_strdup_printf("%d", uri->port);
-            qdict_put(options, "port", qstring_from_str(port_str));
-            g_free(port_str);
-        }
+        qdict_put(options, "server.type", qstring_from_str("inet"));
+        qdict_put(options, "server.data.host", host);
+
+        port_str = g_strdup_printf("%d", uri->port ?: NBD_DEFAULT_PORT);
+        qdict_put(options, "server.data.port", qstring_from_str(port_str));
+        g_free(port_str);
     }
 
 out:
@@ -192,7 +196,8 @@ static void nbd_parse_filename(const char *filename, QDict *options,
 
     /* are we a UNIX or TCP socket? */
     if (strstart(host_spec, "unix:", &unixpath)) {
-        qdict_put(options, "path", qstring_from_str(unixpath));
+        qdict_put(options, "server.type", qstring_from_str("unix"));
+        qdict_put(options, "server.data.path", qstring_from_str(unixpath));
     } else {
         InetSocketAddress *addr = NULL;
 
@@ -201,8 +206,9 @@ static void nbd_parse_filename(const char *filename, QDict *options,
             goto out;
         }
 
-        qdict_put(options, "host", qstring_from_str(addr->host));
-        qdict_put(options, "port", qstring_from_str(addr->port));
+        qdict_put(options, "server.type", qstring_from_str("inet"));
+        qdict_put(options, "server.data.host", qstring_from_str(addr->host));
+        qdict_put(options, "server.data.port", qstring_from_str(addr->port));
         qapi_free_InetSocketAddress(addr);
     }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 18/23] qapi: Allow blockdev-add for NBD
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (16 preceding siblings ...)
  2016-10-27 18:09 ` [Qemu-devel] [PULL 17/23] block/nbd: Use SocketAddress options Kevin Wolf
@ 2016-10-27 18:09 ` Kevin Wolf
  2016-10-27 18:09 ` [Qemu-devel] [PULL 19/23] iotests.py: Add qemu_nbd function Kevin Wolf
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qapi/block-core.json | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 97b1205..cd1fa7b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1703,15 +1703,16 @@
 #
 # @host_device, @host_cdrom: Since 2.1
 # @gluster: Since 2.7
+# @nbd: Since 2.8
 #
 # Since: 2.0
 ##
 { 'enum': 'BlockdevDriver',
   'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop',
             'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom',
-            'host_device', 'http', 'https', 'luks', 'null-aio', 'null-co',
-            'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw',
-	    'replication', 'tftp', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
+            'host_device', 'http', 'https', 'luks', 'nbd', 'null-aio',
+            'null-co', 'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw',
+            'replication', 'tftp', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
 
 ##
 # @BlockdevOptionsFile
@@ -2220,6 +2221,24 @@
   'data': { 'filename': 'str' } }
 
 ##
+# @BlockdevOptionsNbd
+#
+# Driver specific block device options for NBD.
+#
+# @server:      NBD server address
+#
+# @export:      #optional export name
+#
+# @tls-creds:   #optional TLS credentials ID
+#
+# Since: 2.8
+##
+{ 'struct': 'BlockdevOptionsNbd',
+  'data': { 'server': 'SocketAddress',
+            '*export': 'str',
+            '*tls-creds': 'str' } }
+
+##
 # @BlockdevOptions
 #
 # Options for creating a block device.  Many options are available for all
@@ -2264,7 +2283,7 @@
       'https':      'BlockdevOptionsCurl',
 # TODO iscsi: Wait for structured options
       'luks':       'BlockdevOptionsLUKS',
-# TODO nbd: Should take InetSocketAddress for 'host'?
+      'nbd':        'BlockdevOptionsNbd',
 # TODO nfs: Wait for structured options
       'null-aio':   'BlockdevOptionsNull',
       'null-co':    'BlockdevOptionsNull',
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 19/23] iotests.py: Add qemu_nbd function
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (17 preceding siblings ...)
  2016-10-27 18:09 ` [Qemu-devel] [PULL 18/23] qapi: Allow blockdev-add for NBD Kevin Wolf
@ 2016-10-27 18:09 ` Kevin Wolf
  2016-10-27 18:09 ` [Qemu-devel] [PULL 20/23] iotests.py: Allow concurrent qemu instances Kevin Wolf
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/iotests.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 3329bc1..5a2678f 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -39,6 +39,10 @@ qemu_io_args = [os.environ.get('QEMU_IO_PROG', 'qemu-io')]
 if os.environ.get('QEMU_IO_OPTIONS'):
     qemu_io_args += os.environ['QEMU_IO_OPTIONS'].strip().split(' ')
 
+qemu_nbd_args = [os.environ.get('QEMU_NBD_PROG', 'qemu-nbd')]
+if os.environ.get('QEMU_NBD_OPTIONS'):
+    qemu_nbd_args += os.environ['QEMU_NBD_OPTIONS'].strip().split(' ')
+
 qemu_prog = os.environ.get('QEMU_PROG', 'qemu')
 qemu_opts = os.environ.get('QEMU_OPTIONS', '').strip().split(' ')
 
@@ -87,6 +91,10 @@ def qemu_io(*args):
         sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args)))
     return subp.communicate()[0]
 
+def qemu_nbd(*args):
+    '''Run qemu-nbd in daemon mode and return the parent's exit code'''
+    return subprocess.call(qemu_nbd_args + ['--fork'] + list(args))
+
 def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
     '''Return True if two image files are identical'''
     return qemu_img('compare', '-f', fmt1,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 20/23] iotests.py: Allow concurrent qemu instances
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (18 preceding siblings ...)
  2016-10-27 18:09 ` [Qemu-devel] [PULL 19/23] iotests.py: Add qemu_nbd function Kevin Wolf
@ 2016-10-27 18:09 ` Kevin Wolf
  2016-10-27 18:09 ` [Qemu-devel] [PULL 21/23] socket_scm_helper: Accept fd directly Kevin Wolf
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

By adding an optional suffix to the files used for communication with a
VM, we can launch multiple VM instances concurrently.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/iotests.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 5a2678f..c589deb 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -140,8 +140,10 @@ def log(msg, filters=[]):
 class VM(qtest.QEMUQtestMachine):
     '''A QEMU VM'''
 
-    def __init__(self):
-        super(VM, self).__init__(qemu_prog, qemu_opts, test_dir=test_dir,
+    def __init__(self, path_suffix=''):
+        name = "qemu%s-%d" % (path_suffix, os.getpid())
+        super(VM, self).__init__(qemu_prog, qemu_opts, name=name,
+                                 test_dir=test_dir,
                                  socket_scm_helper=socket_scm_helper)
         if debug:
             self._debug = True
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 21/23] socket_scm_helper: Accept fd directly
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (19 preceding siblings ...)
  2016-10-27 18:09 ` [Qemu-devel] [PULL 20/23] iotests.py: Allow concurrent qemu instances Kevin Wolf
@ 2016-10-27 18:09 ` Kevin Wolf
  2016-10-27 18:09 ` [Qemu-devel] [PULL 22/23] iotests: Add assert_json_filename_equal() method Kevin Wolf
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

This gives us more freedom about the fd that is passed to qemu, allowing
us to e.g. pass sockets.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/socket_scm_helper.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/tests/qemu-iotests/socket_scm_helper.c b/tests/qemu-iotests/socket_scm_helper.c
index 80cadf4..eb76d31 100644
--- a/tests/qemu-iotests/socket_scm_helper.c
+++ b/tests/qemu-iotests/socket_scm_helper.c
@@ -60,7 +60,7 @@ static int send_fd(int fd, int fd_to_send)
 }
 
 /* Convert string to fd number. */
-static int get_fd_num(const char *fd_str)
+static int get_fd_num(const char *fd_str, bool silent)
 {
     int sock;
     char *err;
@@ -68,12 +68,16 @@ static int get_fd_num(const char *fd_str)
     errno = 0;
     sock = strtol(fd_str, &err, 10);
     if (errno) {
-        fprintf(stderr, "Failed in strtol for socket fd, reason: %s\n",
-                strerror(errno));
+        if (!silent) {
+            fprintf(stderr, "Failed in strtol for socket fd, reason: %s\n",
+                    strerror(errno));
+        }
         return -1;
     }
     if (!*fd_str || *err || sock < 0) {
-        fprintf(stderr, "bad numerical value for socket fd '%s'\n", fd_str);
+        if (!silent) {
+            fprintf(stderr, "bad numerical value for socket fd '%s'\n", fd_str);
+        }
         return -1;
     }
 
@@ -104,18 +108,21 @@ int main(int argc, char **argv, char **envp)
     }
 
 
-    sock = get_fd_num(argv[1]);
+    sock = get_fd_num(argv[1], false);
     if (sock < 0) {
         return EXIT_FAILURE;
     }
 
-    /* Now only open a file in readonly mode for test purpose. If more precise
-       control is needed, use python script in file operation, which is
-       supposed to fork and exec this program. */
-    fd = open(argv[2], O_RDONLY);
+    fd = get_fd_num(argv[2], true);
     if (fd < 0) {
-        fprintf(stderr, "Failed to open file '%s'\n", argv[2]);
-        return EXIT_FAILURE;
+        /* Now only open a file in readonly mode for test purpose. If more
+           precise control is needed, use python script in file operation, which
+           is supposed to fork and exec this program. */
+        fd = open(argv[2], O_RDONLY);
+        if (fd < 0) {
+            fprintf(stderr, "Failed to open file '%s'\n", argv[2]);
+            return EXIT_FAILURE;
+        }
     }
 
     ret = send_fd(sock, fd);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 22/23] iotests: Add assert_json_filename_equal() method
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (20 preceding siblings ...)
  2016-10-27 18:09 ` [Qemu-devel] [PULL 21/23] socket_scm_helper: Accept fd directly Kevin Wolf
@ 2016-10-27 18:09 ` Kevin Wolf
  2016-10-27 18:09 ` [Qemu-devel] [PULL 23/23] iotests: Add test for NBD's blockdev-add interface Kevin Wolf
  2016-10-28 13:29 ` [Qemu-devel] [PULL 00/23] Block layer patches Peter Maydell
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Since the order of keys in JSON filenames is not necessarily fixed, they
should not be compared to fixed strings. This method takes a Python dict
as a reference, parses a given JSON filename and compares both.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/iotests.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index c589deb..1f30cfc 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -222,6 +222,19 @@ class QMPTestCase(unittest.TestCase):
                     self.fail('invalid index "%s" in path "%s" in "%s"' % (idx, path, str(d)))
         return d
 
+    def flatten_qmp_object(self, obj, output=None, basestr=''):
+        if output is None:
+            output = dict()
+        if isinstance(obj, list):
+            for i in range(len(obj)):
+                self.flatten_qmp_object(obj[i], output, basestr + str(i) + '.')
+        elif isinstance(obj, dict):
+            for key in obj:
+                self.flatten_qmp_object(obj[key], output, basestr + key + '.')
+        else:
+            output[basestr[:-1]] = obj # Strip trailing '.'
+        return output
+
     def assert_qmp_absent(self, d, path):
         try:
             result = self.dictpath(d, path)
@@ -252,6 +265,13 @@ class QMPTestCase(unittest.TestCase):
         self.assertTrue(False, "Cannot find %s %s in result:\n%s" % \
                 (node_name, file_name, result))
 
+    def assert_json_filename_equal(self, json_filename, reference):
+        '''Asserts that the given filename is a json: filename and that its
+           content is equal to the given reference object'''
+        self.assertEqual(json_filename[:5], 'json:')
+        self.assertEqual(self.flatten_qmp_object(json.loads(json_filename[5:])),
+                         self.flatten_qmp_object(reference))
+
     def cancel_and_wait(self, drive='drive0', force=False, resume=False):
         '''Cancel a block job and wait for it to finish, returning the event'''
         result = self.vm.qmp('block-job-cancel', device=drive, force=force)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 23/23] iotests: Add test for NBD's blockdev-add interface
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (21 preceding siblings ...)
  2016-10-27 18:09 ` [Qemu-devel] [PULL 22/23] iotests: Add assert_json_filename_equal() method Kevin Wolf
@ 2016-10-27 18:09 ` Kevin Wolf
  2016-10-28 13:29 ` [Qemu-devel] [PULL 00/23] Block layer patches Peter Maydell
  23 siblings, 0 replies; 34+ messages in thread
From: Kevin Wolf @ 2016-10-27 18:09 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

From: Max Reitz <mreitz@redhat.com>

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/147     | 195 +++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/147.out |   5 ++
 tests/qemu-iotests/group   |   1 +
 3 files changed, 201 insertions(+)
 create mode 100755 tests/qemu-iotests/147
 create mode 100644 tests/qemu-iotests/147.out

diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147
new file mode 100755
index 0000000..45469c9
--- /dev/null
+++ b/tests/qemu-iotests/147
@@ -0,0 +1,195 @@
+#!/usr/bin/env python
+#
+# Test case for NBD's blockdev-add interface
+#
+# Copyright (C) 2016 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/>.
+#
+
+import os
+import socket
+import stat
+import time
+import iotests
+from iotests import cachemode, imgfmt, qemu_img, qemu_nbd
+
+NBD_PORT = 10811
+
+test_img = os.path.join(iotests.test_dir, 'test.img')
+unix_socket = os.path.join(iotests.test_dir, 'nbd.socket')
+
+class NBDBlockdevAddBase(iotests.QMPTestCase):
+    def blockdev_add_options(self, address, export=None):
+        options = { 'node-name': 'nbd-blockdev',
+                    'driver': 'raw',
+                    'file': {
+                        'driver': 'nbd',
+                        'server': address
+                    } }
+        if export is not None:
+            options['file']['export'] = export
+        return options
+
+    def client_test(self, filename, address, export=None):
+        bao = self.blockdev_add_options(address, export)
+        result = self.vm.qmp('blockdev-add', **bao)
+        self.assert_qmp(result, 'return', {})
+
+        result = self.vm.qmp('query-named-block-nodes')
+        for node in result['return']:
+            if node['node-name'] == 'nbd-blockdev':
+                if isinstance(filename, str):
+                    self.assert_qmp(node, 'image/filename', filename)
+                else:
+                    self.assert_json_filename_equal(node['image']['filename'],
+                                                    filename)
+                break
+
+        result = self.vm.qmp('x-blockdev-del', node_name='nbd-blockdev')
+        self.assert_qmp(result, 'return', {})
+
+
+class QemuNBD(NBDBlockdevAddBase):
+    def setUp(self):
+        qemu_img('create', '-f', iotests.imgfmt, test_img, '64k')
+        self.vm = iotests.VM()
+        self.vm.launch()
+
+    def tearDown(self):
+        self.vm.shutdown()
+        os.remove(test_img)
+        try:
+            os.remove(unix_socket)
+        except OSError:
+            pass
+
+    def _server_up(self, *args):
+        self.assertEqual(qemu_nbd('-f', imgfmt, test_img, *args), 0)
+
+    def test_inet(self):
+        self._server_up('-p', str(NBD_PORT))
+        address = { 'type': 'inet',
+                    'data': {
+                        'host': 'localhost',
+                        'port': str(NBD_PORT)
+                    } }
+        self.client_test('nbd://localhost:%i' % NBD_PORT, address)
+
+    def test_unix(self):
+        self._server_up('-k', unix_socket)
+        address = { 'type': 'unix',
+                    'data': { 'path': unix_socket } }
+        self.client_test('nbd+unix://?socket=' + unix_socket, address)
+
+
+class BuiltinNBD(NBDBlockdevAddBase):
+    def setUp(self):
+        qemu_img('create', '-f', iotests.imgfmt, test_img, '64k')
+        self.vm = iotests.VM()
+        self.vm.launch()
+        self.server = iotests.VM('.server')
+        self.server.add_drive_raw('if=none,id=nbd-export,' +
+                                  'file=%s,' % test_img +
+                                  'format=%s,' % imgfmt +
+                                  'cache=%s' % cachemode)
+        self.server.launch()
+
+    def tearDown(self):
+        self.vm.shutdown()
+        self.server.shutdown()
+        os.remove(test_img)
+        try:
+            os.remove(unix_socket)
+        except OSError:
+            pass
+
+    def _server_up(self, address):
+        result = self.server.qmp('nbd-server-start', addr=address)
+        self.assert_qmp(result, 'return', {})
+
+        result = self.server.qmp('nbd-server-add', device='nbd-export')
+        self.assert_qmp(result, 'return', {})
+
+    def _server_down(self):
+        result = self.server.qmp('nbd-server-stop')
+        self.assert_qmp(result, 'return', {})
+
+    def test_inet(self):
+        address = { 'type': 'inet',
+                    'data': {
+                        'host': 'localhost',
+                        'port': str(NBD_PORT)
+                    } }
+        self._server_up(address)
+        self.client_test('nbd://localhost:%i/nbd-export' % NBD_PORT,
+                         address, 'nbd-export')
+        self._server_down()
+
+    def test_inet6(self):
+        address = { 'type': 'inet',
+                    'data': {
+                        'host': '::1',
+                        'port': str(NBD_PORT),
+                        'ipv4': False,
+                        'ipv6': True
+                    } }
+        filename = { 'driver': 'raw',
+                     'file': {
+                         'driver': 'nbd',
+                         'export': 'nbd-export',
+                         'server': address
+                     } }
+        self._server_up(address)
+        self.client_test(filename, address, 'nbd-export')
+        self._server_down()
+
+    def test_unix(self):
+        address = { 'type': 'unix',
+                    'data': { 'path': unix_socket } }
+        self._server_up(address)
+        self.client_test('nbd+unix:///nbd-export?socket=' + unix_socket,
+                         address, 'nbd-export')
+        self._server_down()
+
+    def test_fd(self):
+        self._server_up({ 'type': 'unix',
+                          'data': { 'path': unix_socket } })
+
+        sockfd = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        sockfd.connect(unix_socket)
+
+        result = self.vm.send_fd_scm(str(sockfd.fileno()))
+        self.assertEqual(result, 0, 'Failed to send socket FD')
+
+        result = self.vm.qmp('getfd', fdname='nbd-fifo')
+        self.assert_qmp(result, 'return', {})
+
+        address = { 'type': 'fd',
+                    'data': { 'str': 'nbd-fifo' } }
+        filename = { 'driver': 'raw',
+                     'file': {
+                         'driver': 'nbd',
+                         'export': 'nbd-export',
+                         'server': address
+                     } }
+        self.client_test(filename, address, 'nbd-export')
+
+        self._server_down()
+
+
+if __name__ == '__main__':
+    # Need to support image creation
+    iotests.main(supported_fmts=['vpc', 'parallels', 'qcow', 'vdi', 'qcow2',
+                                 'vmdk', 'raw', 'vhdx', 'qed'])
diff --git a/tests/qemu-iotests/147.out b/tests/qemu-iotests/147.out
new file mode 100644
index 0000000..3f8a935
--- /dev/null
+++ b/tests/qemu-iotests/147.out
@@ -0,0 +1,5 @@
+......
+----------------------------------------------------------------------
+Ran 6 tests
+
+OK
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 7eb1770..d7d50cf 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -149,6 +149,7 @@
 144 rw auto quick
 145 auto quick
 146 auto quick
+147 auto
 148 rw auto quick
 149 rw auto sudo
 150 rw auto quick
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [Qemu-devel] [PULL 00/23] Block layer patches
  2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
                   ` (22 preceding siblings ...)
  2016-10-27 18:09 ` [Qemu-devel] [PULL 23/23] iotests: Add test for NBD's blockdev-add interface Kevin Wolf
@ 2016-10-28 13:29 ` Peter Maydell
  23 siblings, 0 replies; 34+ messages in thread
From: Peter Maydell @ 2016-10-28 13:29 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Qemu-block, QEMU Developers

On 27 October 2016 at 19:08, Kevin Wolf <kwolf@redhat.com> wrote:
> The following changes since commit 5929d7e8a0e1f43333bc3528b50397ae8dd0fd6b:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-atomic-20161026' into staging (2016-10-27 14:06:34 +0100)
>
> are available in the git repository at:
>
>
>   git://repo.or.cz/qemu/kevin.git tags/for-upstream
>
> for you to fetch changes up to b74fc7f78e0dd54fbae67d46552cebf81b59ae9f:
>
>   iotests: Add test for NBD's blockdev-add interface (2016-10-27 19:05:23 +0200)
>
> ----------------------------------------------------------------
> Block layer patches
>

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Qemu-devel] [PULL 00/23] Block layer patches
  2018-10-02  8:06 ` Peter Maydell
@ 2018-10-03 15:46   ` Peter Maydell
  0 siblings, 0 replies; 34+ messages in thread
From: Peter Maydell @ 2018-10-03 15:46 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Qemu-block, QEMU Developers, Paolo Bonzini

On 2 October 2018 at 09:06, Peter Maydell <peter.maydell@linaro.org> wrote:
> I still got a hang on OSX on test-bdrv-drain, but I've applied
> this anyway, since hopefully it fixes the other intermittent
> failure and may reduce the likelihood with the test-bdrv-drain.

OSX seems to fail test-bdrv-drain fairly frequently. Here's
a back trace from a debug build. When run under the debugger
it seems to stop with a NULL pointer failure in notifier_list_notify();
when not run under the debugger it seems to hang eating CPU...

/bdrv-drain/iothread/drain_subtree: Process 77283 stopped
* thread #12, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000000000000
error: memory read failed for 0x0
Target 1: (test-bdrv-drain) stopped.
(lldb) bt
* thread #12, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000000000000
    frame #1: 0x000000010016524f
test-bdrv-drain`notifier_list_notify(list=0x0000700008501e50,
data=0x0000000000000000) at notify.c:40
    frame #2: 0x0000000100150c92
test-bdrv-drain`qemu_thread_atexit_run(arg=0x0000000100b24f88) at
qemu-thread-posix.c:473
    frame #3: 0x00007fff5a0e1163
libsystem_pthread.dylib`_pthread_tsd_cleanup + 463
    frame #4: 0x00007fff5a0e0ee9 libsystem_pthread.dylib`_pthread_exit + 79
    frame #5: 0x00007fff5a0df66c libsystem_pthread.dylib`_pthread_body + 351
    frame #6: 0x00007fff5a0df50d libsystem_pthread.dylib`_pthread_start + 377
    frame #7: 0x00007fff5a0debf9 libsystem_pthread.dylib`thread_start + 13
(lldb) info thread
error: 'info' is not a valid command.
error: Unrecognized command 'info'.
(lldb) thread backtrace all
  thread #1, queue = 'com.apple.main-thread'
    frame #0: 0x00007fff59f17d82 libsystem_kernel.dylib`__semwait_signal + 10
    frame #1: 0x00007fff5a0e3824 libsystem_pthread.dylib`_pthread_join + 626
    frame #2: 0x0000000100150f2a
test-bdrv-drain`qemu_thread_join(thread=0x0000000103001058) at
qemu-thread-posix.c:565
    frame #3: 0x00000001000f6d70
test-bdrv-drain`iothread_join(iothread=0x0000000103001050) at
iothread.c:62
    frame #4: 0x000000010000a9a0
test-bdrv-drain`test_iothread_common(drain_type=BDRV_SUBTREE_DRAIN,
drain_thread=1) at test-bdrv-drain.c:762
    frame #5: 0x000000010000789f
test-bdrv-drain`test_iothread_drain_subtree at test-bdrv-drain.c:781
    frame #6: 0x00000001003aea47
libglib-2.0.0.dylib`g_test_run_suite_internal + 697
    frame #7: 0x00000001003aec0a
libglib-2.0.0.dylib`g_test_run_suite_internal + 1148
    frame #8: 0x00000001003aec0a
libglib-2.0.0.dylib`g_test_run_suite_internal + 1148
    frame #9: 0x00000001003ae020 libglib-2.0.0.dylib`g_test_run_suite + 121
    frame #10: 0x00000001003adf73 libglib-2.0.0.dylib`g_test_run + 17
    frame #11: 0x0000000100001dd0 test-bdrv-drain`main(argc=1,
argv=0x00007ffeefbffa70) at test-bdrv-drain.c:1606
    frame #12: 0x00007fff59dc7015 libdyld.dylib`start + 1
  thread #2
    frame #0: 0x00007fff59f17a16 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff5a0e0589
libsystem_pthread.dylib`_pthread_cond_wait + 732
    frame #2: 0x0000000100150b5e
test-bdrv-drain`qemu_futex_wait(ev=0x00000001001bbad8, val=4294967295)
at qemu-thread-posix.c:347
    frame #3: 0x0000000100150acd
test-bdrv-drain`qemu_event_wait(ev=0x00000001001bbad8) at
qemu-thread-posix.c:442
    frame #4: 0x000000010016ca82
test-bdrv-drain`call_rcu_thread(opaque=0x0000000000000000) at
rcu.c:261
    frame #5: 0x0000000100150e76
test-bdrv-drain`qemu_thread_start(args=0x0000000100b1dfb0) at
qemu-thread-posix.c:504
    frame #6: 0x00007fff5a0df661 libsystem_pthread.dylib`_pthread_body + 340
    frame #7: 0x00007fff5a0df50d libsystem_pthread.dylib`_pthread_start + 377
    frame #8: 0x00007fff5a0debf9 libsystem_pthread.dylib`thread_start + 13
  thread #3
    frame #0: 0x00007fff59f1803a libsystem_kernel.dylib`__sigwait + 10
    frame #1: 0x00007fff5a0e1ad9 libsystem_pthread.dylib`sigwait + 61
    frame #2: 0x000000010014d781
test-bdrv-drain`sigwait_compat(opaque=0x0000000100b027d0) at
compatfd.c:36
    frame #3: 0x0000000100150e76
test-bdrv-drain`qemu_thread_start(args=0x0000000100b1e560) at
qemu-thread-posix.c:504
    frame #4: 0x00007fff5a0df661 libsystem_pthread.dylib`_pthread_body + 340
    frame #5: 0x00007fff5a0df50d libsystem_pthread.dylib`_pthread_start + 377
    frame #6: 0x00007fff5a0debf9 libsystem_pthread.dylib`thread_start + 13
* thread #12, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000000000000
    frame #1: 0x000000010016524f
test-bdrv-drain`notifier_list_notify(list=0x0000700008501e50,
data=0x0000000000000000) at notify.c:40
    frame #2: 0x0000000100150c92
test-bdrv-drain`qemu_thread_atexit_run(arg=0x0000000100b24f88) at
qemu-thread-posix.c:473
    frame #3: 0x00007fff5a0e1163
libsystem_pthread.dylib`_pthread_tsd_cleanup + 463
    frame #4: 0x00007fff5a0e0ee9 libsystem_pthread.dylib`_pthread_exit + 79
    frame #5: 0x00007fff5a0df66c libsystem_pthread.dylib`_pthread_body + 351
    frame #6: 0x00007fff5a0df50d libsystem_pthread.dylib`_pthread_start + 377
    frame #7: 0x00007fff5a0debf9 libsystem_pthread.dylib`thread_start + 13
  thread #13
    frame #0: 0x00007fff59f17cf2 libsystem_kernel.dylib`__select + 10
    frame #1: 0x000000010039bb60 libglib-2.0.0.dylib`g_poll + 430
    frame #2: 0x0000000100149d7b
test-bdrv-drain`qemu_poll_ns(fds=0x0000000100b25570, nfds=1,
timeout=-1) at qemu-timer.c:337
    frame #3: 0x000000010014c609
test-bdrv-drain`aio_poll(ctx=0x0000000100b26330, blocking=true) at
aio-posix.c:645
    frame #4: 0x00000001000f700f
test-bdrv-drain`iothread_run(opaque=0x0000000100a03620) at
iothread.c:51
    frame #5: 0x0000000100150e76
test-bdrv-drain`qemu_thread_start(args=0x0000000100a05240) at
qemu-thread-posix.c:504
    frame #6: 0x00007fff5a0df661 libsystem_pthread.dylib`_pthread_body + 340
    frame #7: 0x00007fff5a0df50d libsystem_pthread.dylib`_pthread_start + 377
    frame #8: 0x00007fff5a0debf9 libsystem_pthread.dylib`thread_start + 13


As far as I can tell it always fails with
/bdrv-drain/iothread/drain_subtree, but this test
doesn't fail if we just run it alone, so something
earlier in the test is setting it up to go wrong.

I don't understand entirely what's going on with the
union in qemu_thread_atexit_run() (this seems to be
Paolo's code from a few years back), but the pointer
passed to qemu_thread_atexit_run() is a pointer to
zeroed memory:

(lldb) memory read -c 32 arg
0x100a25558: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0x100a25568: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

which when interpreted as a list_head means that
the iteration through the list gets a node with
NULLs in all its fields, and we try to call NULL.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Qemu-devel] [PULL 00/23] Block layer patches
  2018-10-01 17:18 Kevin Wolf
@ 2018-10-02  8:06 ` Peter Maydell
  2018-10-03 15:46   ` Peter Maydell
  0 siblings, 1 reply; 34+ messages in thread
From: Peter Maydell @ 2018-10-02  8:06 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Qemu-block, QEMU Developers

On 1 October 2018 at 18:18, Kevin Wolf <kwolf@redhat.com> wrote:
> The following changes since commit 07f426c35eddd79388a23d11cb278600d7e3831d:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180926' into staging (2018-09-28 18:56:09 +0100)
>
> are available in the git repository at:
>
>   git://repo.or.cz/qemu/kevin.git tags/for-upstream
>
> for you to fetch changes up to dd353157942a59c21da07da5ac8749a871f7c3ed:
>
>   tests/test-bdrv-drain: Fix too late qemu_event_reset() (2018-10-01 19:13:55 +0200)
>
> ----------------------------------------------------------------
> Block layer patches:
>
> - qcow2 cache option default changes (Linux: 32 MB maximum, limited by
>   whatever cache size can be made use of with the specific image;
>   default cache-clean-interval of 10 minutes)
> - reopen: Allow specifying unchanged child node references, and changing
>   a few generic options (discard, detect-zeroes)
> - Fix werror/rerror defaults for -device drive=<node-name>
> - Test case fixes

I still got a hang on OSX on test-bdrv-drain, but I've applied
this anyway, since hopefully it fixes the other intermittent
failure and may reduce the likelihood with the test-bdrv-drain.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 00/23] Block layer patches
@ 2018-10-01 17:18 Kevin Wolf
  2018-10-02  8:06 ` Peter Maydell
  0 siblings, 1 reply; 34+ messages in thread
From: Kevin Wolf @ 2018-10-01 17:18 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, peter.maydell, qemu-devel

The following changes since commit 07f426c35eddd79388a23d11cb278600d7e3831d:

  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180926' into staging (2018-09-28 18:56:09 +0100)

are available in the git repository at:

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

for you to fetch changes up to dd353157942a59c21da07da5ac8749a871f7c3ed:

  tests/test-bdrv-drain: Fix too late qemu_event_reset() (2018-10-01 19:13:55 +0200)

----------------------------------------------------------------
Block layer patches:

- qcow2 cache option default changes (Linux: 32 MB maximum, limited by
  whatever cache size can be made use of with the specific image;
  default cache-clean-interval of 10 minutes)
- reopen: Allow specifying unchanged child node references, and changing
  a few generic options (discard, detect-zeroes)
- Fix werror/rerror defaults for -device drive=<node-name>
- Test case fixes

----------------------------------------------------------------
Alberto Garcia (9):
      qemu-io: Fix writethrough check in reopen
      file-posix: x-check-cache-dropped should default to false on reopen
      block: Remove child references from bs->{options,explicit_options}
      block: Don't look for child references in append_open_options()
      block: Allow child references on reopen
      block: Forbid trying to change unsupported options during reopen
      file-posix: Forbid trying to change unsupported options during reopen
      block: Allow changing 'discard' on reopen
      block: Allow changing 'detect-zeroes' on reopen

Fam Zheng (1):
      file-posix: Include filename in locking error message

Kevin Wolf (3):
      block-backend: Set werror/rerror defaults in blk_new()
      test-replication: Lock AioContext around blk_unref()
      tests/test-bdrv-drain: Fix too late qemu_event_reset()

Leonid Bloch (10):
      qcow2: Options' documentation fixes
      include: Add a lookup table of sizes
      qcow2: Make sizes more humanly readable
      qcow2: Avoid duplication in setting the refcount cache size
      qcow2: Assign the L2 cache relatively to the image size
      qcow2: Increase the default upper limit on the L2 cache size
      qcow2: Resize the cache upon image resizing
      qcow2: Set the default cache-clean-interval to 10 minutes
      qcow2: Explicit number replaced by a constant
      qcow2: Fix cache-clean-interval documentation

 qapi/block-core.json       |   4 +-
 docs/qcow2-cache.txt       |  59 ++++++++++++--------
 block/qcow2.h              |  19 ++++---
 include/block/block.h      |   1 +
 include/qemu/units.h       |  55 ++++++++++++++++++
 block.c                    | 135 +++++++++++++++++++++++++++++----------------
 block/block-backend.c      |   3 +
 block/file-posix.c         |  19 +++++--
 block/qcow2.c              |  43 +++++++++------
 qemu-io-cmds.c             |   2 +-
 tests/test-bdrv-drain.c    |   4 +-
 tests/test-replication.c   |  11 ++++
 qemu-options.hx            |  12 ++--
 tests/qemu-iotests/067.out |   1 +
 tests/qemu-iotests/137     |   8 ++-
 tests/qemu-iotests/137.out |   4 +-
 tests/qemu-iotests/153.out |  76 ++++++++++++-------------
 tests/qemu-iotests/182.out |   2 +-
 18 files changed, 307 insertions(+), 151 deletions(-)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Qemu-devel] [PULL 00/23] Block layer patches
  2016-10-24 17:01 Kevin Wolf
@ 2016-10-24 18:36 ` Peter Maydell
  0 siblings, 0 replies; 34+ messages in thread
From: Peter Maydell @ 2016-10-24 18:36 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Qemu-block, QEMU Developers

On 24 October 2016 at 18:01, Kevin Wolf <kwolf@redhat.com> wrote:
> The following changes since commit a3ae21ec3fe036f536dc94cad735931777143103:
>
>   Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2016-10-24 15:03:09 +0100)
>
> are available in the git repository at:
>
>
>   git://repo.or.cz/qemu/kevin.git tags/for-upstream
>
> for you to fetch changes up to 25493dc012e7c10dba51ee893b634a1dbfeed126:
>
>   Merge remote-tracking branch 'mreitz/tags/pull-block-2016-10-24' into queue-block (2016-10-24 18:02:26 +0200)
>
> ----------------------------------------------------------------
>
> Block layer patches

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 00/23] Block layer patches
@ 2016-10-24 17:01 Kevin Wolf
  2016-10-24 18:36 ` Peter Maydell
  0 siblings, 1 reply; 34+ messages in thread
From: Kevin Wolf @ 2016-10-24 17:01 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

The following changes since commit a3ae21ec3fe036f536dc94cad735931777143103:

  Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2016-10-24 15:03:09 +0100)

are available in the git repository at:


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

for you to fetch changes up to 25493dc012e7c10dba51ee893b634a1dbfeed126:

  Merge remote-tracking branch 'mreitz/tags/pull-block-2016-10-24' into queue-block (2016-10-24 18:02:26 +0200)

----------------------------------------------------------------

Block layer patches

----------------------------------------------------------------
Alberto Garcia (2):
      throttle: Correct access to wrong BlockBackendPublic structures
      qemu-iotests: Test I/O in a single drive from a throttling group

Changlong Xie (1):
      block/replication: Clarify 'top-id' parameter usage

Fam Zheng (9):
      qcow2: Support BDRV_REQ_MAY_UNMAP
      block: Hide HBitmap in block dirty bitmap interface
      HBitmap: Introduce "meta" bitmap to track bit changes
      tests: Add test code for meta bitmap
      block: Support meta dirty bitmap
      block: Add two dirty bitmap getters
      block: Assert that bdrv_release_dirty_bitmap succeeded
      tests: Add test code for hbitmap serialization
      block: More operations for meta dirty bitmap

Halil Pasic (1):
      block: improve error handling in raw_open

Kevin Wolf (2):
      block: Remove "options" indirection from blockdev-add
      Merge remote-tracking branch 'mreitz/tags/pull-block-2016-10-24' into queue-block

Max Reitz (3):
      qemu-nbd: Add --fork option
      iotests: Remove raciness from 162
      iotests: Do not rely on unavailable domains in 162

Paolo Bonzini (2):
      quorum: change child_iter to children_read
      quorum: do not allocate multiple iovecs for FIFO strategy

Pino Toscano (1):
      qapi: fix memory leak in bdrv_image_info_specific_dump

Vladimir Sementsov-Ogievskiy (2):
      hbitmap: serialization
      block: BdrvDirtyBitmap serialization interface

Xu Tian (1):
      block: failed qemu-img command should return non-zero exit code

 block/backup.c               |  14 ++-
 block/dirty-bitmap.c         | 160 ++++++++++++++++++++++++-
 block/mirror.c               |  24 ++--
 block/qapi.c                 |   1 +
 block/qcow2-cluster.c        |   9 +-
 block/qcow2.c                |   3 +-
 block/qcow2.h                |   3 +-
 block/quorum.c               |  93 +++++++--------
 block/raw-posix.c            |   1 +
 block/raw-win32.c            |   1 +
 block/replication.c          |   5 +
 block/throttle-groups.c      |  27 ++++-
 docs/qmp-commands.txt        |  84 +++++++------
 include/block/dirty-bitmap.h |  35 +++++-
 include/qemu/hbitmap.h       | 100 ++++++++++++++++
 include/qemu/typedefs.h      |   1 +
 qapi/block-core.json         |   7 +-
 qemu-img.c                   |   2 +
 qemu-nbd.c                   |  17 ++-
 qemu-nbd.texi                |   2 +
 tests/qemu-iotests/041       |  11 +-
 tests/qemu-iotests/067       |  12 +-
 tests/qemu-iotests/071       | 118 ++++++++-----------
 tests/qemu-iotests/081       |  52 ++++-----
 tests/qemu-iotests/085       |   9 +-
 tests/qemu-iotests/087       |  76 +++++-------
 tests/qemu-iotests/093       |  33 +++++-
 tests/qemu-iotests/093.out   |   4 +-
 tests/qemu-iotests/117       |  12 +-
 tests/qemu-iotests/118       |  42 +++----
 tests/qemu-iotests/124       |  20 ++--
 tests/qemu-iotests/139       |  10 +-
 tests/qemu-iotests/141       |  13 +--
 tests/qemu-iotests/155       |  10 +-
 tests/qemu-iotests/162       |  22 +++-
 tests/qemu-iotests/162.out   |   2 +-
 tests/test-hbitmap.c         | 272 +++++++++++++++++++++++++++++++++++++++++++
 util/hbitmap.c               | 206 +++++++++++++++++++++++++++++---
 38 files changed, 1140 insertions(+), 373 deletions(-)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Qemu-devel] [PULL 00/23] Block layer patches
  2015-09-14  9:57   ` Kevin Wolf
@ 2015-09-14 14:36     ` Max Reitz
  0 siblings, 0 replies; 34+ messages in thread
From: Max Reitz @ 2015-09-14 14:36 UTC (permalink / raw)
  To: Kevin Wolf, Peter Maydell; +Cc: QEMU Developers, Qemu-block

[-- Attachment #1: Type: text/plain, Size: 1788 bytes --]

On 14.09.2015 11:57, Kevin Wolf wrote:
> Am 14.09.2015 um 11:46 hat Peter Maydell geschrieben:
>> On 11 September 2015 at 20:40, Kevin Wolf <kwolf@redhat.com> wrote:
>>> The following changes since commit 30c38c90bd3f1bb105ebc069ac1821067c980b7c:
>>>
>>>   scripts/qemu-gdb: Add brief comment describing usage (2015-09-11 17:14:50 +0100)
>>>
>>> are available in the git repository at:
>>>
>>>   git://repo.or.cz/qemu/kevin.git tags/for-upstream
>>>
>>> for you to fetch changes up to 1fcbcc93872953d08cd35830d1169fed19196290:
>>>
>>>   qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-11 20:03:02 +0200)
>>>
>>> ----------------------------------------------------------------
>>> Block layer patches
>>>
>>> ----------------------------------------------------------------
>>
>> Hi. I'm afraid this fails to build on 32-bit:
>>
>> /home/pm215/qemu/block/qcow2-refcount.c: In function ‘realloc_refcount_array’:
>> /home/pm215/qemu/block/qcow2-refcount.c:1294:16: error: cast to
>> pointer from integer of different size [-Werror=int-to-pointer-cast]
>>          memset((void *)((uintptr_t)new_ptr + old_byte_size), 0,
>>                 ^
>> cc1: all warnings being treated as errors
>> /home/pm215/qemu/rules.mak:57: recipe for target 'block/qcow2-refcount.o' failed
>> make: *** [block/qcow2-refcount.o] Error 1
>>
>> (old_byte_size is int64_t, so (uintptr_t)new_ptr + old_byte_size
>> becomes a 64-bit addition, and then you cast it to a 32-bit
>> pointer.)
> 
> Max, I think this is yours.

Indeed, I'll send a v3 for "qcow2: Make size_to_clusters() return
uint64_t" and "iotests: Add test for checking large image files".

You decide whether you are going to include them in a new pull request
or just drop them for now.

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Qemu-devel] [PULL 00/23] Block layer patches
  2015-09-14  9:46 ` Peter Maydell
@ 2015-09-14  9:57   ` Kevin Wolf
  2015-09-14 14:36     ` Max Reitz
  0 siblings, 1 reply; 34+ messages in thread
From: Kevin Wolf @ 2015-09-14  9:57 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Qemu-block, mreitz

Am 14.09.2015 um 11:46 hat Peter Maydell geschrieben:
> On 11 September 2015 at 20:40, Kevin Wolf <kwolf@redhat.com> wrote:
> > The following changes since commit 30c38c90bd3f1bb105ebc069ac1821067c980b7c:
> >
> >   scripts/qemu-gdb: Add brief comment describing usage (2015-09-11 17:14:50 +0100)
> >
> > are available in the git repository at:
> >
> >   git://repo.or.cz/qemu/kevin.git tags/for-upstream
> >
> > for you to fetch changes up to 1fcbcc93872953d08cd35830d1169fed19196290:
> >
> >   qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-11 20:03:02 +0200)
> >
> > ----------------------------------------------------------------
> > Block layer patches
> >
> > ----------------------------------------------------------------
> 
> Hi. I'm afraid this fails to build on 32-bit:
> 
> /home/pm215/qemu/block/qcow2-refcount.c: In function ‘realloc_refcount_array’:
> /home/pm215/qemu/block/qcow2-refcount.c:1294:16: error: cast to
> pointer from integer of different size [-Werror=int-to-pointer-cast]
>          memset((void *)((uintptr_t)new_ptr + old_byte_size), 0,
>                 ^
> cc1: all warnings being treated as errors
> /home/pm215/qemu/rules.mak:57: recipe for target 'block/qcow2-refcount.o' failed
> make: *** [block/qcow2-refcount.o] Error 1
> 
> (old_byte_size is int64_t, so (uintptr_t)new_ptr + old_byte_size
> becomes a 64-bit addition, and then you cast it to a 32-bit
> pointer.)

Max, I think this is yours.

Kevin

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Qemu-devel] [PULL 00/23] Block layer patches
  2015-09-11 19:40 Kevin Wolf
@ 2015-09-14  9:46 ` Peter Maydell
  2015-09-14  9:57   ` Kevin Wolf
  0 siblings, 1 reply; 34+ messages in thread
From: Peter Maydell @ 2015-09-14  9:46 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: QEMU Developers, Qemu-block

On 11 September 2015 at 20:40, Kevin Wolf <kwolf@redhat.com> wrote:
> The following changes since commit 30c38c90bd3f1bb105ebc069ac1821067c980b7c:
>
>   scripts/qemu-gdb: Add brief comment describing usage (2015-09-11 17:14:50 +0100)
>
> are available in the git repository at:
>
>   git://repo.or.cz/qemu/kevin.git tags/for-upstream
>
> for you to fetch changes up to 1fcbcc93872953d08cd35830d1169fed19196290:
>
>   qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-11 20:03:02 +0200)
>
> ----------------------------------------------------------------
> Block layer patches
>
> ----------------------------------------------------------------

Hi. I'm afraid this fails to build on 32-bit:

/home/pm215/qemu/block/qcow2-refcount.c: In function ‘realloc_refcount_array’:
/home/pm215/qemu/block/qcow2-refcount.c:1294:16: error: cast to
pointer from integer of different size [-Werror=int-to-pointer-cast]
         memset((void *)((uintptr_t)new_ptr + old_byte_size), 0,
                ^
cc1: all warnings being treated as errors
/home/pm215/qemu/rules.mak:57: recipe for target 'block/qcow2-refcount.o' failed
make: *** [block/qcow2-refcount.o] Error 1

(old_byte_size is int64_t, so (uintptr_t)new_ptr + old_byte_size
becomes a 64-bit addition, and then you cast it to a 32-bit
pointer.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Qemu-devel] [PULL 00/23] Block layer patches
@ 2015-09-11 19:40 Kevin Wolf
  2015-09-14  9:46 ` Peter Maydell
  0 siblings, 1 reply; 34+ messages in thread
From: Kevin Wolf @ 2015-09-11 19:40 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel

The following changes since commit 30c38c90bd3f1bb105ebc069ac1821067c980b7c:

  scripts/qemu-gdb: Add brief comment describing usage (2015-09-11 17:14:50 +0100)

are available in the git repository at:

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

for you to fetch changes up to 1fcbcc93872953d08cd35830d1169fed19196290:

  qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-11 20:03:02 +0200)

----------------------------------------------------------------
Block layer patches

----------------------------------------------------------------
Kevin Wolf (14):
      qcow2: Rename BDRVQcowState to BDRVQcow2State
      block: Allow specifying driver-specific options to reopen
      qemu-io: Remove duplicate 'open' error message
      qemu-io: Add command 'reopen'
      qcow2: Improve error message
      qcow2: Factor out qcow2_update_options()
      qcow2: Move qcow2_update_options() call up
      qcow2: Move rest of option handling to qcow2_update_options()
      qcow2: Leave s unchanged on qcow2_update_options() failure
      qcow2: Fix memory leak in qcow2_update_options() error path
      qcow2: Make qcow2_update_options() suitable for transactions
      qcow2: Support updating driver-specific options in reopen
      qemu-iotests: Reopen qcow2 with lazy-refcounts change
      qemu-iotests: More qcow2 reopen tests

Max Reitz (8):
      block: Always pass NULL as drv for bdrv_open()
      block: Drop drv parameter from bdrv_open()
      block: Drop drv parameter from bdrv_open_inherit()
      block: Drop drv parameter from bdrv_fill_options()
      block: Drop bdrv_find_whitelisted_format()
      qcow2: Make size_to_clusters() return uint64_t
      iotests: Add test for checking large image files
      qcow2: Make qcow2_alloc_bytes() more explicit

Radoslav Gerganov (1):
      vmdk: Fix next_cluster_sector for compressed write

 block.c                    | 150 +++++++-------
 block/block-backend.c      |   2 +-
 block/commit.c             |   4 +-
 block/parallels.c          |   2 +-
 block/qcow.c               |   2 +-
 block/qcow2-cache.c        |  14 +-
 block/qcow2-cluster.c      |  76 +++----
 block/qcow2-refcount.c     |  74 ++++---
 block/qcow2-snapshot.c     |  20 +-
 block/qcow2.c              | 486 +++++++++++++++++++++++++++++----------------
 block/qcow2.h              |  26 +--
 block/qed.c                |   2 +-
 block/sheepdog.c           |   5 +-
 block/vdi.c                |   2 +-
 block/vhdx.c               |   2 +-
 block/vmdk.c               |  15 +-
 block/vpc.c                |   2 +-
 block/vvfat.c              |   8 +-
 blockdev.c                 |  72 +++----
 include/block/block.h      |   9 +-
 qemu-io-cmds.c             |  90 +++++++++
 qemu-io.c                  |   1 -
 tests/qemu-iotests/039     |  27 +++
 tests/qemu-iotests/039.out |  18 ++
 tests/qemu-iotests/137     | 145 ++++++++++++++
 tests/qemu-iotests/137.out |  42 ++++
 tests/qemu-iotests/138     |  73 +++++++
 tests/qemu-iotests/138.out |   9 +
 tests/qemu-iotests/group   |   2 +
 29 files changed, 972 insertions(+), 408 deletions(-)
 create mode 100755 tests/qemu-iotests/137
 create mode 100644 tests/qemu-iotests/137.out
 create mode 100755 tests/qemu-iotests/138
 create mode 100644 tests/qemu-iotests/138.out

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2018-10-03 15:46 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 01/23] block: Use blk_co_flush() for all BB level flushes Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 02/23] block: Use blk_co_pdiscard() for all BB level discard Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 03/23] block: Remove bdrv_aio_pdiscard() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 04/23] block: Use blk_co_ioctl() for all BB level ioctls Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 05/23] raw-posix: Don't use bdrv_ioctl() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 06/23] block: Remove bdrv_ioctl() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 07/23] block: Introduce .bdrv_co_ioctl() driver callback Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 08/23] raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 09/23] block: Remove bdrv_aio_ioctl() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 10/23] qemu-iotests: Fix typo for NFS with IMGOPTSSYNTAX Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 11/23] block/nbd: Drop trailing "." in error messages Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 12/23] block/nbd: Reject port parameter without host Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 13/23] block/nbd: Default port in nbd_refresh_filename() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 14/23] block/nbd: Use qdict_put() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 15/23] block/nbd: Add nbd_has_filename_options_conflict() Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 16/23] block/nbd: Accept SocketAddress Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 17/23] block/nbd: Use SocketAddress options Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 18/23] qapi: Allow blockdev-add for NBD Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 19/23] iotests.py: Add qemu_nbd function Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 20/23] iotests.py: Allow concurrent qemu instances Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 21/23] socket_scm_helper: Accept fd directly Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 22/23] iotests: Add assert_json_filename_equal() method Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 23/23] iotests: Add test for NBD's blockdev-add interface Kevin Wolf
2016-10-28 13:29 ` [Qemu-devel] [PULL 00/23] Block layer patches Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2018-10-01 17:18 Kevin Wolf
2018-10-02  8:06 ` Peter Maydell
2018-10-03 15:46   ` Peter Maydell
2016-10-24 17:01 Kevin Wolf
2016-10-24 18:36 ` Peter Maydell
2015-09-11 19:40 Kevin Wolf
2015-09-14  9:46 ` Peter Maydell
2015-09-14  9:57   ` Kevin Wolf
2015-09-14 14:36     ` Max Reitz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.