From: Eduardo Habkost <ehabkost@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org, Cole Robinson <crobinso@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] Add a BlockDriverState parameter to bdrv_probe_device()
Date: Wed, 17 Jun 2009 17:28:27 -0300 [thread overview]
Message-ID: <1245270508-23315-2-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1245270508-23315-1-git-send-email-ehabkost@redhat.com>
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 <ehabkost@redhat.com>
---
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
next prev parent reply other threads:[~2009-06-17 20:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-17 20:28 [Qemu-devel] [PATCH 0/2] Guess host device type from guest device type for block devices Eduardo Habkost
2009-06-17 20:28 ` Eduardo Habkost [this message]
2009-06-17 20:28 ` [Qemu-devel] [PATCH 2/2] Guess host device type from requested guest device type Eduardo Habkost
2009-06-17 22:17 ` [Qemu-devel] Re: [PATCH 0/2] Guess host device type from guest device type for block devices Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1245270508-23315-2-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=crobinso@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).