Skip to contentSkip to conversation

: xl: move domain struct init functions to libxl

PATCH Superseded Gianni Tedesco 2 participants 4 messages Jan 11, 2011

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : xl: move domain struct init functions to libxl

This allows libxl users to get some sane default values for this complex set of structures. This is purely code movement and there are no functional changes.

tools/libxl/libxl.h +3 -0
diff -r feb198f3c97f tools/libxl/libxl.h
@@ -280,6 +280,9 @@ int libxl_ctx_set_log(libxl_ctx *ctx, xe
 int libxl_ctx_postfork(libxl_ctx *ctx);
 
 /* domain related functions */
+void libxl_init_create_info(libxl_domain_create_info *c_info);
+void libxl_init_build_info(libxl_domain_build_info *b_info, libxl_domain_create_info *c_info);
+void libxl_init_dm_info(libxl_device_model_info *dm_info, libxl_domain_create_info *c_info, libxl_domain_build_info *b_info);
 typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid);
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);
tools/libxl/libxl_create.c +69 -0

75 lines not on this page · raw message

tools/libxl/xl_cmdimpl.c +3 -72

99 lines not on this page · raw message

#1 lore raw
Quoted 20 lines · Gianni Tedesco

This allows libxl users to get some sane default values for this complex set of structures. This is purely code movement and there are no functional changes.

diff -r feb198f3c97f tools/libxl/libxl.h

tools/libxl/libxl.h +3 -0
@@ -280,6 +280,9 @@ int libxl_ctx_set_log(libxl_ctx *ctx, xe
 int libxl_ctx_postfork(libxl_ctx *ctx);
 
 /* domain related functions */
+void libxl_init_create_info(libxl_domain_create_info *c_info);
+void libxl_init_build_info(libxl_domain_build_info *b_info, libxl_domain_create_info *c_info);
+void libxl_init_dm_info(libxl_device_model_info *dm_info, libxl_domain_create_info *c_info, libxl_domain_build_info *b_info);
 typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid);
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);
Quoted 1 line

diff -r feb198f3c97f tools/libxl/libxl_create.c

What about init_nic_info, init_net2_info, init_vfb_info, init_vkb_info and init_console_info?
Wouldn't make sense to have a libxl_init_domain_config?

#2 lore raw
Quoted 14 lines · Stefano Stabellini
Quoted 13 lines · Gianni Tedesco

This allows libxl users to get some sane default values for this complex set of structures. This is purely code movement and there are no functional changes.

diff -r feb198f3c97f tools/libxl/libxl.h

tools/libxl/libxl.h +0 -0
@@ -280,6 +280,9 @@ int libxl_ctx_set_log(libxl_ctx *ctx, xe
 int libxl_ctx_postfork(libxl_ctx *ctx);
 
Quoted 13 lines
Quoted 8 lines
tools/libxl/libxl.h +3 -0
 /* domain related functions */
+void libxl_init_create_info(libxl_domain_create_info *c_info);
+void libxl_init_build_info(libxl_domain_build_info *b_info, libxl_domain_create_info *c_info);
+void libxl_init_dm_info(libxl_device_model_info *dm_info, libxl_domain_create_info *c_info, libxl_domain_build_info *b_info);
 typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid);
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);

diff -r feb198f3c97f tools/libxl/libxl_create.c

What about init_nic_info, init_net2_info, init_vfb_info, init_vkb_info and init_console_info?
Wouldn't make sense to have a libxl_init_domain_config

Yeah good point, I can re-spin to include the various device info's.

Not sure about an init_domain_config, I don't see how it would work, currently we have:

libxl_domain_config x; init_create_info(&x.c_info);
// do stuff to c_info init_build_info(&x.b_info, &x.c_info);
// do stuff to b_info init_dm_info(&x.dm_info, &x.c_info, &x.b_info); // do stuff to dm_info
for each device { init device; do stuff to device; }

You could init them all in one functions but it breaks IMO the main purpose of these functions which is that when you 'do stuff' to b_info then init_dm_info() depends on that to set the sane defaults (eg. for vidmem).

So either we would have every field as a parameter to this function or add callbacks for the 'do stuff' bits which seems a very rigid interface. I think we should wait for 4.2 before we try to make any more-sweeping changes in this area.

Gianni

#3 lore raw
Quoted 43 lines · Gianni Tedesco
Quoted 14 lines · Stefano Stabellini
Quoted 13 lines · Gianni Tedesco

This allows libxl users to get some sane default values for this complex set of structures. This is purely code movement and there are no functional changes.

diff -r feb198f3c97f tools/libxl/libxl.h

tools/libxl/libxl.h +0 -0
@@ -280,6 +280,9 @@ int libxl_ctx_set_log(libxl_ctx *ctx, xe
 int libxl_ctx_postfork(libxl_ctx *ctx);
 
Quoted 13 lines
Quoted 8 lines
tools/libxl/libxl.h +3 -0
 /* domain related functions */
+void libxl_init_create_info(libxl_domain_create_info *c_info);
+void libxl_init_build_info(libxl_domain_build_info *b_info, libxl_domain_create_info *c_info);
+void libxl_init_dm_info(libxl_device_model_info *dm_info, libxl_domain_create_info *c_info, libxl_domain_build_info *b_info);
 typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid);
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);

diff -r feb198f3c97f tools/libxl/libxl_create.c

What about init_nic_info, init_net2_info, init_vfb_info, init_vkb_info and init_console_info?
Wouldn't make sense to have a libxl_init_domain_config

Yeah good point, I can re-spin to include the various device info's.

Not sure about an init_domain_config, I don't see how it would work, currently we have:

libxl_domain_config x; init_create_info(&x.c_info);
// do stuff to c_info init_build_info(&x.b_info, &x.c_info);
// do stuff to b_info init_dm_info(&x.dm_info, &x.c_info, &x.b_info); // do stuff to dm_info
for each device { init device; do stuff to device; }

Quoted 5 lines

You could init them all in one functions but it breaks IMO the main purpose of these functions which is that when you 'do stuff' to b_info then init_dm_info() depends on that to set the sane defaults (eg. for vidmem).

No I mean instead of having:

libxl_init_nic_info, libxl_init_net2_info, etc.

we would have a single libxl_init_domain_config that does it all. However we cannot actually do that because we don't know exactly the number of devices of each kind we are going to have.
So forget about libxl_init_domain_config.