diff options
author | Anthony Liguori <aliguori@amazon.com> | 2013-10-18 10:02:14 -0700 |
---|---|---|
committer | Anthony Liguori <aliguori@amazon.com> | 2013-10-18 10:02:14 -0700 |
commit | 1da9772d83576cef463b88adb7c390f978ef4ea3 (patch) | |
tree | 37bfc90ec167e9d0aaf69f3a6db5b50a5466010a | |
parent | 989644915c281ac83f06f65923d716272ede1ed8 (diff) | |
parent | dbbcaa8d4358fdf3c42bf01e9e2d687300e84770 (diff) |
Merge remote-tracking branch 'stefanha/block' into staging
# By Fam Zheng (3) and others
# Via Stefan Hajnoczi
* stefanha/block:
vmdk: fix VMFS extent parsing
vmdk: Only read cid from image file when opening
virtio: Remove unneeded memcpy
block/raw-win32: Always use -errno in hdev_open
blockdev: fix cdrom read_only flag
sd: Avoid access to NULL BlockDriverState
hmp: drop bogus "[not inserted]"
Message-id: 1382105915-27735-1-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
-rw-r--r-- | block/raw-win32.c | 5 | ||||
-rw-r--r-- | block/vmdk.c | 10 | ||||
-rw-r--r-- | blockdev.c | 7 | ||||
-rw-r--r-- | hmp.c | 2 | ||||
-rw-r--r-- | hw/block/virtio-blk.c | 1 | ||||
-rw-r--r-- | hw/sd/sd.c | 2 |
6 files changed, 12 insertions, 15 deletions
diff --git a/block/raw-win32.c b/block/raw-win32.c index c3e4c62d53..676b5701db 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -590,12 +590,11 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, int err = GetLastError(); if (err == ERROR_ACCESS_DENIED) { - error_setg_errno(errp, EACCES, "Could not open device"); ret = -EACCES; } else { - error_setg(errp, "Could not open device"); - ret = -1; + ret = -EINVAL; } + error_setg_errno(errp, -ret, "Could not open device"); goto done; } diff --git a/block/vmdk.c b/block/vmdk.c index 5a9f2787f8..32ec8b7766 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -112,6 +112,7 @@ typedef struct BDRVVmdkState { CoMutex lock; uint64_t desc_offset; bool cid_updated; + bool cid_checked; uint32_t parent_cid; int num_extents; /* Extent array with num_extents entries, ascend ordered by address */ @@ -197,8 +198,6 @@ static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename) } } -#define CHECK_CID 1 - #define SECTOR_SIZE 512 #define DESC_SIZE (20 * SECTOR_SIZE) /* 20 sectors of 512 bytes each */ #define BUF_SIZE 4096 @@ -301,19 +300,18 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid) static int vmdk_is_cid_valid(BlockDriverState *bs) { -#ifdef CHECK_CID BDRVVmdkState *s = bs->opaque; BlockDriverState *p_bs = bs->backing_hd; uint32_t cur_pcid; - if (p_bs) { + if (!s->cid_checked && p_bs) { cur_pcid = vmdk_read_cid(p_bs, 0); if (s->parent_cid != cur_pcid) { /* CID not valid */ return 0; } } -#endif + s->cid_checked = true; /* CID valid */ return 1; } @@ -728,6 +726,8 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, error_setg(errp, "Invalid extent lines: \n%s", p); return -EINVAL; } + } else if (!strcmp(type, "VMFS")) { + flat_offset = 0; } else if (ret != 4) { error_setg(errp, "Invalid extent lines: \n%s", p); return -EINVAL; diff --git a/blockdev.c b/blockdev.c index 4f76e28164..b260477f1b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -625,7 +625,8 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) int cyls, heads, secs, translation; int max_devs, bus_id, unit_id, index; const char *devaddr; - bool read_only, copy_on_read; + bool read_only = false; + bool copy_on_read; Error *local_err = NULL; /* Change legacy command line options into QMP ones */ @@ -701,7 +702,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) media = MEDIA_DISK; } else if (!strcmp(value, "cdrom")) { media = MEDIA_CDROM; - qdict_put(bs_opts, "read-only", qstring_from_str("on")); + read_only = true; } else { error_report("'%s' invalid media", value); goto fail; @@ -709,7 +710,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) } /* copy-on-read is disabled with a warning for read-only devices */ - read_only = qemu_opt_get_bool(legacy_opts, "read-only", false); + read_only |= qemu_opt_get_bool(legacy_opts, "read-only", false); copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false); if (read_only && copy_on_read) { @@ -366,8 +366,6 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) info->value->inserted->iops_rd_max, info->value->inserted->iops_wr_max, info->value->inserted->iops_size); - } else { - monitor_printf(mon, " [not inserted]"); } if (verbose) { diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 49a23c33f7..13f6d8276e 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -703,7 +703,6 @@ static int virtio_blk_device_init(VirtIODevice *vdev) s->bs = blk->conf.bs; s->conf = &blk->conf; - memcpy(&(s->blk), blk, sizeof(struct VirtIOBlkConf)); s->rq = NULL; s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7380f063f7..4502ad143d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -494,7 +494,7 @@ SDState *sd_init(BlockDriverState *bs, bool is_spi) { SDState *sd; - if (bdrv_is_read_only(bs)) { + if (bs && bdrv_is_read_only(bs)) { fprintf(stderr, "sd_init: Cannot use read-only drive\n"); return NULL; } |