
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@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org