On Wed, Jan 26, 2011 at 02:45:43PM +0000, Matthew Booth wrote:
Unfortunately libvirt will not always return volume information for a
guest's
volume. Specifically, it will not return volume information if the volume is not
in a storage pool. Rather than displaying a generic libvirt error in this case,
advise the user how they can create an appropriate storage pool.
Fixes RHBZ#672498
---
lib/Sys/VirtV2V/Connection/LibVirtSource.pm | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/lib/Sys/VirtV2V/Connection/LibVirtSource.pm
b/lib/Sys/VirtV2V/Connection/LibVirtSource.pm
index 628074c..9db9f60 100644
--- a/lib/Sys/VirtV2V/Connection/LibVirtSource.pm
+++ b/lib/Sys/VirtV2V/Connection/LibVirtSource.pm
@@ -130,10 +130,29 @@ sub get_volume
eval {
$vol = $self->{vmm}->get_storage_volume_by_path($path);
};
- die(user_message(__x("Failed to retrieve storage volume {path}:".
- "{error}",
- path => $path,
- error => $@->stringify()))) if($@);
+ if ($@->code == Sys::Virt::Error->ERR_NO_STORAGE_VOL) {
+ die user_message(__x("Failed to retrieve volume information for
".
+ "{path}. This could be because the volume ".
+ "doesn't exist, or because the volume exists
".
+ "but is not contained in a storage
pool.\n\n".
+ "In the latter case, you must create a ".
+ "storage pool of the correct type to contain
".
+ "the volume. Note that you do not have to ".
+ "re-create or move the volume itself, only
".
+ "define a pool which contains it. libvirt ".
+ "will automatically detect the volume when
".
+ "it scans the pool after creation.\n\n".
+ "virt-manager is able to create storage ".
+ "pools. Select Edit->Connection Details
".
+ "from the application menu. Storage pools ".
+ "are displayed in the Storage tab.",
+ path => $path));
+ } else {
+ die user_message(__x("Failed to retrieve storage volume {path}:".
+ "{error}",
+ path => $path,
+ error => $@->stringify()));
+ }
($name, $format, $size, $usage, $is_sparse, $is_block) =
parse_libvirt_volinfo($vol);
ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming blog:
http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora