diff options
author | Peter Maydell | 2015-06-10 17:52:34 +0200 |
---|---|---|
committer | Peter Maydell | 2015-06-10 17:52:35 +0200 |
commit | 3974c9d8ccfccbd81edc9df271fcae7082f3921d (patch) | |
tree | 220d33e6b92aa3b3e68de39a80ed277a820c3e92 /vl.c | |
parent | Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150609.0' i... (diff) | |
parent | bios-tables-test: handle false-positive smbios signature matches (diff) | |
download | qemu-3974c9d8ccfccbd81edc9df271fcae7082f3921d.tar.gz qemu-3974c9d8ccfccbd81edc9df271fcae7082f3921d.tar.xz qemu-3974c9d8ccfccbd81edc9df271fcae7082f3921d.zip |
Merge remote-tracking branch 'remotes/kraxel/tags/pull-fw_cfg-20150610-1' into staging
fw_cfg: drop write support, qemu cmdline support, bugfixes.
bios-tables-test: fix smbios test.
# gpg: Signature made Wed Jun 10 07:29:53 2015 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg: aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
* remotes/kraxel/tags/pull-fw_cfg-20150610-1:
bios-tables-test: handle false-positive smbios signature matches
fw_cfg: insert fw_cfg file blobs via qemu cmdline
fw_cfg: prohibit insertion of duplicate fw_cfg file names
fw_cfg: prevent selector key conflict
fw_cfg: remove support for guest-side data writes
fw_cfg: fix FW_CFG_BOOT_DEVICE update on ppc and sparc
fw_cfg: add fw_cfg_modify_i16 (update) method
QemuOpts: increase number of vm_config_groups
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 63 |
1 files changed, 63 insertions, 0 deletions
@@ -492,6 +492,25 @@ static QemuOptsList qemu_semihosting_config_opts = { }, }; +static QemuOptsList qemu_fw_cfg_opts = { + .name = "fw_cfg", + .implied_opt_name = "name", + .head = QTAILQ_HEAD_INITIALIZER(qemu_fw_cfg_opts.head), + .desc = { + { + .name = "name", + .type = QEMU_OPT_STRING, + .help = "Sets the fw_cfg name of the blob to be inserted", + }, { + .name = "file", + .type = QEMU_OPT_STRING, + .help = "Sets the name of the file from which\n" + "the fw_cfg blob will be loaded", + }, + { /* end of list */ } + }, +}; + /** * Get machine options * @@ -2127,6 +2146,38 @@ char *qemu_find_file(int type, const char *name) return NULL; } +static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp) +{ + gchar *buf; + size_t size; + const char *name, *file; + + if (opaque == NULL) { + error_report("fw_cfg device not available"); + return -1; + } + name = qemu_opt_get(opts, "name"); + file = qemu_opt_get(opts, "file"); + if (name == NULL || *name == '\0' || file == NULL || *file == '\0') { + error_report("invalid argument value"); + return -1; + } + if (strlen(name) > FW_CFG_MAX_FILE_PATH - 1) { + error_report("name too long (max. %d char)", FW_CFG_MAX_FILE_PATH - 1); + return -1; + } + if (strncmp(name, "opt/", 4) != 0) { + error_report("WARNING: externally provided fw_cfg item names " + "should be prefixed with \"opt/\"!"); + } + if (!g_file_get_contents(file, &buf, &size, NULL)) { + error_report("can't load %s", file); + return -1; + } + fw_cfg_add_file((FWCfgState *)opaque, name, buf, size); + return 0; +} + static int device_help_func(void *opaque, QemuOpts *opts, Error **errp) { return qdev_device_help(opts); @@ -2822,6 +2873,7 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_numa_opts); qemu_add_opts(&qemu_icount_opts); qemu_add_opts(&qemu_semihosting_config_opts); + qemu_add_opts(&qemu_fw_cfg_opts); runstate_init(); @@ -3438,6 +3490,12 @@ int main(int argc, char **argv, char **envp) } do_smbios_option(opts); break; + case QEMU_OPTION_fwcfg: + opts = qemu_opts_parse(qemu_find_opts("fw_cfg"), optarg, 1); + if (opts == NULL) { + exit(1); + } + break; case QEMU_OPTION_enable_kvm: olist = qemu_find_opts("machine"); qemu_opts_parse(olist, "accel=kvm", 0); @@ -4274,6 +4332,11 @@ int main(int argc, char **argv, char **envp) numa_post_machine_init(); + if (qemu_opts_foreach(qemu_find_opts("fw_cfg"), + parse_fw_cfg, fw_cfg_find(), NULL) != 0) { + exit(1); + } + /* init USB devices */ if (usb_enabled()) { if (foreach_device_config(DEV_USB, usb_parse) < 0) |