ia64/xen-unstable

changeset 18004:830e5d8b71da

Blktapctrl compatibility layer

I originally had just changed the NEWINTF ioctl to send over 48-bits
of information, which works on 64-bit but not on 32-bit (since the arg
is an unsigned long). Additionally, the previous changes would break
an older userland against a new kernel. For that reason, introduce a
new ioctl (NEWINTF_EXT) that fixes both of these problems. This is
the dom0 userland side.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jul 09 10:41:49 2008 +0100 (2008-07-09)
parents 79978fcf8797
children 06bcd8f622c8
files tools/blktap/drivers/blktapctrl.c tools/blktap/lib/blktaplib.h
line diff
     1.1 --- a/tools/blktap/drivers/blktapctrl.c	Wed Jul 09 10:39:42 2008 +0100
     1.2 +++ b/tools/blktap/drivers/blktapctrl.c	Wed Jul 09 10:41:49 2008 +0100
     1.3 @@ -123,12 +123,25 @@ static void make_blktap_dev(char *devnam
     1.4  static int get_new_dev(int *major, int *minor, blkif_t *blkif)
     1.5  {
     1.6  	domid_translate_t tr;
     1.7 +	domid_translate_ext_t tr_ext;
     1.8  	int ret;
     1.9  	char *devname;
    1.10  	
    1.11 -	tr.domid = blkif->domid;
    1.12 -        tr.busid = blkif->be_id;
    1.13 -	ret = ioctl(ctlfd, BLKTAP_IOCTL_NEWINTF, tr );
    1.14 +	if (blkif->be_id >= (1<<28)) {
    1.15 +		/* new-style backend-id, so use the extended structure */
    1.16 +		tr_ext.domid = blkif->domid;
    1.17 +		tr_ext.busid = blkif->be_id;
    1.18 +		ret = ioctl(ctlfd, BLKTAP_IOCTL_NEWINTF_EXT, &tr_ext);
    1.19 +		DPRINTF("Sent domid %d and be_id %d\n", tr_ext.domid,
    1.20 +			tr_ext.busid);
    1.21 +	}
    1.22 +	else {
    1.23 +		/* old-style backend-id; use the old structure */
    1.24 +		tr.domid = blkif->domid;
    1.25 +		tr.busid = (unsigned short)blkif->be_id;
    1.26 +		ret = ioctl(ctlfd, BLKTAP_IOCTL_NEWINTF, tr);
    1.27 +		DPRINTF("Sent domid %d and be_id %d\n", tr.domid, tr.busid);
    1.28 +	}
    1.29  	
    1.30  	if ( (ret <= 0)||(ret > MAX_TAP_DEV) ) {
    1.31  		DPRINTF("Incorrect Dev ID [%d]\n",ret);
    1.32 @@ -145,9 +158,8 @@ static int get_new_dev(int *major, int *
    1.33  	if (asprintf(&devname,"%s/%s%d",BLKTAP_DEV_DIR, BLKTAP_DEV_NAME, *minor) == -1)
    1.34  		return -1;
    1.35  	make_blktap_dev(devname,*major,*minor);	
    1.36 -	DPRINTF("Received device id %d and major %d, "
    1.37 -		"sent domid %d and be_id %d\n",
    1.38 -		*minor, *major, tr.domid, tr.busid);
    1.39 +	DPRINTF("Received device id %d and major %d\n",
    1.40 +		*minor, *major);
    1.41  	return 0;
    1.42  }
    1.43  
     2.1 --- a/tools/blktap/lib/blktaplib.h	Wed Jul 09 10:39:42 2008 +0100
     2.2 +++ b/tools/blktap/lib/blktaplib.h	Wed Jul 09 10:41:49 2008 +0100
     2.3 @@ -57,6 +57,7 @@
     2.4  #define BLKTAP_IOCTL_MAJOR	     7
     2.5  #define BLKTAP_QUERY_ALLOC_REQS      8
     2.6  #define BLKTAP_IOCTL_FREEINTF	     9
     2.7 +#define BLKTAP_IOCTL_NEWINTF_EXT     50
     2.8  #define BLKTAP_IOCTL_PRINT_IDXS      100   
     2.9  
    2.10  /* blktap switching modes: (Set with BLKTAP_IOCTL_SETMODE)             */
    2.11 @@ -161,8 +162,13 @@ typedef struct tapdev_info {
    2.12  
    2.13  typedef struct domid_translate {
    2.14  	unsigned short domid;
    2.15 +	unsigned short busid;
    2.16 +} domid_translate_t ;
    2.17 +
    2.18 +typedef struct domid_translate_ext {
    2.19 +	unsigned short domid;
    2.20  	uint32_t busid;
    2.21 -} domid_translate_t ;
    2.22 +} domid_translate_ext_t ;
    2.23  
    2.24  typedef struct image {
    2.25  	unsigned long long size;