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.
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
)
20 r
= kvm_s390_get_clock_ext(&tod
->high
, &tod
->low
);
22 r
= kvm_s390_get_clock(&tod
->high
, &tod
->low
);
25 error_setg(errp
, "Unable to get KVM guest TOD clock: %s",
30 static void kvm_s390_tod_set(S390TODState
*td
, const S390TOD
*tod
, Error
**errp
)
34 r
= kvm_s390_set_clock_ext(tod
->high
, tod
->low
);
36 r
= kvm_s390_set_clock(tod
->high
, tod
->low
);
39 error_setg(errp
, "Unable to set KVM guest TOD clock: %s",
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
);