ia64/xen-unstable

changeset 17285:491a3b62ae5b

minios: get VBD CD/removable/RO info

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Mar 20 17:48:02 2008 +0000 (2008-03-20)
parents f4a92f0db20f
children c8c8b5c5f6d7
files extras/mini-os/blkfront.c extras/mini-os/include/blkfront.h extras/mini-os/kernel.c tools/ioemu/block-vbd.c
line diff
     1.1 --- a/extras/mini-os/blkfront.c	Thu Mar 20 17:47:33 2008 +0000
     1.2 +++ b/extras/mini-os/blkfront.c	Thu Mar 20 17:48:02 2008 +0000
     1.3 @@ -70,7 +70,7 @@ void blkfront_handler(evtchn_port_t port
     1.4      wake_up(&blkfront_queue);
     1.5  }
     1.6  
     1.7 -struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned *sector_size, int *mode)
     1.8 +struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned *sector_size, int *mode, int *info)
     1.9  {
    1.10      xenbus_transaction_t xbt;
    1.11      char* err;
    1.12 @@ -176,6 +176,9 @@ done:
    1.13  
    1.14          xenbus_unwatch_path(XBT_NIL, path);
    1.15  
    1.16 +        snprintf(path, sizeof(path), "%s/info", dev->backend);
    1.17 +        *info = xenbus_read_integer(path);
    1.18 +
    1.19          snprintf(path, sizeof(path), "%s/sectors", dev->backend);
    1.20          // FIXME: read_integer returns an int, so disk size limited to 1TB for now
    1.21          *sectors = dev->sectors = xenbus_read_integer(path);
     2.1 --- a/extras/mini-os/include/blkfront.h	Thu Mar 20 17:47:33 2008 +0000
     2.2 +++ b/extras/mini-os/include/blkfront.h	Thu Mar 20 17:48:02 2008 +0000
     2.3 @@ -15,7 +15,7 @@ struct blkfront_aiocb
     2.4  
     2.5      void (*aio_cb)(struct blkfront_aiocb *aiocb, int ret);
     2.6  };
     2.7 -struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned *sector_size, int *mode);
     2.8 +struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned *sector_size, int *mode, int *info);
     2.9  #ifdef HAVE_LIBC
    2.10  int blkfront_open(struct blkfront_dev *dev);
    2.11  #endif
     3.1 --- a/extras/mini-os/kernel.c	Thu Mar 20 17:47:33 2008 +0000
     3.2 +++ b/extras/mini-os/kernel.c	Thu Mar 20 17:48:02 2008 +0000
     3.3 @@ -207,10 +207,19 @@ static void blk_write_sector(uint64_t se
     3.4  static void blkfront_thread(void *p)
     3.5  {
     3.6      time_t lasttime = 0;
     3.7 -    blk_dev = init_blkfront(NULL, &blk_sectors, &blk_sector_size, &blk_mode);
     3.8 +    int blk_info;
     3.9 +
    3.10 +    blk_dev = init_blkfront(NULL, &blk_sectors, &blk_sector_size, &blk_mode, &blk_info);
    3.11      if (!blk_dev)
    3.12          return;
    3.13  
    3.14 +    if (blk_info & VDISK_CDROM)
    3.15 +        printk("Block device is a CDROM\n");
    3.16 +    if (blk_info & VDISK_REMOVABLE)
    3.17 +        printk("Block device is removable\n");
    3.18 +    if (blk_info & VDISK_READONLY)
    3.19 +        printk("Block device is read-only\n");
    3.20 +
    3.21  #ifdef BLKTEST_WRITE
    3.22      if (blk_mode == O_RDWR) {
    3.23          blk_write_sector(0);
     4.1 --- a/tools/ioemu/block-vbd.c	Thu Mar 20 17:47:33 2008 +0000
     4.2 +++ b/tools/ioemu/block-vbd.c	Thu Mar 20 17:48:02 2008 +0000
     4.3 @@ -51,6 +51,7 @@ typedef struct BDRVVbdState {
     4.4      int fd;
     4.5      int type;
     4.6      int mode;
     4.7 +    int info;
     4.8      uint64_t sectors;
     4.9      unsigned sector_size;
    4.10      QEMU_LIST_ENTRY(BDRVVbdState) list;
    4.11 @@ -80,7 +81,7 @@ static int vbd_open(BlockDriverState *bs
    4.12      //handy to test posix access
    4.13      //return -EIO;
    4.14  
    4.15 -    s->dev = init_blkfront((char *) filename, &s->sectors, &s->sector_size, &s->mode);
    4.16 +    s->dev = init_blkfront((char *) filename, &s->sectors, &s->sector_size, &s->mode, &s->info);
    4.17  
    4.18      if (!s->dev)
    4.19  	return -EIO;