qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] Add a BlockDriverState parameter to bdrv_probe_


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH 1/2] Add a BlockDriverState parameter to bdrv_probe_device()
Date: Wed, 17 Jun 2009 17:28:27 -0300

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 <address@hidden>
---
 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]