[libvirt] [PATCH] testNodeDeviceMockCreateVport: Don't call public APIs
Michal Privoznik
mprivozn at redhat.com
Wed Mar 1 08:35:11 UTC 2017
On 02/28/2017 03:24 PM, John Ferlan wrote:
>
>
> On 02/28/2017 07:12 AM, Michal Privoznik wrote:
>> This function is calling public APIs (virNodeDeviceLookupByName
>> etc.). That requires the driver lock to be unlocked and locked
>> again. If we, however, replace the public APIs calls with the
>> internal calls (that public APIs call anyway), we can drop the
>> lock/unlock exercise.
>>
>> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>> ---
>> src/test/test_driver.c | 59 ++++++++++++++++++++++++++++----------------------
>> 1 file changed, 33 insertions(+), 26 deletions(-)
>>
>> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
>> index 5fef3f10b..8495443db 100644
>> --- a/src/test/test_driver.c
>> +++ b/src/test/test_driver.c
>> @@ -5626,17 +5626,16 @@ testNodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
>> }
>>
>>
>> -static virNodeDeviceDefPtr
>> +static virNodeDeviceObjPtr
>> testNodeDeviceMockCreateVport(virConnectPtr conn,
>
> Conceptually this could take the driver instead of conn since all conn
> is used for is to get driver. I see testObjectEventQueue does this...
Ah, good point. I'll fix that before pushing.
>
>> const char *wwnn,
>> const char *wwpn)
>> {
>> testDriverPtr driver = conn->privateData;
>> - virNodeDevicePtr devcpy = NULL;
>> char *xml = NULL;
>> virNodeDeviceDefPtr def = NULL;
>> virNodeDevCapsDefPtr caps;
>> - virNodeDeviceObjPtr obj = NULL;
>> + virNodeDeviceObjPtr obj = NULL, objcopy = NULL;
>
> There are those that prefer separate lines for each, IDC, but I usually
> just capitulate to keep the peace.
I don't really understand why. Multiple variables per line is just fine.
Michal
More information about the libvir-list
mailing list