提交 218c81ea 编写于 作者: P Peter Krempa

conf: Merge virDomainStorageSourceFormat into virDomainDiskSourceFormat

There was only one caller, remove the unnecessary wrapper.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 0f13b78b
...@@ -23716,38 +23716,45 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf, ...@@ -23716,38 +23716,45 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
} }
static int int
virDomainStorageSourceFormat(virBufferPtr attrBuf, virDomainDiskSourceFormat(virBufferPtr buf,
virBufferPtr childBuf, virStorageSourcePtr src,
virStorageSourcePtr src, int policy,
unsigned int flags) bool attrIndex,
unsigned int flags,
virDomainXMLOptionPtr xmlopt)
{ {
VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
virBufferSetChildIndent(&childBuf, buf);
switch ((virStorageType)src->type) { switch ((virStorageType)src->type) {
case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_FILE:
virBufferEscapeString(attrBuf, " file='%s'", src->path); virBufferEscapeString(&attrBuf, " file='%s'", src->path);
break; break;
case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_BLOCK:
virBufferEscapeString(attrBuf, " dev='%s'", src->path); virBufferEscapeString(&attrBuf, " dev='%s'", src->path);
break; break;
case VIR_STORAGE_TYPE_DIR: case VIR_STORAGE_TYPE_DIR:
virBufferEscapeString(attrBuf, " dir='%s'", src->path); virBufferEscapeString(&attrBuf, " dir='%s'", src->path);
break; break;
case VIR_STORAGE_TYPE_NETWORK: case VIR_STORAGE_TYPE_NETWORK:
if (virDomainDiskSourceFormatNetwork(attrBuf, childBuf, if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf,
src, flags) < 0) src, flags) < 0)
return -1; return -1;
break; break;
case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_VOLUME:
if (src->srcpool) { if (src->srcpool) {
virBufferEscapeString(attrBuf, " pool='%s'", src->srcpool->pool); virBufferEscapeString(&attrBuf, " pool='%s'", src->srcpool->pool);
virBufferEscapeString(attrBuf, " volume='%s'", virBufferEscapeString(&attrBuf, " volume='%s'",
src->srcpool->volume); src->srcpool->volume);
if (src->srcpool->mode) if (src->srcpool->mode)
virBufferAsprintf(attrBuf, " mode='%s'", virBufferAsprintf(&attrBuf, " mode='%s'",
virStorageSourcePoolModeTypeToString(src->srcpool->mode)); virStorageSourcePoolModeTypeToString(src->srcpool->mode));
} }
...@@ -23761,7 +23768,7 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf, ...@@ -23761,7 +23768,7 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf,
} }
if (src->type != VIR_STORAGE_TYPE_NETWORK) if (src->type != VIR_STORAGE_TYPE_NETWORK)
virDomainSourceDefFormatSeclabel(childBuf, src->nseclabels, virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels,
src->seclabels, flags); src->seclabels, flags);
/* Storage Source formatting will not carry through the blunder /* Storage Source formatting will not carry through the blunder
...@@ -23771,38 +23778,17 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf, ...@@ -23771,38 +23778,17 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf,
* So avoid formatting it for volumes. */ * So avoid formatting it for volumes. */
if (src->auth && src->authInherited && if (src->auth && src->authInherited &&
src->type != VIR_STORAGE_TYPE_VOLUME) src->type != VIR_STORAGE_TYPE_VOLUME)
virStorageAuthDefFormat(childBuf, src->auth); virStorageAuthDefFormat(&childBuf, src->auth);
/* If we found encryption as a child of <source>, then format it /* If we found encryption as a child of <source>, then format it
* as we found it. */ * as we found it. */
if (src->encryption && src->encryptionInherited && if (src->encryption && src->encryptionInherited &&
virStorageEncryptionFormat(childBuf, src->encryption) < 0) virStorageEncryptionFormat(&childBuf, src->encryption) < 0)
return -1; return -1;
if (src->pr) if (src->pr)
virStoragePRDefFormat(childBuf, src->pr, virStoragePRDefFormat(&childBuf, src->pr,
flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE); flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE);
return 0;
}
int
virDomainDiskSourceFormat(virBufferPtr buf,
virStorageSourcePtr src,
int policy,
bool attrIndex,
unsigned int flags,
virDomainXMLOptionPtr xmlopt)
{
VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
virBufferSetChildIndent(&childBuf, buf);
if (virDomainStorageSourceFormat(&attrBuf, &childBuf, src, flags) < 0)
return -1;
if (policy && src->type != VIR_STORAGE_TYPE_NETWORK) if (policy && src->type != VIR_STORAGE_TYPE_NETWORK)
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", virBufferEscapeString(&attrBuf, " startupPolicy='%s'",
virDomainStartupPolicyTypeToString(policy)); virDomainStartupPolicyTypeToString(policy));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册