aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorOsier Yang <jyang@redhat.com>2011-08-31 21:55:32 +0800
committerOsier Yang <jyang@redhat.com>2011-09-02 21:17:08 +0800
commitddcd5674aa59ab1f818f333090c0e695ffe93b67 (patch)
tree9d72402696616beefe8816c43882ce0d77e11378 /tools
parentstorage: Add fs pool formatting (diff)
downloadlibvirt-ddcd5674aa59ab1f818f333090c0e695ffe93b67.tar.gz
libvirt-ddcd5674aa59ab1f818f333090c0e695ffe93b67.tar.bz2
libvirt-ddcd5674aa59ab1f818f333090c0e695ffe93b67.zip
storage: Add virsh support for fs pool formating
Diffstat (limited to 'tools')
-rw-r--r--tools/virsh.c14
-rw-r--r--tools/virsh.pod11
2 files changed, 22 insertions, 3 deletions
diff --git a/tools/virsh.c b/tools/virsh.c
index d43123c6e..924d31bcf 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7199,6 +7199,8 @@ static const vshCmdInfo info_pool_build[] = {
static const vshCmdOptDef opts_pool_build[] = {
{"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name or uuid")},
+ {"no-overwrite", VSH_OT_BOOL, 0, N_("do not overwrite an existing pool of this type")},
+ {"overwrite", VSH_OT_BOOL, 0, N_("overwrite any existing data")},
{NULL, 0, 0, NULL}
};
@@ -7208,6 +7210,7 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
virStoragePoolPtr pool;
bool ret = true;
const char *name;
+ unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
@@ -7215,7 +7218,15 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false;
- if (virStoragePoolBuild(pool, 0) == 0) {
+ if (vshCommandOptBool (cmd, "no-overwrite")) {
+ flags |= VIR_STORAGE_POOL_BUILD_NO_OVERWRITE;
+ }
+
+ if (vshCommandOptBool (cmd, "overwrite")) {
+ flags |= VIR_STORAGE_POOL_BUILD_OVERWRITE;
+ }
+
+ if (virStoragePoolBuild(pool, flags) == 0) {
vshPrint(ctl, _("Pool %s built\n"), name);
} else {
vshError(ctl, _("Failed to build pool %s"), name);
@@ -7227,7 +7238,6 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
return ret;
}
-
/*
* "pool-destroy" command
*/
diff --git a/tools/virsh.pod b/tools/virsh.pod
index b90c26eec..772d33247 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1355,10 +1355,19 @@ where the query is performed.
Configure whether I<pool> should automatically start at boot.
-=item B<pool-build> I<pool-or-uuid>
+=item B<pool-build> I<pool-or-uuid> [I<--overwrite>] [I<--no-overwrite>]
Build a given pool.
+Options I<--overwrite> and I<--no-overwrite> can only be used for
+B<pool-build> a filesystem pool. If neither of them is specified,
+B<pool-build> on a filesystem pool only makes the directory; If
+I<--no-overwrite> is specified, it probes to determine if a
+filesystem already exists on the target device, returning an error
+if exists, or using mkfs to format the target device if not; If
+I<--overwrite> is specified, mkfs is always executed, any existed
+data on the target device is overwritten unconditionally.
+
=item B<pool-create> I<file>
Create and start a pool object from the XML I<file>.