ia64/xen-unstable

changeset 426:62a46bc69cac

bitkeeper revision 1.209 (3eb7eef0DJ3MYtF7Su2LWjq1mtOLsA)

kernel.c, xi_stop.c, xi_start.c, xi_destroy.c, xi_create.c, xi_build.c:
Build fixes to remove compile warnings. Also fixed a crash when run xi_build with no kernel args.
author kaf24@scramble.cl.cam.ac.uk
date Tue May 06 17:20:48 2003 +0000 (2003-05-06)
parents 656d429e294c
children f05fccef69dc
files tools/internal/xi_build.c tools/internal/xi_create.c tools/internal/xi_destroy.c tools/internal/xi_start.c tools/internal/xi_stop.c xen/common/kernel.c
line diff
     1.1 --- a/tools/internal/xi_build.c	Tue May 06 14:54:13 2003 +0000
     1.2 +++ b/tools/internal/xi_build.c	Tue May 06 17:20:48 2003 +0000
     1.3 @@ -52,7 +52,7 @@ static void dom_mem_cleanup(dom_mem_t * 
     1.4  
     1.5      /* open the domain's /proc mem interface */
     1.6      sprintf(mem_path, "%s%s%s%s%d%s%s", "/proc/", PROC_XENO_ROOT, "/", 
     1.7 -        PROC_DOM_PREFIX, dom_mem->domain, "/", PROC_DOM_MEM);
     1.8 +            PROC_DOM_PREFIX, dom_mem->domain, "/", PROC_DOM_MEM);
     1.9  
    1.10      mem_fd = open(mem_path, O_WRONLY);
    1.11      if(mem_fd < 0){
    1.12 @@ -81,7 +81,8 @@ static int setup_dom_memmap(unsigned lon
    1.13      /* open the /proc command interface */
    1.14      sprintf(cmd_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_CMD);
    1.15      cmd_fd = open(cmd_path, O_WRONLY);
    1.16 -    if(cmd_fd < 0){
    1.17 +    if ( cmd_fd < 0 )
    1.18 +    {
    1.19          perror(PERR_STRING);
    1.20          return -1;
    1.21      }
    1.22 @@ -96,12 +97,12 @@ static int setup_dom_memmap(unsigned lon
    1.23  static unsigned long get_vaddr(unsigned int dom)
    1.24  {
    1.25      char mem_path[MAX_PATH];
    1.26 -	unsigned long addr;
    1.27 +    unsigned long addr;
    1.28      int mem_fd;
    1.29  
    1.30      /* open the domain's /proc mem interface */
    1.31      sprintf(mem_path, "%s%s%s%s%d%s%s", "/proc/", PROC_XENO_ROOT, "/", 
    1.32 -                    PROC_DOM_PREFIX, dom, "/", PROC_DOM_MEM);
    1.33 +            PROC_DOM_PREFIX, dom, "/", PROC_DOM_MEM);
    1.34  
    1.35      mem_fd = open(mem_path, O_RDONLY);
    1.36      if(mem_fd < 0){
    1.37 @@ -110,7 +111,7 @@ static unsigned long get_vaddr(unsigned 
    1.38      }
    1.39  
    1.40      /* get virtual address of mapped region */
    1.41 -	read(mem_fd, &addr, sizeof(addr));
    1.42 +    read(mem_fd, &addr, sizeof(addr));
    1.43  	
    1.44      close(mem_fd);
    1.45  
    1.46 @@ -118,7 +119,7 @@ static unsigned long get_vaddr(unsigned 
    1.47  }
    1.48  
    1.49  static int map_dom_mem(unsigned long pfn, int pages, int dom, 
    1.50 -    dom_mem_t * dom_mem)
    1.51 +                       dom_mem_t * dom_mem)
    1.52  {
    1.53  
    1.54      if(setup_dom_memmap(pfn, pages, dom)){
    1.55 @@ -139,7 +140,7 @@ static int map_dom_mem(unsigned long pfn
    1.56  
    1.57  /* open kernel image and do some sanity checks */
    1.58  static int do_kernel_chcks(char *image, long dom_size, 
    1.59 -    unsigned long * load_addr, size_t * ksize)
    1.60 +                           unsigned long * load_addr, size_t * ksize)
    1.61  {
    1.62      char signature[8];
    1.63      char status[MAX_PATH];
    1.64 @@ -157,25 +158,25 @@ static int do_kernel_chcks(char *image, 
    1.65      if(fstat(fd, &stat) < 0){
    1.66          perror(PERR_STRING);
    1.67          ret = -1;
    1.68 -		close(fd);
    1.69 +        close(fd);
    1.70          goto out;
    1.71      }
    1.72  
    1.73      if(stat.st_size > (dom_size << 10)){
    1.74          sprintf(status, "Kernel image size %ld larger than requested "
    1.75 -            "domain size %ld\n Terminated.\n", stat.st_size, dom_size);
    1.76 +                "domain size %ld\n Terminated.\n", stat.st_size, dom_size);
    1.77          dberr(status);
    1.78          ret = -1;
    1.79 -		close(fd);
    1.80 +        close(fd);
    1.81          goto out;
    1.82      }
    1.83      
    1.84      read(fd, signature, SIG_LEN);
    1.85      if(strncmp(signature, GUEST_SIG, SIG_LEN)){
    1.86          dberr("Kernel image does not contain required signature. "
    1.87 -		"Terminating.\n");
    1.88 +              "Terminating.\n");
    1.89          ret = -1;
    1.90 -		close(fd);
    1.91 +        close(fd);
    1.92          goto out;
    1.93      }
    1.94  
    1.95 @@ -185,7 +186,7 @@ static int do_kernel_chcks(char *image, 
    1.96  
    1.97      ret = fd;
    1.98  
    1.99 -out:    
   1.100 + out:    
   1.101      return ret;
   1.102  }
   1.103  
   1.104 @@ -198,7 +199,7 @@ out:
   1.105   */ 
   1.106  #define PAGE_TO_VADDR(_pfn) ((void *)(dom_mem->vaddr + ((_pfn) * PAGE_SIZE)))
   1.107  static dom_meminfo_t *setup_guestos(int dom, int kernel_fd, int initrd_fd,
   1.108 -    unsigned long virt_load_addr, size_t ksize, dom_mem_t *dom_mem)
   1.109 +                                    unsigned long virt_load_addr, size_t ksize, dom_mem_t *dom_mem)
   1.110  {
   1.111      dom_meminfo_t *meminfo;
   1.112      unsigned long *page_array;
   1.113 @@ -327,32 +328,32 @@ static dom_meminfo_t *setup_guestos(int 
   1.114      }
   1.115  
   1.116      if( initrd_fd )
   1.117 -      {
   1.118 +    {
   1.119  	struct stat stat;
   1.120  	unsigned long isize;
   1.121  
   1.122  	if(fstat(initrd_fd, &stat) < 0){
   1.123 -	  perror(PERR_STRING);
   1.124 -	  close(initrd_fd);
   1.125 -	  goto out;
   1.126 +            perror(PERR_STRING);
   1.127 +            close(initrd_fd);
   1.128 +            goto out;
   1.129  	}
   1.130  	isize = stat.st_size;
   1.131  
   1.132  	if( read(initrd_fd, ((char *)dom_mem->vaddr)+ksize, isize) != isize )
   1.133 -	  {
   1.134 +        {
   1.135  	    dberr("Error reading initrd image, could not"
   1.136  		  " read the whole image. Terminating.\n");
   1.137  	    goto out;
   1.138 -	  }
   1.139 +        }
   1.140  
   1.141  	meminfo->virt_mod_addr = virt_load_addr + ksize;
   1.142  	meminfo->virt_mod_len  = isize;
   1.143  
   1.144 -      }
   1.145 +    }
   1.146  
   1.147  
   1.148      ret = meminfo;
   1.149 -out:
   1.150 + out:
   1.151  
   1.152      return ret;
   1.153  }
   1.154 @@ -382,40 +383,40 @@ static int get_domain_info (int domain_i
   1.155                              int *pg_head,
   1.156                              int *tot_pages)
   1.157  {
   1.158 -  FILE *f; 
   1.159 -  char domains_path[MAX_PATH];
   1.160 -  char domains_line[256];
   1.161 -  int rc = -1;
   1.162 -  int read_id;
   1.163 -
   1.164 -  sprintf (domains_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_DOMAINS
   1.165 -);
   1.166 -
   1.167 -  f = fopen (domains_path, "r");
   1.168 -  if (f == NULL) goto out;
   1.169 +    FILE *f; 
   1.170 +    char domains_path[MAX_PATH];
   1.171 +    char domains_line[256];
   1.172 +    int rc = -1;
   1.173 +    int read_id;
   1.174  
   1.175 -  read_id = -1;
   1.176 -  while (fgets (domains_line, 256, f) != 0)
   1.177 +    sprintf (domains_path, "%s%s%s%s", "/proc/", PROC_XENO_ROOT, "/", PROC_DOMAINS
   1.178 +        );
   1.179 +
   1.180 +    f = fopen (domains_path, "r");
   1.181 +    if (f == NULL) goto out;
   1.182 +
   1.183 +    read_id = -1;
   1.184 +    while (fgets (domains_line, 256, f) != 0)
   1.185      { 
   1.186 -      int trans;
   1.187 -      trans = sscanf (domains_line, "%d %*d %*d %*d %*d %*d %x %d %*s", &read_id
   1.188 -, pg_head, tot_pages);
   1.189 -      if (trans == 3) {
   1.190 -        if (read_id == domain_id) {
   1.191 -          rc = 0;
   1.192 -          break;
   1.193 +        int trans;
   1.194 +        trans = sscanf (domains_line, "%d %*d %*d %*d %*d %*d %x %d %*s", &read_id
   1.195 +                        , pg_head, tot_pages);
   1.196 +        if (trans == 3) {
   1.197 +            if (read_id == domain_id) {
   1.198 +                rc = 0;
   1.199 +                break;
   1.200 +            }
   1.201          }
   1.202 -      }
   1.203      }
   1.204  
   1.205 -  if (read_id == -1) {
   1.206 -    errno = ESRCH;
   1.207 -  }
   1.208 +    if (read_id == -1) {
   1.209 +        errno = ESRCH;
   1.210 +    }
   1.211  
   1.212 -  fclose (f);
   1.213 +    fclose (f);
   1.214  
   1.215   out:
   1.216 -  return rc;
   1.217 +    return rc;
   1.218  }
   1.219  
   1.220  
   1.221 @@ -450,35 +451,39 @@ int main(int argc, char **argv)
   1.222  
   1.223      /* Look up information about the domain */
   1.224      domain_id = atol(argv[1]);
   1.225 -    if (get_domain_info (domain_id, &pg_head, &tot_pages) != 0) {
   1.226 -      perror ("Could not find domain information");
   1.227 -      rc = -1;
   1.228 -      goto out;
   1.229 +    if ( get_domain_info (domain_id, &pg_head, &tot_pages) != 0 ) 
   1.230 +    {
   1.231 +        perror ("Could not find domain information");
   1.232 +        rc = -1;
   1.233 +        goto out;
   1.234      }
   1.235  	     
   1.236 -    kernel_fd = do_kernel_chcks(argv[2], tot_pages << (PAGE_SHIFT - 10), &load_addr, &ksize);
   1.237 -    if(kernel_fd < 0)
   1.238 +    kernel_fd = do_kernel_chcks(argv[2], 
   1.239 +                                tot_pages << (PAGE_SHIFT - 10), 
   1.240 +                                &load_addr, &ksize);
   1.241 +    if ( kernel_fd < 0 )
   1.242  	return -1;
   1.243      
   1.244  
   1.245      /* map domain's memory */
   1.246 -    if(map_dom_mem(pg_head, tot_pages,
   1.247 -		   domain_id, &dom_os_image))
   1.248 +    if ( map_dom_mem(pg_head, tot_pages,
   1.249 +                     domain_id, &dom_os_image) )
   1.250          goto out;
   1.251  
   1.252 -    if( strncmp("initrd=", argv[args_start], 7) == 0 )
   1.253 -      {
   1.254 +    if( (argc > args_start) && 
   1.255 +        (strncmp("initrd=", argv[args_start], 7) == 0) )
   1.256 +    {
   1.257  	strncpy( initrd_name, argv[args_start]+7, sizeof(initrd_name) );
   1.258  	initrd_name[sizeof(initrd_name)-1] = 0;
   1.259  	printf("initrd present, name = %s\n", initrd_name );
   1.260  	args_start++;
   1.261 -
   1.262 +        
   1.263  	initrd_fd = open(initrd_name, O_RDONLY);
   1.264  	if(initrd_fd < 0){
   1.265 -	  perror(PERR_STRING);
   1.266 -	  goto out;
   1.267 +            perror(PERR_STRING);
   1.268 +            goto out;
   1.269  	}
   1.270 -      }
   1.271 +    }
   1.272  
   1.273      /* the following code does the actual domain building */
   1.274      meminfo = setup_guestos(domain_id, kernel_fd, initrd_fd, load_addr, 
   1.275 @@ -507,18 +512,18 @@ int main(int argc, char **argv)
   1.276      }
   1.277  
   1.278      /*    sprintf(status, 
   1.279 -	    "About to launch new domain %d with folowing parameters:\n"
   1.280 -	    " * page table base: %lx \n * load address: %lx \n"
   1.281 -	    " * shared info address: %lx \n * start info address: %lx \n"
   1.282 -	    " * number of vifs: %d \n * cmd line: %s \n", meminfo->domain, 
   1.283 -	    meminfo->l2_pgt_addr, meminfo->virt_load_addr, 
   1.284 -	    meminfo->virt_shinfo_addr, meminfo->virt_startinfo_addr, 
   1.285 -	    meminfo->num_vifs, meminfo->cmd_line);
   1.286 -	    dbstatus(status);*/
   1.287 +          "About to launch new domain %d with folowing parameters:\n"
   1.288 +          " * page table base: %lx \n * load address: %lx \n"
   1.289 +          " * shared info address: %lx \n * start info address: %lx \n"
   1.290 +          " * number of vifs: %d \n * cmd line: %s \n", meminfo->domain, 
   1.291 +          meminfo->l2_pgt_addr, meminfo->virt_load_addr, 
   1.292 +          meminfo->virt_shinfo_addr, meminfo->virt_startinfo_addr, 
   1.293 +          meminfo->num_vifs, meminfo->cmd_line);
   1.294 +          dbstatus(status);*/
   1.295      
   1.296      /* and launch the domain */
   1.297      rc = launch_domain(meminfo); 
   1.298      
   1.299 -out:
   1.300 + out:
   1.301      return rc;
   1.302  }
     2.1 --- a/tools/internal/xi_create.c	Tue May 06 14:54:13 2003 +0000
     2.2 +++ b/tools/internal/xi_create.c	Tue May 06 17:20:48 2003 +0000
     2.3 @@ -30,7 +30,7 @@ static void ERROR (char *message)
     2.4  
     2.5  static void PERROR (char *message)
     2.6  {
     2.7 -  fprintf (stderr, "%s: %s (%s)\n", argv0, message, sys_errlist[errno]);
     2.8 +  fprintf (stderr, "%s: %s (%s)\n", argv0, message, strerror(errno));
     2.9    exit (-1);
    2.10  }
    2.11  
     3.1 --- a/tools/internal/xi_destroy.c	Tue May 06 14:54:13 2003 +0000
     3.2 +++ b/tools/internal/xi_destroy.c	Tue May 06 17:20:48 2003 +0000
     3.3 @@ -25,7 +25,7 @@ static void ERROR (char *message)
     3.4  
     3.5  static void PERROR (char *message)
     3.6  {
     3.7 -  fprintf (stderr, "%s: %s (%s)\n", argv0, message, sys_errlist[errno]);
     3.8 +  fprintf (stderr, "%s: %s (%s)\n", argv0, message, strerror(errno));
     3.9    exit (-1);
    3.10  }
    3.11  
     4.1 --- a/tools/internal/xi_start.c	Tue May 06 14:54:13 2003 +0000
     4.2 +++ b/tools/internal/xi_start.c	Tue May 06 17:20:48 2003 +0000
     4.3 @@ -24,7 +24,7 @@ static void ERROR (char *message)
     4.4  
     4.5  static void PERROR (char *message)
     4.6  {
     4.7 -  fprintf (stderr, "%s: %s (%s)\n", argv0, message, sys_errlist[errno]);
     4.8 +  fprintf (stderr, "%s: %s (%s)\n", argv0, message, strerror(errno));
     4.9    exit (-1);
    4.10  }
    4.11  
     5.1 --- a/tools/internal/xi_stop.c	Tue May 06 14:54:13 2003 +0000
     5.2 +++ b/tools/internal/xi_stop.c	Tue May 06 17:20:48 2003 +0000
     5.3 @@ -24,7 +24,7 @@ static void ERROR (char *message)
     5.4  
     5.5  static void PERROR (char *message)
     5.6  {
     5.7 -  fprintf (stderr, "%s: %s (%s)\n", argv0, message, sys_errlist[errno]);
     5.8 +  fprintf (stderr, "%s: %s (%s)\n", argv0, message, strerror(errno));
     5.9    exit (-1);
    5.10  }
    5.11  
     6.1 --- a/xen/common/kernel.c	Tue May 06 14:54:13 2003 +0000
     6.2 +++ b/xen/common/kernel.c	Tue May 06 17:20:48 2003 +0000
     6.3 @@ -385,7 +385,8 @@ static inline void __putstr(const char *
     6.4  void printf (const char *fmt, ...)
     6.5  {
     6.6      va_list args;
     6.7 -    char buf[128], *p = fmt;
     6.8 +    char buf[128];
     6.9 +    const char *p = fmt;
    6.10      unsigned long flags;
    6.11  
    6.12      /*