ia64/xen-unstable

changeset 840:d75063d55d8e

bitkeeper revision 1.522 (3f8d3cffmNKgZ0npDLxqj41Tk8Lk4w)

xi_build.c:
Cleanups to xi_build.
author kaf24@scramble.cl.cam.ac.uk
date Wed Oct 15 12:26:39 2003 +0000 (2003-10-15)
parents c727b650bf0c
children d503657ed8d9
files tools/internal/xi_build.c
line diff
     1.1 --- a/tools/internal/xi_build.c	Wed Oct 15 12:01:56 2003 +0000
     1.2 +++ b/tools/internal/xi_build.c	Wed Oct 15 12:26:39 2003 +0000
     1.3 @@ -3,12 +3,15 @@
     1.4  #include "dom0_defs.h"
     1.5  #include "mem_defs.h"
     1.6  
     1.7 +/* This string is written to the head of every guest kernel image. */
     1.8  #define GUEST_SIG   "XenoGues"
     1.9  #define SIG_LEN    8
    1.10  
    1.11  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
    1.12  #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
    1.13  
    1.14 +static char *argv0 = "internal_domain_build";
    1.15 +
    1.16  static long get_tot_pages(int domain_id)
    1.17  {
    1.18      dom0_op_t op;
    1.19 @@ -78,6 +81,7 @@ static int read_kernel_header(int fd, lo
    1.20  	return -1;
    1.21      }
    1.22  
    1.23 +    /* Double the kernel image size to account for dynamic memory usage etc. */
    1.24      if ( (stat.st_size * 2) > (dom_size << 10) )
    1.25      {
    1.26          sprintf(status, "Kernel image size %ld larger than requested "
    1.27 @@ -89,11 +93,12 @@ static int read_kernel_header(int fd, lo
    1.28      read(fd, signature, SIG_LEN);
    1.29      if ( strncmp(signature, GUEST_SIG, SIG_LEN) )
    1.30      {
    1.31 -        ERROR("Kernel image does not contain required signature. "
    1.32 +        ERROR("Kernel image does not contain required signature.\n"
    1.33                "Terminating.\n");
    1.34  	return -1;
    1.35      }
    1.36  
    1.37 +    /* Read the load address which immediately follows the Xeno signature. */
    1.38      read(fd, load_addr, sizeof(unsigned long));
    1.39  
    1.40      *ksize = stat.st_size - SIG_LEN - sizeof(unsigned long);
    1.41 @@ -207,6 +212,7 @@ static int setup_guestos(
    1.42              goto error_out;
    1.43          }
    1.44  
    1.45 +        /* 'i' is 'ksize' rounded up to a page boundary. */
    1.46          meminfo->virt_mod_addr = virt_load_addr + i;
    1.47          meminfo->virt_mod_len  = isize;
    1.48  
    1.49 @@ -336,8 +342,12 @@ static int setup_guestos(
    1.50  
    1.51  int main(int argc, char **argv)
    1.52  {
    1.53 +    /*
    1.54 +     * NB. 'ksize' is the size in bytes of the main kernel image. It excludes
    1.55 +     * the 8-byte signature and 4-byte load address.
    1.56 +     */
    1.57 +    size_t ksize;
    1.58      dom0_op_t launch_op;
    1.59 -    size_t ksize;
    1.60      unsigned long load_addr;
    1.61      long tot_pages;
    1.62      int kernel_fd, initrd_fd = -1;
    1.63 @@ -348,10 +358,13 @@ int main(int argc, char **argv)
    1.64      int domain_id;
    1.65      int rc;
    1.66  
    1.67 +    if ( argv[0] != NULL ) 
    1.68 +        argv0 = argv[0];
    1.69 +
    1.70      if ( argc < 4 )
    1.71      {
    1.72 -        fprintf(stderr, "Usage: dom_builder <domain_id> <image> <num_vifs> "
    1.73 -                "[<initrd=initrd_name>] <boot_params>\n");
    1.74 +        fprintf(stderr, "Usage: %s <domain_id> <image> <num_vifs> "
    1.75 +                "[<initrd=initrd_name>] <boot_params>\n", argv0);
    1.76          return 1;
    1.77      }
    1.78