aboutsummaryrefslogtreecommitdiff
path: root/qga
diff options
context:
space:
mode:
authorTomáš Golembiovský <tgolembi@redhat.com>2017-07-14 16:28:58 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2017-07-18 05:49:01 -0500
commit339ca68bef9f30dd18e84b7d92398327e3f819a3 (patch)
treee76e07bcc25c3aa8475f19fbb86c831182a03bd8 /qga
parentc28afa76c0e2829d1ebe5ad33062d1697bf2710b (diff)
test-qga: add test for guest-get-osinfo
Add test for guest-get-osinfo command. Qemu-ga was modified to accept QGA_OS_RELEASE environment variable. If the variable is defined it is interpreted as path to the os-release file and it is parsed instead of the default paths. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> * move declarations to beginning of functions Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga')
-rw-r--r--qga/commands-posix.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 7b3d89a92c..ab0c63d931 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -2682,7 +2682,8 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
{
GuestOSInfo *info = NULL;
struct utsname kinfo;
- GKeyFile *osrelease;
+ GKeyFile *osrelease = NULL;
+ const char *qga_os_release = g_getenv("QGA_OS_RELEASE");
info = g_new0(GuestOSInfo, 1);
@@ -2697,9 +2698,13 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
info->machine = g_strdup(kinfo.machine);
}
- osrelease = ga_parse_osrelease("/etc/os-release");
- if (osrelease == NULL) {
- osrelease = ga_parse_osrelease("/usr/lib/os-release");
+ if (qga_os_release != NULL) {
+ osrelease = ga_parse_osrelease(qga_os_release);
+ } else {
+ osrelease = ga_parse_osrelease("/etc/os-release");
+ if (osrelease == NULL) {
+ osrelease = ga_parse_osrelease("/usr/lib/os-release");
+ }
}
if (osrelease != NULL) {