From: Osier Yang Date: Wed, 21 Sep 2011 06:29:49 +0000 (+0800) Subject: virsh: More friendly err if no pool is specified for looking up a vol X-Git-Tag: v0.9.6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f0595244b73d7d67447bddf4c5e39f597f5e914;p=thirdparty%2Flibvirt.git virsh: More friendly err if no pool is specified for looking up a vol There are 3 ways to lookup a volume, only virStorageVolLookupByName needs pool object. So if no --pool is specified, it will tries to get the volume via virStorageVolLookupByPath/virStorageVolLookupByKey. But if all 3 ways fails, and no --pool is specified, a friendly error might help the user get right way quickly. --- diff --git a/tools/virsh.c b/tools/virsh.c index 371346a825..4b9e6624a9 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -14714,8 +14714,13 @@ vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, vol = virStorageVolLookupByPath(ctl->conn, n); } - if (!vol) - vshError(ctl, _("failed to get vol '%s'"), n); + if (!vol) { + if (pool) + vshError(ctl, _("failed to get vol '%s'"), n); + else + vshError(ctl, _("failed to get vol '%s', specifying --pool " + "might help"), n); + } if (pool) virStoragePoolFree(pool);