mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
bdrv: Use "Error" for creating images
Add an Error ** parameter to BlockDriver.bdrv_create to allow more specific error messages. Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
015a1036a7
commit
d5124c00d8
17 changed files with 34 additions and 18 deletions
2
block.c
2
block.c
|
@ -401,7 +401,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)
|
|||
CreateCo *cco = opaque;
|
||||
assert(cco->drv);
|
||||
|
||||
cco->ret = cco->drv->bdrv_create(cco->filename, cco->options);
|
||||
cco->ret = cco->drv->bdrv_create(cco->filename, cco->options, NULL);
|
||||
}
|
||||
|
||||
int bdrv_create(BlockDriver *drv, const char* filename,
|
||||
|
|
|
@ -295,7 +295,8 @@ static void cow_close(BlockDriverState *bs)
|
|||
{
|
||||
}
|
||||
|
||||
static int cow_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int cow_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
struct cow_header_v2 cow_header;
|
||||
struct stat st;
|
||||
|
|
|
@ -357,7 +357,7 @@ out:
|
|||
}
|
||||
|
||||
static int qemu_gluster_create(const char *filename,
|
||||
QEMUOptionParameter *options)
|
||||
QEMUOptionParameter *options, Error **errp)
|
||||
{
|
||||
struct glfs *glfs;
|
||||
struct glfs_fd *fd;
|
||||
|
|
|
@ -1238,7 +1238,8 @@ static int iscsi_has_zero_init(BlockDriverState *bs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int iscsi_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int iscsi_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int ret = 0;
|
||||
int64_t total_size = 0;
|
||||
|
|
|
@ -659,7 +659,8 @@ static void qcow_close(BlockDriverState *bs)
|
|||
error_free(s->migration_blocker);
|
||||
}
|
||||
|
||||
static int qcow_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int qcow_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int header_size, backing_filename_len, l1_size, shift, i;
|
||||
QCowHeader header;
|
||||
|
|
|
@ -1468,7 +1468,8 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int qcow2_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int qcow2_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
const char *backing_file = NULL;
|
||||
const char *backing_fmt = NULL;
|
||||
|
|
|
@ -604,7 +604,8 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int bdrv_qed_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int bdrv_qed_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
uint64_t image_size = 0;
|
||||
uint32_t cluster_size = QED_DEFAULT_CLUSTER_SIZE;
|
||||
|
|
|
@ -1041,7 +1041,8 @@ static int64_t raw_get_allocated_file_size(BlockDriverState *bs)
|
|||
return (int64_t)st.st_blocks * 512;
|
||||
}
|
||||
|
||||
static int raw_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int raw_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int fd;
|
||||
int result = 0;
|
||||
|
@ -1506,7 +1507,8 @@ static coroutine_fn BlockDriverAIOCB *hdev_aio_discard(BlockDriverState *bs,
|
|||
cb, opaque, QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV);
|
||||
}
|
||||
|
||||
static int hdev_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int hdev_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int fd;
|
||||
int ret = 0;
|
||||
|
|
|
@ -422,7 +422,8 @@ static int64_t raw_get_allocated_file_size(BlockDriverState *bs)
|
|||
return st.st_size;
|
||||
}
|
||||
|
||||
static int raw_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int raw_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int fd;
|
||||
int64_t total_size = 0;
|
||||
|
|
|
@ -130,7 +130,8 @@ static int raw_has_zero_init(BlockDriverState *bs)
|
|||
return bdrv_has_zero_init(bs->file);
|
||||
}
|
||||
|
||||
static int raw_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int raw_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
return bdrv_create_file(filename, options);
|
||||
}
|
||||
|
|
|
@ -287,7 +287,8 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int64_t bytes = 0;
|
||||
int64_t objsize;
|
||||
|
|
|
@ -1438,7 +1438,8 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int sd_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int sd_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t vid = 0, base_vid = 0;
|
||||
|
|
|
@ -651,7 +651,8 @@ static QEMUOptionParameter ssh_create_options[] = {
|
|||
{ NULL }
|
||||
};
|
||||
|
||||
static int ssh_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int ssh_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int r, ret;
|
||||
Error *local_err = NULL;
|
||||
|
|
|
@ -645,7 +645,8 @@ static int vdi_co_write(BlockDriverState *bs,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int vdi_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int vdi_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int fd;
|
||||
int result = 0;
|
||||
|
|
|
@ -1552,7 +1552,8 @@ static int filename_decompose(const char *filename, char *path, char *prefix,
|
|||
return VMDK_OK;
|
||||
}
|
||||
|
||||
static int vmdk_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int vmdk_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
int fd, idx = 0;
|
||||
char desc[BUF_SIZE];
|
||||
|
|
|
@ -684,7 +684,8 @@ static int create_fixed_disk(int fd, uint8_t *buf, int64_t total_size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int vpc_create(const char *filename, QEMUOptionParameter *options)
|
||||
static int vpc_create(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp)
|
||||
{
|
||||
uint8_t buf[1024];
|
||||
struct vhd_footer *footer = (struct vhd_footer *) buf;
|
||||
|
|
|
@ -90,7 +90,8 @@ struct BlockDriver {
|
|||
const uint8_t *buf, int nb_sectors);
|
||||
void (*bdrv_close)(BlockDriverState *bs);
|
||||
void (*bdrv_rebind)(BlockDriverState *bs);
|
||||
int (*bdrv_create)(const char *filename, QEMUOptionParameter *options);
|
||||
int (*bdrv_create)(const char *filename, QEMUOptionParameter *options,
|
||||
Error **errp);
|
||||
int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
|
||||
int (*bdrv_make_empty)(BlockDriverState *bs);
|
||||
/* aio */
|
||||
|
|
Loading…
Reference in a new issue