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

Re: [libvirt] [PATCH 09/11] Add ability to set a default driver name/type when parsing disks



On Mon, Jul 12, 2010 at 02:30:46PM +0100, Daniel P. Berrange wrote:
> Record a default driver name/type in capabilities struct. Use this
> when parsing disks if value is not set in XML config.
> 
> * src/conf/capabilities.h: Record default driver name/type for disks
> * src/conf/domain_conf.c: Fallback to default driver name/type
>   when parsing disks
> * src/qemu/qemu_driver.c: Set default driver name/type to raw
> ---
>  src/conf/capabilities.h |    2 ++
>  src/conf/domain_conf.c  |   16 +++++++++++++++-
>  src/qemu/qemu_driver.c  |    8 ++++++++
>  3 files changed, 25 insertions(+), 1 deletions(-)
> 
> diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
> index 9290c82..f676eb8 100644
> --- a/src/conf/capabilities.h
> +++ b/src/conf/capabilities.h
> @@ -123,6 +123,8 @@ struct _virCaps {
>      virCapsGuestPtr *guests;
>      unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
>      unsigned int emulatorRequired : 1;
> +    const char *defaultDiskDriverName;
> +    const char *defaultDiskDriverType;
>      void *(*privateDataAllocFunc)(void);
>      void (*privateDataFreeFunc)(void *);
>      int (*privateDataXMLFormat)(virBufferPtr, void *);
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b20ca97..f3b8cfa 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -1639,6 +1639,16 @@ virDomainDiskDefParseXML(virCapsPtr caps,
>      def->serial = serial;
>      serial = NULL;
>  
> +    if (!def->driverType &&
> +        caps->defaultDiskDriverType &&
> +        !(def->driverType = strdup(caps->defaultDiskDriverType)))
> +        goto no_memory;
> +
> +    if (!def->driverName &&
> +        caps->defaultDiskDriverName &&
> +        !(def->driverName = strdup(caps->defaultDiskDriverName)))
> +        goto no_memory;
> +
>      if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
>          && virDomainDiskDefAssignAddress(caps, def) < 0)
>          goto error;

  Hum, I find suspsicious that those 2 strings for the new fields are
allocated with strdup, but nowhere in the patch I can see code for
freeing them, so I suspect some kid  of leak here, right ?

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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