summaryrefslogtreecommitdiffstats
path: root/qga/commands-posix.c
diff options
context:
space:
mode:
authorPeter Maydell2019-12-16 11:35:33 +0100
committerPeter Maydell2019-12-16 11:35:33 +0100
commit7697ac55fcc6178fd8fd8aa22baed13a0c8ca942 (patch)
treea2074ffa2e47a353f385d079bf5c343ab7dea64e /qga/commands-posix.c
parentMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into ... (diff)
parentqga: fence guest-set-time if hwclock not available (diff)
downloadqemu-7697ac55fcc6178fd8fd8aa22baed13a0c8ca942.tar.gz
qemu-7697ac55fcc6178fd8fd8aa22baed13a0c8ca942.tar.xz
qemu-7697ac55fcc6178fd8fd8aa22baed13a0c8ca942.zip
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20191214-2' into staging
First s390x update for 5.0: - compat machines (also for other architectures) - cleanups and fixes in reset handling - fence off guest-set-time, as we have no hwclock - fix some misuses of the error API - further cleanups # gpg: Signature made Sat 14 Dec 2019 09:33:17 GMT # gpg: using RSA key C3D0D66DC3624FF6A8C018CEDECF6B93C6F02FAF # gpg: issuer "cohuck@redhat.com" # gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" [unknown] # gpg: aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" [full] # gpg: aka "Cornelia Huck <cornelia.huck@de.ibm.com>" [full] # gpg: aka "Cornelia Huck <cohuck@kernel.org>" [unknown] # gpg: aka "Cornelia Huck <cohuck@redhat.com>" [unknown] # Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0 18CE DECF 6B93 C6F0 2FAF * remotes/cohuck/tags/s390x-20191214-2: qga: fence guest-set-time if hwclock not available s390x/tcg: clear local interrupts on reset normal s390x/cpumodel: Fix query-cpu-definitions error API violations s390x/cpumodel: Fix query-cpu-model-FOO error API violations s390x/cpumodel: Fix realize() error API violations s390x/cpumodel: Fix feature property error API violations s390x/event-facility: Fix realize() error API violations s390x: Fix cpu normal reset ri clearing s390x: kvm: Make kvm_sclp_service_call void s390x: Beautify diag308 handling s390x: Move clear reset s390x: Move initial reset s390x: Move reset normal to shared reset handler s390x: Don't do a normal reset on the initial cpu hw: add compat machines for 5.0 vfio-ccw: Fix error message Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qga/commands-posix.c')
-rw-r--r--qga/commands-posix.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 1c1a165dae..0be301a4ea 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -156,6 +156,17 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
pid_t pid;
Error *local_err = NULL;
struct timeval tv;
+ static const char hwclock_path[] = "/sbin/hwclock";
+ static int hwclock_available = -1;
+
+ if (hwclock_available < 0) {
+ hwclock_available = (access(hwclock_path, X_OK) == 0);
+ }
+
+ if (!hwclock_available) {
+ error_setg(errp, QERR_UNSUPPORTED);
+ return;
+ }
/* If user has passed a time, validate and set it. */
if (has_time) {
@@ -195,7 +206,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
/* Use '/sbin/hwclock -w' to set RTC from the system time,
* or '/sbin/hwclock -s' to set the system time from RTC. */
- execle("/sbin/hwclock", "hwclock", has_time ? "-w" : "-s",
+ execle(hwclock_path, "hwclock", has_time ? "-w" : "-s",
NULL, environ);
_exit(EXIT_FAILURE);
} else if (pid < 0) {