提交 62b825a2 编写于 作者: P Peter Krempa

conf: Add device address type for dimm devices

Dimm devices are described by the slot and base address. Add a new
address type to be able to describe such address.
上级 a41185d8
......@@ -4030,6 +4030,18 @@
</attribute>
</optional>
</define>
<define name="dimmaddress">
<optional>
<attribute name="slot">
<ref name="unsignedInt"/>
</attribute>
</optional>
<optional>
<attribute name="base">
<ref name="hexuint"/>
</attribute>
</optional>
</define>
<define name="devices">
<element name="devices">
<interleave>
......@@ -4449,6 +4461,12 @@
<value>virtio-mmio</value>
</attribute>
</group>
<group>
<attribute name="type">
<value>dimm</value>
</attribute>
<ref name="dimmaddress"/>
</group>
</choice>
</element>
</define>
......
......@@ -249,7 +249,8 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
"virtio-s390",
"ccw",
"virtio-mmio",
"isa")
"isa",
"dimm")
VIR_ENUM_IMPL(virDomainDiskDevice, VIR_DOMAIN_DISK_DEVICE_LAST,
"disk",
......@@ -2833,6 +2834,11 @@ virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a,
if (memcmp(&a->addr.isa, &b->addr.isa, sizeof(a->addr.isa)))
return false;
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
if (memcmp(&a->addr.dimm, &b->addr.dimm, sizeof(a->addr.dimm)))
return false;
break;
}
return true;
......@@ -3702,6 +3708,12 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
virBufferAsprintf(buf, " irq='0x%x'", info->addr.isa.irq);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
virBufferAsprintf(buf, " slot='%u'", info->addr.dimm.slot);
virBufferAsprintf(buf, " base='0x%llx'", info->addr.dimm.base);
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST:
......@@ -4071,6 +4083,41 @@ virDomainDeviceISAAddressParseXML(xmlNodePtr node,
return ret;
}
static int
virDomainDeviceDimmAddressParseXML(xmlNodePtr node,
virDomainDeviceDimmAddressPtr addr)
{
int ret = -1;
char *tmp = NULL;
if (!(tmp = virXMLPropString(node, "slot")) ||
virStrToLong_uip(tmp, NULL, 10, &addr->slot) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid or missing dimm slot id '%s'"),
NULLSTR(tmp));
goto cleanup;
}
VIR_FREE(tmp);
if (!(tmp = virXMLPropString(node, "base")) ||
virStrToLong_ullp(tmp, NULL, 16, &addr->base) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid or missing dimm base address '%s'"),
NULLSTR(tmp));
goto cleanup;
}
VIR_FREE(tmp);
ret = 0;
cleanup:
VIR_FREE(tmp);
return ret;
}
/* Parse the XML definition for a device address
* @param node XML nodeset to parse for device address definition
*/
......@@ -4212,6 +4259,11 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
_("virtio-s390 bus doesn't have an address"));
goto cleanup;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
if (virDomainDeviceDimmAddressParseXML(address, &info->addr.dimm) < 0)
goto cleanup;
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST:
break;
......@@ -15409,6 +15461,26 @@ virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src,
}
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
if (src->addr.dimm.slot != dst->addr.dimm.slot) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target device dimm slot %u does not match "
"source %u"),
dst->addr.dimm.slot,
src->addr.dimm.slot);
return false;
}
if (src->addr.dimm.base != dst->addr.dimm.base) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target device dimm base addres '%llx' does "
"not match source '%llx'"),
dst->addr.dimm.base,
src->addr.dimm.base);
return false;
}
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390:
......
......@@ -234,6 +234,7 @@ typedef enum {
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
} virDomainDeviceAddressType;
......@@ -309,6 +310,13 @@ struct _virDomainDeviceISAAddress {
unsigned int irq;
};
typedef struct _virDomainDeviceDimmAddress virDomainDeviceDimmAddress;
typedef virDomainDeviceDimmAddress *virDomainDeviceDimmAddressPtr;
struct _virDomainDeviceDimmAddress {
unsigned int slot;
unsigned long long base;
};
typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
struct _virDomainDeviceInfo {
......@@ -327,6 +335,7 @@ struct _virDomainDeviceInfo {
virDomainDeviceSpaprVioAddress spaprvio;
virDomainDeviceCCWAddress ccw;
virDomainDeviceISAAddress isa;
virDomainDeviceDimmAddress dimm;
} addr;
int mastertype;
union {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册