]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
util: storage: Improve error message when requesting image above 'start'
authorPeter Krempa <pkrempa@redhat.com>
Tue, 21 Apr 2015 15:38:08 +0000 (17:38 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Apr 2015 12:24:32 +0000 (14:24 +0200)
When a user would specify a backing chain index that is above the start
point libvirt would report a rather unhelpful error:

invalid argument: could not find backing store 1 in chain for 'sub/link2'

This patch adds an explicit check that the index is below start point in
the backing store and reports the following error if not:

invalid argument: requested backing store index 1 is above 'sub/../qcow2' in chain for 'sub/link2'

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1177062

src/util/virstoragefile.c

index c9d3977f30011d9c7b928612a5b1fa50f1176f31..9507ca191a3fec908a545fa98b193228e1e68c03 100644 (file)
@@ -1338,6 +1338,15 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
             chain = chain->backingStore;
             i++;
         }
+
+        if (idx && idx < i) {
+            virReportError(VIR_ERR_INVALID_ARG,
+                           _("requested backing store index %u is above '%s' "
+                             "in chain for '%s'"),
+                           idx, NULLSTR(startFrom->path), NULLSTR(start));
+            return NULL;
+        }
+
         *parent = startFrom;
     }