--- libvirt-gconfig/libvirt-gconfig-domain-clock.c | 35 ++++++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-clock.h | 3 +++ libvirt-gconfig/libvirt-gconfig-domain.c | 24 ++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 5 ++++ libvirt-gconfig/tests/test-domain-create.c | 11 +++++++- 6 files changed, 78 insertions(+), 1 deletion(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-clock.c b/libvirt-gconfig/libvirt-gconfig-domain-clock.c index 7235ed8..12516c7 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-clock.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-clock.c @@ -69,6 +69,20 @@ GVirConfigDomainClock *gvir_config_domain_clock_new_from_xml(const gchar *xml, return GVIR_CONFIG_DOMAIN_CLOCK(object); } + +GVirConfigDomainClockOffset +gvir_config_domain_clock_get_offset(GVirConfigDomainClock *klock) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_CLOCK(klock), + GVIR_CONFIG_DOMAIN_CLOCK_UTC); + + return gvir_config_object_get_attribute_genum(GVIR_CONFIG_OBJECT(klock), + NULL, "offset", + GVIR_CONFIG_TYPE_DOMAIN_CLOCK_OFFSET, + GVIR_CONFIG_DOMAIN_CLOCK_UTC); +} + + void gvir_config_domain_clock_set_offset(GVirConfigDomainClock *klock, GVirConfigDomainClockOffset offset) { @@ -81,6 +95,16 @@ void gvir_config_domain_clock_set_offset(GVirConfigDomainClock *klock, NULL); } + +const char *gvir_config_domain_clock_get_timezone(GVirConfigDomainClock *klock) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_CLOCK(klock), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(klock), + NULL, "timezone"); +} + + void gvir_config_domain_clock_set_timezone(GVirConfigDomainClock *klock, const char *tz) { @@ -91,6 +115,16 @@ void gvir_config_domain_clock_set_timezone(GVirConfigDomainClock *klock, "timezone", tz, NULL); } + +int gvir_config_domain_clock_get_variable_offset(GVirConfigDomainClock *klock) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_CLOCK(klock), 0); + + return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(klock), + NULL, "adjustment", 0); +} + + void gvir_config_domain_clock_set_variable_offset(GVirConfigDomainClock *klock, gint seconds) { @@ -102,6 +136,7 @@ void gvir_config_domain_clock_set_variable_offset(GVirConfigDomainClock *klock, NULL); } + void gvir_config_domain_clock_add_timer(GVirConfigDomainClock *klock, GVirConfigDomainTimer *timer) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-clock.h b/libvirt-gconfig/libvirt-gconfig-domain-clock.h index d58ec03..8a30ffc 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-clock.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-clock.h @@ -70,10 +70,13 @@ GType gvir_config_domain_clock_get_type(void); GVirConfigDomainClock *gvir_config_domain_clock_new(void); GVirConfigDomainClock *gvir_config_domain_clock_new_from_xml(const gchar *xml, GError **error); +GVirConfigDomainClockOffset gvir_config_domain_clock_get_offset(GVirConfigDomainClock *klock); void gvir_config_domain_clock_set_offset(GVirConfigDomainClock *klock, GVirConfigDomainClockOffset offset); +const char *gvir_config_domain_clock_get_timezone(GVirConfigDomainClock *klock); void gvir_config_domain_clock_set_timezone(GVirConfigDomainClock *klock, const char *tz); +gint gvir_config_domain_clock_get_variable_offset(GVirConfigDomainClock *klock); void gvir_config_domain_clock_set_variable_offset(GVirConfigDomainClock *klock, gint seconds); void gvir_config_domain_clock_add_timer(GVirConfigDomainClock *klock, diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 6cd2f86..702669e 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -543,6 +543,30 @@ void gvir_config_domain_set_features(GVirConfigDomain *domain, g_object_notify(G_OBJECT(domain), "features"); } + +/** + * gvir_config_domain_get_clock: + * @domain: a #GVirConfigDomain + * + * Gets the clock configuration of @domain + * + * Returns: (transfer full): A #GVirConfigDomainClock. The returned + * object should be unreffed with g_object_unref() when no longer needed. + */ +GVirConfigDomainClock *gvir_config_domain_get_clock(GVirConfigDomain *domain) +{ + GVirConfigObject *object; + + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN(domain), NULL); + + object = gvir_config_object_get_child_with_type(GVIR_CONFIG_OBJECT(domain), + "clock", + GVIR_CONFIG_TYPE_DOMAIN_CLOCK); + + return GVIR_CONFIG_DOMAIN_CLOCK(object); +} + + /** * gvir_config_domain_set_clock: * @domain: a #GVirConfigDomain diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h index 6e85374..ed9be6b 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.h +++ b/libvirt-gconfig/libvirt-gconfig-domain.h @@ -119,6 +119,7 @@ void gvir_config_domain_set_vcpus(GVirConfigDomain *domain, GStrv gvir_config_domain_get_features(GVirConfigDomain *domain); void gvir_config_domain_set_features(GVirConfigDomain *domain, const GStrv features); +GVirConfigDomainClock *gvir_config_domain_get_clock(GVirConfigDomain *domain); void gvir_config_domain_set_clock(GVirConfigDomain *domain, GVirConfigDomainClock *klock); GVirConfigDomainOs *gvir_config_domain_get_os(GVirConfigDomain *domain); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 0332d33..46566c1 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -614,6 +614,10 @@ LIBVIRT_GCONFIG_0.1.7 { LIBVIRT_GCONFIG_0.1.8 { global: + gvir_config_domain_clock_get_offset; + gvir_config_domain_clock_get_timezone; + gvir_config_domain_clock_get_variable_offset; + gvir_config_domain_disk_driver_discard_get_type; gvir_config_domain_disk_driver_error_policy_get_type; gvir_config_domain_disk_driver_get_cache; @@ -638,6 +642,7 @@ global: gvir_config_domain_disk_get_driver; gvir_config_domain_disk_set_driver; + gvir_config_domain_get_clock; gvir_config_domain_get_uuid; gvir_config_domain_graphics_desktop_get_display; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index 7ff008e..eb4b945 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -141,7 +141,10 @@ int main(int argc, char **argv) GVirConfigDomainTimerHpet *hpet; klock = gvir_config_domain_clock_new(); - gvir_config_domain_clock_set_offset(klock, GVIR_CONFIG_DOMAIN_CLOCK_UTC); + gvir_config_domain_clock_set_offset(klock, GVIR_CONFIG_DOMAIN_CLOCK_TIMEZONE); + gvir_config_domain_clock_set_timezone(klock, "CEST"); + g_assert(gvir_config_domain_clock_get_offset(klock) == GVIR_CONFIG_DOMAIN_CLOCK_TIMEZONE); + g_str_const_check(gvir_config_domain_clock_get_timezone(klock), "CEST"); pit = gvir_config_domain_timer_pit_new(); gvir_config_domain_timer_set_tick_policy(GVIR_CONFIG_DOMAIN_TIMER(pit), @@ -168,6 +171,12 @@ int main(int argc, char **argv) gvir_config_domain_set_clock(domain, klock); g_object_unref(G_OBJECT(klock)); + klock = gvir_config_domain_get_clock(domain); + g_assert(klock != NULL); + g_assert(gvir_config_domain_clock_get_offset(klock) == GVIR_CONFIG_DOMAIN_CLOCK_TIMEZONE); + g_str_const_check(gvir_config_domain_clock_get_timezone(klock), "CEST"); + g_object_unref(G_OBJECT(klock)); + /* os node */ GVirConfigDomainOs *os; GList *devices = NULL; -- 1.8.4.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list