* [Qemu-devel] [PATCH v2 0/3]: Improve machine type functions
@ 2012-02-24 19:36 Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 1/3] boards: qemu_register_machine(): return void Luiz Capitulino
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Luiz Capitulino @ 2012-02-24 19:36 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, aliguori, afaerber
Actually, the major change is to move the machine type functions to boards.c.
But I wanted to keep the same subject as v1.
v2:
o Drop function renames
o Drop machine type list conversion to QTAILQ
o Rebase against latest master
o Other minor changes
Makefile.target | 1 +
hw/boards.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/boards.h | 3 +-
vl.c | 63 ---------------------------------------
4 files changed, 91 insertions(+), 64 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1/3] boards: qemu_register_machine(): return void
2012-02-24 19:36 [Qemu-devel] [PATCH v2 0/3]: Improve machine type functions Luiz Capitulino
@ 2012-02-24 19:36 ` Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 2/3] boards: introduce machine_print_all() Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 3/3] boards: move all machine type functions to boards.c Luiz Capitulino
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Capitulino @ 2012-02-24 19:36 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, aliguori, afaerber
It never fails.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
---
hw/boards.h | 2 +-
vl.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/boards.h b/hw/boards.h
index 667177d..7a9899f 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -31,7 +31,7 @@ typedef struct QEMUMachine {
struct QEMUMachine *next;
} QEMUMachine;
-int qemu_register_machine(QEMUMachine *m);
+void qemu_register_machine(QEMUMachine *m);
QEMUMachine *find_default_machine(void);
extern QEMUMachine *current_machine;
diff --git a/vl.c b/vl.c
index cd77852..728eb36 100644
--- a/vl.c
+++ b/vl.c
@@ -1163,7 +1163,7 @@ void pcmcia_info(Monitor *mon)
static QEMUMachine *first_machine = NULL;
QEMUMachine *current_machine = NULL;
-int qemu_register_machine(QEMUMachine *m)
+void qemu_register_machine(QEMUMachine *m)
{
QEMUMachine **pm;
pm = &first_machine;
@@ -1171,7 +1171,6 @@ int qemu_register_machine(QEMUMachine *m)
pm = &(*pm)->next;
m->next = NULL;
*pm = m;
- return 0;
}
static QEMUMachine *find_machine(const char *name)
--
1.7.9.111.gf3fb0.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/3] boards: introduce machine_print_all()
2012-02-24 19:36 [Qemu-devel] [PATCH v2 0/3]: Improve machine type functions Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 1/3] boards: qemu_register_machine(): return void Luiz Capitulino
@ 2012-02-24 19:36 ` Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 3/3] boards: move all machine type functions to boards.c Luiz Capitulino
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Capitulino @ 2012-02-24 19:36 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, aliguori, afaerber
It prints all registered machine types.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
vl.c | 25 ++++++++++++++++---------
1 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/vl.c b/vl.c
index 728eb36..ced7068 100644
--- a/vl.c
+++ b/vl.c
@@ -1198,6 +1198,20 @@ QEMUMachine *find_default_machine(void)
return NULL;
}
+static void machine_print_all(void)
+{
+ QEMUMachine *m;
+
+ printf("Supported machines are:\n");
+ for (m = first_machine; m != NULL; m = m->next) {
+ if (m->alias) {
+ printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
+ }
+ printf("%-20s %s%s\n", m->name, m->desc,
+ m->is_default ? " (default)" : "");
+ }
+}
+
/***********************************************************/
/* main execution loop */
@@ -1992,7 +2006,7 @@ static int debugcon_parse(const char *devname)
static QEMUMachine *machine_parse(const char *name)
{
- QEMUMachine *m, *machine = NULL;
+ QEMUMachine *machine = NULL;
if (name) {
machine = find_machine(name);
@@ -2000,14 +2014,7 @@ static QEMUMachine *machine_parse(const char *name)
if (machine) {
return machine;
}
- printf("Supported machines are:\n");
- for (m = first_machine; m != NULL; m = m->next) {
- if (m->alias) {
- printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
- }
- printf("%-20s %s%s\n", m->name, m->desc,
- m->is_default ? " (default)" : "");
- }
+ machine_print_all();
exit(!name || *name != '?');
}
--
1.7.9.111.gf3fb0.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 3/3] boards: move all machine type functions to boards.c
2012-02-24 19:36 [Qemu-devel] [PATCH v2 0/3]: Improve machine type functions Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 1/3] boards: qemu_register_machine(): return void Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 2/3] boards: introduce machine_print_all() Luiz Capitulino
@ 2012-02-24 19:36 ` Luiz Capitulino
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Capitulino @ 2012-02-24 19:36 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, aliguori, afaerber
The license text is the same as used in vl.c. Also note that it's
necessary to make machine_parse() public.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
Makefile.target | 1 +
hw/boards.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/boards.h | 1 +
vl.c | 69 -------------------------------------------
4 files changed, 90 insertions(+), 69 deletions(-)
create mode 100644 hw/boards.c
diff --git a/Makefile.target b/Makefile.target
index 68a5641..20ba1e7 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -196,6 +196,7 @@ endif #CONFIG_BSD_USER
ifdef CONFIG_SOFTMMU
obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o
+obj-y += boards.o
# virtio has to be here due to weird dependency between PCI and virtio-net.
# need to fix this properly
obj-$(CONFIG_NO_PCI) += pci-stub.o
diff --git a/hw/boards.c b/hw/boards.c
new file mode 100644
index 0000000..2692930
--- /dev/null
+++ b/hw/boards.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw/boards.h"
+
+static QEMUMachine *first_machine = NULL;
+QEMUMachine *current_machine = NULL;
+
+void qemu_register_machine(QEMUMachine *m)
+{
+ QEMUMachine **pm;
+ pm = &first_machine;
+ while (*pm != NULL)
+ pm = &(*pm)->next;
+ m->next = NULL;
+ *pm = m;
+}
+
+static QEMUMachine *find_machine(const char *name)
+{
+ QEMUMachine *m;
+
+ for(m = first_machine; m != NULL; m = m->next) {
+ if (!strcmp(m->name, name))
+ return m;
+ if (m->alias && !strcmp(m->alias, name))
+ return m;
+ }
+ return NULL;
+}
+
+QEMUMachine *find_default_machine(void)
+{
+ QEMUMachine *m;
+
+ for(m = first_machine; m != NULL; m = m->next) {
+ if (m->is_default) {
+ return m;
+ }
+ }
+ return NULL;
+}
+
+static void machine_print_all(void)
+{
+ QEMUMachine *m;
+
+ printf("Supported machines are:\n");
+ for (m = first_machine; m != NULL; m = m->next) {
+ if (m->alias) {
+ printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
+ }
+ printf("%-20s %s%s\n", m->name, m->desc,
+ m->is_default ? " (default)" : "");
+ }
+}
+
+QEMUMachine *machine_parse(const char *name)
+{
+ QEMUMachine *machine = NULL;
+
+ if (name) {
+ machine = find_machine(name);
+ }
+ if (machine) {
+ return machine;
+ }
+ machine_print_all();
+ exit(!name || *name != '?');
+}
diff --git a/hw/boards.h b/hw/boards.h
index 7a9899f..a9b0c8c 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -33,6 +33,7 @@ typedef struct QEMUMachine {
void qemu_register_machine(QEMUMachine *m);
QEMUMachine *find_default_machine(void);
+QEMUMachine *machine_parse(const char *name);
extern QEMUMachine *current_machine;
diff --git a/vl.c b/vl.c
index ced7068..949cfd8 100644
--- a/vl.c
+++ b/vl.c
@@ -1158,61 +1158,6 @@ void pcmcia_info(Monitor *mon)
}
/***********************************************************/
-/* machine registration */
-
-static QEMUMachine *first_machine = NULL;
-QEMUMachine *current_machine = NULL;
-
-void qemu_register_machine(QEMUMachine *m)
-{
- QEMUMachine **pm;
- pm = &first_machine;
- while (*pm != NULL)
- pm = &(*pm)->next;
- m->next = NULL;
- *pm = m;
-}
-
-static QEMUMachine *find_machine(const char *name)
-{
- QEMUMachine *m;
-
- for(m = first_machine; m != NULL; m = m->next) {
- if (!strcmp(m->name, name))
- return m;
- if (m->alias && !strcmp(m->alias, name))
- return m;
- }
- return NULL;
-}
-
-QEMUMachine *find_default_machine(void)
-{
- QEMUMachine *m;
-
- for(m = first_machine; m != NULL; m = m->next) {
- if (m->is_default) {
- return m;
- }
- }
- return NULL;
-}
-
-static void machine_print_all(void)
-{
- QEMUMachine *m;
-
- printf("Supported machines are:\n");
- for (m = first_machine; m != NULL; m = m->next) {
- if (m->alias) {
- printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
- }
- printf("%-20s %s%s\n", m->name, m->desc,
- m->is_default ? " (default)" : "");
- }
-}
-
-/***********************************************************/
/* main execution loop */
static void gui_update(void *opaque)
@@ -2004,20 +1949,6 @@ static int debugcon_parse(const char *devname)
return 0;
}
-static QEMUMachine *machine_parse(const char *name)
-{
- QEMUMachine *machine = NULL;
-
- if (name) {
- machine = find_machine(name);
- }
- if (machine) {
- return machine;
- }
- machine_print_all();
- exit(!name || *name != '?');
-}
-
static int tcg_init(void)
{
tcg_exec_init(tcg_tb_size * 1024 * 1024);
--
1.7.9.111.gf3fb0.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-24 19:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-24 19:36 [Qemu-devel] [PATCH v2 0/3]: Improve machine type functions Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 1/3] boards: qemu_register_machine(): return void Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 2/3] boards: introduce machine_print_all() Luiz Capitulino
2012-02-24 19:36 ` [Qemu-devel] [PATCH 3/3] boards: move all machine type functions to boards.c Luiz Capitulino
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).