-- v2: use g_return_if_fail to test function args for sanity v3: fix typo in gvir_config_domain_clock_set_variable_offset ("timezone" -> "adjustment") --- libvirt-gconfig/libvirt-gconfig-domain-clock.c | 38 ++++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-clock.h | 5 +++ libvirt-gconfig/libvirt-gconfig.sym | 2 + 3 files changed, 45 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-clock.c b/libvirt-gconfig/libvirt-gconfig-domain-clock.c index 6642742..7c7381b 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-clock.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-clock.c @@ -27,6 +27,7 @@ #include <libxml/tree.h> #include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-object-private.h" extern gboolean debugFlag; @@ -79,3 +80,40 @@ GVirConfigDomainClock *gvir_config_domain_clock_new_from_xml(const gchar *xml, "clock", NULL, xml, error); return GVIR_CONFIG_DOMAIN_CLOCK(object); } + +void gvir_config_domain_clock_set_timezone(GVirConfigDomainClock *klock, + const char *tz) +{ + xmlNodePtr node; + xmlChar *encoded_tz; + + g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_CLOCK(klock)); + g_return_if_fail(tz != NULL); + + node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock)); + if (node == NULL) + return; + + xmlNewProp(node, (xmlChar*)"offset", (xmlChar*)"timezone"); + encoded_tz = xmlEncodeEntitiesReentrant(node->doc, (xmlChar*)tz); + xmlNewProp(node, (xmlChar*)"timezone", encoded_tz); + xmlFree(encoded_tz); +} + +void gvir_config_domain_clock_set_variable_offset(GVirConfigDomainClock *klock, + gint seconds) +{ + xmlNodePtr node; + char *offset_str; + + g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_CLOCK(klock)); + + node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(klock), "clock"); + if (node == NULL) + return; + + xmlNewProp(node, (xmlChar*)"offset", (xmlChar*)"variable"); + offset_str = g_strdup_printf("%d", seconds); + xmlNewProp(node, (xmlChar*)"adjustment", (xmlChar*)offset_str); + g_free(offset_str); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-clock.h b/libvirt-gconfig/libvirt-gconfig-domain-clock.h index 7b22ff8..588bb10 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-clock.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-clock.h @@ -62,6 +62,11 @@ 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); +void gvir_config_domain_clock_set_timezone(GVirConfigDomainClock *klock, + const char *tz); +void gvir_config_domain_clock_set_variable_offset(GVirConfigDomainClock *klock, + gint seconds); + G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 9d779b5..7ee4282 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -17,6 +17,8 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_domain_clock_get_type; gvir_config_domain_clock_new; gvir_config_domain_clock_new_from_xml; + gvir_config_domain_clock_set_timezone; + gvir_config_domain_clock_set_variable_offset; gvir_config_domain_snapshot_get_type; gvir_config_domain_snapshot_new; -- 1.7.7.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list