mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 21:15:20 +00:00
conf: Merge virDomainStorageSourceFormat into virDomainDiskSourceFormat
There was only one caller, remove the unnecessary wrapper. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
0f13b78b20
commit
218c81ead0
@ -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
|
|
||||||
* <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)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (src->pr)
|
|
||||||
virStoragePRDefFormat(childBuf, src->pr,
|
|
||||||
flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainDiskSourceFormat(virBufferPtr buf,
|
virDomainDiskSourceFormat(virBufferPtr buf,
|
||||||
virStorageSourcePtr src,
|
virStorageSourcePtr src,
|
||||||
@ -23800,9 +23729,66 @@ virDomainDiskSourceFormat(virBufferPtr buf,
|
|||||||
|
|
||||||
virBufferSetChildIndent(&childBuf, 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
|
||||||
|
* <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)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (src->pr)
|
||||||
|
virStoragePRDefFormat(&childBuf, src->pr,
|
||||||
|
flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE);
|
||||||
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));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user