diff options
author | Avi Kivity <avi@redhat.com> | 2010-06-21 18:02:27 +0300 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-06-21 18:02:27 +0300 |
commit | 037b8f204645989788be2ef084b12ccb83fb8e56 (patch) | |
tree | 88569beda2c14201e9e5e1027c554ca591cc644b /blockdev.c | |
parent | 80273111d5f954eb06c2b68db12cd86a6f58e2e5 (diff) | |
parent | c9b62a7ee14f51c9fa473a5bbefe264c904613ee (diff) |
Merge commit 'c9b62a7ee14f51c9fa473a5bbefe264c904613ee' into upstream-merge
* commit 'c9b62a7ee14f51c9fa473a5bbefe264c904613ee':
blockdev: Give drives internal linkage
block: Decouple savevm from DriveInfo
block: New bdrv_next()
monitor: Make "commit FOO" complain when FOO doesn't exist
block: Decouple block device "commit all" from DriveInfo
block: Move error actions from DriveInfo to BlockDriverState
cow: use qemu block API
cow: stop using mmap
cow: use pread/pwrite
qcow2: Restore L1 entry on l2_allocate failure
Fix regression for "-drive file="
savevm: Really verify if a drive supports snapshots
qcow2: Return real error code in load_refcount_block
qcow2: Allow alloc_clusters_noref to return errors
qcow2: Allow get_refcount to return errors
vpc: Read/write multiple sectors at once
Conflicts:
blockdev.c
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/blockdev.c b/blockdev.c index 99ad6f1c3..7e2dba473 100644 --- a/blockdev.c +++ b/blockdev.c @@ -17,7 +17,7 @@ DriveInfo *extboot_drive = NULL; -struct drivelist drives = QTAILQ_HEAD_INITIALIZER(drives); +static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); QemuOpts *drive_add(const char *file, const char *fmt, ...) { @@ -92,19 +92,6 @@ const char *drive_get_serial(BlockDriverState *bdrv) return "\0"; } -BlockInterfaceErrorAction drive_get_on_error( - BlockDriverState *bdrv, int is_read) -{ - DriveInfo *dinfo; - - QTAILQ_FOREACH(dinfo, &drives, next) { - if (dinfo->bdrv == bdrv) - return is_read ? dinfo->on_read_error : dinfo->on_write_error; - } - - return is_read ? BLOCK_ERR_REPORT : BLOCK_ERR_STOP_ENOSPC; -} - static void bdrv_format_print(void *opaque, const char *name) { fprintf(stderr, " %s", name); @@ -420,13 +407,13 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error) dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; - dinfo->on_read_error = on_read_error; - dinfo->on_write_error = on_write_error; dinfo->opts = opts; if (serial) strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1); QTAILQ_INSERT_TAIL(&drives, dinfo, next); + bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); + switch(type) { case IF_IDE: case IF_SCSI: @@ -464,7 +451,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error) case IF_COUNT: abort(); } - if (!file) { + if (!file || !*file) { *fatal_error = 0; return NULL; } @@ -501,16 +488,18 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error) void do_commit(Monitor *mon, const QDict *qdict) { - int all_devices; - DriveInfo *dinfo; const char *device = qdict_get_str(qdict, "device"); + BlockDriverState *bs; - all_devices = !strcmp(device, "all"); - QTAILQ_FOREACH(dinfo, &drives, next) { - if (!all_devices) - if (strcmp(bdrv_get_device_name(dinfo->bdrv), device)) - continue; - bdrv_commit(dinfo->bdrv); + if (!strcmp(device, "all")) { + bdrv_commit_all(); + } else { + bs = bdrv_find(device); + if (!bs) { + qerror_report(QERR_DEVICE_NOT_FOUND, device); + return; + } + bdrv_commit(bs); } } |