Re: [libvirt] [PATCH v4 09/25] [ACKED] qemu: use virDomainPCIAddressReserveNextAddr in qemuDomainAssignDevicePCISlots

2016-10-18 Thread Andrea Bolognani
On Fri, 2016-10-14 at 15:54 -0400, Laine Stump wrote:
> instead of calling virDomainPCIAddressGetNextSlot() (which I want to
> turn into a local static in domain_addr.c).
> ---
> 
> Change: fixed line length
> 
>  src/qemu/qemu_domain_address.c | 33 +++--
>  1 file changed, 15 insertions(+), 18 deletions(-)

ACK

-- 
Andrea Bolognani / Red Hat / Virtualization

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


[libvirt] [PATCH v4 09/25] [ACKED] qemu: use virDomainPCIAddressReserveNextAddr in qemuDomainAssignDevicePCISlots

2016-10-14 Thread Laine Stump
instead of calling virDomainPCIAddressGetNextSlot() (which I want to
turn into a local static in domain_addr.c).
---

Change: fixed line length

 src/qemu/qemu_domain_address.c | 33 +++--
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 8628dc1..fa52383 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1005,7 +1005,6 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
 {
 size_t i, j;
 virDomainPCIConnectFlags flags = 0; /* initialize to quiet gcc warning */
-virPCIDeviceAddress tmp_addr;
 
 /* PCI controllers */
 for (i = 0; i < def->ncontrollers; i++) {
@@ -1113,7 +1112,6 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
 virPCIDeviceAddress addr = {0};
 bool foundAddr = false;
 
-memset(_addr, 0, sizeof(tmp_addr));
 for (j = 0; j < def->ncontrollers; j++) {
 if (IS_USB2_CONTROLLER(def->controllers[j]) &&
 def->controllers[j]->idx == cont->idx &&
@@ -1143,26 +1141,25 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
 break;
 }
 
-if (!foundAddr) {
-/* This is the first part of the controller, so need
- * to find a free slot & then reserve a function */
-if (virDomainPCIAddressGetNextSlot(addrs, _addr, flags) < 
0)
+if (foundAddr) {
+/* Reserve this function on the slot we found */
+if (virDomainPCIAddressReserveAddr(addrs, , flags,
+   false, true) < 0)
 goto error;
 
-addr.bus = tmp_addr.bus;
-addr.slot = tmp_addr.slot;
+cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+cont->info.addr.pci = addr;
+} else {
+/* This is the first part of the controller, so need
+ * to find a free slot & then reserve this function */
+if (virDomainPCIAddressReserveNextAddr(addrs, >info,
+   flags, addr.function,
+   false) < 0) {
+goto error;
+}
 
-addrs->lastaddr = addr;
-addrs->lastaddr.function = 0;
-addrs->lastaddr.multi = VIR_TRISTATE_SWITCH_ABSENT;
+cont->info.addr.pci.multi = addr.multi;
 }
-/* Finally we can reserve the slot+function */
-if (virDomainPCIAddressReserveAddr(addrs, , flags,
-   false, foundAddr) < 0)
-goto error;
-
-cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-cont->info.addr.pci = addr;
 } else {
 if (virDomainPCIAddressReserveNextSlot(addrs,
>info, flags) < 0) {
-- 
2.7.4

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