[libvirt] [PATCH v2 05/11] qemu: switch PCI address set from hash table to an array
Eric Blake
eblake at redhat.com
Wed Apr 17 22:24:02 UTC 2013
On 04/17/2013 01:00 PM, Ján Tomko wrote:
> Each bus is represented as an array of 32 8-bit integers
> where each bit represents a PCI function and each byte represents
> a PCI slot.
>
> Uses just one bus so far.
> ---
> src/qemu/qemu_command.c | 152 ++++++++++++++----------------------------------
> 1 file changed, 45 insertions(+), 107 deletions(-)
Less code to represent less in-memory storage - nice :)
> @@ -1268,7 +1274,7 @@ static int qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
> if (!(str = qemuPCIAddressAsString(addr)))
> goto cleanup;
>
> - if (virHashLookup(addrs->used, str)) {
> + if (addrs->used[addr->bus][addr->slot] & 1 << addr->function) {
I had to remind myself that << has higher precedence than &; adding ()
might help, although not strictly necessary.
> @@ -1434,48 +1403,47 @@ int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
> {
> char *str;
>
> - str = qemuPCIAddressAsString(addr);
> - if (!str)
> + if (!(str = qemuPCIAddressAsString(addr)))
> return -1;
>
> VIR_DEBUG("Reserving PCI addr %s", str);
>
> - if (virHashLookup(addrs->used, str)) {
> + if (addrs->used[addr->bus][addr->slot] & 1 << addr->function) {
Same comment.
ACK.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130417/c81471d7/attachment-0001.sig>
More information about the libvir-list
mailing list