[libvirt] [PATCH v3 15/18] blockcopy: add a way to parse disk source

Peter Krempa pkrempa at redhat.com
Fri Sep 5 14:14:30 UTC 2014


On 08/31/14 06:02, Eric Blake wrote:
> The new blockcopy API wants to reuse only a subset of the disk
> hotplug parser - namely, we only care about the embedded
> virStorageSourcePtr inside a <disk> XML.  Strange as it may
> seem, it was easier to just parse an entire disk definition,
> then throw away everything but the embedded source, than it
> was to disentangle the source parsing code from the rest of
> the overall disk parsing function.  All that I needed was a
> couple of tweaks and a new internal flag that determines
> whether the normally-mandatory target element can be
> gracefully skipped, since everything else was already optional.
> 
> * src/conf/domain_conf.h (virDomainDiskSourceParse): New
> prototype.
> * src/conf/domain_conf.c (VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE):
> New flag.
> (virDomainDiskDefParseXML): Honor flag to make target optional.
> (virDomainDiskSourceParse): New function.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>  src/conf/domain_conf.c   | 107 ++++++++++++++++++++++++++++++++++-------------
>  src/conf/domain_conf.h   |   4 ++
>  src/libvirt_private.syms |   1 +
>  3 files changed, 82 insertions(+), 30 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 53ef694..8723008 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
              \
> @@ -5951,7 +5955,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
>      } else {
>          if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
>              def->bus = VIR_DOMAIN_DISK_BUS_FDC;
> -        } else {
> +        } else if (!(flags & VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE)) {
>              if (STRPREFIX(target, "hd"))
>                  def->bus = VIR_DOMAIN_DISK_BUS_IDE;
>              else if (STRPREFIX(target, "sd"))
> @@ -6186,12 +6190,14 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
>          }
>      }
> 
> -    if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
> -        && virDomainDiskDefAssignAddress(xmlopt, def) < 0)
> -        goto error;
> +    if (!(flags & VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE)) {
> +        if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
> +            && virDomainDiskDefAssignAddress(xmlopt, def) < 0)
> +            goto error;
> 
> -    if (virDomainDiskBackingStoreParse(ctxt, def->src) < 0)
> -        goto error;
> +        if (virDomainDiskBackingStoreParse(ctxt, def->src) < 0)
> +            goto error;

This actually might be useful for source of block copy and others some
time in the future.

> +    }
> 
>   cleanup:
>      VIR_FREE(bus);

ACK, thanks for dropping the refactor part.

Peter


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


More information about the libvir-list mailing list