s390/kvm: Support for get/set of extended TOD-Clock for guest

Provides an interface for getting and setting the guest's extended
TOD-Clock via a single ioctl to kvm. If the ioctl fails because it
is not support by kvm, then we fall back to the old style of
retrieving the clock via two ioctls.

Signed-off-by: Collin L. Walling <walling@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
[split failure change from epoch index change]
Message-Id: <20171004105751.24655-2-borntraeger@de.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
[some cosmetic fixes]
This commit is contained in:
Collin L. Walling 2017-10-04 12:57:50 +02:00 committed by Cornelia Huck
parent 489c909f09
commit 7edd4a4967
4 changed files with 63 additions and 8 deletions

View file

@ -347,22 +347,34 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
int s390_get_clock(uint8_t *tod_high, uint64_t *tod_low)
{
int r = 0;
if (kvm_enabled()) {
return kvm_s390_get_clock(tod_high, tod_low);
r = kvm_s390_get_clock_ext(tod_high, tod_low);
if (r == -ENXIO) {
return kvm_s390_get_clock(tod_high, tod_low);
}
} else {
/* Fixme TCG */
*tod_high = 0;
*tod_low = 0;
}
/* Fixme TCG */
*tod_high = 0;
*tod_low = 0;
return 0;
return r;
}
int s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
{
int r = 0;
if (kvm_enabled()) {
return kvm_s390_set_clock(tod_high, tod_low);
r = kvm_s390_set_clock_ext(tod_high, tod_low);
if (r == -ENXIO) {
return kvm_s390_set_clock(tod_high, tod_low);
}
}
/* Fixme TCG */
return 0;
return r;
}
int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)