debuggers.hg

changeset 22564:b1a8ea2f1d01

libxl: introduce libxl_need_xenpv_qemu

Introduce libxl_need_xenpv_qemu to detect if the caller needs to create
a pv qemu instance (using libxl_create_xenpv_qemu).
A positive reply depends on the number of pv console and vfbs, and the
type of disk backends.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Stefano Stabellini <stefano.stabellini@eu.citrix.com>
date Tue Dec 14 18:55:53 2010 +0000 (2010-12-14)
parents 3199c8d7569d
children 0ee07b393daf
files tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/xl_cmdimpl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Tue Dec 14 18:51:55 2010 +0000
     1.2 +++ b/tools/libxl/libxl.c	Tue Dec 14 18:55:53 2010 +0000
     1.3 @@ -2654,6 +2654,39 @@ static int libxl_build_xenpv_qemu_args(l
     1.4      return 0;
     1.5  }
     1.6  
     1.7 +int libxl_need_xenpv_qemu(libxl_ctx *ctx,
     1.8 +        int nr_consoles, libxl_device_console *consoles,
     1.9 +        int nr_vfbs, libxl_device_vfb *vfbs,
    1.10 +        int nr_disks, libxl_device_disk *disks)
    1.11 +{
    1.12 +    int i, ret = 0;
    1.13 +    libxl__gc gc = LIBXL_INIT_GC(ctx);
    1.14 +
    1.15 +    if (nr_consoles > 1) {
    1.16 +        ret = 1;
    1.17 +        goto out;
    1.18 +    }
    1.19 +
    1.20 +    for (i = 0; i < nr_consoles; i++) {
    1.21 +        if (consoles[i].consback == LIBXL_CONSBACK_IOEMU) {
    1.22 +            ret = 1;
    1.23 +            goto out;
    1.24 +        }
    1.25 +    }
    1.26 +
    1.27 +    if (nr_vfbs > 0) {
    1.28 +        ret = 1;
    1.29 +        goto out;
    1.30 +    }
    1.31 +
    1.32 +    if (nr_disks > 0 && !libxl__blktap_enabled(&gc))
    1.33 +        ret = 1;
    1.34 +
    1.35 +out:
    1.36 +    libxl__free_all(&gc);
    1.37 +    return ret;
    1.38 +}
    1.39 +
    1.40  int libxl_create_xenpv_qemu(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
    1.41                              libxl_device_model_starting **starting_r)
    1.42  {
     2.1 --- a/tools/libxl/libxl.h	Tue Dec 14 18:51:55 2010 +0000
     2.2 +++ b/tools/libxl/libxl.h	Tue Dec 14 18:55:53 2010 +0000
     2.3 @@ -376,6 +376,10 @@ int libxl_create_device_model(libxl_ctx 
     2.4                                libxl_device_model_starting **starting_r);
     2.5  int libxl_create_xenpv_qemu(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
     2.6                              libxl_device_model_starting **starting_r);
     2.7 +int libxl_need_xenpv_qemu(libxl_ctx *ctx,
     2.8 +        int nr_consoles, libxl_device_console *consoles,
     2.9 +        int nr_vfbs, libxl_device_vfb *vfbs,
    2.10 +        int nr_disks, libxl_device_disk *disks);
    2.11    /* Caller must either: pass starting_r==0, or on successful
    2.12     * return pass *starting_r (which will be non-0) to
    2.13     * libxl_confirm_device_model or libxl_detach_device_model. */
     3.1 --- a/tools/libxl/xl_cmdimpl.c	Tue Dec 14 18:51:55 2010 +0000
     3.2 +++ b/tools/libxl/xl_cmdimpl.c	Tue Dec 14 18:55:53 2010 +0000
     3.3 @@ -1675,6 +1675,7 @@ start:
     3.4                                          d_config.vifs, d_config.num_vifs,
     3.5                                          &dm_starting) );
     3.6      } else {
     3.7 +        int need_qemu = 0;
     3.8          libxl_device_console console;
     3.9  
    3.10          for (i = 0; i < d_config.num_vfbs; i++) {
    3.11 @@ -1686,12 +1687,18 @@ start:
    3.12  
    3.13          init_console_info(&console, 0, &state);
    3.14          console.domid = domid;
    3.15 -        if (d_config.num_vfbs)
    3.16 +
    3.17 +        need_qemu = libxl_need_xenpv_qemu(&ctx, 1, &console,
    3.18 +                d_config.num_vfbs, d_config.vfbs,
    3.19 +                d_config.num_disks, &d_config.disks[0]);
    3.20 +
    3.21 +        if (need_qemu)
    3.22               console.consback = LIBXL_CONSBACK_IOEMU;
    3.23 +
    3.24          libxl_device_console_add(&ctx, domid, &console);
    3.25          libxl_device_console_destroy(&console);
    3.26  
    3.27 -        if (d_config.num_vfbs)
    3.28 +        if (need_qemu)
    3.29              libxl_create_xenpv_qemu(&ctx, domid, d_config.vfbs, &dm_starting);
    3.30      }
    3.31