qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v2 00/47] Block patches
@ 2015-02-06 17:35 Kevin Wolf
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 43/47] blockdev: Give find_block_job() an Error ** parameter Kevin Wolf
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Kevin Wolf @ 2015-02-06 17:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

[ Posting only the new patches in v2 as replies, see v1 for the rest ]

The following changes since commit cebbae86b4f7ee3d3dd9df906b97d269e70d9cc7:

  Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging (2015-02-06 14:35:52 +0000)

are available in the git repository at:


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

for you to fetch changes up to 728dacbda817b2ca259e9d337fab06bcf14e94a6:

  block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices (2015-02-06 18:00:53 +0100)

----------------------------------------------------------------
Block patches for 2.3

----------------------------------------------------------------
Alberto Garcia (1):
      block: Give always priority to unused entries in the qcow2 L2 cache

Denis V. Lunev (7):
      block/raw-posix: create translate_err helper to merge errno values
      block/raw-posix: create do_fallocate helper
      block/raw-posix: refactor handle_aiocb_write_zeroes a bit
      block: use fallocate(FALLOC_FL_ZERO_RANGE) in handle_aiocb_write_zeroes
      block/raw-posix: call plain fallocate in handle_aiocb_write_zeroes
      block: use fallocate(FALLOC_FL_PUNCH_HOLE) & fallocate(0) to write zeroes
      nbd: fix max_discard/max_transfer_length

Don Slutz (1):
      qemu-img: Add QEMU_PKGVERSION to QEMU_IMG_VERSION

Dr. David Alan Gilbert (2):
      Restore atapi_dma flag across migration
      atapi migration: Throw recoverable error to avoid recovery

Fam Zheng (2):
      qed: Really remove unused field QEDAIOCB.finished
      qemu-iotests: Fix supported_oses check

Francesco Romani (1):
      block: add event when disk usage exceeds threshold

Jeff Cody (1):
      block: fix off-by-one error in qcow and qcow2

Kevin Wolf (1):
      Merge remote-tracking branch 'mreitz/block' into queue-block

Markus Armbruster (4):
      blockdev: Give find_block_job() an Error ** parameter
      blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro
      block: New bdrv_add_key(), convert monitor to use it
      block: Eliminate silly QERR_ macros used for encryption keys

Max Reitz (6):
      iotests: Specify format for qemu-nbd
      iotests: Fix 083
      iotests: Fix 100 for nbd
      iotests: Fix 104 for NBD
      nbd: Improve error messages
      qcow2: Rewrite qcow2_alloc_bytes()

Peter Lieven (7):
      block: change default for discard and write zeroes to INT_MAX
      block: add accounting for merged requests
      hw/virtio-blk: add a constant for max number of merged requests
      block-backend: expose bs->bl.max_transfer_length
      virtio-blk: introduce multiread
      virtio-blk: add a knob to disable request merging
      block: introduce BDRV_REQUEST_MAX_SECTORS

Peter Wu (12):
      block/dmg: properly detect the UDIF trailer
      block/dmg: extract mish block decoding functionality
      block/dmg: extract processing of resource forks
      block/dmg: process a buffer instead of reading ints
      block/dmg: validate chunk size to avoid overflow
      block/dmg: process XML plists
      block/dmg: set virtual size to a non-zero value
      block/dmg: fix sector data offset calculation
      block/dmg: use SectorNumber from BLKX header
      block/dmg: factor out block type check
      block/dmg: support bzip2 block entry types
      block/dmg: improve zeroes handling

Programmingkid (1):
      block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices

Stefan Hajnoczi (2):
      qed: check for header size overflow
      qemu-iotests: add 116 invalid QED input file tests

 block.c                          |  65 +++--
 block/Makefile.objs              |   2 +
 block/accounting.c               |   7 +
 block/block-backend.c            |   5 +
 block/dmg.c                      | 502 ++++++++++++++++++++++++++++++---------
 block/nbd-client.c               |   4 +-
 block/nbd-client.h               |   2 +-
 block/nbd.c                      |  11 +-
 block/qapi.c                     |   5 +
 block/qcow.c                     |   2 +-
 block/qcow2-cache.c              |   4 +-
 block/qcow2-refcount.c           |  78 +++---
 block/qcow2.c                    |   2 +-
 block/qed.c                      |   5 +
 block/qed.h                      |   1 -
 block/raw-posix.c                | 140 ++++++++---
 block/write-threshold.c          | 125 ++++++++++
 blockdev.c                       |  44 +---
 configure                        |  50 ++++
 hmp.c                            |   6 +-
 hw/block/dataplane/virtio-blk.c  |   8 +-
 hw/block/virtio-blk.c            | 299 +++++++++++++++--------
 hw/ide/atapi.c                   |  17 ++
 hw/ide/core.c                    |   1 +
 hw/ide/internal.h                |   2 +
 hw/ide/pci.c                     |  11 +
 include/block/accounting.h       |   3 +
 include/block/block.h            |   4 +
 include/block/block_int.h        |   4 +
 include/block/nbd.h              |   2 +-
 include/block/write-threshold.h  |  64 +++++
 include/hw/virtio/virtio-blk.h   |  18 +-
 include/qapi/qmp/qerror.h        |   9 -
 include/sysemu/block-backend.h   |   1 +
 monitor.c                        |  16 +-
 nbd.c                            |  42 ++--
 qapi/block-core.json             |  60 ++++-
 qemu-img.c                       |   2 +-
 qemu-nbd.c                       |   7 +-
 qmp-commands.hx                  |  54 ++++-
 qmp.c                            |   8 +-
 tests/Makefile                   |   3 +
 tests/qemu-iotests/067.out       |   5 +
 tests/qemu-iotests/083           |   3 +-
 tests/qemu-iotests/083.out       |  81 +++----
 tests/qemu-iotests/100           |  12 +
 tests/qemu-iotests/104           |   9 +-
 tests/qemu-iotests/116           |  96 ++++++++
 tests/qemu-iotests/116.out       |  37 +++
 tests/qemu-iotests/common.filter |   1 +
 tests/qemu-iotests/common.rc     |   2 +-
 tests/qemu-iotests/group         |   1 +
 tests/qemu-iotests/iotests.py    |   2 +-
 tests/test-write-threshold.c     | 119 ++++++++++
 trace-events                     |   1 +
 55 files changed, 1602 insertions(+), 462 deletions(-)
 create mode 100644 block/write-threshold.c
 create mode 100644 include/block/write-threshold.h
 create mode 100755 tests/qemu-iotests/116
 create mode 100644 tests/qemu-iotests/116.out
 create mode 100644 tests/test-write-threshold.c

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

* [Qemu-devel] [PULL v2 43/47] blockdev: Give find_block_job() an Error ** parameter
  2015-02-06 17:35 [Qemu-devel] [PULL v2 00/47] Block patches Kevin Wolf
@ 2015-02-06 17:35 ` Kevin Wolf
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 44/47] blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro Kevin Wolf
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2015-02-06 17:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

From: Markus Armbruster <armbru@redhat.com>

When find_block_job() fails, all its callers build the same Error
object.  Build it in find_block_job() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1422524221-8566-2-git-send-email-armbru@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 blockdev.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index d59efd3..8d6ca35 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2653,7 +2653,8 @@ out:
 }
 
 /* Get the block job for a given device name and acquire its AioContext */
-static BlockJob *find_block_job(const char *device, AioContext **aio_context)
+static BlockJob *find_block_job(const char *device, AioContext **aio_context,
+                                Error **errp)
 {
     BlockDriverState *bs;
 
@@ -2673,6 +2674,7 @@ static BlockJob *find_block_job(const char *device, AioContext **aio_context)
     return bs->job;
 
 notfound:
+    error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
     *aio_context = NULL;
     return NULL;
 }
@@ -2680,10 +2682,9 @@ notfound:
 void qmp_block_job_set_speed(const char *device, int64_t speed, Error **errp)
 {
     AioContext *aio_context;
-    BlockJob *job = find_block_job(device, &aio_context);
+    BlockJob *job = find_block_job(device, &aio_context, errp);
 
     if (!job) {
-        error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
         return;
     }
 
@@ -2695,10 +2696,9 @@ void qmp_block_job_cancel(const char *device,
                           bool has_force, bool force, Error **errp)
 {
     AioContext *aio_context;
-    BlockJob *job = find_block_job(device, &aio_context);
+    BlockJob *job = find_block_job(device, &aio_context, errp);
 
     if (!job) {
-        error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
         return;
     }
 
@@ -2721,10 +2721,9 @@ out:
 void qmp_block_job_pause(const char *device, Error **errp)
 {
     AioContext *aio_context;
-    BlockJob *job = find_block_job(device, &aio_context);
+    BlockJob *job = find_block_job(device, &aio_context, errp);
 
     if (!job) {
-        error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
         return;
     }
 
@@ -2736,10 +2735,9 @@ void qmp_block_job_pause(const char *device, Error **errp)
 void qmp_block_job_resume(const char *device, Error **errp)
 {
     AioContext *aio_context;
-    BlockJob *job = find_block_job(device, &aio_context);
+    BlockJob *job = find_block_job(device, &aio_context, errp);
 
     if (!job) {
-        error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
         return;
     }
 
@@ -2751,10 +2749,9 @@ void qmp_block_job_resume(const char *device, Error **errp)
 void qmp_block_job_complete(const char *device, Error **errp)
 {
     AioContext *aio_context;
-    BlockJob *job = find_block_job(device, &aio_context);
+    BlockJob *job = find_block_job(device, &aio_context, errp);
 
     if (!job) {
-        error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
         return;
     }
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 44/47] blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro
  2015-02-06 17:35 [Qemu-devel] [PULL v2 00/47] Block patches Kevin Wolf
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 43/47] blockdev: Give find_block_job() an Error ** parameter Kevin Wolf
@ 2015-02-06 17:35 ` Kevin Wolf
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 45/47] block: New bdrv_add_key(), convert monitor to use it Kevin Wolf
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2015-02-06 17:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

From: Markus Armbruster <armbru@pond.sub.org>

The QERR_ macros are leftovers from the days of "rich" error objects.
They're used with error_set() and qerror_report(), and expand into the
first *two* arguments.  This trickiness has become pointless.  Clean
this one up.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1422524221-8566-3-git-send-email-armbru@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 blockdev.c                | 3 ++-
 include/qapi/qmp/qerror.h | 3 ---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 8d6ca35..287d7af 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2674,7 +2674,8 @@ static BlockJob *find_block_job(const char *device, AioContext **aio_context,
     return bs->job;
 
 notfound:
-    error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
+    error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE,
+              "No active block job on device '%s'", device);
     *aio_context = NULL;
     return NULL;
 }
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index eeaf0cb..85f1699 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -37,9 +37,6 @@ void qerror_report_err(Error *err);
 #define QERR_BASE_NOT_FOUND \
     ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
 
-#define QERR_BLOCK_JOB_NOT_ACTIVE \
-    ERROR_CLASS_DEVICE_NOT_ACTIVE, "No active block job on device '%s'"
-
 #define QERR_BLOCK_JOB_NOT_READY \
     ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be completed"
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 45/47] block: New bdrv_add_key(), convert monitor to use it
  2015-02-06 17:35 [Qemu-devel] [PULL v2 00/47] Block patches Kevin Wolf
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 43/47] blockdev: Give find_block_job() an Error ** parameter Kevin Wolf
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 44/47] blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro Kevin Wolf
@ 2015-02-06 17:35 ` Kevin Wolf
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 46/47] block: Eliminate silly QERR_ macros used for encryption keys Kevin Wolf
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2015-02-06 17:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

From: Markus Armbruster <armbru@redhat.com>

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1422524221-8566-4-git-send-email-armbru@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block.c               | 29 +++++++++++++++++++++++++++++
 blockdev.c            | 24 ++----------------------
 include/block/block.h |  1 +
 monitor.c             | 16 +++++++++++-----
 qmp.c                 |  8 ++++----
 5 files changed, 47 insertions(+), 31 deletions(-)

diff --git a/block.c b/block.c
index 49e0073..84af3cd 100644
--- a/block.c
+++ b/block.c
@@ -3713,6 +3713,35 @@ int bdrv_set_key(BlockDriverState *bs, const char *key)
     return ret;
 }
 
+/*
+ * Provide an encryption key for @bs.
+ * If @key is non-null:
+ *     If @bs is not encrypted, fail.
+ *     Else if the key is invalid, fail.
+ *     Else set @bs's key to @key, replacing the existing key, if any.
+ * If @key is null:
+ *     If @bs is encrypted and still lacks a key, fail.
+ *     Else do nothing.
+ * On failure, store an error object through @errp if non-null.
+ */
+void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp)
+{
+    if (key) {
+        if (!bdrv_is_encrypted(bs)) {
+            error_set(errp, QERR_DEVICE_NOT_ENCRYPTED,
+                      bdrv_get_device_name(bs));
+        } else if (bdrv_set_key(bs, key) < 0) {
+            error_set(errp, QERR_INVALID_PASSWORD);
+        }
+    } else {
+        if (bdrv_key_required(bs)) {
+            error_set(errp, QERR_DEVICE_ENCRYPTED,
+                      bdrv_get_device_name(bs),
+                      bdrv_get_encrypted_filename(bs));
+        }
+    }
+}
+
 const char *bdrv_get_format_name(BlockDriverState *bs)
 {
     return bs->drv ? bs->drv->format_name : NULL;
diff --git a/blockdev.c b/blockdev.c
index 287d7af..7d34960 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1793,7 +1793,6 @@ void qmp_block_passwd(bool has_device, const char *device,
     Error *local_err = NULL;
     BlockDriverState *bs;
     AioContext *aio_context;
-    int err;
 
     bs = bdrv_lookup_bs(has_device ? device : NULL,
                         has_node_name ? node_name : NULL,
@@ -1806,16 +1805,8 @@ void qmp_block_passwd(bool has_device, const char *device,
     aio_context = bdrv_get_aio_context(bs);
     aio_context_acquire(aio_context);
 
-    err = bdrv_set_key(bs, password);
-    if (err == -EINVAL) {
-        error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
-        goto out;
-    } else if (err < 0) {
-        error_set(errp, QERR_INVALID_PASSWORD);
-        goto out;
-    }
+    bdrv_add_key(bs, password, errp);
 
-out:
     aio_context_release(aio_context);
 }
 
@@ -1833,18 +1824,7 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename,
         return;
     }
 
-    if (bdrv_key_required(bs)) {
-        if (password) {
-            if (bdrv_set_key(bs, password) < 0) {
-                error_set(errp, QERR_INVALID_PASSWORD);
-            }
-        } else {
-            error_set(errp, QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs),
-                      bdrv_get_encrypted_filename(bs));
-        }
-    } else if (password) {
-        error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
-    }
+    bdrv_add_key(bs, password, errp);
 }
 
 void qmp_change_blockdev(const char *device, const char *filename,
diff --git a/include/block/block.h b/include/block/block.h
index 25a6d62..321295e 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -381,6 +381,7 @@ BlockDriverState *bdrv_next(BlockDriverState *bs);
 int bdrv_is_encrypted(BlockDriverState *bs);
 int bdrv_key_required(BlockDriverState *bs);
 int bdrv_set_key(BlockDriverState *bs, const char *key);
+void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp);
 int bdrv_query_missing_keys(void);
 void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
                          void *opaque);
diff --git a/monitor.c b/monitor.c
index 5a24311..c3cc060 100644
--- a/monitor.c
+++ b/monitor.c
@@ -5368,9 +5368,12 @@ static void bdrv_password_cb(void *opaque, const char *password,
     Monitor *mon = opaque;
     BlockDriverState *bs = readline_opaque;
     int ret = 0;
+    Error *local_err = NULL;
 
-    if (bdrv_set_key(bs, password) != 0) {
-        monitor_printf(mon, "invalid password\n");
+    bdrv_add_key(bs, password, &local_err);
+    if (local_err) {
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
+        error_free(local_err);
         ret = -EPERM;
     }
     if (mon->password_completion_cb)
@@ -5388,17 +5391,20 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
                                 BlockCompletionFunc *completion_cb,
                                 void *opaque)
 {
+    Error *local_err = NULL;
     int err;
 
-    if (!bdrv_key_required(bs)) {
+    bdrv_add_key(bs, NULL, &local_err);
+    if (!local_err) {
         if (completion_cb)
             completion_cb(opaque, 0);
         return 0;
     }
 
+    /* Need a key for @bs */
+
     if (monitor_ctrl_mode(mon)) {
-        qerror_report(QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs),
-                      bdrv_get_encrypted_filename(bs));
+        qerror_report_err(local_err);
         return -1;
     }
 
diff --git a/qmp.c b/qmp.c
index 7f2d25a..20a9e97 100644
--- a/qmp.c
+++ b/qmp.c
@@ -154,6 +154,7 @@ SpiceInfo *qmp_query_spice(Error **errp)
 
 void qmp_cont(Error **errp)
 {
+    Error *local_err = NULL;
     BlockDriverState *bs;
 
     if (runstate_needs_reset()) {
@@ -167,10 +168,9 @@ void qmp_cont(Error **errp)
         bdrv_iostatus_reset(bs);
     }
     for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
-        if (bdrv_key_required(bs)) {
-            error_set(errp, QERR_DEVICE_ENCRYPTED,
-                      bdrv_get_device_name(bs),
-                      bdrv_get_encrypted_filename(bs));
+        bdrv_add_key(bs, NULL, &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
             return;
         }
     }
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 46/47] block: Eliminate silly QERR_ macros used for encryption keys
  2015-02-06 17:35 [Qemu-devel] [PULL v2 00/47] Block patches Kevin Wolf
                   ` (2 preceding siblings ...)
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 45/47] block: New bdrv_add_key(), convert monitor to use it Kevin Wolf
@ 2015-02-06 17:35 ` Kevin Wolf
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 47/47] block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices Kevin Wolf
  2015-02-09 22:33 ` [Qemu-devel] [PULL v2 00/47] Block patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2015-02-06 17:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

From: Markus Armbruster <armbru@redhat.com>

The QERR_ macros are leftovers from the days of "rich" error objects.
They're used with error_set() and qerror_report(), and expand into the
first *two* arguments.  This trickiness has become pointless.  Clean
up QERR_DEVICE_ENCRYPTED and QERR_DEVICE_NOT_ENCRYPTED.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1422524221-8566-5-git-send-email-armbru@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block.c                   | 5 +++--
 include/qapi/qmp/qerror.h | 6 ------
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/block.c b/block.c
index 84af3cd..210fd5f 100644
--- a/block.c
+++ b/block.c
@@ -3728,14 +3728,15 @@ void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp)
 {
     if (key) {
         if (!bdrv_is_encrypted(bs)) {
-            error_set(errp, QERR_DEVICE_NOT_ENCRYPTED,
+            error_setg(errp, "Device '%s' is not encrypted",
                       bdrv_get_device_name(bs));
         } else if (bdrv_set_key(bs, key) < 0) {
             error_set(errp, QERR_INVALID_PASSWORD);
         }
     } else {
         if (bdrv_key_required(bs)) {
-            error_set(errp, QERR_DEVICE_ENCRYPTED,
+            error_set(errp, ERROR_CLASS_DEVICE_ENCRYPTED,
+                      "'%s' (%s) is encrypted",
                       bdrv_get_device_name(bs),
                       bdrv_get_encrypted_filename(bs));
         }
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 85f1699..986260f 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -49,9 +49,6 @@ void qerror_report_err(Error *err);
 #define QERR_BUS_NOT_FOUND \
     ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
 
-#define QERR_DEVICE_ENCRYPTED \
-    ERROR_CLASS_DEVICE_ENCRYPTED, "'%s' (%s) is encrypted"
-
 #define QERR_DEVICE_HAS_NO_MEDIUM \
     ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
 
@@ -67,9 +64,6 @@ void qerror_report_err(Error *err);
 #define QERR_DEVICE_NO_HOTPLUG \
     ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
 
-#define QERR_DEVICE_NOT_ENCRYPTED \
-    ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted"
-
 #define QERR_DEVICE_NOT_FOUND \
     ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 47/47] block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices
  2015-02-06 17:35 [Qemu-devel] [PULL v2 00/47] Block patches Kevin Wolf
                   ` (3 preceding siblings ...)
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 46/47] block: Eliminate silly QERR_ macros used for encryption keys Kevin Wolf
@ 2015-02-06 17:35 ` Kevin Wolf
  2015-02-09 22:33 ` [Qemu-devel] [PULL v2 00/47] Block patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2015-02-06 17:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

From: Programmingkid <programmingkidx@gmail.com>

This patch replaces the dummy code in raw_getlength() for block devices
on OS X, which always returned LLONG_MAX, with a real implementation
that returns the actual block device size.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/raw-posix.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 7b42f37..e474c17 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1375,7 +1375,20 @@ again:
         if (size == 0)
 #endif
 #if defined(__APPLE__) && defined(__MACH__)
-        size = LLONG_MAX;
+        {
+            uint64_t sectors = 0;
+            uint32_t sector_size = 0;
+
+            if (ioctl(fd, DKIOCGETBLOCKCOUNT, &sectors) == 0
+               && ioctl(fd, DKIOCGETBLOCKSIZE, &sector_size) == 0) {
+                size = sectors * sector_size;
+            } else {
+                size = lseek(fd, 0LL, SEEK_END);
+                if (size < 0) {
+                    return -errno;
+                }
+            }
+        }
 #else
         size = lseek(fd, 0LL, SEEK_END);
         if (size < 0) {
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PULL v2 00/47] Block patches
  2015-02-06 17:35 [Qemu-devel] [PULL v2 00/47] Block patches Kevin Wolf
                   ` (4 preceding siblings ...)
  2015-02-06 17:35 ` [Qemu-devel] [PULL v2 47/47] block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices Kevin Wolf
@ 2015-02-09 22:33 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2015-02-09 22:33 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: QEMU Developers

On 6 February 2015 at 17:35, Kevin Wolf <kwolf@redhat.com> wrote:
> [ Posting only the new patches in v2 as replies, see v1 for the rest ]
>
> The following changes since commit cebbae86b4f7ee3d3dd9df906b97d269e70d9cc7:
>
>   Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging (2015-02-06 14:35:52 +0000)
>
> are available in the git repository at:
>
>
>   git://repo.or.cz/qemu/kevin.git tags/for-upstream
>
> for you to fetch changes up to 728dacbda817b2ca259e9d337fab06bcf14e94a6:
>
>   block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices (2015-02-06 18:00:53 +0100)
>
> ----------------------------------------------------------------
> Block patches for 2.3
>
> ----------------------------------------------------------------

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2015-02-09 22:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 17:35 [Qemu-devel] [PULL v2 00/47] Block patches Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 43/47] blockdev: Give find_block_job() an Error ** parameter Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 44/47] blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 45/47] block: New bdrv_add_key(), convert monitor to use it Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 46/47] block: Eliminate silly QERR_ macros used for encryption keys Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 47/47] block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices Kevin Wolf
2015-02-09 22:33 ` [Qemu-devel] [PULL v2 00/47] Block patches Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).