]> xenbits.xensource.com Git - libvirt.git/commitdiff
openvz: Implement domainGetHostname
authorGuido Günther <agx@sigxcpu.org>
Tue, 10 Jul 2012 11:58:44 +0000 (13:58 +0200)
committerGuido Günther <agx@sigxcpu.org>
Fri, 20 Jul 2012 19:54:35 +0000 (21:54 +0200)
src/openvz/openvz_driver.c

index 2251b89f0172ab6ba263015df5e5d964e3709e27..a144408d565853d637c358a5ceddbf36460c572a 100644 (file)
@@ -234,6 +234,47 @@ cleanup:
 }
 
 
+static char *
+openvzDomainGetHostname(virDomainPtr dom, unsigned int flags)
+{
+    char *hostname = NULL;
+    struct openvz_driver *driver = dom->conn->privateData;
+    virDomainObjPtr vm;
+
+    virCheckFlags(0, NULL);
+
+    openvzDriverLock(driver);
+    vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+    openvzDriverUnlock(driver);
+
+    if (!vm) {
+        virReportError(VIR_ERR_NO_DOMAIN, "%s",
+                       _("no domain with matching uuid"));
+        goto cleanup;
+    }
+
+    hostname = openvzVEGetStringParam(dom, "hostname");
+    if (hostname == NULL)
+        goto error;
+
+    /* vzlist prints an unset hostname as '-' */
+    if (STREQ(hostname, "-")) {
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("Hostname of '%s' is unset"), vm->def->name);
+        goto error;
+    }
+
+cleanup:
+    if (vm)
+        virDomainObjUnlock(vm);
+    return hostname;
+
+error:
+    VIR_FREE(hostname);
+    goto cleanup;
+}
+
+
 static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
                                            int id) {
     struct openvz_driver *driver = conn->privateData;
@@ -2129,6 +2170,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) {