<p dir="ltr"><br>
On Jan 27, 2014 4:31 AM, "Stéphane Graber" <<a href="mailto:stgraber@ubuntu.com">stgraber@ubuntu.com</a>> wrote:<br>
><br>
> On Mon, Jan 27, 2014 at 12:59:53AM -0500, S.Çağlar Onur wrote:<br>
> > This allows external users to query network related config items<br>
> > from the running containers.<br>
> ><br>
> > Signed-off-by: S.Çağlar Onur <<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>><br>
><br>
> Looks reasonable, though I'd probably go with get_running_config_item<br>
> instead of get_cmd_config_item.<br>
><br>
> If you're fine with that rename, I'll do the change and apply it.</p>
<p dir="ltr">Yes, that's fine with me. Thanks!</p>
<p dir="ltr">> > ---<br>
> > src/lxc/lxc_info.c | 8 ++++----<br>
> > src/lxc/lxccontainer.c | 14 ++++++++++++++<br>
> > src/lxc/lxccontainer.h | 13 +++++++++++++<br>
> > 3 files changed, 31 insertions(+), 4 deletions(-)<br>
> ><br>
> > diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c<br>
> > index ee45c58..501d9c8 100644<br>
> > --- a/src/lxc/lxc_info.c<br>
> > +++ b/src/lxc/lxc_info.c<br>
> > @@ -139,7 +139,7 @@ static unsigned long long str_size_humanize(char *iobuf, size_t iobufsz)<br>
> > return val;<br>
> > }<br>
> ><br>
> > -static void print_net_stats(const char *name, const char *lxcpath)<br>
> > +static void print_net_stats(struct lxc_container *c)<br>
> > {<br>
> > int rc,netnr;<br>
> > unsigned long long rx_bytes = 0, tx_bytes = 0;<br>
> > @@ -149,7 +149,7 @@ static void print_net_stats(const char *name, const char *lxcpath)<br>
> ><br>
> > for(netnr = 0; ;netnr++) {<br>
> > sprintf(buf, "lxc.network.%d.type", netnr);<br>
> > - type = lxc_cmd_get_config_item(name, buf, lxcpath);<br>
> > + type = c->get_cmd_config_item(c, buf);<br>
> > if (!type)<br>
> > break;<br>
> ><br>
> > @@ -159,7 +159,7 @@ static void print_net_stats(const char *name, const char *lxcpath)<br>
> > sprintf(buf, "lxc.network.%d.link", netnr);<br>
> > }<br>
> > free(type);<br>
> > - ifname = lxc_cmd_get_config_item(name, buf, lxcpath);<br>
> > + ifname = c->get_cmd_config_item(c, buf);<br>
> > if (!ifname)<br>
> > return;<br>
> > printf("%-15s %s\n", "Link:", ifname);<br>
> > @@ -326,7 +326,7 @@ static int print_info(const char *name, const char *lxcpath)<br>
> ><br>
> > if (stats) {<br>
> > print_stats(c);<br>
> > - print_net_stats(name, lxcpath);<br>
> > + print_net_stats(c);<br>
> > }<br>
> ><br>
> > for(i = 0; i < keys; i++) {<br>
> > diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c<br>
> > index d0c5e07..1ddac35 100644<br>
> > --- a/src/lxc/lxccontainer.c<br>
> > +++ b/src/lxc/lxccontainer.c<br>
> > @@ -1738,6 +1738,19 @@ static int lxcapi_get_config_item(struct lxc_container *c, const char *key, char<br>
> > return ret;<br>
> > }<br>
> ><br>
> > +static char* lxcapi_get_cmd_config_item(struct lxc_container *c, const char *key)<br>
> > +{<br>
> > + char *ret;<br>
> > +<br>
> > + if (!c || !c->lxc_conf)<br>
> > + return NULL;<br>
> > + if (container_mem_lock(c))<br>
> > + return NULL;<br>
> > + ret = lxc_cmd_get_config_item(c->name, key, c->get_config_path(c));<br>
> > + container_mem_unlock(c);<br>
> > + return ret;<br>
> > +}<br>
> > +<br>
> > static int lxcapi_get_keys(struct lxc_container *c, const char *key, char *retv, int inlen)<br>
> > {<br>
> > if (!key)<br>
> > @@ -3259,6 +3272,7 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath<br>
> > c->clear_config = lxcapi_clear_config;<br>
> > c->clear_config_item = lxcapi_clear_config_item;<br>
> > c->get_config_item = lxcapi_get_config_item;<br>
> > + c->get_cmd_config_item = lxcapi_get_cmd_config_item;<br>
> > c->get_cgroup_item = lxcapi_get_cgroup_item;<br>
> > c->set_cgroup_item = lxcapi_set_cgroup_item;<br>
> > c->get_config_path = lxcapi_get_config_path;<br>
> > diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h<br>
> > index 84caa31..ed9b767 100644<br>
> > --- a/src/lxc/lxccontainer.h<br>
> > +++ b/src/lxc/lxccontainer.h<br>
> > @@ -410,6 +410,19 @@ struct lxc_container {<br>
> > */<br>
> > int (*get_config_item)(struct lxc_container *c, const char *key, char *retv, int inlen);<br>
> ><br>
> > +<br>
> > + /*!<br>
> > + * \brief Retrieve the value of a config item from running container.<br>
> > + *<br>
> > + * \param c Container.<br>
> > + * \param key Name of option to get.<br>
> > + *<br>
> > + * \return the item or NULL on error.<br>
> > + *<br>
> > + * \note Returned string must be freed by the caller.<br>
> > + */<br>
> > + char* (*get_cmd_config_item)(struct lxc_container *c, const char *key);<br>
> > +<br>
> > /*!<br>
> > * \brief Retrieve a list of config item keys given a key<br>
> > * prefix.<br>
> > --<br>
> > 1.8.3.2<br>
> ><br>
> > _______________________________________________<br>
> > lxc-devel mailing list<br>
> > <a href="mailto:lxc-devel@lists.linuxcontainers.org">lxc-devel@lists.linuxcontainers.org</a><br>
> > <a href="http://lists.linuxcontainers.org/listinfo/lxc-devel">http://lists.linuxcontainers.org/listinfo/lxc-devel</a><br>
><br>
> --<br>
> Stéphane Graber<br>
> Ubuntu developer<br>
> <a href="http://www.ubuntu.com">http://www.ubuntu.com</a><br>
><br>
> _______________________________________________<br>
> lxc-devel mailing list<br>
> <a href="mailto:lxc-devel@lists.linuxcontainers.org">lxc-devel@lists.linuxcontainers.org</a><br>
> <a href="http://lists.linuxcontainers.org/listinfo/lxc-devel">http://lists.linuxcontainers.org/listinfo/lxc-devel</a><br>
><br>
</p>