Re: [libvirt] [PATCH 3/3] test: Support virNodeDeviceCreate and virNodeDeviceDestroy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/17/2009 09:10 AM, Matthias Bolte wrote:
> 2009/10/16 Cole Robinson <crobinso@xxxxxxxxxx>:
>>
>> Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
>> ---
>> Â src/test/test_driver.c | Â 129 +++++++++++++++++++++++++++++++++++++++++++++++-
>> Â 1 files changed, 127 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
>> index 0541a73..888bc9c 100644
>> --- a/src/test/test_driver.c
>> +++ b/src/test/test_driver.c
>> @@ -4376,6 +4376,131 @@ cleanup:
>> Â  Â  return ret;
>> Â }
>>
>> +static virNodeDevicePtr
>> +testNodeDeviceCreateXML(virConnectPtr conn,
>> + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â const char *xmlDesc,
>> + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â unsigned int flags ATTRIBUTE_UNUSED)
>> +{
>> + Â  Â testConnPtr driver = conn->privateData;
>> + Â  Â virNodeDeviceDefPtr def = NULL;
>> + Â  Â virNodeDeviceObjPtr obj = NULL;
>> + Â  Â char *wwnn = NULL, *wwpn = NULL;
>> + Â  Â int parent_host = -1;
>> + Â  Â virNodeDevicePtr dev = NULL;
>> + Â  Â virNodeDevCapsDefPtr caps;
>> +
>> + Â  Â testDriverLock(driver);
>> +
>> + Â  Â def = virNodeDeviceDefParseString(conn, xmlDesc, CREATE_DEVICE);
>> + Â  Â if (def == NULL) {
>> + Â  Â  Â  Â goto cleanup;
>> + Â  Â }
>> +
>> + Â  Â /* We run these next two simply for validation */
>> + Â  Â if (virNodeDeviceGetWWNs(conn, def, &wwnn, &wwpn) == -1) {
>> + Â  Â  Â  Â goto cleanup;
>> + Â  Â }
>> +
>> + Â  Â if (virNodeDeviceGetParentHost(conn,
>> + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  &driver->devs,
>> + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  def->name,
>> + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  def->parent,
>> + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  &parent_host) == -1) {
>> + Â  Â  Â  Â goto cleanup;
>> + Â  Â }
>> +
>> + Â  Â /* 'name' is supposed to be filled in by the node device backend, which
>> + Â  Â  * we don't have. Use WWPN instead. */
>> + Â  Â VIR_FREE(def->name);
>> + Â  Â if (!(def->name = strdup(wwpn))) {
>> + Â  Â  Â  Â virReportOOMError(dev->conn);
> 
> dev is NULL here, call virReportOOMError(conn) instead.
> 
>> + Â  Â  Â  Â goto cleanup;
>> + Â  Â }
>> +
>> + Â  Â /* Fill in a random 'host' value, since this would also come from
>> + Â  Â  * the backend */
>> + Â  Â caps = def->caps;
>> + Â  Â while (caps) {
>> + Â  Â  Â  Â if (caps->type != VIR_NODE_DEV_CAP_SCSI_HOST)
>> + Â  Â  Â  Â  Â  Â continue;
>> +
>> + Â  Â  Â  Â caps->data.scsi_host.host = virRandom(1024);
>> + Â  Â  Â  Â caps = caps->next;
>> + Â  Â }
>> +
>> +
>> + Â  Â if (!(obj = virNodeDeviceAssignDef(conn, &driver->devs, def))) {
>> + Â  Â  Â  Â goto cleanup;
>> + Â  Â }
>> + Â  Â virNodeDeviceObjUnlock(obj);
>> +
>> + Â  Â dev = virGetNodeDevice(conn, def->name);
>> + Â  Â def = NULL;
>> +cleanup:
>> + Â  Â testDriverUnlock(driver);
>> + Â  Â if (def)
>> + Â  Â  Â  Â virNodeDeviceDefFree(def);
>> + Â  Â VIR_FREE(wwnn);
>> + Â  Â VIR_FREE(wwpn);
>> + Â  Â return dev;
>> +}
>> +
> 
> ACK
> 
> Matthias

I've pushed this with the fix you pointed out.

Thanks,
Cole

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]