cryptospore / rpms / qemu-kvm

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