[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 2/3] vl: add func to check the machine type
From: |
Liu Ping Fan |
Subject: |
[Qemu-devel] [PATCH v2 2/3] vl: add func to check the machine type |
Date: |
Tue, 27 Aug 2013 16:10:45 +0800 |
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 <address@hidden>
---
include/hw/boards.h | 1 +
vl.c | 8 ++++++++
2 files changed, 9 insertions(+)
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;
--
1.8.1.4