Re: [PATCH virt-viewer 2/3] ovirt-foreign-menu: New function storage_domain_validate()

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

 



Ok, 
Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

On Fri, Jul 06, 2018 at 09:59:22AM -0300, Eduardo Lima (Etrunko) wrote:
> It may be useful to know why the storage domain has not been listed,
> given that there are different reasons for that. To make it easier to
> provide more detailed debug messages, we move code from the callback
> function to this new one.
> 
> Signed-off-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx>
> ---
>  src/ovirt-foreign-menu.c | 45 ++++++++++++++++++++++++++++++---------------
>  1 file changed, 30 insertions(+), 15 deletions(-)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index cd1b8bd..70a0b50 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -640,6 +640,35 @@ static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain *domai
>  }
>  #endif
>  
> +static gboolean storage_domain_validate(OvirtForeignMenu *menu,
> +                                        OvirtStorageDomain *domain)
> +{
> +    char *name;
> +    int type, state;
> +    gboolean ret = TRUE;
> +
> +    g_object_get(domain, "name", &name, "type", &type, "state", &state, NULL);
> +
> +    if (type != OVIRT_STORAGE_DOMAIN_TYPE_ISO) {
> +        g_debug("Storage domain '%s' type is not ISO", name);
> +        ret = FALSE;
> +    }
> +
> +    if (state != OVIRT_STORAGE_DOMAIN_STATE_ACTIVE) {
> +        g_debug("Storage domain '%s' state is not active", name);
> +        ret = FALSE;
> +    }
> +
> +#ifdef HAVE_OVIRT_DATA_CENTER
> +    if (!storage_domain_attached_to_data_center(domain, menu->priv->data_center)) {
> +        g_debug("Storage domain '%s' is not attached to data center", name);
> +        ret = FALSE;
> +    }
> +#endif
> +
> +    g_free(name);
> +    return ret;
> +}
>  
>  static void storage_domains_fetched_cb(GObject *source_object,
>                                         GAsyncResult *result,
> @@ -663,23 +692,9 @@ static void storage_domains_fetched_cb(GObject *source_object,
>      g_hash_table_iter_init(&iter, ovirt_collection_get_resources(collection));
>      while (g_hash_table_iter_next(&iter, NULL, (gpointer *)&domain)) {
>          OvirtCollection *file_collection;
> -        int type;
> -        int state;
> -
> -        g_object_get(domain, "type", &type, "state", &state, NULL);
> -        if (type != OVIRT_STORAGE_DOMAIN_TYPE_ISO) {
> -            continue;
> -        }
> -
> -        if (state != OVIRT_STORAGE_DOMAIN_STATE_ACTIVE) {
> -            continue;
> -        }
>  
> -#ifdef HAVE_OVIRT_DATA_CENTER
> -        if (!storage_domain_attached_to_data_center(domain, menu->priv->data_center)) {
> +        if (!storage_domain_validate(menu, domain))
>              continue;
> -        }
> -#endif
>  
>          file_collection = ovirt_storage_domain_get_files(domain);
>          if (file_collection != NULL) {
> -- 
> 2.14.4
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/virt-tools-list

Attachment: signature.asc
Description: PGP signature

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list

[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux