[libvirt-glib 2/4] Implement gvir_config_domain_disk_[gs]et_driver()

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

 



---
 libvirt-gconfig/libvirt-gconfig-domain-disk.c | 42 +++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-domain-disk.h | 58 +++++++++++++++------------
 libvirt-gconfig/libvirt-gconfig.sym           |  3 ++
 3 files changed, 77 insertions(+), 26 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
index db0416a..85d2bea 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
@@ -390,3 +390,45 @@ gvir_config_domain_disk_set_readonly(GVirConfigDomainDisk *disk,
     } else
         gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(disk), "readonly", NULL);
 }
+
+
+/**
+ * gvir_config_domain_disk_set_driver:
+ * @disk: a #GVirConfigDomainDisk
+ * @driver: (allow-none): a #GVirConfigDomainDiskDriver
+ *
+ * Uses @driver as the driver configuration for @disk.
+ */
+void gvir_config_domain_disk_set_driver(GVirConfigDomainDisk *disk,
+                                        GVirConfigDomainDiskDriver *driver)
+{
+    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk));
+    g_return_if_fail(driver == NULL || GVIR_CONFIG_IS_DOMAIN_DISK_DRIVER(driver));
+
+    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(disk),
+                                      "driver",
+                                      GVIR_CONFIG_OBJECT(driver));
+}
+
+
+/**
+ * gvir_config_domain_disk_get_driver:
+ * @disk: a #GVirConfigDomainDisk
+ *
+ * Gets the driver configuration for @disk.
+ *
+ * Returns: (transfer full): A #GVirConfigDomainDiskDriver. The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
+ */
+GVirConfigDomainDiskDriver *gvir_config_domain_disk_get_driver(GVirConfigDomainDisk *disk)
+{
+    GVirConfigObject *object;
+
+    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk), NULL);
+
+    object = gvir_config_object_get_child_with_type(GVIR_CONFIG_OBJECT(disk),
+                                                    "driver",
+                                                    GVIR_CONFIG_TYPE_DOMAIN_DISK_DRIVER);
+
+    return GVIR_CONFIG_DOMAIN_DISK_DRIVER(object);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.h b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
index 3b82eb5..a28f243 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
@@ -29,6 +29,35 @@
 
 G_BEGIN_DECLS
 
+/* These enum definitions are needed by libvirt-gconfig-domain-disk-driver.h */
+typedef enum {
+    GVIR_CONFIG_DOMAIN_DISK_CACHE_DEFAULT,
+    GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE,
+    GVIR_CONFIG_DOMAIN_DISK_CACHE_WRITETHROUGH,
+    GVIR_CONFIG_DOMAIN_DISK_CACHE_WRITEBACK,
+    GVIR_CONFIG_DOMAIN_DISK_CACHE_DIRECTSYNC,
+    GVIR_CONFIG_DOMAIN_DISK_CACHE_UNSAFE
+} GVirConfigDomainDiskCacheType;
+
+typedef enum {
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_RAW,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_DIR,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_BOCHS,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_CLOOP,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_COW,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_DMG,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_ISO,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QED,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VMDK,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VPC,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_FAT,
+      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VHD,
+} GVirConfigDomainDiskFormat;
+
+#include <libvirt-gconfig/libvirt-gconfig-domain-disk-driver.h>
+
 #define GVIR_CONFIG_TYPE_DOMAIN_DISK            (gvir_config_domain_disk_get_type ())
 #define GVIR_CONFIG_DOMAIN_DISK(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_DISK, GVirConfigDomainDisk))
 #define GVIR_CONFIG_DOMAIN_DISK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_DISK, GVirConfigDomainDiskClass))
@@ -75,15 +104,6 @@ typedef enum {
 } GVirConfigDomainDiskBus;
 
 typedef enum {
-    GVIR_CONFIG_DOMAIN_DISK_CACHE_DEFAULT,
-    GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE,
-    GVIR_CONFIG_DOMAIN_DISK_CACHE_WRITETHROUGH,
-    GVIR_CONFIG_DOMAIN_DISK_CACHE_WRITEBACK,
-    GVIR_CONFIG_DOMAIN_DISK_CACHE_DIRECTSYNC,
-    GVIR_CONFIG_DOMAIN_DISK_CACHE_UNSAFE
-} GVirConfigDomainDiskCacheType;
-
-typedef enum {
     GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_DISK,
     GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_FLOPPY,
     GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_CDROM
@@ -101,23 +121,6 @@ typedef enum {
     GVIR_CONFIG_DOMAIN_DISK_STARTUP_POLICY_OPTIONAL
 } GVirConfigDomainDiskStartupPolicy;
 
-typedef enum {
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_RAW,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_DIR,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_BOCHS,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_CLOOP,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_COW,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_DMG,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_ISO,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QED,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VMDK,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VPC,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_FAT,
-      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VHD,
-} GVirConfigDomainDiskFormat;
-
 /* backward compatibility */
 #define GVIR_CONFIG_DOMAIN_DISK_FORMAT_AIO GVIR_CONFIG_DOMAIN_DISK_FORMAT_RAW;
 
@@ -150,6 +153,9 @@ void gvir_config_domain_disk_set_target_bus(GVirConfigDomainDisk *disk,
                                             GVirConfigDomainDiskBus bus);
 void gvir_config_domain_disk_set_target_dev(GVirConfigDomainDisk *disk,
                                             const char *dev);
+void gvir_config_domain_disk_set_driver(GVirConfigDomainDisk *disk,
+                                        GVirConfigDomainDiskDriver *driver);
+GVirConfigDomainDiskDriver *gvir_config_domain_disk_get_driver(GVirConfigDomainDisk *disk);
 
 GVirConfigDomainDiskType gvir_config_domain_disk_get_disk_type(GVirConfigDomainDisk *disk);
 GVirConfigDomainDiskGuestDeviceType gvir_config_domain_disk_get_guest_device_type(GVirConfigDomainDisk *disk);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 9224426..b9164d4 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -625,6 +625,9 @@ global:
 	gvir_config_domain_disk_driver_set_io_policy;
 	gvir_config_domain_disk_driver_get_io_policy;
 
+	gvir_config_domain_disk_get_driver;
+	gvir_config_domain_disk_set_driver;
+
 	gvir_config_domain_graphics_rdp_set_multi_user;
 	gvir_config_domain_graphics_rdp_set_replace_user;
 
-- 
1.8.4.2

--
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]