mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
conf: Remove unnecessary condition from virDomainDiskSourceFormatInternal
Now that the function is using virXMLFormatElement we don't need to conditionally format anything, since we'll format the element according to the presence of content. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
9265b54d93
commit
bbacd6b113
@ -22832,82 +22832,80 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
|
||||
if (policy)
|
||||
startupPolicy = virDomainStartupPolicyTypeToString(policy);
|
||||
|
||||
if (src->path || src->nhosts > 0 || src->srcpool || startupPolicy) {
|
||||
switch ((virStorageType)src->type) {
|
||||
case VIR_STORAGE_TYPE_FILE:
|
||||
virBufferEscapeString(&attrBuf, " file='%s'", src->path);
|
||||
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
|
||||
switch ((virStorageType)src->type) {
|
||||
case VIR_STORAGE_TYPE_FILE:
|
||||
virBufferEscapeString(&attrBuf, " file='%s'", src->path);
|
||||
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
|
||||
|
||||
virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels,
|
||||
src->seclabels, flags,
|
||||
skipSeclabels);
|
||||
break;
|
||||
virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels,
|
||||
src->seclabels, flags,
|
||||
skipSeclabels);
|
||||
break;
|
||||
|
||||
case VIR_STORAGE_TYPE_BLOCK:
|
||||
virBufferEscapeString(&attrBuf, " dev='%s'", src->path);
|
||||
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
|
||||
case VIR_STORAGE_TYPE_BLOCK:
|
||||
virBufferEscapeString(&attrBuf, " dev='%s'", src->path);
|
||||
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
|
||||
|
||||
virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels,
|
||||
src->seclabels, flags,
|
||||
skipSeclabels);
|
||||
break;
|
||||
virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels,
|
||||
src->seclabels, flags,
|
||||
skipSeclabels);
|
||||
break;
|
||||
|
||||
case VIR_STORAGE_TYPE_DIR:
|
||||
virBufferEscapeString(&attrBuf, " dir='%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:
|
||||
if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf,
|
||||
src, flags) < 0)
|
||||
goto error;
|
||||
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));
|
||||
}
|
||||
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
|
||||
|
||||
virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels,
|
||||
src->seclabels, flags,
|
||||
skipSeclabels);
|
||||
break;
|
||||
|
||||
case VIR_STORAGE_TYPE_NONE:
|
||||
case VIR_STORAGE_TYPE_LAST:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected disk type %d"), src->type);
|
||||
case VIR_STORAGE_TYPE_NETWORK:
|
||||
if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf,
|
||||
src, flags) < 0)
|
||||
goto error;
|
||||
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));
|
||||
}
|
||||
virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy);
|
||||
|
||||
/* Storage Source formatting will not carry through the blunder
|
||||
* that disk source formatting had at one time to format the
|
||||
* <auth> for a volume source type. The <auth> 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);
|
||||
virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels,
|
||||
src->seclabels, flags,
|
||||
skipSeclabels);
|
||||
break;
|
||||
|
||||
/* If we found encryption as a child of <source>, then format it
|
||||
* as we found it. */
|
||||
if (src->encryption && src->encryptionInherited &&
|
||||
virStorageEncryptionFormat(&childBuf, src->encryption) < 0)
|
||||
goto error;
|
||||
|
||||
if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
|
||||
goto error;
|
||||
|
||||
if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
|
||||
goto error;
|
||||
case VIR_STORAGE_TYPE_NONE:
|
||||
case VIR_STORAGE_TYPE_LAST:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected disk type %d"), src->type);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Storage Source formatting will not carry through the blunder
|
||||
* that disk source formatting had at one time to format the
|
||||
* <auth> for a volume source type. The <auth> 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 <source>, then format it
|
||||
* as we found it. */
|
||||
if (src->encryption && src->encryptionInherited &&
|
||||
virStorageEncryptionFormat(&childBuf, src->encryption) < 0)
|
||||
goto error;
|
||||
|
||||
if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
|
||||
goto error;
|
||||
|
||||
if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
Loading…
Reference in New Issue
Block a user