block: Decouple block device "commit all" from DriveInfo

do_commit() and mux_proc_byte() iterate over the list of drives
defined with drive_init().  This misses host block devices defined by
other means.  Such means don't exist now, but will be introduced later
in this series.

Change them to use new bdrv_commit_all(), which iterates over all host
block devices.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Markus Armbruster 2010-06-02 18:55:18 +02:00 committed by Kevin Wolf
parent abd7f68d08
commit 6ab4b5ab8f
4 changed files with 19 additions and 14 deletions

View file

@ -788,6 +788,15 @@ ro_cleanup:
return ret; return ret;
} }
void bdrv_commit_all(void)
{
BlockDriverState *bs;
QTAILQ_FOREACH(bs, &bdrv_states, list) {
bdrv_commit(bs);
}
}
/* /*
* Return values: * Return values:
* 0 - success * 0 - success

View file

@ -85,6 +85,7 @@ int64_t bdrv_getlength(BlockDriverState *bs);
void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
void bdrv_guess_geometry(BlockDriverState *bs, int *pcyls, int *pheads, int *psecs); void bdrv_guess_geometry(BlockDriverState *bs, int *pcyls, int *pheads, int *psecs);
int bdrv_commit(BlockDriverState *bs); int bdrv_commit(BlockDriverState *bs);
void bdrv_commit_all(void);
int bdrv_change_backing_file(BlockDriverState *bs, int bdrv_change_backing_file(BlockDriverState *bs,
const char *backing_file, const char *backing_fmt); const char *backing_file, const char *backing_fmt);
void bdrv_register(BlockDriver *bdrv); void bdrv_register(BlockDriver *bdrv);

View file

@ -486,16 +486,16 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
void do_commit(Monitor *mon, const QDict *qdict) void do_commit(Monitor *mon, const QDict *qdict)
{ {
int all_devices;
DriveInfo *dinfo;
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
BlockDriverState *bs;
all_devices = !strcmp(device, "all"); if (!strcmp(device, "all")) {
QTAILQ_FOREACH(dinfo, &drives, next) { bdrv_commit_all();
if (!all_devices) } else {
if (strcmp(bdrv_get_device_name(dinfo->bdrv), device)) bs = bdrv_find(device);
continue; if (bs) {
bdrv_commit(dinfo->bdrv); bdrv_commit(bs);
}
} }
} }

View file

@ -351,12 +351,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
break; break;
} }
case 's': case 's':
{ bdrv_commit_all();
DriveInfo *dinfo;
QTAILQ_FOREACH(dinfo, &drives, next) {
bdrv_commit(dinfo->bdrv);
}
}
break; break;
case 'b': case 'b':
qemu_chr_event(chr, CHR_EVENT_BREAK); qemu_chr_event(chr, CHR_EVENT_BREAK);