mirror of
https://github.com/qemu/qemu.git
synced 2024-12-11 12:43:55 +08:00
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>
This commit is contained in:
commit
1da9772d83
@ -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;
|
||||
}
|
||||
|
||||
|
10
block/vmdk.c
10
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;
|
||||
|
@ -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) {
|
||||
|
2
hmp.c
2
hmp.c
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user