: Introduce libxl_domain_create()
RFC PATCH 1/1 : Introduce libxl_domain_create()
This patch is my initial attempt to re-factor the libxl domain creation paths to make them more suitable for external users and in particular the python bindings.
The patch is very rough and dirty at the moment, but that said it works for creating and restoring hvm domains at least. Migrate is not tested and I haven't made sure all the error handling and such like is correct.
Any thoughts or suggestions?
Gianni
# HG changeset patch
# Parent 190c37e0eb307858c6cdf1bf5a0a5548babd2b34
tools/libxl/Makefile +2 -2
@@ -20,7 +20,7 @@ ifeq ($(CONFIG_Linux),y) LIBS += -luuid endif -LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o +LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o ifeq ($(LIBXL_BLKTAP),y) LIBXL_OBJS-y += libxl_blktap2.o else
@@ -29,7 +29,7 @@ endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o -LIBXL_OBJS = flexarray.o libxl.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y) +LIBXL_OBJS = libxl.o libxl_create.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y) LIBXL_OBJS += _libxl_types.o AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
tools/libxl/libxl.h +36 -0
@@ -246,6 +246,37 @@ enum {#define LIBXL_VERSION 0 +enum action_on_shutdown { +ACTION_DESTROY , + +ACTION_RESTART , +ACTION_RESTART_RENAME , + +ACTION_PRESERVE , + +ACTION_COREDUMP_DESTROY , +ACTION_COREDUMP_RESTART , +}; + +typedef struct { +libxl_domain_create_info c_info; +libxl_domain_build_info b_info; + +int num_disks, num_vifs, num_vif2s, num_pcidevs, num_vfbs, num_vkbs; + +libxl_device_disk *disks; +libxl_device_nic *vifs; +libxl_device_net2 *vif2s; +libxl_device_pci *pcidevs; +libxl_device_vfb *vfbs; +libxl_device_vkb *vkbs; + +enum action_on_shutdown on_poweroff; +enum action_on_shutdown on_reboot; +enum action_on_shutdown on_watchdog; +enum action_on_shutdown on_crash; +}libxl_domain_config ; +/* context functions */ int libxl_ctx_init (libxl_ctx *ctx,int version,xentoollog_logger *);int libxl_ctx_free (libxl_ctx *ctx);
@@ -253,6 +284,11 @@ int libxl_ctx_set_log(libxl_ctx *ctx, xeint libxl_ctx_postfork (libxl_ctx *ctx);/* domain related functions */ +#define LIBXL_CREATE_RESTORE (1<<0) +#define LIBXL_CREATE_RUN_BOOTLOADER (1<<1) +#define LIBXL_CREATE_CONSOLE_CONNECT (1<<2) +int libxl_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config,libxl_device_model_info *dm_info, +unsigned int flags,int restore_fd,uint32_t *domid);int libxl_domain_make (libxl_ctx *ctx,libxl_domain_create_info *info,uint32_t *domid);int libxl_domain_build (libxl_ctx *ctx,libxl_domain_build_info *info,uint32_t domid,/* out */ libxl_domain_build_state *state); int libxl_domain_restore(libxl_ctx *ctx, libxl_domain_build_info *info,
tools/libxl/libxl_create.c new file +206 -0
206 lines not on this page · raw message
tools/libxl/xl_cmdimpl.c +25 -186
302 lines not on this page · raw message
Gianni Tedesco writes ("[PATCH,RFC]: Introduce libxl_domain_create()"):
Quoted 1 line
Any thoughts or suggestions?
Thanks. It seems to be roughly along the right lines.
I'll put my comments inline ...
tools/libxl/libxl.h int libxl_ctx_set_log(libxl_ctx *ctx, xe · line 289
Quoted 4 lines
/* domain related functions */
tools/libxl/libxl.h +3
-0+#define LIBXL_CREATE_RESTORE (1<<0) +#define LIBXL_CREATE_RUN_BOOTLOADER (1<<1) +#define LIBXL_CREATE_CONSOLE_CONNECT (1<<2)
If we don't say CREATE_RUN_BOOTLOADER, where or when does the bootloader run ?
I'm not sure how a daemon caller of the library supposed to deal with this. Supppose the library caller is virt-manager, which is a daemon. Is the bootloader going to run with no console connected, or what ?
tools/libxl/libxl_create.c line 36
Quoted 8 lines
tools/libxl/libxl_create.c new file +8
-0+#define MUST ( call ) ({ \ + int must_rc = (call); \ + if (must_rc < 0) { \ + fprintf(stderr,"xl: fatal error: %s:%d, rc=%d: %s\n", \ + __FILE__,__LINE__, must_rc, #call); \ + exit(-must_rc); \ + } \ + })
As a library function, the error handling needs to be changed. It needs to not cause your whole process to exit. Instead, it should return an error to the caller. And error messages should go to the log.
Quoted 1 line
+
console->output=strdup("pty");
I think this should be some kind of checked strdup, surely ?
tools/libxl/xl_cmdimpl.c out: · line 1711
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +2
-0+#if 0 waitpid_out:if (child_console_pid >0 &&waitpid (child_console_pid, &status,0 ) <0 && errno ==EINTR ) goto waitpid_out; +#endif
Uh ?
Ian.
Quoted 28 lines · Gianni Tedesco
This patch is my initial attempt to re-factor the libxl domain creation paths to make them more suitable for external users and in particular the python bindings.
The patch is very rough and dirty at the moment, but that said it works for creating and restoring hvm domains at least. Migrate is not tested and I haven't made sure all the error handling and such like is correct.
Any thoughts or suggestions?
Gianni
# HG changeset patch
# Parent190c37e0eb307858c6cdf1bf5a0a5548babd2b34diff -r
190c37e0eb30tools/libxl/Makefiletools/libxl/Makefile Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/Makefile Tue Dec 14 18:00:35 2010 +0000 +1
-1@@ -20,7 +20,7 @@ ifeq ($(CONFIG_Linux),y) LIBS += -luuid endif -LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o +LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o ifeq ($(LIBXL_BLKTAP),y) LIBXL_OBJS-y += libxl_blktap2.o else
tools/libxl/Makefile Tue Dec 14 18:54:20 2010 +0000 endif · line 33
Quoted 6 lines
tools/libxl/Makefile Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/Makefile Tue Dec 14 18:00:35 2010 +0000 +1
-1@@ -29,7 +29,7 @@ endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o -LIBXL_OBJS = flexarray.o libxl.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y) +LIBXL_OBJS = libxl.o libxl_create.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y) LIBXL_OBJS += _libxl_types.o
Not your fault but the distinction between LIBXL_OBJS-y and LIBXL_OBJS is very non-obvious for things which are always included anyway, I'm not sure it serves any purpose as it is.
Quoted 9 lines
tools/libxl/Makefile Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/Makefile Tue Dec 14 18:00:35 2010 +0000 +0
-0AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.hdiff -r
190c37e0eb30tools/libxl/libxl.htools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +1
-0@@ -246,6 +246,37 @@ enum { #define LIBXL_VERSION 0 +enum action_on_shutdown {
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 enum { · line 259
Quoted 10 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +10
-0+ ACTION_DESTROY, + + ACTION_RESTART, + ACTION_RESTART_RENAME, + + ACTION_PRESERVE, + + ACTION_COREDUMP_DESTROY, + ACTION_COREDUMP_RESTART, +};
Should be in the libxl namespace?
We probably need IDL support for enumerations and other constants.
Quoted 9 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +8
-0+typedef struct { + libxl_domain_create_info c_info; + libxl_domain_build_info b_info; + + int num_disks, num_vifs, num_vif2s, num_pcidevs, num_vfbs, num_vkbs; + + libxl_device_disk *disks; + libxl_device_nic *vifs;
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 enum { · line 278
Quoted 10 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +10
-0+ libxl_device_net2 *vif2s; + libxl_device_pci *pcidevs; + libxl_device_vfb *vfbs; + libxl_device_vkb *vkbs; + + enum action_on_shutdown on_poweroff; + enum action_on_shutdown on_reboot; + enum action_on_shutdown on_watchdog; + enum action_on_shutdown on_crash; +} libxl_domain_config;
Should be in IDL so it gets a destructor? Could require adding an Array construct to handle the foo + num_foo style stuff.
Quoted 2 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +2
-0+static pid_t autoconnect_console(libxl_ctx *ctx, int domid) +{
[...]
Quoted 1 line
+}
I think console connect should be under toolstack control (i.e. stay in xl). exec'ing the xenconsole client is only one way of connecting the console, e.g. xapi might want to launch vncterm instead.
I think libxl_domain_create should take a callback function pointer to connect the console. It's possible that libxl might also provide a convenience function which launches xenconsole which is suitable for use as this callback but ultimately it should be the toolstack's decision what to do here.
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000
Quoted 2 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +2
-0+ +int libxl_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_device_model_info *dm_info,
I think dm_info should be part of d_config.
Quoted 1 line
+ unsigned int flags, int
restore_fd,uint32_t*domid_out)
For the external API I think I'd make the restore functionality a separate function, even if it happens to call into the same internal function.
libxl_domain_restore already exists but I guess the current implementation, as well as libxl_domain_{make,build} and friends could/should be make internal as part of this change.
Ian.
Quoted 15 lines · Ian Jackson
Gianni Tedesco writes ("[PATCH,RFC]: Introduce
libxl_domain_create()"):Quoted 1 line
Any thoughts or suggestions?
Thanks. It seems to be roughly along the right lines.
I'll put my comments inline ...
tools/libxl/libxl.h int libxl_ctx_set_log(libxl_ctx *ctx, xe · line 289
Quoted 4 lines
/* domain related functions */
tools/libxl/libxl.h +3
-0+#define LIBXL_CREATE_RESTORE (1<<0) +#define LIBXL_CREATE_RUN_BOOTLOADER (1<<1) +#define LIBXL_CREATE_CONSOLE_CONNECT (1<<2)If we don't say
CREATE_RUN_BOOTLOADER, where or when does the bootloader run ?
Quoted 4 lines
I'm not sure how a daemon caller of the library supposed to deal with this. Supppose the library caller is virt-manager, which is a daemon. Is the bootloader going to run with no console connected, or what ?
AFAICT this is just so that we don't run the bootloader during resume/migrate-receive. I've been a bit of a scaredy cat and left seperate flags for each bit of logic that was in the original function.
To be honest, I'm not sure I want to stick with the flags based API.
Quoted 9 lines
tools/libxl/libxl_create.c line 36
Quoted 8 lines
tools/libxl/libxl_create.c new file +8
-0+#define MUST ( call ) ({ \ + int must_rc = (call); \ + if (must_rc < 0) { \ + fprintf(stderr,"xl: fatal error: %s:%d, rc=%d: %s\n", \ + __FILE__,__LINE__, must_rc, #call); \ + exit(-must_rc); \ + } \ + })
Quoted 4 lines
As a library function, the error handling needs to be changed. It needs to not cause your whole process to exit. Instead, it should return an error to the caller. And error messages should go to the log.
Well spotted
Quoted 3 lines
Quoted 1 line
+
console->output=strdup("pty");I think this should be some kind of checked strdup, surely ?
Again, yes.
Quoted 8 lines
tools/libxl/xl_cmdimpl.c out: · line 1711
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +2
-0+#if 0 waitpid_out:if (child_console_pid >0 &&waitpid (child_console_pid, &status,0 ) <0 && errno ==EINTR ) goto waitpid_out; +#endif Uh ?
Heh, actualyl I wasn't sure if this was needed or not but I think it is if we had run the daemon. Need to fix that.
Gianni
Quoted 32 lines · Ian Campbell
Quoted 31 lines · Gianni Tedesco
This patch is my initial attempt to re-factor the libxl domain creation paths to make them more suitable for external users and in particular the python bindings.
The patch is very rough and dirty at the moment, but that said it works for creating and restoring hvm domains at least. Migrate is not tested and I haven't made sure all the error handling and such like is correct.
Any thoughts or suggestions?
Gianni
# HG changeset patch
# Parent190c37e0eb307858c6cdf1bf5a0a5548babd2b34diff -r
190c37e0eb30tools/libxl/Makefiletools/libxl/Makefile Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/Makefile Tue Dec 14 18:00:35 2010 +0000 +1
-1@@ -20,7 +20,7 @@ ifeq ($(CONFIG_Linux),y) LIBS += -luuid endif -LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o +LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o ifeq ($(LIBXL_BLKTAP),y) LIBXL_OBJS-y += libxl_blktap2.o else@@ -29,7 +29,7 @@ endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o
Quoted 7 lines
tools/libxl/Makefile Tue Dec 14 18:54:20 2010 +0000 endif · line 33
Quoted 3 lines
tools/libxl/Makefile Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/Makefile Tue Dec 14 18:00:35 2010 +0000 +1
-1-LIBXL_OBJS = flexarray.o libxl.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y) +LIBXL_OBJS = libxl.o libxl_create.o libxl_pci.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o libxl_utils.o $(LIBXL_OBJS-y) LIBXL_OBJS += _libxl_types.oNot your fault but the distinction between LIBXL_OBJS-y and
LIBXL_OBJSis very non-obvious for things which are always included anyway, I'm not sure it serves any purpose as it is.
Yeah, it's a bit of pointless fiddling there. I think I just want to reformat everything on to its own line so we don't end up with one massive difficult to read list of objs on one line.
Quoted 8 lines
Quoted 8 lines
tools/libxl/Makefile Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/Makefile Tue Dec 14 18:00:35 2010 +0000 +0
-0AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.hdiff -r
190c37e0eb30tools/libxl/libxl.htools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +0
-0@@ -246,6 +246,37 @@ enum { #define LIBXL_VERSION 0
Quoted 13 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 enum { · line 259
Quoted 11 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +11
-0+enum action_on_shutdown { + ACTION_DESTROY, + + ACTION_RESTART, + ACTION_RESTART_RENAME, + + ACTION_PRESERVE, + + ACTION_COREDUMP_DESTROY, + ACTION_COREDUMP_RESTART, +};Should be in the libxl namespace?
Yes it should.
Quoted 1 line
We probably need IDL support for enumerations and other constants.
Might be a good idea. We also rely on a few xc constants. In the case of the python binding I had been adding them manually. If we did this via IDL it'd be an idea to generate type-safety macros for that stuff too.
Quoted 14 lines
Quoted 14 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +13
-0+typedef struct { + libxl_domain_create_info c_info; + libxl_domain_build_info b_info; + + int num_disks, num_vifs, num_vif2s, num_pcidevs, num_vfbs, num_vkbs; + + libxl_device_disk *disks; + libxl_device_nic *vifs; + libxl_device_net2 *vif2s; + libxl_device_pci *pcidevs; + libxl_device_vfb *vfbs; + libxl_device_vkb *vkbs; +
Quoted 8 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 enum { · line 278
Quoted 5 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +5
-0+ enum action_on_shutdown on_poweroff; + enum action_on_shutdown on_reboot; + enum action_on_shutdown on_watchdog; + enum action_on_shutdown on_crash; +} libxl_domain_config;Should be in IDL so it gets a destructor? Could require adding an Array construct to handle the foo +
num_foostyle stuff.
I've thought about that and rejected it because C arrays don't map to anything useful in language bindings. It makes sense to me to keep this as a builtin and use functions to fill these domain creation related structures in for us.
But then what you get is like two versions of:
- libxl_device_add_(nic|block|etc)
One for a live domain and one for domain creation.
I have been toying with the idea of using polymorphism (is that what it's called?) So that such a function would multiplex to different implementations depending on whether this is a live domain or a description of a domain for creation. It might need a bit of thinking through as how it would be used.
Not sure what the others think of that?
Quoted 9 lines
Quoted 2 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +2
-0+static pid_t autoconnect_console(libxl_ctx *ctx, int domid) +{[...]
Quoted 1 line
+}
I think console connect should be under toolstack control (i.e. stay in xl). exec'ing the xenconsole client is only one way of connecting the console, e.g. xapi might want to launch vncterm instead.
Quoted 5 lines
I think
libxl_domain_createshould take a callback function pointer to connect the console. It's possible that libxl might also provide a convenience function which launches xenconsole which is suitable for use as this callback but ultimately it should be the toolstack's decision what to do here.
I think you're right. I had just been trying to avoid having a mega function with 12 arguments, 6 of them callbacks.
I had the idea that the original domain_create() was very fragile and I didn't want to move things around. But on the other hand it seems to me that there's no reason to start the console at two different points depending on pv or hvm and perhaps I should just try to move the code around. Domains start paused anyway so why can't we just:
libxl_domain_create();
do_console_stuff();
libxl_domain_unpause();
??
Quoted 7 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000
Quoted 2 lines
tools/libxl/libxl.h Tue Dec 14 18:54:20 2010 +0000 renamed from tools/libxl/libxl.h Tue Dec 14 18:00:35 2010 +0000 +2
-0+ +int libxl_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_device_model_info *dm_info,I think
dm_infoshould be part ofd_config.Quoted 1 line
+ unsigned int flags, int
restore_fd,uint32_t*domid_out)
Quoted 7 lines
For the external API I think I'd make the restore functionality a separate function, even if it happens to call into the same internal function.
libxl_domain_restorealready exists but I guess the current implementation, as well as libxl_domain_{make,build} and friends could/should be make internal as part of this change.
Yeah, I think I have come to the same conslusion myself and that allows the bitmask stuff to be hidden as well if it stays.
Quoted 1 line
Ian.
Thanks for comments
Gianni
Quoted 7 lines · Gianni Tedesco
Quoted 2 lines · Ian Campbell
On Tue, 2010-12-14 at 19:00 +0000, Gianni Tedesco wrote:
We probably need IDL support for enumerations and other constants.Might be a good idea. We also rely on a few xc constants. In the case of the python binding I had been adding them manually. If we did this via IDL it'd be an idea to generate type-safety macros for that stuff too.
What sort of macros?
Quoted 11 lines
Quoted 1 line
Quoted 1 line
+typedef struct {
[...]
Quoted 4 lines
Quoted 1 line
+}
libxl_domain_config;Should be in IDL so it gets a destructor? Could require adding an Array construct to handle the foo +
num_foostyle stuff.I've thought about that and rejected it because C arrays don't map to anything useful in language bindings. It makes sense to me to keep this as a builtin and use functions to fill these domain creation related structures in for us.
OK
Quoted 11 lines
But then what you get is like two versions of:
-libxl_device_add_(nic|block|etc)
One for a live domain and one for domain creation.I have been toying with the idea of using polymorphism (is that what it's called?) So that such a function would multiplex to different implementations depending on whether this is a live domain or a description of a domain for creation. It might need a bit of thinking through as how it would be used.
Not sure what the others think of that?
Proper polymorphism is a bit tricky in C, since you can't have multiple variations of the same function with different parameters and you simply end up with multiple different functions -- i.e. back where you started.
The need for a version of libxl_device_add_FOO for the create case is simply to support automatically extending the array while filing in the structure etc? I don't see a useful way to have a function which works like this for both live and in-creation domains.
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
(quoted diff) +2
-0+static pid_t autoconnect_console(libxl_ctx *ctx, int domid) +{[...]
Quoted 1 line
+}
I think console connect should be under toolstack control (i.e. stay in xl). exec'ing the xenconsole client is only one way of connecting the console, e.g. xapi might want to launch vncterm instead.
Quoted 8 lines
Quoted 5 lines
I think
libxl_domain_createshould take a callback function pointer to connect the console. It's possible that libxl might also provide a convenience function which launches xenconsole which is suitable for use as this callback but ultimately it should be the toolstack's decision what to do here.I think you're right. I had just been trying to avoid having a mega function with 12 arguments, 6 of them callbacks.
A structure containing the callback functions is the answer there.
Quoted 5 lines
I had the idea that the original
domain_create()was very fragile and I didn't want to move things around. But on the other hand it seems to me that there's no reason to start the console at two different points depending on pv or hvm and perhaps I should just try to move the code around.
I'm pretty certain Stefano did this deliberately when he introduced console support for HVM, I don't remember the specific constraint he found on HVM though. It seems to arise from 22100:fde833c66948 but the commit message doesn't say why just "it needs to be this way".
Quoted 5 lines
Domains start paused anyway so why can't we just:
libxl_domain_create();
do_console_stuff();
libxl_domain_unpause();
Not quite because for a PV domain we need to do the console before the bootloader runs (so the user can interact with pygrub) and the bootloader provides the input to libxl_domain_create().
So for PV it ends up as
libxl_domain_make() // returns a domid
do_console_stuff() // launches console client libxl_run_bootloader() // potentially interact with console, return kernel etc libxl_domain_create() // build domain using kernel libxl_domain_unpause() // go go go
My guess is that there is some reason you can't create the console for an HVM guest before libxl_domain_create but I don't specifically know why, perhaps qemu needs to be running?
In theory at least the do_console_stuff should cause a client to start and wait for the server end to appear, rather than insist on connecting immediately and it already behaves that way for PV guests, I don't see any fundamental reason HVM couldn't be the same.
Ian.
Ian Campbell writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce libxl_domain_create()"):
Quoted 3 lines
My guess is that there is some reason you can't create the console for an HVM guest before
libxl_domain_createbut I don't specifically know why, perhaps qemu needs to be running?
Yes. The primary console for an HVM guest is not a PV console, but the guest's emulated serial port provided by qemu. So to connect to it you need qemu running.
Ian.
Gianni Tedesco writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce libxl_domain_create()"):
Quoted 8 lines · Ian Campbell
Quoted 2 lines
Should be in IDL so it gets a destructor? Could require adding an Array construct to handle the foo +
num_foostyle stuff.I've thought about that and rejected it because C arrays don't map to anything useful in language bindings. It makes sense to me to keep this as a builtin and use functions to fill these domain creation related structures in for us.
Arrays map perfectly well to a C pointer and a length. If you want to do automatic expansion you need a separate allocated length too, which is probably worthwhile.
Quoted 3 lines
But then what you get is like two versions of:
-libxl_device_add_(nic|block|etc)
One for a live domain and one for domain creation.
I think that's fine, particularly if they take the same struct.
Quoted 5 lines
I have been toying with the idea of using polymorphism (is that what it's called?) So that such a function would multiplex to different implementations depending on whether this is a live domain or a description of a domain for creation. It might need a bit of thinking through as how it would be used.
Urgh.
Ian.
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Gianni Tedesco
Quoted 2 lines · Ian Campbell
On Tue, 2010-12-14 at 19:00 +0000, Gianni Tedesco wrote:
We probably need IDL support for enumerations and other constants.Might be a good idea. We also rely on a few xc constants. In the case of the python binding I had been adding them manually. If we did this via IDL it'd be an idea to generate type-safety macros for that stuff too.
What sort of macros?
Well just to have them as typed structs and macros to get/set the integer values. Beyond that I don't see much point in putting them in the IDL at all.
Quoted 26 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
+typedef struct {
[...]
Quoted 4 lines
Quoted 1 line
+}
libxl_domain_config;Should be in IDL so it gets a destructor? Could require adding an Array construct to handle the foo +
num_foostyle stuff.I've thought about that and rejected it because C arrays don't map to anything useful in language bindings. It makes sense to me to keep this as a builtin and use functions to fill these domain creation related structures in for us.
OK
Quoted 11 lines
But then what you get is like two versions of:
-libxl_device_add_(nic|block|etc)
One for a live domain and one for domain creation.I have been toying with the idea of using polymorphism (is that what it's called?) So that such a function would multiplex to different implementations depending on whether this is a live domain or a description of a domain for creation. It might need a bit of thinking through as how it would be used.
Not sure what the others think of that?
Quoted 8 lines
Proper polymorphism is a bit tricky in C, since you can't have multiple variations of the same function with different parameters and you simply end up with multiple different functions -- i.e. back where you started.
The need for a version of
libxl_device_add_FOOfor the create case is simply to support automatically extending the array while filing in the structure etc? I don't see a useful way to have a function which works like this for both live and in-creation domains.
Maybe I'm using the wrong OOP term? But you would have a libxl_domain struct and operations on it would be redirected via virtual methods. Either to update a struct or a live domain. But the input parameters would always be the same.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 2 lines
(quoted diff) +2
-0+static pid_t autoconnect_console(libxl_ctx *ctx, int domid) +{[...]
Quoted 1 line
+}
I think console connect should be under toolstack control (i.e. stay in xl). exec'ing the xenconsole client is only one way of connecting the console, e.g. xapi might want to launch vncterm instead.
I think
libxl_domain_createshould take a callback function pointer to connect the console. It's possible that libxl might also provide a convenience function which launches xenconsole which is suitable for use as this callback but ultimately it should be the toolstack's decision what to do here.
Quoted 4 lines
Quoted 2 lines
I think you're right. I had just been trying to avoid having a mega function with 12 arguments, 6 of them callbacks.
A structure containing the callback functions is the answer there.
Hmm, my displeasure is not so much how to pass the arguments but that API's based around a lot of callbacks tend to be difficult to understand and hard to maintain. They pretend to make it such that you don't need to know what order things are done in but then you end up relying on the order things are done in...
I have already factored out the other nastiness of the API I proposed (the flags) but autoconnect seems to be the final sticking point.
Quoted 28 lines
Quoted 5 lines
I had the idea that the original
domain_create()was very fragile and I didn't want to move things around. But on the other hand it seems to me that there's no reason to start the console at two different points depending on pv or hvm and perhaps I should just try to move the code around.I'm pretty certain Stefano did this deliberately when he introduced console support for HVM, I don't remember the specific constraint he found on HVM though. It seems to arise from 22100:fde833c66948 but the commit message doesn't say why just "it needs to be this way".
Quoted 5 lines
Domains start paused anyway so why can't we just:
libxl_domain_create();
do_console_stuff();
libxl_domain_unpause();Not quite because for a PV domain we need to do the console before the bootloader runs (so the user can interact with pygrub) and the bootloader provides the input to
libxl_domain_create().So for PV it ends up as
libxl_domain_make()// returns a domid
do_console_stuff()// launches console clientlibxl_run_bootloader()// potentially interact with console, return kernel etclibxl_domain_create()// build domain using kernellibxl_domain_unpause()// go go go
Quoted 8 lines
My guess is that there is some reason you can't create the console for an HVM guest before
libxl_domain_createbut I don't specifically know why, perhaps qemu needs to be running?In theory at least the
do_console_stuffshould cause a client to start and wait for the server end to appear, rather than insist on connecting immediately and it already behaves that way for PV guests, I don't see any fundamental reason HVM couldn't be the same.
Yes, the points above make sense. I think I would rather go down the road of libxl callers setting up their console stuff before creating the domain, providing a wait_for_console_stuff() API. Or at worst, give them the control back over bootloader and do a 2/3-phase domain creation API.
Gianni
Quoted 5 lines · Ian Jackson
Gianni Tedesco writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce
libxl_domain_create()"):Quoted 4 lines · Ian Campbell
Quoted 2 lines
Should be in IDL so it gets a destructor? Could require adding an Array construct to handle the foo +
num_foostyle stuff.
Quoted 8 lines
Quoted 4 lines
I've thought about that and rejected it because C arrays don't map to anything useful in language bindings. It makes sense to me to keep this as a builtin and use functions to fill these domain creation related structures in for us.
Arrays map perfectly well to a C pointer and a length. If you want to do automatic expansion you need a separate allocated length too, which is probably worthwhile.
Python, for example, has no concept of an array nor any remotely similar data structure.
The way I have developed the current xl binding is that C-structs are embedded inside python objects which wrap them. To be fair I could probably auto-generate list <-> array marshalling functions to go each way so it's not impossible.
Quoted 6 lines
Quoted 3 lines
But then what you get is like two versions of:
-libxl_device_add_(nic|block|etc)
One for a live domain and one for domain creation.I think that's fine, particularly if they take the same struct.
Quoted 7 lines
Quoted 5 lines
I have been toying with the idea of using polymorphism (is that what it's called?) So that such a function would multiplex to different implementations depending on whether this is a live domain or a description of a domain for creation. It might need a bit of thinking through as how it would be used.
Urgh.
Fair enough, I didn't expect a positive response to that one. But I mentioned to Stefano that that's the sort of interface I'll end up writing in python and he suggested that it be done that way in C so that the API's people are using are similar.
Gianni
Quoted 8 lines · Ian Jackson
Ian Campbell writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce
libxl_domain_create()"):Quoted 3 lines
My guess is that there is some reason you can't create the console for an HVM guest before
libxl_domain_createbut I don't specifically know why, perhaps qemu needs to be running?Yes. The primary console for an HVM guest is not a PV console, but the guest's emulated serial port provided by qemu. So to connect to it you need qemu running.
Why is that?
In the PV case the xenconsole client is quite happy to sit and wait (on a xenstore watch) for the console entries to be created in xenstore. Why can the qemu case not do the same?
Ian.
Quoted 6 lines · Gianni Tedesco
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Gianni Tedesco
Quoted 2 lines · Ian Campbell
On Tue, 2010-12-14 at 19:00 +0000, Gianni Tedesco wrote:
We probably need IDL support for enumerations and other constants.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Might be a good idea. We also rely on a few xc constants. In the case of the python binding I had been adding them manually. If we did this via IDL it'd be an idea to generate type-safety macros for that stuff too.
What sort of macros?
Well just to have them as typed structs and macros to get/set the integer values.
Seem like overkill to me.
Quoted 2 lines
Beyond that I don't see much point in putting them in the IDL at all.
So that language bindings can make a variable/constant with the appropriate name and value available to the user, without needing to manually code a list in each set of bindings.
Quoted 36 lines
Quoted 27 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
+typedef struct {
[...]
Quoted 2 lines
Quoted 1 line
+}
libxl_domain_config;Quoted 7 lines
Quoted 2 lines
Should be in IDL so it gets a destructor? Could require adding an Array construct to handle the foo +
num_foostyle stuff.I've thought about that and rejected it because C arrays don't map to anything useful in language bindings. It makes sense to me to keep this as a builtin and use functions to fill these domain creation related structures in for us.
OK
Quoted 11 lines
But then what you get is like two versions of:
-libxl_device_add_(nic|block|etc)
One for a live domain and one for domain creation.I have been toying with the idea of using polymorphism (is that what it's called?) So that such a function would multiplex to different implementations depending on whether this is a live domain or a description of a domain for creation. It might need a bit of thinking through as how it would be used.
Not sure what the others think of that?
Quoted 8 lines
Proper polymorphism is a bit tricky in C, since you can't have multiple variations of the same function with different parameters and you simply end up with multiple different functions -- i.e. back where you started.
The need for a version of
libxl_device_add_FOOfor the create case is simply to support automatically extending the array while filing in the structure etc? I don't see a useful way to have a function which works like this for both live and in-creation domains.
Quoted 4 lines
Maybe I'm using the wrong OOP term? But you would have a
libxl_domainstruct and operations on it would be redirected via virtual methods. Either to update a struct or a live domain. But the input parameters would always be the same.
Hmm, so in the live domain case the struct would be mostly empty apart from a domid and in the domain build case it would contains all the various info structures?
Polymorphic would mean you had libxl_add_nic(int domid, ...) and libxl_add_nic(struct libxl_domain, ...) and the compiler would pick the right one from the arguments you give.
I think what you describe is more like inheritance or something.
Quoted 66 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 2 lines
(quoted diff) +2
-0+static pid_t autoconnect_console(libxl_ctx *ctx, int domid) +{[...]
Quoted 1 line
+}
I think console connect should be under toolstack control (i.e. stay in xl). exec'ing the xenconsole client is only one way of connecting the console, e.g. xapi might want to launch vncterm instead.
I think
libxl_domain_createshould take a callback function pointer to connect the console. It's possible that libxl might also provide a convenience function which launches xenconsole which is suitable for use as this callback but ultimately it should be the toolstack's decision what to do here.Quoted 4 lines
Quoted 2 lines
I think you're right. I had just been trying to avoid having a mega function with 12 arguments, 6 of them callbacks.
A structure containing the callback functions is the answer there.
Hmm, my displeasure is not so much how to pass the arguments but that API's based around a lot of callbacks tend to be difficult to understand and hard to maintain. They pretend to make it such that you don't need to know what order things are done in but then you end up relying on the order things are done in...
I have already factored out the other nastiness of the API I proposed (the flags) but autoconnect seems to be the final sticking point.
Quoted 28 lines
Quoted 5 lines
I had the idea that the original
domain_create()was very fragile and I didn't want to move things around. But on the other hand it seems to me that there's no reason to start the console at two different points depending on pv or hvm and perhaps I should just try to move the code around.I'm pretty certain Stefano did this deliberately when he introduced console support for HVM, I don't remember the specific constraint he found on HVM though. It seems to arise from 22100:fde833c66948 but the commit message doesn't say why just "it needs to be this way".
Quoted 5 lines
Domains start paused anyway so why can't we just:
libxl_domain_create();
do_console_stuff();
libxl_domain_unpause();Not quite because for a PV domain we need to do the console before the bootloader runs (so the user can interact with pygrub) and the bootloader provides the input to
libxl_domain_create().So for PV it ends up as
libxl_domain_make()// returns a domid
do_console_stuff()// launches console clientlibxl_run_bootloader()// potentially interact with console, return kernel etclibxl_domain_create()// build domain using kernellibxl_domain_unpause()// go go goQuoted 8 lines
My guess is that there is some reason you can't create the console for an HVM guest before
libxl_domain_createbut I don't specifically know why, perhaps qemu needs to be running?In theory at least the
do_console_stuffshould cause a client to start and wait for the server end to appear, rather than insist on connecting immediately and it already behaves that way for PV guests, I don't see any fundamental reason HVM couldn't be the same.
Quoted 4 lines
Yes, the points above make sense. I think I would rather go down the road of libxl callers setting up their console stuff before creating the domain, providing a
wait_for_console_stuff()API. Or at worst, give them the control back over bootloader and do a 2/3-phase domain creation API.
That's pretty close to what we have today, isn't it?
We have (roughly):
libxl_domain_make() do_the_pv_console() libxl_run_bootloader() libxl_domain_create() for each device: libxl_device_blah_add do_the_hvm_console() libxl_domain_unpause()
Your initial patch moved all of that into libxl_domain_create but now you are suggesting that only the "for each device" and/or libxl_run_bootloader bits gets pushed down? e.g. the caller does
libxl_domain_make() do_the_pv_console() libxl_domain_create() libxl_run_bootloader() libxl_domain_actually_create() for each device: libxl_device_blah_add do_the_hvm_console() libxl_domain_unpause()
seems semi plausible, although how to do the do_the_pv_console vs hvm console in a clean way.
Ian.
Quoted 16 lines · Ian Campbell
Quoted 6 lines · Gianni Tedesco
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Gianni Tedesco
Quoted 2 lines · Ian Campbell
On Tue, 2010-12-14 at 19:00 +0000, Gianni Tedesco wrote:
We probably need IDL support for enumerations and other constants.Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Might be a good idea. We also rely on a few xc constants. In the case of the python binding I had been adding them manually. If we did this via IDL it'd be an idea to generate type-safety macros for that stuff too.
What sort of macros?
Well just to have them as typed structs and macros to get/set the integer values.
Quoted 8 lines
Seem like overkill to me.
Quoted 2 lines
Beyond that I don't see much point in putting them in the IDL at all.
So that language bindings can make a variable/constant with the appropriate name and value available to the user, without needing to manually code a list in each set of bindings.
Fair enough
Quoted 36 lines
Quoted 36 lines
Quoted 35 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
+typedef struct {
[...]
Quoted 2 lines
Quoted 1 line
+}
libxl_domain_config;Quoted 7 lines
Quoted 2 lines
Should be in IDL so it gets a destructor? Could require adding an Array construct to handle the foo +
num_foostyle stuff.I've thought about that and rejected it because C arrays don't map to anything useful in language bindings. It makes sense to me to keep this as a builtin and use functions to fill these domain creation related structures in for us.
OK
Quoted 11 lines
But then what you get is like two versions of:
-libxl_device_add_(nic|block|etc)
One for a live domain and one for domain creation.I have been toying with the idea of using polymorphism (is that what it's called?) So that such a function would multiplex to different implementations depending on whether this is a live domain or a description of a domain for creation. It might need a bit of thinking through as how it would be used.
Not sure what the others think of that?
Proper polymorphism is a bit tricky in C, since you can't have multiple variations of the same function with different parameters and you simply end up with multiple different functions -- i.e. back where you started.
The need for a version of
libxl_device_add_FOOfor the create case is simply to support automatically extending the array while filing in the structure etc? I don't see a useful way to have a function which works like this for both live and in-creation domains.
Quoted 8 lines
Quoted 4 lines
Maybe I'm using the wrong OOP term? But you would have a
libxl_domainstruct and operations on it would be redirected via virtual methods. Either to update a struct or a live domain. But the input parameters would always be the same.Hmm, so in the live domain case the struct would be mostly empty apart from a domid and in the domain build case it would contains all the various info structures?
Exactly yes.
Quoted 100 lines
Polymorphic would mean you had
libxl_add_nic(int domid, ...)andlibxl_add_nic(struct libxl_domain, ...)and the compiler would pick the right one from the arguments you give.I think what you describe is more like inheritance or something.
Quoted 66 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 2 lines
(quoted diff) +2
-0+static pid_t autoconnect_console(libxl_ctx *ctx, int domid) +{[...]
Quoted 1 line
+}
I think console connect should be under toolstack control (i.e. stay in xl). exec'ing the xenconsole client is only one way of connecting the console, e.g. xapi might want to launch vncterm instead.
I think
libxl_domain_createshould take a callback function pointer to connect the console. It's possible that libxl might also provide a convenience function which launches xenconsole which is suitable for use as this callback but ultimately it should be the toolstack's decision what to do here.Quoted 4 lines
Quoted 2 lines
I think you're right. I had just been trying to avoid having a mega function with 12 arguments, 6 of them callbacks.
A structure containing the callback functions is the answer there.
Hmm, my displeasure is not so much how to pass the arguments but that API's based around a lot of callbacks tend to be difficult to understand and hard to maintain. They pretend to make it such that you don't need to know what order things are done in but then you end up relying on the order things are done in...
I have already factored out the other nastiness of the API I proposed (the flags) but autoconnect seems to be the final sticking point.
Quoted 28 lines
Quoted 5 lines
I had the idea that the original
domain_create()was very fragile and I didn't want to move things around. But on the other hand it seems to me that there's no reason to start the console at two different points depending on pv or hvm and perhaps I should just try to move the code around.I'm pretty certain Stefano did this deliberately when he introduced console support for HVM, I don't remember the specific constraint he found on HVM though. It seems to arise from 22100:fde833c66948 but the commit message doesn't say why just "it needs to be this way".
Quoted 5 lines
Domains start paused anyway so why can't we just:
libxl_domain_create();
do_console_stuff();
libxl_domain_unpause();Not quite because for a PV domain we need to do the console before the bootloader runs (so the user can interact with pygrub) and the bootloader provides the input to
libxl_domain_create().So for PV it ends up as
libxl_domain_make()// returns a domid
do_console_stuff()// launches console clientlibxl_run_bootloader()// potentially interact with console, return kernel etclibxl_domain_create()// build domain using kernellibxl_domain_unpause()// go go goQuoted 8 lines
My guess is that there is some reason you can't create the console for an HVM guest before
libxl_domain_createbut I don't specifically know why, perhaps qemu needs to be running?In theory at least the
do_console_stuffshould cause a client to start and wait for the server end to appear, rather than insist on connecting immediately and it already behaves that way for PV guests, I don't see any fundamental reason HVM couldn't be the same.Quoted 4 lines
Yes, the points above make sense. I think I would rather go down the road of libxl callers setting up their console stuff before creating the domain, providing a
wait_for_console_stuff()API. Or at worst, give them the control back over bootloader and do a 2/3-phase domain creation API.That's pretty close to what we have today, isn't it?
We have (roughly):
libxl_domain_make() do_the_pv_console() libxl_run_bootloader() libxl_domain_create() for each device: libxl_device_blah_add do_the_hvm_console() libxl_domain_unpause()Your initial patch moved all of that into
libxl_domain_createbut now you are suggesting that only the "for each device" and/orlibxl_run_bootloaderbits gets pushed down? e.g. the caller doeslibxl_domain_make() do_the_pv_console() libxl_domain_create() libxl_run_bootloader() libxl_domain_actually_create() for each device: libxl_device_blah_add do_the_hvm_console() libxl_domain_unpause()
Quoted 2 lines
seems semi plausible, although how to do the
do_the_pv_consolevs hvm console in a clean way.
Yeah I don't like it because I already think xl is doing a helluva lot of stuff in its create_domain() function.
If we can have pv and hvm cases unified so that both consoles can be done a lot earlier (ie. before libxl_domain_create()) then that would let us keep the bulk of the work in libxl and we can zap:
- libxl_domain(make|create|restore|run_bootloader)
Then again, it may complicate the callers because then they have to do something if domain_create() fails to clean that up.
So, domain creation really is hard. Let's go shopping :S
Gianni
Gianni Tedesco writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce libxl_domain_create()"):
Quoted 2 lines
Python, for example, has no concept of an array nor any remotely similar data structure.
Python calls them lists. The literal constructor is []. You can iterate over them and efficiently retrieve and set elements by index number. Ie, they are arrays.
Quoted 4 lines
The way I have developed the current xl binding is that C-structs are embedded inside python objects which wrap them. To be fair I could probably auto-generate list <-> array marshalling functions to go each way so it's not impossible.
I don't see in what way a Python list is not an array or what the fundamental difficulty is here.
Ian.
Ian Campbell writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce libxl_domain_create()"):
Quoted 10 lines · Ian Jackson
Quoted 3 lines
Yes. The primary console for an HVM guest is not a PV console, but the guest's emulated serial port provided by qemu. So to connect to it you need qemu running.
Why is that?
In the PV case the xenconsole client is quite happy to sit and wait (on a xenstore watch) for the console entries to be created in xenstore. Why can the qemu case not do the same?
TBH I think this is a bug in the xenconsole client, because it means that the xenconsole client has an arbitrary timeout when it ought to be started at the point when we know that the console is there.
But I think you are right and this isn't the reason why it's done like that at the moment.
I vaguely remember some complication with the bootloader. Perhaps the problem was that we can't start the console client until the bootloader has finished using our controlling terminal ?
It seems to me that the right approach is
(a) the domain creation function should call back to the application to say "your domain's console is ready now and you can connect to it if you like"
(b) the bootloader's console should be plumbed explicitly rather than simply relying on inheriting a suitable terminal from the library's caller.
Without (b), doing xapi or libvirt on top of libxl is going to be impossible.
TBH some of the console plumbing is pretty horrid and needs a redesign. For example, why can't you connect to the same domain more than once ? (Ans: because xenconsoled uses ptys for talking to xenconsole!!) Why can't you automatically log the guest's serial console ? (Ans: because that's done with completely separate code in qemu which doesn't know how to do more than speak to a particular tty.)
Ian.
Quoted 16 lines · Ian Jackson
Ian Campbell writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce
libxl_domain_create()"):Quoted 10 lines · Ian Jackson
Quoted 3 lines
Yes. The primary console for an HVM guest is not a PV console, but the guest's emulated serial port provided by qemu. So to connect to it you need qemu running.
Why is that?
In the PV case the xenconsole client is quite happy to sit and wait (on a xenstore watch) for the console entries to be created in xenstore. Why can the qemu case not do the same?
TBH I think this is a bug in the xenconsole client, because it means that the xenconsole client has an arbitrary timeout when it ought to be started at the point when we know that the console is there.
Quoted 6 lines
But I think you are right and this isn't the reason why it's done like that at the moment.
I vaguely remember some complication with the bootloader. Perhaps the problem was that we can't start the console client until the bootloader has finished using our controlling terminal ?
The opposite -- the bootloader interacts with the user via xenconsole.
Quoted 10 lines
It seems to me that the right approach is
(a) the domain creation function should call back to the application to say "your domain's console is ready now and you can connect to it if you like"
(b) the bootloader's console should be plumbed explicitly rather than simply relying on inheriting a suitable terminal from the library's caller.Without (b), doing xapi or libvirt on top of libxl is going to be impossible.
(b) is already done and has been since Tim first plumbed the bootloader stuff through.
Quoted 7 lines
TBH some of the console plumbing is pretty horrid and needs a redesign. For example, why can't you connect to the same domain more than once ? (Ans: because xenconsoled uses ptys for talking to xenconsole!!) Why can't you automatically log the guest's serial console ? (Ans: because that's done with completely separate code in qemu which doesn't know how to do more than speak to a particular tty.)
Quoted 7 lines · Ian Jackson
Gianni Tedesco writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce
libxl_domain_create()"):Quoted 2 lines
Python, for example, has no concept of an array nor any remotely similar data structure.
Python calls them lists. The literal constructor is []. You can iterate over them and efficiently retrieve and set elements by index number. Ie, they are arrays.
Hmm, they are lists :)
They behave entirely like lists but look like arrays.
Quoted 7 lines
Quoted 4 lines
The way I have developed the current xl binding is that C-structs are embedded inside python objects which wrap them. To be fair I could probably auto-generate list <-> array marshalling functions to go each way so it's not impossible.
I don't see in what way a Python list is not an array or what the fundamental difficulty is here.
Well, when I have a list of PyFoo then I can't back that with an array of Foo that's all.
Quoted 1 line
Ian.
Ian Campbell writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce libxl_domain_create()"):
Quoted 1 line
The opposite -- the bootloader interacts with the user via xenconsole.
So it does. I hadn't spotted that going in. In that case I think not setting up the console earlier is just historical.
Ian.