Patchwork [v2,2/3] vl: add func to check the machine type

login
register
mail settings
Submitter pingfan liu
Date Aug. 27, 2013, 8:10 a.m.
Message ID <1377591046-1944-2-git-send-email-pingfank@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/270058/
State New
Headers show

Comments

pingfan liu - Aug. 27, 2013, 8:10 a.m.
On different machines, the device can has different properties.
Export machine type's check interface to devices, so the device
can decide its behavior at runtime.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 include/hw/boards.h | 1 +
 vl.c                | 8 ++++++++
 2 files changed, 9 insertions(+)

Patch

diff --git a/include/hw/boards.h b/include/hw/boards.h
index fb7c6f1..020edfb 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -49,6 +49,7 @@  typedef struct QEMUMachine {
 } QEMUMachine;
 
 int qemu_register_machine(QEMUMachine *m);
+bool qemu_check_machine(const char *idstr);
 QEMUMachine *find_default_machine(void);
 
 extern QEMUMachine *current_machine;
diff --git a/vl.c b/vl.c
index f422a1c..1f37489 100644
--- a/vl.c
+++ b/vl.c
@@ -1667,6 +1667,14 @@  int qemu_register_machine(QEMUMachine *m)
     return 0;
 }
 
+bool qemu_check_machine(const char *idstr)
+{
+    size_t n = strlen(idstr);
+
+    assert(current_machine);
+    return !strncmp(current_machine->name, idstr, n);
+}
+
 static QEMUMachine *find_machine(const char *name)
 {
     QEMUMachine *m;