cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From ee2c4c17b2bf7a0f1b420096460d33d87792ef78 Mon Sep 17 00:00:00 2001
9ae3a8
From: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Date: Tue, 16 Sep 2014 20:11:42 +0200
9ae3a8
Subject: [PATCH 04/20] vdi: say why an image is bad
9ae3a8
9ae3a8
Message-id: <3fcc4a3635f7e4e2da9110df47e59d9727327707.1410897407.git.jcody@redhat.com>
9ae3a8
Patchwork-id: 61208
9ae3a8
O-Subject: [PATCH qemu-kvm-rhel RHEL7.1 03/15] vdi: say why an image is bad
9ae3a8
Bugzilla: 1098086
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
9ae3a8
From: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
Instead of just putting it in debugging output, we can now put the
9ae3a8
value in an Error.
9ae3a8
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Reviewed-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 5b7aa9b56d1bfc79916262f380c3fc7961becb50)
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	block/vdi.c
9ae3a8
9ae3a8
RHEL7 Conflict Notes:  Conflict due to different patch order, from
9ae3a8
                       a CVE commit.
9ae3a8
9ae3a8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block/vdi.c |   25 ++++++++++++++++---------
9ae3a8
 1 files changed, 16 insertions(+), 9 deletions(-)
9ae3a8
9ae3a8
diff --git a/block/vdi.c b/block/vdi.c
9ae3a8
index 5e2fad5..b095bee 100644
9ae3a8
--- a/block/vdi.c
9ae3a8
+++ b/block/vdi.c
9ae3a8
@@ -412,39 +412,46 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
9ae3a8
         ret = -EMEDIUMTYPE;
9ae3a8
         goto fail;
9ae3a8
     } else if (header.version != VDI_VERSION_1_1) {
9ae3a8
-        logout("unsupported version %u.%u\n",
9ae3a8
-               header.version >> 16, header.version & 0xffff);
9ae3a8
+        error_setg(errp, "unsupported VDI image (version %u.%u)",
9ae3a8
+                   header.version >> 16, header.version & 0xffff);
9ae3a8
         ret = -ENOTSUP;
9ae3a8
         goto fail;
9ae3a8
     } else if (header.offset_bmap % SECTOR_SIZE != 0) {
9ae3a8
         /* We only support block maps which start on a sector boundary. */
9ae3a8
-        logout("unsupported block map offset 0x%x B\n", header.offset_bmap);
9ae3a8
+        error_setg(errp, "unsupported VDI image (unaligned block map offset "
9ae3a8
+                   "0x%x)", header.offset_bmap);
9ae3a8
         ret = -ENOTSUP;
9ae3a8
         goto fail;
9ae3a8
     } else if (header.offset_data % SECTOR_SIZE != 0) {
9ae3a8
         /* We only support data blocks which start on a sector boundary. */
9ae3a8
-        logout("unsupported data offset 0x%x B\n", header.offset_data);
9ae3a8
+        error_setg(errp, "unsupported VDI image (unaligned data offset 0x%x)",
9ae3a8
+                   header.offset_data);
9ae3a8
         ret = -ENOTSUP;
9ae3a8
         goto fail;
9ae3a8
     } else if (header.sector_size != SECTOR_SIZE) {
9ae3a8
-        logout("unsupported sector size %u B\n", header.sector_size);
9ae3a8
+        error_setg(errp, "unsupported VDI image (sector size %u is not %u)",
9ae3a8
+                   header.sector_size, SECTOR_SIZE);
9ae3a8
         ret = -ENOTSUP;
9ae3a8
         goto fail;
9ae3a8
     } else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
9ae3a8
-        logout("unsupported block size %u B\n", header.block_size);
9ae3a8
+        error_setg(errp, "unsupported VDI image (sector size %u is not %u)",
9ae3a8
+                   header.block_size, DEFAULT_CLUSTER_SIZE);
9ae3a8
         ret = -ENOTSUP;
9ae3a8
         goto fail;
9ae3a8
     } else if (header.disk_size >
9ae3a8
                (uint64_t)header.blocks_in_image * header.block_size) {
9ae3a8
-        logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
9ae3a8
+        error_setg(errp, "unsupported VDI image (disk size %" PRIu64 ", "
9ae3a8
+                   "image bitmap has room for %" PRIu64 ")",
9ae3a8
+                   header.disk_size,
9ae3a8
+                   (uint64_t)header.blocks_in_image * header.block_size);
9ae3a8
         ret = -ENOTSUP;
9ae3a8
         goto fail;
9ae3a8
     } else if (!uuid_is_null(header.uuid_link)) {
9ae3a8
-        logout("link uuid != 0, unsupported\n");
9ae3a8
+        error_setg(errp, "unsupported VDI image (non-NULL link UUID)");
9ae3a8
         ret = -ENOTSUP;
9ae3a8
         goto fail;
9ae3a8
     } else if (!uuid_is_null(header.uuid_parent)) {
9ae3a8
-        logout("parent uuid != 0, unsupported\n");
9ae3a8
+        error_setg(errp, "unsupported VDI image (non-NULL parent UUID)");
9ae3a8
         ret = -ENOTSUP;
9ae3a8
         goto fail;
9ae3a8
     } else if (header.blocks_in_image > VDI_BLOCKS_IN_IMAGE_MAX) {
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8