404507
From fd981b46a6729b5d5dac4923b860f888b0c193b9 Mon Sep 17 00:00:00 2001
404507
Message-Id: <fd981b46a6729b5d5dac4923b860f888b0c193b9@dist-git>
404507
From: Andrea Bolognani <abologna@redhat.com>
404507
Date: Wed, 29 Nov 2017 16:23:12 +0100
404507
Subject: [PATCH] conf: Add target type and model for spapr-vty
404507
404507
We can finally introduce a specific target model for the spapr-vty
404507
device used by pSeries guests, which means isa-serial will no longer
404507
show up to confuse users.
404507
404507
We make sure migration works in both directions by interpreting the
404507
isa-serial target type, or the lack of target type, appropriately
404507
when parsing the guest XML, and skipping the newly-introduced type
404507
when formatting if for migration. We also verify that spapr-vty is
404507
not used for non-pSeries guests and add a bunch of test cases.
404507
404507
This commit is best viewed with 'git show -w'.
404507
404507
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511421
404507
404507
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
404507
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
404507
(cherry picked from commit c498a8921e447715189c8c6d22b7ca24cc810830)
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 docs/formatdomain.html.in                          | 13 ++--
404507
 docs/schemas/domaincommon.rng                      |  2 +
404507
 src/conf/domain_conf.c                             |  6 +-
404507
 src/conf/domain_conf.h                             |  2 +
404507
 src/qemu/qemu_command.c                            | 67 +++++++++------------
404507
 src/qemu/qemu_domain.c                             | 69 ++++++++++++++++++----
404507
 src/qemu/qemu_domain_address.c                     |  1 +
404507
 .../qemuxml2argv-pseries-basic.args                |  2 +-
404507
 .../qemuxml2argv-pseries-console-native.args       |  1 +
404507
 .../qemuxml2argv-pseries-console-native.xml        | 17 ++++++
404507
 .../qemuxml2argv-pseries-console-virtio.args       | 23 ++++++++
404507
 .../qemuxml2argv-pseries-console-virtio.xml        | 19 ++++++
404507
 .../qemuxml2argv-pseries-cpu-compat-power9.args    |  2 +-
404507
 .../qemuxml2argv-pseries-cpu-compat.args           |  2 +-
404507
 .../qemuxml2argv-pseries-cpu-exact.args            |  2 +-
404507
 .../qemuxml2argv-pseries-cpu-le.args               |  2 +-
404507
 .../qemuxml2argv-pseries-panic-missing.args        |  2 +-
404507
 .../qemuxml2argv-pseries-panic-no-address.args     |  2 +-
404507
 ...qemuxml2argv-pseries-serial+console-native.args |  1 +
404507
 .../qemuxml2argv-pseries-serial+console-native.xml | 18 ++++++
404507
 .../qemuxml2argv-pseries-serial-compat.args        |  1 +
404507
 .../qemuxml2argv-pseries-serial-compat.xml         | 19 ++++++
404507
 ...qemuxml2argv-pseries-serial-invalid-machine.xml | 19 ++++++
404507
 .../qemuxml2argv-pseries-serial-native.args        | 22 +++++++
404507
 .../qemuxml2argv-pseries-serial-native.xml         | 16 +++++
404507
 .../qemuxml2argv-pseries-usb-default.args          |  2 +-
404507
 .../qemuxml2argv-pseries-usb-kbd.args              |  2 +-
404507
 .../qemuxml2argv-pseries-usb-multi.args            |  2 +-
404507
 .../qemuxml2argv-pseries-vio-user-assigned.args    |  4 +-
404507
 .../qemuxml2argvdata/qemuxml2argv-pseries-vio.args |  4 +-
404507
 tests/qemuxml2argvtest.c                           | 16 +++++
404507
 .../qemuxml2xmlout-panic-pseries.xml               |  4 +-
404507
 .../qemuxml2xmlout-pseries-console-native.xml      |  1 +
404507
 .../qemuxml2xmlout-pseries-console-virtio.xml      | 31 ++++++++++
404507
 .../qemuxml2xmlout-pseries-cpu-compat-power9.xml   |  4 +-
404507
 .../qemuxml2xmlout-pseries-cpu-compat.xml          |  4 +-
404507
 .../qemuxml2xmlout-pseries-cpu-exact.xml           |  4 +-
404507
 .../qemuxml2xmlout-pseries-panic-missing.xml       |  4 +-
404507
 .../qemuxml2xmlout-pseries-panic-no-address.xml    |  4 +-
404507
 ...emuxml2xmlout-pseries-serial+console-native.xml |  1 +
404507
 .../qemuxml2xmlout-pseries-serial-compat.xml       |  1 +
404507
 .../qemuxml2xmlout-pseries-serial-native.xml       | 35 +++++++++++
404507
 tests/qemuxml2xmltest.c                            | 15 +++++
404507
 43 files changed, 386 insertions(+), 82 deletions(-)
404507
 create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml
404507
 create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml
404507
 create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml
404507
 create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml
404507
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml
404507
 create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml
404507
 create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml
404507
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml
404507
404507
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
404507
index cf1167b9c6..0634f3396a 100644
404507
--- a/docs/formatdomain.html.in
404507
+++ b/docs/formatdomain.html.in
404507
@@ -6462,7 +6462,9 @@ qemu-kvm -net nic,model=? /dev/null
404507
       since 1.0.2, isa-serial (usable
404507
       with x86 guests), usb-serial (usable whenever USB support
404507
       is available) and pci-serial (usable whenever PCI support
404507
-      is available).
404507
+      is available); since 3.10.0,
404507
+      spapr-vio-serial (usable with ppc64/pseries guests)
404507
+      is available as well.
404507
     

404507
 
404507
     

404507
@@ -6472,7 +6474,9 @@ qemu-kvm -net nic,model=? /dev/null
404507
       isa-serial (usable with the isa-serial target
404507
       type); usb-serial (usable with the usb-serial
404507
       target type); pci-serial
404507
-      (usable with the pci-serial target type).
404507
+      (usable with the pci-serial target type);
404507
+      spapr-vty (usable with the spapr-vio-serial
404507
+      target type).
404507
     

404507
 
404507
     

404507
@@ -6484,8 +6488,9 @@ qemu-kvm -net nic,model=? /dev/null
404507
       All of the target types support configuring the guest-visible device
404507
       address as documented above; more
404507
       specifically, acceptable address types are isa (for
404507
-      isa-serial), usb (for usb-serial)
404507
-      and pci (for pci-serial).
404507
+      isa-serial), usb (for usb-serial),
404507
+      pci (for pci-serial) and spapr-vio
404507
+      (for spapr-vio-serial).
404507
     

404507
 
404507
     

404507
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
404507
index 3630e539e6..027d9ae7a1 100644
404507
--- a/docs/schemas/domaincommon.rng
404507
+++ b/docs/schemas/domaincommon.rng
404507
@@ -3571,6 +3571,7 @@
404507
         <value>isa-serial</value>
404507
         <value>usb-serial</value>
404507
         <value>pci-serial</value>
404507
+        <value>spapr-vio-serial</value>
404507
       </choice>
404507
     </attribute>
404507
   </define>
404507
@@ -3582,6 +3583,7 @@
404507
           <value>isa-serial</value>
404507
           <value>usb-serial</value>
404507
           <value>pci-serial</value>
404507
+          <value>spapr-vty</value>
404507
         </choice>
404507
       </attribute>
404507
     </element>
404507
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
404507
index 692b9d9414..97c7a66b5b 100644
404507
--- a/src/conf/domain_conf.c
404507
+++ b/src/conf/domain_conf.c
404507
@@ -444,7 +444,9 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget,
404507
               "none",
404507
               "isa-serial",
404507
               "usb-serial",
404507
-              "pci-serial")
404507
+              "pci-serial",
404507
+              "spapr-vio-serial",
404507
+);
404507
 
404507
 VIR_ENUM_IMPL(virDomainChrChannelTarget,
404507
               VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
404507
@@ -471,6 +473,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetModel,
404507
               "isa-serial",
404507
               "usb-serial",
404507
               "pci-serial",
404507
+              "spapr-vty",
404507
 );
404507
 
404507
 VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST,
404507
@@ -4059,6 +4062,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
404507
 
404507
         switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) {
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
404507
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: {
404507
 
404507
             /* Create a stub console to match the serial port.
404507
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
404507
index 9dfe9388cd..979e8cca00 100644
404507
--- a/src/conf/domain_conf.h
404507
+++ b/src/conf/domain_conf.h
404507
@@ -1077,6 +1077,7 @@ typedef enum {
404507
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
404507
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
404507
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
404507
+    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
404507
 
404507
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
404507
 } virDomainChrSerialTargetType;
404507
@@ -1109,6 +1110,7 @@ typedef enum {
404507
     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL,
404507
     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL,
404507
     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL,
404507
+    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
404507
 
404507
     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
404507
 } virDomainChrSerialTargetModel;
404507
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
404507
index f8d5d317cd..91083dc73d 100644
404507
--- a/src/qemu/qemu_command.c
404507
+++ b/src/qemu/qemu_command.c
404507
@@ -9227,6 +9227,8 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
404507
         return QEMU_CAPS_DEVICE_USB_SERIAL;
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
404507
         return QEMU_CAPS_DEVICE_PCI_SERIAL;
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
404507
+        return QEMU_CAPS_DEVICE_SPAPR_VTY;
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
404507
@@ -10354,52 +10356,39 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
404507
     virBuffer cmd = VIR_BUFFER_INITIALIZER;
404507
     virQEMUCapsFlags caps;
404507
 
404507
-    if (qemuDomainIsPSeries(def)) {
404507
-        if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
404507
-            serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
404507
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_VTY)) {
404507
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
404507
-                               _("spapr-vty not supported in this QEMU binary"));
404507
-                goto error;
404507
-            }
404507
+    switch ((virDomainChrSerialTargetModel) serial->targetModel) {
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
404507
 
404507
-            virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s",
404507
-                              serial->info.alias);
404507
-        }
404507
-    } else {
404507
-        switch ((virDomainChrSerialTargetModel) serial->targetModel) {
404507
-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
404507
-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
404507
+        caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
404507
 
404507
-            caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
404507
-
404507
-            if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
404507
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
404507
-                               _("'%s' is not supported in this QEMU binary"),
404507
-                               virDomainChrSerialTargetModelTypeToString(serial->targetModel));
404507
-                goto error;
404507
-            }
404507
-            break;
404507
-
404507
-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
404507
-            break;
404507
-
404507
-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
404507
-        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
404507
-            /* Except from _LAST, which is just a guard value and will never
404507
-             * be used, all of the above are platform devices, which means
404507
-             * qemuBuildSerialCommandLine() will have taken the appropriate
404507
-             * branch and we will not have ended up here. */
404507
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
404507
-                           _("Invalid target model for serial device"));
404507
+        if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
404507
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
404507
+                           _("'%s' is not supported in this QEMU binary"),
404507
+                           virDomainChrSerialTargetModelTypeToString(serial->targetModel));
404507
             goto error;
404507
         }
404507
+        break;
404507
 
404507
-        virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
404507
-                          virDomainChrSerialTargetModelTypeToString(serial->targetModel),
404507
-                          serial->info.alias, serial->info.alias);
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
404507
+        break;
404507
+
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
404507
+        /* Except from _LAST, which is just a guard value and will never
404507
+         * be used, all of the above are platform devices, which means
404507
+         * qemuBuildSerialCommandLine() will have taken the appropriate
404507
+         * branch and we will not have ended up here. */
404507
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
404507
+                       _("Invalid target model for serial device"));
404507
+        goto error;
404507
     }
404507
 
404507
+    virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
404507
+                      virDomainChrSerialTargetModelTypeToString(serial->targetModel),
404507
+                      serial->info.alias, serial->info.alias);
404507
+
404507
     if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
404507
         goto error;
404507
 
404507
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
404507
index 7b5bc97de6..17c898896d 100644
404507
--- a/src/qemu/qemu_domain.c
404507
+++ b/src/qemu/qemu_domain.c
404507
@@ -3466,6 +3466,8 @@ qemuDomainChrSerialTargetTypeToAddressType(int targetType)
404507
         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB;
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
404507
         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
404507
+        return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
404507
         break;
404507
@@ -3485,6 +3487,8 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel)
404507
         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB;
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
404507
         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI;
404507
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
404507
+        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
404507
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
404507
         break;
404507
@@ -3495,8 +3499,7 @@ qemuDomainChrSerialTargetModelToTargetType(int targetModel)
404507
 
404507
 
404507
 static int
404507
-qemuDomainChrTargetDefValidate(const virDomainDef *def,
404507
-                               const virDomainChrDef *chr)
404507
+qemuDomainChrTargetDefValidate(const virDomainChrDef *chr)
404507
 {
404507
     int expected;
404507
 
404507
@@ -3508,11 +3511,7 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def,
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
404507
-
404507
-            /* Hack required until we have a proper type for pSeries
404507
-             * serial consoles */
404507
-            if (qemuDomainIsPSeries(def))
404507
-                return 0;
404507
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
404507
 
404507
             expected = qemuDomainChrSerialTargetTypeToAddressType(chr->targetType);
404507
 
404507
@@ -3536,6 +3535,7 @@ qemuDomainChrTargetDefValidate(const virDomainDef *def,
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
404507
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
404507
 
404507
             expected = qemuDomainChrSerialTargetModelToTargetType(chr->targetModel);
404507
 
404507
@@ -3573,7 +3573,7 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev,
404507
     if (qemuDomainChrSourceDefValidate(dev->source) < 0)
404507
         return -1;
404507
 
404507
-    if (qemuDomainChrTargetDefValidate(def, dev) < 0)
404507
+    if (qemuDomainChrTargetDefValidate(dev) < 0)
404507
         return -1;
404507
 
404507
     if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL &&
404507
@@ -3583,6 +3583,26 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev,
404507
             return -1;
404507
     }
404507
 
404507
+    if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
404507
+        bool isCompatible = true;
404507
+
404507
+        if (!qemuDomainIsPSeries(def) &&
404507
+            (dev->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO ||
404507
+             dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY)) {
404507
+            isCompatible = false;
404507
+        }
404507
+
404507
+        if (!isCompatible) {
404507
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
404507
+                           _("Serial device with target type '%s' and "
404507
+                             "target model '%s' not compatible with guest "
404507
+                             "architecture or machine type"),
404507
+                           virDomainChrSerialTargetTypeToString(dev->targetType),
404507
+                           virDomainChrSerialTargetModelTypeToString(dev->targetModel));
404507
+            return -1;
404507
+        }
404507
+    }
404507
+
404507
     return 0;
404507
 }
404507
 
404507
@@ -4222,10 +4242,7 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
404507
         if (ARCH_IS_X86(def->os.arch)) {
404507
             chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
404507
         } else if (qemuDomainIsPSeries(def)) {
404507
-            /* Setting TYPE_ISA here is just a temporary hack to reduce test
404507
-             * suite churn. Later on we will have a proper serial type for
404507
-             * pSeries and this line will be updated accordingly. */
404507
-            chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
404507
+            chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
404507
         }
404507
     }
404507
 
404507
@@ -4242,6 +4259,9 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
404507
             chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL;
404507
             break;
404507
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
404507
+            chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY;
404507
+            break;
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
404507
             /* Nothing to do */
404507
@@ -5147,6 +5167,31 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
404507
                 goto cleanup;
404507
         }
404507
 
404507
+        for (i = 0; i < def->nserials; i++) {
404507
+            virDomainChrDefPtr serial = def->serials[i];
404507
+
404507
+            /* Historically, the native console type for some machine types
404507
+             * was not set at all, which means it defaulted to ISA even
404507
+             * though that was not even remotely accurate. To ensure migration
404507
+             * towards older libvirt versions works for such guests, we switch
404507
+             * it back to the default here */
404507
+            if (flags & VIR_DOMAIN_XML_MIGRATABLE) {
404507
+                switch ((virDomainChrSerialTargetType) serial->targetType) {
404507
+                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
404507
+                    serial->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
404507
+                    serial->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE;
404507
+                    break;
404507
+                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
404507
+                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
404507
+                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
404507
+                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
404507
+                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
404507
+                    /* Nothing to do */
404507
+                    break;
404507
+                }
404507
+            }
404507
+        }
404507
+
404507
         /* Replace the CPU definition updated according to QEMU with the one
404507
          * used for starting the domain. The updated def will be sent
404507
          * separately for backward compatibility.
404507
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
404507
index 989c0e6c93..2319e503eb 100644
404507
--- a/src/qemu/qemu_domain_address.c
404507
+++ b/src/qemu/qemu_domain_address.c
404507
@@ -782,6 +782,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
404507
 
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
404507
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
404507
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
404507
             return 0;
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
404507
index 97a7057ba0..789d9f679e 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-basic.args
404507
@@ -20,4 +20,4 @@ server,nowait \
404507
 -boot c \
404507
 -usb \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args
404507
new file mode 120000
404507
index 0000000000..d6c830ecdf
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.args
404507
@@ -0,0 +1 @@
404507
+qemuxml2argv-pseries-serial-native.args
404507
\ No newline at end of file
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml
404507
new file mode 100644
404507
index 0000000000..9f37bf0dec
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-native.xml
404507
@@ -0,0 +1,17 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+  </os>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' model='none'/>
404507
+    
404507
+         <serial> element being created -->
404507
+    <console type='pty'/>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args
404507
new file mode 100644
404507
index 0000000000..343018fb3e
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.args
404507
@@ -0,0 +1,23 @@
404507
+LC_ALL=C \
404507
+PATH=/bin \
404507
+HOME=/home/test \
404507
+USER=test \
404507
+LOGNAME=test \
404507
+QEMU_AUDIO_DRV=none \
404507
+/usr/bin/qemu-system-ppc64 \
404507
+-name guest \
404507
+-S \
404507
+-M pseries \
404507
+-m 512 \
404507
+-smp 1,sockets=1,cores=1,threads=1 \
404507
+-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
404507
+-nographic \
404507
+-nodefconfig \
404507
+-nodefaults \
404507
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
404507
+server,nowait \
404507
+-mon chardev=charmonitor,id=monitor,mode=readline \
404507
+-boot c \
404507
+-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x1 \
404507
+-chardev pty,id=charconsole0 \
404507
+-device virtconsole,chardev=charconsole0,id=console0
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml
404507
new file mode 100644
404507
index 0000000000..0190ab63ac
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-console-virtio.xml
404507
@@ -0,0 +1,19 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+  </os>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' model='none'/>
404507
+    
404507
+         matching <serial> element being created -->
404507
+    <console type='pty'>
404507
+      <target type='virtio'/>
404507
+    </console>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
404507
index af93d63dc9..9bb375aeba 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args
404507
@@ -21,4 +21,4 @@ server,nowait \
404507
 -boot c \
404507
 -usb \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
404507
index 7740e2f5a9..5174aa760e 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat.args
404507
@@ -21,4 +21,4 @@ server,nowait \
404507
 -boot c \
404507
 -usb \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
404507
index d2c99a7fa3..3790deca8c 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-exact.args
404507
@@ -21,4 +21,4 @@ server,nowait \
404507
 -boot c \
404507
 -usb \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
404507
index 97a7057ba0..789d9f679e 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-le.args
404507
@@ -20,4 +20,4 @@ server,nowait \
404507
 -boot c \
404507
 -usb \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
404507
index 97a7057ba0..789d9f679e 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
404507
@@ -20,4 +20,4 @@ server,nowait \
404507
 -boot c \
404507
 -usb \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
404507
index 97a7057ba0..789d9f679e 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-no-address.args
404507
@@ -20,4 +20,4 @@ server,nowait \
404507
 -boot c \
404507
 -usb \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args
404507
new file mode 120000
404507
index 0000000000..d6c830ecdf
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.args
404507
@@ -0,0 +1 @@
404507
+qemuxml2argv-pseries-serial-native.args
404507
\ No newline at end of file
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml
404507
new file mode 100644
404507
index 0000000000..2733baa980
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial+console-native.xml
404507
@@ -0,0 +1,18 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+  </os>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' model='none'/>
404507
+    
404507
+         be matched and end up representing the same native serial console -->
404507
+    <serial type='pty'/>
404507
+    <console type='pty'/>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args
404507
new file mode 120000
404507
index 0000000000..d6c830ecdf
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.args
404507
@@ -0,0 +1 @@
404507
+qemuxml2argv-pseries-serial-native.args
404507
\ No newline at end of file
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml
404507
new file mode 100644
404507
index 0000000000..2e182edbd0
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-compat.xml
404507
@@ -0,0 +1,19 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+  </os>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' model='none'/>
404507
+    
404507
+         but should get converted to the proper type (spapr-vty-serial) -->
404507
+    <serial type='pty'>
404507
+      <target type='isa-serial'/>
404507
+    </serial>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml
404507
new file mode 100644
404507
index 0000000000..5482146a57
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-invalid-machine.xml
404507
@@ -0,0 +1,19 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='x86_64' machine='pc'>hvm</type>
404507
+  </os>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
404507
+    <controller type='usb' model='none'/>
404507
+    
404507
+         guests, so this should be rejected -->
404507
+    <serial type='pty'>
404507
+      <target type='spapr-vio-serial'/>
404507
+    </serial>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args
404507
new file mode 100644
404507
index 0000000000..f72b8b6259
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.args
404507
@@ -0,0 +1,22 @@
404507
+LC_ALL=C \
404507
+PATH=/bin \
404507
+HOME=/home/test \
404507
+USER=test \
404507
+LOGNAME=test \
404507
+QEMU_AUDIO_DRV=none \
404507
+/usr/bin/qemu-system-ppc64 \
404507
+-name guest \
404507
+-S \
404507
+-M pseries \
404507
+-m 512 \
404507
+-smp 1,sockets=1,cores=1,threads=1 \
404507
+-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
404507
+-nographic \
404507
+-nodefconfig \
404507
+-nodefaults \
404507
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
404507
+server,nowait \
404507
+-mon chardev=charmonitor,id=monitor,mode=readline \
404507
+-boot c \
404507
+-chardev pty,id=charserial0 \
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml
404507
new file mode 100644
404507
index 0000000000..6cec4bc9d3
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-native.xml
404507
@@ -0,0 +1,16 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+  </os>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' model='none'/>
404507
+    
404507
+    <serial type='pty'/>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
404507
index a92b1e01b1..37c0594032 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-default.args
404507
@@ -20,4 +20,4 @@ server,nowait \
404507
 -boot c \
404507
 -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
404507
index caaccdbb8e..838b80453a 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
404507
@@ -20,5 +20,5 @@ server,nowait \
404507
 -boot c \
404507
 -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000 \
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \
404507
 -device usb-kbd,id=input0,bus=usb.0,port=1
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
404507
index b9bd905a5d..56bc1d67ef 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-multi.args
404507
@@ -21,4 +21,4 @@ server,nowait \
404507
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1 \
404507
 -device pci-ohci,id=usb1,bus=pci.0,addr=0x2 \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
404507
index 63cf3c1830..0fcfbe3796 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args
404507
@@ -25,6 +25,6 @@ server,nowait \
404507
 -device scsi-disk,bus=scsi1.0,channel=0,scsi-id=0,lun=0,\
404507
 drive=drive-scsi1-0-0-0,id=scsi1-0-0-0 \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x20000000 \
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x20000000 \
404507
 -chardev pty,id=charserial1 \
404507
--device spapr-vty,chardev=charserial1,reg=0x30001000
404507
+-device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
404507
index 0294067bc8..8a9bdcc4cd 100644
404507
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args
404507
@@ -25,6 +25,6 @@ server,nowait \
404507
 -device scsi-disk,bus=scsi1.0,channel=0,scsi-id=0,lun=0,\
404507
 drive=drive-scsi1-0-0-0,id=scsi1-0-0-0 \
404507
 -chardev pty,id=charserial0 \
404507
--device spapr-vty,chardev=charserial0,reg=0x30000000 \
404507
+-device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \
404507
 -chardev pty,id=charserial1 \
404507
--device spapr-vty,chardev=charserial1,reg=0x30001000
404507
+-device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000
404507
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
404507
index 747ad24663..4b63dd141d 100644
404507
--- a/tests/qemuxml2argvtest.c
404507
+++ b/tests/qemuxml2argvtest.c
404507
@@ -1875,6 +1875,22 @@ mymain(void)
404507
                         QEMU_CAPS_MACHINE_OPT,
404507
                         QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
404507
 
404507
+    DO_TEST("pseries-serial-native",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-serial+console-native",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-serial-compat",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-console-native",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-console-virtio",
404507
+            QEMU_CAPS_NODEFCONFIG);
404507
+    DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
404507
+
404507
     DO_TEST("disk-ide-drive-split",
404507
             QEMU_CAPS_NODEFCONFIG,
404507
             QEMU_CAPS_IDE_CD);
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
404507
index 496df0696c..484fe4cfa6 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-panic-pseries.xml
404507
@@ -22,8 +22,8 @@
404507
       <target index='0'/>
404507
     </controller>
404507
     <serial type='pty'>
404507
-      <target type='isa-serial' port='0'>
404507
-        <model name='isa-serial'/>
404507
+      <target type='spapr-vio-serial' port='0'>
404507
+        <model name='spapr-vty'/>
404507
       </target>
404507
       <address type='spapr-vio' reg='0x30000000'/>
404507
     </serial>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml
404507
new file mode 120000
404507
index 0000000000..b0e645fc03
404507
--- /dev/null
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-native.xml
404507
@@ -0,0 +1 @@
404507
+qemuxml2xmlout-pseries-serial-native.xml
404507
\ No newline at end of file
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml
404507
new file mode 100644
404507
index 0000000000..48760f2824
404507
--- /dev/null
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-console-virtio.xml
404507
@@ -0,0 +1,31 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <currentMemory unit='KiB'>524288</currentMemory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+    <boot dev='hd'/>
404507
+  </os>
404507
+  <clock offset='utc'/>
404507
+  <on_poweroff>destroy</on_poweroff>
404507
+  <on_reboot>restart</on_reboot>
404507
+  <on_crash>destroy</on_crash>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' index='0' model='none'/>
404507
+    <controller type='pci' index='0' model='pci-root'>
404507
+      <model name='spapr-pci-host-bridge'/>
404507
+      <target index='0'/>
404507
+    </controller>
404507
+    <controller type='virtio-serial' index='0'>
404507
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
404507
+    </controller>
404507
+    <console type='pty'>
404507
+      <target type='virtio' port='0'/>
404507
+    </console>
404507
+    <memballoon model='none'/>
404507
+    <panic model='pseries'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
404507
index 9d4c5efe67..404bb0c768 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat-power9.xml
404507
@@ -25,8 +25,8 @@
404507
       <target index='0'/>
404507
     </controller>
404507
     <serial type='pty'>
404507
-      <target type='isa-serial' port='0'>
404507
-        <model name='isa-serial'/>
404507
+      <target type='spapr-vio-serial' port='0'>
404507
+        <model name='spapr-vty'/>
404507
       </target>
404507
       <address type='spapr-vio' reg='0x30000000'/>
404507
     </serial>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
404507
index 6059859abd..1891fa5f48 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-compat.xml
404507
@@ -25,8 +25,8 @@
404507
       <target index='0'/>
404507
     </controller>
404507
     <serial type='pty'>
404507
-      <target type='isa-serial' port='0'>
404507
-        <model name='isa-serial'/>
404507
+      <target type='spapr-vio-serial' port='0'>
404507
+        <model name='spapr-vty'/>
404507
       </target>
404507
       <address type='spapr-vio' reg='0x30000000'/>
404507
     </serial>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
404507
index f3216523ed..f08f3e005f 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-cpu-exact.xml
404507
@@ -26,8 +26,8 @@
404507
       <target index='0'/>
404507
     </controller>
404507
     <serial type='pty'>
404507
-      <target type='isa-serial' port='0'>
404507
-        <model name='isa-serial'/>
404507
+      <target type='spapr-vio-serial' port='0'>
404507
+        <model name='spapr-vty'/>
404507
       </target>
404507
       <address type='spapr-vio' reg='0x30000000'/>
404507
     </serial>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
404507
index 496df0696c..484fe4cfa6 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
404507
@@ -22,8 +22,8 @@
404507
       <target index='0'/>
404507
     </controller>
404507
     <serial type='pty'>
404507
-      <target type='isa-serial' port='0'>
404507
-        <model name='isa-serial'/>
404507
+      <target type='spapr-vio-serial' port='0'>
404507
+        <model name='spapr-vty'/>
404507
       </target>
404507
       <address type='spapr-vio' reg='0x30000000'/>
404507
     </serial>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
404507
index 496df0696c..484fe4cfa6 100644
404507
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-no-address.xml
404507
@@ -22,8 +22,8 @@
404507
       <target index='0'/>
404507
     </controller>
404507
     <serial type='pty'>
404507
-      <target type='isa-serial' port='0'>
404507
-        <model name='isa-serial'/>
404507
+      <target type='spapr-vio-serial' port='0'>
404507
+        <model name='spapr-vty'/>
404507
       </target>
404507
       <address type='spapr-vio' reg='0x30000000'/>
404507
     </serial>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml
404507
new file mode 120000
404507
index 0000000000..b0e645fc03
404507
--- /dev/null
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial+console-native.xml
404507
@@ -0,0 +1 @@
404507
+qemuxml2xmlout-pseries-serial-native.xml
404507
\ No newline at end of file
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml
404507
new file mode 120000
404507
index 0000000000..b0e645fc03
404507
--- /dev/null
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-compat.xml
404507
@@ -0,0 +1 @@
404507
+qemuxml2xmlout-pseries-serial-native.xml
404507
\ No newline at end of file
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml
404507
new file mode 100644
404507
index 0000000000..fae7c54d5b
404507
--- /dev/null
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-native.xml
404507
@@ -0,0 +1,35 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <currentMemory unit='KiB'>524288</currentMemory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+    <boot dev='hd'/>
404507
+  </os>
404507
+  <clock offset='utc'/>
404507
+  <on_poweroff>destroy</on_poweroff>
404507
+  <on_reboot>restart</on_reboot>
404507
+  <on_crash>destroy</on_crash>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' index='0' model='none'/>
404507
+    <controller type='pci' index='0' model='pci-root'>
404507
+      <model name='spapr-pci-host-bridge'/>
404507
+      <target index='0'/>
404507
+    </controller>
404507
+    <serial type='pty'>
404507
+      <target type='spapr-vio-serial' port='0'>
404507
+        <model name='spapr-vty'/>
404507
+      </target>
404507
+      <address type='spapr-vio' reg='0x30000000'/>
404507
+    </serial>
404507
+    <console type='pty'>
404507
+      <target type='serial' port='0'/>
404507
+      <address type='spapr-vio' reg='0x30000000'/>
404507
+    </console>
404507
+    <memballoon model='none'/>
404507
+    <panic model='pseries'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
404507
index 6687997900..ad429ead4d 100644
404507
--- a/tests/qemuxml2xmltest.c
404507
+++ b/tests/qemuxml2xmltest.c
404507
@@ -766,6 +766,21 @@ mymain(void)
404507
             QEMU_CAPS_MACHINE_OPT,
404507
             QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
404507
 
404507
+    DO_TEST("pseries-serial-native",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-serial+console-native",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-serial-compat",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-console-native",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-console-virtio",
404507
+            QEMU_CAPS_NODEFCONFIG);
404507
+
404507
     DO_TEST("balloon-device-auto", NONE);
404507
     DO_TEST("balloon-device-period", NONE);
404507
     DO_TEST("channel-virtio-auto", NONE);
404507
-- 
404507
2.15.1
404507