Commit 8d2a450e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make it possible to name storage devices.

The syntax is:

	-s [name=]type[, args]

Add storage.list command to show storage devices, more details will be
added later.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4836 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 4fbd60f0
......@@ -355,6 +355,7 @@ mgt_cli_init_cls(void)
AZ(CLS_AddFunc(cls, MCF_NOAUTH, cli_auth));
AZ(CLS_AddFunc(cls, MCF_AUTH, cli_proto));
AZ(CLS_AddFunc(cls, MCF_AUTH, cli_debug));
AZ(CLS_AddFunc(cls, MCF_AUTH, cli_stv));
AZ(CLS_AddFunc(cls, MCF_AUTH, cli_askchild));
}
......
......@@ -44,3 +44,6 @@ cli_func_t mcf_config_use;
cli_func_t mcf_config_discard;
cli_func_t mcf_config_list;
cli_func_t mcf_config_show;
/* stevedore.c */
extern struct cli_proto cli_stv[];
......@@ -38,6 +38,7 @@ SVNID("$Id$")
#include "cache.h"
#include "stevedore.h"
#include "cli_priv.h"
static VTAILQ_HEAD(, stevedore) stevedores =
VTAILQ_HEAD_INITIALIZER(stevedores);
......@@ -271,11 +272,20 @@ void
STV_config(const char *spec)
{
char **av;
const char *p, *q;
struct stevedore *stv;
const struct stevedore *stv2;
int ac;
av = ParseArgv(spec, ARGV_COMMA);
int ac, l;
static unsigned seq = 0;
p = strchr(spec, '=');
q = strchr(spec, ',');
if (p != NULL && (q == NULL || q > p)) {
av = ParseArgv(p + 1, ARGV_COMMA);
} else {
av = ParseArgv(spec, ARGV_COMMA);
p = NULL;
}
AN(av);
if (av[0] != NULL)
......@@ -289,6 +299,8 @@ STV_config(const char *spec)
stv2 = pick(STV_choice, av[1], "storage");
AN(stv2);
/* Append to ident string */
vsb_printf(vident, ",-s%s", av[1]);
av += 2;
......@@ -300,6 +312,16 @@ STV_config(const char *spec)
*stv = *stv2;
AN(stv->name);
AN(stv->alloc);
if (p == NULL)
bprintf(stv->ident, "storage_%u", seq++);
else {
l = p - spec;
if (l > sizeof stv->ident - 1)
l = sizeof stv->ident - 1;
bprintf(stv->ident, "%*.*s", l, l, spec);
}
stv->lru = LRU_Alloc();
if (stv->init != NULL)
......@@ -312,3 +334,28 @@ STV_config(const char *spec)
if (!stv_next)
stv_next = VTAILQ_FIRST(&stevedores);
}
/*--------------------------------------------------------------------*/
static void
stv_cli_list(struct cli *cli, const char * const *av, void *priv)
{
struct stevedore *stv;
ASSERT_MGT();
(void)av;
(void)priv;
cli_out(cli, "Storage devices:\n");
VTAILQ_FOREACH(stv, &stevedores, list) {
cli_out(cli, "\tstorage.%s.%s\n", stv->name, stv->ident);
}
}
/*--------------------------------------------------------------------*/
struct cli_proto cli_stv[] = {
{ "storage.list", "storage.list", "List storage devices\n",
0, 0, "", stv_cli_list },
{ NULL}
};
......@@ -65,6 +65,7 @@ struct stevedore {
void *priv;
VTAILQ_ENTRY(stevedore) list;
char ident[16];
};
struct object *STV_NewObject(struct sess *sp, unsigned len, double ttl,
......
......@@ -174,7 +174,7 @@ sma_init(struct stevedore *parent, int ac, char * const *av)
if ((u != (uintmax_t)(size_t)u))
ARGV_ERR("(-smalloc) size \"%s\": too big\n", av[0]);
printf("storage_malloc: max size %ju MB.\n",
printf("storage.malloc.%s: max size %ju MB.\n", parent->ident,
u / (1024 * 1024));
sc->sma_max = u;
......
# $Id$
test "CLI coverage test"
varnish v1 -cliok storage.list
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment