You need to sign in or sign up before continuing.
  • E
    conf: track more fields in backing chain metadata · 5976a9ac
    Eric Blake 提交于
    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: NEric Blake <eblake@redhat.com>
    5976a9ac
virstoragefile.c 49.0 KB