]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Need to set secrettype for direct iscsi disk volume
authorJohn Ferlan <jferlan@redhat.com>
Mon, 8 Jun 2015 22:41:28 +0000 (18:41 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 15 Jun 2015 11:14:40 +0000 (07:14 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1200206

Commit id '1b4eaa61' added the ability to have a mode='direct' for
an iscsi disk volume.  It relied on virStorageTranslateDiskSourcePool
in order to copy any disk source pool authentication information to
the direct disk volume, but it neglected to also copy the 'secrettype'
field which ends up being used in the domain volume formatting code.
Adding a secrettype for this case will allow for proper formatting later
and allow disk snapshotting to work properly

Additionally libvirtd restart processing would fail to find the domain
since the translation processing code is run after domain xml processing,
so handle the the case where the authdef could have an empty secrettype
field when processing the auth and additionally ignore performing the
actual and expected auth secret type checks for a DISK_VOLUME since that
data will be reassembled later during translation processing of the
running domain.

src/conf/domain_conf.c
src/storage/storage_driver.c

index 60d4d0751a880cb620fe53c6d316491709f311fb..ca559815f6baa69d2e699db2b77a43ee35243072 100644 (file)
@@ -6571,6 +6571,16 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
                        xmlStrEqual(cur->name, BAD_CAST "auth")) {
                 if (!(authdef = virStorageAuthDefParse(node->doc, cur)))
                     goto error;
+                /* Shared processing code with storage pools can leave
+                 * this empty, but disk formatting uses it as does command
+                 * creation - so use the secretType to attempt to fill it in.
+                 */
+                if (!authdef->secrettype) {
+                    const char *secrettype =
+                        virSecretUsageTypeToString(authdef->secretType);
+                    if (VIR_STRDUP(authdef->secrettype, secrettype) < 0)
+                        goto error;
+                }
                 if ((auth_secret_usage =
                      virSecretUsageTypeFromString(authdef->secrettype)) < 0) {
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -6790,7 +6800,11 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         cur = cur->next;
     }
 
-    if (auth_secret_usage != -1 && auth_secret_usage != expected_secret_usage) {
+    /* Disk volume types will have authentication information handled in
+     * virStorageTranslateDiskSourcePool
+     */
+    if (def->src->type != VIR_STORAGE_TYPE_VOLUME &&
+        auth_secret_usage != -1 && auth_secret_usage != expected_secret_usage) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("invalid secret type '%s'"),
                        virSecretUsageTypeToString(auth_secret_usage));
index ab8675db8179db0e92c397ed4513a3a2016f1171..57060abc4d2f2e9ecc4575550f3748b0a0188299 100644 (file)
@@ -3310,6 +3310,16 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
                                                      &pooldef->source) < 0)
                goto cleanup;
 
+           /* Source pool may not fill in the secrettype field,
+            * so we need to do so here
+            */
+           if (def->src->auth && !def->src->auth->secrettype) {
+               const char *secrettype =
+                   virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI);
+               if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0)
+                   goto cleanup;
+           }
+
            if (virStorageAddISCSIPoolSourceHost(def, pooldef) < 0)
                goto cleanup;
            break;