Re: [PATCH 4/5] openvz: Implement domainGetHostname

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

 



On 07/10/2012 02:46 PM, Guido Günther wrote:
> If the container doesn't have the hostname parameter set an empty string
> ("") is returned.

I'd almost rather return NULL and an error code (either invent a new
error, or maybe reuse VIR_ERR_OPERATION_FAILED) than an empty string if
we fail to get the information.

> +static char* openvzDomainGetHostname(virDomainPtr dom, unsigned int flags)
> +{
> +    char *hostname = NULL;
> +
> +    virCheckFlags(0, NULL);
> +
> +    hostname = openvzVEGetStringParam(dom, "hostname");
> +    if (hostname == NULL)
> +        goto cleanup;
> +
> +    /* vzlist prints an unset hostname as '-' */
> +    if (strlen(hostname) == 1 && hostname[0] == '-') {

More efficient to write:

if (STREQ(hostname, "-")) {

> @@ -2127,6 +2154,7 @@ static virDriver openvzDriver = {
>      .domainIsUpdated = openvzDomainIsUpdated, /* 0.8.6 */
>      .isAlive = openvzIsAlive, /* 0.9.8 */
>      .domainUpdateDeviceFlags = openvzDomainUpdateDeviceFlags, /* 0.9.13 */
> +    .domainGetHostname = openvzDomainGetHostname, /* 0.9.14 */

Again, a global version cleanup would fix this to 0.10.0.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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