aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-05-07 12:55:02 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-05-07 12:55:02 +0100
commit2d731dbd5e7173961cd76dc12c939e672cbca2bd (patch)
tree99009af4da151c5298d1769d744cea107da4e223 /hw/block
parentc8d8ef00a121ee7326c87a76cc9f49716ed68917 (diff)
downloadqemu-2d731dbd5e7173961cd76dc12c939e672cbca2bd.zip
qemu-2d731dbd5e7173961cd76dc12c939e672cbca2bd.tar.gz
qemu-2d731dbd5e7173961cd76dc12c939e672cbca2bd.tar.bz2
pflash_cfi01: New pflash_cfi01_legacy_drive()
Factored out of pc_system_firmware_init() so the next commit can reuse it in hw/arm/virt.c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20190416091348.26075-3-armbru@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/pflash_cfi01.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 16dfae1..333b736 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -44,9 +44,12 @@
#include "qapi/error.h"
#include "qemu/timer.h"
#include "qemu/bitops.h"
+#include "qemu/error-report.h"
#include "qemu/host-utils.h"
#include "qemu/log.h"
+#include "qemu/option.h"
#include "hw/sysbus.h"
+#include "sysemu/blockdev.h"
#include "sysemu/sysemu.h"
#include "trace.h"
@@ -968,6 +971,31 @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl)
return &fl->mem;
}
+/*
+ * Handle -drive if=pflash for machines that use properties.
+ * If @dinfo is null, do nothing.
+ * Else if @fl's property "drive" is already set, fatal error.
+ * Else set it to the BlockBackend with @dinfo.
+ */
+void pflash_cfi01_legacy_drive(PFlashCFI01 *fl, DriveInfo *dinfo)
+{
+ Location loc;
+
+ if (!dinfo) {
+ return;
+ }
+
+ loc_push_none(&loc);
+ qemu_opts_loc_restore(dinfo->opts);
+ if (fl->blk) {
+ error_report("clashes with -machine");
+ exit(1);
+ }
+ qdev_prop_set_drive(DEVICE(fl), "drive",
+ blk_by_legacy_dinfo(dinfo), &error_fatal);
+ loc_pop(&loc);
+}
+
static void postload_update_cb(void *opaque, int running, RunState state)
{
PFlashCFI01 *pfl = opaque;