-- v2: use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-domain-disk.c | 50 +++++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-disk.h | 25 ++++++++++++ libvirt-gconfig/libvirt-gconfig.sym | 6 +++ 3 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c index 41f456b..cf7e481 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c @@ -27,6 +27,8 @@ #include <libxml/tree.h> #include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h" +#include "libvirt-gconfig/libvirt-gconfig-object-private.h" extern gboolean debugFlag; @@ -79,3 +81,51 @@ GVirConfigDomainDisk *gvir_config_domain_disk_new_from_xml(const gchar *xml, "disk", NULL, xml, error); return GVIR_CONFIG_DOMAIN_DISK(object); } + +void gvir_config_domain_disk_set_type(GVirConfigDomainDisk *disk, + GVirConfigDomainDiskType type) +{ + xmlNodePtr node; + const char *type_str; + + g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DISK(disk)); + + node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); + g_return_if_fail(node != NULL); + type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DOMAIN_DISK_TYPE, + type); + g_return_if_fail(type_str != NULL); + xmlNewProp(node, (xmlChar*)"type", (xmlChar*)type_str); +} + +void gvir_config_domain_disk_set_guest_device_type(GVirConfigDomainDisk *disk, + GVirConfigDomainDiskGuestDeviceType type) +{ + xmlNodePtr node; + const char *type_str; + + g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DISK(disk)); + + node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); + g_return_if_fail(node != NULL); + type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DOMAIN_DISK_GUEST_DEVICE_TYPE, + type); + g_return_if_fail(type_str != NULL); + xmlNewProp(node, (xmlChar*)"device", (xmlChar*)type_str); +} + +void gvir_config_domain_disk_set_snapshot_type(GVirConfigDomainDisk *disk, + GVirConfigDomainDiskSnapshotType type) +{ + xmlNodePtr node; + const char *type_str; + + g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DISK(disk)); + + node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); + g_return_if_fail(node != NULL); + type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DOMAIN_DISK_SNAPSHOT_TYPE, + type); + g_return_if_fail(type_str != NULL); + xmlNewProp(node, (xmlChar*)"snapshot", (xmlChar*)type_str); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.h b/libvirt-gconfig/libvirt-gconfig-domain-disk.h index 98835f7..e9428ea 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-disk.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.h @@ -56,6 +56,24 @@ struct _GVirConfigDomainDiskClass gpointer padding[20]; }; +typedef enum { + GVIR_CONFIG_DOMAIN_DISK_FILE, + GVIR_CONFIG_DOMAIN_DISK_BLOCK, + GVIR_CONFIG_DOMAIN_DISK_DIR, + GVIR_CONFIG_DOMAIN_DISK_NETWORK +} GVirConfigDomainDiskType; + +typedef enum { + GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_DISK, + GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_FLOPPY, + GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_CDROM +} GVirConfigDomainDiskGuestDeviceType; + +typedef enum { + GVIR_CONFIG_DOMAIN_DISK_SNAPSHOT_NO, + GVIR_CONFIG_DOMAIN_DISK_SNAPSHOT_INTERNAL, + GVIR_CONFIG_DOMAIN_DISK_SNAPSHOT_EXTERNAL +} GVirConfigDomainDiskSnapshotType; GType gvir_config_domain_disk_get_type(void); @@ -63,6 +81,13 @@ GVirConfigDomainDisk *gvir_config_domain_disk_new(void); GVirConfigDomainDisk *gvir_config_domain_disk_new_from_xml(const gchar *xml, GError **error); +void gvir_config_domain_disk_set_type(GVirConfigDomainDisk *disk, + GVirConfigDomainDiskType type); +void gvir_config_domain_disk_set_guest_device_type(GVirConfigDomainDisk *disk, + GVirConfigDomainDiskGuestDeviceType type); +void gvir_config_domain_disk_set_snapshot_type(GVirConfigDomainDisk *disk, + GVirConfigDomainDiskSnapshotType type); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_DISK_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 1bc03ec..258c1f3 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -29,8 +29,14 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_domain_device_get_type; gvir_config_domain_disk_get_type; + gvir_config_domain_disk_guest_device_type_get_type; + gvir_config_domain_disk_snapshot_type_get_type; + gvir_config_domain_disk_type_get_type; gvir_config_domain_disk_new; gvir_config_domain_disk_new_from_xml; + gvir_config_domain_disk_set_snapshot_type; + gvir_config_domain_disk_set_guest_device_type; + gvir_config_domain_disk_set_type; gvir_config_domain_os_get_type; gvir_config_domain_os_boot_device_get_type; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list