[libvirt-glib 22/37] More GVirConfigDeviceDisk setters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 libvirt-gconfig/libvirt-gconfig-device-disk.c |   88 ++++++++++++++++++++++++-
 libvirt-gconfig/libvirt-gconfig-device-disk.h |   10 +++
 libvirt-gconfig/libvirt-gconfig.sym           |    7 ++-
 3 files changed, 102 insertions(+), 3 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.c b/libvirt-gconfig/libvirt-gconfig-device-disk.c
index 9981ae8..29de68b 100644
--- a/libvirt-gconfig/libvirt-gconfig-device-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c
@@ -38,7 +38,7 @@ extern gboolean debugFlag;
 
 struct _GVirConfigDeviceDiskPrivate
 {
-    gboolean unused;
+    GVirConfigDeviceDiskType type;
 };
 
 G_DEFINE_TYPE(GVirConfigDeviceDisk, gvir_config_device_disk, GVIR_TYPE_CONFIG_DEVICE);
@@ -93,8 +93,10 @@ void gvir_config_device_disk_set_type(GVirConfigDeviceDisk *disk,
         return;
     type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_DISK_TYPE,
                                           type);
-    if (type_str != NULL)
+    if (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,
@@ -126,3 +128,85 @@ void gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk,
     if (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;
+
+    if (disk->priv->type == GVIR_CONFIG_DEVICE_DISK_DIR) {
+        /* I don't know what attribute name to use for 'dir' */
+        g_warning("set_source not implemented for 'dir' disk nodes");
+        return;
+    }
+
+    source_node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk),
+                                               "source", TRUE);
+    if (source_node == NULL)
+        return;
+
+    switch (disk->priv->type) {
+        case GVIR_CONFIG_DEVICE_DISK_FILE:
+            attribute_name = "file";
+            break;
+        case GVIR_CONFIG_DEVICE_DISK_BLOCK:
+            attribute_name = "block";
+            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;
+
+    node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk),
+                                        "driver", FALSE);
+    if (node == NULL)
+        return;
+    xmlNewProp(node, (xmlChar*)"name", (xmlChar*)driver_name);
+
+}
+
+void gvir_config_device_disk_set_driver_type(GVirConfigDeviceDisk *disk,
+                                             const char *driver_type)
+{
+    xmlNodePtr node;
+
+    node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk),
+                                        "driver", FALSE);
+    if (node == NULL)
+        return;
+    xmlNewProp(node, (xmlChar*)"type", (xmlChar*)driver_type);
+}
+
+void gvir_config_device_disk_set_target_bus(GVirConfigDeviceDisk *disk,
+                                            const char *bus)
+{
+    xmlNodePtr node;
+
+    node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk),
+                                        "target", FALSE);
+    if (node == NULL)
+        return;
+    xmlNewProp(node, (xmlChar*)"bus", (xmlChar*)bus);
+}
+
+void gvir_config_device_disk_set_target_dev(GVirConfigDeviceDisk *disk,
+                                            const char *dev)
+{
+    xmlNodePtr node;
+
+    node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk),
+                                        "target", FALSE);
+    if (node == NULL)
+        return;
+    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 2850672..3e25e9f 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,
+                                             const char *driver_type);
+void gvir_config_device_disk_set_target_bus(GVirConfigDeviceDisk *disk,
+                                            const char *bus);
+void gvir_config_device_disk_set_target_dev(GVirConfigDeviceDisk *disk,
+                                            const char *dev);
 
 G_END_DECLS
 
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 963ca53..cb0d035 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -20,8 +20,13 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_config_device_disk_type_get_type;
 	gvir_config_device_disk_new;
 	gvir_config_device_disk_new_from_xml;
-	gvir_config_device_disk_set_snapshot_type;
+	gvir_config_device_disk_set_driver_name;
+	gvir_config_device_disk_set_driver_type;
 	gvir_config_device_disk_set_guest_device_type;
+	gvir_config_device_disk_set_snapshot_type;
+	gvir_config_device_disk_set_source;
+	gvir_config_device_disk_set_target_bus;
+	gvir_config_device_disk_set_target_dev;
 	gvir_config_device_disk_set_type;
 
 	gvir_config_domain_get_type;
-- 
1.7.7

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]