From c4bd6d96f42727568abeeb3253f1764da6c7dc71 Mon Sep 17 00:00:00 2001 From: Daniel Gollub Date: Wed, 15 Jun 2011 15:27:43 +0200 Subject: [PATCH] support for Xen HVM Viridian (Hyper-V) enlightenment interface Introduce libvirt support for Xen HVM Viridian (Hyper-V) enlightenment interface guest feature. src/conf/domain_conf.c | 3 ++- src/conf/domain_conf.h | 1 + src/xen/xen_hypervisor.c | 11 +++++++++++ src/xenapi/xenapi_driver.c | 2 ++ src/xenapi/xenapi_utils.c | 2 ++ src/xenxs/xen_sxpr.c | 4 ++++ src/xenxs/xen_xm.c | 12 +++++++++++- 7 files changed, 33 insertions(+), 2 deletions(-) --- AUTHORS | 1 + src/conf/domain_conf.c | 3 ++- src/conf/domain_conf.h | 1 + src/xen/xen_hypervisor.c | 11 +++++++++++ src/xenapi/xenapi_driver.c | 2 ++ src/xenapi/xenapi_utils.c | 2 ++ src/xenxs/xen_sxpr.c | 4 ++++ src/xenxs/xen_xm.c | 12 +++++++++++- 8 files changed, 34 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index dbc00c775f..64ba1a1ed6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -176,6 +176,7 @@ Patches have also been contributed by: Neil Wilson Ohad Levy Michael Chapman + Daniel Gollub [....send patches to get your name here....] diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7393690dfb..02707dde2c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -84,7 +84,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, "acpi", "apic", "pae", - "hap") + "hap", + "viridian") VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST, "destroy", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3ef48d14f4..1f4bf1de4a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -899,6 +899,7 @@ enum virDomainFeature { VIR_DOMAIN_FEATURE_APIC, VIR_DOMAIN_FEATURE_PAE, VIR_DOMAIN_FEATURE_HAP, + VIR_DOMAIN_FEATURE_VIRIDIAN, VIR_DOMAIN_FEATURE_LAST }; diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 21e664572a..6a46a39df6 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2401,7 +2401,18 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, 0, 1) == NULL) goto no_memory; + + /* Xen 3.4.x and beyond supports the Viridian (Hyper-V) + * enlightenment interface. Default is off. + */ + if ((hv_major == 3 && hv_minor >= 4) || (hv_major > 3)) + if (virCapabilitiesAddGuestFeature(guest, + "viridian", + 0, + 1) == NULL) + goto no_memory; } + } caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 3fc35c6499..77d17ee960 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -1430,6 +1430,8 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, int flags ATTRIBUTE_UNUSED) defPtr->features = defPtr->features | (1<contents[i].key, "hap")) defPtr->features = defPtr->features | (1<contents[i].key, "viridian")) + defPtr->features = defPtr->features | (1<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 (strings != NULL) (*record)->platform = strings; diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index 59d585d822..b5877bbd2c 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -1171,6 +1171,8 @@ xenParseSxpr(const struct sexpr *root, def->features |= (1 << VIR_DOMAIN_FEATURE_PAE); if (sexpr_int(root, "domain/image/hvm/hap")) def->features |= (1 << VIR_DOMAIN_FEATURE_HAP); + if (sexpr_int(root, "domain/image/hvm/viridian")) + def->features |= (1 << VIR_DOMAIN_FEATURE_VIRIDIAN); /* Old XenD only allows localtime here for HVM */ if (sexpr_int(root, "domain/image/hvm/localtime")) @@ -2166,6 +2168,8 @@ xenFormatSxpr(virConnectPtr conn, virBufferAddLit(&buf, "(pae 1)"); if (def->features & (1 << VIR_DOMAIN_FEATURE_HAP)) virBufferAddLit(&buf, "(hap 1)"); + if (def->features & (1 << VIR_DOMAIN_FEATURE_VIRIDIAN)) + virBufferAddLit(&buf, "(viridian 1)"); virBufferAddLit(&buf, "(usb 1)"); diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index accf5f4c44..0ad2179546 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -369,6 +369,10 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, goto cleanup; else if (val) def->features |= (1 << VIR_DOMAIN_FEATURE_HAP); + if (xenXMConfigGetBool(conf, "viridian", &val, 0) < 0) + goto cleanup; + else if (val) + def->features |= (1 << VIR_DOMAIN_FEATURE_VIRIDIAN); if (xenXMConfigGetBool(conf, "hpet", &val, -1) < 0) goto cleanup; @@ -1507,12 +1511,18 @@ virConfPtr xenFormatXM(virConnectPtr conn, (1 << VIR_DOMAIN_FEATURE_APIC)) ? 1 : 0) < 0) goto no_memory; - if (xendConfigVersion >= 3) + if (xendConfigVersion >= 3) { if (xenXMConfigSetInt(conf, "hap", (def->features & (1 << VIR_DOMAIN_FEATURE_HAP)) ? 1 : 0) < 0) goto no_memory; + if (xenXMConfigSetInt(conf, "viridian", + (def->features & + (1 << VIR_DOMAIN_FEATURE_VIRIDIAN)) ? 1 : 0) < 0) + goto no_memory; + } + if (def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME) { if (def->clock.data.timezone) { XENXS_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,