Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
xen.5575
xs-01-temporary-context.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xs-01-temporary-context.patch of Package xen.5575
commit 31b08f76b78a7db101d151a0b0b912c4e974022c Author: Juergen Gross <jgross@suse.com> Date: Tue Jul 19 13:30:42 2016 +0200 xenstore: call each xenstored command function with temporary context In order to be able to avoid leaving temporary memory allocated after processing of a command in xenstored call all command functions with the temporary "in" context. Each function can then make use of that temporary context for allocating temporary memory instead of either leaving that memory allocated until the connection is dropped (or even until end of xenstored) or freeing the memory itself. This requires to modify the interfaces of the functions taking only one argument from the connection by moving the call of onearg() into the single functions. Other than that no functional change. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Index: xen-4.5.5-testing/tools/xenstore/xenstored_core.c =================================================================== --- xen-4.5.5-testing.orig/tools/xenstore/xenstored_core.c +++ xen-4.5.5-testing/tools/xenstore/xenstored_core.c @@ -729,7 +729,7 @@ bool is_valid_nodename(const char *node) /* We expect one arg in the input: return NULL otherwise. * The payload must contain exactly one nul, at the end. */ -static const char *onearg(struct buffered_data *in) +const char *onearg(struct buffered_data *in) { if (!in->used || get_string(in, 0) != in->used) return NULL; @@ -777,9 +777,10 @@ bool check_event_node(const char *node) return true; } -static void send_directory(struct connection *conn, const char *name) +static void send_directory(struct connection *conn, struct buffered_data *in) { struct node *node; + const char *name = onearg(in); name = canonicalize(conn, name); node = get_node(conn, name, XS_PERM_READ); @@ -791,9 +792,10 @@ static void send_directory(struct connec send_reply(conn, XS_DIRECTORY, node->children, node->childlen); } -static void do_read(struct connection *conn, const char *name) +static void do_read(struct connection *conn, struct buffered_data *in) { struct node *node; + const char *name = onearg(in); name = canonicalize(conn, name); node = get_node(conn, name, XS_PERM_READ); @@ -973,9 +975,10 @@ static void do_write(struct connection * send_ack(conn, XS_WRITE); } -static void do_mkdir(struct connection *conn, const char *name) +static void do_mkdir(struct connection *conn, struct buffered_data *in) { struct node *node; + const char *name = onearg(in); name = canonicalize(conn, name); node = get_node(conn, name, XS_PERM_WRITE); @@ -1091,9 +1094,10 @@ static void internal_rm(const char *name } -static void do_rm(struct connection *conn, const char *name) +static void do_rm(struct connection *conn, struct buffered_data *in) { struct node *node; + const char *name = onearg(in); name = canonicalize(conn, name); node = get_node(conn, name, XS_PERM_WRITE); @@ -1126,9 +1130,10 @@ static void do_rm(struct connection *con } -static void do_get_perms(struct connection *conn, const char *name) +static void do_get_perms(struct connection *conn, struct buffered_data *in) { struct node *node; + const char *name = onearg(in); char *strings; unsigned int len; @@ -1243,11 +1248,11 @@ static void process_message(struct conne switch (in->hdr.msg.type) { case XS_DIRECTORY: - send_directory(conn, onearg(in)); + send_directory(conn, in); break; case XS_READ: - do_read(conn, onearg(in)); + do_read(conn, in); break; case XS_WRITE: @@ -1255,15 +1260,15 @@ static void process_message(struct conne break; case XS_MKDIR: - do_mkdir(conn, onearg(in)); + do_mkdir(conn, in); break; case XS_RM: - do_rm(conn, onearg(in)); + do_rm(conn, in); break; case XS_GET_PERMS: - do_get_perms(conn, onearg(in)); + do_get_perms(conn, in); break; case XS_SET_PERMS: @@ -1287,7 +1292,7 @@ static void process_message(struct conne break; case XS_TRANSACTION_END: - do_transaction_end(conn, onearg(in)); + do_transaction_end(conn, in); break; case XS_INTRODUCE: @@ -1295,19 +1300,19 @@ static void process_message(struct conne break; case XS_IS_DOMAIN_INTRODUCED: - do_is_domain_introduced(conn, onearg(in)); + do_is_domain_introduced(conn, in); break; case XS_RELEASE: - do_release(conn, onearg(in)); + do_release(conn, in); break; case XS_GET_DOMAIN_PATH: - do_get_domain_path(conn, onearg(in)); + do_get_domain_path(conn, in); break; case XS_RESUME: - do_resume(conn, onearg(in)); + do_resume(conn, in); break; case XS_SET_TARGET: @@ -1315,7 +1320,7 @@ static void process_message(struct conne break; case XS_RESET_WATCHES: - do_reset_watches(conn); + do_reset_watches(conn, in); break; default: Index: xen-4.5.5-testing/tools/xenstore/xenstored_core.h =================================================================== --- xen-4.5.5-testing.orig/tools/xenstore/xenstored_core.h +++ xen-4.5.5-testing/tools/xenstore/xenstored_core.h @@ -126,6 +126,9 @@ struct node { char *children; }; +/* Return the only argument in the input. */ +const char *onearg(struct buffered_data *in); + /* Break input into vectors, return the number, fill in up to num of them. */ unsigned int get_strings(struct buffered_data *data, char *vec[], unsigned int num); Index: xen-4.5.5-testing/tools/xenstore/xenstored_domain.c =================================================================== --- xen-4.5.5-testing.orig/tools/xenstore/xenstored_domain.c +++ xen-4.5.5-testing/tools/xenstore/xenstored_domain.c @@ -472,8 +472,9 @@ void do_set_target(struct connection *co } /* domid */ -void do_release(struct connection *conn, const char *domid_str) +void do_release(struct connection *conn, struct buffered_data *in) { + const char *domid_str = onearg(in); struct domain *domain; unsigned int domid; @@ -509,10 +510,11 @@ void do_release(struct connection *conn, send_ack(conn, XS_RELEASE); } -void do_resume(struct connection *conn, const char *domid_str) +void do_resume(struct connection *conn, struct buffered_data *in) { struct domain *domain; unsigned int domid; + const char *domid_str = onearg(in); if (!domid_str) { send_error(conn, EINVAL); @@ -546,9 +548,10 @@ void do_resume(struct connection *conn, send_ack(conn, XS_RESUME); } -void do_get_domain_path(struct connection *conn, const char *domid_str) +void do_get_domain_path(struct connection *conn, struct buffered_data *in) { char *path; + const char *domid_str = onearg(in); if (!domid_str) { send_error(conn, EINVAL); @@ -562,10 +565,11 @@ void do_get_domain_path(struct connectio talloc_free(path); } -void do_is_domain_introduced(struct connection *conn, const char *domid_str) +void do_is_domain_introduced(struct connection *conn, struct buffered_data *in) { int result; unsigned int domid; + const char *domid_str = onearg(in); if (!domid_str) { send_error(conn, EINVAL); @@ -582,7 +586,7 @@ void do_is_domain_introduced(struct conn } /* Allow guest to reset all watches */ -void do_reset_watches(struct connection *conn) +void do_reset_watches(struct connection *conn, struct buffered_data *in) { conn_delete_all_watches(conn); conn_delete_all_transactions(conn); Index: xen-4.5.5-testing/tools/xenstore/xenstored_domain.h =================================================================== --- xen-4.5.5-testing.orig/tools/xenstore/xenstored_domain.h +++ xen-4.5.5-testing/tools/xenstore/xenstored_domain.h @@ -26,22 +26,22 @@ void handle_event(void); void do_introduce(struct connection *conn, struct buffered_data *in); /* domid */ -void do_is_domain_introduced(struct connection *conn, const char *domid_str); +void do_is_domain_introduced(struct connection *conn, struct buffered_data *in); /* domid */ -void do_release(struct connection *conn, const char *domid_str); +void do_release(struct connection *conn, struct buffered_data *in); /* domid */ -void do_resume(struct connection *conn, const char *domid_str); +void do_resume(struct connection *conn, struct buffered_data *in); /* domid, target */ void do_set_target(struct connection *conn, struct buffered_data *in); /* domid */ -void do_get_domain_path(struct connection *conn, const char *domid_str); +void do_get_domain_path(struct connection *conn, struct buffered_data *in); /* Allow guest to reset all watches */ -void do_reset_watches(struct connection *conn); +void do_reset_watches(struct connection *conn, struct buffered_data *in); void domain_init(void); Index: xen-4.5.5-testing/tools/xenstore/xenstored_transaction.c =================================================================== --- xen-4.5.5-testing.orig/tools/xenstore/xenstored_transaction.c +++ xen-4.5.5-testing/tools/xenstore/xenstored_transaction.c @@ -187,8 +187,9 @@ void do_transaction_start(struct connect send_reply(conn, XS_TRANSACTION_START, id_str, strlen(id_str)+1); } -void do_transaction_end(struct connection *conn, const char *arg) +void do_transaction_end(struct connection *conn, struct buffered_data *in) { + const char *arg = onearg(in); struct changed_node *i; struct changed_domain *d; struct transaction *trans; Index: xen-4.5.5-testing/tools/xenstore/xenstored_transaction.h =================================================================== --- xen-4.5.5-testing.orig/tools/xenstore/xenstored_transaction.h +++ xen-4.5.5-testing/tools/xenstore/xenstored_transaction.h @@ -23,7 +23,7 @@ struct transaction; void do_transaction_start(struct connection *conn, struct buffered_data *node); -void do_transaction_end(struct connection *conn, const char *arg); +void do_transaction_end(struct connection *conn, struct buffered_data *in); struct transaction *transaction_lookup(struct connection *conn, uint32_t id);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor