diff options
author | Emil Condrea <emilcondrea@gmail.com> | 2016-10-25 08:50:09 +0300 |
---|---|---|
committer | Stefano Stabellini <sstabellini@kernel.org> | 2016-10-28 17:52:48 -0700 |
commit | f0021dba622f562d42982f4f4105a7e14ef7535c (patch) | |
tree | 3a216ed2e908a0ee97d38dc488cf93e2d624d736 /hw/xen/xen_backend.c | |
parent | b9730c5b4e7132b5e49806c6724f91d760e88d17 (diff) |
xen: Create a new file xen_pvdev.c
The purpose of the new file is to store generic functions shared by frontend
and backends such as xenstore operations, xendevs.
Signed-off-by: Quan Xu <quan.xu@intel.com>
Signed-off-by: Emil Condrea <emilcondrea@gmail.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Quan Xu <xuquan8@huawei.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Diffstat (limited to 'hw/xen/xen_backend.c')
-rw-r--r-- | hw/xen/xen_backend.c | 126 |
1 files changed, 1 insertions, 125 deletions
diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 0e95880138..b32b0dd6f8 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -30,6 +30,7 @@ #include "sysemu/char.h" #include "qemu/log.h" #include "hw/xen/xen_backend.h" +#include "hw/xen/xen_pvdev.h" #include <xen/grant_table.h> @@ -57,8 +58,6 @@ static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = QTAILQ_HEAD_INITIALIZER(xendevs); static int debug; -/* ------------------------------------------------------------- */ - static void xenstore_cleanup_dir(char *dir) { struct xs_dirs *d; @@ -77,34 +76,6 @@ void xen_config_cleanup(void) } } -int xenstore_write_str(const char *base, const char *node, const char *val) -{ - char abspath[XEN_BUFSIZE]; - - snprintf(abspath, sizeof(abspath), "%s/%s", base, node); - if (!xs_write(xenstore, 0, abspath, val, strlen(val))) { - return -1; - } - return 0; -} - -char *xenstore_read_str(const char *base, const char *node) -{ - char abspath[XEN_BUFSIZE]; - unsigned int len; - char *str, *ret = NULL; - - snprintf(abspath, sizeof(abspath), "%s/%s", base, node); - str = xs_read(xenstore, 0, abspath, &len); - if (str != NULL) { - /* move to qemu-allocated memory to make sure - * callers can savely g_free() stuff. */ - ret = g_strdup(str); - free(str); - } - return ret; -} - int xenstore_mkdir(char *path, int p) { struct xs_permissions perms[2] = { @@ -129,48 +100,6 @@ int xenstore_mkdir(char *path, int p) return 0; } -int xenstore_write_int(const char *base, const char *node, int ival) -{ - char val[12]; - - snprintf(val, sizeof(val), "%d", ival); - return xenstore_write_str(base, node, val); -} - -int xenstore_write_int64(const char *base, const char *node, int64_t ival) -{ - char val[21]; - - snprintf(val, sizeof(val), "%"PRId64, ival); - return xenstore_write_str(base, node, val); -} - -int xenstore_read_int(const char *base, const char *node, int *ival) -{ - char *val; - int rc = -1; - - val = xenstore_read_str(base, node); - if (val && 1 == sscanf(val, "%d", ival)) { - rc = 0; - } - g_free(val); - return rc; -} - -int xenstore_read_uint64(const char *base, const char *node, uint64_t *uval) -{ - char *val; - int rc = -1; - - val = xenstore_read_str(base, node); - if (val && 1 == sscanf(val, "%"SCNu64, uval)) { - rc = 0; - } - g_free(val); - return rc; -} - int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val) { return xenstore_write_str(xendev->be, node, val); @@ -214,20 +143,6 @@ int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, /* ------------------------------------------------------------- */ -const char *xenbus_strstate(enum xenbus_state state) -{ - static const char *const name[] = { - [XenbusStateUnknown] = "Unknown", - [XenbusStateInitialising] = "Initialising", - [XenbusStateInitWait] = "InitWait", - [XenbusStateInitialised] = "Initialised", - [XenbusStateConnected] = "Connected", - [XenbusStateClosing] = "Closing", - [XenbusStateClosed] = "Closed", - }; - return (state < ARRAY_SIZE(name)) ? name[state] : "INVALID"; -} - int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state) { int rc; @@ -827,45 +742,6 @@ int xen_be_send_notify(struct XenDevice *xendev) return xenevtchn_notify(xendev->evtchndev, xendev->local_port); } -/* - * msg_level: - * 0 == errors (stderr + logfile). - * 1 == informative debug messages (logfile only). - * 2 == noisy debug messages (logfile only). - * 3 == will flood your log (logfile only). - */ -void xen_be_printf(struct XenDevice *xendev, int msg_level, - const char *fmt, ...) -{ - va_list args; - - if (xendev) { - if (msg_level > xendev->debug) { - return; - } - qemu_log("xen be: %s: ", xendev->name); - if (msg_level == 0) { - fprintf(stderr, "xen be: %s: ", xendev->name); - } - } else { - if (msg_level > debug) { - return; - } - qemu_log("xen be core: "); - if (msg_level == 0) { - fprintf(stderr, "xen be core: "); - } - } - va_start(args, fmt); - qemu_log_vprintf(fmt, args); - va_end(args); - if (msg_level == 0) { - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - } - qemu_log_flush(); -} static int xen_sysdev_init(SysBusDevice *dev) { |