Implement support for "virsh cpu-compare" so that we can calculate common cpu element between a pool of hosts, which had a requirement of providing host cpu description. Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx> --- src/libxl/libxl_driver.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index f153f69..977e9b5 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5770,6 +5770,43 @@ libxlConnectGetDomainCapabilities(virConnectPtr conn, } +static int +libxlConnectCompareCPU(virConnectPtr conn, + const char *xmlDesc, + unsigned int flags) +{ + libxlDriverPrivatePtr driver = conn->privateData; + libxlDriverConfigPtr cfg; + int ret = VIR_CPU_COMPARE_ERROR; + bool failIncompatible; + + virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE, + VIR_CPU_COMPARE_ERROR); + + if (virConnectCompareCPUEnsureACL(conn) < 0) + return ret; + + failIncompatible = !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE); + + cfg = libxlDriverConfigGet(driver); + + if (!cfg->caps->host.cpu || + !cfg->caps->host.cpu->model) { + if (failIncompatible) { + virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", + _("cannot get host CPU capabilities")); + } else { + VIR_WARN("cannot get host CPU capabilities"); + ret = VIR_CPU_COMPARE_INCOMPATIBLE; + } + } else { + ret = cpuCompareXML(cfg->caps->host.cpu, xmlDesc, failIncompatible); + } + + virObjectUnref(cfg); + return ret; +} + static virHypervisorDriver libxlHypervisorDriver = { .name = LIBXL_DRIVER_NAME, .connectOpen = libxlConnectOpen, /* 0.9.0 */ @@ -5872,6 +5909,7 @@ static virHypervisorDriver libxlHypervisorDriver = { .nodeGetSecurityModel = libxlNodeGetSecurityModel, /* 1.2.16 */ .domainInterfaceAddresses = libxlDomainInterfaceAddresses, /* 1.3.5 */ .connectGetDomainCapabilities = libxlConnectGetDomainCapabilities, /* 2.0.0 */ + .connectCompareCPU = libxlConnectCompareCPU, /* 2.1.0 */ }; static virConnectDriver libxlConnectDriver = { -- 2.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list