From 218c81ead0551aba8fca807f750dc60131746f46 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 20 Mar 2019 13:51:07 +0100 Subject: [PATCH] conf: Merge virDomainStorageSourceFormat into virDomainDiskSourceFormat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was only one caller, remove the unnecessary wrapper. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 130 ++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 72 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6a2d46b3e9..5f55a7382d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23716,77 +23716,6 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf, } -static int -virDomainStorageSourceFormat(virBufferPtr attrBuf, - virBufferPtr childBuf, - virStorageSourcePtr src, - unsigned int flags) -{ - switch ((virStorageType)src->type) { - case VIR_STORAGE_TYPE_FILE: - virBufferEscapeString(attrBuf, " file='%s'", src->path); - break; - - case VIR_STORAGE_TYPE_BLOCK: - virBufferEscapeString(attrBuf, " dev='%s'", src->path); - break; - - case VIR_STORAGE_TYPE_DIR: - virBufferEscapeString(attrBuf, " dir='%s'", src->path); - break; - - case VIR_STORAGE_TYPE_NETWORK: - if (virDomainDiskSourceFormatNetwork(attrBuf, childBuf, - src, flags) < 0) - return -1; - break; - - case VIR_STORAGE_TYPE_VOLUME: - if (src->srcpool) { - virBufferEscapeString(attrBuf, " pool='%s'", src->srcpool->pool); - virBufferEscapeString(attrBuf, " volume='%s'", - src->srcpool->volume); - if (src->srcpool->mode) - virBufferAsprintf(attrBuf, " mode='%s'", - virStorageSourcePoolModeTypeToString(src->srcpool->mode)); - } - - break; - - case VIR_STORAGE_TYPE_NONE: - case VIR_STORAGE_TYPE_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk type %d"), src->type); - return -1; - } - - if (src->type != VIR_STORAGE_TYPE_NETWORK) - virDomainSourceDefFormatSeclabel(childBuf, src->nseclabels, - src->seclabels, flags); - - /* Storage Source formatting will not carry through the blunder - * that disk source formatting had at one time to format the - * for a volume source type. The information is - * kept in the storage pool and would be overwritten anyway. - * So avoid formatting it for volumes. */ - if (src->auth && src->authInherited && - src->type != VIR_STORAGE_TYPE_VOLUME) - virStorageAuthDefFormat(childBuf, src->auth); - - /* If we found encryption as a child of , then format it - * as we found it. */ - if (src->encryption && src->encryptionInherited && - virStorageEncryptionFormat(childBuf, src->encryption) < 0) - return -1; - - if (src->pr) - virStoragePRDefFormat(childBuf, src->pr, - flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE); - - return 0; -} - - int virDomainDiskSourceFormat(virBufferPtr buf, virStorageSourcePtr src, @@ -23800,9 +23729,66 @@ virDomainDiskSourceFormat(virBufferPtr buf, virBufferSetChildIndent(&childBuf, buf); - if (virDomainStorageSourceFormat(&attrBuf, &childBuf, src, flags) < 0) + switch ((virStorageType)src->type) { + case VIR_STORAGE_TYPE_FILE: + virBufferEscapeString(&attrBuf, " file='%s'", src->path); + break; + + case VIR_STORAGE_TYPE_BLOCK: + virBufferEscapeString(&attrBuf, " dev='%s'", src->path); + break; + + case VIR_STORAGE_TYPE_DIR: + virBufferEscapeString(&attrBuf, " dir='%s'", src->path); + break; + + case VIR_STORAGE_TYPE_NETWORK: + if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf, + src, flags) < 0) + return -1; + break; + + case VIR_STORAGE_TYPE_VOLUME: + if (src->srcpool) { + virBufferEscapeString(&attrBuf, " pool='%s'", src->srcpool->pool); + virBufferEscapeString(&attrBuf, " volume='%s'", + src->srcpool->volume); + if (src->srcpool->mode) + virBufferAsprintf(&attrBuf, " mode='%s'", + virStorageSourcePoolModeTypeToString(src->srcpool->mode)); + } + + break; + + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk type %d"), src->type); + return -1; + } + + if (src->type != VIR_STORAGE_TYPE_NETWORK) + virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels, + src->seclabels, flags); + + /* Storage Source formatting will not carry through the blunder + * that disk source formatting had at one time to format the + * for a volume source type. The information is + * kept in the storage pool and would be overwritten anyway. + * So avoid formatting it for volumes. */ + if (src->auth && src->authInherited && + src->type != VIR_STORAGE_TYPE_VOLUME) + virStorageAuthDefFormat(&childBuf, src->auth); + + /* If we found encryption as a child of , then format it + * as we found it. */ + if (src->encryption && src->encryptionInherited && + virStorageEncryptionFormat(&childBuf, src->encryption) < 0) return -1; + if (src->pr) + virStoragePRDefFormat(&childBuf, src->pr, + flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE); if (policy && src->type != VIR_STORAGE_TYPE_NETWORK) virBufferEscapeString(&attrBuf, " startupPolicy='%s'", virDomainStartupPolicyTypeToString(policy));