~kirkland/+junk/eucalyptus

« back to all changes in this revision

Viewing changes to node/handlers_kvm.c

  • Committer: Dustin Kirkland
  • Date: 2010-04-23 01:31:13 UTC
  • Revision ID: kirkland@x200-20100423013113-ebwqkffptwwpyx79
Cherry-pick upstream commit r1223..1224:
* node/handlers_kvm.c: fix console bug (was only showing first 64K),
LP: #566793

Show diffs side-by-side

added added

removed removed

Lines of Context:
305
305
                        char **consoleOutput) {
306
306
  char *console_output;
307
307
  char console_file[1024];
308
 
  int rc, fd;
 
308
  int rc, fd, readsize;
309
309
  struct stat statbuf;
310
310
 
311
311
  *consoleOutput = NULL;
 
312
  readsize = 64 * 1024;
312
313
 
313
314
  // for KVM, read the console output from a file, encode it, and return
314
 
  console_output = malloc(64 * 1024);
 
315
  console_output = malloc(readsize);
315
316
  if (console_output == NULL) {
316
317
    return(1);
317
318
  }
332
333
    return(1);
333
334
  }
334
335
  
335
 
  bzero(console_output, 64*1024);
336
 
  rc = read(fd, console_output, (64*1024)-1);
 
336
  rc = lseek(fd, (off_t)(-1 * readsize), SEEK_END);
 
337
  if (rc < 0) {
 
338
    rc = lseek(fd, (off_t)0, SEEK_SET);
 
339
    if (rc < 0) {
 
340
      logprintfl(EUCAERROR, "cannot seek to beginning of file\n");
 
341
      if (console_output) free(console_output);
 
342
      return(1);
 
343
    }
 
344
  }
 
345
 
 
346
  bzero(console_output, readsize);
 
347
  rc = read(fd, console_output, (readsize)-1);
337
348
  close(fd);
338
349
  
339
350
  *consoleOutput = base64_enc((unsigned char *)console_output, strlen(console_output));