Re: [RFC PATCH 4/5] util: storagefile: Add deep copy for struct virStorageSource

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

 



On 06/13/14 00:38, Eric Blake wrote:
> On 06/12/2014 09:02 AM, Peter Krempa wrote:
>> Now that we have pointers to store disk source information and thus can
>> easily exchange the structs behind we need a function to copy all the
>> data.
>> ---
>>  src/libvirt_private.syms  |   1 +
>>  src/util/virstoragefile.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++
>>  src/util/virstoragefile.h |   2 +
>>  3 files changed, 153 insertions(+)
>>
> 
>> +virStorageSourcePtr
>> +virStorageSourceCopy(const virStorageSource *src,
>> +                     bool backingChain)
>> +{
>> +    size_t i;
>> +    virStorageSourcePtr ret = NULL;
>> +
>> +    if (VIR_ALLOC(ret) < 0)
>> +        return NULL;
>> +
>> +    ret->type = src->type;
>> +    ret->protocol = src->protocol;
>> +    ret->format = src->format;
>> +    ret->allocation = src->allocation;
>> +    ret->capacity = src->capacity;
>> +    ret->backingRelative = src->backingRelative;
> 
> If I'm not mistaken, backingRelative disappears in your other series;
> I'm guessing you plan on rebasing that on top of this to pick up on the
> easier semantics.
> 
>> +
>> +    /* storage driver metadata are not copied */
>> +    ret->drv = NULL;
> 
> Seems okay, particularly since doing a deep copy of that would require
> callback functions in the storage drivers.

Actually I'm planning on adding reference counting to the storage driver
access data so that we will be able to initialize and de-initialize it
in a nested way. This place would also benefit from that as you'd gain a
initialized file. Not sure though whether that's feasible yet as we
don't always initialize it. For now I'll leave it this way and in the
future we might want to change it.

> 


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]