[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 5/6] libxl: add config update callback to device type framework
Some device types require a configuration update after resume of domain. Add a callback for this purpose. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- tools/libxl/libxl.c | 17 ++++++++++++++++- tools/libxl/libxl_internal.c | 21 ++++++++++++++------- tools/libxl/libxl_internal.h | 17 +---------------- tools/libxl/libxl_vtpm.c | 16 +++++++++++++++- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 7ada4a7..03e5a58 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -3147,6 +3147,14 @@ static int libxl__device_from_nic(libxl__gc *gc, uint32_t domid, return 0; } +static void libxl__update_config_nic(libxl__gc *gc, libxl_device_nic *dst, + const libxl_device_nic *src) +{ + dst->devid = src->devid; + dst->nictype = src->nictype; + libxl_mac_copy(CTX, &dst->mac, &src->mac); +} + static void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, libxl_device_nic *nic, libxl__ao_device *aodev) @@ -7197,12 +7205,19 @@ static int libxl_device_nic_compare(libxl_device_nic *d1, return COMPARE_DEVID(d1, d2); } +static void libxl_device_nic_update_config(libxl__gc *gc, void *d, void *s) +{ + libxl__update_config_nic(gc, d, s); +} + DEFINE_DEVICE_TYPE_STRUCT(disk, .merge = libxl_device_disk_merge, .dm_needed = libxl_device_disk_dm_needed, .skip_attach = 1 ); -DEFINE_DEVICE_TYPE_STRUCT(nic); +DEFINE_DEVICE_TYPE_STRUCT(nic, + .update_config = libxl_device_nic_update_config +); /* * Local variables: diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index 3b30f8a..448dd61 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -537,15 +537,22 @@ void libxl__update_domain_configuration(libxl__gc *gc, libxl_domain_config *dst, const libxl_domain_config *src) { - int i; + int i, idx, num; + const struct libxl_device_type *dt; - /* update network interface information */ - for (i = 0; i < src->num_nics; i++) - libxl__update_config_nic(gc, &dst->nics[i], &src->nics[i]); + for (idx = 0;; idx++) { + dt = device_type_tbl[idx]; + if (!dt) + break; - /* update vtpm information */ - for (i = 0; i < src->num_vtpms; i++) - libxl__update_config_vtpm(gc, &dst->vtpms[i], &src->vtpms[i]); + num = *libxl__device_type_get_num(dt, src); + if (!dt->update_config || !num) + continue; + + for (i = 0; i < num; i++) + dt->update_config(gc, libxl__device_type_get_elem(dt, dst, i), + libxl__device_type_get_elem(dt, src, i)); + } /* update guest UUID */ libxl_uuid_copy(CTX, &dst->c_info.uuid, &src->c_info.uuid); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 30b6e1e..cdc23e2 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3451,6 +3451,7 @@ struct libxl_device_type { int (*compare)(void *, void *); void (*merge)(libxl_ctx *, void *, void *); int (*dm_needed)(void *, unsigned); + void (*update_config)(libxl__gc *, void *, void *); }; #define DEFINE_DEVICE_TYPE_STRUCT_X(name, sname, ...) \ @@ -4192,22 +4193,6 @@ int libxl__set_domain_configuration(libxl__gc *gc, uint32_t domid, void libxl__update_domain_configuration(libxl__gc *gc, libxl_domain_config *dst, const libxl_domain_config *src); -static inline void libxl__update_config_nic(libxl__gc *gc, - libxl_device_nic *dst, - const libxl_device_nic *src) -{ - dst->devid = src->devid; - dst->nictype = src->nictype; - libxl_mac_copy(CTX, &dst->mac, &src->mac); -} - -static inline void libxl__update_config_vtpm(libxl__gc *gc, - libxl_device_vtpm *dst, - libxl_device_vtpm *src) -{ - dst->devid = src->devid; - libxl_uuid_copy(CTX, &dst->uuid, &src->uuid); -} /* Target memory in xenstore is different from what user has * asked for. The difference is video_memkb + (possible) fudge. diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c index cbbeea7..29a0817 100644 --- a/tools/libxl/libxl_vtpm.c +++ b/tools/libxl/libxl_vtpm.c @@ -41,6 +41,13 @@ static int libxl__device_from_vtpm(libxl__gc *gc, uint32_t domid, return 0; } +static void libxl__update_config_vtpm(libxl__gc *gc, libxl_device_vtpm *dst, + libxl_device_vtpm *src) +{ + dst->devid = src->devid; + libxl_uuid_copy(CTX, &dst->uuid, &src->uuid); +} + static void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid, libxl_device_vtpm *vtpm, libxl__ao_device *aodev) @@ -350,11 +357,18 @@ void libxl_device_vtpm_list_free(libxl_device_vtpm* list, int nr) free(list); } +static void libxl_device_vtpm_update_config(libxl__gc *gc, void *d, void *s) +{ + libxl__update_config_vtpm(gc, d, s); +} + LIBXL_DEFINE_DEVICE_ADD(vtpm) static LIBXL_DEFINE_DEVICES_ADD(vtpm) LIBXL_DEFINE_DEVICE_REMOVE(vtpm) -DEFINE_DEVICE_TYPE_STRUCT(vtpm); +DEFINE_DEVICE_TYPE_STRUCT(vtpm, + .update_config = libxl_device_vtpm_update_config +); /* * Local variables: -- 2.6.6 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |