mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
conf: Turn virDomainDef.kvm_features into a struct
In future commits we will need to store not just an array of VIR_TRISTATE_SWITCH_* but also an additional integer. Follow the example of TCG and introduce a structure where both the array an integer can live. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
dacf616b78
commit
a8e0f9c682
@ -3713,6 +3713,7 @@ void virDomainDefFree(virDomainDef *def)
|
||||
g_free(def->emulator);
|
||||
g_free(def->description);
|
||||
g_free(def->title);
|
||||
g_free(def->kvm_features);
|
||||
g_free(def->hyperv_vendor_id);
|
||||
g_free(def->tcg_features);
|
||||
|
||||
@ -17532,7 +17533,9 @@ static int
|
||||
virDomainFeaturesKVMDefParse(virDomainDef *def,
|
||||
xmlNodePtr node)
|
||||
{
|
||||
def->features[VIR_DOMAIN_FEATURE_KVM] = VIR_TRISTATE_SWITCH_ON;
|
||||
g_autofree virDomainFeatureKVM *kvm = NULL;
|
||||
|
||||
kvm = g_new0(virDomainFeatureKVM, 1);
|
||||
|
||||
node = xmlFirstElementChild(node);
|
||||
while (node) {
|
||||
@ -17551,11 +17554,14 @@ virDomainFeaturesKVMDefParse(virDomainDef *def,
|
||||
&value) < 0)
|
||||
return -1;
|
||||
|
||||
def->kvm_features[feature] = value;
|
||||
kvm->features[feature] = value;
|
||||
|
||||
node = xmlNextElementSibling(node);
|
||||
}
|
||||
|
||||
def->features[VIR_DOMAIN_FEATURE_KVM] = VIR_TRISTATE_SWITCH_ON;
|
||||
def->kvm_features = g_steal_pointer(&kvm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -21803,13 +21809,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDef *src,
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
case VIR_DOMAIN_KVM_POLLCONTROL:
|
||||
case VIR_DOMAIN_KVM_PVIPI:
|
||||
if (src->kvm_features[i] != dst->kvm_features[i]) {
|
||||
if (src->kvm_features->features[i] != dst->kvm_features->features[i]) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("State of KVM feature '%s' differs: "
|
||||
"source: '%s', destination: '%s'"),
|
||||
virDomainKVMTypeToString(i),
|
||||
virTristateSwitchTypeToString(src->kvm_features[i]),
|
||||
virTristateSwitchTypeToString(dst->kvm_features[i]));
|
||||
virTristateSwitchTypeToString(src->kvm_features->features[i]),
|
||||
virTristateSwitchTypeToString(dst->kvm_features->features[i]));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -27873,11 +27879,11 @@ virDomainDefFormatFeatures(virBuffer *buf,
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
case VIR_DOMAIN_KVM_POLLCONTROL:
|
||||
case VIR_DOMAIN_KVM_PVIPI:
|
||||
if (def->kvm_features[j])
|
||||
if (def->kvm_features->features[j])
|
||||
virBufferAsprintf(&childBuf, "<%s state='%s'/>\n",
|
||||
virDomainKVMTypeToString(j),
|
||||
virTristateSwitchTypeToString(
|
||||
def->kvm_features[j]));
|
||||
def->kvm_features->features[j]));
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_KVM_LAST:
|
||||
|
@ -2263,6 +2263,11 @@ typedef enum {
|
||||
|
||||
VIR_ENUM_DECL(virDomainIBS);
|
||||
|
||||
typedef struct _virDomainFeatureKVM virDomainFeatureKVM;
|
||||
struct _virDomainFeatureKVM {
|
||||
int features[VIR_DOMAIN_KVM_LAST];
|
||||
};
|
||||
|
||||
typedef struct _virDomainFeatureTCG virDomainFeatureTCG;
|
||||
struct _virDomainFeatureTCG {
|
||||
unsigned long long tb_cache; /* Stored in KiB */
|
||||
@ -2819,7 +2824,7 @@ struct _virDomainDef {
|
||||
int features[VIR_DOMAIN_FEATURE_LAST];
|
||||
int caps_features[VIR_DOMAIN_PROCES_CAPS_FEATURE_LAST];
|
||||
int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
|
||||
int kvm_features[VIR_DOMAIN_KVM_LAST];
|
||||
virDomainFeatureKVM *kvm_features;
|
||||
int msrs_features[VIR_DOMAIN_MSRS_LAST];
|
||||
int xen_features[VIR_DOMAIN_XEN_LAST];
|
||||
virDomainXenPassthroughMode xen_passthrough_mode;
|
||||
|
@ -6765,22 +6765,22 @@ qemuBuildCpuCommandLine(virCommand *cmd,
|
||||
for (i = 0; i < VIR_DOMAIN_KVM_LAST; i++) {
|
||||
switch ((virDomainKVM) i) {
|
||||
case VIR_DOMAIN_KVM_HIDDEN:
|
||||
if (def->kvm_features[i] == VIR_TRISTATE_SWITCH_ON)
|
||||
if (def->kvm_features->features[i] == VIR_TRISTATE_SWITCH_ON)
|
||||
virBufferAddLit(&buf, ",kvm=off");
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
if (def->kvm_features[i] == VIR_TRISTATE_SWITCH_ON)
|
||||
if (def->kvm_features->features[i] == VIR_TRISTATE_SWITCH_ON)
|
||||
virBufferAddLit(&buf, ",kvm-hint-dedicated=on");
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_KVM_POLLCONTROL:
|
||||
if (def->kvm_features[i] == VIR_TRISTATE_SWITCH_ON)
|
||||
if (def->kvm_features->features[i] == VIR_TRISTATE_SWITCH_ON)
|
||||
virBufferAddLit(&buf, ",kvm-poll-control=on");
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_KVM_PVIPI:
|
||||
if (def->kvm_features[i] == VIR_TRISTATE_SWITCH_OFF)
|
||||
if (def->kvm_features->features[i] == VIR_TRISTATE_SWITCH_OFF)
|
||||
virBufferAddLit(&buf, ",kvm-pv-ipi=off");
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user