From: Kiarie Kahurani <davidkiarie4@xxxxxxxxx> Introduce xenParseXMCPUFeatures(.....); This function parses config related to CPU and power management signed-off-by:David Kiarie<davidkiarie4@xxxxxxxxx> --- src/xenxs/xen_xm.c | 116 ++++++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 54 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 7a5b47c..ebeeeb5 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -625,6 +625,66 @@ xenParseXMPCI(virConfPtr conf, virDomainDefPtr def) return 0; } +static int xenParseXMCPUFeatures(virConfPtr conf, virDomainDefPtr def) +{ + unsigned long count; + const char *str; + int val; + if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || + MAX_VIRT_CPUS < count) + return -1; + def->maxvcpus = count; + if (xenXMConfigGetULong(conf, "vcpu_avail", &count, -1) < 0) + return -1; + def->vcpus = MIN(count_one_bits_l(count), def->maxvcpus); + + if (xenXMConfigGetString(conf, "cpus", &str, NULL) < 0) + return -1; + if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0)) + return -1; + + if (STREQ(def->os.type, "hvm")) { + if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0) + return -1; + else if (val) + def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "acpi", &val, 0) < 0) + return -1; + else if (val) + def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "apic", &val, 0) < 0) + return -1; + else if (val) + def->features[VIR_DOMAIN_FEATURE_APIC] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "hap", &val, 0) < 0) + return -1; + else if (val) + def->features[VIR_DOMAIN_FEATURE_HAP] = VIR_DOMAIN_FEATURE_STATE_ON; + if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0) + return -1; + else if (val) + def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = VIR_DOMAIN_FEATURE_STATE_ON; + + if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0) + return -1; + else if (val != -1) { + virDomainTimerDefPtr timer; + + if (VIR_ALLOC_N(def->clock.timers, 1) < 0 || + VIR_ALLOC(timer) < 0) + return -1; + + timer->name = VIR_DOMAIN_TIMER_NAME_HPET; + timer->present = val; + timer->tickpolicy = -1; + + def->clock.ntimers = 1; + def->clock.timers[0] = timer; + } + } + + return 0; +} virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion, virCapsPtr caps) @@ -638,7 +698,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, virDomainNetDefPtr net = NULL; virDomainGraphicsDefPtr graphics = NULL; size_t i; - unsigned long count; char *script = NULL; char *listenAddr = NULL; @@ -703,59 +762,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, } if (xenParseXMMem(conf, def) < 0) goto cleanup; - - if (xenXMConfigGetULong(conf, "vcpus", &count, 1) < 0 || - MAX_VIRT_CPUS < count) - goto cleanup; - def->maxvcpus = count; - if (xenXMConfigGetULong(conf, "vcpu_avail", &count, -1) < 0) - goto cleanup; - def->vcpus = MIN(count_one_bits_l(count), def->maxvcpus); - - if (xenXMConfigGetString(conf, "cpus", &str, NULL) < 0) - goto cleanup; - if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0)) - goto cleanup; - - if (hvm) { - if (xenXMConfigGetBool(conf, "pae", &val, 0) < 0) - goto cleanup; - else if (val) - 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[VIR_DOMAIN_FEATURE_ACPI] = VIR_DOMAIN_FEATURE_STATE_ON; - if (xenXMConfigGetBool(conf, "apic", &val, 0) < 0) - goto cleanup; - else if (val) - 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[VIR_DOMAIN_FEATURE_HAP] = VIR_DOMAIN_FEATURE_STATE_ON; - if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0) - goto cleanup; - else if (val) - def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = VIR_DOMAIN_FEATURE_STATE_ON; - - if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0) - goto cleanup; - else if (val != -1) { - virDomainTimerDefPtr timer; - - if (VIR_ALLOC_N(def->clock.timers, 1) < 0 || - VIR_ALLOC(timer) < 0) - goto cleanup; - - timer->name = VIR_DOMAIN_TIMER_NAME_HPET; - timer->present = val; - timer->tickpolicy = -1; - - def->clock.ntimers = 1; - def->clock.timers[0] = timer; - } - } if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0) goto cleanup; @@ -945,6 +951,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; if (xenParseXMPCI(conf, def) < 0) goto cleanup; + if (xenParseXMCPUFeatures(conf, def) < 0) + goto cleanup; if (hvm) { if (xenXMConfigGetString(conf, "usbdevice", &str, NULL) < 0) goto cleanup; -- 1.8.4.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list