mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 01:50:43 +00:00
blockdev: Hide QEMUMachine from drive_init()
To pave the way for moving it out of vl.c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
7cdb1f6d30
commit
a803cb8eb8
@ -38,7 +38,7 @@ DriveInfo *add_init_drive(const char *optstr)
|
|||||||
if (!opts)
|
if (!opts)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dinfo = drive_init(opts, current_machine, &fatal_error);
|
dinfo = drive_init(opts, current_machine->use_scsi, &fatal_error);
|
||||||
if (!dinfo) {
|
if (!dinfo) {
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -584,7 +584,7 @@ static USBDevice *usb_msd_init(const char *filename)
|
|||||||
qemu_opt_set(opts, "if", "none");
|
qemu_opt_set(opts, "if", "none");
|
||||||
|
|
||||||
/* create host drive */
|
/* create host drive */
|
||||||
dinfo = drive_init(opts, NULL, &fatal_error);
|
dinfo = drive_init(opts, 0, &fatal_error);
|
||||||
if (!dinfo) {
|
if (!dinfo) {
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
3
sysemu.h
3
sysemu.h
@ -191,7 +191,8 @@ extern BlockInterfaceErrorAction drive_get_on_error(
|
|||||||
BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type);
|
BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type);
|
||||||
|
|
||||||
extern QemuOpts *drive_add(const char *file, const char *fmt, ...);
|
extern QemuOpts *drive_add(const char *file, const char *fmt, ...);
|
||||||
extern DriveInfo *drive_init(QemuOpts *arg, void *machine, int *fatal_error);
|
extern DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi,
|
||||||
|
int *fatal_error);
|
||||||
|
|
||||||
/* device-hotplug */
|
/* device-hotplug */
|
||||||
|
|
||||||
|
12
vl.c
12
vl.c
@ -767,8 +767,7 @@ static int parse_block_error_action(const char *buf, int is_read)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DriveInfo *drive_init(QemuOpts *opts, void *opaque,
|
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
|
||||||
int *fatal_error)
|
|
||||||
{
|
{
|
||||||
const char *buf;
|
const char *buf;
|
||||||
const char *file = NULL;
|
const char *file = NULL;
|
||||||
@ -780,7 +779,6 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
|
|||||||
int bus_id, unit_id;
|
int bus_id, unit_id;
|
||||||
int cyls, heads, secs, translation;
|
int cyls, heads, secs, translation;
|
||||||
BlockDriver *drv = NULL;
|
BlockDriver *drv = NULL;
|
||||||
QEMUMachine *machine = opaque;
|
|
||||||
int max_devs;
|
int max_devs;
|
||||||
int index;
|
int index;
|
||||||
int ro = 0;
|
int ro = 0;
|
||||||
@ -795,7 +793,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
|
|||||||
|
|
||||||
translation = BIOS_ATA_TRANSLATION_AUTO;
|
translation = BIOS_ATA_TRANSLATION_AUTO;
|
||||||
|
|
||||||
if (machine && machine->use_scsi) {
|
if (default_to_scsi) {
|
||||||
type = IF_SCSI;
|
type = IF_SCSI;
|
||||||
max_devs = MAX_SCSI_DEVS;
|
max_devs = MAX_SCSI_DEVS;
|
||||||
pstrcpy(devname, sizeof(devname), "scsi");
|
pstrcpy(devname, sizeof(devname), "scsi");
|
||||||
@ -1135,10 +1133,10 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
|
|||||||
|
|
||||||
static int drive_init_func(QemuOpts *opts, void *opaque)
|
static int drive_init_func(QemuOpts *opts, void *opaque)
|
||||||
{
|
{
|
||||||
QEMUMachine *machine = opaque;
|
int *use_scsi = opaque;
|
||||||
int fatal_error = 0;
|
int fatal_error = 0;
|
||||||
|
|
||||||
if (drive_init(opts, machine, &fatal_error) == NULL) {
|
if (drive_init(opts, *use_scsi, &fatal_error) == NULL) {
|
||||||
if (fatal_error)
|
if (fatal_error)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -3641,7 +3639,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
/* open the virtual block devices */
|
/* open the virtual block devices */
|
||||||
if (snapshot)
|
if (snapshot)
|
||||||
qemu_opts_foreach(&qemu_drive_opts, drive_enable_snapshot, NULL, 0);
|
qemu_opts_foreach(&qemu_drive_opts, drive_enable_snapshot, NULL, 0);
|
||||||
if (qemu_opts_foreach(&qemu_drive_opts, drive_init_func, machine, 1) != 0)
|
if (qemu_opts_foreach(&qemu_drive_opts, drive_init_func, &machine->use_scsi, 1) != 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
register_savevm_live("ram", 0, 3, NULL, ram_save_live, NULL,
|
register_savevm_live("ram", 0, 3, NULL, ram_save_live, NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user