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

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

 



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@xxxxxxxxxx>
> ---
>  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


Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]