Jiageng Yu
2011-May-31 13:54 UTC
[Xen-devel] [PATCH] libxl: Support linux-stubdom in libxl
author jiageng_yu <yujiageng734@gmail.com> Tue, 31 May 2011 02:18:01 +0000 (03:18 +0100) committer jiageng_yu <yujiageng734@gmail.com> ue, 31 May 2011 02:18:01 +0000 (03:18 +0100) commit 179b4167dd9e86a06a700d60e277c4477f0c06ef tree 4e4c8492b480e08d9122abcb37aca52ae5650786 tree | snapshot (tar.gz zip) parent cf4866b9161a724e4b2c366da73de271cf7ef348 commit | diff libxl: Support linux-stubdom in libxl Add linux-stubdom support in libxl. Users could start a linux-stubdom throuh the following options: device_model_override = ''linux-stubdom'' device_model_stubdomain_override=1 linux-stubdom project: http://repo.or.cz/w/linux-based-stubdoms.git diff -r 37c77bacb52a tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon May 23 17:38:28 2011 +0100 +++ b/tools/libxl/libxl_dm.c Tue May 31 02:41:59 2011 +0100 @@ -556,6 +556,14 @@ return 0; } +inline int libxl__is_linux_stubdom(libxl_device_model_info *info) +{ + if(!strncmp(info->device_model,"linux-stubdom",strlen(info->device_model))) + return 1; + else + return 0; +}; + static int libxl__create_stubdom(libxl__gc *gc, libxl_device_model_info *info, libxl_device_disk *disks, int num_disks, @@ -581,7 +589,12 @@ goto out; } - args = libxl__build_device_model_args(gc, "stubdom-dm", info, + if(libxl__is_linux_stubdom(info)) + args = libxl__build_device_model_args(gc, "linux-stubdom", info, + disks, num_disks, + vifs, num_vifs); + else + args = libxl__build_device_model_args(gc, "stubdom-dm", info, disks, num_disks, vifs, num_vifs); if (!args) { @@ -599,13 +612,22 @@ b_info.max_vcpus = 1; b_info.max_memkb = 32 * 1024; b_info.target_memkb = b_info.max_memkb; - b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", - libxl_xenfirmwaredir_path()); b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid); - b_info.u.pv.ramdisk.path = ""; b_info.u.pv.features = ""; b_info.hvm = 0; + if(libxl__is_linux_stubdom(info)){ + b_info.u.pv.kernel.path = libxl__abs_path(gc, "vmlinuz-ioemu", + libxl_xenfirmwaredir_path()); + b_info.u.pv.ramdisk.path = libxl__abs_path(gc, "ramdisk-ioemu", + libxl_xenfirmwaredir_path()); + } + else{ + b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", + libxl_xenfirmwaredir_path()); + b_info.u.pv.ramdisk.path = ""; + } + /* fixme: this function can leak the stubdom if it fails */ ret = libxl__domain_make(gc, &c_info, &domid); diff -r 37c77bacb52a tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon May 23 17:38:28 2011 +0100 +++ b/tools/libxl/libxl_internal.h Tue May 31 02:41:59 2011 +0100 @@ -249,6 +249,7 @@ libxl__domain_build_state *state); /* for device model creation */ +_hidden int libxl__is_linux_stubdom(libxl_device_model_info *info); _hidden const char *libxl__domain_device_model(libxl__gc *gc, libxl_device_model_info *info); _hidden int libxl__create_device_model(libxl__gc *gc, diff -r 37c77bacb52a tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon May 23 17:38:28 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Tue May 31 02:41:59 2011 +0100 @@ -1087,7 +1087,7 @@ fprintf(stderr, "WARNING: ignoring device_model directive.\n" "WARNING: Use \"device_model_override\" instead if you really want a non-default device_model\n"); - if (strstr(buf, "stubdom-dm")) + if (strstr(buf, "stubdom-dm") || strstr(buf, "linux-stubdom")) fprintf(stderr, "WARNING: Or use \"device_model_stubdomain_override\" if you want to enable stubdomains\n"); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Stefano Stabellini
2011-May-31 14:38 UTC
[Xen-devel] Re: [PATCH] libxl: Support linux-stubdom in libxl
On Tue, 31 May 2011, Jiageng Yu wrote:> author jiageng_yu <yujiageng734@gmail.com> > Tue, 31 May 2011 02:18:01 +0000 (03:18 +0100) > committer jiageng_yu <yujiageng734@gmail.com> > ue, 31 May 2011 02:18:01 +0000 (03:18 +0100) > commit 179b4167dd9e86a06a700d60e277c4477f0c06ef > tree 4e4c8492b480e08d9122abcb37aca52ae5650786 tree | snapshot (tar.gz zip) > parent cf4866b9161a724e4b2c366da73de271cf7ef348 commit | diff > > libxl: Support linux-stubdom in libxl > > Add linux-stubdom support in libxl. Users could start a linux-stubdom > throuh the following options: > device_model_override = ''linux-stubdom'' > device_model_stubdomain_override=1 >I would avoid using device_model_override to select linux stubdoms: device_model_override is used to specify a path to a qemu binary and it is better to keep it that way. I would rather introduce a new boolean config option, for example device_model_linux_stubdomain_override.> linux-stubdom project: http://repo.or.cz/w/linux-based-stubdoms.git > > > diff -r 37c77bacb52a tools/libxl/libxl_dm.c > --- a/tools/libxl/libxl_dm.c Mon May 23 17:38:28 2011 +0100 > +++ b/tools/libxl/libxl_dm.c Tue May 31 02:41:59 2011 +0100 > @@ -556,6 +556,14 @@ > return 0; > } > > +inline int libxl__is_linux_stubdom(libxl_device_model_info *info) > +{ > + if(!strncmp(info->device_model,"linux-stubdom",strlen(info->device_model))) > + return 1; > + else > + return 0; > +}; > +Same as before: it is better to avoid parsing the device model string here. I would rather change device_model_stubdomain to be an enum so that it can specify: "no stubdom", "MiniOS stubdom", "Linux stubdom". _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jun-01 12:58 UTC
Re: [Xen-devel] [PATCH] libxl: Support linux-stubdom in libxl
On Tue, 2011-05-31 at 14:54 +0100, Jiageng Yu wrote:> @@ -581,7 +589,12 @@ > goto out; > } > > - args = libxl__build_device_model_args(gc, "stubdom-dm", info, > + if(libxl__is_linux_stubdom(info))Please try and match the indentation level (incl tab vs spaces) of the surrounding code. You should probably checkout tools/libxl/CODING_STYLE. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jiageng Yu
2011-Jun-02 13:40 UTC
Re: [Xen-devel] [PATCH] libxl: Support linux-stubdom in libxl
That is new patch for libxl. diff -r 37c77bacb52a tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon May 23 17:38:28 2011 +0100 +++ b/tools/libxl/libxl.c Wed Jun 01 03:24:57 2011 +0100 @@ -2078,7 +2078,8 @@ *need_memkb = b_info->target_memkb; if (b_info->hvm) { *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY; - if (dm_info->device_model_stubdomain) + if (dm_info->device_model_stubdomain || + dm_info->device_model_linux_stubdomain) *need_memkb += 32 * 1024; } else *need_memkb += b_info->shadow_memkb + LIBXL_PV_EXTRA_MEMORY; diff -r 37c77bacb52a tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Mon May 23 17:38:28 2011 +0100 +++ b/tools/libxl/libxl.idl Wed Jun 01 03:24:57 2011 +0100 @@ -196,6 +196,7 @@ ("dom_name", string), ("device_model_version", libxl_device_model_version), ("device_model_stubdomain", bool), + ("device_model_linux_stubdomain", bool), ("device_model", string, False, "if you set this you must set device_model_version too"), ("saved_state", string), ("type", libxl_domain_type), diff -r 37c77bacb52a tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon May 23 17:38:28 2011 +0100 +++ b/tools/libxl/libxl_create.c Wed Jun 01 03:24:57 2011 +0100 @@ -110,6 +110,7 @@ dm_info->dom_name = strdup(c_info->name); dm_info->device_model_version LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL; dm_info->device_model_stubdomain = false; + dm_info->device_model_linux_stubdomain = false; dm_info->device_model = NULL; dm_info->target_ram = libxl__sizekb_to_mb(b_info->target_memkb); dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb); diff -r 37c77bacb52a tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon May 23 17:38:28 2011 +0100 +++ b/tools/libxl/libxl_dm.c Wed Jun 01 03:24:57 2011 +0100 @@ -44,7 +44,8 @@ libxl_ctx *ctx = libxl__gc_owner(gc); const char *dm; - if (info->device_model_stubdomain) + if (info->device_model_stubdomain || + info->device_model_linux_stubdomain) return NULL; if (info->device_model) { @@ -571,7 +572,7 @@ libxl_domain_build_info b_info; libxl__domain_build_state state; uint32_t domid; - char **args; + char **args=NULL; struct xs_permissions perm[2]; xs_transaction_t t; libxl__device_model_starting *dm_starting = 0; @@ -581,7 +582,12 @@ goto out; } - args = libxl__build_device_model_args(gc, "stubdom-dm", info, + if(info->device_model_stubdomain) + args = libxl__build_device_model_args(gc, "stubdom-dm", info, + disks, num_disks, + vifs, num_vifs); + if(info->device_model_linux_stubdomain) + args = libxl__build_device_model_args(gc, "linux-stubdom", info, disks, num_disks, vifs, num_vifs); if (!args) { @@ -599,13 +605,22 @@ b_info.max_vcpus = 1; b_info.max_memkb = 32 * 1024; b_info.target_memkb = b_info.max_memkb; - b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", - libxl_xenfirmwaredir_path()); b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid); - b_info.u.pv.ramdisk.path = ""; b_info.u.pv.features = ""; b_info.hvm = 0; + if(info->device_model_linux_stubdomain){ + b_info.u.pv.kernel.path = libxl__abs_path(gc, "vmlinuz-ioemu", + libxl_xenfirmwaredir_path()); + b_info.u.pv.ramdisk.path = libxl__abs_path(gc, "ramdisk-ioemu", + libxl_xenfirmwaredir_path()); + } else if(info->device_model_stubdomain){ + b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", + libxl_xenfirmwaredir_path()); + b_info.u.pv.ramdisk.path = ""; + } + /* fixme: this function can leak the stubdom if it fails */ ret = libxl__domain_make(gc, &c_info, &domid); @@ -745,7 +760,8 @@ char **pass_stuff; const char *dm; - if (info->device_model_stubdomain) { + if (info->device_model_stubdomain || + info->device_model_linux_stubdomain) { libxl_device_vfb vfb; libxl_device_vkb vkb; diff -r 37c77bacb52a tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon May 23 17:38:28 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Jun 01 03:24:57 2011 +0100 @@ -1109,6 +1109,8 @@ fprintf(stderr, "WARNING: device model override given without specific DM version\n"); if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l)) dm_info->device_model_stubdomain = l; + if (!xlu_cfg_get_long (config, "device_model_linux_stubdomain_override", &l)) + dm_info->device_model_linux_stubdomain = l; if (!xlu_cfg_get_long (config, "stdvga", &l)) dm_info->stdvga = l; if (!xlu_cfg_get_long (config, "vnc", &l)) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jun-02 14:25 UTC
Re: [Xen-devel] [PATCH] libxl: Support linux-stubdom in libxl
On Thu, 2011-06-02 at 14:40 +0100, Jiageng Yu wrote:> diff -r 37c77bacb52a tools/libxl/libxl.idl > --- a/tools/libxl/libxl.idl Mon May 23 17:38:28 2011 +0100 > +++ b/tools/libxl/libxl.idl Wed Jun 01 03:24:57 2011 +0100 > @@ -196,6 +196,7 @@ > ("dom_name", string), > ("device_model_version", libxl_device_model_version), > ("device_model_stubdomain", bool), > + ("device_model_linux_stubdomain", bool), > ("device_model", string, False, "if you set this you must set device_model_version too"), > ("saved_state", string), > ("type", libxl_domain_type),I think what we actually want here is a single device_model_type Enumeration, values are something like "process", "stub-linux", "stub-minios", rather than multiple device_model_XXX_stubdom booleans. I''m not convinced device_model_type is a good name, hopefully someone can suggest something better. (device_model_mode??) Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Stefano Stabellini
2011-Jun-02 14:31 UTC
Re: [Xen-devel] [PATCH] libxl: Support linux-stubdom in libxl
On Thu, 2 Jun 2011, Ian Campbell wrote:> On Thu, 2011-06-02 at 14:40 +0100, Jiageng Yu wrote: > > diff -r 37c77bacb52a tools/libxl/libxl.idl > > --- a/tools/libxl/libxl.idl Mon May 23 17:38:28 2011 +0100 > > +++ b/tools/libxl/libxl.idl Wed Jun 01 03:24:57 2011 +0100 > > @@ -196,6 +196,7 @@ > > ("dom_name", string), > > ("device_model_version", libxl_device_model_version), > > ("device_model_stubdomain", bool), > > + ("device_model_linux_stubdomain", bool), > > ("device_model", string, False, "if you set this you must set device_model_version too"), > > ("saved_state", string), > > ("type", libxl_domain_type), > > I think what we actually want here is a single device_model_type > Enumeration, values are something like "process", "stub-linux", > "stub-minios", rather than multiple device_model_XXX_stubdom booleans.indeed> I''m not convinced device_model_type is a good name, hopefully someone > can suggest something better. (device_model_mode??)some suggestions: 1) device_model_class 2) device_model_deployment 3) device_model_instance I vote for 3) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jun-02 14:35 UTC
Re: [Xen-devel] [PATCH] libxl: Support linux-stubdom in libxl
On Thu, 2011-06-02 at 15:31 +0100, Stefano Stabellini wrote:> On Thu, 2 Jun 2011, Ian Campbell wrote: > > On Thu, 2011-06-02 at 14:40 +0100, Jiageng Yu wrote: > > > diff -r 37c77bacb52a tools/libxl/libxl.idl > > > --- a/tools/libxl/libxl.idl Mon May 23 17:38:28 2011 +0100 > > > +++ b/tools/libxl/libxl.idl Wed Jun 01 03:24:57 2011 +0100 > > > @@ -196,6 +196,7 @@ > > > ("dom_name", string), > > > ("device_model_version", libxl_device_model_version), > > > ("device_model_stubdomain", bool), > > > + ("device_model_linux_stubdomain", bool), > > > ("device_model", string, False, "if you set this you must set device_model_version too"), > > > ("saved_state", string), > > > ("type", libxl_domain_type), > > > > I think what we actually want here is a single device_model_type > > Enumeration, values are something like "process", "stub-linux", > > "stub-minios", rather than multiple device_model_XXX_stubdom booleans. > > indeed > > > > I''m not convinced device_model_type is a good name, hopefully someone > > can suggest something better. (device_model_mode??) > > some suggestions: > > 1) device_model_class > 2) device_model_deployment > 3) device_model_instance > > I vote for 3)I don''t think deployment or instance has the right meaning here. class is better but still doesn''t feel right. maybe ..._mode? </bikeshed> Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
ZhouPeng
2011-Jun-06 11:56 UTC
Re: [Xen-devel] [PATCH] libxl: Support linux-stubdom in libxl
I think class is better than mode? ''Mode'' is somewhat misleading to new newbie? It seem be telling there is one device model instance, which has mutiple working mode. Just like kernel mode or user mode to describe one OS‘s current working mode. 1) device_model_class 2) device_model_deployment 3) device_model_instance 4) device_model_mode If I have one vote for all the above chances, I will select ''...class'' :) And I suggest one : device_modele_mechanism :) 2011/6/2 Ian Campbell <Ian.Campbell@eu.citrix.com>:> On Thu, 2011-06-02 at 15:31 +0100, Stefano Stabellini wrote: >> On Thu, 2 Jun 2011, Ian Campbell wrote: >> > On Thu, 2011-06-02 at 14:40 +0100, Jiageng Yu wrote: >> > > diff -r 37c77bacb52a tools/libxl/libxl.idl >> > > --- a/tools/libxl/libxl.idl Mon May 23 17:38:28 2011 +0100 >> > > +++ b/tools/libxl/libxl.idl Wed Jun 01 03:24:57 2011 +0100 >> > > @@ -196,6 +196,7 @@ >> > > ("dom_name", string), >> > > ("device_model_version", libxl_device_model_version), >> > > ("device_model_stubdomain", bool), >> > > + ("device_model_linux_stubdomain", bool), >> > > ("device_model", string, False, "if you set this you must set device_model_version too"), >> > > ("saved_state", string), >> > > ("type", libxl_domain_type), >> > >> > I think what we actually want here is a single device_model_type >> > Enumeration, values are something like "process", "stub-linux", >> > "stub-minios", rather than multiple device_model_XXX_stubdom booleans. >> >> indeed >> >> >> > I''m not convinced device_model_type is a good name, hopefully someone >> > can suggest something better. (device_model_mode??) >> >> some suggestions: >> >> 1) device_model_class >> 2) device_model_deployment >> 3) device_model_instance >> >> I vote for 3) > > I don''t think deployment or instance has the right meaning here. class > is better but still doesn''t feel right. > > maybe ..._mode? > > </bikeshed> > > Ian. > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel >-- Zhou Peng Operating System Technology Group Institute of Software, the Chinese Academy of Sciences (ISCAS) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel