[libvirt] [PATCH 2/4] conf: Parse and format disk <wwn>

Eric Blake eblake at redhat.com
Thu Aug 30 16:23:52 UTC 2012


On 08/30/2012 09:14 AM, Paolo Bonzini wrote:
> Il 29/08/2012 18:36, Osier Yang ha scritto:
>> @@ -11557,6 +11564,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
>>      if (def->transient)
>>          virBufferAddLit(buf, "      <transient/>\n");
>>      virBufferEscapeString(buf, "      <serial>%s</serial>\n", def->serial);
>> +    virBufferEscapeString(buf, "      <wwn>%s</wwn>\n", def->wwn);
> 
> What happens if the wwn was not passed?

virBufferEscapeString() is magic - if def->wwn is NULL, then the entire
output string is omitted from buf.  We use that idiom all over the place.

> 
> If it is NULL, it's a bug (same for serial).
> 
> If it is empty, the output will not obey the schema, so the whole
> element should be left out.

Yep, that is what will happen, with the code as-is.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120830/cdbef237/attachment-0001.sig>


More information about the libvir-list mailing list