aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2012-07-10 09:34:23 +0200
committerGuido Günther <agx@sigxcpu.org>2012-07-20 21:54:34 +0200
commita91067fa0d92e2716db32e0db07b3e4f3623fa90 (patch)
tree1506c2a7621db0733e21386f76e30bb559cb9649 /src/libvirt.c
parentReport 'errno' in int1 field of virErrorPtr (diff)
downloadlibvirt-a91067fa0d92e2716db32e0db07b3e4f3623fa90.tar.gz
libvirt-a91067fa0d92e2716db32e0db07b3e4f3623fa90.tar.bz2
libvirt-a91067fa0d92e2716db32e0db07b3e4f3623fa90.zip
Add virDomainGetHostname
to query a guests's hostname. Containers like LXC and OpenVZ allow to set a hostname different from the hosts name and QEMU's guest agent could provide similar functionality.
Diffstat (limited to 'src/libvirt.c')
-rw-r--r--src/libvirt.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/libvirt.c b/src/libvirt.c
index df78e8aca..8315b4fca 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -18977,3 +18977,48 @@ error:
virDispatchError(dom->conn);
return -1;
}
+
+/**
+ * virDomainGetHostname:
+ * @domain: a domain object
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Get the hostname for that domain.
+ *
+ * Dependent on hypervisor used, this may require a guest agent to be
+ * available.
+ *
+ * Returns the hostname which must be freed by the caller, or
+ * NULL if there was an error.
+ */
+char *
+virDomainGetHostname(virDomainPtr domain, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return NULL;
+ }
+
+ conn = domain->conn;
+
+ if (conn->driver->domainGetHostname) {
+ char *ret;
+ ret = conn->driver->domainGetHostname (domain, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(domain->conn);
+ return NULL;
+}