From patchwork Tue Nov 29 15:44:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 700626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tSpX55tmQz9t26 for ; Wed, 30 Nov 2016 03:14:13 +1100 (AEDT) Received: from localhost ([::1]:37848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBl2o-0005Um-Rk for incoming@patchwork.ozlabs.org; Tue, 29 Nov 2016 11:14:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBkdk-0000KS-IP for qemu-devel@nongnu.org; Tue, 29 Nov 2016 10:48:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBkde-0005oU-MY for qemu-devel@nongnu.org; Tue, 29 Nov 2016 10:48:16 -0500 Received: from 1.mo1.mail-out.ovh.net ([178.32.127.22]:32890) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cBkde-0005oA-G7 for qemu-devel@nongnu.org; Tue, 29 Nov 2016 10:48:10 -0500 Received: from player795.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id BEB2A1F94F for ; Tue, 29 Nov 2016 16:48:08 +0100 (CET) Received: from hermes.lab.toulouse-stg.fr.ibm.com (deibp9eh1--blueice2n7.emea.ibm.com [195.212.29.169]) (Authenticated sender: clg@kaod.org) by player795.ha.ovh.net (Postfix) with ESMTPSA id 2F7F51200B6; Tue, 29 Nov 2016 16:48:01 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: Peter Maydell Date: Tue, 29 Nov 2016 16:44:03 +0100 Message-Id: <1480434248-27138-26-git-send-email-clg@kaod.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480434248-27138-1-git-send-email-clg@kaod.org> References: <1480434248-27138-1-git-send-email-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 11761150430051404561 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelfedrfeejgddvtdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.127.22 Subject: [Qemu-devel] [PATCH for-2.9 25/30] block: add a model option for MTD devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Crosthwaite , Andrew Jeffery , Marcin Krzeminski , qemu-devel@nongnu.org, qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This could be used to define the flash model to use on some boards definitions. Signed-off-by: Cédric Le Goater Reviewed-by: Joel Stanley --- blockdev.c | 12 ++++++++++++ include/sysemu/blockdev.h | 1 + qemu-options.hx | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 245e1e1d177a..bcc99365b86c 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; @@ -1076,6 +1081,12 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) qdict_put(bs_opts, "rerror", qstring_from_str(rerror)); } + model = qemu_opt_get(legacy_opts, "model"); + if (model && type != IF_MTD) { + error_report("model is not supported by this bus type"); + goto fail; + } + /* Actual block device init: Functionality shared with blockdev-add */ blk = blockdev_init(filename, bs_opts, &local_err); bs_opts = NULL; @@ -1102,6 +1113,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. +@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}