lxc_log_define(lxc_freezer, lxc);
-static int freeze_unfreeze(const char *name, int freeze)
+static int freeze_unfreeze(const char *name, int freeze, const char *lxcpath)
{
char *nsgroup;
char freezer[MAXPATHLEN], *f;
ret = strncmp(f, tmpf, strlen(f));
if (!ret)
{
- lxc_monitor_send_state(name, freeze ? FROZEN : THAWED);
+ lxc_monitor_send_state(name, freeze ? FROZEN : THAWED, lxcpath);
break; /* Success */
}
return ret;
}
-int lxc_freeze(const char *name)
+int lxc_freeze(const char *name, const char *lxcpath)
{
- lxc_monitor_send_state(name, FREEZING);
- return freeze_unfreeze(name, 1);
+ lxc_monitor_send_state(name, FREEZING, lxcpath);
+ return freeze_unfreeze(name, 1, lxcpath);
}
-int lxc_unfreeze(const char *name)
+int lxc_unfreeze(const char *name, const char *lxcpath)
{
- return freeze_unfreeze(name, 0);
+ return freeze_unfreeze(name, 0, lxcpath);
}
* The function will return an fd corresponding to the events
* Returns a file descriptor on success, < 0 otherwise
*/
-extern int lxc_monitor_open(void);
+extern int lxc_monitor_open(const char *lxcpath);
/*
* Read the state of the container if this one has changed
* @name : the container name
* Returns 0 on success, < 0 otherwise
*/
-extern int lxc_freeze(const char *name);
+extern int lxc_freeze(const char *name, const char *lxcpath);
/*
* Unfreeze all previously frozen tasks.
* @name : the name of the container
* Return 0 on sucess, < 0 otherwise
*/
-extern int lxc_unfreeze(const char *name);
+extern int lxc_unfreeze(const char *name, const char *lxcpath);
/*
* Retrieve the container state
my_args.progname, my_args.quiet))
return -1;
- return lxc_freeze(my_args.name);
+ return lxc_freeze(my_args.name, my_args.lxcpath);
}
return -1;
}
- fd = lxc_monitor_open();
+ fd = lxc_monitor_open(my_args.lxcpath);
if (fd < 0)
return -1;
my_args.progname, my_args.quiet))
return -1;
- return lxc_unfreeze(my_args.name);
+ return lxc_unfreeze(my_args.name, my_args.lxcpath);
}
if (lxclock(c->slock, 0))
return false;
- ret = lxc_freeze(c->name);
+ ret = lxc_freeze(c->name, c->config_path);
lxcunlock(c->slock);
if (ret)
return false;
if (lxclock(c->slock, 0))
return false;
- ret = lxc_unfreeze(c->name);
+ ret = lxc_unfreeze(c->name, c->config_path);
lxcunlock(c->slock);
if (ret)
return false;
#define UNIX_PATH_MAX 108
#endif
-static void lxc_monitor_send(struct lxc_msg *msg)
+static void lxc_monitor_send(struct lxc_msg *msg, const char *lxcpath)
{
int fd;
struct sockaddr_un addr = { .sun_family = AF_UNIX };
char *offset = &addr.sun_path[1];
-
- strcpy(offset, "lxc-monitor");
+ size_t ret, len;
+
+ /*
+ * addr.sun_path is only 108 bytes.
+ * should we take a hash of lxcpath? a subset of it?
+ */
+ len = sizeof(addr.sun_path) - 1;
+ ret = snprintf(offset, len, "%s/lxc-monitor", lxcpath);
+ if (ret < 0 || ret >= len) {
+ ERROR("lxcpath too long to open monitor");
+ return;
+ }
fd = socket(PF_UNIX, SOCK_DGRAM, 0);
if (fd < 0)
close(fd);
}
-void lxc_monitor_send_state(const char *name, lxc_state_t state)
+void lxc_monitor_send_state(const char *name, lxc_state_t state, const char *lxcpath)
{
struct lxc_msg msg = { .type = lxc_msg_state,
.value = state };
strncpy(msg.name, name, sizeof(msg.name));
msg.name[sizeof(msg.name) - 1] = 0;
- lxc_monitor_send(&msg);
+ lxc_monitor_send(&msg, lxcpath);
}
-int lxc_monitor_open(void)
+int lxc_monitor_open(const char *lxcpath)
{
struct sockaddr_un addr = { .sun_family = AF_UNIX };
char *offset = &addr.sun_path[1];
int fd;
-
- strcpy(offset, "lxc-monitor");
+ size_t ret, len;
+
+ /*
+ * addr.sun_path is only 108 bytes.
+ * should we take a hash of lxcpath? a subset of it?
+ */
+ len = sizeof(addr.sun_path) - 1;
+ ret = snprintf(offset, len, "%s/lxc-monitor", lxcpath);
+ if (ret < 0 || ret >= len) {
+ ERROR("lxcpath too long to open monitor");
+ return -1;
+ }
fd = socket(PF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
int value;
};
-void lxc_monitor_send_state(const char *name, lxc_state_t state);
-void lxc_monitor_send_priority(const char *name, int priority);
-void lxc_monitor_cleanup(const char *name);
+void lxc_monitor_send_state(const char *name, lxc_state_t state,
+ const char *lxcpath);
#endif
int lxc_set_state(const char *name, struct lxc_handler *handler, lxc_state_t state)
{
handler->state = state;
- lxc_monitor_send_state(name, state);
+ lxc_monitor_send_state(name, state, handler->lxcpath);
return 0;
}
memset(handler, 0, sizeof(*handler));
handler->conf = conf;
+ handler->lxcpath = lxcpath;
apparmor_handler_init(handler);
handler->name = strdup(name);
int aa_enabled;
#endif
int pinfd;
+ const char *lxcpath;
};
extern struct lxc_handler *lxc_init(const char *name, struct lxc_conf *, const char *);
if (fillwaitedstates(states, s))
return -1;
- fd = lxc_monitor_open();
+ fd = lxc_monitor_open(lxcpath);
if (fd < 0)
return -1;
answer.ret = kill(handler->pid, SIGKILL);
if (!answer.ret) {
- ret = lxc_unfreeze(handler->name);
+ ret = lxc_unfreeze(handler->name, handler->lxcpath);
if (!ret)
return 0;