[Libvirt-cim] [PATCH 2 of 3] Add association ReferencedProfile for conformance to DMTF's Profile Registration Profile

Dan Smith danms at us.ibm.com
Thu Mar 13 14:56:13 UTC 2008


HE> +static CMPIStatus prof_to_prof(const CMPIObjectPath *ref,
HE> +                               struct std_assoc_info *info,
HE> +                               struct inst_list *list)
HE> +{
HE> +        CMPIStatus s = {CMPI_RC_OK, NULL};
HE> +        CMPIInstance *inst = NULL;
HE> +        virConnectPtr conn = NULL;
HE> +        struct reg_prof *source;
HE> +        struct reg_prof *scope;
HE> +        int i;
HE> +        
HE> +        if (!match_hypervisor_prefix(ref, info))
HE> +                goto out;
HE> +
HE> +        s = get_profile_by_ref(_BROKER, ref, info->properties, &inst);
HE> +        if (s.rc != CMPI_RC_OK)
HE> +                goto out;
HE> +
HE> +        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
HE> +        if (conn == NULL)
HE> +                goto out;
HE> +
HE> +        source = get_reg_prof_by_ref(ref);
HE> +        if (source == NULL) {
HE> +                cu_statusf(_BROKER, &s, 
HE> +                           CMPI_RC_ERR_FAILED,
HE> +                           "Can't find RegisteredProfile instance");
HE> +                goto out;
HE> +        }
HE> +
HE> +        if (source->scoping_profile != NULL) {
HE> +                s = get_profile(_BROKER,
HE> +                                ref, 
HE> +                                info->properties,
HE> +                                CIM_INTEROP_NS,
HE> +                                pfx_from_conn(conn),
HE> +                                source->scoping_profile,
HE> +                                &inst);
HE> +                if (s.rc != CMPI_RC_OK)
HE> +                        goto out;
HE> +                inst_list_add(list, inst);
HE> +        }
HE> +
HE> +        for (i = 0; profiles[i] != NULL; i++) {
HE> +                if (profiles[i]->scoping_profile == NULL)
HE> +                        continue;
HE> +
HE> +                scope = profiles[i]->scoping_profile;
HE> +                if (!STREQC(scope->reg_id, source->reg_id))
HE> +                        continue;
HE> +
HE> +                s = get_profile(_BROKER,
HE> +                                ref, 
HE> +                                info->properties,
HE> +                                CIM_INTEROP_NS,
HE> +                                pfx_from_conn(conn),
HE> +                                profiles[i],
HE> +                                &inst);
HE> +                if (s.rc != CMPI_RC_OK)
HE> +                        goto out;
HE> +                        
HE> +                inst_list_add(list, inst);
HE> +        }
HE> + 
HE> + out:
HE> +        virConnectClose(conn);
HE> +
HE> +        return s;
HE> +}

This seems a little long to me.  Can we break the loop out into a
helper function?

-- 
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms at us.ibm.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20080313/68568d77/attachment.sig>


More information about the Libvirt-cim mailing list