fix rename: xenstore not fully updated
PATCH v2 1/1 fix rename: xenstore not fully updated
Currently libxl__domain_rename only update /local/domain/<domid>/name, still some places in xenstore are not updated, including:
/vm/<uuid>/name and /local/domain/0/backend/<device>/<domid>/.../domain.
This patch updates /vm/<uuid>/name in xenstore, and removes the unusual 'domain' field under backend directory (the affected are backend/console, backend/vfb, backend/vkb).
---
Changes:
* remove unusual 'domain' field from backend dir
* get uuid from hypervisor rather then from xenstore
tools/libxl/libxl.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +18 -5
@@ -359,6 +359,9 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,uint32_t stub_dm_domid;const char *stub_dm_old_name =NULL , *stub_dm_new_name =NULL ;int rc; +libxl_dominfo info; +char *uuid; +const char *vm_name_path; dom_path =libxl__xs_get_dompath (gc, domid);if (!dom_path) goto x_nomem;
@@ -429,6 +432,21 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid, goto x_fail; } +/* update /vm/<uuid>/name */ + rc =libxl_domain_info (ctx, &info, domid); +if (rc) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"fail to get domain info for domain %d" , domid); + goto x_fail; + } + uuid =GCSPRINTF (LIBXL_UUID_FMT ,LIBXL_UUID_BYTES (info.uuid)); + vm_name_path =GCSPRINTF ("/vm/%s/name" , uuid); +if (libxl__xs_write_checked (gc, trans, vm_name_path, new_name)) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"failed to write new name `%s'" +" to %s" , new_name, vm_name_path); + goto x_fail; + } +if (stub_dm_domid) { rc = libxl__domain_rename(gc, stub_dm_domid, stub_dm_old_name,
@@ -3605,8 +3623,6 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t domid,flexarray_append (back,"1" );flexarray_append (back,"state" );flexarray_append (back,libxl__sprintf (gc,"%d" ,1 )); -flexarray_append (back,"domain" ); -flexarray_append (back,libxl__domid_to_name (gc, domid));flexarray_append (back,"protocol" );flexarray_append (back,LIBXL_XENCONSOLE_PROTOCOL );
@@ -3943,8 +3959,6 @@ int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid,flexarray_append (back,"1" );flexarray_append (back,"state" );flexarray_append (back,libxl__sprintf (gc,"%d" ,1 )); -flexarray_append (back,"domain" ); -flexarray_append (back,libxl__domid_to_name (gc, domid));flexarray_append (front,"backend-id" );flexarray_append (front,libxl__sprintf (gc,"%d" , vkb->backend_domid));
@@ -4041,7 +4055,6 @@ int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb)flexarray_append_pair (back,"frontend-id" ,libxl__sprintf (gc,"%d" , domid));flexarray_append_pair (back,"online" ,"1" );flexarray_append_pair (back,"state" ,libxl__sprintf (gc,"%d" ,1 )); -flexarray_append_pair (back,"domain" ,libxl__domid_to_name (gc, domid));flexarray_append_pair (back,"vnc" ,libxl_defbool_val (vfb->vnc.enable) ?"1" :"0" );flexarray_append_pair (back,"vnclisten" , vfb->vnc.listen);
Signature · 1 line
1.8.4.5
Chunyan Liu writes ("[PATCH v2] fix rename: xenstore not fully updated"):
Quoted 3 lines
Currently
libxl__domain_renameonly update /local/domain/<domid>/name, still some places in xenstore are not updated, including:
/vm/<uuid>/name and /local/domain/0/backend/<device>/<domid>/.../domain.
Thanks. The principle is correct now and so is the broad approach.
Quoted 3 lines
This patch updates /vm/<uuid>/name in xenstore, and removes the unusual 'domain' field under backend directory (the affected are backend/console, backend/vfb, backend/vkb).
I think this should be a separate patch.
Quoted 14 lines
Signed-off-by Chunyan Liu <[email protected]>---
Changes:
* remove unusual 'domain' field from backend dir
* get uuid from hypervisor rather then from xenstoretools/libxl/libxl.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)tools/libxl/libxl.c +0
-0
tools/libxl/libxl.c int libxl__domain_rename(libxl__gc *gc, uint32_t domid, · line 365
Quoted 7 lines
tools/libxl/libxl.c +7
-0@@ -359,6 +359,9 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid, +/* update /vm/<uuid>/name */ + rc =libxl_domain_info (ctx, &info, domid); +if (rc) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"fail to get domain info for domain %d" , domid); + goto x_fail; + }
I don't think you need to log here since libxl_domain_info already does so. Likewise libxl__xs_write_checked. But before deleting this, please let's wait and see whether Wei and Ian C agree.
If you do want to add logging here, it's probably better to use use LOG rather than LIBXL__LOG.
tools/libxl/libxl.c int libxl__domain_rename(libxl__gc *gc, uint32_t domid, · line 447
Quoted 6 lines
tools/libxl/libxl.c +6
-0+ uuid =GCSPRINTF (LIBXL_UUID_FMT ,LIBXL_UUID_BYTES (info.uuid)); + vm_name_path =GCSPRINTF ("/vm/%s/name" , uuid); +if (libxl__xs_write_checked (gc, trans, vm_name_path, new_name)) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"failed to write new name `%s'" +" to %s" , new_name, vm_name_path); + goto x_fail;
I don't think it is necessary to LIBXL__LOG here, since libxl__xs_write_checked does so. (See the doc comment in libxl_internal.h.)
Thanks,
Ian.
Quoted 22 lines · Ian Jackson
Chunyan Liu writes ("[PATCH v2] fix rename: xenstore not fully updated"):
Quoted 3 lines
Currently
libxl__domain_renameonly update /local/domain/<domid>/name, still some places in xenstore are not updated, including:
/vm/<uuid>/name and /local/domain/0/backend/<device>/<domid>/.../domain.Thanks. The principle is correct now and so is the broad approach.
Quoted 3 lines
This patch updates /vm/<uuid>/name in xenstore, and removes the unusual 'domain' field under backend directory (the affected are backend/console, backend/vfb, backend/vkb).
I think this should be a separate patch.
Quoted 9 lines
Signed-off-by Chunyan Liu <[email protected]>---
Changes:
* remove unusual 'domain' field from backend dir
* get uuid from hypervisor rather then from xenstoretools/libxl/libxl.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
Quoted 16 lines
tools/libxl/libxl.c int libxl__domain_rename(libxl__gc *gc, uint32_t domid, · line 365
Quoted 12 lines
tools/libxl/libxl.c +7
-0@@ -359,6 +359,9 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid, +/* update /vm/<uuid>/name */ + rc =libxl_domain_info (ctx, &info, domid); +if (rc) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"fail to get domain info for domain %d" , domid); + goto x_fail; + }I don't think you need to log here since
libxl_domain_infoalready does so. Likewiselibxl__xs_write_checked. But before deleting this, please let's wait and see whether Wei and Ian C agree.
I'm all for removing redundant logging.
Ian
Quoted 17 lines
If you do want to add logging here, it's probably better to use use LOG rather than
LIBXL__LOG.tools/libxl/libxl.c int libxl__domain_rename(libxl__gc *gc, uint32_t domid, · line 447
Quoted 6 lines
tools/libxl/libxl.c +6
-0+ uuid =GCSPRINTF (LIBXL_UUID_FMT ,LIBXL_UUID_BYTES (info.uuid)); + vm_name_path =GCSPRINTF ("/vm/%s/name" , uuid); +if (libxl__xs_write_checked (gc, trans, vm_name_path, new_name)) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"failed to write new name `%s'" +" to %s" , new_name, vm_name_path); + goto x_fail;I don't think it is necessary to
LIBXL__LOGhere, sincelibxl__xs_write_checkeddoes so. (See the doc comment inlibxl_internal.h.)Thanks,
Ian.