From patchwork Tue Aug 27 08:10:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pingfan liu X-Patchwork-Id: 270058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DB6B82C00BC for ; Tue, 27 Aug 2013 18:12:13 +1000 (EST) Received: from localhost ([::1]:54735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEENn-0007JA-Ty for incoming@patchwork.ozlabs.org; Tue, 27 Aug 2013 04:12:11 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ir2FlnV2abL+94O/t4YOhgyB6yqWQuvUMXoWSx4r2Bc=; b=IUBdnPxQH3dfINZN7NLW3zdZ7TV28OTokcjhM+5VPv68mtlIbScr4XnuJvNbIKRp8d YhOCjZLxBayECvWgOTI3J8dfEXUVcDanPP1qk+jHhBtEoDo2uXyc5qcv+8yRdAUSCIyV pIW6Wl3u1hCSmR1zzvapAwRzX4qHWU0oxImmnA7B/gkf7RyccVkWCZFXRK93k7/IMI9J eAgzpp0sEVmiDrVCZbRG5jVnSnMztV+sVXSFRzcx/OoyFI3ykv1Z9Pyn2Xe5PT5uSJbl CCS9MnsdOeHtkN1s5/jfn82vyHVfriy12vmw+CYPXa7NTWtCw24UkEybS3ARniGxu/oI kXtg== X-Received: by 10.66.178.143 with SMTP id cy15mr19224486pac.105.1377591077914; Tue, 27 Aug 2013 01:11:17 -0700 (PDT) Received: from localhost ([202.108.130.138]) by mx.google.com with ESMTPSA id iu7sm22987443pbc.45.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 27 Aug 2013 01:11:16 -0700 (PDT) From: Liu Ping Fan To: qemu-devel@nongnu.org Date: Tue, 27 Aug 2013 16:10:45 +0800 Message-Id: <1377591046-1944-2-git-send-email-pingfank@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.1.4 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> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.220.49 Cc: Paolo Bonzini , Anthony Liguori , Jan Kiszka Subject: [Qemu-devel] [PATCH v2 2/3] vl: add func to check the machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;