]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: Move disk->backingChain to the recursive disk->src.backingStore
authorPeter Krempa <pkrempa@redhat.com>
Thu, 17 Apr 2014 21:20:22 +0000 (23:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 23 Apr 2014 21:11:07 +0000 (23:11 +0200)
Switch over to storing of the backing chain as a recursive
virStorageSource structure.

This is a string based move. Currently the first element will be present
twice in the backing chain as currently the retrieval function stores
the parent in the newly detected chain. This will be fixed later.

src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
src/security/security_selinux.c
src/security/virt-aa-helper.c

index 03cb4b2c31452193c65b6953843ef36ee76da94d..206f75a60155776a485c439af6a2e39f15901d26 100644 (file)
@@ -1190,7 +1190,6 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
     virStorageSourceClear(&def->src);
     VIR_FREE(def->serial);
     VIR_FREE(def->dst);
-    virStorageSourceFree(def->backingChain);
     VIR_FREE(def->mirror);
     VIR_FREE(def->wwn);
     VIR_FREE(def->vendor);
@@ -18514,7 +18513,7 @@ virDomainSmartcardDefForeach(virDomainDefPtr def,
 
 
 /* Call iter(disk, name, depth, opaque) for each element of disk and
- * its backing chain in the pre-populated disk->backingChain.
+ * its backing chain in the pre-populated disk->src.backingStore.
  * ignoreOpenFailure determines whether to warn about a chain that
  * mentions a backing file without also having metadata on that
  * file.  */
@@ -18540,7 +18539,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
         goto cleanup;
     /* XXX: temporarily we need to select the second element of the backing
      * chain to start as the first is the copy of the disk itself. */
-    tmp = disk->backingChain ? disk->backingChain->backingStore : NULL;
+    tmp = disk->src.backingStore ? disk->src.backingStore->backingStore : NULL;
     while (tmp && virStorageIsFile(tmp->path)) {
         if (!ignoreOpenFailure && tmp->backingStoreRaw && !tmp->backingStore) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
index d0a7f9b9357163479382fd3b8c5ba3bb09e61964..a92f0f3a1fdf86d06f03526a4779dcecbf834d2b 100644 (file)
@@ -605,7 +605,6 @@ struct _virDomainDiskDef {
     char *dst;
     int tray_status; /* enum virDomainDiskTray */
     int removable; /* enum virDomainFeatureState */
-    virStorageSourcePtr backingChain;
 
     char *mirror;
     int mirrorFormat; /* enum virStorageFileFormat */
index b6f9e6a0d5035c1920ebf396f31ff56bffb47d5d..45ed8727b0fcbe6983331e814ed20c71e85839ee 100644 (file)
@@ -2239,10 +2239,10 @@ qemuDiskChainCheckBroken(virDomainDiskDefPtr disk)
 {
     char *brokenFile = NULL;
 
-    if (!virDomainDiskGetSource(disk) || !disk->backingChain)
+    if (!virDomainDiskGetSource(disk) || !disk->src.backingStore)
         return 0;
 
-    if (virStorageFileChainGetBroken(disk->backingChain, &brokenFile) < 0)
+    if (virStorageFileChainGetBroken(disk->src.backingStore, &brokenFile) < 0)
         return -1;
 
     if (brokenFile) {
@@ -2408,10 +2408,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
         type == VIR_STORAGE_TYPE_VOLUME)
         goto cleanup;
 
-    if (disk->backingChain) {
+    if (disk->src.backingStore) {
         if (force) {
-            virStorageSourceFree(disk->backingChain);
-            disk->backingChain = NULL;
+            virStorageSourceFree(disk->src.backingStore);
+            disk->src.backingStore = NULL;
         } else {
             goto cleanup;
         }
@@ -2419,11 +2419,11 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
 
     qemuDomainGetImageIds(cfg, vm, disk, &uid, &gid);
 
-    disk->backingChain = virStorageFileGetMetadata(src,
-                                                   virDomainDiskGetFormat(disk),
-                                                   uid, gid,
-                                                   cfg->allowDiskFormatProbing);
-    if (!disk->backingChain)
+    disk->src.backingStore = virStorageFileGetMetadata(src,
+                                                       virDomainDiskGetFormat(disk),
+                                                       uid, gid,
+                                                       cfg->allowDiskFormatProbing);
+    if (!disk->src.backingStore)
         ret = -1;
 
  cleanup:
index dc0d8d5995cb7d17fde66354ab9681e503cca7d0..a610ed82e1dda5b05ca43cb0378a6d623577168a 100644 (file)
@@ -12011,14 +12011,14 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
      * temporarily modify the disk in place.  */
     char *origsrc = disk->src.path;
     int origformat = disk->src.format;
-    virStorageSourcePtr origchain = disk->backingChain;
+    virStorageSourcePtr origchain = disk->src.backingStore;
     bool origreadonly = disk->readonly;
     int ret = -1;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
 
     disk->src.path = (char *) file; /* casting away const is safe here */
     disk->src.format = VIR_STORAGE_FILE_RAW;
-    disk->backingChain = NULL;
+    disk->src.backingStore = NULL;
     disk->readonly = mode == VIR_DISK_CHAIN_READ_ONLY;
 
     if (mode == VIR_DISK_CHAIN_NO_ACCESS) {
@@ -12043,7 +12043,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
  cleanup:
     disk->src.path = origsrc;
     disk->src.format = origformat;
-    disk->backingChain = origchain;
+    disk->src.backingStore = origchain;
     disk->readonly = origreadonly;
     virObjectUnref(cfg);
     return ret;
@@ -12719,13 +12719,13 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
     if (virAsprintf(&device, "drive-%s", disk->info.alias) < 0)
         goto cleanup;
 
-    /* XXX Here, we know we are about to alter disk->backingChain if
+    /* XXX Here, we know we are about to alter disk->src.backingStore if
      * successful, so we nuke the existing chain so that future commands will
      * recompute it.  Better would be storing the chain ourselves rather than
      * reprobing, but this requires modifying domain_conf and our XML to fully
      * track the chain across libvirtd restarts.  */
-    virStorageSourceFree(disk->backingChain);
-    disk->backingChain = NULL;
+    virStorageSourceFree(disk->src.backingStore);
+    disk->src.backingStore = NULL;
 
     if (virStorageFileInit(&snap->src) < 0)
         goto cleanup;
@@ -14763,14 +14763,14 @@ qemuDomainBlockPivot(virConnectPtr conn,
      * we know for sure that there is a backing chain.  */
     oldsrc = disk->src.path;
     oldformat = disk->src.format;
-    oldchain = disk->backingChain;
+    oldchain = disk->src.backingStore;
     disk->src.path = disk->mirror;
     disk->src.format = disk->mirrorFormat;
-    disk->backingChain = NULL;
+    disk->src.backingStore = NULL;
     if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0) {
         disk->src.path = oldsrc;
         disk->src.format = oldformat;
-        disk->backingChain = oldchain;
+        disk->src.backingStore = oldchain;
         goto cleanup;
     }
     if (disk->mirrorFormat && disk->mirrorFormat != VIR_STORAGE_FILE_RAW &&
@@ -14781,7 +14781,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
                                          disk) < 0)) {
         disk->src.path = oldsrc;
         disk->src.format = oldformat;
-        disk->backingChain = oldchain;
+        disk->src.backingStore = oldchain;
         goto cleanup;
     }
 
@@ -14812,8 +14812,8 @@ qemuDomainBlockPivot(virConnectPtr conn,
          * success case, there's security labeling to worry about.  */
         disk->src.path = oldsrc;
         disk->src.format = oldformat;
-        virStorageSourceFree(disk->backingChain);
-        disk->backingChain = oldchain;
+        virStorageSourceFree(disk->src.backingStore);
+        disk->src.backingStore = oldchain;
         VIR_FREE(disk->mirror);
     }
     disk->mirrorFormat = VIR_STORAGE_FILE_NONE;
@@ -15123,7 +15123,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
 
     if ((flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) &&
         STREQ_NULLABLE(format, "raw") &&
-        disk->backingChain->backingStore->path) {
+        disk->src.backingStore->backingStore->path) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("disk '%s' has backing file, so raw shallow copy "
                          "is not possible"),
@@ -15330,8 +15330,8 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
 
     if (!top) {
         top_canon = disk->src.path;
-        top_meta = disk->backingChain;
-    } else if (!(top_canon = virStorageFileChainLookup(disk->backingChain,
+        top_meta = disk->src.backingStore;
+    } else if (!(top_canon = virStorageFileChainLookup(disk->src.backingStore,
                                                        top, &top_meta,
                                                        &top_parent))) {
         goto endjob;
index 01a384a065c80ee8c6bbddd76f53560a815abf21..04dbfbb8c6965789beead3c5d4188e12ce214daa 100644 (file)
@@ -1148,7 +1148,7 @@ virSecuritySELinuxRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
      * be tracked in domain XML, at which point labelskip should be a
      * per-file attribute instead of a disk attribute.  */
     if (disk_seclabel && disk_seclabel->labelskip &&
-        !disk->backingChain)
+        !disk->src.backingStore)
         return 0;
 
     /* Don't restore labels on readoly/shared disks, because
index da66583ea12f1c2e40ec45d691edf9a76a355b19..1c8981537ec1363a2bdafc1fbca3b12a11664c57 100644 (file)
@@ -950,11 +950,11 @@ get_files(vahControl * ctl)
         /* XXX - if we knew the qemu user:group here we could send it in
          *        so that the open could be re-tried as that user:group.
          */
-        if (!disk->backingChain) {
+        if (!disk->src.backingStore) {
             bool probe = ctl->allowDiskFormatProbing;
-            disk->backingChain = virStorageFileGetMetadata(src,
-                                                           virDomainDiskGetFormat(disk),
-                                                           -1, -1, probe);
+            disk->src.backingStore = virStorageFileGetMetadata(src,
+                                                               virDomainDiskGetFormat(disk),
+                                                               -1, -1, probe);
         }
 
         /* XXX passing ignoreOpenFailure = true to get back to the behavior