From: Chunyan Liu <cyliu@suse.com>
To: xen-devel@lists.xensource.com
Cc: Chunyan Liu <cyliu@suse.com>,
qemu-devel@nongnu.org, pasik@iki.fi, Ian.Campbell@citrix.com
Subject: [RFC PATCH 1/2] xen: pass kernel initrd to qemu
Date: Thu, 29 May 2014 11:23:23 +0800 [thread overview]
Message-ID: <1401333804-15456-2-git-send-email-cyliu@suse.com> (raw)
In-Reply-To: <1401333804-15456-1-git-send-email-cyliu@suse.com>
[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@suse.com>
---
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
next prev parent reply other threads:[~2014-05-29 3:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 3:23 [RFC PATCH 0/2] support xen HVM direct kernel boot Chunyan Liu
2014-05-29 3:23 ` Chunyan Liu [this message]
2014-06-02 15:24 ` [RFC PATCH 1/2] xen: pass kernel initrd to qemu Ian Campbell
2014-06-03 4:49 ` [Xen-devel] " Chun Yan Liu
2014-06-03 9:06 ` Ian Campbell
2014-06-03 9:18 ` Chun Yan Liu
2014-05-29 3:23 ` [RFC PATCH 2/2] qemu: support xen hvm direct kernel boot Chunyan Liu
2014-05-29 8:23 ` Paolo Bonzini
2014-06-03 4:59 ` [Xen-devel] " Chun Yan Liu
2014-05-30 16:04 ` [Xen-devel] [RFC PATCH 0/2] support xen HVM " Konrad Rzeszutek Wilk
2014-06-02 15:14 ` Stefano Stabellini
2014-06-03 9:16 ` Chun Yan Liu
2014-06-03 9:31 ` [Qemu-devel] " Ian Campbell
2014-06-03 10:20 ` [Xen-devel] " Chun Yan Liu
2014-06-03 11:32 ` Stefano Stabellini
2014-06-02 15:19 ` Ian Campbell
2014-06-02 16:58 ` Konrad Rzeszutek Wilk
2014-06-03 3:35 ` Chun Yan Liu
2014-06-03 9:04 ` Ian Campbell
2014-06-03 9:24 ` Chun Yan Liu
2014-06-03 8:59 ` [Xen-devel] " Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401333804-15456-2-git-send-email-cyliu@suse.com \
--to=cyliu@suse.com \
--cc=Ian.Campbell@citrix.com \
--cc=pasik@iki.fi \
--cc=qemu-devel@nongnu.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).