mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
storagefile: Fill in meta->externalDataStore
Add virStorageSourceNewFromExternalData, similar to virStorageSourceNewFromBacking and use it to fill in a virStorageSource for externalDataStore Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
884cc9d615
commit
527f377a92
@ -3800,6 +3800,24 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virStorageSourceNewFromExternalData(virStorageSourcePtr parent,
|
||||
virStorageSourcePtr *externalDataStore)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if ((rc = virStorageSourceNewFromChild(parent,
|
||||
parent->externalDataStoreRaw,
|
||||
externalDataStore)) < 0)
|
||||
return rc;
|
||||
|
||||
/* qcow2 data_file can only be raw */
|
||||
(*externalDataStore)->format = VIR_STORAGE_FILE_RAW;
|
||||
(*externalDataStore)->readonly = parent->readonly;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @src: disk source definition structure
|
||||
* @fd: file descriptor
|
||||
@ -5008,6 +5026,23 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
|
||||
}
|
||||
|
||||
VIR_STEAL_PTR(src->backingStore, backingStore);
|
||||
|
||||
if (src->externalDataStoreRaw) {
|
||||
VIR_AUTOUNREF(virStorageSourcePtr) externalDataStore = NULL;
|
||||
|
||||
if ((rv = virStorageSourceNewFromExternalData(src,
|
||||
&externalDataStore)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (rv == 1) {
|
||||
/* the file would not be usable for VM usage */
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
VIR_STEAL_PTR(src->externalDataStore, externalDataStore);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
|
Loading…
Reference in New Issue
Block a user