[libvirt] [PATCH] auto-create pci-bridge controller info

if some devices specify a pci bus number that haven't been defined by a pci-bridge controller then fill the required correct controller info silently. it based on previous add pci-bridge support patches, https://www.redhat.com/archives/libvir-list/2013-January/msg00577.html Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- src/conf/domain_conf.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8ebe77d..dabd374 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11756,6 +11756,98 @@ virDomainDefMaybeAddSmartcardController(virDomainDefPtr def) } +static int +virDomainDefMaybeAddPcibridgeController(virDomainDefPtr def) +{ + int i, idx = 0; + + for (i = 0; i < def->nnets; i++) { + if (def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + continue; + idx = def->nets[i]->info.addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + } + + for (i = 0; i < def->nsounds; i++) { + if (def->sounds[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + continue; + idx = def->sounds[i]->info.addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + } + + for (i = 0; i < def->nvideos; i++) { + if (def->videos[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + continue; + idx = def->videos[i]->info.addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + } + + for (i = 0; i < def->ncontrollers; i++) { + if (def->controllers[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + continue; + idx = def->controllers[i]->info.addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + } + + for (i = 0; i < def->nfss; i++) { + if (def->fss[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + continue; + idx = def->fss[i]->info.addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + } + + for (i = 0; i < def->nhostdevs; i++) { + if (def->hostdevs[i]->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + continue; + idx = def->hostdevs[i]->info->addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + } + + for (i = 0; i < def->ndisks; i++) { + if (def->disks[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + continue; + idx = def->disks[i]->info.addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + } + + if (def->watchdog->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + idx = def->watchdog->info.addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + + if (def->memballoon->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + idx = def->memballoon->info.addr.pci.bus; + if (virDomainDefMaybeAddController(def, + VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE, + idx) < 0) + return -1; + + return 0; +} + /* * Based on the declared <address/> info for any devices, * add necessary drive controllers which are not already present @@ -11790,6 +11882,9 @@ int virDomainDefAddImplicitControllers(virDomainDefPtr def) if (virDomainDefMaybeAddSmartcardController(def) < 0) return -1; + if (virDomainDefMaybeAddPcibridgeController(def) < 0) + return -1; + return 0; } -- 1.7.2.5

On Wed, Jan 23, 2013 at 09:45:20AM +0800, liguang wrote:
if some devices specify a pci bus number that haven't been defined by a pci-bridge controller then fill the required correct controller info silently. it based on previous add pci-bridge support patches, https://www.redhat.com/archives/libvir-list/2013-January/msg00577.html
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- src/conf/domain_conf.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-)
ACK 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 :|

On 01/23/2013 03:05 AM, Daniel P. Berrange wrote:
On Wed, Jan 23, 2013 at 09:45:20AM +0800, liguang wrote:
if some devices specify a pci bus number that haven't been defined by a pci-bridge controller then fill the required correct controller info silently. it based on previous add pci-bridge support patches, https://www.redhat.com/archives/libvir-list/2013-January/msg00577.html
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- src/conf/domain_conf.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-)
ACK
However, it fails to compile: CC libvirt_conf_la-domain_conf.lo conf/domain_conf.c: In function 'virDomainDefMaybeAddPcibridgeController': conf/domain_conf.c:11829:44: error: 'VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE' undeclared (first use in this function) Please resubmit a fixed version. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Jan 23, 2013 at 06:05:42AM -0700, Eric Blake wrote:
On 01/23/2013 03:05 AM, Daniel P. Berrange wrote:
On Wed, Jan 23, 2013 at 09:45:20AM +0800, liguang wrote:
if some devices specify a pci bus number that haven't been defined by a pci-bridge controller then fill the required correct controller info silently. it based on previous add pci-bridge support patches, https://www.redhat.com/archives/libvir-list/2013-January/msg00577.html
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- src/conf/domain_conf.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-)
ACK
However, it fails to compile:
CC libvirt_conf_la-domain_conf.lo conf/domain_conf.c: In function 'virDomainDefMaybeAddPcibridgeController': conf/domain_conf.c:11829:44: error: 'VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE' undeclared (first use in this function)
Please resubmit a fixed version.
I believe it depends on the earlier PCI patches which have not yet been agreed on. 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 :|

On 01/23/2013 06:15 AM, Daniel P. Berrange wrote:
ACK
However, it fails to compile:
CC libvirt_conf_la-domain_conf.lo conf/domain_conf.c: In function 'virDomainDefMaybeAddPcibridgeController': conf/domain_conf.c:11829:44: error: 'VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE' undeclared (first use in this function)
Please resubmit a fixed version.
I believe it depends on the earlier PCI patches which have not yet been agreed on.
We are probably going to have to slip this to post-1.0.2 as a result. It would be nice to see a complete rebased thread of all the necessary related patches. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

在 2013-01-23三的 10:05 +0000,Daniel P. Berrange写道:
On Wed, Jan 23, 2013 at 09:45:20AM +0800, liguang wrote:
if some devices specify a pci bus number that haven't been defined by a pci-bridge controller then fill the required correct controller info silently. it based on previous add pci-bridge support patches, https://www.redhat.com/archives/libvir-list/2013-January/msg00577.html
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> --- src/conf/domain_conf.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-)
ACK
Daniel
Thanks! -- regards! li guang
participants (4)
-
Daniel P. Berrange
-
Eric Blake
-
li guang
-
liguang