[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH 2/7] Check for availability of inspect_get_product_variant

On Tue, Apr 26, 2011 at 05:03:47PM +0100, Matthew Booth wrote:
> F14 doesn't have inspect_get_product_variant (F15 does). The only thing it's
> needed for is differentiating Win7 from Win2k8r2 when writing to RHEV, so work
> round it if it's not there.
> ---
>  lib/Sys/VirtConvert/Connection/RHEVTarget.pm |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> diff --git a/lib/Sys/VirtConvert/Connection/RHEVTarget.pm b/lib/Sys/VirtConvert/Connection/RHEVTarget.pm
> index 5f0fe47..687f745 100644
> --- a/lib/Sys/VirtConvert/Connection/RHEVTarget.pm
> +++ b/lib/Sys/VirtConvert/Connection/RHEVTarget.pm
> @@ -848,7 +848,11 @@ sub _get_os_type_windows
>      }
>      if ($major == 6 && $minor == 1) {
> -        if ($g->inspect_get_product_variant($root) eq 'Client') {
> +        # This API is new in libguestfs 1.10
> +        # If it's not present, we can't differentiate between Win7 and Win2k8r2
> +        if ($g->can('inspect_get_product_variant') &&

My tests indicated that you have to write:

  if (defined (Sys::Guestfs->can ("inspect_get_product_variant"))) ...

However I don't know if 'defined' is really needed there or not.
'can' is documented this way:

      "can" checks to see if its object has a method called "METHOD",
      if it does then a reference to the sub is returned, if it does
      not then "undef" is returned.

It seems to hang on whether the sub reference could ever be evaluated
to false (eg. it could be "0" or something like that).  That seems
unlikely to me right now ...


Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]