openvz: Add openvzVEGetStringParam

to retrieve a VEs config parameters as a single string. This will be
used by the upcoming domainGetHostname implementation.
This commit is contained in:
Guido Günther 2012-07-10 13:57:38 +02:00
parent 6869b59709
commit 4e8468045c
3 changed files with 34 additions and 1 deletions

View File

@ -1,7 +1,7 @@
#
# These symbols are dependent upon --with-openvz via WITH_OPENVZ
#
openvzReadConfigParam;
openvzReadNetworkConf;
openvzLocateConfFile;
openvzVEGetStringParam;

View File

@ -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"
@ -50,3 +53,32 @@ openvzKBPerPages(void)
}
return kb_per_pages;
}
char*
openvzVEGetStringParam(virDomainPtr domain, const char* param)
{
int len;
char *output = NULL;
virCommandPtr cmd = virCommandNewArgList(VZLIST,
"-o",
param,
domain->name,
"-H" , NULL);
virCommandSetOutputBuffer(cmd, &output);
if (virCommandRun(cmd, NULL) < 0) {
VIR_FREE(output);
/* virCommandRun sets the virError */
goto cleanup;
}
/* delete trailing newline */
len = strlen(output);
if (len && output[len - 1] == '\n')
output[len - 1] = '\0';
cleanup:
virCommandFree(cmd);
return output;
}

View File

@ -24,5 +24,6 @@
# define OPENVZ_UTIL_H
long openvzKBPerPages(void);
char *openvzVEGetStringParam(virDomainPtr dom, const char *param);
#endif