1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

storage: Need to set secrettype for direct iscsi disk volume

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.
This commit is contained in:
John Ferlan 2015-06-08 18:41:28 -04:00
parent f886701290
commit 1feaccf000
2 changed files with 25 additions and 1 deletions

View 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));

View 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;