[PATCH qemu 23/38] block: add a model option for MTD devices

Joel Stanley joel at jms.id.au
Mon Nov 21 18:27:00 AEDT 2016


On Sat, Nov 19, 2016 at 12:52 AM, Cédric Le Goater <clg at kaod.org> wrote:
> This could be used to define the flash model to use on some boards
> definitions.

Nice, I like it.

Could we add an option specify the mac/ncsi setup of the system too?
Some hardware will have a NCSI device on one MAC and a PHY on the
other. It would be handy to be able to test those without adding a new
board.

>
> Signed-off-by: Cédric Le Goater <clg at kaod.org>

Reviewed-by: Joel Stanley <joel at jms.id.au>

> ---
>  blockdev.c                | 13 +++++++++++++
>  include/sysemu/blockdev.h |  1 +
>  qemu-options.hx           |  4 +++-
>  3 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 245e1e1d177a..fcea923edf02 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -742,6 +742,10 @@ QemuOptsList qemu_legacy_drive_opts = {
>              .type = QEMU_OPT_STRING,
>              .help = "pci address (virtio only)",
>          },{
> +            .name = "model",
> +            .type = QEMU_OPT_STRING,
> +            .help = "flash model (mtd only)",
> +        },{
>              .name = "serial",
>              .type = QEMU_OPT_STRING,
>              .help = "disk serial number",
> @@ -790,6 +794,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
>      bool read_only = false;
>      bool copy_on_read;
>      const char *serial;
> +    const char *model;
>      const char *filename;
>      Error *local_err = NULL;
>      int i;
> @@ -1030,6 +1035,13 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
>          g_free(new_id);
>      }
>
> +   /* Add virtio block device */
> +    model = qemu_opt_get(legacy_opts, "model");
> +    if (model && type != IF_MTD) {
> +        error_report("model is not supported by this bus type");
> +        goto fail;
> +    }
> +
>      /* Add virtio block device */
>      devaddr = qemu_opt_get(legacy_opts, "addr");
>      if (devaddr && type != IF_VIRTIO) {
> @@ -1102,6 +1114,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
>      dinfo->unit = unit_id;
>      dinfo->devaddr = devaddr;
>      dinfo->serial = g_strdup(serial);
> +    dinfo->model = g_strdup(model);
>
>      blk_set_legacy_dinfo(blk, dinfo);
>
> diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
> index 16432f350805..10c66e5e86a4 100644
> --- a/include/sysemu/blockdev.h
> +++ b/include/sysemu/blockdev.h
> @@ -39,6 +39,7 @@ struct DriveInfo {
>      int cyls, heads, secs, trans;
>      QemuOpts *opts;
>      char *serial;
> +    char *model;
>      QTAILQ_ENTRY(DriveInfo) next;
>  };
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 4a5b29f349f7..16add85bd0f5 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -517,7 +517,7 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive,
>      "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
>      "       [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
>      "       [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n"
> -    "       [,serial=s][,addr=A][,rerror=ignore|stop|report]\n"
> +    "       [,serial=s][,model=m][,addr=A][,rerror=ignore|stop|report]\n"
>      "       [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n"
>      "       [,readonly=on|off][,copy-on-read=on|off]\n"
>      "       [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n"
> @@ -570,6 +570,8 @@ the format.  Can be used to specify format=raw to avoid interpreting
>  an untrusted format header.
>  @item serial=@var{serial}
>  This option specifies the serial number to assign to the device.
> + at item model=@var{model}
> +This option specifies the model to use to create a flash device (if=mtd only).
>  @item addr=@var{addr}
>  Specify the controller's PCI address (if=virtio only).
>  @item werror=@var{action},rerror=@var{action}
> --
> 2.7.4
>
> _______________________________________________
> openbmc mailing list
> openbmc at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc


More information about the openbmc mailing list