debuggers.hg

changeset 21978:fe930e1b2ce8

Merge
author Keir Fraser <keir.fraser@citrix.com>
date Fri Aug 06 18:35:02 2010 +0100 (2010-08-06)
parents cd606ea8f963 6b28b2dac7dd
children add40eb47868
files
line diff
     1.1 --- a/tools/libxc/xc_domain_restore.c	Fri Aug 06 16:49:16 2010 +0100
     1.2 +++ b/tools/libxc/xc_domain_restore.c	Fri Aug 06 18:35:02 2010 +0100
     1.3 @@ -640,6 +640,7 @@ typedef struct {
     1.4      uint64_t vcpumap;
     1.5      uint64_t identpt;
     1.6      uint64_t vm86_tss;
     1.7 +    uint64_t console_pfn;
     1.8  } pagebuf_t;
     1.9  
    1.10  static int pagebuf_init(pagebuf_t* buf)
    1.11 @@ -737,6 +738,16 @@ static int pagebuf_get_one(xc_interface 
    1.12              return -1;
    1.13          }
    1.14          return pagebuf_get_one(xch, ctx, buf, fd, dom);
    1.15 +    } else if (count == -8 ) {
    1.16 +        /* Skip padding 4 bytes then read the console pfn location. */
    1.17 +        if ( read_exact(fd, &buf->console_pfn, sizeof(uint32_t)) ||
    1.18 +             read_exact(fd, &buf->console_pfn, sizeof(uint64_t)) )
    1.19 +        {
    1.20 +            PERROR("error read the address of the console pfn");
    1.21 +            return -1;
    1.22 +        }
    1.23 +        // DPRINTF("console pfn location: %llx\n", buf->console_pfn);
    1.24 +        return pagebuf_get_one(xch, ctx, buf, fd, dom);
    1.25      } else if ( (count > MAX_BATCH_SIZE) || (count < 0) ) {
    1.26          ERROR("Max batch size exceeded (%d). Giving up.", count);
    1.27          errno = EMSGSIZE;
    1.28 @@ -1055,6 +1066,7 @@ int xc_domain_restore(xc_interface *xch,
    1.29      pagebuf_t pagebuf;
    1.30      tailbuf_t tailbuf, tmptail;
    1.31      void* vcpup;
    1.32 +    uint64_t console_pfn = 0;
    1.33  
    1.34      static struct restore_ctx _ctx = {
    1.35          .live_p2m = NULL,
    1.36 @@ -1207,6 +1219,8 @@ int xc_domain_restore(xc_interface *xch,
    1.37                  xc_set_hvm_param(xch, dom, HVM_PARAM_IDENT_PT, pagebuf.identpt);
    1.38              if ( pagebuf.vm86_tss )
    1.39                  xc_set_hvm_param(xch, dom, HVM_PARAM_VM86_TSS, pagebuf.vm86_tss);
    1.40 +            if ( pagebuf.console_pfn )
    1.41 +                console_pfn = pagebuf.console_pfn;
    1.42              break;  /* our work here is done */
    1.43          }
    1.44  
    1.45 @@ -1717,6 +1731,19 @@ int xc_domain_restore(xc_interface *xch,
    1.46      }
    1.47      *store_mfn = tailbuf.u.hvm.magicpfns[2];
    1.48  
    1.49 +    if ( console_pfn ) {
    1.50 +        if ( xc_clear_domain_page(xch, dom, console_pfn) ) {
    1.51 +            PERROR("error zeroing console page");
    1.52 +            goto out;
    1.53 +        }
    1.54 +        if ( (frc = xc_set_hvm_param(xch, dom, 
    1.55 +                                    HVM_PARAM_CONSOLE_PFN, console_pfn)) ) {
    1.56 +            PERROR("error setting HVM param: %i", frc);
    1.57 +            goto out;
    1.58 +        }
    1.59 +        *console_mfn = console_pfn;
    1.60 +    }
    1.61 +
    1.62      frc = xc_domain_hvm_setcontext(xch, dom, tailbuf.u.hvm.hvmbuf,
    1.63                                     tailbuf.u.hvm.reclen);
    1.64      if ( frc )
     2.1 --- a/tools/libxc/xc_domain_save.c	Fri Aug 06 16:49:16 2010 +0100
     2.2 +++ b/tools/libxc/xc_domain_save.c	Fri Aug 06 18:35:02 2010 +0100
     2.3 @@ -1587,6 +1587,17 @@ int xc_domain_save(xc_interface *xch, in
     2.4              PERROR("Error when writing the vm86 TSS for guest");
     2.5              goto out;
     2.6          }
     2.7 +
     2.8 +        chunk.id = -8;
     2.9 +        xc_get_hvm_param(xch, dom, HVM_PARAM_CONSOLE_PFN,
    2.10 +                         (unsigned long *)&chunk.data);
    2.11 +
    2.12 +        if ( (chunk.data != 0) &&
    2.13 +             wrexact(io_fd, &chunk, sizeof(chunk)) )
    2.14 +        {
    2.15 +            PERROR("Error when writing the console pfn for guest");
    2.16 +            goto out;
    2.17 +        }
    2.18      }
    2.19  
    2.20      /* Zero terminate */
     3.1 --- a/tools/libxc/xc_hvm_build.c	Fri Aug 06 16:49:16 2010 +0100
     3.2 +++ b/tools/libxc/xc_hvm_build.c	Fri Aug 06 18:35:02 2010 +0100
     3.3 @@ -28,7 +28,8 @@
     3.4  #define SPECIALPAGE_XENSTORE 1
     3.5  #define SPECIALPAGE_IOREQ    2
     3.6  #define SPECIALPAGE_IDENT_PT 3
     3.7 -#define NR_SPECIAL_PAGES     4
     3.8 +#define SPECIALPAGE_CONSOLE  4
     3.9 +#define NR_SPECIAL_PAGES     5
    3.10  #define special_pfn(x) (0xff000u - NR_SPECIAL_PAGES + (x))
    3.11  
    3.12  static void build_hvm_info(void *hvm_info_page, uint64_t mem_size)
    3.13 @@ -354,6 +355,8 @@ static int setup_guest(xc_interface *xch
    3.14                       special_pfn(SPECIALPAGE_BUFIOREQ));
    3.15      xc_set_hvm_param(xch, dom, HVM_PARAM_IOREQ_PFN,
    3.16                       special_pfn(SPECIALPAGE_IOREQ));
    3.17 +    xc_set_hvm_param(xch, dom, HVM_PARAM_CONSOLE_PFN,
    3.18 +                     special_pfn(SPECIALPAGE_CONSOLE));
    3.19  
    3.20      /*
    3.21       * Identity-map page table is required for running with CR0.PG=0 when
     4.1 --- a/tools/libxl/libxl_dom.c	Fri Aug 06 16:49:16 2010 +0100
     4.2 +++ b/tools/libxl/libxl_dom.c	Fri Aug 06 18:35:02 2010 +0100
     4.3 @@ -237,7 +237,7 @@ int build_hvm(libxl_ctx *ctx, uint32_t d
     4.4          return ERROR_FAIL;
     4.5      }
     4.6      ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
     4.7 -                               &state->store_mfn);
     4.8 +                               &state->store_mfn, state->console_port, &state->console_mfn);
     4.9      if (ret) {
    4.10          XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm build set params failed");
    4.11          return ERROR_FAIL;
     5.1 --- a/tools/libxl/libxl_internal.h	Fri Aug 06 16:49:16 2010 +0100
     5.2 +++ b/tools/libxl/libxl_internal.h	Fri Aug 06 18:35:02 2010 +0100
     5.3 @@ -173,7 +173,8 @@ int libxl_device_pci_reset(libxl_ctx *ct
     5.4  /* from xenguest (helper */
     5.5  int hvm_build_set_params(xc_interface *handle, uint32_t domid,
     5.6                           libxl_domain_build_info *info,
     5.7 -                         int store_evtchn, unsigned long *store_mfn);
     5.8 +                         int store_evtchn, unsigned long *store_mfn,
     5.9 +                         int console_evtchn, unsigned long *console_mfn);
    5.10  
    5.11  /* xl_exec */
    5.12  
     6.1 --- a/tools/libxl/libxl_utils.c	Fri Aug 06 16:49:16 2010 +0100
     6.2 +++ b/tools/libxl/libxl_utils.c	Fri Aug 06 18:35:02 2010 +0100
     6.3 @@ -101,6 +101,7 @@ int libxl_name_to_poolid(libxl_ctx *ctx,
     6.4      int i, nb_pools;
     6.5      char *poolname;
     6.6      libxl_poolinfo *poolinfo;
     6.7 +    int ret = -1;
     6.8  
     6.9      poolinfo = libxl_list_pool(ctx, &nb_pools);
    6.10      if (!poolinfo)
    6.11 @@ -112,10 +113,12 @@ int libxl_name_to_poolid(libxl_ctx *ctx,
    6.12              continue;
    6.13          if (strcmp(poolname, name) == 0) {
    6.14              *poolid = poolinfo[i].poolid;
    6.15 -            return 0;
    6.16 +            ret = 0;
    6.17 +            break;
    6.18          }
    6.19      }
    6.20 -    return -1;
    6.21 +    free(poolinfo);
    6.22 +    return ret;
    6.23  }
    6.24  
    6.25  int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid)
     7.1 --- a/tools/libxl/xenguest.c	Fri Aug 06 16:49:16 2010 +0100
     7.2 +++ b/tools/libxl/xenguest.c	Fri Aug 06 18:35:02 2010 +0100
     7.3 @@ -23,7 +23,8 @@
     7.4  
     7.5  int hvm_build_set_params(xc_interface *handle, uint32_t domid,
     7.6                           libxl_domain_build_info *info,
     7.7 -                         int store_evtchn, unsigned long *store_mfn)
     7.8 +                         int store_evtchn, unsigned long *store_mfn,
     7.9 +                         int console_evtchn, unsigned long *console_mfn)
    7.10  {
    7.11      struct hvm_info_table *va_hvm;
    7.12      uint8_t *va_map, sum;
    7.13 @@ -46,6 +47,7 @@ int hvm_build_set_params(xc_interface *h
    7.14      munmap(va_map, XC_PAGE_SIZE);
    7.15  
    7.16      xc_get_hvm_param(handle, domid, HVM_PARAM_STORE_PFN, store_mfn);
    7.17 +    xc_get_hvm_param(handle, domid, HVM_PARAM_CONSOLE_PFN, console_mfn);
    7.18      xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED, info->u.hvm.pae);
    7.19  #if defined(__i386__) || defined(__x86_64__)
    7.20      xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, info->u.hvm.viridian);
    7.21 @@ -54,5 +56,6 @@ int hvm_build_set_params(xc_interface *h
    7.22      xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, (unsigned long) info->u.hvm.timer_mode);
    7.23      xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN, (unsigned long) info->u.hvm.vpt_align);
    7.24      xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn);
    7.25 +    xc_set_hvm_param(handle, domid, HVM_PARAM_CONSOLE_EVTCHN, console_evtchn);
    7.26      return 0;
    7.27  }
     8.1 --- a/tools/libxl/xl_cmdimpl.c	Fri Aug 06 16:49:16 2010 +0100
     8.2 +++ b/tools/libxl/xl_cmdimpl.c	Fri Aug 06 18:35:02 2010 +0100
     8.3 @@ -1433,6 +1433,9 @@ start:
     8.4          }
     8.5      }
     8.6      if (d_config.c_info.hvm) {
     8.7 +        init_console_info(&console, 0, &state);
     8.8 +        console.domid = domid;
     8.9 +        libxl_device_console_add(&ctx, domid, &console);
    8.10          dm_info.domid = domid;
    8.11          MUST( libxl_create_device_model(&ctx, &dm_info,
    8.12                                          d_config.disks, d_config.num_disks,
     9.1 --- a/xen/include/public/hvm/params.h	Fri Aug 06 16:49:16 2010 +0100
     9.2 +++ b/xen/include/public/hvm/params.h	Fri Aug 06 18:35:02 2010 +0100
     9.3 @@ -109,6 +109,10 @@
     9.4  /* Boolean: Enable aligning all periodic vpts to reduce interrupts */
     9.5  #define HVM_PARAM_VPT_ALIGN    16
     9.6  
     9.7 -#define HVM_NR_PARAMS          17
     9.8 +/* Console debug shared memory ring and event channel */
     9.9 +#define HVM_PARAM_CONSOLE_PFN    17
    9.10 +#define HVM_PARAM_CONSOLE_EVTCHN 18
    9.11 +
    9.12 +#define HVM_NR_PARAMS          19
    9.13  
    9.14  #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */