[libvirt] [v5][Patch 0/4] Libvirt CPU enhancements for Power KVM

This patch series is a collection of enhancements for PowerPC CPUs on PowerKVM. In this iteration, I have followed Dan's suggestion on using existing cpu mode format to describe powerPC compatibility mode. Hope this can finally make it for 1.2.10 ! Series Summary: ========== Patch 1/4 : Introduce a new architecture 'ppc64le' for libvirt. Patch 2/4 : Add libvirt support for VMs running in 'compat' mode on Power KVM. Patch 3/4 : Improve PVR handling to fall back to cpu generation. Patch 4/4 : Add documentation describing compat mode usage for PowerPC guests. Detail: ==== * PowerPC has traditionally been a Big-endian architecture. However, with PowerPC ISA version 2.07, it can run in Little-endian mode as well. IBM Power8 processors, compliant with ISA 2.07 allow launching VMs in little-endian mode. This is signified by 'ppc64le' architecture. Patch 1 adds this support to libvirt, to allow running VMs based on ppc64le architecture. * Patch 2,3 tweak libvirt to correctly model PowerPC CPUs based on recent PowerKVM implementation. PowerKVM permits VMs with vcpus in the following allowed modes : i) Host native mode: where the vcpu seen in the VM belongs to the same processor generation as the host. Example: A POWER7 host, conforming to PowerISA version 2.06, will run VMs with "power7" vcpus. ii) Binary Compatibility ("compat") mode: PowerISA allows processors to run VMs in binary compatibility ("compat") mode supporting an older version of ISA. As an example: In compatibility mode, a POWER7 host can run a "power6" VM, conforming to power ISA v2.05. Similarly, a POWER8 host can run a "power7" VM conforming to PowerISA v2.06. QEMU has recently added support to explicitly denote a VM running in compatibility mode through commits 6d9412ea & 8dfa3a5e85. Henceforth, VMs of type (i) will be invoked with the QEMU invocation "-cpu host", while VMs of type (ii) will be invoked using "-cpu host, compat=power6". Now, an explicit cpu selection using "-cpu POWER6" is not valid. Instead, the recommended practice is to use the matching compat mode, if the requested cpu type differs from the host. Patches 2-3 address various aspects of this change. * Patch 2 : Adds support for generating the correct command line for QEMU. Existing xml semantics of 'host-model' are interpreted differently on PowerPc architecture to signify this type. * Patch 3 : PowerKVM vCPUs differ uniquely across generations ( such as power6, power7, power8). Each generation signifies a new PowerISA version that exhibits features unique to that generation. The higher order 16 bits of PVR denote the processor generation and the lower order 16 bits denote the cpu chip (sub)version. For all practical purposes of launching a VM, we care about the generation the vCPU will belong to, and not specifically the chip version. In fact, PowerKVM does not seek out specification of a unique chip version(such as POWER7_v2.3) for running a vCPU. This patch updates the libvirt PVR check to reflect this relationship. * Patch 4 : Documentation is added to explain functionality introduced by Patch 2. Changelog: ========= v1 : https://www.redhat.com/archives/libvir-list/2014-June/msg01338.html v2 : http://www.redhat.com/archives/libvir-list/2014-October/msg00351.html v3 : http://www.mail-archive.com/libvir-list@redhat.com/msg104010.html v4: http://www.mail-archive.com/libvir-list@redhat.com/msg104067.html Changes since v4: ================ * Patches 1,3 already ack'ed by Michal, and have been posted unchanged. * In Patch 2,Discarded fallback=compat, and implemented Dan's suggestion to overload cpu mode "host-model". Now, on PowerPc, a VM with this XML schema will automatically be a compat-mode VM: <cpu mode='host-model'> <model>power7</model> </cpu> * Introduced a new patch '4' to add documentation that explains this. Regards, -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India

From fca5b950ec688122adde121bacd5937b5c4e2e06 Mon Sep 17 00:00:00 2001 From: "Pradipta Kr. Banerjee" <bpradip@in.ibm.com> Date: Tue, 28 Oct 2014 14:41:59 +0530 Subject: [PATCH 1/4] Cpu: Add support for Power LE Architecture.
This adds support for PowerPC Little Endian architecture., and allows libvirt to spawn VMs based on 'ppc64le' architecture. Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com> Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/domain_conf.c | 2 +- src/cpu/cpu_powerpc.c | 2 +- src/qemu/qemu_capabilities.c | 6 +++--- src/qemu/qemu_command.c | 22 +++++++++++----------- src/qemu/qemu_domain.c | 1 + src/util/virarch.h | 3 +++ 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a351382..ed4c823 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10039,7 +10039,7 @@ virDomainVideoDefaultType(const virDomainDef *def) (STREQ(def->os.type, "xen") || STREQ(def->os.type, "linux"))) return VIR_DOMAIN_VIDEO_TYPE_XEN; - else if (def->os.arch == VIR_ARCH_PPC64) + else if ARCH_IS_PPC64(def->os.arch) return VIR_DOMAIN_VIDEO_TYPE_VGA; else return VIR_DOMAIN_VIDEO_TYPE_CIRRUS; diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c index 67cb9ff..d591c18 100644 --- a/src/cpu/cpu_powerpc.c +++ b/src/cpu/cpu_powerpc.c @@ -38,7 +38,7 @@ VIR_LOG_INIT("cpu.cpu_powerpc"); -static const virArch archs[] = { VIR_ARCH_PPC64 }; +static const virArch archs[] = { VIR_ARCH_PPC64, VIR_ARCH_PPC64LE }; struct ppc_vendor { char *name; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b6c0f1b..be73cf8 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -633,7 +633,7 @@ virQEMUCapsProbeCPUModels(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid) if (qemuCaps->arch == VIR_ARCH_I686 || qemuCaps->arch == VIR_ARCH_X86_64) { parse = virQEMUCapsParseX86Models; - } else if (qemuCaps->arch == VIR_ARCH_PPC64) { + } else if ARCH_IS_PPC64(qemuCaps->arch) { parse = virQEMUCapsParsePPCModels; } else { VIR_DEBUG("don't know how to parse %s CPU models", @@ -2003,7 +2003,7 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps, return true; if (def->os.arch == VIR_ARCH_PPC || - def->os.arch == VIR_ARCH_PPC64) { + ARCH_IS_PPC64(def->os.arch)) { /* * Usage of pci.0 naming: * @@ -3573,7 +3573,7 @@ virQEMUCapsSupportsChardev(virDomainDefPtr def, !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) return false; - if ((def->os.arch == VIR_ARCH_PPC) || (def->os.arch == VIR_ARCH_PPC64)) { + if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) { /* only pseries need -device spapr-vty with -chardev */ return (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2e5af4f..d60f274 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -713,7 +713,7 @@ qemuSetSCSIControllerModel(virDomainDefPtr def, return -1; } } else { - if ((def->os.arch == VIR_ARCH_PPC64) && + if (ARCH_IS_PPC64(def->os.arch) && STRPREFIX(def->os.machine, "pseries")) { *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) { @@ -1264,7 +1264,7 @@ int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def, for (i = 0; i < def->nserials; i++) { if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && - (def->os.arch == VIR_ARCH_PPC64) && + ARCH_IS_PPC64(def->os.arch) && STRPREFIX(def->os.machine, "pseries")) def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; if (qemuAssignSpaprVIOAddress(def, &def->serials[i]->info, @@ -1273,7 +1273,7 @@ int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def, } if (def->nvram) { - if (def->os.arch == VIR_ARCH_PPC64 && + if (ARCH_IS_PPC64(def->os.arch) && STRPREFIX(def->os.machine, "pseries")) def->nvram->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; if (qemuAssignSpaprVIOAddress(def, &def->nvram->info, @@ -4195,7 +4195,7 @@ qemuBuildUSBControllerDevStr(virDomainDefPtr domainDef, model = def->model; if (model == -1) { - if (domainDef->os.arch == VIR_ARCH_PPC64) + if ARCH_IS_PPC64(domainDef->os.arch) model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI; else model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI; @@ -8573,7 +8573,7 @@ qemuBuildCommandLine(virConnectPtr conn, !qemuDomainMachineIsQ35(def) && (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI) || (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI) && - def->os.arch == VIR_ARCH_PPC64))) { + ARCH_IS_PPC64(def->os.arch)))) { if (usblegacy) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Multiple legacy USB controllers are " @@ -9771,7 +9771,7 @@ qemuBuildCommandLine(virConnectPtr conn, } if (def->nvram) { - if (def->os.arch == VIR_ARCH_PPC64 && + if (ARCH_IS_PPC64(def->os.arch) && STRPREFIX(def->os.machine, "pseries")) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVRAM)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -9894,7 +9894,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, { virBuffer cmd = VIR_BUFFER_INITIALIZER; - if ((arch == VIR_ARCH_PPC64) && STRPREFIX(machine, "pseries")) { + if (ARCH_IS_PPC64(arch) && STRPREFIX(machine, "pseries")) { if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) { virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s", @@ -10316,7 +10316,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, if (VIR_ALLOC(def->src) < 0) goto error; - if (((dom->os.arch == VIR_ARCH_PPC64) && + if ((ARCH_IS_PPC64(dom->os.arch) && dom->os.machine && STRPREFIX(dom->os.machine, "pseries"))) def->bus = VIR_DOMAIN_DISK_BUS_SCSI; else @@ -10409,7 +10409,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, } else if (STREQ(keywords[i], "if")) { if (STREQ(values[i], "ide")) { def->bus = VIR_DOMAIN_DISK_BUS_IDE; - if (((dom->os.arch == VIR_ARCH_PPC64) && + if ((ARCH_IS_PPC64(dom->os.arch) && dom->os.machine && STRPREFIX(dom->os.machine, "pseries"))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pseries systems do not support ide devices '%s'"), val); @@ -11654,7 +11654,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, } if (STREQ(arg, "-cdrom")) { disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; - if (((def->os.arch == VIR_ARCH_PPC64) && + if ((ARCH_IS_PPC64(def->os.arch) && def->os.machine && STRPREFIX(def->os.machine, "pseries"))) disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; if (VIR_STRDUP(disk->dst, "hdc") < 0) @@ -11670,7 +11670,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, disk->bus = VIR_DOMAIN_DISK_BUS_IDE; else disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; - if (((def->os.arch == VIR_ARCH_PPC64) && + if ((ARCH_IS_PPC64(def->os.arch) && def->os.machine && STRPREFIX(def->os.machine, "pseries"))) disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 76fccce..e4edf34 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -980,6 +980,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, break; case VIR_ARCH_PPC64: + case VIR_ARCH_PPC64LE: addPCIRoot = true; addDefaultUSBKBD = true; addDefaultUSBMouse = true; diff --git a/src/util/virarch.h b/src/util/virarch.h index d395e58..3206ce2 100644 --- a/src/util/virarch.h +++ b/src/util/virarch.h @@ -79,6 +79,9 @@ typedef enum { (arch) == VIR_ARCH_PPC64LE ||\ (arch) == VIR_ARCH_PPCEMB) +# define ARCH_IS_PPC64(arch) ((arch) == VIR_ARCH_PPC64 ||\ + (arch) == VIR_ARCH_PPC64LE) + # define ARCH_IS_ARM(arch) ((arch) == VIR_ARCH_ARMV6L ||\ (arch) == VIR_ARCH_ARMV7L ||\ (arch) == VIR_ARCH_ARMV7B ||\ -- 1.9.3 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India

From: Prerna Saxena <prerna@linux.vnet.ibm.com> Date: Tue, 28 Oct 2014 15:05:59 +0530 PowerISA allows processors to run VMs in binary compatibility ("compat") mode supporting an older version of ISA. QEMU has recently added support to explicitly denote a VM running in compatibility mode through commit 6d9412ea & 8dfa3a5e85. Now, a "compat" mode VM can be run by invoking this qemu commandline on a POWER8 host: -cpu host,compat=power7. This patch allows libvirt to exploit cpu mode 'host-model' to describe this new mode for PowerKVM guests. As an example: When a user wants to request a power7 vm to run in compatibility mode on a Power8 host, this can be described in XML as follows : <cpu mode='host-model'> <model>power7</model> </cpu> Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com> --- src/conf/cpu_conf.c | 1 + src/cpu/cpu_powerpc.c | 11 ++--------- src/qemu/qemu_command.c | 10 +++++++++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 9b7fbb0..0e7a979 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -619,6 +619,7 @@ virCPUDefFormatBuf(virBufferPtr buf, return 0; formatModel = (def->mode == VIR_CPU_MODE_CUSTOM || + def->mode == VIR_CPU_MODE_HOST_MODEL || (flags & VIR_DOMAIN_XML_UPDATE_CPU)); formatFallback = (def->type == VIR_CPU_TYPE_GUEST && (def->mode == VIR_CPU_MODE_HOST_MODEL || diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c index d591c18..4ea1835 100644 --- a/src/cpu/cpu_powerpc.c +++ b/src/cpu/cpu_powerpc.c @@ -562,8 +562,8 @@ ppcUpdate(virCPUDefPtr guest, static virCPUDefPtr ppcBaseline(virCPUDefPtr *cpus, unsigned int ncpus, - const char **models, - unsigned int nmodels, + const char **models ATTRIBUTE_UNUSED, + unsigned int nmodels ATTRIBUTE_UNUSED, unsigned int flags) { struct ppc_map *map = NULL; @@ -583,13 +583,6 @@ ppcBaseline(virCPUDefPtr *cpus, goto error; } - if (!cpuModelIsAllowed(model->name, models, nmodels)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("CPU model %s is not supported by hypervisor"), - model->name); - goto error; - } - for (i = 0; i < ncpus; i++) { const struct ppc_vendor *vnd; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d60f274..34f6535 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6221,7 +6221,9 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, *hasHwVirt = hasSVM > 0 ? true : false; } - if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) { + if ((cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) || + ((cpu->mode == VIR_CPU_MODE_HOST_MODEL) && + ARCH_IS_PPC64(def->os.arch))) { const char *mode = virCPUModeTypeToString(cpu->mode); if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_HOST)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -6236,6 +6238,12 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, goto cleanup; } virBufferAddLit(buf, "host"); + + if (ARCH_IS_PPC64(def->os.arch) && + cpu->mode == VIR_CPU_MODE_HOST_MODEL) { + virBufferAsprintf(buf, ",compat=%s", def->cpu->model); + } + } else { if (VIR_ALLOC(guest) < 0) goto cleanup; -- 1.9.3 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India

On 31.10.2014 10:51, Prerna Saxena wrote:
From: Prerna Saxena <prerna@linux.vnet.ibm.com> Date: Tue, 28 Oct 2014 15:05:59 +0530
PowerISA allows processors to run VMs in binary compatibility ("compat") mode supporting an older version of ISA. QEMU has recently added support to explicitly denote a VM running in compatibility mode through commit 6d9412ea & 8dfa3a5e85. Now, a "compat" mode VM can be run by invoking this qemu commandline on a POWER8 host: -cpu host,compat=power7.
This patch allows libvirt to exploit cpu mode 'host-model' to describe this new mode for PowerKVM guests. As an example: When a user wants to request a power7 vm to run in compatibility mode on a Power8 host, this can be described in XML as follows : <cpu mode='host-model'> <model>power7</model> </cpu>
So I guess we've agreement on this.
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com> --- src/conf/cpu_conf.c | 1 + src/cpu/cpu_powerpc.c | 11 ++--------- src/qemu/qemu_command.c | 10 +++++++++- 3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 9b7fbb0..0e7a979 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -619,6 +619,7 @@ virCPUDefFormatBuf(virBufferPtr buf, return 0;
formatModel = (def->mode == VIR_CPU_MODE_CUSTOM || + def->mode == VIR_CPU_MODE_HOST_MODEL || (flags & VIR_DOMAIN_XML_UPDATE_CPU)); formatFallback = (def->type == VIR_CPU_TYPE_GUEST && (def->mode == VIR_CPU_MODE_HOST_MODEL || diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c index d591c18..4ea1835 100644 --- a/src/cpu/cpu_powerpc.c +++ b/src/cpu/cpu_powerpc.c @@ -562,8 +562,8 @@ ppcUpdate(virCPUDefPtr guest, static virCPUDefPtr ppcBaseline(virCPUDefPtr *cpus, unsigned int ncpus, - const char **models, - unsigned int nmodels, + const char **models ATTRIBUTE_UNUSED, + unsigned int nmodels ATTRIBUTE_UNUSED, unsigned int flags) { struct ppc_map *map = NULL; @@ -583,13 +583,6 @@ ppcBaseline(virCPUDefPtr *cpus, goto error; }
- if (!cpuModelIsAllowed(model->name, models, nmodels)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("CPU model %s is not supported by hypervisor"), - model->name); - goto error; - } - for (i = 0; i < ncpus; i++) { const struct ppc_vendor *vnd;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d60f274..34f6535 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6221,7 +6221,9 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, *hasHwVirt = hasSVM > 0 ? true : false; }
- if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) { + if ((cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) || + ((cpu->mode == VIR_CPU_MODE_HOST_MODEL) && + ARCH_IS_PPC64(def->os.arch))) { const char *mode = virCPUModeTypeToString(cpu->mode); if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_HOST)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -6236,6 +6238,12 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, goto cleanup; } virBufferAddLit(buf, "host"); + + if (ARCH_IS_PPC64(def->os.arch) && + cpu->mode == VIR_CPU_MODE_HOST_MODEL) { + virBufferAsprintf(buf, ",compat=%s", def->cpu->model); + } + } else { if (VIR_ALLOC(guest) < 0) goto cleanup;
ACK then. Michal

From 40c57322949a064607d27de8a293047fb5c7ff8e Mon Sep 17 00:00:00 2001 From: Prerna Saxena <prerna@linux.vnet.ibm.com> Date: Tue, 28 Oct 2014 15:30:05 +0530
IBM Power processors differ uniquely across generations (such as power6, power7, power8). Each generation signifies a new PowerISA version that exhibits features unique to that generation. The higher 16 bits of PVR for IBM Power processors encode the CPU generation, while the CPU chip (sub)version is encoded in lower 16 bits. For all practical purposes of launching a VM, we care about the generation which the vCPU will belong to, and not specifically the chip version. This patch updates the libvirt PVR check to reflect this relationship. It allows libvirt to select the right CPU generation in case the exact match for a a specific CPU is not found. Hence, there will no longer be a need to add each PowerPC CPU model to cpu_map.xml; just adding entry for the matching ISA generation will suffice. It also contains changes to cpu_map.xml since processor generations as understood by QEMU compat mode go as "power6", "power7" or "power8" [Reference : QEMU commit 8dfa3a5e85 ] Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com> Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> --- src/cpu/cpu_map.xml | 24 ++++++++++++++++++++++++ src/cpu/cpu_powerpc.c | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml index 18c7b0d..f9d8d38 100644 --- a/src/cpu/cpu_map.xml +++ b/src/cpu/cpu_map.xml @@ -627,5 +627,29 @@ <pvr value='0x004b0100'/> </model> + <model name='power6'> + <vendor name='IBM'/> + <compat isa='2.05'/> + <pvr value='0x003e0000'/> + </model> + + <model name='power7'> + <vendor name='IBM'/> + <compat isa='2.06'/> + <pvr value='0x003f0000'/> + </model> + + <model name='power7+'> + <vendor name='IBM'/> + <compat isa='2.06B'/> + <pvr value='0x004a0000'/> + </model> + + <model name='power8'> + <vendor name='IBM'/> + <compat isa='2.07'/> + <pvr value='0x004b0000'/> + </model> + </arch> </cpus> diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c index 4ea1835..531868c 100644 --- a/src/cpu/cpu_powerpc.c +++ b/src/cpu/cpu_powerpc.c @@ -99,6 +99,14 @@ ppcModelFindPVR(const struct ppc_map *map, model = model->next; } + /* PowerPC Processor Version Register is interpreted as follows : + * Higher order 16 bits : Power ISA generation. + * Lower order 16 bits : CPU chip version number. + * If the exact CPU isnt found, return the nearest matching CPU generation + */ + if (pvr & 0x0000FFFFul) + return ppcModelFindPVR(map, (pvr & 0xFFFF0000ul)); + return NULL; } -- 1.9.3 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India

From dd917ef27269bc3a9af2294212b088f838792315 Mon Sep 17 00:00:00 2001 From: Prerna Saxena <prerna@linux.vnet.ibm.com> Date: Fri, 31 Oct 2014 15:13:16 +0530 Subject: [PATCH 4/4] docs: Add documentation for compat mode.
Add documentation to explain how compat-mode can be invoked with libvirt running on PowerPC architecture. Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> --- docs/formatdomain.html.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0099ce7..ded9b90 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1047,7 +1047,20 @@ (such as CPUID level) that don't work. Until these issues are fixed, it's a good idea to avoid using <code>host-model</code> and use <code>custom</code> mode with just the CPU model from host - capabilities XML.</dd> + capabilities XML. + <span class="since">(Since 1.2.10)</span>.PowerISA allows + processors to run VMs in binary compatibility mode supporting an + older version of ISA. Libvirt on PowerPC architecture uses the + <code>host-model</code> to signify a guest mode CPU running in + binary compatibility mode. Example: + When a user needs a power7 VM to run in compatibility mode + on a Power8 host, this can be described in XML as follows : +<pre> + <cpu mode='host-model'> + <model>power7</model> + </cpu> + ...</pre> + </dd> <dt><code>host-passthrough</code></dt> <dd>With this mode, the CPU visible to the guest should be exactly the same as the host CPU even in the aspects that libvirt does not -- 1.9.3 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India

On 31.10.2014 10:54, Prerna Saxena wrote:
From dd917ef27269bc3a9af2294212b088f838792315 Mon Sep 17 00:00:00 2001 From: Prerna Saxena <prerna@linux.vnet.ibm.com> Date: Fri, 31 Oct 2014 15:13:16 +0530 Subject: [PATCH 4/4] docs: Add documentation for compat mode.
Add documentation to explain how compat-mode can be invoked with libvirt running on PowerPC architecture.
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> --- docs/formatdomain.html.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0099ce7..ded9b90 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1047,7 +1047,20 @@ (such as CPUID level) that don't work. Until these issues are fixed, it's a good idea to avoid using <code>host-model</code> and use <code>custom</code> mode with just the CPU model from host - capabilities XML.</dd> + capabilities XML. + <span class="since">(Since 1.2.10)</span>.PowerISA allows
s/\./. /
+ processors to run VMs in binary compatibility mode supporting an + older version of ISA. Libvirt on PowerPC architecture uses the + <code>host-model</code> to signify a guest mode CPU running in + binary compatibility mode. Example: + When a user needs a power7 VM to run in compatibility mode + on a Power8 host, this can be described in XML as follows : +<pre> + <cpu mode='host-model'> + <model>power7</model> + </cpu> + ...</pre> + </dd> <dt><code>host-passthrough</code></dt> <dd>With this mode, the CPU visible to the guest should be exactly the same as the host CPU even in the aspects that libvirt does not
Michal

Ping ! I understand it is a busy time for libvirt folks -- would someone still be able to take a look ? I have addressed all concerns raised by Dan in this version. Prerna -------- Original Message -------- Subject: [libvirt] [v5][Patch 0/4] Libvirt CPU enhancements for Power KVM Date: Fri, 31 Oct 2014 14:45:52 +0530 From: Prerna Saxena <prerna@linux.vnet.ibm.com> To: libvirt mailing list <libvir-list@redhat.com> CC: Michal Privoznik <mprivozn@redhat.com>, jtomko@redhat.com This patch series is a collection of enhancements for PowerPC CPUs on PowerKVM. In this iteration, I have followed Dan's suggestion on using existing cpu mode format to describe powerPC compatibility mode. Hope this can finally make it for 1.2.10 ! Series Summary: ========== Patch 1/4 : Introduce a new architecture 'ppc64le' for libvirt. Patch 2/4 : Add libvirt support for VMs running in 'compat' mode on Power KVM. Patch 3/4 : Improve PVR handling to fall back to cpu generation. Patch 4/4 : Add documentation describing compat mode usage for PowerPC guests. Detail: ==== * PowerPC has traditionally been a Big-endian architecture. However, with PowerPC ISA version 2.07, it can run in Little-endian mode as well. IBM Power8 processors, compliant with ISA 2.07 allow launching VMs in little-endian mode. This is signified by 'ppc64le' architecture. Patch 1 adds this support to libvirt, to allow running VMs based on ppc64le architecture. * Patch 2,3 tweak libvirt to correctly model PowerPC CPUs based on recent PowerKVM implementation. PowerKVM permits VMs with vcpus in the following allowed modes : i) Host native mode: where the vcpu seen in the VM belongs to the same processor generation as the host. Example: A POWER7 host, conforming to PowerISA version 2.06, will run VMs with "power7" vcpus. ii) Binary Compatibility ("compat") mode: PowerISA allows processors to run VMs in binary compatibility ("compat") mode supporting an older version of ISA. As an example: In compatibility mode, a POWER7 host can run a "power6" VM, conforming to power ISA v2.05. Similarly, a POWER8 host can run a "power7" VM conforming to PowerISA v2.06. QEMU has recently added support to explicitly denote a VM running in compatibility mode through commits 6d9412ea & 8dfa3a5e85. Henceforth, VMs of type (i) will be invoked with the QEMU invocation "-cpu host", while VMs of type (ii) will be invoked using "-cpu host, compat=power6". Now, an explicit cpu selection using "-cpu POWER6" is not valid. Instead, the recommended practice is to use the matching compat mode, if the requested cpu type differs from the host. Patches 2-3 address various aspects of this change. * Patch 2 : Adds support for generating the correct command line for QEMU. Existing xml semantics of 'host-model' are interpreted differently on PowerPc architecture to signify this type. * Patch 3 : PowerKVM vCPUs differ uniquely across generations ( such as power6, power7, power8). Each generation signifies a new PowerISA version that exhibits features unique to that generation. The higher order 16 bits of PVR denote the processor generation and the lower order 16 bits denote the cpu chip (sub)version. For all practical purposes of launching a VM, we care about the generation the vCPU will belong to, and not specifically the chip version. In fact, PowerKVM does not seek out specification of a unique chip version(such as POWER7_v2.3) for running a vCPU. This patch updates the libvirt PVR check to reflect this relationship. * Patch 4 : Documentation is added to explain functionality introduced by Patch 2. Changelog: ========= v1 : https://www.redhat.com/archives/libvir-list/2014-June/msg01338.html v2 : http://www.redhat.com/archives/libvir-list/2014-October/msg00351.html v3 : http://www.mail-archive.com/libvir-list@redhat.com/msg104010.html v4: http://www.mail-archive.com/libvir-list@redhat.com/msg104067.html Changes since v4: ================ * Patches 1,3 already ack'ed by Michal, and have been posted unchanged. * In Patch 2,Discarded fallback=compat, and implemented Dan's suggestion to overload cpu mode "host-model". Now, on PowerPc, a VM with this XML schema will automatically be a compat-mode VM: <cpu mode='host-model'> <model>power7</model> </cpu> * Introduced a new patch '4' to add documentation that explains this. Regards, -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 31.10.2014 10:15, Prerna Saxena wrote:
This patch series is a collection of enhancements for PowerPC CPUs on PowerKVM. In this iteration, I have followed Dan's suggestion on using existing cpu mode format to describe powerPC compatibility mode. Hope this can finally make it for 1.2.10 !
Series Summary: ========== Patch 1/4 : Introduce a new architecture 'ppc64le' for libvirt. Patch 2/4 : Add libvirt support for VMs running in 'compat' mode on Power KVM. Patch 3/4 : Improve PVR handling to fall back to cpu generation. Patch 4/4 : Add documentation describing compat mode usage for PowerPC guests.
What am I missing here is a test case. Can you please add a qemuxml2argv test case? Just send it as a follow up patch and I'll merge the code then. Michal

On Monday 03 November 2014 02:57 PM, Michal Privoznik wrote:
On 31.10.2014 10:15, Prerna Saxena wrote:
This patch series is a collection of enhancements for PowerPC CPUs on PowerKVM. In this iteration, I have followed Dan's suggestion on using existing cpu mode format to describe powerPC compatibility mode. Hope this can finally make it for 1.2.10 !
Series Summary: ========== Patch 1/4 : Introduce a new architecture 'ppc64le' for libvirt. Patch 2/4 : Add libvirt support for VMs running in 'compat' mode on Power KVM. Patch 3/4 : Improve PVR handling to fall back to cpu generation. Patch 4/4 : Add documentation describing compat mode usage for PowerPC guests.
What am I missing here is a test case. Can you please add a qemuxml2argv test case? Just send it as a follow up patch and I'll merge the code then.
Michal
Hi Michal, I have sent out a v6 of the patches rebased on top of latest master. Apart from introducing a testcase, these have minor changes over v5. Thanks for the review, -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India
participants (2)
-
Michal Privoznik
-
Prerna Saxena