From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Glauber Costa <glommer@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 11/22] machine: replace compat_props with opts_default
Date: Mon, 7 Jun 2010 18:51:59 -0500 [thread overview]
Message-ID: <1275954730-8196-12-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1275954730-8196-1-git-send-email-aliguori@us.ibm.com>
Right now, machine structs can hard code GlobalProperty lists of default qdev
global properties. This doesn't generalize well to a config file though because
there are three parameters: driver, property, value.
This patch moves this data to the generic machine opts default list. In the
process, it converts the form to driver.property=value. Now any option with
a '.' in the name is treated as a compat global property.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/hw/boards.h b/hw/boards.h
index 06b9f73..c7358ae 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -24,7 +24,6 @@ struct QEMUMachine {
no_cdrom:1,
no_sdcard:1;
int is_default;
- GlobalProperty *compat_props;
QemuOptDesc *opts_desc;
QemuOptValue *opts_default;
struct QEMUMachine *next;
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 0ad1145..28c1408 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -225,20 +225,15 @@ static QEMUMachine pc_machine_v0_12 = {
.name = "cpu",
.value = PC_DEFAULT_CPU_MODEL,
},
- { /* end of list */ }
- },
- .compat_props = (GlobalProperty[]) {
{
- .driver = "virtio-serial-pci",
- .property = "max_nr_ports",
- .value = stringify(1),
+ .name = "virtio-serial-pci.max_nr_ports",
+ .value = stringify(1),
},{
- .driver = "virtio-serial-pci",
- .property = "vectors",
- .value = stringify(0),
+ .name = "virtio-serial-pci.vectors",
+ .value = stringify(0),
},
{ /* end of list */ }
- }
+ },
};
static QEMUMachine pc_machine_v0_11 = {
@@ -260,33 +255,24 @@ static QEMUMachine pc_machine_v0_11 = {
.name = "cpu",
.value = PC_DEFAULT_CPU_MODEL,
},
- { /* end of list */ }
- },
- .compat_props = (GlobalProperty[]) {
{
- .driver = "virtio-blk-pci",
- .property = "vectors",
- .value = stringify(0),
+ .name = "virtio-blk-pci.vectors",
+ .value = stringify(0),
},{
- .driver = "virtio-serial-pci",
- .property = "max_nr_ports",
- .value = stringify(1),
+ .name = "virtio-serial-pci.max_nr_ports",
+ .value = stringify(1),
},{
- .driver = "virtio-serial-pci",
- .property = "vectors",
- .value = stringify(0),
+ .name = "virtio-serial-pci.vectors",
+ .value = stringify(0),
},{
- .driver = "ide-drive",
- .property = "ver",
- .value = "0.11",
+ .name = "ide-drive.ver",
+ .value = "0.11",
},{
- .driver = "scsi-disk",
- .property = "ver",
- .value = "0.11",
+ .name = "scsi-disk.ver",
+ .value = "0.11",
},{
- .driver = "PCI",
- .property = "rombar",
- .value = stringify(0),
+ .name = "PCI.rombar",
+ .value = stringify(0),
},
{ /* end of list */ }
}
@@ -311,45 +297,33 @@ static QEMUMachine pc_machine_v0_10 = {
.name = "cpu",
.value = PC_DEFAULT_CPU_MODEL,
},
- { /* end of list */ }
- },
- .compat_props = (GlobalProperty[]) {
{
- .driver = "virtio-blk-pci",
- .property = "class",
- .value = stringify(PCI_CLASS_STORAGE_OTHER),
+ .name = "virtio-blk-pci.class",
+ .value = stringify(PCI_CLASS_STORAGE_OTHER),
},{
- .driver = "virtio-serial-pci",
- .property = "class",
- .value = stringify(PCI_CLASS_DISPLAY_OTHER),
+ .name = "virtio-serial-pci.class",
+ .value = stringify(PCI_CLASS_DISPLAY_OTHER),
},{
- .driver = "virtio-serial-pci",
- .property = "max_nr_ports",
- .value = stringify(1),
+ .name = "virtio-serial-pci.max_nr_ports",
+ .value = stringify(1),
},{
- .driver = "virtio-serial-pci",
- .property = "vectors",
- .value = stringify(0),
+ .name = "virtio-serial-pci.vectors",
+ .value = stringify(0),
},{
- .driver = "virtio-net-pci",
- .property = "vectors",
- .value = stringify(0),
+ .name = "virtio-net-pci.vectors",
+ .value = stringify(0),
},{
- .driver = "virtio-blk-pci",
- .property = "vectors",
- .value = stringify(0),
+ .name = "virtio-blk-pci.vectors",
+ .value = stringify(0),
},{
- .driver = "ide-drive",
- .property = "ver",
- .value = "0.10",
+ .name = "ide-drive.ver",
+ .value = "0.10",
},{
- .driver = "scsi-disk",
- .property = "ver",
- .value = "0.10",
+ .name = "scsi-disk.ver",
+ .value = "0.10",
},{
- .driver = "PCI",
- .property = "rombar",
- .value = stringify(0),
+ .name = "PCI.rombar",
+ .value = stringify(0),
},
{ /* end of list */ }
},
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index ddbefb7..8ed4632 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -183,15 +183,13 @@ static QEMUMachine bamboo_machine_v0_12 = {
.name = "bamboo-0.12",
.desc = "bamboo",
.init = bamboo_init,
- .compat_props = (GlobalProperty[]) {
+ .opts_default = (QemuOptValue[]) {
{
- .driver = "virtio-serial-pci",
- .property = "max_nr_ports",
- .value = stringify(1),
+ .name = "virtio-serial-pci.max_nr_ports",
+ .value = stringify(1),
},{
- .driver = "virtio-serial-pci",
- .property = "vectors",
- .value = stringify(0),
+ .name = "virtio-serial-pci.vectors",
+ .value = stringify(0),
},
{ /* end of list */ }
},
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 9ffdba7..edd5ebd 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -661,7 +661,7 @@ void qdev_prop_set_defaults(DeviceState *dev, Property *props)
static QTAILQ_HEAD(, GlobalProperty) global_props = QTAILQ_HEAD_INITIALIZER(global_props);
-static void qdev_prop_register_global(GlobalProperty *prop)
+void qdev_prop_register_global(GlobalProperty *prop)
{
QTAILQ_INSERT_TAIL(&global_props, prop, next);
}
diff --git a/hw/qdev.h b/hw/qdev.h
index a44060e..9700b7a 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -277,6 +277,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
void qdev_prop_set_defaults(DeviceState *dev, Property *props);
+void qdev_prop_register_global(GlobalProperty *props);
void qdev_prop_register_global_list(GlobalProperty *props);
void qdev_prop_set_globals(DeviceState *dev);
diff --git a/vl.c b/vl.c
index a7f0a3d..0a31a45 100644
--- a/vl.c
+++ b/vl.c
@@ -2558,7 +2558,42 @@ static QemuOptDesc common_machine_opts[] = {
static int machine_combine_opt(const char *name, const char *value, void *opaque)
{
QemuOpts *base_opts = opaque;
- qemu_opt_set(base_opts, name, value);
+ char *ptr;
+
+ ptr = strchr(name, '.');
+ if (ptr) {
+ GlobalProperty *prop;
+ char *driver, *property;
+
+ prop = qemu_mallocz(sizeof(*prop));
+ driver = qemu_mallocz(strlen(name) + 1);
+ property = qemu_mallocz(strlen(name) + 1);
+
+ memcpy(driver, name, (ptr - name));
+ driver[(ptr - name)] = 0;
+ strcpy(property, ptr + 1);
+
+ prop->driver = driver;
+ prop->property = property;
+ prop->value = strdup(value);
+
+ qdev_prop_register_global(prop);
+ } else {
+ qemu_opt_set(base_opts, name, value);
+ }
+ return 0;
+}
+
+static int machine_find(QemuOpts *opts, void *opaque)
+{
+ QEMUMachine **machinep = opaque;
+ const char *driver;
+
+ driver = qemu_opt_get(opts, "driver");
+ if (driver) {
+ *machinep = find_machine(driver);
+ }
+
return 0;
}
@@ -3428,20 +3463,20 @@ int main(int argc, char **argv, char **envp)
data_dir = CONFIG_QEMU_SHAREDIR;
}
- /* Combine all -machine options into one option group */
- machine_opts = qemu_opts_create(&qemu_machine_opts, NULL, 0);
- qemu_opts_foreach(&qemu_machine_opts, machine_combine_opts, machine_opts, 0);
-
- if (!qemu_opt_get(machine_opts, "driver")) {
+ qemu_opts_foreach(&qemu_machine_opts, machine_find, &machine, 0);
+ if (!machine) {
machine = find_default_machine();
- } else {
- machine = find_machine(qemu_opt_get(machine_opts, "driver"));
}
if (machine->opts_default) {
- qemu_opts_set_defaults(machine_opts, machine->opts_default);
+ opts = qemu_opts_create(&qemu_machine_opts, NULL, 0);
+ qemu_opts_set_defaults(opts, machine->opts_default);
}
+ /* Combine all -machine options into one option group */
+ machine_opts = qemu_opts_create(&qemu_machine_opts, NULL, 0);
+ qemu_opts_foreach(&qemu_machine_opts, machine_combine_opts, machine_opts, 0);
+
if (machine->opts_desc) {
if (qemu_opts_validate(machine_opts, machine->opts_desc) < 0) {
exit(1);
@@ -3746,9 +3781,6 @@ int main(int argc, char **argv, char **envp)
exit (i == 1 ? 1 : 0);
}
- if (machine->compat_props) {
- qdev_prop_register_global_list(machine->compat_props);
- }
qemu_add_globals();
qemu_opt_set(machine_opts, "boot_device", boot_devices);
--
1.7.0.4
next prev parent reply other threads:[~2010-06-07 23:52 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-07 23:51 [Qemu-devel] [PATCH 0/22] Refactor machine support Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 01/22] QemuOpts: fix a bug in QemuOpts when setting an option twice Anthony Liguori
2010-06-08 7:51 ` Gerd Hoffmann
2010-06-08 10:32 ` [Qemu-devel] " Paolo Bonzini
2010-06-08 13:07 ` Anthony Liguori
2010-06-08 13:44 ` Gerd Hoffmann
2010-06-08 15:17 ` Anthony Liguori
2010-06-08 15:37 ` Gerd Hoffmann
2010-06-08 16:04 ` Anthony Liguori
2010-06-09 7:01 ` Gerd Hoffmann
2010-06-08 14:38 ` Paul Brook
2010-06-08 15:14 ` Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 02/22] QemuOpts: make qemu_opts_validate() store the description list for later use Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 03/22] QemuOpts: add function to set QemuOpts from defaults Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 04/22] machine: package all init arguments into a QemuOpts (v2) Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 05/22] machine: pass all init options as a single QemuOpts Anthony Liguori
2010-06-08 7:58 ` Gerd Hoffmann
2010-06-07 23:51 ` [Qemu-devel] [PATCH 06/22] Make -acpi-enable a machine specific option Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 07/22] machine: introduce -machine option Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 08/22] machine: implement -kernel/-append/-initrd options in term of -machine Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 09/22] machine: implement -m in terms " Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 10/22] machine: allow boards to specify default values and use it in isapc Anthony Liguori
2010-06-08 8:03 ` Gerd Hoffmann
2010-06-08 13:09 ` Anthony Liguori
2010-06-08 13:29 ` Gerd Hoffmann
2010-06-07 23:51 ` Anthony Liguori [this message]
2010-06-07 23:52 ` [Qemu-devel] [PATCH 12/22] machine: some sugary macros to simplify machine default options Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 13/22] machine: get rid of global default QEMUMachine members Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 14/22] machine: replace QEMUMachine.use_scsi with -machine default_drive Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 15/22] machine: make max_cpus a -machine option Anthony Liguori
2010-06-08 1:01 ` Paul Brook
2010-06-08 1:56 ` Anthony Liguori
2010-06-08 2:56 ` Paul Brook
2010-06-09 7:44 ` Jes Sorensen
2010-06-09 7:47 ` Jes Sorensen
2010-06-07 23:52 ` [Qemu-devel] [PATCH 16/22] machine: move default machine out of machine definitions Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 17/22] machine: kill machine->alias Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 18/22] machine: final conversion to pure QemuOpts Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 19/22] machine: introduce accel option to allow selection of kvm or tcg Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 20/22] machine: introduce machine core and split qemu_register_machine Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 21/22] machine: convert pc machines to split core vs machine API Anthony Liguori
2010-06-09 7:51 ` Jes Sorensen
2010-06-07 23:52 ` [Qemu-devel] [PATCH 22/22] machine: introduce -machine-def option to define a machine via config Anthony Liguori
2010-06-08 0:50 ` Anthony Liguori
2010-06-10 17:48 ` Daniel P. Berrange
2010-06-11 13:03 ` Daniel P. Berrange
2010-06-08 3:12 ` [Qemu-devel] [PATCH 0/22] Refactor machine support Paul Brook
2010-06-08 10:24 ` [Qemu-devel] " Paolo Bonzini
2010-06-08 14:30 ` Paul Brook
2010-06-08 15:28 ` Anthony Liguori
2010-06-08 15:36 ` Paul Brook
2010-06-08 15:58 ` Paolo Bonzini
2010-06-08 16:15 ` Anthony Liguori
2010-06-08 21:05 ` Alexander Graf
2010-06-08 21:16 ` Anthony Liguori
2010-06-08 17:23 ` Anthony Liguori
2010-06-09 2:11 ` Paul Brook
2010-06-09 13:55 ` Anthony Liguori
2010-06-09 14:30 ` Paul Brook
2010-06-09 20:47 ` Blue Swirl
2010-06-09 20:52 ` Anthony Liguori
2010-06-09 21:09 ` Blue Swirl
2010-06-09 22:26 ` Paul Brook
2010-06-08 14:04 ` [Qemu-devel] " Anthony Liguori
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=1275954730-8196-12-git-send-email-aliguori@us.ibm.com \
--to=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).