On Fri, Aug 26, 2011 at 01:44:23AM +0300, Marc-André Lureau wrote: > Companion controllers take an extra 'master' attribute to associate > them. > > Changes since v1: > - use the same bus index for companion controllers > - removed the master bus attribute, redundant with controller index > --- > docs/formatdomain.html.in | 22 ++++++++++++ > docs/schemas/domain.rng | 12 +++++++ > src/conf/domain_conf.c | 35 ++++++++++++++++++++ > src/conf/domain_conf.h | 18 ++++++++++ > src/qemu/qemu_command.c | 11 ++++++- > .../qemuxml2argv-input-usbmouse-addr.args | 2 +- > .../qemuxml2argv-usb-ich9-companion.args | 6 +++ > .../qemuxml2argv-usb-ich9-companion.xml | 30 +++++++++++++++++ > tests/qemuxml2argvtest.c | 3 ++ > 9 files changed, 137 insertions(+), 2 deletions(-) > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-companion.args > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-companion.xml > > diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in > index 5552fbc..633cea1 100644 > --- a/docs/formatdomain.html.in > +++ b/docs/formatdomain.html.in > @@ -1243,6 +1243,28 @@ > sub-element. > </p> > > + <p> > + USB companion controllers have an optional > + sub-element <code><master></code> to specify the exact > + relationship of the companion to its master controller. > + A companion controller is on the same bus as its master, so > + the companion <code>index</code> value should be equal. > + </p> > + > +<pre> > + ... > + <devices> > + <controller type='usb' index='0' model='ich9-ehci1'> > + <address type='pci' domain='0' bus='0' slot='4' function='7'/> > + </controller> > + <controller type='usb' index='0' model='ich9-uhci1'> > + <master startport='0'/> > + <address type='pci' domain='0' bus='0' slot='4' function='0'/> > + </controller> > + ... > + </devices> > + ...</pre> > + > <h4><a name="elementsLease">Device leases</a></h4> > > <p> > diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng > index 632e029..455f57d 100644 > --- a/docs/schemas/domain.rng > +++ b/docs/schemas/domain.rng > @@ -923,6 +923,9 @@ > </attribute> > </optional> > <optional> > + <ref name="usbmaster"/> > + </optional> > + <optional> > <ref name="address"/> > </optional> > </element> > @@ -2378,6 +2381,15 @@ > </element> > </define> > > + <define name="usbmaster"> > + <element name="master"> > + <attribute name="startport"> > + <ref name="usbAddr"/> > + </attribute> > + <empty/> > + </element> > + </define> > + > <define name="filterref-node-attributes"> > <attribute name="filter"> > <data type="NCName"/> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 5487e0e..5ef062a 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -1832,6 +1832,31 @@ cleanup: > return ret; > } > > +static int > +virDomainDeviceUSBMasterParseXML(xmlNodePtr node, > + virDomainDeviceUSBMasterPtr master) > +{ > + char *startport; > + int ret = -1; > + > + memset(master, 0, sizeof(*master)); > + > + startport = virXMLPropString(node, "startport"); > + > + if (startport && > + virStrToLong_ui(startport, NULL, 10, &master->startport) < 0) { > + virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", > + _("Cannot parse <master> 'startport' attribute")); > + goto cleanup; > + } > + > + ret = 0; > + > +cleanup: > + VIR_FREE(startport); > + return ret; > +} > + > /* Parse the XML definition for a device address > * @param node XML nodeset to parse for device address definition > */ > @@ -1842,6 +1867,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, > { > xmlNodePtr cur; > xmlNodePtr address = NULL; > + xmlNodePtr master = NULL; > xmlNodePtr alias = NULL; > char *type = NULL; > int ret = -1; > @@ -1858,6 +1884,9 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, > } else if (address == NULL && > xmlStrEqual(cur->name, BAD_CAST "address")) { > address = cur; > + } else if (master == NULL && > + xmlStrEqual(cur->name, BAD_CAST "master")) { > + master = cur; > } > } > cur = cur->next; > @@ -1866,6 +1895,12 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, > if (alias) > info->alias = virXMLPropString(alias, "name"); > > + if (master) { > + info->mastertype = VIR_DOMAIN_CONTROLLER_MASTER_USB; > + if (virDomainDeviceUSBMasterParseXML(master, &info->master.usb) < 0) > + goto cleanup; > + } > + > if (!address) > return 0; > > diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h > index 1ad8071..07d60a4 100644 > --- a/src/conf/domain_conf.h > +++ b/src/conf/domain_conf.h > @@ -113,6 +113,20 @@ struct _virDomainDeviceUSBAddress { > unsigned int port; > }; > > +enum virDomainControllerMaster { > + VIR_DOMAIN_CONTROLLER_MASTER_NONE, > + VIR_DOMAIN_CONTROLLER_MASTER_USB, > + > + VIR_DOMAIN_CONTROLLER_MASTER_LAST > +}; > + > +typedef struct _virDomainDeviceUSBMaster virDomainDeviceUSBMaster; > +typedef virDomainDeviceUSBMaster *virDomainDeviceUSBMasterPtr; > +struct _virDomainDeviceUSBMaster { > + unsigned int bus; > + unsigned int startport; > +}; The 'bus' field is now unused, so can be removed here I believe. ACK aside from that Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list