tools/libs/store: cleanup libxenstore interface
There are some internals in the libxenstore interface which should be removed.
Move those functions into xs_lib.c and the related definitions into xs_lib.h. Remove the functions from the mapfile. Add xs_lib.o to xenstore_client as some of the internal functions are needed there.
--- tools/include/xenstore_lib.h | 34 --------- tools/libs/store/libxenstore.map | 8 -- tools/libs/store/xs.c | 112 +--------------------------- tools/xenstore/Makefile | 4 +- tools/xenstore/utils.h | 11 +++ tools/xenstore/xenstore_client.c | 2 + tools/xenstore/xenstored_control.c | 1 + tools/xenstore/xenstored_core.c | 2 +- tools/xenstore/xs_lib.c | 114 ++++++++++++++++++++++++++++- tools/xenstore/xs_lib.h | 50 +++++++++++++ 10 files changed, 181 insertions(+), 157 deletions(-) create mode 100644 tools/xenstore/xs_lib.h
tools/include/xenstore_lib.h +0 -34
@@ -43,25 +43,13 @@ struct xs_permissionsenum xs_perm_type perms; }; -/* Header of the node record in tdb. */ -struct xs_tdb_record_hdr { -uint64_t generation; -uint32_t num_perms; -uint32_t datalen; -uint32_t childlen; -struct xs_permissions perms[0 ]; -}; -/* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */ #define MAX_STRLEN (x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)/* Path for various daemon things: env vars can override. */ -const char *xs_daemon_rootdir (void );const char *xs_daemon_rundir (void );const char *xs_daemon_socket (void );const char *xs_daemon_socket_ro (void ); -const char *xs_domain_dev (void ); -const char *xs_daemon_tdb (void );/* Simple write function: loops for you. */ bool xs_write_all (int fd,const void *data,unsigned int len);
@@ -70,26 +58,4 @@ bool xs_write_all(int fd, const void *data, unsigned int len);bool xs_strings_to_perms (struct xs_permissions *perms,unsigned int num,const char *strings); -/* Convert permissions to a string (up to len MAX_STRLEN(unsigned int)+1). */ -bool xs_perm_to_string (const struct xs_permissions *perm, -char *buffer,size_t buf_len); - -/* Given a string and a length, count how many strings (nul terms). */ -unsigned int xs_count_strings (const char *strings,unsigned int len); - -/* Sanitising (quoting) possibly-binary strings. */ -struct expanding_buffer { -char *buf; -int avail; -}; - -/* Ensure that given expanding buffer has at least min_avail characters. */ -char *expanding_buffer_ensure (struct expanding_buffer *,int min_avail); - -/* sanitise_value() may return NULL if malloc fails. */ -char *sanitise_value (struct expanding_buffer *,const char *val,unsigned len); - -/* *out_len_r on entry is ignored; out must be at least strlen(in)+1 bytes. */ -void unsanitise_value (char *out,unsigned *out_len_r,const char *in); -#endif /* XENSTORE_LIB_H */
tools/libs/store/libxenstore.map +0 -8
@@ -32,18 +32,10 @@ VERS_3.0.3 { xs_control_command; xs_debug_command; xs_suspend_evtchn_port; - xs_daemon_rootdir; xs_daemon_rundir; xs_daemon_socket; xs_daemon_socket_ro; - xs_domain_dev; - xs_daemon_tdb; xs_write_all; xs_strings_to_perms; - xs_perm_to_string; - xs_count_strings; - expanding_buffer_ensure; - sanitise_value; - unsanitise_value; local: *; /* Do not expose anything by default */ };
tools/libs/store/xs.c +1 -111
124 lines not on this page · raw message
tools/xenstore/Makefile +2 -2
@@ -78,8 +78,8 @@ xenstored.a: $(XENSTORED_OBJS) $(CLIENTS): xenstore ln -f xenstore $@ -xenstore: xenstore_client.o - $(CC) $< $(LDFLAGS) $(LDLIBS_libxenstore) $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS) +xenstore: xenstore_client.o xs_lib.o + $(CC) $^ $(LDFLAGS) $(LDLIBS_libxenstore) $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS) xenstore-control: xenstore_control.o $(CC) $< $(LDFLAGS) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS)
tools/xenstore/utils.h +11 -0
@@ -7,6 +7,17 @@#include <xen-tools/libs.h> +#include "xenstore_lib.h" + +/* Header of the node record in tdb. */ +struct xs_tdb_record_hdr { +uint64_t generation; +uint32_t num_perms; +uint32_t datalen; +uint32_t childlen; +struct xs_permissions perms[0 ]; +}; +/* Is A == B ? */ #define streq (a,b) (strcmp((a),(b)) == 0)
tools/xenstore/xenstore_client.c +2 -0
@@ -22,6 +22,8 @@#include <sys/ioctl.h> +#include "xs_lib.h" +#define PATH_SEP '/'#define MAX_PATH_LEN 256
tools/xenstore/xenstored_control.c +1 -0
@@ -34,6 +34,7 @@ Interactive commands for Xen Store Daemon.#include "utils.h" #include "talloc.h" +#include "xs_lib.h" #include "xenstored_core.h" #include "xenstored_control.h" #include "xenstored_domain.h"
tools/xenstore/xenstored_core.c +1 -1
@@ -46,7 +46,7 @@#include "utils.h" #include "list.h" #include "talloc.h" -#include "xenstore_lib.h" +#include "xs_lib.h" #include "xenstored_core.h" #include "xenstored_watch.h" #include "xenstored_transaction.h"
tools/xenstore/xs_lib.c +113 -1
128 lines not on this page · raw message
tools/xenstore/xs_lib.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.26.2
Juergen Gross writes ("[PATCH-for-4.15] tools/libs/store: cleanup libxenstore interface"):
Quoted 6 lines
There are some internals in the libxenstore interface which should be removed.
Move those functions into
xs_lib.cand the related definitions intoxs_lib.h. Remove the functions from the mapfile. Add xs_lib.o toxenstore_clientas some of the internal functions are needed there.
This seems wider in scope than I was expecting.
Reviewing it again makes me think that there are more concers than I anticipated and I am now doubtful whether I want to take it in 4.15.
I thought at this stage we were just going to fix the accidentally-exported symbols with improperly namespaced names. It is those for which I think that withdrawing them without an ABI soname bump, in contravention of usual library ABI stability rules, will not cause trouble in pracice.
My current thoughts are that several of these really ought not to be withdrawn as they might cause actual trouble:
tools/include/xenstore_lib.h struct xs_permissions · line 64
Quoted 4 lines
/* Path for various daemon things: env vars can override. */
tools/include/xenstore_lib.h +0
-3-const char *xs_daemon_rootdir (void ); -const char *xs_domain_dev (void ); -const char *xs_daemon_tdb (void );
Someone who was writing bindings might have exposed these without knowing what they were, resulting in linkage to these symbols.
tools/include/xenstore_lib.h bool xs_write_all(int fd, const void *data, unsigned int len); · line 75
Quoted 6 lines
bool xs_strings_to_perms(struct
xs_permissions*perms, unsigned int num,tools/include/xenstore_lib.h +0
-3const char *strings); -/* Convert permissions to a string (up to len MAX_STRLEN(unsigned int)+1). */ -bool xs_perm_to_string (const struct xs_permissions *perm, -char *buffer,size_t buf_len);
Isn't this function potentially useful ? It seems funny to have only one of the conversion directions.
Quoted 1 line
+void
unsanitise_value(char *out, unsigned *out_len_r, const char *in)
Is it possible to do sort this out in a more minimal way ? Eg we could change the name to namespace it properly. (I haven't looked at the code in detail and am still rather under-caffeinated so maybe I am talking nonsense here.)
Ian.
Quoted 4 lines · Ian Jackson
Juergen Gross writes ("[PATCH-for-4.15]
tools/libs/store: cleanup libxenstore interface"):Quoted 3 lines
There are some internals in the libxenstore interface which should be removed.
Quoted 8 lines
Quoted 3 lines
Move those functions into
xs_lib.cand the related definitions intoxs_lib.h. Remove the functions from the mapfile. Add xs_lib.o toxenstore_clientas some of the internal functions are needed there.This seems wider in scope than I was expecting.
Reviewing it again makes me think that there are more concers than I anticipated and I am now doubtful whether I want to take it in 4.15.
I'm fine with that. TBH I would have been surprised if you'd just take it. :-)
Quoted 5 lines
I thought at this stage we were just going to fix the accidentally-exported symbols with improperly namespaced names. It is those for which I think that withdrawing them without an ABI soname bump, in contravention of usual library ABI stability rules, will not cause trouble in pracice.
Just removing them from the mapfile doesn't work.
Either we need to keep them (maybe with "xs_" prefixed), or we need to go the way I've done in this patch.
Quoted 10 lines
My current thoughts are that several of these really ought not to be withdrawn as they might cause actual trouble:
tools/include/xenstore_lib.h struct xs_permissions · line 64
Quoted 4 lines
/* Path for various daemon things: env vars can override. */
tools/include/xenstore_lib.h +0
-3-const char *xs_daemon_rootdir (void ); -const char *xs_domain_dev (void ); -const char *xs_daemon_tdb (void );Someone who was writing bindings might have exposed these without knowing what they were, resulting in linkage to these symbols.
This patch is removing everything not being used in the (known) Xen ecosystem (Xen, qemu, qemu-trad, mini-os).
Quoted 10 lines
tools/include/xenstore_lib.h bool xs_write_all(int fd, const void *data, unsigned int len); · line 75
Quoted 7 lines
bool xs_strings_to_perms(struct
xs_permissions*perms, unsigned int num,
const char *strings);tools/include/xenstore_lib.h +0
-3-/* Convert permissions to a string (up to len MAX_STRLEN(unsigned int)+1). */ -bool xs_perm_to_string (const struct xs_permissions *perm, -char *buffer,size_t buf_len);Isn't this function potentially useful ? It seems funny to have only one of the conversion directions.
As stated above: this patch is doing the absolute possible maximum. I'm absolutely fine to drop some of the removals.
Quoted 6 lines
Quoted 1 line
+void
unsanitise_value(char *out, unsigned *out_len_r, const char *in)Is it possible to do sort this out in a more minimal way ? Eg we could change the name to namespace it properly. (I haven't looked at the code in detail and am still rather under-caffeinated so maybe I am talking nonsense here.)
No nonsense. This would be the really minimum option (apart from doing nothing).
I can setup the patch for that and keep the rest for 4.16 (which will then probably need to bump the so version).
Juergen
Jürgen Groß writes ("Re: [PATCH-for-4.15] tools/libs/store: cleanup libxenstore interface"):
Quoted 11 lines · Ian Jackson
Quoted 4 lines
Is it possible to do sort this out in a more minimal way ? Eg we could change the name to namespace it properly. (I haven't looked at the code in detail and am still rather under-caffeinated so maybe I am talking nonsense here.)
No nonsense. This would be the really minimum option (apart from doing nothing).
I can setup the patch for that and keep the rest for 4.16 (which will then probably need to bump the so version).
Hmmm. Maybe it would be less disruptive to punt the whole lot for xen-next. That way we don't have a silent withdrawl in one release followed by a soname bump in the next.
If you're keen to change this for 4.15, please feel free to show me what the patch looks like. But I would be inclined to postpone this.
Thanks,
Ian.
Quoted 13 lines · Ian Jackson
Jürgen Groß writes ("Re: [PATCH-for-4.15]
tools/libs/store: cleanup libxenstore interface"):Quoted 11 lines · Ian Jackson
Quoted 4 lines
Is it possible to do sort this out in a more minimal way ? Eg we could change the name to namespace it properly. (I haven't looked at the code in detail and am still rather under-caffeinated so maybe I am talking nonsense here.)
No nonsense. This would be the really minimum option (apart from doing nothing).
I can setup the patch for that and keep the rest for 4.16 (which will then probably need to bump the so version).
Quoted 6 lines
Hmmm. Maybe it would be less disruptive to punt the whole lot for xen-next. That way we don't have a silent withdrawl in one release followed by a soname bump in the next.
If you're keen to change this for 4.15, please feel free to show me what the patch looks like. But I would be inclined to postpone this.
Minimal variant sent. I'm not keen to have that for 4.15, but the patch was just ready. :-)
Juergen
Jürgen Groß writes ("Re: [PATCH-for-4.15] tools/libs/store: cleanup libxenstore interface"):
Quoted 6 lines · Ian Jackson
Quoted 2 lines
If you're keen to change this for 4.15, please feel free to show me what the patch looks like. But I would be inclined to postpone this.
Minimal variant sent. I'm not keen to have that for 4.15, but the patch was just ready. :-)
Thanks :-). However, looking at it I think it would be best to postpone this for xen-next and then do the full fix with soname bump.
Ian.