diff --git a/tools/virsh.c b/tools/virsh.c index db14f55eae..3057115067 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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); diff --git a/tools/virsh.pod b/tools/virsh.pod index bb2d49a830..05ba731c27 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -842,10 +842,12 @@ I 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 is the name or UUID of the storage pool. -=item B I +=item B [optional I<--uuid>] I -Return the pool for a given volume. -I 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 is the key or path of the volume to return the pool +information for. =item B [optional I<--pool> I] I