fix a ambiguous output of the command:'virsh vol-create-as'

I created a storage volume(eg: test) from a storage pool(eg:vg10) using
the following command:"virsh vol-create-as --pool vg10 --name test --capacity 300M."
When I re-executed the above command, the output was as the following:
"error: Failed to create vol test
 error: Storage volume not found: storage vol 'test' already exists"

I think the output "Storage volume not found" is not appropriate. Because in fact storage
vol test has been found at this time. And then I think virErrorNumber should includes
VIR_ERR_STORAGE_EXIST which can also be used elsewhere. So I make this patch. The result
is as following:
"error: Failed to create vol test
 error: storage volume 'test' exists already"
This commit is contained in:
Hongwei Bi 2013-10-07 22:04:26 +08:00 committed by Michal Privoznik
parent ba1a91cd1f
commit 91875896d5
3 changed files with 9 additions and 2 deletions

View File

@ -296,6 +296,7 @@ typedef enum {
VIR_ERR_ACCESS_DENIED = 88, /* operation on the object/resource
was denied */
VIR_ERR_DBUS_SERVICE = 89, /* error from a dbus service */
VIR_ERR_STORAGE_VOL_EXISTS = 90, /* the storage vol already exists */
} virErrorNumber;
/**

View File

@ -1538,8 +1538,8 @@ storageVolCreateXML(virStoragePoolPtr obj,
goto cleanup;
if (virStorageVolDefFindByName(pool, voldef->name)) {
virReportError(VIR_ERR_NO_STORAGE_VOL,
_("storage vol '%s' already exists"), voldef->name);
virReportError(VIR_ERR_STORAGE_VOL_EXISTS,
_("'%s'"), voldef->name);
goto cleanup;
}

View File

@ -1004,6 +1004,12 @@ virErrorMsg(virErrorNumber error, const char *info)
else
errmsg = _("Storage volume not found: %s");
break;
case VIR_ERR_STORAGE_VOL_EXISTS:
if (info == NULL)
errmsg = _("this storage volume exists already");
else
errmsg = _("storage volume %s exists already");
break;
case VIR_ERR_STORAGE_PROBE_FAILED:
if (info == NULL)
errmsg = _("Storage pool probe failed");