[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 1/2] xen: pass kernel initrd to qemu
[support xen HVM direct kernel boot] xen side patch: support 'kernel', 'ramdisk', 'root', 'extra' in HVM config file, parse config file, pass -kernel, -initrd and -append parameters to qemu. [config example] kernel="/mnt/vmlinuz-3.0.13-0.27-default" ramdisk="/mnt/initrd-3.0.13-0.27-default" root="/dev/hda2" extra="console=tty0 console=ttyS0" disk=[ 'file:/mnt/images/bjz_04_sles11_sp2/disk0.raw,hda,w', ] Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx> --- tools/libxl/libxl_dm.c | 20 ++++++++++++++++++++ tools/libxl/libxl_types.idl | 3 +++ tools/libxl/xl_cmdimpl.c | 33 +++++++++++++++++++++++++++------ 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 51ab2bf..133bb56 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -196,6 +196,16 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc, int nr_set_cpus = 0; char *s; + if (b_info->u.hvm.kernel) { + flexarray_vappend(dm_args, "-kernel", b_info->u.hvm.kernel, NULL); + } + if (b_info->u.hvm.ramdisk) { + flexarray_vappend(dm_args, "-initrd", b_info->u.hvm.ramdisk, NULL); + } + if (b_info->u.hvm.cmdline) { + flexarray_vappend(dm_args, "-append", b_info->u.hvm.cmdline, NULL); + } + if (b_info->u.hvm.serial) { flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL); } @@ -479,6 +489,16 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) { int ioemu_nics = 0; + if (b_info->u.hvm.kernel) { + flexarray_vappend(dm_args, "-kernel", b_info->u.hvm.kernel, NULL); + } + if (b_info->u.hvm.ramdisk) { + flexarray_vappend(dm_args, "-initrd", b_info->u.hvm.ramdisk, NULL); + } + if (b_info->u.hvm.cmdline) { + flexarray_vappend(dm_args, "-append", b_info->u.hvm.cmdline, NULL); + } + if (b_info->u.hvm.serial) { flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL); } diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 52f1aa9..b8b973b 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -336,6 +336,9 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("event_channels", uint32), ("u", KeyedUnion(None, libxl_domain_type, "type", [("hvm", Struct(None, [("firmware", string), + ("kernel", string), + ("cmdline", string), + ("ramdisk", string), ("bios", libxl_bios_type), ("pae", libxl_defbool), ("apic", libxl_defbool), diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 5195914..efd2474 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -743,6 +743,8 @@ static void parse_config_data(const char *config_source, int pci_permissive = 0; int pci_seize = 0; int i, e; + char *cmdline = NULL; + const char *root = NULL, *extra = ""; libxl_domain_create_info *c_info = &d_config->c_info; libxl_domain_build_info *b_info = &d_config->b_info; @@ -1007,9 +1009,31 @@ static void parse_config_data(const char *config_source, switch(b_info->type) { case LIBXL_DOMAIN_TYPE_HVM: - if (!xlu_cfg_get_string (config, "kernel", &buf, 0)) - fprintf(stderr, "WARNING: ignoring \"kernel\" directive for HVM guest. " - "Use \"firmware_override\" instead if you really want a non-default firmware\n"); + if (!xlu_cfg_get_string (config, "kernel", &buf, 0)) { + if (strstr(buf, "hvmloader")) + fprintf(stderr, "WARNING: ignoring \"kernel\" directive for HVM guest. " + "Use \"firmware_override\" instead if you really want a non-default firmware\n"); + else + b_info->u.hvm.kernel = strdup(buf); + } + + xlu_cfg_get_string (config, "root", &root, 0); + xlu_cfg_get_string (config, "extra", &extra, 0); + + if (root) { + if (asprintf(&cmdline, "root=%s %s", root, extra) == -1) + cmdline = NULL; + } else { + cmdline = strdup(extra); + } + + if ((root || extra) && !cmdline) { + fprintf(stderr, "Failed to allocate memory for cmdline\n"); + exit(1); + } + + b_info->u.hvm.cmdline = cmdline; + xlu_cfg_replace_string (config, "ramdisk", &b_info->u.hvm.ramdisk, 0); xlu_cfg_replace_string (config, "firmware_override", &b_info->u.hvm.firmware, 0); @@ -1061,9 +1085,6 @@ static void parse_config_data(const char *config_source, break; case LIBXL_DOMAIN_TYPE_PV: { - char *cmdline = NULL; - const char *root = NULL, *extra = ""; - xlu_cfg_replace_string (config, "kernel", &b_info->u.pv.kernel, 0); xlu_cfg_get_string (config, "root", &root, 0); -- 1.8.4.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |