From patchwork Tue Jul 5 15:24:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: clord@redhat.com X-Patchwork-Id: 644852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rkT8Q4FgNz9sBG for ; Wed, 6 Jul 2016 01:59:02 +1000 (AEST) Received: from localhost ([::1]:55993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSkW-0006pS-HD for incoming@patchwork.ozlabs.org; Tue, 05 Jul 2016 11:59:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSDh-0006KM-Gv for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKSDa-0000A8-JP for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:25:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSDU-00005s-M7; Tue, 05 Jul 2016 11:24:52 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50EA7C05B1DF; Tue, 5 Jul 2016 15:24:52 +0000 (UTC) Received: from dhcp-17-138.bos.redhat.com (dhcp-17-5.bos.redhat.com [10.18.17.5]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u65FOWuL006841; Tue, 5 Jul 2016 11:24:51 -0400 From: Colin Lord To: qemu-devel@nongnu.org Date: Tue, 5 Jul 2016 11:24:25 -0400 Message-Id: <1467732272-23368-26-git-send-email-clord@redhat.com> In-Reply-To: <1467732272-23368-1-git-send-email-clord@redhat.com> References: <1467732272-23368-1-git-send-email-clord@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 05 Jul 2016 15:24:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 25/32] blockdev: Separate raw probe from its driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Colin Lord , qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Completes the separation of the raw probe from the raw driver. The raw probe now returns the format in addition to the score, allowing correlation of the score and driver without the probe function being part of the driver itself. Signed-off-by: Colin Lord Reviewed-by: Max Reitz --- block.c | 1 + block/probe/raw.c | 8 ++++++-- block/raw_bsd.c | 1 - include/block/probe.h | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index fee9f8c..a3d983f 100644 --- a/block.c +++ b/block.c @@ -69,6 +69,7 @@ static BdrvProbeFunc *format_probes[] = { qcow_probe, qcow2_probe, bdrv_qed_probe, + raw_probe, }; static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states = diff --git a/block/probe/raw.c b/block/probe/raw.c index 22c6bcb..9923bb6 100644 --- a/block/probe/raw.c +++ b/block/probe/raw.c @@ -1,10 +1,14 @@ #include "qemu/osdep.h" #include "block/probe.h" -int raw_probe(const uint8_t *buf, int buf_size, const char *filename) +const char *raw_probe(const uint8_t *buf, int buf_size, const char *filename, + int *score) { + const char *format = "raw"; + assert(score); /* smallest possible positive score so that raw is used if and only if no * other block driver works */ - return 1; + *score = 1; + return format; } diff --git a/block/raw_bsd.c b/block/raw_bsd.c index 8f49637..4b24a36 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -231,7 +231,6 @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo) BlockDriver bdrv_raw = { .format_name = "raw", - .bdrv_probe = &raw_probe, .bdrv_reopen_prepare = &raw_reopen_prepare, .bdrv_open = &raw_open, .bdrv_close = &raw_close, diff --git a/include/block/probe.h b/include/block/probe.h index 63edd74..b49663d 100644 --- a/include/block/probe.h +++ b/include/block/probe.h @@ -1,7 +1,6 @@ #ifndef PROBE_H #define PROBE_H -int raw_probe(const uint8_t *buf, int buf_size, const char *filename); int vdi_probe(const uint8_t *buf, int buf_size, const char *filename); int vhdx_probe(const uint8_t *buf, int buf_size, const char *filename); int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename); @@ -22,5 +21,7 @@ const char *qcow2_probe(const uint8_t *buf, int buf_size, const char *filename, int *score); const char *bdrv_qed_probe(const uint8_t *buf, int buf_size, const char *filename, int *score); +const char *raw_probe(const uint8_t *buf, int buf_size, const char *filename, + int *score); #endif