Re: [libvirt] [PATCH] virsh: More friendly err if no pool is specified for looking up a vol

From: Osier Yang <jyang redhat com>

To: Eric Blake <eblake redhat com>

Cc: libvir-list redhat com

Subject: Re: [libvirt] [PATCH] virsh: More friendly err if no pool is specified for looking up a vol

Date: Thu, 22 Sep 2011 08:15:55 +0800

于 2011年09月21日 23:19, Eric Blake 写道:

On 09/21/2011 01:12 AM, Osier Yang wrote:

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.
---
tools/virsh.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 371346a..4b9e662 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c

ACK - this is a minimal patch. A nicer patch might be to search by
name in all pools, and if an unambiguous name is found, use that
volume, but it requires more work, so there's nothing wrong with using
this patch in the meantime.

Pushed, thanks, by the way, it might need to introduce some
new flags again, ;-) such as "*_FUZZY_MATCH/PRECISE_MATCH".
By default it uses PRECISE_MATCH. FUZZY_MATCH will search
all pools and use the specified string as a RE to match out
the vols. But the problem is the already existed API
virStorageVolLookupByName just returns one virStorageVolPtr
obj. So we might need to introduce a new API then.
Osier