[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 3/5] openvz: Add openvzVEGetStringParam



to retrieve a VEs config parameters as a single string. This will be
used by the upcoming domainGetHostname implementation.
---
 src/libvirt_openvz.syms  |    2 +-
 src/openvz/openvz_util.c |   31 +++++++++++++++++++++++++++++++
 src/openvz/openvz_util.h |    1 +
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/libvirt_openvz.syms b/src/libvirt_openvz.syms
index 11c5587..1993eb5 100644
--- a/src/libvirt_openvz.syms
+++ b/src/libvirt_openvz.syms
@@ -1,7 +1,7 @@
 #
 # These symbols are dependent upon --with-openvz via WITH_OPENVZ
 #
-
 openvzReadConfigParam;
 openvzReadNetworkConf;
 openvzLocateConfFile;
+openvzVEGetStringParam;
diff --git a/src/openvz/openvz_util.c b/src/openvz/openvz_util.c
index 61b55de..b172104 100644
--- a/src/openvz/openvz_util.c
+++ b/src/openvz/openvz_util.c
@@ -26,6 +26,9 @@
 #include "internal.h"
 
 #include "virterror_internal.h"
+#include "command.h"
+#include "datatypes.h"
+#include "memory.h"
 
 #include "openvz_conf.h"
 #include "openvz_util.h"
@@ -49,3 +52,31 @@ openvzKBPerPages(void)
     }
     return kb_per_pages;
 }
+
+char*
+openvzVEGetStringParam(virDomainPtr domain, const char* param)
+{
+    int status, len;
+    char *output = NULL;
+
+    virCommandPtr cmd = virCommandNewArgList(VZLIST,
+                                             "-o",
+                                             param,
+                                             domain->name,
+                                             "-H" , NULL);
+
+    virCommandSetOutputBuffer(cmd, &output);
+    if (virCommandRun(cmd, &status)) {
+        openvzError(VIR_ERR_OPERATION_FAILED,
+                    _("Failed to get %s for %s: %d"), param, domain->name,
+                    status);
+        VIR_FREE(output);
+    }
+    len = strlen(output);
+    /* delete trailing newline */
+    if (len)
+        output[len-1] = '\0';
+
+    virCommandFree(cmd);
+    return output;
+}
diff --git a/src/openvz/openvz_util.h b/src/openvz/openvz_util.h
index a0d9bbb..6a991f3 100644
--- a/src/openvz/openvz_util.h
+++ b/src/openvz/openvz_util.h
@@ -24,5 +24,6 @@
 # define OPENVZ_UTIL_H
 
 long openvzKBPerPages(void);
+char* openvzVEGetStringParam(virDomainPtr dom, const char *param);
 
 #endif
-- 
1.7.10.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]