提交 de7b5faf 编写于 作者: P Peter Krempa

conf: Refactor storing and usage of feature flags

Currently we were storing domain feature flags in a bit field as the
they were either enabled or disabled. New features such as paravirtual
spinlocks however can be tri-state as the default option may depend on
hypervisor version.

To allow storing tri-state feature state in the same place instead of
having to declare dedicated variables for each feature this patch
refactors the bit field to an array.
上级 2e8f9080
......@@ -11416,10 +11416,10 @@ virDomainDefParseXML(xmlDocPtr xml,
_("unexpected feature '%s'"), nodes[i]->name);
goto error;
}
def->features |= (1 << val);
if (val == VIR_DOMAIN_FEATURE_APIC) {
tmp = virXPathString("string(./features/apic/@eoi)", ctxt);
if (tmp) {
switch ((enum virDomainFeature) val) {
case VIR_DOMAIN_FEATURE_APIC:
if ((tmp = virXPathString("string(./features/apic/@eoi)", ctxt))) {
int eoi;
if ((eoi = virDomainFeatureStateTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
......@@ -11430,11 +11430,23 @@ virDomainDefParseXML(xmlDocPtr xml,
def->apic_eoi = eoi;
VIR_FREE(tmp);
}
/* fallthrough */
case VIR_DOMAIN_FEATURE_ACPI:
case VIR_DOMAIN_FEATURE_PAE:
case VIR_DOMAIN_FEATURE_HAP:
case VIR_DOMAIN_FEATURE_VIRIDIAN:
case VIR_DOMAIN_FEATURE_PRIVNET:
case VIR_DOMAIN_FEATURE_HYPERV:
def->features[val] = VIR_DOMAIN_FEATURE_STATE_ON;
break;
case VIR_DOMAIN_FEATURE_LAST:
break;
}
}
VIR_FREE(nodes);
if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) {
if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_DOMAIN_FEATURE_STATE_ON) {
int feature;
int value;
node = ctxt->node;
......@@ -13406,12 +13418,16 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
{
size_t i;
/* basic check */
if (src->features != dst->features) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain features %d does not match source %d"),
dst->features, src->features);
return false;
for (i = 0; i < VIR_DOMAIN_FEATURE_LAST; i++) {
if (src->features[i] != dst->features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%s' differs: "
"source: '%s', destination: '%s'"),
virDomainFeatureTypeToString(i),
virDomainFeatureStateTypeToString(src->features[i]),
virDomainFeatureStateTypeToString(dst->features[i]));
return false;
}
}
/* APIC EOI */
......@@ -13425,7 +13441,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
}
/* hyperv */
if (src->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) {
if (src->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_DOMAIN_FEATURE_STATE_ON) {
for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
switch ((enum virDomainHyperv) i) {
case VIR_DOMAIN_HYPERV_RELAXED:
......@@ -16748,58 +16764,99 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAddLit(buf, " </idmap>\n");
}
for (i = 0; i < VIR_DOMAIN_FEATURE_LAST; i++) {
if (def->features[i] != VIR_DOMAIN_FEATURE_STATE_DEFAULT)
break;
}
if (def->features) {
if (i != VIR_DOMAIN_FEATURE_LAST) {
virBufferAddLit(buf, " <features>\n");
for (i = 0; i < VIR_DOMAIN_FEATURE_LAST; i++) {
if (def->features & (1 << i) && i != VIR_DOMAIN_FEATURE_HYPERV) {
const char *name = virDomainFeatureTypeToString(i);
if (!name) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected feature %zu"), i);
goto error;
}
virBufferAsprintf(buf, " <%s", name);
if (i == VIR_DOMAIN_FEATURE_APIC && def->apic_eoi) {
virBufferAsprintf(buf,
" eoi='%s'",
virDomainFeatureStateTypeToString(def->apic_eoi));
}
virBufferAddLit(buf, "/>\n");
const char *name = virDomainFeatureTypeToString(i);
size_t j;
if (!name) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected feature %zu"), i);
goto error;
}
}
if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) {
virBufferAddLit(buf, " <hyperv>\n");
for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
switch ((enum virDomainHyperv) i) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
if (def->hyperv_features[i])
virBufferAsprintf(buf, " <%s state='%s'/>\n",
virDomainHypervTypeToString(i),
virDomainFeatureStateTypeToString(
def->hyperv_features[i]));
switch ((enum virDomainFeature) i) {
case VIR_DOMAIN_FEATURE_ACPI:
case VIR_DOMAIN_FEATURE_PAE:
case VIR_DOMAIN_FEATURE_HAP:
case VIR_DOMAIN_FEATURE_VIRIDIAN:
case VIR_DOMAIN_FEATURE_PRIVNET:
switch ((enum virDomainFeatureState) def->features[i]) {
case VIR_DOMAIN_FEATURE_STATE_DEFAULT:
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
if (def->hyperv_features[i] == 0)
break;
case VIR_DOMAIN_FEATURE_STATE_ON:
virBufferAsprintf(buf, " <%s/>\n", name);
break;
case VIR_DOMAIN_FEATURE_STATE_LAST:
case VIR_DOMAIN_FEATURE_STATE_OFF:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected state of feature '%s'"), name);
goto error;
break;
}
break;
virBufferAsprintf(buf, " <spinlocks state='%s'",
virDomainFeatureStateTypeToString(
def->hyperv_features[i]));
if (def->hyperv_features[i] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAsprintf(buf, " retries='%d'",
def->hyperv_spinlocks);
case VIR_DOMAIN_FEATURE_APIC:
if (def->features[i] == VIR_DOMAIN_FEATURE_STATE_ON) {
virBufferAddLit(buf, " <apic");
if (def->apic_eoi) {
virBufferAsprintf(buf, " eoi='%s'",
virDomainFeatureStateTypeToString(def->apic_eoi));
}
virBufferAddLit(buf, "/>\n");
break;
}
break;
case VIR_DOMAIN_HYPERV_LAST:
case VIR_DOMAIN_FEATURE_HYPERV:
if (def->features[i] != VIR_DOMAIN_FEATURE_STATE_ON)
break;
virBufferAddLit(buf, " <hyperv>\n");
for (j = 0; j < VIR_DOMAIN_HYPERV_LAST; j++) {
switch ((enum 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),
virDomainFeatureStateTypeToString(
def->hyperv_features[j]));
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
if (def->hyperv_features[j] == 0)
break;
virBufferAsprintf(buf, " <spinlocks state='%s'",
virDomainFeatureStateTypeToString(
def->hyperv_features[j]));
if (def->hyperv_features[j] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAsprintf(buf, " retries='%d'",
def->hyperv_spinlocks);
virBufferAddLit(buf, "/>\n");
break;
case VIR_DOMAIN_HYPERV_LAST:
break;
}
}
virBufferAddLit(buf, " </hyperv>\n");
break;
case VIR_DOMAIN_FEATURE_LAST:
break;
}
virBufferAddLit(buf, " </hyperv>\n");
}
virBufferAddLit(buf, " </features>\n");
......
......@@ -1988,7 +1988,7 @@ struct _virDomainDef {
virDomainOSDef os;
char *emulator;
int features;
int features[VIR_DOMAIN_FEATURE_LAST];
/* enum virDomainFeatureState */
int apic_eoi;
/* These options are of type virDomainFeatureState */
......
......@@ -603,11 +603,14 @@ libxlMakeDomBuildInfo(virDomainObjPtr vm, libxl_domain_config *d_config)
char bootorder[VIR_DOMAIN_BOOT_LAST + 1];
libxl_defbool_set(&b_info->u.hvm.pae,
def->features & (1 << VIR_DOMAIN_FEATURE_PAE));
def->features[VIR_DOMAIN_FEATURE_PAE] ==
VIR_DOMAIN_FEATURE_STATE_ON);
libxl_defbool_set(&b_info->u.hvm.apic,
def->features & (1 << VIR_DOMAIN_FEATURE_APIC));
def->features[VIR_DOMAIN_FEATURE_APIC] ==
VIR_DOMAIN_FEATURE_STATE_ON);
libxl_defbool_set(&b_info->u.hvm.acpi,
def->features & (1 << VIR_DOMAIN_FEATURE_ACPI));
def->features[VIR_DOMAIN_FEATURE_ACPI] ==
VIR_DOMAIN_FEATURE_STATE_ON);
for (i = 0; i < def->clock.ntimers; i++) {
if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET &&
def->clock.timers[i]->present == 1) {
......
......@@ -1887,8 +1887,8 @@ static int lxcContainerChild(void *data)
}
/* rename and enable interfaces */
if (lxcContainerRenameAndEnableInterfaces(!!(vmDef->features &
(1 << VIR_DOMAIN_FEATURE_PRIVNET)),
if (lxcContainerRenameAndEnableInterfaces(vmDef->features[VIR_DOMAIN_FEATURE_PRIVNET] ==
VIR_DOMAIN_FEATURE_STATE_ON,
argv->nveths,
argv->veths) < 0) {
goto cleanup;
......@@ -1978,7 +1978,7 @@ lxcNeedNetworkNamespace(virDomainDefPtr def)
size_t i;
if (def->nets != NULL)
return true;
if (def->features & (1 << VIR_DOMAIN_FEATURE_PRIVNET))
if (def->features[VIR_DOMAIN_FEATURE_PRIVNET] == VIR_DOMAIN_FEATURE_STATE_ON)
return true;
for (i = 0; i < def->nhostdevs; i++) {
if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES &&
......
......@@ -6718,7 +6718,7 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
have_cpu = true;
}
if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) {
if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_DOMAIN_FEATURE_STATE_ON) {
if (!have_cpu) {
virBufferAdd(&buf, default_model, -1);
have_cpu = true;
......@@ -8067,7 +8067,7 @@ qemuBuildCommandLine(virConnectPtr conn,
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI)) {
if (!(def->features & (1 << VIR_DOMAIN_FEATURE_ACPI)))
if (def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_DOMAIN_FEATURE_STATE_ON)
virCommandAddArg(cmd, "-no-acpi");
}
......@@ -10866,7 +10866,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
if (*feature == '\0')
goto syntax;
dom->features |= (1 << VIR_DOMAIN_FEATURE_HYPERV);
dom->features[VIR_DOMAIN_FEATURE_HYPERV] = VIR_DOMAIN_FEATURE_STATE_ON;
if ((f = virDomainHypervTypeFromString(feature)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
......@@ -11120,7 +11120,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
goto error;
if (strstr(path, "kvm")) {
def->virtType = VIR_DOMAIN_VIRT_KVM;
def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON;
}
}
......@@ -11133,8 +11133,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
if ((def->os.arch == VIR_ARCH_I686) ||
(def->os.arch == VIR_ARCH_X86_64))
def->features |= (1 << VIR_DOMAIN_FEATURE_ACPI)
/*| (1 << VIR_DOMAIN_FEATURE_APIC)*/;
def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON;
#define WANT_VALUE() \
const char *val = progargv[++i]; \
......@@ -11428,7 +11427,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
def->disks[def->ndisks++] = disk;
disk = NULL;
} else if (STREQ(arg, "-no-acpi")) {
def->features &= ~(1 << VIR_DOMAIN_FEATURE_ACPI);
def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_DEFAULT;
} else if (STREQ(arg, "-no-reboot")) {
def->onReboot = VIR_DOMAIN_LIFECYCLE_DESTROY;
} else if (STREQ(arg, "-no-kvm")) {
......@@ -11547,7 +11546,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
def->mem.nosharepages = true;
} else if (STRPREFIX(param, "accel=kvm")) {
def->virtType = VIR_DOMAIN_VIRT_KVM;
def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON;
}
}
virStringFreeList(list);
......
......@@ -2337,7 +2337,6 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
}
}
def->features = 0;
#if VBOX_API_VERSION < 3001
machine->vtbl->GetPAEEnabled(machine, &PAEEnabled);
#elif VBOX_API_VERSION == 3001
......@@ -2345,21 +2344,18 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
#elif VBOX_API_VERSION >= 3002
machine->vtbl->GetCPUProperty(machine, CPUPropertyType_PAE, &PAEEnabled);
#endif
if (PAEEnabled) {
def->features = def->features | (1 << VIR_DOMAIN_FEATURE_PAE);
}
if (PAEEnabled)
def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON;
machine->vtbl->GetBIOSSettings(machine, &bios);
if (bios) {
bios->vtbl->GetACPIEnabled(bios, &ACPIEnabled);
if (ACPIEnabled) {
def->features = def->features | (1 << VIR_DOMAIN_FEATURE_ACPI);
}
if (ACPIEnabled)
def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON;
bios->vtbl->GetIOAPICEnabled(bios, &IOAPICEnabled);
if (IOAPICEnabled) {
def->features = def->features | (1 << VIR_DOMAIN_FEATURE_APIC);
}
if (IOAPICEnabled)
def->features[VIR_DOMAIN_FEATURE_APIC] = VIR_DOMAIN_FEATURE_STATE_ON;
VBOX_RELEASE(bios);
}
......@@ -5076,40 +5072,43 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
}
#if VBOX_API_VERSION < 3001
rc = machine->vtbl->SetPAEEnabled(machine, (def->features) &
(1 << VIR_DOMAIN_FEATURE_PAE));
rc = machine->vtbl->SetPAEEnabled(machine,
def->features[VIR_DOMAIN_FEATURE_PAE] ==
VIR_DOMAIN_FEATURE_STATE_ON);
#elif VBOX_API_VERSION == 3001
rc = machine->vtbl->SetCpuProperty(machine, CpuPropertyType_PAE,
(def->features) &
(1 << VIR_DOMAIN_FEATURE_PAE));
def->features[VIR_DOMAIN_FEATURE_PAE] ==
VIR_DOMAIN_FEATURE_STATE_ON);
#elif VBOX_API_VERSION >= 3002
rc = machine->vtbl->SetCPUProperty(machine, CPUPropertyType_PAE,
(def->features) &
(1 << VIR_DOMAIN_FEATURE_PAE));
def->features[VIR_DOMAIN_FEATURE_PAE] ==
VIR_DOMAIN_FEATURE_STATE_ON);
#endif
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not change PAE status to: %s, rc=%08x"),
((def->features) & (1 << VIR_DOMAIN_FEATURE_PAE))
(def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_DOMAIN_FEATURE_STATE_ON)
? _("Enabled") : _("Disabled"), (unsigned)rc);
}
machine->vtbl->GetBIOSSettings(machine, &bios);
if (bios) {
rc = bios->vtbl->SetACPIEnabled(bios, (def->features) &
(1 << VIR_DOMAIN_FEATURE_ACPI));
rc = bios->vtbl->SetACPIEnabled(bios,
def->features[VIR_DOMAIN_FEATURE_ACPI] ==
VIR_DOMAIN_FEATURE_STATE_ON);
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not change ACPI status to: %s, rc=%08x"),
((def->features) & (1 << VIR_DOMAIN_FEATURE_ACPI))
(def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_DOMAIN_FEATURE_STATE_ON)
? _("Enabled") : _("Disabled"), (unsigned)rc);
}
rc = bios->vtbl->SetIOAPICEnabled(bios, (def->features) &
(1 << VIR_DOMAIN_FEATURE_APIC));
rc = bios->vtbl->SetIOAPICEnabled(bios,
def->features[VIR_DOMAIN_FEATURE_APIC] ==
VIR_DOMAIN_FEATURE_STATE_ON);
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not change APIC status to: %s, rc=%08x"),
((def->features) & (1 << VIR_DOMAIN_FEATURE_APIC))
(def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_DOMAIN_FEATURE_STATE_ON)
? _("Enabled") : _("Disabled"), (unsigned)rc);
}
VBOX_RELEASE(bios);
......
......@@ -1489,15 +1489,15 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
for (i = 0; i < result->size; i++) {
if (STREQ(result->contents[i].val, "true")) {
if (STREQ(result->contents[i].key, "acpi"))
defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_ACPI);
defPtr->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON;
else if (STREQ(result->contents[i].key, "apic"))
defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_APIC);
defPtr->features[VIR_DOMAIN_FEATURE_APIC] = VIR_DOMAIN_FEATURE_STATE_ON;
else if (STREQ(result->contents[i].key, "pae"))
defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_PAE);
defPtr->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON;
else if (STREQ(result->contents[i].key, "hap"))
defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_HAP);
defPtr->features[VIR_DOMAIN_FEATURE_HAP] = VIR_DOMAIN_FEATURE_STATE_ON;
else if (STREQ(result->contents[i].key, "viridian"))
defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_VIRIDIAN);
defPtr->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = VIR_DOMAIN_FEATURE_STATE_ON;
}
}
xen_string_string_map_free(result);
......
......@@ -511,18 +511,16 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
if (def->onCrash)
(*record)->actions_after_crash = actionCrashLibvirt2XenapiEnum(def->onCrash);
if (def->features) {
if (def->features & (1 << VIR_DOMAIN_FEATURE_ACPI))
allocStringMap(&strings, (char *)"acpi", (char *)"true");
if (def->features & (1 << VIR_DOMAIN_FEATURE_APIC))
allocStringMap(&strings, (char *)"apic", (char *)"true");
if (def->features & (1 << VIR_DOMAIN_FEATURE_PAE))
allocStringMap(&strings, (char *)"pae", (char *)"true");
if (def->features & (1 << VIR_DOMAIN_FEATURE_HAP))
allocStringMap(&strings, (char *)"hap", (char *)"true");
if (def->features & (1 << VIR_DOMAIN_FEATURE_VIRIDIAN))
allocStringMap(&strings, (char *)"viridian", (char *)"true");
}
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_DOMAIN_FEATURE_STATE_ON)
allocStringMap(&strings, (char *)"acpi", (char *)"true");
if (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_DOMAIN_FEATURE_STATE_ON)
allocStringMap(&strings, (char *)"apic", (char *)"true");
if (def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_DOMAIN_FEATURE_STATE_ON)
allocStringMap(&strings, (char *)"pae", (char *)"true");
if (def->features[VIR_DOMAIN_FEATURE_HAP] == VIR_DOMAIN_FEATURE_STATE_ON)
allocStringMap(&strings, (char *)"hap", (char *)"true");
if (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == VIR_DOMAIN_FEATURE_STATE_ON)
allocStringMap(&strings, (char *)"viridian", (char *)"true");
if (strings != NULL)
(*record)->platform = strings;
......
......@@ -1202,15 +1202,15 @@ xenParseSxpr(const struct sexpr *root,
if (hvm) {
if (sexpr_int(root, "domain/image/hvm/acpi"))
def->features |= (1 << VIR_DOMAIN_FEATURE_ACPI);
def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON;
if (sexpr_int(root, "domain/image/hvm/apic"))
def->features |= (1 << VIR_DOMAIN_FEATURE_APIC);
def->features[VIR_DOMAIN_FEATURE_APIC] = VIR_DOMAIN_FEATURE_STATE_ON;
if (sexpr_int(root, "domain/image/hvm/pae"))
def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON;
if (sexpr_int(root, "domain/image/hvm/hap"))
def->features |= (1 << VIR_DOMAIN_FEATURE_HAP);
def->features[VIR_DOMAIN_FEATURE_HAP] = VIR_DOMAIN_FEATURE_STATE_ON;
if (sexpr_int(root, "domain/image/hvm/viridian"))
def->features |= (1 << VIR_DOMAIN_FEATURE_VIRIDIAN);
def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = VIR_DOMAIN_FEATURE_STATE_ON;
}
/* 12aaf4a2486b (3.0.3) added a second low-priority 'localtime' setting */
......@@ -2333,15 +2333,15 @@ xenFormatSxpr(virConnectPtr conn,
}
}
if (def->features & (1 << VIR_DOMAIN_FEATURE_ACPI))
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAddLit(&buf, "(acpi 1)");
if (def->features & (1 << VIR_DOMAIN_FEATURE_APIC))
if (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAddLit(&buf, "(apic 1)");
if (def->features & (1 << VIR_DOMAIN_FEATURE_PAE))
if (def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAddLit(&buf, "(pae 1)");
if (def->features & (1 << VIR_DOMAIN_FEATURE_HAP))
if (def->features[VIR_DOMAIN_FEATURE_HAP] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAddLit(&buf, "(hap 1)");
if (def->features & (1 << VIR_DOMAIN_FEATURE_VIRIDIAN))
if (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAddLit(&buf, "(viridian 1)");
virBufferAddLit(&buf, "(usb 1)");
......
......@@ -398,23 +398,23 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0)
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_PAE);
def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON;
if (xenXMConfigGetBool(conf, "acpi", &val, 0) < 0)
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_ACPI);
def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON;
if (xenXMConfigGetBool(conf, "apic", &val, 0) < 0)
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_APIC);
def->features[VIR_DOMAIN_FEATURE_APIC] = VIR_DOMAIN_FEATURE_STATE_ON;
if (xenXMConfigGetBool(conf, "hap", &val, 0) < 0)
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_HAP);
def->features[VIR_DOMAIN_FEATURE_HAP] = VIR_DOMAIN_FEATURE_STATE_ON;
if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0)
goto cleanup;
else if (val)
def->features |= (1 << VIR_DOMAIN_FEATURE_VIRIDIAN);
def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = VIR_DOMAIN_FEATURE_STATE_ON;
if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0)
goto cleanup;
......@@ -1571,29 +1571,29 @@ virConfPtr xenFormatXM(virConnectPtr conn,
goto cleanup;
if (xenXMConfigSetInt(conf, "pae",
(def->features &
(1 << VIR_DOMAIN_FEATURE_PAE)) ? 1 : 0) < 0)
(def->features[VIR_DOMAIN_FEATURE_PAE] ==
VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0)
goto cleanup;
if (xenXMConfigSetInt(conf, "acpi",
(def->features &
(1 << VIR_DOMAIN_FEATURE_ACPI)) ? 1 : 0) < 0)
(def->features[VIR_DOMAIN_FEATURE_ACPI] ==
VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0)
goto cleanup;
if (xenXMConfigSetInt(conf, "apic",
(def->features &
(1 << VIR_DOMAIN_FEATURE_APIC)) ? 1 : 0) < 0)
(def->features[VIR_DOMAIN_FEATURE_APIC] ==
VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0)
goto cleanup;
if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) {
if (xenXMConfigSetInt(conf, "hap",
(def->features &
(1 << VIR_DOMAIN_FEATURE_HAP)) ? 1 : 0) < 0)
(def->features[VIR_DOMAIN_FEATURE_HAP] ==
VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0)
goto cleanup;
if (xenXMConfigSetInt(conf, "viridian",
(def->features &
(1 << VIR_DOMAIN_FEATURE_VIRIDIAN)) ? 1 : 0) < 0)
(def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] ==
VIR_DOMAIN_FEATURE_STATE_ON) ? 1 : 0) < 0)
goto cleanup;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册