virStringListFree(ret);
return NULL;
}
+
+
+char **
+virshStoragePoolNameCompleter(vshControl *ctl,
+ const vshCmd *cmd ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virshControlPtr priv = ctl->privData;
+ virStoragePoolPtr *pools = NULL;
+ int npools = 0;
+ size_t i = 0;
+ char **ret = NULL;
+
+ virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE |
+ VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE |
+ VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT,
+ NULL);
+
+ if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
+ return NULL;
+
+ if ((npools = virConnectListAllStoragePools(priv->conn, &pools, flags)) < 0)
+ return NULL;
+
+ if (VIR_ALLOC_N(ret, npools + 1) < 0)
+ goto error;
+
+ for (i = 0; i < npools; i++) {
+ const char *name = virStoragePoolGetName(pools[i]);
+
+ if (VIR_STRDUP(ret[i], name) < 0)
+ goto error;
+
+ virStoragePoolFree(pools[i]);
+ }
+ VIR_FREE(pools);
+
+ return ret;
+
+ error:
+ for (; i < npools; i++)
+ virStoragePoolFree(pools[i]);
+ VIR_FREE(pools);
+ for (i = 0; i < npools; i++)
+ VIR_FREE(ret[i]);
+ VIR_FREE(ret);
+ return NULL;
+}
#include "virstring.h"
#include "virtime.h"
-#define VIRSH_COMMON_OPT_POOL_FULL \
- VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"))
+#define VIRSH_COMMON_OPT_POOL_FULL(cflags) \
+ VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"), cflags)
#define VIRSH_COMMON_OPT_POOL_BUILD \
{.name = "build", \
};
static const vshCmdOptDef opts_pool_autostart[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT),
{.name = "disable",
.type = VSH_OT_BOOL,
};
static const vshCmdOptDef opts_pool_build[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(0),
VIRSH_COMMON_OPT_POOL_NO_OVERWRITE,
VIRSH_COMMON_OPT_POOL_OVERWRITE,
};
static const vshCmdOptDef opts_pool_destroy[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE),
{.name = NULL}
};
};
static const vshCmdOptDef opts_pool_delete[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE),
{.name = NULL}
};
};
static const vshCmdOptDef opts_pool_refresh[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(0),
{.name = NULL}
};
};
static const vshCmdOptDef opts_pool_dumpxml[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(0),
{.name = "inactive",
.type = VSH_OT_BOOL,
};
static const vshCmdOptDef opts_pool_info[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(0),
{.name = "bytes",
.type = VSH_OT_BOOL,
};
static const vshCmdOptDef opts_pool_name[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(0),
{.name = NULL}
};
};
static const vshCmdOptDef opts_pool_start[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE),
VIRSH_COMMON_OPT_POOL_BUILD,
VIRSH_COMMON_OPT_POOL_NO_OVERWRITE,
VIRSH_COMMON_OPT_POOL_OVERWRITE,
};
static const vshCmdOptDef opts_pool_undefine[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT),
{.name = NULL}
};
};
static const vshCmdOptDef opts_pool_uuid[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(0),
{.name = NULL}
};
};
static const vshCmdOptDef opts_pool_edit[] = {
- VIRSH_COMMON_OPT_POOL_FULL,
+ VIRSH_COMMON_OPT_POOL_FULL(0),
{.name = NULL}
};
#include "virstring.h"
#define VIRSH_COMMON_OPT_POOL_FULL \
- VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"))
+ VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"), \
+ VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)
#define VIRSH_COMMON_OPT_POOL_NAME \
- VIRSH_COMMON_OPT_POOL(N_("pool name"))
+ VIRSH_COMMON_OPT_POOL(N_("pool name"), \
+ VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)
#define VIRSH_COMMON_OPT_POOL_OPTIONAL \
{.name = "pool", \
.type = VSH_OT_STRING, \
- .help = N_("pool name or uuid") \
+ .help = N_("pool name or uuid"), \
+ .completer = virshStoragePoolNameCompleter, \
+ .completer_flags = VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE, \
}
#define VIRSH_COMMON_OPT_VOLUME_VOL \