# HG changeset patch
# User Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
# Date 1292352953 0
# Node ID b1a8ea2f1d01f2887305db6c3b2d9387fd0c1413
# Parent 3199c8d7569d8a7cf3c265f98052eb0b5b6cedd0
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@xxxxxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
tools/libxl/libxl.c | 33 +++++++++++++++++++++++++++++++++
tools/libxl/libxl.h | 4 ++++
tools/libxl/xl_cmdimpl.c | 11 +++++++++--
3 files changed, 46 insertions(+), 2 deletions(-)
diff -r 3199c8d7569d -r b1a8ea2f1d01 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Tue Dec 14 18:51:55 2010 +0000
+++ b/tools/libxl/libxl.c Tue Dec 14 18:55:53 2010 +0000
@@ -2652,6 +2652,39 @@ static int libxl_build_xenpv_qemu_args(l
info->device_model = libxl__abs_path(gc, "qemu-dm", libxl_libexec_path());
info->type = XENPV;
return 0;
+}
+
+int libxl_need_xenpv_qemu(libxl_ctx *ctx,
+ int nr_consoles, libxl_device_console *consoles,
+ int nr_vfbs, libxl_device_vfb *vfbs,
+ int nr_disks, libxl_device_disk *disks)
+{
+ int i, ret = 0;
+ libxl__gc gc = LIBXL_INIT_GC(ctx);
+
+ if (nr_consoles > 1) {
+ ret = 1;
+ goto out;
+ }
+
+ for (i = 0; i < nr_consoles; i++) {
+ if (consoles[i].consback == LIBXL_CONSBACK_IOEMU) {
+ ret = 1;
+ goto out;
+ }
+ }
+
+ if (nr_vfbs > 0) {
+ ret = 1;
+ goto out;
+ }
+
+ if (nr_disks > 0 && !libxl__blktap_enabled(&gc))
+ ret = 1;
+
+out:
+ libxl__free_all(&gc);
+ return ret;
}
int libxl_create_xenpv_qemu(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb
*vfb,
diff -r 3199c8d7569d -r b1a8ea2f1d01 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Tue Dec 14 18:51:55 2010 +0000
+++ b/tools/libxl/libxl.h Tue Dec 14 18:55:53 2010 +0000
@@ -376,6 +376,10 @@ int libxl_create_device_model(libxl_ctx
libxl_device_model_starting **starting_r);
int libxl_create_xenpv_qemu(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb
*vfb,
libxl_device_model_starting **starting_r);
+int libxl_need_xenpv_qemu(libxl_ctx *ctx,
+ int nr_consoles, libxl_device_console *consoles,
+ int nr_vfbs, libxl_device_vfb *vfbs,
+ int nr_disks, libxl_device_disk *disks);
/* Caller must either: pass starting_r==0, or on successful
* return pass *starting_r (which will be non-0) to
* libxl_confirm_device_model or libxl_detach_device_model. */
diff -r 3199c8d7569d -r b1a8ea2f1d01 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Tue Dec 14 18:51:55 2010 +0000
+++ b/tools/libxl/xl_cmdimpl.c Tue Dec 14 18:55:53 2010 +0000
@@ -1675,6 +1675,7 @@ start:
d_config.vifs, d_config.num_vifs,
&dm_starting) );
} else {
+ int need_qemu = 0;
libxl_device_console console;
for (i = 0; i < d_config.num_vfbs; i++) {
@@ -1686,12 +1687,18 @@ start:
init_console_info(&console, 0, &state);
console.domid = domid;
- if (d_config.num_vfbs)
+
+ need_qemu = libxl_need_xenpv_qemu(&ctx, 1, &console,
+ d_config.num_vfbs, d_config.vfbs,
+ d_config.num_disks, &d_config.disks[0]);
+
+ if (need_qemu)
console.consback = LIBXL_CONSBACK_IOEMU;
+
libxl_device_console_add(&ctx, domid, &console);
libxl_device_console_destroy(&console);
- if (d_config.num_vfbs)
+ if (need_qemu)
libxl_create_xenpv_qemu(&ctx, domid, d_config.vfbs, &dm_starting);
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|