Re: [libvirt] [PATCH] ESX: Fallback to the preliminary name if the datastore cannot be found.

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

 



On Wed, Oct 28, 2009 at 09:07:55PM +0100, Matthias Bolte wrote:
> This allows to use domain-xml-from-native with VMX files that reference
> unavailable datastores.
> 
> * src/esx/esx_vmx.c: fallback to the preliminary name if the datastore
>   cannot be found
> ---
>  src/esx/esx_vmx.c |   43 +++++++++++++++++++++++--------------------
>  1 files changed, 23 insertions(+), 20 deletions(-)
> 
> diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
> index 8e2bdec..a9ff1b4 100644
> --- a/src/esx/esx_vmx.c
> +++ b/src/esx/esx_vmx.c
> @@ -606,34 +606,37 @@ esxVMX_AbsolutePathToDatastoreRelatedPath(virConnectPtr conn,
>      if (ctx != NULL) {
>          if (esxVI_LookupDatastoreByName(conn, ctx, preliminaryDatastoreName,
>                                          NULL, &datastore,
> -                                        esxVI_Occurence_RequiredItem) < 0) {
> +                                        esxVI_Occurence_OptionalItem) < 0) {
>              goto failure;
>          }
>  
> -        for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
> -             dynamicProperty = dynamicProperty->_next) {
> -            if (STREQ(dynamicProperty->name, "summary.accessible")) {
> -                /* Ignore it */
> -            } else if (STREQ(dynamicProperty->name, "summary.name")) {
> -                if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
> -                                             esxVI_Type_String) < 0) {
> -                    goto failure;
> +        if (datastore != NULL) {
> +            for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
> +                 dynamicProperty = dynamicProperty->_next) {
> +                if (STREQ(dynamicProperty->name, "summary.accessible")) {
> +                    /* Ignore it */
> +                } else if (STREQ(dynamicProperty->name, "summary.name")) {
> +                    if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
> +                                                 esxVI_Type_String) < 0) {
> +                        goto failure;
> +                    }
> +
> +                    datastoreName = dynamicProperty->val->string;
> +                    break;
> +                } else if (STREQ(dynamicProperty->name, "summary.url")) {
> +                    /* Ignore it */
> +                } else {
> +                    VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
>                  }
> -
> -                datastoreName = dynamicProperty->val->string;
> -                break;
> -            } else if (STREQ(dynamicProperty->name, "summary.url")) {
> -                /* Ignore it */
> -            } else {
> -                VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
>              }
>          }
>  
>          if (datastoreName == NULL) {
> -            ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
> -                      "Could not retrieve datastore name for absolute path '%s'",
> -                      absolutePath);
> -            goto failure;
> +            VIR_WARN("Could not retrieve datastore name for absolute "
> +                     "path '%s', falling back to preliminary name '%s'",
> +                     absolutePath, preliminaryDatastoreName);
> +
> +            datastoreName = preliminaryDatastoreName;
>          }
>      } else {
>          datastoreName = preliminaryDatastoreName;

ACK


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]