ia64/xen-unstable

changeset 577:cc54519f9a1a

bitkeeper revision 1.320 (3f0c3487S9CwVDQRe6TtSjZepJCw3w)

Half of a way of getting /proc/dom0/vhd to return something
sensible.
author sos22@labyrinth.cl.cam.ac.uk
date Wed Jul 09 15:28:07 2003 +0000 (2003-07-09)
parents 17bca2096d98
children 3539152a9fab
files xen/drivers/block/xen_block.c xen/drivers/block/xen_segment.c xen/include/hypervisor-ifs/block.h xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_block.c xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_segment_proc.c
line diff
     1.1 --- a/xen/drivers/block/xen_block.c	Wed Jul 09 14:00:09 2003 +0000
     1.2 +++ b/xen/drivers/block/xen_block.c	Wed Jul 09 15:28:07 2003 +0000
     1.3 @@ -102,6 +102,7 @@ static int do_block_io_op_domain(struct 
     1.4  static void dispatch_rw_block_io(struct task_struct *p, int index);
     1.5  static void dispatch_probe_blk(struct task_struct *p, int index);
     1.6  static void dispatch_probe_seg(struct task_struct *p, int index);
     1.7 +static void dispatch_probe_seg_all(struct task_struct *p, int index);
     1.8  static void dispatch_debug_block_io(struct task_struct *p, int index);
     1.9  static void dispatch_create_segment(struct task_struct *p, int index);
    1.10  static void dispatch_delete_segment(struct task_struct *p, int index);
    1.11 @@ -387,6 +388,10 @@ static int do_block_io_op_domain(struct 
    1.12  	    dispatch_probe_seg(p, i);
    1.13  	    break;
    1.14  
    1.15 +	case XEN_BLOCK_PROBE_SEG_ALL:
    1.16 +	    dispatch_probe_seg_all(p, i);
    1.17 +	    break;
    1.18 +
    1.19  	case XEN_BLOCK_DEBUG:
    1.20  	    dispatch_debug_block_io(p, i);
    1.21  	    break;
    1.22 @@ -566,7 +571,10 @@ static void dispatch_probe_blk(struct ta
    1.23      make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_PROBE_BLK, rc);
    1.24  }
    1.25  
    1.26 -static void dispatch_probe_seg(struct task_struct *p, int index)
    1.27 +static void dispatch_probe_seg_common(struct task_struct *p,
    1.28 +				      struct task_struct *target,
    1.29 +				      int type,
    1.30 +				      int index)
    1.31  {
    1.32      extern void xen_segment_probe(struct task_struct *, xen_disk_info_t *);
    1.33  
    1.34 @@ -589,12 +597,22 @@ static void dispatch_probe_seg(struct ta
    1.35      spin_unlock_irqrestore(&p->page_lock, flags);
    1.36  
    1.37      xdi = phys_to_virt(buffer);
    1.38 -    xen_segment_probe(p, xdi);
    1.39 +    xen_segment_probe(target, xdi);
    1.40  
    1.41      unlock_buffer(p, buffer, sizeof(xen_disk_info_t), 1);
    1.42  
    1.43   out:
    1.44 -    make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_PROBE_SEG, rc);
    1.45 +    make_response(p, blk_ring->ring[index].req.id, type, rc);
    1.46 +}
    1.47 +
    1.48 +static void dispatch_probe_seg(struct task_struct *p, int index)
    1.49 +{
    1.50 +    dispatch_probe_seg_common(p, p, XEN_BLOCK_PROBE_SEG, index);
    1.51 +}
    1.52 +
    1.53 +static void dispatch_probe_seg_all(struct task_struct *p, int index)
    1.54 +{
    1.55 +    dispatch_probe_seg_common(p, NULL, XEN_BLOCK_PROBE_SEG_ALL, index);
    1.56  }
    1.57  
    1.58  static void dispatch_rw_block_io(struct task_struct *p, int index)
     2.1 --- a/xen/drivers/block/xen_segment.c	Wed Jul 09 14:00:09 2003 +0000
     2.2 +++ b/xen/drivers/block/xen_segment.c	Wed Jul 09 15:28:07 2003 +0000
     2.3 @@ -162,7 +162,7 @@ void xen_segment_probe(struct task_struc
     2.4      for ( loop = 0; loop < XEN_MAX_SEGMENTS; loop++ )
     2.5      {
     2.6          if ( (xsegments[loop].mode == XEN_SEGMENT_UNUSED) ||
     2.7 -             (xsegments[loop].domain != p->domain) )
     2.8 +             (p && xsegments[loop].domain != p->domain) )
     2.9              continue;
    2.10  
    2.11          device = MK_VIRTUAL_XENDEV(xsegments[loop].segment_number);
     3.1 --- a/xen/include/hypervisor-ifs/block.h	Wed Jul 09 14:00:09 2003 +0000
     3.2 +++ b/xen/include/hypervisor-ifs/block.h	Wed Jul 09 15:28:07 2003 +0000
     3.3 @@ -50,6 +50,8 @@
     3.4  #define XEN_BLOCK_PHYSDEV_GRANT 10 /* grant access to range of disk blocks */
     3.5  #define XEN_BLOCK_PHYSDEV_PROBE 11 /* probe for a domain's physdev
     3.6  				      accesses */
     3.7 +#define XEN_BLOCK_PROBE_SEG_ALL 12 /* prove for every domain's segments,
     3.8 +				      not just ours. */
     3.9  
    3.10  /* NB. Ring size must be small enough for sizeof(blk_ring_t) <= PAGE_SIZE. */
    3.11  #define BLK_RING_SIZE        64
     4.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_block.c	Wed Jul 09 14:00:09 2003 +0000
     4.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_block.c	Wed Jul 09 15:28:07 2003 +0000
     4.3 @@ -311,6 +311,7 @@ static int hypervisor_request(unsigned l
     4.4      case XEN_BLOCK_PHYSDEV_PROBE:
     4.5      case XEN_BLOCK_PROBE_BLK:
     4.6      case XEN_BLOCK_PROBE_SEG:
     4.7 +    case XEN_BLOCK_PROBE_SEG_ALL:
     4.8          if ( RING_FULL ) return 1;
     4.9  	phys_device = (kdev_t) 0;
    4.10  	sector_number = 0;
    4.11 @@ -479,6 +480,7 @@ static void xlblk_response_int(int irq, 
    4.12          case XEN_BLOCK_SEG_CREATE:
    4.13          case XEN_BLOCK_SEG_DELETE:
    4.14          case XEN_BLOCK_PROBE_SEG:
    4.15 +	case XEN_BLOCK_PROBE_SEG_ALL:
    4.16          case XEN_BLOCK_PROBE_BLK:
    4.17  	case XEN_BLOCK_PHYSDEV_GRANT:
    4.18  	case XEN_BLOCK_PHYSDEV_PROBE:
     5.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_segment_proc.c	Wed Jul 09 14:00:09 2003 +0000
     5.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/block/xl_segment_proc.c	Wed Jul 09 15:28:07 2003 +0000
     5.3 @@ -7,17 +7,70 @@
     5.4  #include "xl_block.h"
     5.5  #include <linux/proc_fs.h>
     5.6  #include <linux/delay.h>
     5.7 +#include <linux/seq_file.h>
     5.8  
     5.9  static struct proc_dir_entry *vhd;
    5.10  
    5.11  extern unsigned short xldev_to_physdev(kdev_t xldev);
    5.12  
    5.13 -static int proc_read_vhd(char *page, char **start, off_t off,
    5.14 -			 int count, int *eof, void *data)
    5.15 +static void *proc_vhd_next(struct seq_file *s, void *v, loff_t *pos)
    5.16 +{
    5.17 +    xen_disk_info_t *data;
    5.18 +
    5.19 +    if ( pos != NULL )
    5.20 +        ++(*pos); 
    5.21 +
    5.22 +    data = v;
    5.23 +    return data->count-- ? NULL : v;
    5.24 +}
    5.25 +
    5.26 +static void *proc_vhd_start(struct seq_file *s, loff_t *ppos)
    5.27  {
    5.28 +    loff_t pos = *ppos;
    5.29 +    xen_disk_info_t *data;
    5.30 +
    5.31 +    data = kmalloc(sizeof(*data), GFP_KERNEL);
    5.32 +    xenolinux_control_msg(XEN_BLOCK_PROBE_SEG_ALL, (char *)data, sizeof(*data));
    5.33 +    data->count -= pos;
    5.34 +
    5.35 +    if (data->count > 0)
    5.36 +	return data;
    5.37 +
    5.38 +    kfree(data);
    5.39 +    return NULL;
    5.40 +}
    5.41 +
    5.42 +static int proc_vhd_show(struct seq_file *s, void *v)
    5.43 +{ 
    5.44 +    xen_disk_info_t *data = v;
    5.45 +
    5.46 +    seq_printf (s,
    5.47 +		"%4x %4x %lx\n",
    5.48 +		data->disks[data->count - 1].device,
    5.49 +		data->disks[data->count - 1].type,
    5.50 +		data->disks[data->count - 1].capacity);
    5.51 +
    5.52      return 0;
    5.53  }
    5.54  
    5.55 +static void proc_vhd_stop(struct seq_file *s, void *v)
    5.56 +{
    5.57 +  kfree(v);
    5.58 +}
    5.59 +
    5.60 +static struct seq_operations proc_vhd_op = {
    5.61 +    .start         = proc_vhd_start,
    5.62 +    .next          = proc_vhd_next,
    5.63 +    .show          = proc_vhd_show,
    5.64 +    .stop          = proc_vhd_stop
    5.65 +};
    5.66 +
    5.67 +static int proc_open_vhd(struct inode *inode, struct file *file)
    5.68 +{
    5.69 +    return seq_open(file, &proc_vhd_op);
    5.70 +}
    5.71 +
    5.72 +
    5.73  #define isdelim(c) \
    5.74    (c==' '||c==','||c=='\n'||c=='\r'||c=='\t'||c==':'||c=='('||c==')' ? 1 : 0)
    5.75  
    5.76 @@ -72,7 +125,7 @@ unsigned long to_number(char *string)   
    5.77  }
    5.78  
    5.79  static int proc_write_vhd(struct file *file, const char *buffer,
    5.80 -			  unsigned long count, void *data)
    5.81 +			  size_t count, loff_t *offp)
    5.82  {
    5.83      char *local = kmalloc((count + 1) * sizeof(char), GFP_KERNEL);
    5.84      char *string;
    5.85 @@ -226,6 +279,14 @@ static int proc_write_vhd(struct file *f
    5.86      return res;
    5.87  }
    5.88  
    5.89 +static struct file_operations proc_vhd_operations = {
    5.90 +    open:         proc_open_vhd,
    5.91 +    read:         seq_read,
    5.92 +    llseek:       seq_lseek,
    5.93 +    release:      seq_release,
    5.94 +    write:        proc_write_vhd
    5.95 +};
    5.96 +
    5.97  /******************************************************************/
    5.98  
    5.99  int __init xlseg_proc_init(void)
   5.100 @@ -236,8 +297,7 @@ int __init xlseg_proc_init(void)
   5.101          panic ("xlseg_init: unable to create vhd proc entry\n");
   5.102      }
   5.103      vhd->data       = NULL;
   5.104 -    vhd->read_proc  = proc_read_vhd;
   5.105 -    vhd->write_proc = proc_write_vhd;
   5.106 +    vhd->proc_fops  = &proc_vhd_operations;
   5.107      vhd->owner      = THIS_MODULE;
   5.108  
   5.109      printk(KERN_ALERT "XenoLinux Virtual Disk Device Monitor installed\n");