[libvirt] [PATCH 4/6] conf: track more fields in backing chain metadata

Peter Krempa pkrempa at redhat.com
Wed Apr 9 12:03:47 UTC 2014


On 04/09/14 06:35, Eric Blake wrote:
> The current use of virStorageFileMetadata is awkward; to learn
> some of the information about a child node, you have to read
> fields in the parent node.  This does not lend itself well to
> modifying backing chains (whether inserting a new node in the
> chain, or consolidating existing nodes); better would be to
> learn about a child node directly in that node.  This patch
> sets up some new fields which contain redundant information,
> although not necessarily in the final desired state for the
> new fields (see the next patch for actual tests of what is there
> now).  Then later patches will do any refactoring necessary to
> get the fields to their desired states, and update clients to
> get the information from the new fields, so we can finally
> delete the fields that are tracking information about the wrong
> node.
> 
> More concretely, compare these three example backing chains:
> 
> good <- one
> missing <- two
> gluster://server/vol/img <- three
> 
> Pre-patch, querying the chains gives:
> { .backingStore = "/path/to/good",
>   .backingStoreRaw = "good",
>   .backingStoreIsFile = true,
>   .backingStoreFormat = VIR_STORAGE_FILE_RAW,
>   .backingMeta = {
>     .backingStore = NULL,
>     .backingStoreRaw = NULL,
>     .backingStoreIsFile = false,
>     .backingMeta = NULL,
>   }
> }
> { .backingStore = NULL,
>   .backingStoreRaw = "missing",
>   .backingStoreIsFile = false,
>   .backingStoreFormat = VIR_STORAGE_FILE_NONE,
>   .backingMeta = NULL,
> }
> { .backingStore = "gluster://server/vol/img",
>   .backingStoreRaw = NULL,
>   .backingStoreIsFile = false,
>   .backingStoreFormat = VIR_STORAGE_FILE_RAW,
>   .backingMeta = NULL,
> }
> 
> Deciding whether to ignore a missing backing file (as in virsh
> vol-dumpxml) or report an error (as in security manager sVirt
> labeling) requires reading multiple fields.  Plus, the format
> is hard-coded to treat all network protocols as end-of-the-chain,
> as if they were raw.  By the end of this patch series, the goal
> is to instead represent these three situations as:
> 
> { .path = "one",
>   .canonPath = "/path/to/one",
>   .type = VIR_STORAGE_TYPE_FILE,
>   .format = VIR_STORAGE_FILE_QCOW2,
>   .backingStoreRaw = "good",
>   .backingMeta = {
>     .path = "good",
>     .canonPath = "/path/to/good",
>     .type = VIR_STORAGE_TYPE_FILE,
>     .format = VIR_STORAGE_FILE_RAW,
>     .backingStoreRaw = NULL,
>     .backingMeta = NULL,
>   }
> }
> { .path = "two",
>   .canonPath = "/path/to/two",
>   .type = VIR_STORAGE_TYPE_FILE,
>   .format = VIR_STORAGE_FILE_QCOW2,
>   .backingStoreRaw = "missing",
>   .backingMeta = NULL,
> }
> { .path = "three",
>   .canonPath = "/path/to/three",
>   .type = VIR_STORAGE_TYPE_FILE,
>   .format = VIR_STORAGE_FILE_QCOW2,
>   .backingStoreRaw = "gluster://server/vol/img",
>   .backingMeta = {
>     .path = "gluster://server/vol/img",
>     .canonPath = "gluster://server/vol/img",
>     .type = VIR_STORAGE_TYPE_NETWORK,
>     .format = VIR_STORAGE_FILE_RAW,
>     .backingStoreRaw = NULL,
>     .backingMeta = NULL,
>   }
> }
> 
> or, for the second file, maybe also allowing:
> { .path = "two",
>   .canonPath = "/path/to/two",
>   .type = VIR_STORAGE_TYPE_FILE,
>   .format = VIR_STORAGE_FILE_QCOW2,
>   .backingStoreRaw = "missing",
>   .backingMeta = {
>     .path = "missing",
>     .canonPath = NULL,
>     .type = VIR_STORAGE_TYPE_NONE,
>     .format = VIR_STORAGE_FILE_NONE,
>     .backingStoreRaw = NULL,
>     .backingMeta = NULL,
>   }
> }
> 
> * src/util/virstoragefile.h (_virStorageFileMetadata): Add
> path, canonPath, relDir, type, and format fields.  Reorder
> existing fields, and add lots of comments.
> * src/util/virstoragefile.c (virStorageFileFreeMetadata): Clean
> new fields.
> (virStorageFileGetMetadataInternal)
> (virStorageFileGetMetadataFromFDInternal): Start populating new
> fields.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>  src/util/virstoragefile.c | 26 +++++++++++++++++++++++++-
>  src/util/virstoragefile.h | 36 +++++++++++++++++++++++++++++++-----
>  2 files changed, 56 insertions(+), 6 deletions(-)
> 

ACK,

Peter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140409/73184434/attachment-0001.sig>


More information about the libvir-list mailing list