mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-21 21:25:25 +00:00
storage file: fill in src->dataFileStore during file probe
Signed-off-by: Nikolai Barybin <nikolai.barybin@virtuozzo.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
63481eca80
commit
0a3d177d9b
@ -543,6 +543,39 @@ virStorageSourceNewFromBacking(virStorageSource *parent,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virStorageSourceNewFromDataFile:
|
||||
* @parent: storage source parent
|
||||
*
|
||||
* Creates a storage source which describes the data file image of @parent.
|
||||
* Returned storage source format is VIR_STORAGE_FILE_RAW, and, unlike
|
||||
* backing storage creation, readonly flag is copied from @parent.
|
||||
*/
|
||||
static virStorageSource *
|
||||
virStorageSourceNewFromDataFile(virStorageSource *parent)
|
||||
{
|
||||
g_autoptr(virStorageSource) dataFile = NULL;
|
||||
int rc;
|
||||
|
||||
if ((rc = virStorageSourceNewFromChild(parent,
|
||||
parent->dataFileRaw,
|
||||
&dataFile)) < 0)
|
||||
return NULL;
|
||||
|
||||
if (rc == 1) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
_("can't use data file definition '%1$s'"),
|
||||
parent->dataFileRaw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dataFile->format = VIR_STORAGE_FILE_RAW;
|
||||
dataFile->readonly = parent->readonly;
|
||||
|
||||
return g_steal_pointer(&dataFile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @src: disk source definition structure
|
||||
* @fd: file descriptor
|
||||
@ -1391,6 +1424,14 @@ virStorageSourceGetMetadataRecurse(virStorageSource *src,
|
||||
}
|
||||
}
|
||||
|
||||
/* The image we're detecting on can have a '<dataStore>' explicitly
|
||||
* configured without a '<backingStore/>' terminator so we must not
|
||||
* overwrite it */
|
||||
if (!src->dataFileStore && src->dataFileRaw) {
|
||||
if (!(src->dataFileStore = virStorageSourceNewFromDataFile(src)))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (src->backingStoreRaw) {
|
||||
if ((rv = virStorageSourceNewFromBacking(src, &backingStore)) < 0)
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user