This new function checks for both the architecture and the
machine type, so we can use it instead of writing the same
checks over and over again.
---
src/qemu/qemu_command.c | 13 +++++--------
src/qemu/qemu_domain.c | 19 ++++++++++++++++---
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_domain_address.c | 9 +++------
src/qemu/qemu_parse_command.c | 12 ++++--------
5 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 10bcb1c..e2201ff 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1946,9 +1946,8 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo;
/* PowerPC pseries based VMs do not support floppy device */
- if ((disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) &&
- ARCH_IS_PPC64(def->os.arch) &&
- STRPREFIX(def->os.machine, "pseries")) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
+ qemuDomainMachineIsPSeries(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("PowerPC pseries machines do not support floppy
device"));
return -1;
@@ -3701,8 +3700,7 @@ qemuBuildNVRAMCommandLine(virCommandPtr cmd,
if (!def->nvram)
return 0;
- if (ARCH_IS_PPC64(def->os.arch) &&
- STRPREFIX(def->os.machine, "pseries")) {
+ if (qemuDomainMachineIsPSeries(def)) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVRAM)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nvram device is not supported by "
@@ -8968,8 +8966,7 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
/* For pSeries guests, the firmware provides the same
* functionality as the pvpanic device. The address
* cannot be configured by the user */
- if (!ARCH_IS_PPC64(def->os.arch) ||
- !STRPREFIX(def->os.machine, "pseries")) {
+ if (!qemuDomainMachineIsPSeries(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("only pSeries guests support panic device "
"of model 'pseries'"));
@@ -9390,7 +9387,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
{
virBuffer cmd = VIR_BUFFER_INITIALIZER;
- if (ARCH_IS_PPC64(def->os.arch) && STRPREFIX(def->os.machine,
"pseries")) {
+ if (qemuDomainMachineIsPSeries(def)) {
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",
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 3e906b3..6f70ca7 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1878,7 +1878,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
/* For pSeries guests, the firmware provides the same
* functionality as the pvpanic device, so automatically
* add the definition if not already present */
- if (STRPREFIX(def->os.machine, "pseries"))
+ if (qemuDomainMachineIsPSeries(def))
addPanicDevice = true;
break;
@@ -2366,8 +2366,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
if (dev->type == VIR_DOMAIN_DEVICE_PANIC &&
dev->data.panic->model == VIR_DOMAIN_PANIC_MODEL_DEFAULT) {
- if (ARCH_IS_PPC64(def->os.arch) &&
- STRPREFIX(def->os.machine, "pseries"))
+ if (qemuDomainMachineIsPSeries(def))
dev->data.panic->model = VIR_DOMAIN_PANIC_MODEL_PSERIES;
else if (ARCH_IS_S390(def->os.arch))
dev->data.panic->model = VIR_DOMAIN_PANIC_MODEL_S390;
@@ -4930,6 +4929,20 @@ qemuDomainMachineIsVirt(const virDomainDef *def)
}
+bool
+qemuDomainMachineIsPSeries(const virDomainDef *def)
+{
+ if (!ARCH_IS_PPC64(def->os.arch))
+ return false;
+
+ if (STRNEQ(def->os.machine, "pseries") &&
+ !STRPREFIX(def->os.machine, "pseries-"))
+ return false;
+
+ return true;
+}
+
+
static bool
qemuCheckMemoryDimmConflict(const virDomainDef *def,
const virDomainMemoryDef *mem)
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 2443e97..9b50b81 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -616,6 +616,7 @@ bool qemuDomainMachineIsI440FX(const virDomainDef *def);
bool qemuDomainMachineNeedsFDC(const virDomainDef *def);
bool qemuDomainMachineIsS390CCW(const virDomainDef *def);
bool qemuDomainMachineIsVirt(const virDomainDef *def);
+bool qemuDomainMachineIsPSeries(const virDomainDef *def);
bool qemuDomainMachineHasBuiltinIDE(const virDomainDef *def);
int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index d9d71e7..ee44d45 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -88,8 +88,7 @@ qemuDomainSetSCSIControllerModel(const virDomainDef *def,
return -1;
}
} else {
- if (ARCH_IS_PPC64(def->os.arch) &&
- STRPREFIX(def->os.machine, "pseries")) {
+ if (qemuDomainMachineIsPSeries(def)) {
*model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) {
*model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
@@ -253,8 +252,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
for (i = 0; i < def->nserials; i++) {
if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL
&&
- ARCH_IS_PPC64(def->os.arch) &&
- STRPREFIX(def->os.machine, "pseries"))
+ qemuDomainMachineIsPSeries(def))
def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info,
VIO_ADDR_SERIAL) < 0)
@@ -262,8 +260,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
}
if (def->nvram) {
- if (ARCH_IS_PPC64(def->os.arch) &&
- STRPREFIX(def->os.machine, "pseries"))
+ if (qemuDomainMachineIsPSeries(def))
def->nvram->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
if (qemuDomainAssignSpaprVIOAddress(def, &def->nvram->info,
VIO_ADDR_NVRAM) < 0)
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 1d54a68..9ee262b 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -654,8 +654,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
if (VIR_ALLOC(def->src) < 0)
goto error;
- if ((ARCH_IS_PPC64(dom->os.arch) &&
- dom->os.machine && STRPREFIX(dom->os.machine,
"pseries")))
+ if (qemuDomainMachineIsPSeries(dom))
def->bus = VIR_DOMAIN_DISK_BUS_SCSI;
else
def->bus = VIR_DOMAIN_DISK_BUS_IDE;
@@ -747,8 +746,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
} else if (STREQ(keywords[i], "if")) {
if (STREQ(values[i], "ide")) {
def->bus = VIR_DOMAIN_DISK_BUS_IDE;
- if ((ARCH_IS_PPC64(dom->os.arch) &&
- dom->os.machine && STRPREFIX(dom->os.machine,
"pseries"))) {
+ if (qemuDomainMachineIsPSeries(dom)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("pseries systems do not support ide devices
'%s'"), val);
goto error;
@@ -1939,8 +1937,7 @@ qemuParseCommandLine(virCapsPtr caps,
}
if (STREQ(arg, "-cdrom")) {
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
- if ((ARCH_IS_PPC64(def->os.arch) &&
- def->os.machine && STRPREFIX(def->os.machine,
"pseries")))
+ if (qemuDomainMachineIsPSeries(def))
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
if (VIR_STRDUP(disk->dst, "hdc") < 0)
goto error;
@@ -1955,8 +1952,7 @@ qemuParseCommandLine(virCapsPtr caps,
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
else
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
- if ((ARCH_IS_PPC64(def->os.arch) &&
- def->os.machine && STRPREFIX(def->os.machine,
"pseries")))
+ if (qemuDomainMachineIsPSeries(def))
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
}
if (VIR_STRDUP(disk->dst, arg + 1) < 0)
--
2.7.4