mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 20:51:26 +00:00
storagefile: Split out virStorageSourceNewFromChild
Future patches will use this for external data file handling 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
f57336358c
commit
8863c03d7d
@ -3717,38 +3717,38 @@ virStorageSourceNewFromBackingAbsolute(const char *path,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virStorageSourceNewFromBacking:
|
* virStorageSourceNewFromChild:
|
||||||
* @parent: storage source parent
|
* @parent: storage source parent
|
||||||
* @backing: returned backing store definition
|
* @child: returned child/backing store definition
|
||||||
|
* @parentRaw: raw child string (backingStoreRaw)
|
||||||
*
|
*
|
||||||
* Creates a storage source which describes the backing image of @parent and
|
* Creates a storage source which describes the backing image of @parent and
|
||||||
* fills it into @backing depending on the 'backingStoreRaw' property of @parent
|
* fills it into @backing depending on the passed parentRaw (backingStoreRaw)
|
||||||
* and other data. Note that for local storage this function accesses the file
|
* and other data. Note that for local storage this function accesses the file
|
||||||
* to update the actual type of the backing store.
|
* to update the actual type of the child store.
|
||||||
*
|
*
|
||||||
* Returns 0 on success, 1 if we could parse all location data but the backinig
|
* Returns 0 on success, 1 if we could parse all location data but the child
|
||||||
* store specification contained other data unrepresentable by libvirt (e.g.
|
* store specification contained other data unrepresentable by libvirt (e.g.
|
||||||
* inline authentication).
|
* inline authentication).
|
||||||
* In both cases @src is filled. On error -1 is returned @src is NULL and an
|
* In both cases @src is filled. On error -1 is returned @src is NULL and an
|
||||||
* error is reported.
|
* error is reported.
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
virStorageSourceNewFromBacking(virStorageSourcePtr parent,
|
virStorageSourceNewFromChild(virStorageSourcePtr parent,
|
||||||
virStorageSourcePtr *backing)
|
const char *parentRaw,
|
||||||
|
virStorageSourcePtr *child)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
VIR_AUTOUNREF(virStorageSourcePtr) def = NULL;
|
VIR_AUTOUNREF(virStorageSourcePtr) def = NULL;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
*backing = NULL;
|
*child = NULL;
|
||||||
|
|
||||||
if (virStorageIsRelative(parent->backingStoreRaw)) {
|
if (virStorageIsRelative(parentRaw)) {
|
||||||
if (!(def = virStorageSourceNewFromBackingRelative(parent,
|
if (!(def = virStorageSourceNewFromBackingRelative(parent, parentRaw)))
|
||||||
parent->backingStoreRaw)))
|
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
if ((rc = virStorageSourceNewFromBackingAbsolute(parent->backingStoreRaw,
|
if ((rc = virStorageSourceNewFromBackingAbsolute(parentRaw, &def)) < 0)
|
||||||
&def)) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3768,10 +3768,25 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent,
|
|||||||
if (virStorageSourceInitChainElement(def, parent, true) < 0)
|
if (virStorageSourceInitChainElement(def, parent, true) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
def->readonly = true;
|
|
||||||
def->detected = true;
|
def->detected = true;
|
||||||
|
|
||||||
VIR_STEAL_PTR(*backing, def);
|
VIR_STEAL_PTR(*child, def);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virStorageSourceNewFromBacking(virStorageSourcePtr parent,
|
||||||
|
virStorageSourcePtr *backing)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if ((rc = virStorageSourceNewFromChild(parent,
|
||||||
|
parent->backingStoreRaw,
|
||||||
|
backing)) < 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
(*backing)->readonly = true;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user