libxl: tweak the cpupool interface slightly
PATCH 1/1 libxl: tweak the cpupool interface slightly
Just a few changes I noticed while playing with cpupools on Friday.
There is no need for both poolid and poolname in the libxl API. Remove poolname.
Use libxl_cpupool_create not libxl_create_cpupool for consistency with other functions.
Do not write "pool_name" to xenstore. I couldn't find any reader of this node but I left it till last so it can easily be dropped if necessary.
PATCH 1/1 libxl: remove libxl_domain_create_info.poolname
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1327329346 0
# Node ID c91bee33280debdfe602d28e48318c03ddf0f4c9 # Parent 4bb2b6a04ec02c3502c1825e2736df54870229e5
libxl: remove libxl_domain_create_info.poolname
It is redundant with poolid and allowing the user to specify both opens up the possibility of a disconnect.
Also default c_info->poolid to -1 (no pool) instead of defaulting to 0 in the library and overriding in the toolstack.
tools/libxl/libxl_create.c +4 -3
@@ -60,7 +60,7 @@ int libxl_init_create_info(libxl_ctx *ct c_info->type =LIBXL_DOMAIN_TYPE_HVM ; c_info->oos =1 ; c_info->ssidref =0 ; - c_info->poolid =0 ; + c_info->poolid =-1 ;return 0 ; }
@@ -438,8 +438,9 @@ retry_transaction:xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/uuid" , vm_path), uuid_string,strlen (uuid_string));xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/name" , vm_path), info->name,strlen (info->name)); -if (info->poolname) -xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), info->poolname,strlen (info->poolname)); +if (info->poolid !=-1 ) +libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), +"%s" ,libxl__cpupoolid_to_name (gc, info->poolid));libxl__xs_writev (gc, t, dom_path, info->xsdata);libxl__xs_writev (gc, t,libxl__sprintf (gc,"%s/platform" , dom_path), info->platformdata);
tools/libxl/libxl_types.idl +0 -1
@@ -156,7 +156,6 @@ libxl_domain_create_info = Struct("domai ("xsdata", libxl_key_value_list), ("platformdata", libxl_key_value_list), ("poolid", uint32), - ("poolname", string), ]) libxl_domain_build_info = Struct("domain_build_info",[
tools/libxl/xl_cmdimpl.c +2 -4
@@ -315,7 +315,7 @@ static void printf_info(int domid,printf ("\t(uuid <unknown>)\n" ); } -printf ("\t(cpupool %s)\n" , c_info->poolname); +printf ("\t(cpupool %s)\n" ,libxl_cpupoolid_to_name (ctx, c_info->poolid));if (c_info->xsdata)printf ("\t(xsdata contains data)\n" );else
@@ -640,11 +640,9 @@ static void parse_config_data(const char c_info->oos = l;if (!xlu_cfg_get_string (config,"pool" , &buf,0 )) { - c_info->poolid =-1 ;cpupool_qualifier_to_cpupoolid (buf, &c_info->poolid,NULL ); } - c_info->poolname =libxl_cpupoolid_to_name (ctx, c_info->poolid); -if (!c_info->poolname) { +if (!libxl_cpupoolid_to_name (ctx, c_info->poolid)) {fprintf (stderr,"Illegal pool specified\n" );exit (1 ); }
PATCH 1/1 libxl: name libxl_create_cpupool consistent with other functions
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1327329347 0
# Node ID 10f5656caaaa2bdfd6a7ae9aada903da8bddcbb6
# Parent c91bee33280debdfe602d28e48318c03ddf0f4c9
libxl: name libxl_create_cpupool consistent with other functions.
The pattern for the other cpupool functions is libxl_cpupool_<ACTION> and in general we use libxl_<THING>_<ACTION>
tools/libxl/libxl.c +1 -1
@@ -3172,7 +3172,7 @@ int libxl_get_freecpus(libxl_ctx *ctx, lreturn 0 ; } -int libxl_create_cpupool (libxl_ctx *ctx,const char *name,int schedid, +int libxl_cpupool_create (libxl_ctx *ctx,const char *name,int schedid,libxl_cpumap cpumap,libxl_uuid *uuid,uint32_t *poolid) {
tools/libxl/libxl.h +1 -1
@@ -605,7 +605,7 @@ int libxl_tmem_shared_auth(libxl_ctx *ctint libxl_tmem_freeable (libxl_ctx *ctx);int libxl_get_freecpus (libxl_ctx *ctx,libxl_cpumap *cpumap); -int libxl_create_cpupool (libxl_ctx *ctx,const char *name,int schedid, +int libxl_cpupool_create (libxl_ctx *ctx,const char *name,int schedid,libxl_cpumap cpumap,libxl_uuid *uuid,uint32_t *poolid);int libxl_cpupool_destroy (libxl_ctx *ctx,uint32_t poolid);
tools/libxl/xl_cmdimpl.c +2 -2
@@ -5332,7 +5332,7 @@ int main_cpupoolcreate(int argc, char **return 0 ; poolid =0 ; -if (libxl_create_cpupool (ctx, name, schedid, cpumap, &uuid, &poolid)) { +if (libxl_cpupool_create (ctx, name, schedid, cpumap, &uuid, &poolid)) {fprintf (stderr,"error on creating cpupool\n" );return -ERROR_FAIL ; }
@@ -5706,7 +5706,7 @@ int main_cpupoolnumasplit(int argc, charsnprintf (name,15 ,"Pool-node%d" , node);libxl_uuid_generate (&uuid); poolid =0 ; - ret = -libxl_create_cpupool (ctx, name, schedid, cpumap, &uuid, &poolid); + ret = -libxl_cpupool_create (ctx, name, schedid, cpumap, &uuid, &poolid);if (ret) {fprintf (stderr,"error on creating cpupool\n" ); goto out;
PATCH 1/1 libxl: do not write/maintain "pool_name" in XenStore
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1327329565 0
# Node ID d8efdb16b1ef06013061da1f47c2dbce4b042992 # Parent 10f5656caaaa2bdfd6a7ae9aada903da8bddcbb6
libxl: do not write/maintain "pool_name" in XenStore
Nothing that I can find ever reads this key.
tools/libxl/libxl.c +0 -25
@@ -3434,16 +3434,6 @@ int libxl_cpupool_movedomain(libxl_ctx * {GC_INIT (ctx);int rc; -char *dom_path; -char *vm_path; -char *poolname; -xs_transaction_t t; - - dom_path =libxl__xs_get_dompath (gc, domid); -if (!dom_path) { -GC_FREE ; -return ERROR_FAIL ; - } rc =xc_cpupool_movedomain (ctx->xch, poolid, domid);if (rc) {
@@ -3453,21 +3443,6 @@ int libxl_cpupool_movedomain(libxl_ctx *return ERROR_FAIL ; } -for (;;) { - t =xs_transaction_start (ctx->xsh); - - poolname =libxl__cpupoolid_to_name (gc, poolid); - vm_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/vm" , dom_path)); -if (!vm_path) -break ; - -libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), -"%s" , poolname); - -if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN )) -break ; - } -GC_FREE ;return 0 ; }
tools/libxl/libxl_create.c +0 -3
@@ -438,9 +438,6 @@ retry_transaction:xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/uuid" , vm_path), uuid_string,strlen (uuid_string));xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/name" , vm_path), info->name,strlen (info->name)); -if (info->poolid !=-1 ) -libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), -"%s" ,libxl__cpupoolid_to_name (gc, info->poolid));libxl__xs_writev (gc, t, dom_path, info->xsdata);libxl__xs_writev (gc, t,libxl__sprintf (gc,"%s/platform" , dom_path), info->platformdata);
Re: [PATCH 1 of 3] libxl: remove libxl_domain_create_info.poolname
In reply to Ian CampbellQuoted 7 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell<[email protected]> # Date 1327329346 0
# Node IDc91bee33280debdfe602d28e48318c03ddf0f4c9# Parent4bb2b6a04ec02c3502c1825e2736df54870229e5
libxl: remove libxl_domain_create_info.poolname
Quoted 7 lines
It is redundant with poolid and allowing the user to specify both opens up the possibility of a disconnect.
Also default
c_info->poolidto -1 (no pool) instead of defaulting to 0 in the library and overriding in the toolstack.Signed-off-by Ian Campbell<[email protected]>
Quoted 67 lines
diff -r
4bb2b6a04ec0-rc91bee33280dtools/libxl/libxl_create.ctools/libxl/libxl_create.c +4
-3@@ -60,7 +60,7 @@ int libxl_init_create_info(libxl_ctx *ct c_info->type =LIBXL_DOMAIN_TYPE_HVM ; c_info->oos =1 ; c_info->ssidref =0 ; - c_info->poolid =0 ; + c_info->poolid =-1 ;return 0 ; }@@ -438,8 +438,9 @@ retry_transaction:xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/uuid" , vm_path), uuid_string,strlen (uuid_string));xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/name" , vm_path), info->name,strlen (info->name)); -if (info->poolname) -xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), info->poolname,strlen (info->poolname)); +if (info->poolid !=-1 ) +libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), +"%s" ,libxl__cpupoolid_to_name (gc, info->poolid));libxl__xs_writev (gc, t, dom_path, info->xsdata);libxl__xs_writev (gc, t,libxl__sprintf (gc,"%s/platform" , dom_path), info->platformdata);diff -r
4bb2b6a04ec0-rc91bee33280dtools/libxl/libxl_types.idltools/libxl/libxl_types.idl +0
-1@@ -156,7 +156,6 @@ libxl_domain_create_info = Struct("domai ("xsdata", libxl_key_value_list), ("platformdata", libxl_key_value_list), ("poolid", uint32), - ("poolname", string), ]) libxl_domain_build_info = Struct("domain_build_info",[diff -r
4bb2b6a04ec0-rc91bee33280dtools/libxl/xl_cmdimpl.ctools/libxl/xl_cmdimpl.c +2
-4@@ -315,7 +315,7 @@ static void printf_info(int domid,printf ("\t(uuid<unknown>)\n" ); } -printf ("\t(cpupool %s)\n" , c_info->poolname); +printf ("\t(cpupool %s)\n" ,libxl_cpupoolid_to_name (ctx, c_info->poolid));if (c_info->xsdata)printf ("\t(xsdata contains data)\n" );else @@ -640,11 +640,9 @@ static void parse_config_data(const char c_info->oos = l;if (!xlu_cfg_get_string (config,"pool" ,&buf,0 )) { - c_info->poolid =-1 ;cpupool_qualifier_to_cpupoolid (buf,&c_info->poolid,NULL ); } - c_info->poolname =libxl_cpupoolid_to_name (ctx, c_info->poolid); -if (!c_info->poolname) { +if (!libxl_cpupoolid_to_name (ctx, c_info->poolid)) {fprintf (stderr,"Illegal pool specified\n" );exit (1 ); }_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Signature · 5 lines
Juergen Gross Principal Developer Operating Systems PDG ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967 Fujitsu Technology Solutions e-mail: [email protected] Domagkstr. 28 Internet: ts.fujitsu.com D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
Re: [PATCH 2 of 3] libxl: name libxl_create_cpupool consistent with other functions
In reply to Ian CampbellQuoted 11 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell<[email protected]>
# Date 1327329347 0
# Node ID10f5656caaaa2bdfd6a7ae9aada903da8bddcbb6
# Parentc91bee33280debdfe602d28e48318c03ddf0f4c9
libxl: namelibxl_create_cpupoolconsistent with other functions.The pattern for the other cpupool functions is libxl_cpupool_<ACTION> and in general we use libxl_<THING>_<ACTION>
Signed-off-by Ian Campbell<[email protected]>
Quoted 52 lines
diff -r
c91bee33280d-r10f5656caaaatools/libxl/libxl.ctools/libxl/libxl.c +1
-1@@ -3172,7 +3172,7 @@ int libxl_get_freecpus(libxl_ctx *ctx, lreturn 0 ; } -int libxl_create_cpupool (libxl_ctx *ctx,const char *name,int schedid, +int libxl_cpupool_create (libxl_ctx *ctx,const char *name,int schedid,libxl_cpumap cpumap,libxl_uuid *uuid,uint32_t *poolid) {diff -r
c91bee33280d-r10f5656caaaatools/libxl/libxl.htools/libxl/libxl.h +1
-1@@ -605,7 +605,7 @@ int libxl_tmem_shared_auth(libxl_ctx *ctint libxl_tmem_freeable (libxl_ctx *ctx);int libxl_get_freecpus (libxl_ctx *ctx,libxl_cpumap *cpumap); -int libxl_create_cpupool (libxl_ctx *ctx,const char *name,int schedid, +int libxl_cpupool_create (libxl_ctx *ctx,const char *name,int schedid,libxl_cpumap cpumap,libxl_uuid *uuid,uint32_t *poolid);int libxl_cpupool_destroy (libxl_ctx *ctx,uint32_t poolid);diff -r
c91bee33280d-r10f5656caaaatools/libxl/xl_cmdimpl.ctools/libxl/xl_cmdimpl.c +2
-2@@ -5332,7 +5332,7 @@ int main_cpupoolcreate(int argc, char **return 0 ; poolid =0 ; -if (libxl_create_cpupool (ctx, name, schedid, cpumap,&uuid,&poolid)) { +if (libxl_cpupool_create (ctx, name, schedid, cpumap,&uuid,&poolid)) {fprintf (stderr,"error on creating cpupool\n" );return -ERROR_FAIL ; }@@ -5706,7 +5706,7 @@ int main_cpupoolnumasplit(int argc, charsnprintf (name,15 ,"Pool-node%d" , node);libxl_uuid_generate (&uuid); poolid =0 ; - ret = -libxl_create_cpupool (ctx, name, schedid, cpumap,&uuid,&poolid); + ret = -libxl_cpupool_create (ctx, name, schedid, cpumap,&uuid,&poolid);if (ret) {fprintf (stderr,"error on creating cpupool\n" ); goto out;_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Signature · 5 lines
Juergen Gross Principal Developer Operating Systems PDG ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967 Fujitsu Technology Solutions e-mail: [email protected] Domagkstr. 28 Internet: ts.fujitsu.com D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
Re: [PATCH 3 of 3] libxl: do not write/maintain "pool_name" in XenStore
In reply to Ian CampbellQuoted 10 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell<[email protected]> # Date 1327329565 0
# Node IDd8efdb16b1ef06013061da1f47c2dbce4b042992# Parent10f5656caaaa2bdfd6a7ae9aada903da8bddcbb6
libxl: do not write/maintain "pool_name" in XenStoreNothing that I can find ever reads this key.
Signed-off-by Ian Campbell<[email protected]>
Quoted 62 lines
diff -r
10f5656caaaa-rd8efdb16b1eftools/libxl/libxl.ctools/libxl/libxl.c +0
-25@@ -3434,16 +3434,6 @@ int libxl_cpupool_movedomain(libxl_ctx * {GC_INIT (ctx);int rc; -char *dom_path; -char *vm_path; -char *poolname; -xs_transaction_t t; - - dom_path =libxl__xs_get_dompath (gc, domid); -if (!dom_path) { -GC_FREE ; -return ERROR_FAIL ; - } rc =xc_cpupool_movedomain (ctx->xch, poolid, domid);if (rc) {@@ -3453,21 +3443,6 @@ int libxl_cpupool_movedomain(libxl_ctx *return ERROR_FAIL ; } -for (;;) { - t =xs_transaction_start (ctx->xsh); - - poolname =libxl__cpupoolid_to_name (gc, poolid); - vm_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/vm" , dom_path)); -if (!vm_path) -break ; - -libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), -"%s" , poolname); - -if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN )) -break ; - } -GC_FREE ;return 0 ; }diff -r
10f5656caaaa-rd8efdb16b1eftools/libxl/libxl_create.ctools/libxl/libxl_create.c +0
-3@@ -438,9 +438,6 @@ retry_transaction:xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/uuid" , vm_path), uuid_string,strlen (uuid_string));xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/name" , vm_path), info->name,strlen (info->name)); -if (info->poolid !=-1 ) -libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), -"%s" ,libxl__cpupoolid_to_name (gc, info->poolid));libxl__xs_writev (gc, t, dom_path, info->xsdata);libxl__xs_writev (gc, t,libxl__sprintf (gc,"%s/platform" , dom_path), info->platformdata);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Signature · 5 lines
Juergen Gross Principal Developer Operating Systems PDG ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967 Fujitsu Technology Solutions e-mail: [email protected] Domagkstr. 28 Internet: ts.fujitsu.com D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
Re: [PATCH 1 of 3] libxl: remove libxl_domain_create_info.poolname
In reply to Ian CampbellQuoted 7 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1327329346 0
# Node IDc91bee33280debdfe602d28e48318c03ddf0f4c9# Parent4bb2b6a04ec02c3502c1825e2736df54870229e5
libxl: remove libxl_domain_create_info.poolname
Quoted 5 lines
It is redundant with poolid and allowing the user to specify both opens up the possibility of a disconnect.
Also default
c_info->poolidto -1 (no pool) instead of defaulting to 0 in the library and overriding in the toolstack.
The above seems to be a false assumption -- the correct default is 0, libxl does not actually treat -1 as special and xen always creates a single pool on boot.
Found by actually testing without using a pool option which also showed up that the option parsing in xl was wrong, we cannot call libxl_cpupoolid_to_name on an invalid pool (which is the case if no pool is given).
Corrected patch follows.
8<---------------------------------------------------------------------
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1327510469 0
# Node ID 4b54a3680947f9cf24340a3f7e458afc948c7165 # Parent 3f0d2ed701104e7e37560a3262bc7bcd7da5b90b
libxl: remove libxl_domain_create_info.poolname
It is redundant with poolid and allowing the user to specify both opens up the possibility of a disconnect.
tools/libxl/libxl_create.c +3 -2
@@ -438,8 +438,9 @@ retry_transaction:xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/uuid" , vm_path), uuid_string,strlen (uuid_string));xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/name" , vm_path), info->name,strlen (info->name)); -if (info->poolname) -xs_write (ctx->xsh, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), info->poolname,strlen (info->poolname)); +if (info->poolid !=-1 ) +libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/pool_name" , vm_path), +"%s" ,libxl__cpupoolid_to_name (gc, info->poolid));libxl__xs_writev (gc, t, dom_path, info->xsdata);libxl__xs_writev (gc, t,libxl__sprintf (gc,"%s/platform" , dom_path), info->platformdata);
tools/libxl/libxl_types.idl +0 -1
@@ -156,7 +156,6 @@ libxl_domain_create_info = Struct("domai ("xsdata", libxl_key_value_list), ("platformdata", libxl_key_value_list), ("poolid", uint32), - ("poolname", string), ]) libxl_domain_build_info = Struct("domain_build_info",[
tools/libxl/xl_cmdimpl.c +2 -3
@@ -315,7 +315,7 @@ static void printf_info(int domid,printf ("\t(uuid <unknown>)\n" ); } -printf ("\t(cpupool %s)\n" , c_info->poolname); +printf ("\t(cpupool %s)\n" ,libxl_cpupoolid_to_name (ctx, c_info->poolid));if (c_info->xsdata)printf ("\t(xsdata contains data)\n" );else
@@ -643,8 +643,7 @@ static void parse_config_data(const char c_info->poolid =-1 ;cpupool_qualifier_to_cpupoolid (buf, &c_info->poolid,NULL ); } - c_info->poolname =libxl_cpupoolid_to_name (ctx, c_info->poolid); -if (!c_info->poolname) { +if (!libxl_cpupoolid_to_name (ctx, c_info->poolid)) {fprintf (stderr,"Illegal pool specified\n" );exit (1 ); }