[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Add warning message to XML definition files stored on disk



On 04/28/2011 10:34 AM, Michal Privoznik wrote:
> Users often edit XML domain file stored in configuration directory
> thinking of modifying a domain/network/pool/etc. Thus it is wise
> to let them know they are using the wrong way and give them hint.

> +++ b/src/conf/domain_conf.c
> @@ -8543,6 +8543,7 @@ int virDomainSaveConfig(const char *configDir,
>                                     VIR_DOMAIN_XML_WRITE_FLAGS)))
>          goto cleanup;
>  
> +    virSavePrependWarning(&xml);
>      if (virDomainSaveXML(configDir, def, xml))

Prepending can be expensive - in the middle of the operation, we have to
have twice the space for xml malloc'd, and we are also spending time on
a memcpy from old memory to new.  Is there any way to instead change
virDomainSaveXML and friends to take a flags argument, and pass 0 from
most callers but VIR_XML_EMIT_WARNING from these particular callers;
then if the flag is set, they call the common helper function:

virEmitXMLWarning(int fd)

which outputs the message directly into the target file prior to
outputting xml?  That would be less memory pressure and copying involved.

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]