render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 8a0f676b42526ea92fa8e1e62ddea2aeb7768df1 Mon Sep 17 00:00:00 2001
Message-Id: <8a0f676b42526ea92fa8e1e62ddea2aeb7768df1.1387385061.git.jdenemar@redhat.com>
From: Hu Tao <hutao@cn.fujitsu.com>
Date: Mon, 16 Dec 2013 11:58:20 -0700
Subject: [PATCH] conf: introduce generic ISA address

RHEL 7.0: https://bugzilla.redhat.com/show_bug.cgi?id=996520

For example:
<address type='isa' iobase='0x505' irq='0x1'/>

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit f1a039ef57f48fbc28c629163d2fedf9f273179f)

Conflicts:
	src/conf/domain_conf.c - no virtio-mmio (commit 4fa1722)
	src/conf/domain_conf.h - no virtio-mmio
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 docs/formatdomain.html.in     |  5 ++++
 docs/schemas/basictypes.rng   | 17 ++++++++++++
 docs/schemas/domaincommon.rng |  6 +++++
 src/conf/domain_conf.c        | 63 ++++++++++++++++++++++++++++++++++++++++++-
 src/conf/domain_conf.h        |  9 +++++++
 5 files changed, 99 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c783478..fb557f6 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2382,6 +2382,11 @@
         operating system.
         <span class="since">Since 1.0.4</span>
       </dd>
+      <dt><code>type='isa'</code></dt>
+      <dd>ISA addresses have the following additional
+        attributes: <code>iobase</code> and <code>irq</code>.
+        <span class="since">Since 1.2.1</span>
+      </dd>
     </dl>
 
     <h4><a name="elementsControllers">Controllers</a></h4>
diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 34c2254..dcd846e 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -372,4 +372,21 @@
     </element>
   </define>
 
+  <define name="isaaddress">
+    <optional>
+      <attribute name="iobase">
+        <data type="string">
+          <param name="pattern">0x[a-fA-F0-9]{1,4}</param>
+        </data>
+      </attribute>
+    </optional>
+    <optional>
+      <attribute name="irq">
+        <data type="string">
+          <param name="pattern">0x[a-fA-F0-9]</param>
+        </data>
+      </attribute>
+    </optional>
+  </define>
+
 </grammar>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 36a4b94..871ae30 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3870,6 +3870,12 @@
           </attribute>
           <ref name="ccwaddress"/>
         </group>
+        <group>
+          <attribute name="type">
+            <value>isa</value>
+          </attribute>
+          <ref name="isaaddress"/>
+        </group>
       </choice>
     </element>
   </define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f7c0274..f35ec44 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -211,7 +211,8 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
               "usb",
               "spapr-vio",
               "virtio-s390",
-              "ccw")
+              "ccw",
+              "isa")
 
 VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST,
               "block",
@@ -3036,6 +3037,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
                           info->addr.ccw.devno);
         break;
 
+    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
+        if (info->addr.isa.iobase > 0)
+            virBufferAsprintf(buf, " iobase='0x%x'", info->addr.isa.iobase);
+        if (info->addr.isa.irq > 0)
+            virBufferAsprintf(buf, " irq='0x%x'", info->addr.isa.irq);
+        break;
+
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unknown address type '%d'"), info->type);
@@ -3372,6 +3380,40 @@ cleanup:
     return ret;
 }
 
+static int
+virDomainDeviceISAAddressParseXML(xmlNodePtr node,
+                                  virDomainDeviceISAAddressPtr addr)
+{
+    int ret = -1;
+    char *iobase;
+    char *irq;
+
+    memset(addr, 0, sizeof(*addr));
+
+    iobase = virXMLPropString(node, "iobase");
+    irq = virXMLPropString(node, "irq");
+
+    if (iobase &&
+        virStrToLong_ui(iobase, NULL, 16, &addr->iobase) < 0) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("Cannot parse <address> 'iobase' attribute"));
+        goto cleanup;
+    }
+
+    if (irq &&
+        virStrToLong_ui(irq, NULL, 16, &addr->irq) < 0) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("Cannot parse <address> 'irq' attribute"));
+        goto cleanup;
+    }
+
+    ret = 0;
+cleanup:
+    VIR_FREE(iobase);
+    VIR_FREE(irq);
+    return ret;
+}
+
 /* Parse the XML definition for a device address
  * @param node XML nodeset to parse for device address definition
  */
@@ -3500,6 +3542,11 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
             goto cleanup;
         break;
 
+    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
+        if (virDomainDeviceISAAddressParseXML(address, &info->addr.isa) < 0)
+            goto cleanup;
+        break;
+
     default:
         /* Should not happen */
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -12806,6 +12853,20 @@ virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src,
             return false;
         }
         break;
+
+    case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
+        if (src->addr.isa.iobase != dst->addr.isa.iobase ||
+            src->addr.isa.irq != dst->addr.isa.irq) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Target device isa address %d:%d "
+                             "does not match source %d:%d"),
+                           dst->addr.isa.iobase,
+                           dst->addr.isa.irq,
+                           src->addr.isa.iobase,
+                           src->addr.isa.irq);
+            return false;
+        }
+        break;
     }
 
     return true;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1d27ccd..7f6096f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -207,6 +207,7 @@ enum virDomainDeviceAddressType {
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390,
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW,
+    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA,
 
     VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
 };
@@ -283,6 +284,13 @@ struct _virDomainDeviceUSBMaster {
     unsigned int startport;
 };
 
+typedef struct _virDomainDeviceISAAddress virDomainDeviceISAAddress;
+typedef virDomainDeviceISAAddress *virDomainDeviceISAAddressPtr;
+struct _virDomainDeviceISAAddress {
+    unsigned int iobase;
+    unsigned int irq;
+};
+
 typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
 typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
 struct _virDomainDeviceInfo {
@@ -300,6 +308,7 @@ struct _virDomainDeviceInfo {
         virDomainDeviceUSBAddress usb;
         virDomainDeviceSpaprVioAddress spaprvio;
         virDomainDeviceCCWAddress ccw;
+        virDomainDeviceISAAddress isa;
     } addr;
     int mastertype;
     union {
-- 
1.8.5.1