From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MH1kT-0007WQ-B9 for qemu-devel@nongnu.org; Wed, 17 Jun 2009 16:28:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MH1kO-0007Vg-Ez for qemu-devel@nongnu.org; Wed, 17 Jun 2009 16:28:44 -0400 Received: from [199.232.76.173] (port=36781 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MH1kN-0007VQ-Ul for qemu-devel@nongnu.org; Wed, 17 Jun 2009 16:28:40 -0400 Received: from mx2.redhat.com ([66.187.237.31]:52744) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MH1kN-0008Ir-8l for qemu-devel@nongnu.org; Wed, 17 Jun 2009 16:28:39 -0400 From: Eduardo Habkost Date: Wed, 17 Jun 2009 17:28:27 -0300 Message-Id: <1245270508-23315-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1245270508-23315-1-git-send-email-ehabkost@redhat.com> References: <1245270508-23315-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] Add a BlockDriverState parameter to bdrv_probe_device() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Cole Robinson Some probe functions may behave differently depending on the drive configuration. For example, if a block device is used as backend for a virtual cdrom device, the cdrom driver may be used. Changes not tested on Windows or FreeBSD, but I don't expect them to cause any problems. Signed-off-by: Eduardo Habkost --- block.c | 6 +++--- block/raw-posix.c | 8 ++++---- block/raw-win32.c | 2 +- block_int.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index aca5a6d..fa890a7 100644 --- a/block.c +++ b/block.c @@ -253,14 +253,14 @@ static BlockDriver *find_protocol(const char *filename) * Detect host devices. By convention, /dev/cdrom[N] is always * recognized as a host CDROM. */ -static BlockDriver *find_hdev_driver(const char *filename) +static BlockDriver *find_hdev_driver(BlockDriverState *bs, const char *filename) { int score_max = 0, score; BlockDriver *drv = NULL, *d; for (d = first_drv; d; d = d->next) { if (d->bdrv_probe_device) { - score = d->bdrv_probe_device(filename); + score = d->bdrv_probe_device(bs, filename); if (score > score_max) { score_max = score; drv = d; @@ -397,7 +397,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, if (flags & BDRV_O_FILE) { drv = find_protocol(filename); } else if (!drv) { - drv = find_hdev_driver(filename); + drv = find_hdev_driver(bs, filename); if (!drv) { drv = find_image_format(filename); } diff --git a/block/raw-posix.c b/block/raw-posix.c index fa1a394..bbcb6bc 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -955,7 +955,7 @@ kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFIndex ma #endif -static int hdev_probe_device(const char *filename) +static int hdev_probe_device(BlockDriverState *bs, const char *filename) { struct stat st; @@ -1201,7 +1201,7 @@ static int floppy_open(BlockDriverState *bs, const char *filename, int flags) return 0; } -static int floppy_probe_device(const char *filename) +static int floppy_probe_device(BlockDriverState *bs, const char *filename) { if (strstart(filename, "/dev/fd", NULL)) return 100; @@ -1285,7 +1285,7 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) return raw_open_common(bs, filename, flags, O_NONBLOCK); } -static int cdrom_probe_device(const char *filename) +static int cdrom_probe_device(BlockDriverState *bs, const char *filename) { if (strstart(filename, "/dev/cd", NULL)) return 100; @@ -1381,7 +1381,7 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) return 0; } -static int cdrom_probe_device(const char *filename) +static int cdrom_probe_device(BlockDriverState *bs, const char *filename) { if (strstart(filename, "/dev/cd", NULL) || strstart(filename, "/dev/acd", NULL)) diff --git a/block/raw-win32.c b/block/raw-win32.c index 72acad5..7c7e846 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -306,7 +306,7 @@ static int find_device_type(BlockDriverState *bs, const char *filename) } } -static int hdev_probe_device(const char *filename) +static int hdev_probe_device(BlockDriverState *bs, const char *filename) { if (strstart(filename, "/dev/cdrom", NULL)) return 100; diff --git a/block_int.h b/block_int.h index 830b7e9..b70186d 100644 --- a/block_int.h +++ b/block_int.h @@ -48,7 +48,7 @@ struct BlockDriver { const char *format_name; int instance_size; int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); - int (*bdrv_probe_device)(const char *filename); + int (*bdrv_probe_device)(BlockDriverState *bs, const char *filename); int (*bdrv_open)(BlockDriverState *bs, const char *filename, int flags); int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors); -- 1.6.3.rc4.29.g8146