From 092ca9689a6e95fa61cd956548c24b2de9a6b278 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Sat, 13 Jul 2013 14:23:38 -0400 Subject: [PATCH] storage_conf: Move auth processing into virStoragePoolDefParseAuth Split processing of "authType = VIR_STORAGE_POOL_AUTH_NONE; + ret = 0; + goto cleanup; + } + + if ((source->authType = + virStoragePoolAuthTypeTypeFromString(authType)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown auth type '%s'"), + authType); + goto cleanup; + } + + if (source->authType == VIR_STORAGE_POOL_AUTH_CHAP) { + if (virStoragePoolDefParseAuthChap(ctxt, &source->auth.chap) < 0) + goto cleanup; + } + + if (source->authType == VIR_STORAGE_POOL_AUTH_CEPHX) { + if (virStoragePoolDefParseAuthCephx(ctxt, &source->auth.cephx) < 0) + goto cleanup; + } + + ret = 0; + +cleanup: + VIR_FREE(authType); + return ret; +} + static int virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, virStoragePoolSourcePtr source, @@ -530,7 +569,6 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, { int ret = -1; xmlNodePtr relnode, *nodeset = NULL; - char *authType = NULL; int nsource; size_t i; virStoragePoolOptionsPtr options; @@ -676,28 +714,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; } - authType = virXPathString("string(./auth/@type)", ctxt); - if (authType == NULL) { - source->authType = VIR_STORAGE_POOL_AUTH_NONE; - } else { - if ((source->authType = - virStoragePoolAuthTypeTypeFromString(authType)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown auth type '%s'"), - authType); - goto cleanup; - } - } - - if (source->authType == VIR_STORAGE_POOL_AUTH_CHAP) { - if (virStoragePoolDefParseAuthChap(ctxt, &source->auth.chap) < 0) - goto cleanup; - } - - if (source->authType == VIR_STORAGE_POOL_AUTH_CEPHX) { - if (virStoragePoolDefParseAuthCephx(ctxt, &source->auth.cephx) < 0) - goto cleanup; - } + if (virStoragePoolDefParseAuth(ctxt, source) < 0) + goto cleanup; source->vendor = virXPathString("string(./vendor/@name)", ctxt); source->product = virXPathString("string(./product/@name)", ctxt); @@ -707,7 +725,6 @@ cleanup: ctxt->node = relnode; VIR_FREE(port); - VIR_FREE(authType); VIR_FREE(nodeset); VIR_FREE(adapter_type); return ret; -- 2.39.5