[Libvirt-cim] [PATCH] RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults
Kaitlin Rupert
kaitlin at linux.vnet.ibm.com
Fri Feb 1 16:06:02 UTC 2008
Heidi Eckhart wrote:
> # HG changeset patch
> # User Heidi Eckhart <heidieck at linux.vnet.ibm.com>
> # Date 1201864846 -3600
> # Node ID 6b1bf8231d82f51f25ac3d954b63962bfc7484c9
> # Parent cb0e8b858f4243a7086f627d65a07075b9f31ebc
> RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults
>
> wbemein http://localhost/root/virt:CIM_ResourcePoolConfigurationService
> on a KVM system with no Xen segfaults.
>
> The same happens to
> wbemgi 'http://localhost:5988/root/virt:Xen_ResourcePoolConfigurationService.SystemCreationClassName="Xen_HostSystem",SystemName="localhost.localdomain",CreationClassName="Xen_ResourcePoolConfigurationService",Name="RPCS"'
>
> This patch also makes RPCS aware of the supported hypervisor type. Now only
> instances of the machine's supported hypervisor are returned. This approach
> is used all over the libvirt-cim providers, but was broken here.
>
> Signed-off-by: Heidi Eckhart <heidieck at linux.vnet.ibm.com>
>
> diff -r cb0e8b858f42 -r 6b1bf8231d82 src/Virt_ResourcePoolConfigurationService.c
> --- a/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 11:17:15 2008 +0100
> +++ b/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 12:20:46 2008 +0100
> @@ -100,15 +100,20 @@ CMPIStatus rpcs_instance(const CMPIObjec
> {
> CMPIInstance *inst;
> CMPIInstance *host;
> - CMPIStatus s;
> + CMPIStatus s = {CMPI_RC_OK, NULL};
> CMPIData prop;
> + virConnectPtr conn = NULL;
> +
> + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
> + if (conn == NULL)
> + goto out;
I would also set the status here. This would mean we don't need to check
for a NULL instance everywhere rpcs_instance() is called.
Virt_HostedService calls rpcs_instance(), but currently doesn't check
for a NULL. So if don't set the status here, HostedService will need to
be updated to check for a NULL instance.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list