[Libguestfs] [PATCH] v2v: Filter out the transfer iso if it's returned by inspect_os()

Richard W.M. Jones rjones at redhat.com
Thu Apr 21 20:58:30 UTC 2011


On Thu, Apr 21, 2011 at 06:01:24PM +0100, Matthew Booth wrote:
> inspect_os() shouldn't do this, but ultimately it's heuristic. As we know what
> the transfer device is, we can double-check the output.
> ---
>  v2v/virt-v2v.pl |   18 +++++++++++++++++-
>  1 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/v2v/virt-v2v.pl b/v2v/virt-v2v.pl
> index fe07ae9..6e73102 100755
> --- a/v2v/virt-v2v.pl
> +++ b/v2v/virt-v2v.pl
> @@ -496,11 +496,18 @@ my $g = new Sys::VirtConvert::GuestfsHandle(
>      $output_method eq 'rhev'
>  );
>  
> +# Get the name of the appliance's transfer device, if it has one
> +my $transferdev;
> +if (defined($transferiso)) {
> +    my @devices = $g->list_devices();
> +    $transferdev = pop(@devices);
> +}
> +
>  my $guestcaps;
>  my $desc;
>  eval {
>      # Inspect the guest
> -    $desc = inspect_guest($g);
> +    $desc = inspect_guest($g, $transferdev);
>  
>      # Modify the guest and its metadata
>      $guestcaps =
> @@ -559,9 +566,18 @@ sub signal_exit
>  sub inspect_guest
>  {
>      my $g = shift;
> +    my $transferdev = shift;
>  
>      # Get list of roots, sorted.
>      my @roots = $g->inspect_os ();
> +
> +    # Filter out the transfer device from the results of inspect_os
> +    # There's a libguestfs bug (fixed upstream) which meant the transfer ISO
> +    # could be erroneously detected as an unknown Windows OS. As we know what it
> +    # is, we can filter out the transfer device here. Even when the fix is
> +    # released this is reasonable belt & braces.
> +    @roots = grep(!/^\Q$transferdev\E$/, @roots);
> +
>      @roots = sort @roots;
>  
>      my $root_dev;

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




More information about the Libguestfs mailing list