diff options
author | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2003-10-15 12:26:39 +0000 |
---|---|---|
committer | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2003-10-15 12:26:39 +0000 |
commit | d03d4e2132dcdf487d497220e609be11d78dcffa (patch) | |
tree | 342f0fdc8296c35ed3e136d3fd335215a0bf79f1 | |
parent | 7bc800b94f50deb4904c54eb46ad8dc8c57b8c90 (diff) | |
download | xen-d03d4e2132dcdf487d497220e609be11d78dcffa.tar.gz xen-d03d4e2132dcdf487d497220e609be11d78dcffa.tar.bz2 xen-d03d4e2132dcdf487d497220e609be11d78dcffa.zip |
bitkeeper revision 1.522 (3f8d3cffmNKgZ0npDLxqj41Tk8Lk4w)
xi_build.c:
Cleanups to xi_build.
-rw-r--r-- | tools/internal/xi_build.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/internal/xi_build.c b/tools/internal/xi_build.c index 78533000ed..1ba36a1ef4 100644 --- a/tools/internal/xi_build.c +++ b/tools/internal/xi_build.c @@ -3,12 +3,15 @@ #include "dom0_defs.h" #include "mem_defs.h" +/* This string is written to the head of every guest kernel image. */ #define GUEST_SIG "XenoGues" #define SIG_LEN 8 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED) #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) +static char *argv0 = "internal_domain_build"; + static long get_tot_pages(int domain_id) { dom0_op_t op; @@ -78,6 +81,7 @@ static int read_kernel_header(int fd, long dom_size, return -1; } + /* Double the kernel image size to account for dynamic memory usage etc. */ if ( (stat.st_size * 2) > (dom_size << 10) ) { sprintf(status, "Kernel image size %ld larger than requested " @@ -89,11 +93,12 @@ static int read_kernel_header(int fd, long dom_size, read(fd, signature, SIG_LEN); if ( strncmp(signature, GUEST_SIG, SIG_LEN) ) { - ERROR("Kernel image does not contain required signature. " + ERROR("Kernel image does not contain required signature.\n" "Terminating.\n"); return -1; } + /* Read the load address which immediately follows the Xeno signature. */ read(fd, load_addr, sizeof(unsigned long)); *ksize = stat.st_size - SIG_LEN - sizeof(unsigned long); @@ -207,6 +212,7 @@ static int setup_guestos( goto error_out; } + /* 'i' is 'ksize' rounded up to a page boundary. */ meminfo->virt_mod_addr = virt_load_addr + i; meminfo->virt_mod_len = isize; @@ -336,8 +342,12 @@ static int setup_guestos( int main(int argc, char **argv) { - dom0_op_t launch_op; + /* + * NB. 'ksize' is the size in bytes of the main kernel image. It excludes + * the 8-byte signature and 4-byte load address. + */ size_t ksize; + dom0_op_t launch_op; unsigned long load_addr; long tot_pages; int kernel_fd, initrd_fd = -1; @@ -348,10 +358,13 @@ int main(int argc, char **argv) int domain_id; int rc; + if ( argv[0] != NULL ) + argv0 = argv[0]; + if ( argc < 4 ) { - fprintf(stderr, "Usage: dom_builder <domain_id> <image> <num_vifs> " - "[<initrd=initrd_name>] <boot_params>\n"); + fprintf(stderr, "Usage: %s <domain_id> <image> <num_vifs> " + "[<initrd=initrd_name>] <boot_params>\n", argv0); return 1; } |