* [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot @ 2014-07-07 6:34 Chunyan Liu 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 1/3] xen: pass kernel initrd to qemu Chunyan Liu ` (3 more replies) 0 siblings, 4 replies; 13+ messages in thread From: Chunyan Liu @ 2014-07-07 6:34 UTC (permalink / raw) To: xen-devel, qemu-devel Cc: Chunyan Liu, Ian.Jackson, Ian.Campbell, stefano.stabellini Updated current patch series for working with qemu-xen and default BIOS (seabios), to make it in good shape. Stubdom support will be continued. xen side patches: * pass kernel/initrd/append parameters to qemu-dm * add 'cmdline' in xl.cfg qemu side patch: reuse load_linux() for xen hvm direct kernel boot. Different from pc_memory_init which does lots of ram alloc work and rom/bios loading work, for xen, we only need to init a basic fw_cfg device used by load_linux() to store ADDRs and linuxboot.bin/multiboot.bin to retrive ADDRs, then load_linux(), after that, do real add option rom work to add linuxboot.bin/multiboot.bin to system option rom. Other things would be done by seabios smoothly. Changes: xen side patch: - add 'cmdline' in xl.cfg (as a separate patch) - update u.pv.kernel compable work: fill in b_info.kernel with old u.pv.kernel in libxl__domain_build_info_setdefault, handle b_info.kernel only later. - update libxl.h to include LIBXL_HAVE_BUILDINFO_KERNEL only rather than three qemu side patch: - no change to v4. v4 is here: http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg00026.html v3 is here: https://lists.nongnu.org/archive/html/qemu-devel/2014-06/msg04903.html v2 is here: http://thread.gmane.org/gmane.comp.emulators.qemu/277514 v1 is here: http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg06233.html Chunyan Liu (3): xen: pass kernel initrd to qemu xl.cfg: add 'cmdline' in config file qemu: support xen HVM direct kernel boot -- 1.8.4.5 ^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [RFC PATCH V5 1/3] xen: pass kernel initrd to qemu 2014-07-07 6:34 [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot Chunyan Liu @ 2014-07-07 6:34 ` Chunyan Liu 2014-07-10 14:48 ` Ian Campbell 2014-11-27 18:14 ` [Qemu-devel] [for 4.5] missing chunk in 11dffa2359e8a2629490c14c029c7c7c777b3e47 Stefano Stabellini 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 2/3] xl.cfg: add 'cmdline' in config file Chunyan Liu ` (2 subsequent siblings) 3 siblings, 2 replies; 13+ messages in thread From: Chunyan Liu @ 2014-07-07 6:34 UTC (permalink / raw) To: xen-devel, qemu-devel Cc: Chunyan Liu, Ian.Jackson, Ian.Campbell, stefano.stabellini xen side patch to support xen HVM direct kernel boot: support 'kernel', 'ramdisk', 'cmdline' (and 'root', 'extra' as well which would be deprecated later) in HVM config file, parse config file, pass -kernel, -initrd, -append parameters to qemu. It's working with qemu-xen when using the default BIOS (seabios). [HVM config example] name="sles11_sp2" description="None" uuid="5c84adcc-bd59-788a-96d2-195f9b599cfe" memory=512 maxmem=512 vcpus=4 on_poweroff="destroy" on_reboot="restart" on_crash="destroy" localtime=0 keymap="en-us" builder="hvm" device_model_override="/home/cyliu/git/qemu/x86_64-softmmu/qemu-system-x86_64" 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/sles11_sp2/disk0.raw,hda,w', ] vif=[ 'mac=00:16:3e:56:af:69,bridge=br0,type=netfront', ] stdvga=0 vnc=1 vncunused=1 viridian=0 acpi=1 pae=1 serial="pty" Signed-off-by: Chunyan Liu <cyliu@suse.com> --- Changes: - update b_info->u.pv.kernel compatibility work: turn b_info->u.pv.kernel to b_info->kernel in libxl__domain_build_info_setdefault, handle b_info->kernel in later processing. - include LIBXL_HAVE_BUILDINFO_KERNEL only instead of each for kernel, ramdisk and cmdline. - update examples in commit message docs/man/xl.cfg.pod.5 | 53 ++++++++++++++++++++++-------------- tools/libxl/libxl.h | 15 +++++++++++ tools/libxl/libxl_bootloader.c | 18 ++++++------- tools/libxl/libxl_create.c | 19 +++++++++++++ tools/libxl/libxl_dm.c | 15 +++++++++++ tools/libxl/libxl_types.idl | 3 +++ tools/libxl/xl_cmdimpl.c | 61 ++++++++++++++++++++++++------------------ 7 files changed, 129 insertions(+), 55 deletions(-) diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index ff9ea77..c4a6589 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -304,6 +304,37 @@ Action to take if the domain crashes. Default is C<destroy>. =back +=head3 Direct Kernel Boot + +Direct kernel boot allows booting directly from a kernel and initrd +stored in the host physical machine OS, allowing command line arguments +to be passed directly. PV guest direct kernel boot is supported. HVM +guest direct kernel boot is supported with limitation (it's supported +when using qemu-xen and default BIOS 'seabios'; not supported in case of +stubdom-dm and old rombios.) + +=over 4 + +=item B<kernel="PATHNAME"> + +Load the specified file as the kernel image. + +=item B<ramdisk="PATHNAME"> + +Load the specified file as the ramdisk. + +=item B<root="STRING"> + +Append B<root="STRING"> to the kernel command line (Note: it is guest +specific what meaning this has). + +=item B<extra="STRING"> + +Append B<STRING> to the kernel command line. (Note: it is guest +specific what meaning this has). + +=back + =head3 Other Options =over 4 @@ -646,20 +677,12 @@ The following options apply only to Paravirtual guests. =over 4 -=item B<kernel="PATHNAME"> - -Load the specified file as the kernel image. Either B<kernel> or -B<bootloader> must be specified for PV guests. - -=item B<ramdisk="PATHNAME"> - -Load the specified file as the ramdisk. - =item B<bootloader="PROGRAM"> Run C<PROGRAM> to find the kernel image and ramdisk to use. Normally C<PROGRAM> would be C<pygrub>, which is an emulation of -grub/grub2/syslinux. +grub/grub2/syslinux. Either B<kernel> or B<bootloader> must be specified +for PV guests. =item B<bootloader_args=[ "ARG", "ARG", ...]> @@ -667,16 +690,6 @@ Append B<ARG>s to the arguments to the B<bootloader> program. Alternatively if the argument is a simple string then it will be split into words at whitespace (this second option is deprecated). -=item B<root="STRING"> - -Append B<root="STRING"> to the kernel command line (Note: it is guest -specific what meaning this has). - -=item B<extra="STRING"> - -Append B<STRING> to the kernel command line. Note: it is guest -specific what meaning this has). - =item B<e820_host=BOOLEAN> Selects whether to expose the host e820 (memory map) to the guest via diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 459557d..3a1be8d 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -530,6 +530,21 @@ typedef struct libxl__ctx libxl_ctx; */ #define LIBXL_HAVE_DEVICE_PCI_SEIZE 1 +/* + * LIBXL_HAVE_BUILDINFO_KERNEL + * + * If this is defined, then the libxl_domain_build_info structure will + * contain 'kernel', 'ramdisk', 'cmdline' fields. 'kernel' is a string + * to indicate kernel image location, 'ramdisk' is a string to indicate + * ramdisk location, 'cmdline' is a string to indicate the paramters which + * would be appended to kernel image. + * + * Both PV guest and HVM guest can use these fields for direct kernel boot. + * But for compatibility reason, u.pv.kernel, u.pv.ramdisk and u.pv.cmdline + * still exist. + */ +#define LIBXL_HAVE_BUILDINFO_KERNEL 1 + /* Functions annotated with LIBXL_EXTERNAL_CALLERS_ONLY may not be * called from within libxl itself. Callers outside libxl, who * do not #include libxl_internal.h, are fine. */ diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c index c3ec782..79947d4 100644 --- a/tools/libxl/libxl_bootloader.c +++ b/tools/libxl/libxl_bootloader.c @@ -58,12 +58,12 @@ static void make_bootloader_args(libxl__gc *gc, libxl__bootloader_state *bl, ARG(bootloader_path); - if (info->u.pv.kernel) - ARG(libxl__sprintf(gc, "--kernel=%s", info->u.pv.kernel)); - if (info->u.pv.ramdisk) - ARG(libxl__sprintf(gc, "--ramdisk=%s", info->u.pv.ramdisk)); - if (info->u.pv.cmdline && *info->u.pv.cmdline != '\0') - ARG(libxl__sprintf(gc, "--args=%s", info->u.pv.cmdline)); + if (info->kernel) + ARG(libxl__sprintf(gc, "--kernel=%s", info->kernel)); + if (info->ramdisk) + ARG(libxl__sprintf(gc, "--ramdisk=%s", info->ramdisk)); + if (info->cmdline && *info->cmdline != '\0') + ARG(libxl__sprintf(gc, "--args=%s", info->cmdline)); ARG(libxl__sprintf(gc, "--output=%s", bl->outputpath)); ARG("--output-format=simple0"); @@ -327,9 +327,9 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) if (!info->u.pv.bootloader) { LOG(DEBUG, "no bootloader configured, using user supplied kernel"); - bl->kernel->path = bl->info->u.pv.kernel; - bl->ramdisk->path = bl->info->u.pv.ramdisk; - bl->cmdline = bl->info->u.pv.cmdline; + bl->kernel->path = bl->info->kernel; + bl->ramdisk->path = bl->info->ramdisk; + bl->cmdline = bl->info->cmdline; rc = 0; goto out_ok; } diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 0686f96..d5c3b7d 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -339,6 +339,25 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, b_info->shadow_memkb = 0; if (b_info->u.pv.slack_memkb == LIBXL_MEMKB_DEFAULT) b_info->u.pv.slack_memkb = 0; + + /* For compatibility, fill in b_info->kernel|ramdisk|cmdline + * with the value in u.pv, later processing will use + * b_info->kernel|ramdisk|cmdline only. + * User with old APIs that passes u.pv.kernel|ramdisk|cmdline + * is not affected. + */ + if (!b_info->kernel && b_info->u.pv.kernel) { + b_info->kernel = b_info->u.pv.kernel; + b_info->u.pv.kernel = NULL; + } + if (!b_info->ramdisk && b_info->u.pv.ramdisk) { + b_info->ramdisk = b_info->u.pv.ramdisk; + b_info->u.pv.ramdisk = NULL; + } + if (!b_info->cmdline && b_info->u.pv.cmdline) { + b_info->cmdline = b_info->u.pv.cmdline; + b_info->u.pv.cmdline = NULL; + } break; default: LIBXL__LOG(CTX, LIBXL__LOG_ERROR, diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index addacdb..4f1cbd2 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -196,6 +196,12 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc, int nr_set_cpus = 0; char *s; + if (b_info->kernel) { + LOG(ERROR, "HVM direct kernel boot is not supported by " + "qemu-xen-traditional"); + return NULL; + } + if (b_info->u.hvm.serial) { flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL); } @@ -479,6 +485,15 @@ 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->kernel) + flexarray_vappend(dm_args, "-kernel", b_info->kernel, NULL); + + if (b_info->ramdisk) + flexarray_vappend(dm_args, "-initrd", b_info->ramdisk, NULL); + + if (b_info->cmdline) + flexarray_vappend(dm_args, "-append", b_info->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 de25f42..e02abff 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -340,6 +340,9 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("iomem", Array(libxl_iomem_range, "num_iomem")), ("claim_mode", libxl_defbool), ("event_channels", uint32), + ("kernel", string), + ("cmdline", string), + ("ramdisk", string), ("u", KeyedUnion(None, libxl_domain_type, "type", [("hvm", Struct(None, [("firmware", string), ("bios", libxl_bios_type), diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 68df548..d4cd50b 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -690,6 +690,29 @@ static void parse_top_level_sdl_options(XLU_Config *config, xlu_cfg_replace_string (config, "xauthority", &sdl->xauthority, 0); } +static char *parse_cmdline(XLU_Config *config) +{ + char *cmdline = NULL; + const char *root = NULL, *extra = ""; + + 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); + } + + return cmdline; +} + static void parse_config_data(const char *config_source, const char *config_data, int config_len, @@ -928,13 +951,21 @@ static void parse_config_data(const char *config_source, if (!xlu_cfg_get_long(config, "max_event_channels", &l, 0)) b_info->event_channels = l; + xlu_cfg_replace_string (config, "kernel", &b_info->kernel, 0); + xlu_cfg_replace_string (config, "ramdisk", &b_info->ramdisk, 0); + b_info->cmdline = parse_cmdline(config); + xlu_cfg_get_defbool(config, "driver_domain", &c_info->driver_domain, 0); 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 (!strcmp(libxl_basename(b_info->kernel), "hvmloader")) { + fprintf(stderr, "WARNING: you seem to be using \"kernel\" " + "directive to override HVM guest firmware. Ignore " + "that. Use \"firmware_override\" instead if you " + "really want a non-default firmware\n"); + b_info->kernel = NULL; + } xlu_cfg_replace_string (config, "firmware_override", &b_info->u.hvm.firmware, 0); @@ -1001,26 +1032,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); - 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); - } - xlu_cfg_replace_string (config, "bootloader", &b_info->u.pv.bootloader, 0); switch (xlu_cfg_get_list_as_string_list(config, "bootloader_args", &b_info->u.pv.bootloader_args, 1)) @@ -1043,13 +1054,11 @@ static void parse_config_data(const char *config_source, exit(-ERROR_FAIL); } - if (!b_info->u.pv.bootloader && !b_info->u.pv.kernel) { + if (!b_info->u.pv.bootloader && !b_info->kernel) { fprintf(stderr, "Neither kernel nor bootloader specified\n"); exit(1); } - b_info->u.pv.cmdline = cmdline; - xlu_cfg_replace_string (config, "ramdisk", &b_info->u.pv.ramdisk, 0); break; } default: -- 1.8.4.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [RFC PATCH V5 1/3] xen: pass kernel initrd to qemu 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 1/3] xen: pass kernel initrd to qemu Chunyan Liu @ 2014-07-10 14:48 ` Ian Campbell 2014-11-27 18:14 ` [Qemu-devel] [for 4.5] missing chunk in 11dffa2359e8a2629490c14c029c7c7c777b3e47 Stefano Stabellini 1 sibling, 0 replies; 13+ messages in thread From: Ian Campbell @ 2014-07-10 14:48 UTC (permalink / raw) To: Chunyan Liu; +Cc: xen-devel, Ian.Jackson, qemu-devel, stefano.stabellini On Mon, 2014-07-07 at 14:34 +0800, Chunyan Liu wrote: > xen side patch to support xen HVM direct kernel boot: > support 'kernel', 'ramdisk', 'cmdline' (and 'root', 'extra' as well > which would be deprecated later) in HVM config file, parse config file, > pass -kernel, -initrd, -append parameters to qemu. > > It's working with qemu-xen when using the default BIOS (seabios). > > [HVM config example] > name="sles11_sp2" > description="None" > uuid="5c84adcc-bd59-788a-96d2-195f9b599cfe" > memory=512 > maxmem=512 > vcpus=4 > on_poweroff="destroy" > on_reboot="restart" > on_crash="destroy" > localtime=0 > keymap="en-us" > builder="hvm" > device_model_override="/home/cyliu/git/qemu/x86_64-softmmu/qemu-system-x86_64" > 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/sles11_sp2/disk0.raw,hda,w', ] > vif=[ 'mac=00:16:3e:56:af:69,bridge=br0,type=netfront', ] > stdvga=0 > vnc=1 > vncunused=1 > viridian=0 > acpi=1 > pae=1 > serial="pty" > > > Signed-off-by: Chunyan Liu <cyliu@suse.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> ^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [for 4.5] missing chunk in 11dffa2359e8a2629490c14c029c7c7c777b3e47 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 1/3] xen: pass kernel initrd to qemu Chunyan Liu 2014-07-10 14:48 ` Ian Campbell @ 2014-11-27 18:14 ` Stefano Stabellini 2014-11-28 6:03 ` Chun Yan Liu 1 sibling, 1 reply; 13+ messages in thread From: Stefano Stabellini @ 2014-11-27 18:14 UTC (permalink / raw) To: Chunyan Liu Cc: xen-devel, Wei Liu (Intern), Ian Campbell, stefano.stabellini, Konrad Rzeszutek Wilk, Ian.Jackson, qemu-devel, Anthony.Perard On Mon, 7 Jul 2014, Chunyan Liu wrote: > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > index addacdb..4f1cbd2 100644 > --- a/tools/libxl/libxl_dm.c > +++ b/tools/libxl/libxl_dm.c > @@ -479,6 +485,15 @@ 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->kernel) > + flexarray_vappend(dm_args, "-kernel", b_info->kernel, NULL); > + > + if (b_info->ramdisk) > + flexarray_vappend(dm_args, "-initrd", b_info->ramdisk, NULL); > + > + if (b_info->cmdline) > + flexarray_vappend(dm_args, "-append", b_info->cmdline, NULL); > + > if (b_info->u.hvm.serial) { > flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL); > } This chunk of the patch was never applied to xen-unstable (commit 11dffa2359e8a2629490c14c029c7c7c777b3e47), see http://marc.info/?l=qemu-devel&m=140471493425353&w=2. The feature is broken at the moment. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [for 4.5] missing chunk in 11dffa2359e8a2629490c14c029c7c7c777b3e47 2014-11-27 18:14 ` [Qemu-devel] [for 4.5] missing chunk in 11dffa2359e8a2629490c14c029c7c7c777b3e47 Stefano Stabellini @ 2014-11-28 6:03 ` Chun Yan Liu 0 siblings, 0 replies; 13+ messages in thread From: Chun Yan Liu @ 2014-11-28 6:03 UTC (permalink / raw) To: stefano.stabellini Cc: xen-devel, Wei Liu (Intern), Ian Campbell, Konrad Rzeszutek Wilk, Ian.Jackson, qemu-devel, Anthony.Perard >>> On 11/28/2014 at 02:14 AM, in message <alpine.DEB.2.02.1411271809430.14135@kaball.uk.xensource.com>, Stefano Stabellini <stefano.stabellini@eu.citrix.com> wrote: > On Mon, 7 Jul 2014, Chunyan Liu wrote: > > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > > index addacdb..4f1cbd2 100644 > > --- a/tools/libxl/libxl_dm.c > > +++ b/tools/libxl/libxl_dm.c > > @@ -479,6 +485,15 @@ 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->kernel) > > + flexarray_vappend(dm_args, "-kernel", b_info->kernel, NULL); > > + > > + if (b_info->ramdisk) > > + flexarray_vappend(dm_args, "-initrd", b_info->ramdisk, NULL); > > + > > + if (b_info->cmdline) > > + flexarray_vappend(dm_args, "-append", b_info->cmdline, NULL); > > + > > if (b_info->u.hvm.serial) { > > flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, > NULL); > > } > > This chunk of the patch was never applied to xen-unstable (commit > 11dffa2359e8a2629490c14c029c7c7c777b3e47), see > http://marc.info/?l=qemu-devel&m=140471493425353&w=2. > The feature is broken at the moment. > Thanks very much. Didn't notice that. Resend the missing part of patch. > ^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [RFC PATCH V5 2/3] xl.cfg: add 'cmdline' in config file 2014-07-07 6:34 [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot Chunyan Liu 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 1/3] xen: pass kernel initrd to qemu Chunyan Liu @ 2014-07-07 6:34 ` Chunyan Liu 2014-07-10 14:49 ` Ian Campbell 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 3/3] qemu: support xen hvm direct kernel boot Chunyan Liu 2014-07-10 15:12 ` [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM " Ian Campbell 3 siblings, 1 reply; 13+ messages in thread From: Chunyan Liu @ 2014-07-07 6:34 UTC (permalink / raw) To: xen-devel, qemu-devel Cc: Chunyan Liu, Ian.Jackson, Ian.Campbell, stefano.stabellini Currently in xl.cfg, use 'root' and 'extra' to generate the command line. 'cmdline' could be a more generic equivalent. So, add 'cmdline' in xl.cfg and let it be preferred. 'root' and 'extra' still works. But when 'cmdline' is specified, 'root' and 'extra' will be ignored. [HVM config example] [snip] builder="hvm" device_model_override="/home/cyliu/git/qemu/x86_64-softmmu/qemu-system-x86_64" 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" [snip] or: [snip] builder="hvm" device_model_override="/home/cyliu/git/qemu/x86_64-softmmu/qemu-system-x86_64" kernel="/mnt/vmlinuz-3.0.13-0.27-default" ramdisk="/mnt/initrd-3.0.13-0.27-default" cmdline="root=/dev/hda2 console=tty0 console=ttyS0" [snip] Signed-off-by: Chunyan Liu <cyliu@suse.com> --- Changes: - add back the 'cmdline' in xl.cfg, but as separate patch docs/man/xl.cfg.pod.5 | 7 +++++++ tools/libxl/xl_cmdimpl.c | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index c4a6589..cb5b76b 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -323,6 +323,13 @@ Load the specified file as the kernel image. Load the specified file as the ramdisk. +=item B<cmdline="STRING"> + +Append B<cmdline="STRING"> to the kernel command line. (Note: it is +guest specific what meaning this has). It can replace B<root="STRING"> +plus B<extra="STRING"> and is preferred. When B<cmdline="STRING"> is set, +B<root="STRING"> and B<extra="STRING"> will be ignored. + =item B<root="STRING"> Append B<root="STRING"> to the kernel command line (Note: it is guest diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index d4cd50b..cfe13e3 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -693,19 +693,27 @@ static void parse_top_level_sdl_options(XLU_Config *config, static char *parse_cmdline(XLU_Config *config) { char *cmdline = NULL; - const char *root = NULL, *extra = ""; + const char *root = NULL, *extra = NULL, *buf = NULL; + xlu_cfg_get_string (config, "cmdline", &buf, 0); 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; + if (buf) { + cmdline = strdup(buf); + if (root || extra) + fprintf(stderr, "Warning: ignoring root= and extra= " + "in favour of cmdline=\n"); } else { - cmdline = strdup(extra); + if (root) { + if (asprintf(&cmdline, "root=%s %s", root, extra) == -1) + cmdline = NULL; + } else if (extra) { + cmdline = strdup(extra); + } } - if ((root || extra) && !cmdline) { + if ((buf || root || extra) && !cmdline) { fprintf(stderr, "Failed to allocate memory for cmdline\n"); exit(1); } -- 1.8.4.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [RFC PATCH V5 2/3] xl.cfg: add 'cmdline' in config file 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 2/3] xl.cfg: add 'cmdline' in config file Chunyan Liu @ 2014-07-10 14:49 ` Ian Campbell 0 siblings, 0 replies; 13+ messages in thread From: Ian Campbell @ 2014-07-10 14:49 UTC (permalink / raw) To: Chunyan Liu; +Cc: xen-devel, Ian.Jackson, qemu-devel, stefano.stabellini On Mon, 2014-07-07 at 14:34 +0800, Chunyan Liu wrote: > Currently in xl.cfg, use 'root' and 'extra' to generate the command > line. 'cmdline' could be a more generic equivalent. So, add 'cmdline' > in xl.cfg and let it be preferred. 'root' and 'extra' still works. > But when 'cmdline' is specified, 'root' and 'extra' will be ignored. > > [HVM config example] > [snip] > builder="hvm" > device_model_override="/home/cyliu/git/qemu/x86_64-softmmu/qemu-system-x86_64" > 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" > [snip] > > or: > > [snip] > builder="hvm" > device_model_override="/home/cyliu/git/qemu/x86_64-softmmu/qemu-system-x86_64" > kernel="/mnt/vmlinuz-3.0.13-0.27-default" > ramdisk="/mnt/initrd-3.0.13-0.27-default" > cmdline="root=/dev/hda2 console=tty0 console=ttyS0" > [snip] > > > Signed-off-by: Chunyan Liu <cyliu@suse.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> ^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [RFC PATCH V5 3/3] qemu: support xen hvm direct kernel boot 2014-07-07 6:34 [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot Chunyan Liu 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 1/3] xen: pass kernel initrd to qemu Chunyan Liu 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 2/3] xl.cfg: add 'cmdline' in config file Chunyan Liu @ 2014-07-07 6:34 ` Chunyan Liu 2014-07-10 15:12 ` [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM " Ian Campbell 3 siblings, 0 replies; 13+ messages in thread From: Chunyan Liu @ 2014-07-07 6:34 UTC (permalink / raw) To: xen-devel, qemu-devel Cc: Chunyan Liu, Ian.Jackson, Ian.Campbell, stefano.stabellini qemu side patch to support xen HVM direct kernel boot: if -kernel exists, calls xen_load_linux(), which will read kernel/initrd and add a linuxboot.bin or multiboot.bin option rom. The linuxboot.bin/multiboot.bin will load kernel/initrd and jump to execute kernel directly. It's working when xen uses seabios. During this work, found the 'kvmvapic' is in option_rom list, it should not be there in xen case. Set s->vapic_control = 0 in xen_apic_realize() to handle that. Signed-off-by: Chunyan Liu <cyliu@suse.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> --- hw/i386/pc.c | 25 +++++++++++++++++++++++++ hw/i386/pc_piix.c | 7 +++++++ hw/i386/xen/xen_apic.c | 1 + include/hw/i386/pc.h | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2cf22b1..9e58982 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1190,6 +1190,31 @@ void pc_acpi_init(const char *default_dsdt) } } +FWCfgState *xen_load_linux(const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + ram_addr_t below_4g_mem_size, + PcGuestInfo *guest_info) +{ + int i; + FWCfgState *fw_cfg; + + assert(kernel_filename != NULL); + + fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0); + rom_set_fw(fw_cfg); + + load_linux(fw_cfg, kernel_filename, initrd_filename, + kernel_cmdline, below_4g_mem_size); + for (i = 0; i < nb_option_roms; i++) { + assert(!strcmp(option_rom[i].name, "linuxboot.bin") || + !strcmp(option_rom[i].name, "multiboot.bin")); + rom_add_option(option_rom[i].name, option_rom[i].bootindex); + } + guest_info->fw_cfg = fw_cfg; + return fw_cfg; +} + FWCfgState *pc_memory_init(MachineState *machine, MemoryRegion *system_memory, ram_addr_t below_4g_mem_size, diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 2dccb34..63e2198 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -180,6 +180,13 @@ static void pc_init1(MachineState *machine, fw_cfg = pc_memory_init(machine, system_memory, below_4g_mem_size, above_4g_mem_size, rom_memory, &ram_memory, guest_info); + } else if (machine->kernel_filename != NULL) { + /* For xen HVM direct kernel boot, load linux here */ + fw_cfg = xen_load_linux(machine->kernel_filename, + machine->kernel_cmdline, + machine->initrd_filename, + below_4g_mem_size, + guest_info); } gsi_state = g_malloc0(sizeof(*gsi_state)); diff --git a/hw/i386/xen/xen_apic.c b/hw/i386/xen/xen_apic.c index 63bb7f7..f5acd6a 100644 --- a/hw/i386/xen/xen_apic.c +++ b/hw/i386/xen/xen_apic.c @@ -40,6 +40,7 @@ static void xen_apic_realize(DeviceState *dev, Error **errp) { APICCommonState *s = APIC_COMMON(dev); + s->vapic_control = 0; memory_region_init_io(&s->io_memory, OBJECT(s), &xen_apic_io_ops, s, "xen-apic-msi", APIC_SPACE_SIZE); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 1c0c382..b47aaa9 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -187,6 +187,11 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size, void pc_pci_as_mapping_init(Object *owner, MemoryRegion *system_memory, MemoryRegion *pci_address_space); +FWCfgState *xen_load_linux(const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + ram_addr_t below_4g_mem_size, + PcGuestInfo *guest_info); FWCfgState *pc_memory_init(MachineState *machine, MemoryRegion *system_memory, ram_addr_t below_4g_mem_size, -- 1.8.4.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot 2014-07-07 6:34 [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot Chunyan Liu ` (2 preceding siblings ...) 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 3/3] qemu: support xen hvm direct kernel boot Chunyan Liu @ 2014-07-10 15:12 ` Ian Campbell 2014-07-10 15:14 ` Stefano Stabellini 3 siblings, 1 reply; 13+ messages in thread From: Ian Campbell @ 2014-07-10 15:12 UTC (permalink / raw) To: Chunyan Liu; +Cc: xen-devel, Ian.Jackson, qemu-devel, stefano.stabellini On Mon, 2014-07-07 at 14:34 +0800, Chunyan Liu wrote: > Updated current patch series for working with qemu-xen and default > BIOS (seabios), to make it in good shape. Stubdom support will be > continued. This series is all acked and hasn't really felt RFC for a few iterations now. I suppose the xen side stuff really ought to wait for the qemu side to be accepted, which in turn is waiting for qemu's freeze to finish and a new development cycle to open. Does that sound right? Ian. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot 2014-07-10 15:12 ` [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM " Ian Campbell @ 2014-07-10 15:14 ` Stefano Stabellini 2014-08-04 17:26 ` Stefano Stabellini 0 siblings, 1 reply; 13+ messages in thread From: Stefano Stabellini @ 2014-07-10 15:14 UTC (permalink / raw) To: Ian Campbell Cc: xen-devel, Ian.Jackson, Chunyan Liu, stefano.stabellini, qemu-devel On Thu, 10 Jul 2014, Ian Campbell wrote: > On Mon, 2014-07-07 at 14:34 +0800, Chunyan Liu wrote: > > Updated current patch series for working with qemu-xen and default > > BIOS (seabios), to make it in good shape. Stubdom support will be > > continued. > > This series is all acked and hasn't really felt RFC for a few iterations > now. > > I suppose the xen side stuff really ought to wait for the qemu side to > be accepted, which in turn is waiting for qemu's freeze to finish and a > new development cycle to open. Does that sound right? Yep. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot 2014-07-10 15:14 ` Stefano Stabellini @ 2014-08-04 17:26 ` Stefano Stabellini 2014-08-26 21:02 ` Ian Campbell 0 siblings, 1 reply; 13+ messages in thread From: Stefano Stabellini @ 2014-08-04 17:26 UTC (permalink / raw) To: Stefano Stabellini Cc: qemu-devel, xen-devel, Ian.Jackson, Ian Campbell, Chunyan Liu On Thu, 10 Jul 2014, Stefano Stabellini wrote: > On Thu, 10 Jul 2014, Ian Campbell wrote: > > On Mon, 2014-07-07 at 14:34 +0800, Chunyan Liu wrote: > > > Updated current patch series for working with qemu-xen and default > > > BIOS (seabios), to make it in good shape. Stubdom support will be > > > continued. > > > > This series is all acked and hasn't really felt RFC for a few iterations > > now. > > > > I suppose the xen side stuff really ought to wait for the qemu side to > > be accepted, which in turn is waiting for qemu's freeze to finish and a > > new development cycle to open. Does that sound right? > > Yep. > The patches are both in QEMU and qemu-upstream-unstable. You can go ahead with the tools patches. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot 2014-08-04 17:26 ` Stefano Stabellini @ 2014-08-26 21:02 ` Ian Campbell 2014-08-27 3:26 ` Chun Yan Liu 0 siblings, 1 reply; 13+ messages in thread From: Ian Campbell @ 2014-08-26 21:02 UTC (permalink / raw) To: Stefano Stabellini; +Cc: xen-devel, Ian.Jackson, Chunyan Liu, qemu-devel On Mon, 2014-08-04 at 18:26 +0100, Stefano Stabellini wrote: > The patches are both in QEMU and qemu-upstream-unstable. > You can go ahead with the tools patches. Done. There was some fuzz on the first patch (no doubt due to the delay in apply, sorry) which I resolved, Chunyan please do check I didn't mess it up. Ian. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot 2014-08-26 21:02 ` Ian Campbell @ 2014-08-27 3:26 ` Chun Yan Liu 0 siblings, 0 replies; 13+ messages in thread From: Chun Yan Liu @ 2014-08-27 3:26 UTC (permalink / raw) To: Ian Campbell, Stefano Stabellini; +Cc: xen-devel, Ian.Jackson, qemu-devel >>> On 8/27/2014 at 05:02 AM, in message <1409086964.28009.45.camel@citrix.com>, Ian Campbell <ian.campbell@citrix.com> wrote: > On Mon, 2014-08-04 at 18:26 +0100, Stefano Stabellini wrote: > > The patches are both in QEMU and qemu-upstream-unstable. > > You can go ahead with the tools patches. > > Done. There was some fuzz on the first patch (no doubt due to the delay > in apply, sorry) which I resolved, Chunyan please do check I didn't mess > it up. Sure. Will check. Thanks! - Chunyan > > Ian. > > > ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-11-28 6:03 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-07-07 6:34 [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM direct kernel boot Chunyan Liu 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 1/3] xen: pass kernel initrd to qemu Chunyan Liu 2014-07-10 14:48 ` Ian Campbell 2014-11-27 18:14 ` [Qemu-devel] [for 4.5] missing chunk in 11dffa2359e8a2629490c14c029c7c7c777b3e47 Stefano Stabellini 2014-11-28 6:03 ` Chun Yan Liu 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 2/3] xl.cfg: add 'cmdline' in config file Chunyan Liu 2014-07-10 14:49 ` Ian Campbell 2014-07-07 6:34 ` [Qemu-devel] [RFC PATCH V5 3/3] qemu: support xen hvm direct kernel boot Chunyan Liu 2014-07-10 15:12 ` [Qemu-devel] [RFC PATCH V5 0/3] Support xen HVM " Ian Campbell 2014-07-10 15:14 ` Stefano Stabellini 2014-08-04 17:26 ` Stefano Stabellini 2014-08-26 21:02 ` Ian Campbell 2014-08-27 3:26 ` Chun Yan Liu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).