|
|
383d26 |
From f93730ef94f17043f240950d40d4661629b89aa3 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Date: Mon, 6 May 2019 17:56:15 +0200
|
|
|
383d26 |
Subject: [PATCH 05/53] qemu-img: Gracefully shutdown when map can't finish
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Message-id: <20190506175629.11079-6-jsnow@redhat.com>
|
|
|
383d26 |
Patchwork-id: 87190
|
|
|
383d26 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 05/19] qemu-img: Gracefully shutdown when map can't finish
|
|
|
383d26 |
Bugzilla: 1692018
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
From: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
Trying 'qemu-img map -f raw nbd://localhost:10809' causes the
|
|
|
383d26 |
NBD server to output a scary message:
|
|
|
383d26 |
|
|
|
383d26 |
qemu-nbd: Disconnect client, due to: Failed to read request: Unexpected end-of-file before all bytes were read
|
|
|
383d26 |
|
|
|
383d26 |
This is because the NBD client, being remote, has no way to expose a
|
|
|
383d26 |
human-readable map (the --output=json data is fine, however). But
|
|
|
383d26 |
because we exit(1) right after the message, causing the client to
|
|
|
383d26 |
bypass all block cleanup, the server sees the abrupt exit and warns,
|
|
|
383d26 |
whereas it would be silent had the client had a chance to send
|
|
|
383d26 |
NBD_CMD_DISC. Other protocols may have similar cleanup issues, where
|
|
|
383d26 |
failure to blk_unref() could cause unintended effects.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
Message-Id: <20190326184043.7544-1-eblake@redhat.com>
|
|
|
383d26 |
Reviewed-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
(cherry picked from commit 30065d142443981924786da72828ba683da35e8f)
|
|
|
383d26 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
qemu-img.c | 14 +++++++++-----
|
|
|
383d26 |
1 file changed, 9 insertions(+), 5 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
383d26 |
index 096e844..5be2abf 100644
|
|
|
383d26 |
--- a/qemu-img.c
|
|
|
383d26 |
+++ b/qemu-img.c
|
|
|
383d26 |
@@ -2713,14 +2713,14 @@ static int img_info(int argc, char **argv)
|
|
|
383d26 |
return 0;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
-static void dump_map_entry(OutputFormat output_format, MapEntry *e,
|
|
|
383d26 |
- MapEntry *next)
|
|
|
383d26 |
+static int dump_map_entry(OutputFormat output_format, MapEntry *e,
|
|
|
383d26 |
+ MapEntry *next)
|
|
|
383d26 |
{
|
|
|
383d26 |
switch (output_format) {
|
|
|
383d26 |
case OFORMAT_HUMAN:
|
|
|
383d26 |
if (e->data && !e->has_offset) {
|
|
|
383d26 |
error_report("File contains external, encrypted or compressed clusters.");
|
|
|
383d26 |
- exit(1);
|
|
|
383d26 |
+ return -1;
|
|
|
383d26 |
}
|
|
|
383d26 |
if (e->data && !e->zero) {
|
|
|
383d26 |
printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n",
|
|
|
383d26 |
@@ -2753,6 +2753,7 @@ static void dump_map_entry(OutputFormat output_format, MapEntry *e,
|
|
|
383d26 |
}
|
|
|
383d26 |
break;
|
|
|
383d26 |
}
|
|
|
383d26 |
+ return 0;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
static int get_block_status(BlockDriverState *bs, int64_t offset,
|
|
|
383d26 |
@@ -2939,12 +2940,15 @@ static int img_map(int argc, char **argv)
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
if (curr.length > 0) {
|
|
|
383d26 |
- dump_map_entry(output_format, &curr, &next;;
|
|
|
383d26 |
+ ret = dump_map_entry(output_format, &curr, &next;;
|
|
|
383d26 |
+ if (ret < 0) {
|
|
|
383d26 |
+ goto out;
|
|
|
383d26 |
+ }
|
|
|
383d26 |
}
|
|
|
383d26 |
curr = next;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
- dump_map_entry(output_format, &curr, NULL);
|
|
|
383d26 |
+ ret = dump_map_entry(output_format, &curr, NULL);
|
|
|
383d26 |
|
|
|
383d26 |
out:
|
|
|
383d26 |
blk_unref(blk);
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|