On Thu, Aug 14, 2025 at 12:10:01PM -0300, Fabiano Rosas wrote:
> > IIUC this is essential the trick we used to play before QAPI_CLONE, before
> > commit a15fcc3cf69e.
> >
> > https://lore.kernel.org/all/1465490926-28625-15-git-send-email-ebl...@redhat.com/
> >
> > Yes, looks similar..
> >
> > QAPI_CLONE_MEMBERS() will copy everything, which we do not want here. We
> > only want to copy where has_* is set.  So it's indeed a sligntly different
> > request versus the current clone API.
> >
> > IIUC that can be implemented using a similar qapi clone visitor, however
> > instead of g_memdup() on the structs/lists first (or in the case of
> > QAPI_CLONE_MEMBERS, we did *dst=*src), we lazy copy all the fields.
> >
> > I wished this is a generic API we could use.  I think it means we'll
> > maintain this ourselves.  Maybe it's OK.
> >
> 
> I'm not sure how easy it is to provide a generic API for this. I don't
> think there's much space for this code to change anyway, so is fine to
> keep it in migration. I'll try to implement a
> QAPI_CLONE_PRESENT_MEMBERS, let's see.

The new visitor will slightly improve readability on what this code is
doing. But yeah, feel free to choose whatever you see fit when repost (and
if the code will be kept as-is, please consider adding some comments to
help future readers).

Thanks,

-- 
Peter Xu


Reply via email to