From: Anthony Liguori <aliguori@linux.vnet.ibm.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Glauber Costa <glommer@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 1/2] machine: package all init arguments into a QemuOpts
Date: Fri, 04 Jun 2010 09:22:56 -0500 [thread overview]
Message-ID: <4C090C40.70402@linux.vnet.ibm.com> (raw)
In-Reply-To: <1275660676-11865-1-git-send-email-aliguori@us.ibm.com>
On 06/04/2010 09:11 AM, Anthony Liguori wrote:
> This patch creates a QemuOpts structure and stores all of the machine init
> arguments in that structure. It introduces a temporary list of QemuOptDescs
> in vl.c such that the current common options can be validated.
>
> The long term vision is that that list becomes a #define and that each machine
> can optionally provide it's own QemuOptDescs list using the common options as
> a base. This enables per-machine options.
>
> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>
> diff --git a/qemu-config.c b/qemu-config.c
> index 5a4e61b..3679a9f 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -336,6 +336,14 @@ QemuOptsList qemu_cpudef_opts = {
> },
> };
>
> +QemuOptsList qemu_machine_opts = {
> + .name = "machine",
> + .head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head),
> + .desc = {
> + { /* end of list */ }
> + },
> +};
> +
> static QemuOptsList *vm_config_groups[] = {
> &qemu_drive_opts,
> &qemu_chardev_opts,
> @@ -346,6 +354,7 @@ static QemuOptsList *vm_config_groups[] = {
> &qemu_global_opts,
> &qemu_mon_opts,
> &qemu_cpudef_opts,
> +&qemu_machine_opts,
> NULL,
> };
>
> diff --git a/qemu-config.h b/qemu-config.h
> index dca69d4..6f52188 100644
> --- a/qemu-config.h
> +++ b/qemu-config.h
> @@ -14,6 +14,7 @@ extern QemuOptsList qemu_rtc_opts;
> extern QemuOptsList qemu_global_opts;
> extern QemuOptsList qemu_mon_opts;
> extern QemuOptsList qemu_cpudef_opts;
> +extern QemuOptsList qemu_machine_opts;
>
> QemuOptsList *qemu_find_opts(const char *group);
> int qemu_set_option(const char *str);
> diff --git a/vl.c b/vl.c
> index 7121cd0..d362fc0 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2550,6 +2550,35 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
> return popt;
> }
>
> +/* TEMP: until we have proper -machine support */
> +static QemuOptDesc common_machine_opts[] = {
> + {
> + .name = "ram_size",
> + .type = QEMU_OPT_NUMBER,
> + },
> + {
> + .name = "kernel",
> + .type = QEMU_OPT_STRING,
> + },
> + {
> + .name = "cmdline",
> + .type = QEMU_OPT_STRING,
> + },
> + {
> + .name = "initrd",
> + .type = QEMU_OPT_STRING,
> + },
> + {
> + .name = "boot_device",
> + .type = QEMU_OPT_STRING,
> + },
> + {
> + .name = "cpu_model",
> + .type = QEMU_OPT_STRING,
> + },
> + { /* end of list */ },
> +};
> +
> int main(int argc, char **argv, char **envp)
> {
> const char *gdbstub_dev = NULL;
> @@ -3718,8 +3747,42 @@ int main(int argc, char **argv, char **envp)
> }
> qemu_add_globals();
>
> - machine->init(ram_size, boot_devices,
> - kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
> + opts = qemu_opts_create(&qemu_machine_opts, NULL, 0);
> + if (kernel_filename) {
> + qemu_opt_set(opts, "kernel", kernel_filename);
> + if (kernel_cmdline) {
> + qemu_opt_set(opts, "cmdline", kernel_cmdline);
> + }
> + if (initrd_filename) {
> + qemu_opt_set(opts, "initrd", initrd_filename);
> + }
> + }
> +
> + qemu_opt_set(opts, "boot_device", boot_devices);
> +
> + if (cpu_model) {
> + qemu_opt_set(opts, "cpu_model", cpu_model);
> + }
> +
> + if (ram_size) {
> + char buffer[64];
> + snprintf(buffer, sizeof(buffer),
> + "%" PRId64, ram_size);
> + qemu_opt_set(opts, "ram_size", buffer);
> + }
> +
> + if (qemu_opts_validate(opts, common_machine_opts)< 0) {
> + exit(1);
> + }
> +
> + machine->init(qemu_opt_get_number(opts, "ram_size"),
> + qemu_opt_get(opts, "boot_device"),
> + qemu_opt_get(opts, "kernel"),
> + qemu_opt_get(opts, "cmdline"),
> + qemu_opt_get(opts, "initrd"),
> + qemu_opt_get(opts, "cpu_model"));
>
This should be "cpu". I've updated and will hold off on a v2 for
additional comments.
Regards,
Anthony Liguori
> +
> + qemu_opts_del(opts);
>
> cpu_synchronize_all_post_init();
>
>
prev parent reply other threads:[~2010-06-04 14:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-04 14:11 [Qemu-devel] [PATCH 1/2] machine: package all init arguments into a QemuOpts Anthony Liguori
2010-06-04 14:11 ` [Qemu-devel] [PATCH 2/2] machine: pass all init options as a single QemuOpts Anthony Liguori
2010-06-04 14:22 ` Anthony Liguori [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C090C40.70402@linux.vnet.ibm.com \
--to=aliguori@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=glommer@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).