mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
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:
parent
6869b59709
commit
4e8468045c
@ -1,7 +1,7 @@
|
||||
#
|
||||
# These symbols are dependent upon --with-openvz via WITH_OPENVZ
|
||||
#
|
||||
|
||||
openvzReadConfigParam;
|
||||
openvzReadNetworkConf;
|
||||
openvzLocateConfFile;
|
||||
openvzVEGetStringParam;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -24,5 +24,6 @@
|
||||
# define OPENVZ_UTIL_H
|
||||
|
||||
long openvzKBPerPages(void);
|
||||
char *openvzVEGetStringParam(virDomainPtr dom, const char *param);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user