mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
conf: refactor hyperv features xml output
1. All hyperv features are tristate ones. So make tristate generating part common. 2. Reduce nesting on spinlocks. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
ae37d9f1d1
commit
2e26d78c8b
@ -22331,33 +22331,32 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
||||
virBufferAddLit(buf, "<hyperv>\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
for (j = 0; j < VIR_DOMAIN_HYPERV_LAST; j++) {
|
||||
if (def->hyperv_features[j] == VIR_TRISTATE_SWITCH_ABSENT)
|
||||
continue;
|
||||
|
||||
virBufferAsprintf(buf, "<%s state='%s'",
|
||||
virDomainHypervTypeToString(j),
|
||||
virTristateSwitchTypeToString(
|
||||
def->hyperv_features[j]));
|
||||
|
||||
switch ((virDomainHyperv) j) {
|
||||
case VIR_DOMAIN_HYPERV_RELAXED:
|
||||
case VIR_DOMAIN_HYPERV_VAPIC:
|
||||
if (def->hyperv_features[j])
|
||||
virBufferAsprintf(buf, "<%s state='%s'/>\n",
|
||||
virDomainHypervTypeToString(j),
|
||||
virTristateSwitchTypeToString(
|
||||
def->hyperv_features[j]));
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_HYPERV_SPINLOCKS:
|
||||
if (def->hyperv_features[j] == 0)
|
||||
if (def->hyperv_features[j] != VIR_TRISTATE_SWITCH_ON)
|
||||
break;
|
||||
|
||||
virBufferAsprintf(buf, "<spinlocks state='%s'",
|
||||
virTristateSwitchTypeToString(
|
||||
def->hyperv_features[j]));
|
||||
if (def->hyperv_features[j] == VIR_TRISTATE_SWITCH_ON)
|
||||
virBufferAsprintf(buf, " retries='%d'",
|
||||
def->hyperv_spinlocks);
|
||||
virBufferAddLit(buf, "/>\n");
|
||||
virBufferAsprintf(buf, " retries='%d'",
|
||||
def->hyperv_spinlocks);
|
||||
break;
|
||||
|
||||
/* coverity[dead_error_begin] */
|
||||
case VIR_DOMAIN_HYPERV_LAST:
|
||||
break;
|
||||
}
|
||||
|
||||
virBufferAddLit(buf, "/>\n");
|
||||
}
|
||||
virBufferAdjustIndent(buf, -2);
|
||||
virBufferAddLit(buf, "</hyperv>\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user