x86_iommu/amd: Add interrupt remap support when VAPIC is not enabled
[qemu/ar7.git] / hw / s390x / tod-kvm.c
blobdf564ab89c17a28ccab316a42f0faffa1328c691
1 /*
2 * TOD (Time Of Day) clock - KVM implementation
4 * Copyright 2018 Red Hat, Inc.
5 * Author(s): David Hildenbrand <david@redhat.com>
7 * This work is licensed under the terms of the GNU GPL, version 2 or later.
8 * See the COPYING file in the top-level directory.
9 */
11 #include "qemu/osdep.h"
12 #include "qapi/error.h"
13 #include "hw/s390x/tod.h"
14 #include "kvm_s390x.h"
16 static void kvm_s390_tod_get(const S390TODState *td, S390TOD *tod, Error **errp)
18 int r;
20 r = kvm_s390_get_clock_ext(&tod->high, &tod->low);
21 if (r == -ENXIO) {
22 r = kvm_s390_get_clock(&tod->high, &tod->low);
24 if (r) {
25 error_setg(errp, "Unable to get KVM guest TOD clock: %s",
26 strerror(-r));
30 static void kvm_s390_tod_set(S390TODState *td, const S390TOD *tod, Error **errp)
32 int r;
34 r = kvm_s390_set_clock_ext(tod->high, tod->low);
35 if (r == -ENXIO) {
36 r = kvm_s390_set_clock(tod->high, tod->low);
38 if (r) {
39 error_setg(errp, "Unable to set KVM guest TOD clock: %s",
40 strerror(-r));
44 static void kvm_s390_tod_class_init(ObjectClass *oc, void *data)
46 S390TODClass *tdc = S390_TOD_CLASS(oc);
48 tdc->get = kvm_s390_tod_get;
49 tdc->set = kvm_s390_tod_set;
52 static TypeInfo kvm_s390_tod_info = {
53 .name = TYPE_KVM_S390_TOD,
54 .parent = TYPE_S390_TOD,
55 .instance_size = sizeof(S390TODState),
56 .class_init = kvm_s390_tod_class_init,
57 .class_size = sizeof(S390TODClass),
60 static void register_types(void)
62 type_register_static(&kvm_s390_tod_info);
64 type_init(register_types);