提交 2bbbc979 编写于 作者: P Peter Krempa

conf: Refactor formatting of startupPolicy in virDomainDiskSourceFormatInternal

Move it to a single location which also allows to get rid of the
temporrary variable.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
上级 8f513882
......@@ -22806,29 +22806,22 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
bool skipSeclabels,
virDomainXMLOptionPtr xmlopt)
{
const char *startupPolicy = NULL;
virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
virBuffer childBuf = VIR_BUFFER_INITIALIZER;
virBufferSetChildIndent(&childBuf, buf);
if (policy)
startupPolicy = virDomainStartupPolicyTypeToString(policy);
switch ((virStorageType)src->type) {
case VIR_STORAGE_TYPE_FILE:
virBufferEscapeString(&attrBuf, " file='%s'", src->path);
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
break;
case VIR_STORAGE_TYPE_BLOCK:
virBufferEscapeString(&attrBuf, " dev='%s'", src->path);
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
break;
case VIR_STORAGE_TYPE_DIR:
virBufferEscapeString(&attrBuf, " dir='%s'", src->path);
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
break;
case VIR_STORAGE_TYPE_NETWORK:
......@@ -22846,7 +22839,6 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
virBufferAsprintf(&attrBuf, " mode='%s'",
virStorageSourcePoolModeTypeToString(src->srcpool->mode));
}
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
break;
......@@ -22858,6 +22850,10 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
}
if (src->type != VIR_STORAGE_TYPE_NETWORK) {
if (policy)
virBufferEscapeString(&attrBuf, " startupPolicy='%s'",
virDomainStartupPolicyTypeToString(policy));
if (!skipSeclabels)
virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels,
src->seclabels, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册