From 0c8b80da2f3ea85f65d5b6a7b841433d5162a3bd Mon Sep 17 00:00:00 2001
From: "Pradipta Kr. Banerjee" <bpradip(a)in.ibm.com>
Date: Tue, 28 Oct 2014 14:41:59 +0530
Subject: [PATCH 1/5] 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(a)in.ibm.com>
Signed-off-by: Prerna Saxena <prerna(a)linux.vnet.ibm.com>
Acked-by: Michal Privoznik <mprivozn(a)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 1b8efb1..21309b0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10043,7 +10043,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 ec6614a..2505d32 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:
*
@@ -3575,7 +3575,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 917639e..96071d8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -714,7 +714,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)) {
@@ -1265,7 +1265,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,
@@ -1274,7 +1274,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,
@@ -4196,7 +4196,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;
@@ -8579,7 +8579,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
"
@@ -9777,7 +9777,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",
@@ -9900,7 +9900,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",
@@ -10322,7 +10322,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
@@ -10415,7 +10415,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);
@@ -11660,7 +11660,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)
@@ -11676,7 +11676,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 0caf1c0..8e91a48 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