--
v2: fix gvir_config_device_disk_set_source
use g_return_if_fail to test function args for sanity
---
libvirt-gconfig/libvirt-gconfig-device-disk.c | 78 -
libvirt-gconfig/libvirt-gconfig-device-disk.h | 10 +++
libvirt-gconfig/libvirt-gconfig.sym |7 ++-
3 files changed, 93 insertions(+), 2 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.c
b/libvirt-gconfig/libvirt-gconfig-device-disk.c
index e34e9a0..acfd1ab 100644
--- a/libvirt-gconfig/libvirt-gconfig-device-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c
@@ -39,7 +39,7 @@ extern gboolean debugFlag;
struct _GVirConfigDeviceDiskPrivate
{
-gboolean unused;
+GVirConfigDeviceDiskType type;
};
G_DEFINE_TYPE(GVirConfigDeviceDisk, gvir_config_device_disk,
GVIR_TYPE_CONFIG_DEVICE);
@@ -96,6 +96,7 @@ void gvir_config_device_disk_set_type(GVirConfigDeviceDisk
*disk,
type);
g_return_if_fail(type_str != NULL);
xmlNewProp(node, (xmlChar*)"type", (xmlChar*)type_str);
+disk->priv->type = type;
}
void gvir_config_device_disk_set_guest_device_type(GVirConfigDeviceDisk *disk,
@@ -129,3 +130,78 @@ void
gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk,
g_return_if_fail(type_str != NULL);
xmlNewProp(node, (xmlChar*)"snapshot", (xmlChar*)type_str);
}
+
+void gvir_config_device_disk_set_source(GVirConfigDeviceDisk *disk,
+const char *source)
+{
+xmlNodePtr source_node;
+const char *attribute_name;
+
+g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk));
+source_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(disk),
+ "source");
+g_return_if_fail(source_node != NULL);
+
+switch (disk->priv->type) {
+case GVIR_CONFIG_DEVICE_DISK_FILE:
+attribute_name = "file";
+break;
+case GVIR_CONFIG_DEVICE_DISK_BLOCK:
+attribute_name = "dev";
+break;
+case GVIR_CONFIG_DEVICE_DISK_DIR:
+attribute_name = "dir";
+break;
+case GVIR_CONFIG_DEVICE_DISK_NETWORK:
+attribute_name = "protocol";
+break;
+default:
+g_return_if_reached();
+}
+xmlNewProp(source_node, (xmlChar*)attribute_name, (xmlChar*)source);
+}
+
+void gvir_config_device_disk_set_driver_name(GVirConfigDeviceDisk *disk,
+ const char *driver_name)
+{
+xmlNodePtr node;
+
+g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk));
+node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), "driver");
+g_return_if_fail(node != NULL);
+xmlNewProp(node, (xmlChar*)"name", (xmlChar*)driver_name);
+
+}
+
+void gvir_config_device_disk_set_driver_type(GVirConfigDeviceDisk *disk,
+ const char *driver_type)
+{
+xmlNodePtr node;
+
+g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk));
+node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), "driver");
+g_return_if_fail(node != NULL);
+xmlNewProp(node, (xmlChar*)"type", (xmlChar*)driver_type);
+}
+
+void gvir_config_device_disk_set_target_bus(GVirConfigDeviceDisk *disk,
+const char *bus)
+{
+xmlNodePtr node;
+
+g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk));
+node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), "target");
+g_return_if_fail(node != NULL);
+xmlNewProp(node, (xmlChar*)"bus", (xmlChar*)bus);
+}
+
+void gvir_config_device_disk_set_target_dev(GVirConfigDeviceDisk *disk,
+const char *dev)
+{
+xmlNodePtr node;
+
+g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk));
+node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), "target");
+g_return_if_fail(node != NULL);
+xmlNewProp(node, (xmlChar*)"dev", (xmlChar*)dev);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.h
b/libvirt-gconfig/libvirt-gconfig-device-disk.h
index e597815..ac89d9b 100644
--- a/libvirt-gconfig/libvirt-gconfig-device-disk.h
+++ b/libvirt-gconfig/libvirt-gconfig-device-disk.h
@@ -87,6 +87,16 @@ 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);
+void gvir_config_device_disk_set_source(GVirConfigDeviceDisk *disk,
+const char *source);
+void gvir_config_device_disk_set_driver_name(GVirConfigDeviceDisk *disk,
+ const char *driver_name);
+void gvir_config_device_disk_set_driver_type(GVirConfigDeviceDisk *disk,
+