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

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

 



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

--
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]