File aab943a6-support-firmware-debug.patch of Package libvirt.29155

commit aab943a632d40131b5d472fc7784b46b734aa550
Author: Daniel P. Berrangé <berrange@redhat.com>
Date:   Thu Jan 20 08:10:16 2022 -0500

    conf: support firmware ISA debug console
    
    Introduce support for
    
      <serial type='pty'>
        <target type='isa-debug'>
          <model type='isa-debugcon'/>
        </target>
        <address type='isa' iobase='0x402'/>
      </console>
    
    which is used as a way to receive debug messages from the
    firmware on x86 platforms.
    
    Note that the default port is hypervisor specific, with QEMU
    currently using 0xe9 since that's the original Bochs debug port.
    For use with SeaBIOS/OVMF, the iobase port needs to be explicitly
    set to 0x402.
    
    Reviewed-by: Andrea Bolognani <abologna@redhat.com>
    Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Index: libvirt-8.0.0/docs/formatdomain.rst
===================================================================
--- libvirt-8.0.0.orig/docs/formatdomain.rst
+++ libvirt-8.0.0/docs/formatdomain.rst
@@ -6388,8 +6388,9 @@ values are, :since:`since 1.0.2` , ``isa
 ``usb-serial`` (usable whenever USB support is available) and ``pci-serial``
 (usable whenever PCI support is available); :since:`since 3.10.0` ,
 ``spapr-vio-serial`` (usable with ppc64/pseries guests), ``system-serial``
-(usable with aarch64/virt and, :since:`since 4.7.0` , riscv/virt guests) and
-``sclp-serial`` (usable with s390 and s390x guests) are available as well.
+(usable with aarch64/virt and, :since:`since 4.7.0` , riscv/virt guests),
+``sclp-serial`` (usable with s390 and s390x guests) are available as well
+and :since:`since 8.1.0` ``isa-debug`` (usable with x86 guests).
 
 :since:`Since 3.10.0` , the ``target`` element can have an optional ``model``
 subelement; valid values for its ``name`` attribute are: ``isa-serial`` (usable
@@ -6398,9 +6399,12 @@ with the ``isa-serial`` target type); ``
 target type); ``spapr-vty`` (usable with the ``spapr-vio-serial`` target type);
 ``pl011`` and, :since:`since 4.7.0` , ``16550a`` (usable with the
 ``system-serial`` target type); ``sclpconsole`` and ``sclplmconsole`` (usable
-with the ``sclp-serial`` target type). Providing a target model is usually
-unnecessary: libvirt will automatically pick one that's suitable for the chosen
-target type, and overriding that value is generally not recommended.
+with the ``sclp-serial`` target type). ``isa-debugcon`` (usable with the
+``isa-debug`` target type); provides a virtual console for receiving debug
+messages from the firmware on x86 platforms. :since:`Since: 8.1.0`.
+Providing a target model is usually unnecessary: libvirt will automatically
+pick one that's suitable for the chosen target type, and overriding that
+value is generally not recommended.
 
 If any of the attributes is not specified by the user, libvirt will choose a
 value suitable for most users.
Index: libvirt-8.0.0/docs/schemas/domaincommon.rng
===================================================================
--- libvirt-8.0.0.orig/docs/schemas/domaincommon.rng
+++ libvirt-8.0.0/docs/schemas/domaincommon.rng
@@ -4406,6 +4406,7 @@
         <value>spapr-vio-serial</value>
         <value>system-serial</value>
         <value>sclp-serial</value>
+        <value>isa-debug</value>
       </choice>
     </attribute>
   </define>
@@ -4422,6 +4423,7 @@
           <value>16550a</value>
           <value>sclpconsole</value>
           <value>sclplmconsole</value>
+          <value>isa-debugcon</value>
         </choice>
       </attribute>
     </element>
Index: libvirt-8.0.0/src/conf/domain_conf.c
===================================================================
--- libvirt-8.0.0.orig/src/conf/domain_conf.c
+++ libvirt-8.0.0/src/conf/domain_conf.c
@@ -651,6 +651,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTarget,
               "spapr-vio-serial",
               "system-serial",
               "sclp-serial",
+              "isa-debug",
 );
 
 VIR_ENUM_IMPL(virDomainChrChannelTarget,
@@ -685,6 +686,7 @@ VIR_ENUM_IMPL(virDomainChrSerialTargetMo
               "sclpconsole",
               "sclplmconsole",
               "16550a",
+              "isa-debugcon",
 );
 
 VIR_ENUM_IMPL(virDomainChrDevice,
@@ -4938,6 +4940,7 @@ virDomainDefAddConsoleCompat(virDomainDe
 
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
             /* Nothing to do */
             break;
@@ -5330,7 +5333,7 @@ virDomainHostdevDefPostParse(virDomainHo
 }
 
 
-static void
+static int
 virDomainChrDefPostParse(virDomainChrDef *chr,
                          const virDomainDef *def)
 {
@@ -5344,6 +5347,14 @@ virDomainChrDefPostParse(virDomainChrDef
         chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
     }
 
+    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+        chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG &&
+        !ARCH_IS_X86(def->os.arch)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("isa-debug serial type only valid on x86 architecture"));
+        return -1;
+    }
+
     if (chr->target.port == -1 &&
         (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL ||
          chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL ||
@@ -5357,6 +5368,8 @@ virDomainChrDefPostParse(virDomainChrDef
 
         chr->target.port = maxport + 1;
     }
+
+    return 0;
 }
 
 
@@ -5568,8 +5581,7 @@ virDomainDeviceDefPostParseCommon(virDom
 
     switch ((virDomainDeviceType)dev->type) {
     case VIR_DOMAIN_DEVICE_CHR:
-        virDomainChrDefPostParse(dev->data.chr, def);
-        ret = 0;
+        ret = virDomainChrDefPostParse(dev->data.chr, def);
         break;
 
     case VIR_DOMAIN_DEVICE_RNG:
Index: libvirt-8.0.0/src/conf/domain_conf.h
===================================================================
--- libvirt-8.0.0.orig/src/conf/domain_conf.h
+++ libvirt-8.0.0/src/conf/domain_conf.h
@@ -1160,6 +1160,7 @@ typedef enum {
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP,
+    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG,
 
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
 } virDomainChrSerialTargetType;
@@ -1197,6 +1198,7 @@ typedef enum {
     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE,
     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE,
     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A,
+    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_DEBUGCON,
 
     VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
 } virDomainChrSerialTargetModel;
Index: libvirt-8.0.0/src/qemu/qemu_command.c
===================================================================
--- libvirt-8.0.0.orig/src/qemu/qemu_command.c
+++ libvirt-8.0.0/src/qemu/qemu_command.c
@@ -9315,6 +9315,7 @@ qemuChrSerialTargetModelToCaps(virDomain
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
         return QEMU_CAPS_DEVICE_PL011;
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A:
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_DEBUGCON:
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
         break;
@@ -10726,6 +10727,7 @@ qemuBuildSerialChrDeviceProps(const virD
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE:
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_DEBUGCON:
 
         caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
 
Index: libvirt-8.0.0/src/qemu/qemu_domain.c
===================================================================
--- libvirt-8.0.0.orig/src/qemu/qemu_domain.c
+++ libvirt-8.0.0/src/qemu/qemu_domain.c
@@ -5204,6 +5204,9 @@ qemuDomainChrDefPostParse(virDomainChrDe
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
             chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE;
             break;
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG:
+            chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_DEBUGCON;
+            break;
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
             /* Nothing to do */
@@ -6211,6 +6214,7 @@ qemuDomainDefFormatBufInternal(virQEMUDr
                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
+                case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG:
                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
                 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
                     /* Nothing to do */
Index: libvirt-8.0.0/src/qemu/qemu_domain_address.c
===================================================================
--- libvirt-8.0.0.orig/src/qemu/qemu_domain_address.c
+++ libvirt-8.0.0/src/qemu/qemu_domain_address.c
@@ -995,6 +995,7 @@ qemuDomainDeviceCalculatePCIConnectFlags
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
             return 0;
Index: libvirt-8.0.0/src/qemu/qemu_validate.c
===================================================================
--- libvirt-8.0.0.orig/src/qemu/qemu_validate.c
+++ libvirt-8.0.0/src/qemu/qemu_validate.c
@@ -1817,6 +1817,7 @@ qemuValidateChrSerialTargetTypeToAddress
 {
     switch ((virDomainChrSerialTargetType)targetType) {
     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG:
         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA;
     case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
         return VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB;
@@ -1853,6 +1854,8 @@ qemuValidateChrSerialTargetModelToTarget
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE:
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
         return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP;
+    case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_DEBUGCON:
+        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG;
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
         break;
@@ -1876,6 +1879,7 @@ qemuValidateDomainChrTargetDef(const vir
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO:
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA_DEBUG:
 
             expected = qemuValidateChrSerialTargetTypeToAddressType(chr->targetType);
 
@@ -1915,6 +1919,7 @@ qemuValidateDomainChrTargetDef(const vir
         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A:
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_DEBUGCON:
 
             expected = qemuValidateChrSerialTargetModelToTargetType(chr->targetModel);
 
openSUSE Build Service is sponsored by