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

Christophe Fergeau cfergeau at redhat.com
Tue Jul 17 14:14:11 UTC 2018


Ok, 
Acked-by: Christophe Fergeau <cfergeau at redhat.com>

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 at redhat.com>
> ---
>  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 at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20180717/cd5e0395/attachment.sig>


More information about the virt-tools-list mailing list