ia64/xen-unstable

changeset 14896:f033cc5cc0d5

[TAPDISK] Use incremental cookies and fix blktapctrl::test_path parameter typo.
Signed-off-by: Jake Wires <jwires@xensource.com>
author Jake Wires <jwires@xensource.com>
date Mon Apr 23 15:37:53 2007 -0700 (2007-04-23)
parents 6139337e2690
children 800aa9f5cec9
files tools/blktap/drivers/blktapctrl.c
line diff
     1.1 --- a/tools/blktap/drivers/blktapctrl.c	Mon Apr 23 16:37:03 2007 +0100
     1.2 +++ b/tools/blktap/drivers/blktapctrl.c	Mon Apr 23 15:37:53 2007 -0700
     1.3 @@ -177,14 +177,14 @@ static int get_tapdisk_pid(blkif_t *blki
     1.4   *   return 0 on success, -1 on error.
     1.5   */
     1.6  
     1.7 -static int test_path(char *path, char **dev, int *type, blkif_t *blkif)
     1.8 +static int test_path(char *path, char **dev, int *type, blkif_t **blkif)
     1.9  {
    1.10  	char *ptr, handle[10];
    1.11  	int i, size, found = 0;
    1.12  
    1.13  	size = sizeof(dtypes)/sizeof(disk_info_t *);
    1.14  	*type = MAX_DISK_TYPES + 1;
    1.15 -        blkif = NULL;
    1.16 +        *blkif = NULL;
    1.17  
    1.18  	if ( (ptr = strstr(path, ":"))!=NULL) {
    1.19  		memcpy(handle, path, (ptr - path));
    1.20 @@ -207,9 +207,9 @@ static int test_path(char *path, char **
    1.21                                  /* Check whether tapdisk process 
    1.22                                     already exists */
    1.23                                  if (active_disks[dtypes[i]->idnum] == NULL) 
    1.24 -                                        blkif = NULL;
    1.25 +                                        *blkif = NULL;
    1.26                                  else 
    1.27 -                                        blkif = active_disks[dtypes[i]
    1.28 +                                        *blkif = active_disks[dtypes[i]
    1.29                                                               ->idnum]->blkif;
    1.30                          }
    1.31                          return 0;
    1.32 @@ -478,19 +478,20 @@ int blktapctrl_new_blkif(blkif_t *blkif)
    1.33  	char *rdctldev, *wrctldev, *cmd, *ptr;
    1.34  	image_t *image;
    1.35  	blkif_t *exist = NULL;
    1.36 +	static uint16_t next_cookie = 0;
    1.37  
    1.38  	DPRINTF("Received a poll for a new vbd\n");
    1.39  	if ( ((blk=blkif->info) != NULL) && (blk->params != NULL) ) {
    1.40  		if (get_new_dev(&major, &minor, blkif)<0)
    1.41  			return -1;
    1.42  
    1.43 -		if (test_path(blk->params, &ptr, &type, exist) != 0) {
    1.44 +		if (test_path(blk->params, &ptr, &type, &exist) != 0) {
    1.45                          DPRINTF("Error in blktap device string(%s).\n",
    1.46                                  blk->params);
    1.47                          return -1;
    1.48                  }
    1.49  		blkif->drivertype = type;
    1.50 -		blkif->cookie = lrand48() % MAX_RAND_VAL;
    1.51 +		blkif->cookie = next_cookie++;
    1.52  
    1.53  		if (!exist) {
    1.54  			DPRINTF("Process does not exist:\n");