conf: Add virDomainDiskSetBlockIOTune

That function sets disk->blkdeviotune sensibly.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2017-01-30 20:37:48 +01:00
parent 8336cbca21
commit eae7cfd42d
3 changed files with 32 additions and 0 deletions

View File

@ -25845,3 +25845,30 @@ virDomainDefVcpuOrderClear(virDomainDefPtr def)
for (i = 0; i < def->maxvcpus; i++)
def->vcpus[i]->order = 0;
}
/**
* virDomainDiskSetBlockIOTune:
* @disk: The disk to set block I/O tuning on
* @info: The BlockIoTuneInfo to be set on the @disk
*
* Set the block I/O tune settings from @info on the @disk, but error out early
* in case of any error. That is to make sure nothing will fail half-way.
*
* Returns: 0 on success, -1 otherwise
*/
int
virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
virDomainBlockIoTuneInfo *info)
{
char *tmp_group = NULL;
if (VIR_STRDUP(tmp_group, info->group_name) < 0)
return -1;
VIR_FREE(disk->blkdeviotune.group_name);
disk->blkdeviotune = *info;
VIR_STEAL_PTR(disk->blkdeviotune.group_name, tmp_group);
return 0;
}

View File

@ -3219,4 +3219,8 @@ bool
virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a,
const virDomainDeviceInfo *b)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
virDomainBlockIoTuneInfo *info);
#endif /* __DOMAIN_CONF_H */

View File

@ -314,6 +314,7 @@ virDomainDiskMirrorStateTypeToString;
virDomainDiskPathByName;
virDomainDiskRemove;
virDomainDiskRemoveByName;
virDomainDiskSetBlockIOTune;
virDomainDiskSetDriver;
virDomainDiskSetFormat;
virDomainDiskSetSource;