<html><body>
<p>I am okay with virConnectClose trying to close a NULL connection.<br>
I suggest we change to  &uuid.<br>
<br>
Regards,<br>
Sharad Mishra<br>
Open Virtualization<br>
Linux Technology Center<br>
IBM<br>
<br>
<tt>libvirt-cim-bounces@redhat.com wrote on 05/03/2011 12:21:13 PM:<br>
<br>
> Chip Vincent <cvincent@linux.vnet.ibm.com> </tt><br>
<tt>> Sent by: libvirt-cim-bounces@redhat.com<br>
> </tt><br>
<tt>> 05/03/2011 12:21 PM</tt><br>
<tt>> <br>
> Please respond to<br>
> cvincent@linux.vnet.ibm.com; Please respond to<br>
> List for discussion and development of libvirt CIM <libvirt-cim@redhat.com></tt><br>
<tt>> <br>
> To</tt><br>
<tt>> <br>
> libvirt-cim@redhat.com</tt><br>
<tt>> <br>
> cc</tt><br>
<tt>> <br>
> Subject</tt><br>
<tt>> <br>
> Re: [Libvirt-cim] [PATCH] Fix UUID in migration job lifecycle indications</tt><br>
<tt>> <br>
> <br>
> >  > Subject<br>
> >  ><br>
> >  > [Libvirt-cim] [PATCH] Fix UUID in migration job lifecycle indications<br>
> >  ><br>
> >  > # HG changeset patch<br>
> >  > # User Chip Vincent <cvincent@us.ibm.com><br>
> >  > # Date 1304034351 14400<br>
> >  > # Node ID 454ce8f30a13881cc6f5206d8e8e6f42a2ff8621<br>
> >  > # Parent 8b428df21c360d1eaedba7157b0dfd429d2db121<br>
> >  > Fix UUID in migration job lifecycle indications.<br>
> >  ><br>
> >  > Fixed the logic that fetches a VM UUID and adds it to the migration<br>
> >  > job's InstanceIdentifier property.<br>
> >  ><br>
> >  > Siged-off-by: Chip Vincent <cvincent@us.ibm.com><br>
> >  ><br>
> >  > diff --git a/src/Virt_VSMigrationService.c<br>
> > b/src/Virt_VSMigrationService.c<br>
> >  > --- a/src/Virt_VSMigrationService.c<br>
> >  > +++ b/src/Virt_VSMigrationService.c<br>
> >  > @@ -812,15 +812,20 @@<br>
> >  > CMPIInstance *ind = NULL;<br>
> >  > CMPIInstance *prev_inst = NULL;<br>
> >  > const char *pfx = NULL;<br>
> >  > + virConnectPtr conn = NULL;<br>
> >  > virDomainPtr dom = NULL;<br>
> >  > char uuid[VIR_UUID_STRING_BUFLEN];<br>
> >  > CMPIDateTime *timestamp = NULL;<br>
> >  ><br>
> >  > + conn = connect_by_classname(_BROKER, job->ref_cn, s);<br>
> >  > + if(conn == NULL)<br>
> >  > + goto out;<br>
> ><br>
> > "out" will try to close a connection that has not been established yet.<br>
> <br>
> This is the same pattern most of the providers use and virConnectClose() <br>
> properly handles a NULL connection, much like<br>
> free handles NULL. I prefer this approach as opposed to having<br>
> multiple goto's for each failure scenario.<br>
> <br>
> ><br>
> >  > +<br>
> >  > ind_name = ind_type_to_name(ind_type);<br>
> >  ><br>
> >  > CU_DEBUG("Creating indication.");<br>
> >  ><br>
> >  > - pfx = pfx_from_conn(job->conn);<br>
> >  > + pfx = pfx_from_conn(conn);<br>
> >  ><br>
> >  > ind = get_typed_instance(broker,<br>
> >  > pfx,<br>
> >  > @@ -832,13 +837,15 @@<br>
> >  > goto out;<br>
> >  > }<br>
> >  ><br>
> >  > - dom = virDomainLookupByName(job->conn, job->domain);<br>
> >  > - if(dom == NULL) {<br>
> >  > - CU_DEBUG("Failed to connect to domain %s", job->domain);<br>
> >  > + timestamp = CMNewDateTime(broker, s);<br>
> >  > + CMSetProperty(ind, "IndicationTime",<br>
> >  > + (CMPIValue *)&timestamp, CMPI_dateTime);<br>
> >  > +<br>
> >  > + dom = virDomainLookupByName(conn, job->domain);<br>
> >  > + if (dom == NULL)<br>
> >  > goto out;<br>
> >  > - }<br>
> >  ><br>
> >  > - if(virDomainGetUUIDString(dom, uuid) != 0) {<br>
> >  > + if (virDomainGetUUIDString(dom, &uuid[0]) != 0) {<br>
> ><br>
> > Why are you doing "&uuid[0]" and why not just "&uuid" ?<br>
> <br>
> libvirt test case for this function used that notation, so I simply <br>
> followed their lead regarding this style guideline.<br>
> <br>
> ><br>
> >  > CU_DEBUG("Failed to get UUID from domain name");<br>
> >  > goto out;<br>
> >  > }<br>
> >  > @@ -846,10 +853,6 @@<br>
> >  > CMSetProperty(ind, "IndicationIdentifier",<br>
> >  > (CMPIValue *)uuid, CMPI_chars);<br>
> >  ><br>
> >  > - timestamp = CMNewDateTime(broker, s);<br>
> >  > - CMSetProperty(ind, "IndicationTime",<br>
> >  > - (CMPIValue *)&timestamp, CMPI_dateTime);<br>
> >  > -<br>
> >  > if (ind_type == MIG_MODIFIED) {<br>
> >  > /* Need to copy job inst before attaching as<br>
> >  > PreviousInstance<br>
> >  > because otherwise the changes we are about to make to job<br>
> >  > @@ -867,6 +870,7 @@<br>
> >  ><br>
> >  > out:<br>
> >  > virDomainFree(dom);<br>
> >  > + virConnectClose(conn);<br>
> >  > return ind;<br>
> >  > }<br>
> >  ><br>
> >  > _______________________________________________<br>
> >  > Libvirt-cim mailing list<br>
> >  > Libvirt-cim@redhat.com<br>
> >  > <a href="https://www.redhat.com/mailman/listinfo/libvirt-cim">https://www.redhat.com/mailman/listinfo/libvirt-cim</a><br>
> ><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > Libvirt-cim mailing list<br>
> > Libvirt-cim@redhat.com<br>
> > <a href="https://www.redhat.com/mailman/listinfo/libvirt-cim">https://www.redhat.com/mailman/listinfo/libvirt-cim</a><br>
> <br>
> -- <br>
> Chip Vincent<br>
> Open Virtualization<br>
> IBM Linux Technology Center<br>
> cvincent@linux.vnet.ibm.com<br>
> _______________________________________________<br>
> Libvirt-cim mailing list<br>
> Libvirt-cim@redhat.com<br>
> <a href="https://www.redhat.com/mailman/listinfo/libvirt-cim">https://www.redhat.com/mailman/listinfo/libvirt-cim</a><br>
</tt></body></html>