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

Eric Blake eblake at redhat.com
Tue Jul 10 21:13:03 UTC 2012


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 at 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: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120710/cb2e6643/attachment-0001.sig>


More information about the libvir-list mailing list