From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 16/23] libxl: suspend: New libxl__domain_pvcontrol_xspath Date: Tue, 17 Dec 2013 18:35:30 +0000 Message-ID: <1387305337-15355-17-git-send-email-ian.jackson@eu.citrix.com> References: <1387305337-15355-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1387305337-15355-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: Shriram Rajagopalan , George Dunlap , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Factor out the pv control node xenstore path calculation into libxl__domain_pvcontrol_xspath. This xs path calculation was open coded in libxl__domain_pvcontrol_read and _write. This is undesirable because it duplicates the code and because it makes the path inaccessible to other parts of libxl (which are soon going to want it). No functional change. Signed-off-by: Ian Jackson CC: Stefano Stabellini CC: Ian Campbell --- tools/libxl/libxl.c | 21 +++++++++++---------- tools/libxl/libxl_internal.h | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 51158aa..8d70a45 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -898,17 +898,23 @@ int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid) return !!pvdriver; } -char * libxl__domain_pvcontrol_read(libxl__gc *gc, xs_transaction_t t, - uint32_t domid) +const char *libxl__domain_pvcontrol_xspath(libxl__gc *gc, uint32_t domid) { - const char *shutdown_path; const char *dom_path; dom_path = libxl__xs_get_dompath(gc, domid); if (!dom_path) return NULL; - shutdown_path = libxl__sprintf(gc, "%s/control/shutdown", dom_path); + return GCSPRINTF("%s/control/shutdown", dom_path); +} + +char * libxl__domain_pvcontrol_read(libxl__gc *gc, xs_transaction_t t, + uint32_t domid) +{ + const char *shutdown_path; + + shutdown_path = libxl__domain_pvcontrol_xspath(gc, domid); if (!shutdown_path) return NULL; @@ -919,13 +925,8 @@ int libxl__domain_pvcontrol_write(libxl__gc *gc, xs_transaction_t t, uint32_t domid, const char *cmd) { const char *shutdown_path; - const char *dom_path; - - dom_path = libxl__xs_get_dompath(gc, domid); - if (!dom_path) - return ERROR_FAIL; - shutdown_path = libxl__sprintf(gc, "%s/control/shutdown", dom_path); + shutdown_path = libxl__domain_pvcontrol_xspath(gc, domid); if (!shutdown_path) return ERROR_FAIL; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 55293f1..93e0d4e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -967,6 +967,7 @@ _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid, /* returns 0 or 1, or a libxl error code */ _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid); +_hidden const char *libxl__domain_pvcontrol_xspath(libxl__gc*, uint32_t domid); _hidden char * libxl__domain_pvcontrol_read(libxl__gc *gc, xs_transaction_t t, uint32_t domid); _hidden int libxl__domain_pvcontrol_write(libxl__gc *gc, xs_transaction_t t, -- 1.7.10.4