Re: [Qemu-devel] [PATCH v1 03/13] blockdev: Introduce QEMUMachine-default_drive_if
Jason Baron jba...@redhat.com writes: From: Jason Baron jba...@redhat.com The current QEMUMachine definition has a 'use_scsi' field to indicate if a machine type should use scsi by default. However, Q35 wants to use ahci by default. Thus, introdue a new field in the QEMUMachine defintion, default_drive_if. Please use 'static inline int get_default_drive_if(int default_drive_if)', when accesssing the new default_drive_if field. The field should be initialized by the machine type to the default interface type which it wants to use (IF_SCSI, IF_AHCI, etc.). If no default_drive_if is specified, we assume IF_IDE. In the future, we should go through all of the machines types and explicitly define their desired default interface, thus eliminating the need for get_default_drive_if() interface. Reviewed-by: Paolo Bonzini pbonz...@redhat.com Signed-off-by: Jason Baron jba...@redhat.com I think having a storage machine option is a bit nicer here but I'll defer to Kevin/Markus. Regards, Anthony Liguori --- blockdev.c |4 ++-- blockdev.h | 20 hw/boards.h |2 +- hw/device-hotplug.c |2 +- hw/highbank.c |2 +- hw/leon3.c |1 - hw/mips_jazz.c |4 ++-- hw/pc_sysfw.c |2 +- hw/puv3.c |1 - hw/realview.c |6 +++--- hw/spapr.c |2 +- hw/sun4m.c | 24 hw/versatilepb.c|4 ++-- hw/vexpress.c |4 ++-- hw/xilinx_zynq.c|2 +- vl.c| 20 +++- 16 files changed, 60 insertions(+), 40 deletions(-) diff --git a/blockdev.c b/blockdev.c index 99828ad..2977e2f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -275,7 +275,7 @@ static bool do_check_io_limits(BlockIOLimit *io_limits) return true; } -DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) +DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType default_drive_if) { const char *buf; const char *file = NULL; @@ -325,7 +325,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) return NULL; } } else { -type = default_to_scsi ? IF_SCSI : IF_IDE; +type = get_default_drive_if(default_drive_if); } max_devs = if_max_devs[type]; diff --git a/blockdev.h b/blockdev.h index 5f27b64..658380d 100644 --- a/blockdev.h +++ b/blockdev.h @@ -40,6 +40,26 @@ struct DriveInfo { int refcount; }; +/* + * Each qemu machine type defines a default_drive_if field for its default + * interface type. When accessing the default_drive_if field, please make use + * of get_default_drive_if(). If default_drive_if is unspecified, we set it to + * IF_IDE. + * + * Left as a 'todo': We should convert those that are unspecified to their + * proper default values, thus eliminating the need for get_default_drive_if(). + */ +static inline int get_default_drive_if(int default_drive_if) +{ +assert(default_drive_if IF_COUNT); +assert(default_drive_if = IF_NONE); + +if (default_drive_if == 0) { +return IF_IDE; +} +return default_drive_if; +} + DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); int drive_get_max_bus(BlockInterfaceType type); diff --git a/hw/boards.h b/hw/boards.h index 813d0e5..cd3f79f 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -24,7 +24,7 @@ typedef struct QEMUMachine { const char *desc; QEMUMachineInitFunc *init; QEMUMachineResetFunc *reset; -int use_scsi; +int default_drive_if; int max_cpus; unsigned int no_serial:1, no_parallel:1, diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index eec0fe3..53ee6c3 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -39,7 +39,7 @@ DriveInfo *add_init_drive(const char *optstr) if (!opts) return NULL; -dinfo = drive_init(opts, current_machine-use_scsi); +dinfo = drive_init(opts, current_machine-default_drive_if); if (!dinfo) { qemu_opts_del(opts); return NULL; diff --git a/hw/highbank.c b/hw/highbank.c index afbb005..03ae3d8 100644 --- a/hw/highbank.c +++ b/hw/highbank.c @@ -326,7 +326,7 @@ static QEMUMachine highbank_machine = { .name = highbank, .desc = Calxeda Highbank (ECX-1000), .init = highbank_init, -.use_scsi = 1, +.default_drive_if = IF_SCSI, .max_cpus = 4, }; diff --git a/hw/leon3.c b/hw/leon3.c index 7742738..ef83dff 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -212,7 +212,6 @@ static QEMUMachine leon3_generic_machine = { .name = leon3_generic, .desc = Leon-3 generic, .init = leon3_generic_hw_init, -.use_scsi = 0, }; static void leon3_machine_init(void) diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index
[Qemu-devel] [PATCH v1 03/13] blockdev: Introduce QEMUMachine-default_drive_if
From: Jason Baron jba...@redhat.com The current QEMUMachine definition has a 'use_scsi' field to indicate if a machine type should use scsi by default. However, Q35 wants to use ahci by default. Thus, introdue a new field in the QEMUMachine defintion, default_drive_if. Please use 'static inline int get_default_drive_if(int default_drive_if)', when accesssing the new default_drive_if field. The field should be initialized by the machine type to the default interface type which it wants to use (IF_SCSI, IF_AHCI, etc.). If no default_drive_if is specified, we assume IF_IDE. In the future, we should go through all of the machines types and explicitly define their desired default interface, thus eliminating the need for get_default_drive_if() interface. Reviewed-by: Paolo Bonzini pbonz...@redhat.com Signed-off-by: Jason Baron jba...@redhat.com --- blockdev.c |4 ++-- blockdev.h | 20 hw/boards.h |2 +- hw/device-hotplug.c |2 +- hw/highbank.c |2 +- hw/leon3.c |1 - hw/mips_jazz.c |4 ++-- hw/pc_sysfw.c |2 +- hw/puv3.c |1 - hw/realview.c |6 +++--- hw/spapr.c |2 +- hw/sun4m.c | 24 hw/versatilepb.c|4 ++-- hw/vexpress.c |4 ++-- hw/xilinx_zynq.c|2 +- vl.c| 20 +++- 16 files changed, 60 insertions(+), 40 deletions(-) diff --git a/blockdev.c b/blockdev.c index 99828ad..2977e2f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -275,7 +275,7 @@ static bool do_check_io_limits(BlockIOLimit *io_limits) return true; } -DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) +DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType default_drive_if) { const char *buf; const char *file = NULL; @@ -325,7 +325,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) return NULL; } } else { -type = default_to_scsi ? IF_SCSI : IF_IDE; +type = get_default_drive_if(default_drive_if); } max_devs = if_max_devs[type]; diff --git a/blockdev.h b/blockdev.h index 5f27b64..658380d 100644 --- a/blockdev.h +++ b/blockdev.h @@ -40,6 +40,26 @@ struct DriveInfo { int refcount; }; +/* + * Each qemu machine type defines a default_drive_if field for its default + * interface type. When accessing the default_drive_if field, please make use + * of get_default_drive_if(). If default_drive_if is unspecified, we set it to + * IF_IDE. + * + * Left as a 'todo': We should convert those that are unspecified to their + * proper default values, thus eliminating the need for get_default_drive_if(). + */ +static inline int get_default_drive_if(int default_drive_if) +{ +assert(default_drive_if IF_COUNT); +assert(default_drive_if = IF_NONE); + +if (default_drive_if == 0) { +return IF_IDE; +} +return default_drive_if; +} + DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); int drive_get_max_bus(BlockInterfaceType type); diff --git a/hw/boards.h b/hw/boards.h index 813d0e5..cd3f79f 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -24,7 +24,7 @@ typedef struct QEMUMachine { const char *desc; QEMUMachineInitFunc *init; QEMUMachineResetFunc *reset; -int use_scsi; +int default_drive_if; int max_cpus; unsigned int no_serial:1, no_parallel:1, diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index eec0fe3..53ee6c3 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -39,7 +39,7 @@ DriveInfo *add_init_drive(const char *optstr) if (!opts) return NULL; -dinfo = drive_init(opts, current_machine-use_scsi); +dinfo = drive_init(opts, current_machine-default_drive_if); if (!dinfo) { qemu_opts_del(opts); return NULL; diff --git a/hw/highbank.c b/hw/highbank.c index afbb005..03ae3d8 100644 --- a/hw/highbank.c +++ b/hw/highbank.c @@ -326,7 +326,7 @@ static QEMUMachine highbank_machine = { .name = highbank, .desc = Calxeda Highbank (ECX-1000), .init = highbank_init, -.use_scsi = 1, +.default_drive_if = IF_SCSI, .max_cpus = 4, }; diff --git a/hw/leon3.c b/hw/leon3.c index 7742738..ef83dff 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -212,7 +212,6 @@ static QEMUMachine leon3_generic_machine = { .name = leon3_generic, .desc = Leon-3 generic, .init = leon3_generic_hw_init, -.use_scsi = 0, }; static void leon3_machine_init(void) diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 0847427..f72358c 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -324,14 +324,14 @@ static QEMUMachine mips_magnum_machine = { .name = magnum, .desc = MIPS Magnum, .init = mips_magnum_init, -.use_scsi = 1, +.default_drive_if = IF_SCSI, }; static QEMUMachine mips_pica61_machine