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:
Cole Robinson 2019-10-05 14:39:32 -04:00
parent 884cc9d615
commit 527f377a92
1 changed files with 35 additions and 0 deletions

View File

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