mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
qemuBuildDiskFrontendAttributeErrorPolicy: Extract logic
Extract the logic to determine the actual settings into 'qemuBuildDiskGetErrorPolicy' so that it can be reused when we'll convert the disk -device formatter to JSON. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9616976433
commit
d06e3000c4
@ -1963,28 +1963,37 @@ qemuBuildDiskThrottling(virDomainDiskDef *disk,
|
||||
|
||||
|
||||
static void
|
||||
qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDef *disk,
|
||||
virBuffer *buf)
|
||||
qemuBuildDiskGetErrorPolicy(virDomainDiskDef *disk,
|
||||
const char **wpolicy,
|
||||
const char **rpolicy)
|
||||
{
|
||||
const char *wpolicy = NULL;
|
||||
const char *rpolicy = NULL;
|
||||
|
||||
if (disk->error_policy)
|
||||
wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy);
|
||||
*wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy);
|
||||
|
||||
if (disk->rerror_policy)
|
||||
rpolicy = virDomainDiskErrorPolicyTypeToString(disk->rerror_policy);
|
||||
*rpolicy = virDomainDiskErrorPolicyTypeToString(disk->rerror_policy);
|
||||
|
||||
if (disk->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE) {
|
||||
/* in the case of enospace, the option is spelled
|
||||
* differently in qemu, and it's only valid for werror,
|
||||
* not for rerror, so leave rerror NULL.
|
||||
*/
|
||||
wpolicy = "enospc";
|
||||
} else if (!rpolicy) {
|
||||
*wpolicy = "enospc";
|
||||
} else if (!*rpolicy) {
|
||||
/* for other policies, rpolicy can match wpolicy */
|
||||
rpolicy = wpolicy;
|
||||
*rpolicy = *wpolicy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDef *disk,
|
||||
virBuffer *buf)
|
||||
{
|
||||
const char *wpolicy = NULL;
|
||||
const char *rpolicy = NULL;
|
||||
|
||||
qemuBuildDiskGetErrorPolicy(disk, &wpolicy, &rpolicy);
|
||||
|
||||
if (wpolicy)
|
||||
virBufferAsprintf(buf, ",werror=%s", wpolicy);
|
||||
|
Loading…
Reference in New Issue
Block a user