--
v2: use g_return_if_fail to test function args for sanity
---
libvirt-gconfig/libvirt-gconfig-device-disk.c | 50 +
libvirt-gconfig/libvirt-gconfig-device-disk.h | 25
libvirt-gconfig/libvirt-gconfig.sym |6 +++
3 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.c
b/libvirt-gconfig/libvirt-gconfig-device-disk.c
index 44c1f8e..e34e9a0 100644
--- a/libvirt-gconfig/libvirt-gconfig-device-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c
@@ -27,6 +27,8 @@
#include
#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 @@ GVirConfigDeviceDisk
*gvir_config_device_disk_new_from_xml(const gchar *xml,
"disk", NULL, xml, error);
return GVIR_CONFIG_DEVICE_DISK(object);
}
+
+void gvir_config_device_disk_set_type(GVirConfigDeviceDisk *disk,
+ GVirConfigDeviceDiskType type)
+{
+xmlNodePtr node;
+const char *type_str;
+
+g_return_if_fail(GVIR_IS_CONFIG_DEVICE_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_DEVICE_DISK_TYPE,
+ type);
+g_return_if_fail(type_str != NULL);
+xmlNewProp(node, (xmlChar*)"type", (xmlChar*)type_str);
+}
+
+void gvir_config_device_disk_set_guest_device_type(GVirConfigDeviceDisk *disk,
+
GVirConfigDeviceDiskGuestDeviceType type)
+{
+xmlNodePtr node;
+const char *type_str;
+
+g_return_if_fail(GVIR_IS_CONFIG_DEVICE_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_DEVICE_DISK_GUEST_DEVICE_TYPE,
+ type);
+g_return_if_fail(type_str != NULL);
+xmlNewProp(node, (xmlChar*)"device", (xmlChar*)type_str);
+}
+
+void gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk,
+
GVirConfigDeviceDiskSnapshotType type)
+{
+xmlNodePtr node;
+const char *type_str;
+
+g_return_if_fail(GVIR_IS_CONFIG_DEVICE_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_DEVICE_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-device-disk.h
b/libvirt-gconfig/libvirt-gconfig-device-disk.h
index ef771d5..e597815 100644
--- a/libvirt-gconfig/libvirt-gconfig-device-disk.h
+++ b/libvirt-gconfig/libvirt-gconfig-device-disk.h
@@ -56,6 +56,24 @@ struct _GVirConfigDeviceDiskClass
gpointer padding[20];
};
+typedef enum {
+GVIR_CONFIG_DEVICE_DISK_FILE,
+GVIR_CONFIG_DEVICE_DISK_BLOCK,
+GVIR_CONFIG_DEVICE_DISK_DIR,
+GVIR_CONFIG_DEVICE_DISK_NETWORK
+} GVirConfigDeviceDiskType;
+
+typedef enum {
+GVIR_CONFIG_DEVICE_DISK_GUEST_DEVICE_DISK,
+GVIR_CONFIG_DEVICE_DISK_GUEST_DEVICE_FLOPPY,
+GVIR_CONFIG_DEVICE_DISK_GUEST_DEVICE_CDROM
+} GVirConfigDeviceDiskGuestDeviceType;
+
+typedef enum {
+GVIR_CONFIG_DEVICE_DISK_SNAPSHOT_NO,
+GVIR_CONFIG_DEVICE_DISK_SNAPSHOT_INTERNAL,
+GVIR_CONFIG_DEVICE_DISK_SNAPSHOT_EXTERNAL
+} GVirConfigDeviceDiskSnapshotType;
GType gvir_config_device_disk_get_type(void);
@@ -63,6 +81,13 @@ GVirConfigDeviceDisk *gvir_config_device_disk_new(void);
GVirConfigDeviceDisk *gvir_config_device_disk_new_from_xml(const gchar *xml,
GError **error);
+void gvir_config_device_disk_set_type(GVirConfigDeviceDisk *disk,
+ GVirConfigDeviceDiskType type);
+void gvir_config_device_disk_set_guest_device_type(GVirConfigDeviceDisk *disk,
+
GVirConfigDeviceDiskGuestDeviceType type);
+void gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk,
+
GVirConfigDeviceDiskSnapshotType type);
+
G_END_DECLS
#endif /* __LIBVIRT_GCONFIG_DEVICE_DISK_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.sym
b/libvirt-gconfig/libvirt-gconfig.sym
index b0e752a..f059f9d 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -15,8 +15,14 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_config_device_get_type;
gvir_config_device_disk_get_type;
+ gvir_config_device_disk_guest_device_t