From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEENJ-00079Q-6J for qemu-devel@nongnu.org; Tue, 27 Aug 2013 04:11:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEENB-0000ry-Qs for qemu-devel@nongnu.org; Tue, 27 Aug 2013 04:11:41 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:47596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEENB-0000rs-KY for qemu-devel@nongnu.org; Tue, 27 Aug 2013 04:11:33 -0400 Received: by mail-pa0-f49.google.com with SMTP id ld10so4443078pab.8 for ; Tue, 27 Aug 2013 01:11:17 -0700 (PDT) From: Liu Ping Fan Date: Tue, 27 Aug 2013 16:10:45 +0800 Message-Id: <1377591046-1944-2-git-send-email-pingfank@linux.vnet.ibm.com> In-Reply-To: <1377591046-1944-1-git-send-email-pingfank@linux.vnet.ibm.com> References: <1377591046-1944-1-git-send-email-pingfank@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2 2/3] vl: add func to check the machine type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , Jan Kiszka 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 --- 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