]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
fix a ambiguous output of the command:'virsh vol-create-as'
authorHongwei Bi <hwbi2008@gmail.com>
Mon, 7 Oct 2013 14:04:26 +0000 (22:04 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 7 Oct 2013 16:26:09 +0000 (18:26 +0200)
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"

include/libvirt/virterror.h
src/storage/storage_driver.c
src/util/virerror.c

index c1960c86d27eb9e4d2457cf69f672b08aeebe79c..fd142371da47d0a9ef760645ef50e99c25e98c13 100644 (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;
 
 /**
index 6c392840f48b7f83229186b79c28b2e6071b41e8..d419a36e2e753ec400bd424273805cfa8bd27d50 100644 (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;
     }
 
index ca25678ffe8f9bbc8e0c040841a80085aed50d00..3f55cec1c7e010121c7d468c28bf8a5e8080a61a 100644 (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");