]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: add --uuid option to vol-pool
authorJustin Clift <justin@salasaga.org>
Fri, 11 Jun 2010 16:26:58 +0000 (02:26 +1000)
committerEric Blake <eblake@redhat.com>
Thu, 17 Jun 2010 20:45:34 +0000 (14:45 -0600)
Adds an optional switch, --uuid, for telling the virsh vol-pool command
to return the pool UUID rather than pool name.

tools/virsh.c
tools/virsh.pod

index db14f55eae135c16fc16d724f586ebe63e0f59b6..3057115067db7334e5e141bd56039dbd20716849 100644 (file)
@@ -6084,6 +6084,7 @@ static const vshCmdInfo info_vol_pool[] = {
 };
 
 static const vshCmdOptDef opts_vol_pool[] = {
+    {"uuid", VSH_OT_BOOL, 0, N_("return the pool uuid rather than pool name")},
     {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume key or path")},
     {NULL, 0, 0, NULL}
 };
@@ -6093,6 +6094,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
 {
     virStoragePoolPtr pool;
     virStorageVolPtr vol;
+    char uuid[VIR_UUID_STRING_BUFLEN];
 
     /* Check the connection to libvirtd daemon is still working */
     if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
@@ -6112,8 +6114,15 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
         return FALSE;
     }
 
-    /* Return the name of the parent storage pool */
-    vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
+    /* Return the requested details of the parent storage pool */
+    if (vshCommandOptBool(cmd, "uuid")) {
+        /* Retrieve and return pool UUID string */
+        if (virStoragePoolGetUUIDString(pool, &uuid[0]) == 0)
+            vshPrint(ctl, "%s\n", uuid);
+    } else {
+        /* Return the storage pool name */
+        vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
+    }
 
     /* Cleanup */
     virStorageVolFree(vol);
index bb2d49a830fe9379ff8854ce355ada1b241059bc..05ba731c27839dceb0db75cb41e5d1eab50c1e01 100644 (file)
@@ -842,10 +842,12 @@ I<vol-name-or-key-or-path> is the name or key or path of the volume to return in
 Return the list of volumes in the given storage pool.
 I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool.
 
-=item B<vol-pool> I<vol-key-or-path>
+=item B<vol-pool> [optional I<--uuid>] I<vol-key-or-path>
 
-Return the pool for a given volume.
-I<vol-key-or-path> is the key or path of the volume to return the pool name for.
+Return the pool name or UUID for a given volume. By default, the pool name is
+returned. If the I<--uuid> option is given, the pool UUID is returned instead.
+I<vol-key-or-path> is the key or path of the volume to return the pool
+information for.
 
 =item B<vol-path> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key>