[Libvirt-cim] [PATCH 3 of 4] Add support for ref checking to VSMigrationCapabilities
Heidi Eckhart
heidieck at linux.vnet.ibm.com
Tue Feb 19 09:56:44 UTC 2008
Kaitlin Rupert wrote:
> @@ -81,10 +81,21 @@ static CMPIStatus set_method_properties(
>
> CMPIStatus get_migration_caps(const CMPIObjectPath *ref,
> CMPIInstance **_inst,
> - const CMPIBroker *broker)
> + const CMPIBroker *broker,
> + bool is_get_inst)
> {
> CMPIInstance *inst;
> CMPIStatus s;
>
Please initialize the Status s to become absolutely sure, that a valid
status is returned.
> + virConnectPtr conn = NULL;
> +
> + conn = connect_by_classname(broker, CLASSNAME(ref), &s);
> + if (conn == NULL) {
> + if (is_get_inst)
> + cu_statusf(broker, &s,
> + CMPI_RC_ERR_NOT_FOUND,
> + "No such instance");
> + goto out;
> + }
>
> inst = get_typed_instance(broker,
> CLASSNAME(ref),
>
As the connection is established at this point in time and through all
the other code we use pfx_from_conn(conn) in that case, it might be good
to also use this here instead of CLASSNAME(ref). But that's more a
convenience thing.
> static CMPIStatus return_vsmc(const CMPIObjectPath *ref,
> const CMPIResult *results,
> - bool name_only)
> + bool name_only,
> + bool is_get_inst)
> {
> CMPIInstance *inst;
>
This is causing the reproducible seg fault on my system. Please
initialize inst = NULL. In the case of a Xen request on a KVM only
system this uninitialized inst is disorienting the check for inst ==NULL
and afterwards seg faulting the return instance functions - as inst is
only containing garbage.
> CMPIStatus s;
>
> - s = get_migration_caps(ref, &inst, _BROKER);
> -
> - if (s.rc == CMPI_RC_OK) {
> - if (name_only)
> - cu_return_instance_name(results, inst);
> - else
> - CMReturnInstance(results, inst);
> - }
> -
> + s = get_migration_caps(ref, &inst, _BROKER, is_get_inst);
> + if ((s.rc != CMPI_RC_OK) || (inst == NULL))
> + goto out;
> +
> + if (name_only)
> + cu_return_instance_name(results, inst);
> + else
> + CMReturnInstance(results, inst);
> +
> + out:
> return s;
> }
>
--
Regards
Heidi Eckhart
Software Engineer
IBM Linux Technology Center - Open Hypervisor
More information about the Libvirt-cim
mailing list