: patch_libxl_get_console_tty.diff
PATCH 1/1 : patch_libxl_get_console_tty.diff
tools/libxl/libxl.c +25 -0
@@ -15,6 +15,8 @@*/ #include "libxl_osdeps.h" +//#include "libxl_osdeps.h" +//#include "libxl_osdeps.h" #include "libxl_internal.h"
@@ -1173,6 +1175,29 @@ int libxl_primary_console_exec(libxl_ctxreturn rc; } +int libxl_get_console_tty (libxl_ctx *ctx,uint32_t domid,char **path) +{ +GC_INIT (ctx); +char *dom_path =0 ; +char *tty_path =0 , *os_type_path =0 , *vm_uuid_path =0 ; +char *tty =0 , *os_type =0 , *vm_uuid =0 ; + + dom_path =libxl__xs_get_dompath (gc, domid); + vm_uuid_path =libxl__sprintf (gc,"%s/vm" , dom_path); + vm_uuid =libxl__xs_read (gc,XBT_NULL , vm_uuid_path); + os_type_path =libxl__sprintf (gc,"%s/image/ostype" , vm_uuid); + os_type =libxl__xs_read (gc,XBT_NULL , os_type_path); +if ( !strcmp ("hvm" , os_type)) { + tty_path =libxl__sprintf (gc,"%s/serial/0/tty" , dom_path); + }else { + tty_path =libxl__sprintf (gc,"%s/console/tty" , dom_path); + } + tty =libxl__xs_read (gc,XBT_NULL , tty_path); + *path =strdup (tty); +GC_FREE ; +return 0 ; +} +int libxl_vncviewer_exec (libxl_ctx *ctx,uint32_t domid,int autopass) {GC_INIT (ctx);
tools/libxl/libxl.h +4 -0
@@ -534,6 +534,10 @@ int libxl_console_exec(libxl_ctx *ctx, u* case of HVM guests, and before libxl_run_bootloader in case of PV * guests using pygrub. */ int libxl_primary_console_exec (libxl_ctx *ctx,uint32_t domid_vm); +/* libxl_get_console_tty get the tty path from xenstore according to the +* domain id. +*/ +int libxl_get_console_tty (libxl_ctx *ctx,uint32_t domid,char **path);/* May be called with info_r == NULL to check for domain's existance */ int libxl_domain_info(libxl_ctx*, libxl_dominfo *info_r,
Bamvor Jian Zhang writes ("[Xen-devel] [PATCH] [mq]: patch_libxl_get_console_tty.diff"):
tools/libxl/libxl.c line 19
Quoted 9 lines
diff -r
9dda0efd8ce1-r4a6043e1434atools/libxl/libxl.ctools/libxl/libxl.c +2
-0@@ -15,6 +15,8 @@*/ #include "libxl_osdeps.h" +//#include "libxl_osdeps.h" +//#include "libxl_osdeps.h"
Thanks for posting this but was int actually inteded for inclusion in the tree ? If so we need a commit message and a Signed-off-by and so forth. Also we may be too late for 4.2 considering the feature freeze.
tools/libxl/libxl.c int libxl_primary_console_exec(libxl_ctx · line 1179
Quoted 2 lines
tools/libxl/libxl.c +2
-0+int libxl_get_console_tty (libxl_ctx *ctx,uint32_t domid,char **path) +{
We already have various functions to refer to and open consoles, which have much of this functionality in them already. That shouldn't be duplicated.
Also we need to make a policy decision about whether the fact that the console looks like a tty is a part of the API.
tools/libxl/libxl.c
Quoted 4 lines
tools/libxl/libxl.c +4
-0+/* libxl_get_console_tty get the tty path from xenstore according to the +* domain id. +*/ +int libxl_get_console_tty (libxl_ctx *ctx,uint32_t domid,char **path);
In any case the doc comment should not mention xenstore. It should also document the memory allocation behaviour.
Ian.
Hi, Ian
thanks your reply.
Quoted 7 lines · Ian Jackson
Bamvor Jian Zhang writes ("[Xen-devel] [PATCH] [mq]: patch_libxl_get_console_tty.diff"):
Quoted 1 line
diff -r
9dda0efd8ce1-r4a6043e1434atools/libxl/libxl.cThanks for posting this but was int actually inteded for inclusion in the tree ? If so we need a commit message and a Signed-off-by and so forth. Also we may be too late for 4.2 considering the feature freeze.
I am sorry maybe there are something wrong in my hgrc settings. the patch including comments and Signed-off-by in my ".hg/patches" directory. I understand that 4.2 is almost release. meanwhile, my patch is useful for adding a api in libvirt for xenlight open console commands.
Quoted 9 lines
tools/libxl/libxl.c int libxl_primary_console_exec(libxl_ctx · line 1179
Quoted 2 lines
tools/libxl/libxl.c +2
-0+int libxl_get_console_tty (libxl_ctx *ctx,uint32_t domid,char **path) +{We already have various functions to refer to and open consoles, which have much of this functionality in them already. That shouldn't be duplicated.
Also we need to make a policy decision about whether the fact that the console looks like a tty is a part of the API.
sorry i only found one api about open console is libxl_console_exec. libxl_console_exec call xenconsole command directly which is not compatible with libvirt open console api. libvirt open console want a console device path and handle the console by libvirt itself. libvirt xen(not xenlight) driver read console path from xenstore directly which is prohibited by libvirt xenlight drvier. So, because these reasons, i guess add this simple api to return console path to libvirt is a good choice. it is useful for libvirt and do not break libxl api.
Quoted 8 lines
tools/libxl/libxl.h int libxl_console_exec(libxl_ctx *ctx, u · line 540
Quoted 5 lines
tools/libxl/libxl.h +4
-0+/* libxl_get_console_tty get the tty path from xenstore according to the +* domain id. +*/ +int libxl_get_console_tty (libxl_ctx *ctx,uint32_t domid,char **path);In any case the doc comment should not mention xenstore. It should also document the memory allocation behaviour.
I will change it in my next version.
Quoted 2 lines
Ian.
Bamvor
Quoted 10 lines · Bamvor Jian Zhang
Quoted 9 lines
tools/libxl/libxl.c int libxl_primary_console_exec(libxl_ctx · line 1179
Quoted 2 lines
tools/libxl/libxl.c +2
-0+int libxl_get_console_tty (libxl_ctx *ctx,uint32_t domid,char **path) +{We already have various functions to refer to and open consoles, which have much of this functionality in them already. That shouldn't be duplicated.
Also we need to make a policy decision about whether the fact that the console looks like a tty is a part of the API.
Quoted 9 lines
sorry i only found one api about open console is
libxl_console_exec.libxl_console_execcall xenconsole command directly which is not compatible with libvirt open console api. libvirt open console want a console device path and handle the console by libvirt itself. libvirt xen(not xenlight) driver read console path from xenstore directly which is prohibited by libvirt xenlight drvier.
So, because these reasons, i guess add this simple api to return console path to libvirt is a good choice. it is useful for libvirt and do not break libxl api.
We actually discussed the existing interface in the context of the libxl stable API (sub-thread starting at <[email protected]> which has a lot of sub-threads. Another interesting bit starts at <[email protected]>)
Quoted 9 lines · In that thread IanJ
] int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass); ] int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type); ] /* libxl_primary_console_exec finds the domid and console number ] * corresponding to the primary console of the given vm, then calls ] * libxl_console_exec with the right arguments (domid might be different ] * if the guest is using stubdoms). ] * This function can be called after creating the device model, in ] * case of HVM guests, and before libxl_run_bootloader in case of PV ] * guests using pygrub. */
Quoted 4 lines
] int
libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm);These functions should not exec things for you; they should tell you the parameters. Any execing helpers should be in libxlu.
and later on he said, in response to some of my musings:
Quoted 4 lines
But what if your vnc viewer doesn't have the command line options these functions expect ? libxl_vncviewer_* should give you an idl struct containing the ip address (or perhaps the domain name), port number, and password.
I think the same can be said of libxl_console_*.
In the end I decided:
Quoted 5 lines
this seems like 4.3 material at this stage.
I'd expect that the functions which behaved this way would not be called ..._exec (perhaps ..._get_params or so) so implementing the proper interface in 4.3 won't cause a compat issue.
I think I'd be happy to make a freeze exception for a patch which implemented the returning of an IDL struct representing the console device for the benefit of libvirt, so long as it is pretty much self contained (which I think it will be).
I don't see any need for it to be a requirement to switch xl over to this new interface at this stage, but we could mark the exec functions as already deprecated in 4.2 and plan to do so (with associated libxlu helpers) in 4.3.
This still leaves us having to decide if we want to expose the fact that the console is a tty. Perhaps a compromise would be to include a libxl_console_type enum and KeyedUnion of params, currently the only possible value for the enum would be "PTY" (or "TTY")? (or maybe we can leave that until the second one comes along...)
Ian.
Hi, Ian
Quoted 56 lines
Quoted 1 line
Quoted 1 line
Ian Campbell <[email protected]> wrote:
Quoted 10 lines · Bamvor Jian Zhang
Quoted 9 lines
tools/libxl/libxl.c int libxl_primary_console_exec(libxl_ctx · line 1179
Quoted 2 lines
tools/libxl/libxl.c +2
-0+int libxl_get_console_tty (libxl_ctx *ctx,uint32_t domid,char **path) +{We already have various functions to refer to and open consoles, which have much of this functionality in them already. That shouldn't be duplicated.
Also we need to make a policy decision about whether the fact that the console looks like a tty is a part of the API.
Quoted 9 lines
sorry i only found one api about open console is
libxl_console_exec.libxl_console_execcall xenconsole command directly which is not compatible with libvirt open console api. libvirt open console want a console device path and handle the console by libvirt itself. libvirt xen(not xenlight) driver read console path from xenstore directly which is prohibited by libvirt xenlight drvier.
So, because these reasons, i guess add this simple api to return console path to libvirt is a good choice. it is useful for libvirt and do not break libxl api.We actually discussed the existing interface in the context of the libxl stable API (sub-thread starting at <[email protected]> which has a lot of sub-threads. Another interesting bit starts at <[email protected]>)
Quoted 2 lines · In that thread IanJ
] int
libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass);
] int libxl_console_exec(libxl_ctx *ctx,uint32_tdomid, intcons_num,
libxl_console_typetype);Quoted 3 lines
] /*
libxl_primary_console_execfinds the domid and console number
] * corresponding to the primary console of the given vm, then calls
] *libxl_console_execwith the right arguments (domid might bedifferent
Quoted 8 lines
] * if the guest is using stubdoms). ] * This function can be called after creating the device model, in ] * case of HVM guests, and before libxl_run_bootloader in case of PV ] * guests using pygrub. */] int
libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm);These functions should not exec things for you; they should tell you the parameters. Any execing helpers should be in libxlu.
and later on he said, in response to some of my musings:
Quoted 4 lines
But what if your vnc viewer doesn't have the command line options these functions expect ? libxl_vncviewer_* should give you an idl struct containing the ip address (or perhaps the domain name), port number, and password.
I think the same can be said of libxl_console_*.
In the end I decided:
Quoted 2 lines
this seems like 4.3 material at this stage.
Quoted 8 lines
Quoted 3 lines
I'd expect that the functions which behaved this way would not be called ..._exec (perhaps ..._get_params or so) so implementing the proper interface in 4.3 won't cause a compat issue.
I think I'd be happy to make a freeze exception for a patch which implemented the returning of an IDL struct representing the console device for the benefit of libvirt, so long as it is pretty much self contained (which I think it will be).
thanks. I am working on it. i will send the patch v2 soon.
Quoted 5 lines
I don't see any need for it to be a requirement to switch xl over to this new interface at this stage, but we could mark the exec functions as already deprecated in 4.2 and plan to do so (with associated libxlu helpers) in 4.3.
Quoted 8 lines
This still leaves us having to decide if we want to expose the fact that the console is a tty. Perhaps a compromise would be to include a
libxl_console_typeenum and KeyedUnion of params, currently the only possible value for the enum would be "PTY" (or "TTY")? (or maybe we can leave that until the second one comes along...)Ian.
Bamvor
Bamvor Jian Zhang writes ("Re: [Xen-devel] [PATCH] [mq]: patch_libxl_get_console_tty.diff"):
Quoted 7 lines
Hi, Ian
Quoted 4 lines
I think I'd be happy to make a freeze exception for a patch which implemented the returning of an IDL struct representing the console device for the benefit of libvirt, so long as it is pretty much self contained (which I think it will be).
thanks. I am working on it. i will send the patch v2 soon.
Sorry to throw a spanner in the works, but I think actually that this isn't really the right approach.
Having the considered the question I think we should indeed expose the fact that there is (or can be) a tty as part of the libxl API. And I don't really want to introduce a new complex IDL struct with only one user.
So your old interface, along these lines, is good:
int libxl_get_console_tty(libxl_ctx *ctx, uint32_t domid, char **path)
However, it should probably be in teh same pattern as libxl_console_exec and libxl_primary_console_exec.
So:
int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid,
int cons_num, libxl_console_type type, char **path);
int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid,
char **path);
These should probably reuse the same innards as the _exec functions.
Are you planning to do anything about libxl_vncviewer_exec ?
Ian.