If the container doesn't have the hostname parameter set an empty string ("") is returned. --- src/openvz/openvz_driver.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index c9150e0..469d043 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -234,6 +234,33 @@ cleanup: } +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] == '-') { + VIR_FREE(hostname); + hostname = strdup(""); + if (hostname == NULL) { + virReportOOMError(); + goto cleanup; + } + } + return hostname; + +cleanup: + VIR_FREE(hostname); + return NULL; +} + + static virDomainPtr openvzDomainLookupByID(virConnectPtr conn, int id) { struct openvz_driver *driver = conn->privateData; @@ -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 */ }; int openvzRegister(void) { -- 1.7.10.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list