|
|
c1c534 |
From 0d9354fe1bef822c515713a3ceb5b619f7eac00c Mon Sep 17 00:00:00 2001
|
|
|
c1c534 |
Message-Id: <0d9354fe1bef822c515713a3ceb5b619f7eac00c@dist-git>
|
|
|
c1c534 |
From: Andrea Bolognani <abologna@redhat.com>
|
|
|
c1c534 |
Date: Wed, 29 Nov 2017 16:23:11 +0100
|
|
|
c1c534 |
Subject: [PATCH] qemu: Remove redundancy in qemuBuildSerialChrDeviceStr()
|
|
|
c1c534 |
|
|
|
c1c534 |
Instead duplicating the capability check for each possible target
|
|
|
c1c534 |
model, introduce a small helper that matches the target model with
|
|
|
c1c534 |
the corresponding capability and collapse all existing checks into
|
|
|
c1c534 |
a single one.
|
|
|
c1c534 |
|
|
|
c1c534 |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
c1c534 |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c1c534 |
(cherry picked from commit fa96d3524296e7119acf5ad7b02653f4c062d030)
|
|
|
c1c534 |
|
|
|
c1c534 |
https://bugzilla.redhat.com/show_bug.cgi?id=1449265
|
|
|
c1c534 |
https://bugzilla.redhat.com/show_bug.cgi?id=1511421
|
|
|
c1c534 |
https://bugzilla.redhat.com/show_bug.cgi?id=1512929
|
|
|
c1c534 |
https://bugzilla.redhat.com/show_bug.cgi?id=1512934
|
|
|
c1c534 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c1c534 |
---
|
|
|
c1c534 |
src/qemu/qemu_command.c | 40 +++++++++++++++++++++++++++++-----------
|
|
|
c1c534 |
1 file changed, 29 insertions(+), 11 deletions(-)
|
|
|
c1c534 |
|
|
|
c1c534 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
c1c534 |
index 7fd2afb1e0..f8d5d317cd 100644
|
|
|
c1c534 |
--- a/src/qemu/qemu_command.c
|
|
|
c1c534 |
+++ b/src/qemu/qemu_command.c
|
|
|
c1c534 |
@@ -9218,6 +9218,25 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
|
|
|
c1c534 |
return 0;
|
|
|
c1c534 |
}
|
|
|
c1c534 |
|
|
|
c1c534 |
+
|
|
|
c1c534 |
+static virQEMUCapsFlags
|
|
|
c1c534 |
+qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
|
|
|
c1c534 |
+{
|
|
|
c1c534 |
+ switch (targetModel) {
|
|
|
c1c534 |
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
|
|
|
c1c534 |
+ return QEMU_CAPS_DEVICE_USB_SERIAL;
|
|
|
c1c534 |
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
|
|
|
c1c534 |
+ return QEMU_CAPS_DEVICE_PCI_SERIAL;
|
|
|
c1c534 |
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
|
|
|
c1c534 |
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
|
|
|
c1c534 |
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
|
|
|
c1c534 |
+ break;
|
|
|
c1c534 |
+ }
|
|
|
c1c534 |
+
|
|
|
c1c534 |
+ return 0;
|
|
|
c1c534 |
+}
|
|
|
c1c534 |
+
|
|
|
c1c534 |
+
|
|
|
c1c534 |
static int
|
|
|
c1c534 |
qemuBuildChrDeviceCommandLine(virCommandPtr cmd,
|
|
|
c1c534 |
const virDomainDef *def,
|
|
|
c1c534 |
@@ -10322,6 +10341,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
|
|
|
c1c534 |
return NULL;
|
|
|
c1c534 |
}
|
|
|
c1c534 |
|
|
|
c1c534 |
+
|
|
|
c1c534 |
/* This function generates the correct '-device' string for character
|
|
|
c1c534 |
* devices of each architecture.
|
|
|
c1c534 |
*/
|
|
|
c1c534 |
@@ -10332,6 +10352,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
|
|
|
c1c534 |
virQEMUCapsPtr qemuCaps)
|
|
|
c1c534 |
{
|
|
|
c1c534 |
virBuffer cmd = VIR_BUFFER_INITIALIZER;
|
|
|
c1c534 |
+ virQEMUCapsFlags caps;
|
|
|
c1c534 |
|
|
|
c1c534 |
if (qemuDomainIsPSeries(def)) {
|
|
|
c1c534 |
if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
|
|
c1c534 |
@@ -10348,9 +10369,14 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
|
|
|
c1c534 |
} else {
|
|
|
c1c534 |
switch ((virDomainChrSerialTargetModel) serial->targetModel) {
|
|
|
c1c534 |
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
|
|
|
c1c534 |
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_SERIAL)) {
|
|
|
c1c534 |
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
c1c534 |
- _("usb-serial is not supported in this QEMU binary"));
|
|
|
c1c534 |
+ case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
|
|
|
c1c534 |
+
|
|
|
c1c534 |
+ caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
|
|
|
c1c534 |
+
|
|
|
c1c534 |
+ if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
|
|
|
c1c534 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
c1c534 |
+ _("'%s' is not supported in this QEMU binary"),
|
|
|
c1c534 |
+ virDomainChrSerialTargetModelTypeToString(serial->targetModel));
|
|
|
c1c534 |
goto error;
|
|
|
c1c534 |
}
|
|
|
c1c534 |
break;
|
|
|
c1c534 |
@@ -10358,14 +10384,6 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
|
|
|
c1c534 |
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
|
|
|
c1c534 |
break;
|
|
|
c1c534 |
|
|
|
c1c534 |
- case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
|
|
|
c1c534 |
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_SERIAL)) {
|
|
|
c1c534 |
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
c1c534 |
- _("pci-serial is not supported with this QEMU binary"));
|
|
|
c1c534 |
- goto error;
|
|
|
c1c534 |
- }
|
|
|
c1c534 |
- break;
|
|
|
c1c534 |
-
|
|
|
c1c534 |
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
|
|
|
c1c534 |
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
|
|
|
c1c534 |
/* Except from _LAST, which is just a guard value and will never
|
|
|
c1c534 |
--
|
|
|
c1c534 |
2.15.1
|
|
|
c1c534 |
|