ia64/xen-unstable

changeset 11775:30f13007be3f

[XEND] No need to decompress the initrd when building a domain.
The guest OS should be capable of parsing an image file in
whatever format was produced by that OS's tools. Furthermore,
we have seen initrd images with trailing garbage. This causes
us to calculate the wrong size for the uncompressed data and hence
fail to build the guest.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Oct 09 13:50:00 2006 +0100 (2006-10-09)
parents 411c6aca255c
children 6e932f32662c
files tools/libxc/xc_linux_build.c
line diff
     1.1 --- a/tools/libxc/xc_linux_build.c	Mon Oct 09 13:46:34 2006 +0100
     1.2 +++ b/tools/libxc/xc_linux_build.c	Mon Oct 09 13:50:00 2006 +0100
     1.3 @@ -38,7 +38,7 @@ struct initrd_info {
     1.4      enum { INITRD_none, INITRD_file, INITRD_mem } type;
     1.5      unsigned long len;
     1.6      union {
     1.7 -        gzFile file_handle;
     1.8 +        int fd;
     1.9          char *mem_addr;
    1.10      } u;
    1.11  };
    1.12 @@ -152,7 +152,7 @@ int load_initrd(int xc_handle, domid_t d
    1.13          }
    1.14          else
    1.15          {
    1.16 -            if ( gzread(initrd->u.file_handle, page, PAGE_SIZE) == -1 )
    1.17 +            if ( read(initrd->u.fd, page, PAGE_SIZE) == -1 )
    1.18              {
    1.19                  PERROR("Error reading initrd image, could not");
    1.20                  return -EINVAL;
    1.21 @@ -1344,20 +1344,16 @@ int xc_linux_build(int xc_handle,
    1.22  
    1.23      if ( (initrd_name != NULL) && (strlen(initrd_name) != 0) )
    1.24      {
    1.25 -        initrd_info.type = INITRD_file;
    1.26 -
    1.27          if ( (fd = open(initrd_name, O_RDONLY)) < 0 )
    1.28          {
    1.29              PERROR("Could not open the initial ramdisk image");
    1.30              goto error_out;
    1.31          }
    1.32  
    1.33 -        initrd_info.len = xc_get_filesz(fd);
    1.34 -        if ( (initrd_info.u.file_handle = gzdopen(fd, "rb")) == NULL )
    1.35 -        {
    1.36 -            PERROR("Could not allocate decompression state for initrd");
    1.37 -            goto error_out;
    1.38 -        }
    1.39 +        initrd_info.type = INITRD_file;
    1.40 +        initrd_info.u.fd = fd;
    1.41 +        initrd_info.len  = lseek(fd, 0, SEEK_END);
    1.42 +        lseek(fd, 0, SEEK_SET);
    1.43      }
    1.44  
    1.45      sts = xc_linux_build_internal(xc_handle, domid, image, image_size,
    1.46 @@ -1367,8 +1363,8 @@ int xc_linux_build(int xc_handle,
    1.47  
    1.48   error_out:
    1.49      free(image);
    1.50 -    if ( initrd_info.type == INITRD_file && initrd_info.u.file_handle )
    1.51 -        gzclose(initrd_info.u.file_handle);
    1.52 +    if ( initrd_info.type == INITRD_file )
    1.53 +        close(initrd_info.u.fd);
    1.54      else if ( fd >= 0 )
    1.55          close(fd);
    1.56