Skip to content

Commit

Permalink
xen: Move xenstore cleanup and mkdir functions
Browse files Browse the repository at this point in the history
The name of the functions moved to xen_pvdev.c:
 * xenstore_cleanup_dir
 * xen_config_cleanup
 * xenstore_mkdir

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>
  • Loading branch information
emilcondrea authored and sstabellini committed Oct 29, 2016
1 parent 148512e commit ecf7981
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 49 deletions.
49 changes: 0 additions & 49 deletions hw/xen/xen_backend.c
Expand Up @@ -47,57 +47,8 @@ struct xs_handle *xenstore = NULL;
const char *xen_protocol;

/* private */
struct xs_dirs {
char *xs_dir;
QTAILQ_ENTRY(xs_dirs) list;
};
static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup =
QTAILQ_HEAD_INITIALIZER(xs_cleanup);

static int debug;

static void xenstore_cleanup_dir(char *dir)
{
struct xs_dirs *d;

d = g_malloc(sizeof(*d));
d->xs_dir = dir;
QTAILQ_INSERT_TAIL(&xs_cleanup, d, list);
}

void xen_config_cleanup(void)
{
struct xs_dirs *d;

QTAILQ_FOREACH(d, &xs_cleanup, list) {
xs_rm(xenstore, 0, d->xs_dir);
}
}

int xenstore_mkdir(char *path, int p)
{
struct xs_permissions perms[2] = {
{
.id = 0, /* set owner: dom0 */
}, {
.id = xen_domid,
.perms = p,
}
};

if (!xs_mkdir(xenstore, 0, path)) {
xen_be_printf(NULL, 0, "xs_mkdir %s: failed\n", path);
return -1;
}
xenstore_cleanup_dir(g_strdup(path));

if (!xs_set_permissions(xenstore, 0, path, perms, 2)) {
xen_be_printf(NULL, 0, "xs_set_permissions %s: failed\n", path);
return -1;
}
return 0;
}

int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val)
{
return xenstore_write_str(xendev->be, node, val);
Expand Down
51 changes: 51 additions & 0 deletions hw/xen/xen_pvdev.c
Expand Up @@ -24,11 +24,62 @@

/* private */
static int debug;

struct xs_dirs {
char *xs_dir;
QTAILQ_ENTRY(xs_dirs) list;
};

static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup =
QTAILQ_HEAD_INITIALIZER(xs_cleanup);

static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs =
QTAILQ_HEAD_INITIALIZER(xendevs);

/* ------------------------------------------------------------- */

static void xenstore_cleanup_dir(char *dir)
{
struct xs_dirs *d;

d = g_malloc(sizeof(*d));
d->xs_dir = dir;
QTAILQ_INSERT_TAIL(&xs_cleanup, d, list);
}

void xen_config_cleanup(void)
{
struct xs_dirs *d;

QTAILQ_FOREACH(d, &xs_cleanup, list) {
xs_rm(xenstore, 0, d->xs_dir);
}
}

int xenstore_mkdir(char *path, int p)
{
struct xs_permissions perms[2] = {
{
.id = 0, /* set owner: dom0 */
}, {
.id = xen_domid,
.perms = p,
}
};

if (!xs_mkdir(xenstore, 0, path)) {
xen_be_printf(NULL, 0, "xs_mkdir %s: failed\n", path);
return -1;
}
xenstore_cleanup_dir(g_strdup(path));

if (!xs_set_permissions(xenstore, 0, path, perms, 2)) {
xen_be_printf(NULL, 0, "xs_set_permissions %s: failed\n", path);
return -1;
}
return 0;
}

int xenstore_write_str(const char *base, const char *node, const char *val)
{
char abspath[XEN_BUFSIZE];
Expand Down

0 comments on commit ecf7981

Please sign in to comment.