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

[Xen-changelog] [xen-unstable] minios: get VBD CD/removable/RO info



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1206035282 0
# Node ID 491a3b62ae5b697485e8f6eaf1da1f9ba1ef1ab3
# Parent  f4a92f0db20fda98a633c149e3396c005a759a77
minios: get VBD CD/removable/RO info

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
---
 extras/mini-os/blkfront.c         |    5 ++++-
 extras/mini-os/include/blkfront.h |    2 +-
 extras/mini-os/kernel.c           |   11 ++++++++++-
 tools/ioemu/block-vbd.c           |    3 ++-
 4 files changed, 17 insertions(+), 4 deletions(-)

diff -r f4a92f0db20f -r 491a3b62ae5b extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Thu Mar 20 17:47:33 2008 +0000
+++ b/extras/mini-os/blkfront.c Thu Mar 20 17:48:02 2008 +0000
@@ -70,7 +70,7 @@ void blkfront_handler(evtchn_port_t port
     wake_up(&blkfront_queue);
 }
 
-struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned 
*sector_size, int *mode)
+struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned 
*sector_size, int *mode, int *info)
 {
     xenbus_transaction_t xbt;
     char* err;
@@ -175,6 +175,9 @@ done:
         xenbus_wait_for_value(path,"4");
 
         xenbus_unwatch_path(XBT_NIL, path);
+
+        snprintf(path, sizeof(path), "%s/info", dev->backend);
+        *info = xenbus_read_integer(path);
 
         snprintf(path, sizeof(path), "%s/sectors", dev->backend);
         // FIXME: read_integer returns an int, so disk size limited to 1TB for 
now
diff -r f4a92f0db20f -r 491a3b62ae5b extras/mini-os/include/blkfront.h
--- a/extras/mini-os/include/blkfront.h Thu Mar 20 17:47:33 2008 +0000
+++ b/extras/mini-os/include/blkfront.h Thu Mar 20 17:48:02 2008 +0000
@@ -15,7 +15,7 @@ struct blkfront_aiocb
 
     void (*aio_cb)(struct blkfront_aiocb *aiocb, int ret);
 };
-struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned 
*sector_size, int *mode);
+struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned 
*sector_size, int *mode, int *info);
 #ifdef HAVE_LIBC
 int blkfront_open(struct blkfront_dev *dev);
 #endif
diff -r f4a92f0db20f -r 491a3b62ae5b extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c   Thu Mar 20 17:47:33 2008 +0000
+++ b/extras/mini-os/kernel.c   Thu Mar 20 17:48:02 2008 +0000
@@ -207,9 +207,18 @@ static void blkfront_thread(void *p)
 static void blkfront_thread(void *p)
 {
     time_t lasttime = 0;
-    blk_dev = init_blkfront(NULL, &blk_sectors, &blk_sector_size, &blk_mode);
+    int blk_info;
+
+    blk_dev = init_blkfront(NULL, &blk_sectors, &blk_sector_size, &blk_mode, 
&blk_info);
     if (!blk_dev)
         return;
+
+    if (blk_info & VDISK_CDROM)
+        printk("Block device is a CDROM\n");
+    if (blk_info & VDISK_REMOVABLE)
+        printk("Block device is removable\n");
+    if (blk_info & VDISK_READONLY)
+        printk("Block device is read-only\n");
 
 #ifdef BLKTEST_WRITE
     if (blk_mode == O_RDWR) {
diff -r f4a92f0db20f -r 491a3b62ae5b tools/ioemu/block-vbd.c
--- a/tools/ioemu/block-vbd.c   Thu Mar 20 17:47:33 2008 +0000
+++ b/tools/ioemu/block-vbd.c   Thu Mar 20 17:48:02 2008 +0000
@@ -51,6 +51,7 @@ typedef struct BDRVVbdState {
     int fd;
     int type;
     int mode;
+    int info;
     uint64_t sectors;
     unsigned sector_size;
     QEMU_LIST_ENTRY(BDRVVbdState) list;
@@ -80,7 +81,7 @@ static int vbd_open(BlockDriverState *bs
     //handy to test posix access
     //return -EIO;
 
-    s->dev = init_blkfront((char *) filename, &s->sectors, &s->sector_size, 
&s->mode);
+    s->dev = init_blkfront((char *) filename, &s->sectors, &s->sector_size, 
&s->mode, &s->info);
 
     if (!s->dev)
        return -EIO;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.