Re: [libvirt] [PATCH v3 2/5] conf: add PCI controllers

2013-04-25 Thread Ján Tomko
On 04/22/2013 10:11 PM, Laine Stump wrote:
 On 04/22/2013 02:43 PM, Ján Tomko wrote:
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -2124,7 +2124,7 @@
  p
Each controller has a mandatory attribute codetype/code,
which must be one of ide, fdc, scsi, sata, usb,
 -  ccid, or virtio-serial, and a mandatory
 +  ccid, virtio-serial or pci, and a mandatory
attribute codeindex/code which is the decimal integer
describing in which order the bus controller is encountered (for
use in codecontroller/code attributes
 @@ -2177,6 +2177,26 @@
lt;/devicesgt;
.../pre
  
 +p
 +  PCI controllers have an optional codemodel/code attribute with
 +  possible values codepci-root/code or codepci-bridge/code.
 +  For machine types which provide an implicit pci bus, the pci-root
 +  controller with index=0 is auto-added and required to use PCI devices.
 +  PCI root has no address.
 +  PCI bridges are auto-added if there are too many devices to fit on
 +  the one bus provided by pci-root, or a PCI bus number greater than 
 zero
 +  was specified. (span class=sincesince 1.0.5/span)
 
 
 Just so that it's clear that it's not automatic-only, you should also
 say something like a pci-bridge device can be manually added in the
 domain's configuration, but care should be taken to not have any gaps in
 the sequence of index attributes when there are multiple pci controllers.
 
 

Gaps in the indexes might work, as long as the bridges don't reference 
unspecified buses.

I'll be squashing this in before pushing:

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index bd4b77c..0c0506b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2189,7 +2189,12 @@
   PCI root has no address.
   PCI bridges are auto-added if there are too many devices to fit on
   the one bus provided by pci-root, or a PCI bus number greater than zero
-  was specified. (span class=sincesince 1.0.5/span)
+  was specified.
+  PCI bridges can also be specified manually, but their addresses should
+  only refer to PCI buses provided by already specified PCI controllers.
+  Leaving gaps in the PCI controller indexes might lead to an invalid
+  configuration.
+  (span class=sincesince 1.0.5/span)
 /p
 pre
   ...


 ACK.
 

Thanks,

Jan

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v3 2/5] conf: add PCI controllers

2013-04-22 Thread Ján Tomko
Add new controller type 'pci' with models 'pci-root' and 'pci-bridge'.
---
 docs/formatdomain.html.in | 22 +-
 docs/schemas/domaincommon.rng | 12 
 src/conf/domain_conf.c| 21 -
 src/conf/domain_conf.h|  9 +
 4 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 888c005..4a700f9 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2124,7 +2124,7 @@
 p
   Each controller has a mandatory attribute codetype/code,
   which must be one of ide, fdc, scsi, sata, usb,
-  ccid, or virtio-serial, and a mandatory
+  ccid, virtio-serial or pci, and a mandatory
   attribute codeindex/code which is the decimal integer
   describing in which order the bus controller is encountered (for
   use in codecontroller/code attributes
@@ -2177,6 +2177,26 @@
   lt;/devicesgt;
   .../pre
 
+p
+  PCI controllers have an optional codemodel/code attribute with
+  possible values codepci-root/code or codepci-bridge/code.
+  For machine types which provide an implicit pci bus, the pci-root
+  controller with index=0 is auto-added and required to use PCI devices.
+  PCI root has no address.
+  PCI bridges are auto-added if there are too many devices to fit on
+  the one bus provided by pci-root, or a PCI bus number greater than zero
+  was specified. (span class=sincesince 1.0.5/span)
+/p
+pre
+  ...
+  lt;devicesgt;
+lt;controller type='pci' index='0' model='pci-root'/gt;
+lt;controller type='pci' index='1' model='pci-bridge'gt;
+  lt;address type='pci' domain='0' bus='0' slot='5' function='0' 
multifunction=off'/gt;
+lt;/controllergt;
+  lt;/devicesgt;
+  .../pre
+
 h4a name=elementsLeaseDevice leases/a/h4
 
 p
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3976b82..cf91c2d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1475,6 +1475,18 @@
   ref name=usbmaster/
 /optional
   /group
+  !-- pci has an optional attribute model --
+  group
+attribute name=type
+  valuepci/value
+/attribute
+attribute name=model
+  choice
+valuepci-root/value
+valuepci-bridge/value
+  /choice
+/attribute
+  /group
   !-- virtio-serial has optional ports and vectors --
   group
 attribute name=type
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8d57256..1e7de52 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -300,7 +300,12 @@ VIR_ENUM_IMPL(virDomainController, 
VIR_DOMAIN_CONTROLLER_TYPE_LAST,
   sata,
   virtio-serial,
   ccid,
-  usb)
+  usb,
+  pci)
+
+VIR_ENUM_IMPL(virDomainControllerModelPCI, 
VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST,
+  pci-root,
+  pci-bridge)
 
 VIR_ENUM_IMPL(virDomainControllerModelSCSI, 
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
   auto,
@@ -5144,6 +5149,8 @@ virDomainControllerModelTypeFromString(const 
virDomainControllerDefPtr def,
 return virDomainControllerModelSCSITypeFromString(model);
 else if (def-type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
 return virDomainControllerModelUSBTypeFromString(model);
+else if (def-type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
+return virDomainControllerModelPCITypeFromString(model);
 
 return -1;
 }
@@ -5261,6 +5268,16 @@ virDomainControllerDefParseXML(xmlNodePtr node,
 }
 break;
 }
+case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
+switch (def-model) {
+case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
+if (def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(pci-root controller should not 
+ have an address));
+goto error;
+}
+}
 
 default:
 break;
@@ -13488,6 +13505,8 @@ 
virDomainControllerModelTypeToString(virDomainControllerDefPtr def,
 return virDomainControllerModelSCSITypeToString(model);
 else if (def-type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
 return virDomainControllerModelUSBTypeToString(model);
+else if (def-type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
+return virDomainControllerModelPCITypeToString(model);
 
 return NULL;
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 89515de..3cb626b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -696,11 +696,19 @@ enum virDomainControllerType {
 VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
 VIR_DOMAIN_CONTROLLER_TYPE_CCID,
 VIR_DOMAIN_CONTROLLER_TYPE_USB,
+

Re: [libvirt] [PATCH v3 2/5] conf: add PCI controllers

2013-04-22 Thread Laine Stump
On 04/22/2013 02:43 PM, Ján Tomko wrote:
 Add new controller type 'pci' with models 'pci-root' and 'pci-bridge'.
 ---
  docs/formatdomain.html.in | 22 +-
  docs/schemas/domaincommon.rng | 12 
  src/conf/domain_conf.c| 21 -
  src/conf/domain_conf.h|  9 +
  4 files changed, 62 insertions(+), 2 deletions(-)

 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index 888c005..4a700f9 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -2124,7 +2124,7 @@
  p
Each controller has a mandatory attribute codetype/code,
which must be one of ide, fdc, scsi, sata, usb,
 -  ccid, or virtio-serial, and a mandatory
 +  ccid, virtio-serial or pci, and a mandatory
attribute codeindex/code which is the decimal integer
describing in which order the bus controller is encountered (for
use in codecontroller/code attributes
 @@ -2177,6 +2177,26 @@
lt;/devicesgt;
.../pre
  
 +p
 +  PCI controllers have an optional codemodel/code attribute with
 +  possible values codepci-root/code or codepci-bridge/code.
 +  For machine types which provide an implicit pci bus, the pci-root
 +  controller with index=0 is auto-added and required to use PCI devices.
 +  PCI root has no address.
 +  PCI bridges are auto-added if there are too many devices to fit on
 +  the one bus provided by pci-root, or a PCI bus number greater than zero
 +  was specified. (span class=sincesince 1.0.5/span)


Just so that it's clear that it's not automatic-only, you should also
say something like a pci-bridge device can be manually added in the
domain's configuration, but care should be taken to not have any gaps in
the sequence of index attributes when there are multiple pci controllers.


 +/p
 +pre
 +  ...
 +  lt;devicesgt;
 +lt;controller type='pci' index='0' model='pci-root'/gt;
 +lt;controller type='pci' index='1' model='pci-bridge'gt;
 +  lt;address type='pci' domain='0' bus='0' slot='5' function='0' 
 multifunction=off'/gt;
 +lt;/controllergt;
 +  lt;/devicesgt;
 +  .../pre
 +
  h4a name=elementsLeaseDevice leases/a/h4
  
  p
 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
 index 3976b82..cf91c2d 100644
 --- a/docs/schemas/domaincommon.rng
 +++ b/docs/schemas/domaincommon.rng
 @@ -1475,6 +1475,18 @@
ref name=usbmaster/
  /optional
/group
 +  !-- pci has an optional attribute model --
 +  group
 +attribute name=type
 +  valuepci/value
 +/attribute
 +attribute name=model
 +  choice
 +valuepci-root/value
 +valuepci-bridge/value
 +  /choice
 +/attribute
 +  /group
!-- virtio-serial has optional ports and vectors --
group
  attribute name=type
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index 8d57256..1e7de52 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -300,7 +300,12 @@ VIR_ENUM_IMPL(virDomainController, 
 VIR_DOMAIN_CONTROLLER_TYPE_LAST,
sata,
virtio-serial,
ccid,
 -  usb)
 +  usb,
 +  pci)
 +
 +VIR_ENUM_IMPL(virDomainControllerModelPCI, 
 VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST,
 +  pci-root,
 +  pci-bridge)
  
  VIR_ENUM_IMPL(virDomainControllerModelSCSI, 
 VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
auto,
 @@ -5144,6 +5149,8 @@ virDomainControllerModelTypeFromString(const 
 virDomainControllerDefPtr def,
  return virDomainControllerModelSCSITypeFromString(model);
  else if (def-type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
  return virDomainControllerModelUSBTypeFromString(model);
 +else if (def-type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
 +return virDomainControllerModelPCITypeFromString(model);
  
  return -1;
  }
 @@ -5261,6 +5268,16 @@ virDomainControllerDefParseXML(xmlNodePtr node,
  }
  break;
  }
 +case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
 +switch (def-model) {
 +case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
 +if (def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
 +virReportError(VIR_ERR_XML_ERROR, %s,
 +   _(pci-root controller should not 
 + have an address));
 +goto error;
 +}
 +}
  
  default:
  break;
 @@ -13488,6 +13505,8 @@ 
 virDomainControllerModelTypeToString(virDomainControllerDefPtr def,
  return virDomainControllerModelSCSITypeToString(model);
  else if (def-type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
  return virDomainControllerModelUSBTypeToString(model);
 +else if (def-type ==