[libvirt-glib 1/2] Add gvir_config_domain_disk_[gs]et_cache

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

 



---
 libvirt-gconfig/libvirt-gconfig-domain-disk.c |   23 +++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-domain-disk.h |   12 ++++++++++++
 libvirt-gconfig/libvirt-gconfig.sym           |    3 +++
 libvirt-gconfig/tests/test-domain-create.c    |    2 ++
 4 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
index b2861e4..afa7eda 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
@@ -172,6 +172,18 @@ void gvir_config_domain_disk_set_driver_type(GVirConfigDomainDisk *disk,
                                                 "driver", "type", driver_type);
 }
 
+void gvir_config_domain_disk_set_driver_cache(GVirConfigDomainDisk *disk,
+                                              GVirConfigDomainDiskCacheType cache_type)
+{
+    const char *cache_str;
+
+    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk));
+    cache_str = gvir_config_genum_get_nick(GVIR_CONFIG_TYPE_DOMAIN_DISK_CACHE_TYPE, cache_type);
+    g_return_if_fail(cache_str != NULL);
+    gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
+                                                "driver", "cache", cache_str);
+}
+
 void gvir_config_domain_disk_set_target_bus(GVirConfigDomainDisk *disk,
                                             GVirConfigDomainDiskBus bus)
 {
@@ -269,6 +281,17 @@ gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk)
                                             "driver", "type");
 }
 
+GVirConfigDomainDiskCacheType
+gvir_config_domain_disk_get_driver_cache(GVirConfigDomainDisk *disk)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk),
+                         GVIR_CONFIG_DOMAIN_DISK_CACHE_DEFAULT);
+
+    return gvir_config_object_get_attribute_genum(GVIR_CONFIG_OBJECT(disk),
+                                                  "driver", "cache",
+                                                  GVIR_CONFIG_TYPE_DOMAIN_DISK_CACHE_TYPE,
+                                                  GVIR_CONFIG_DOMAIN_DISK_CACHE_DEFAULT);
+}
 GVirConfigDomainDiskBus
 gvir_config_domain_disk_get_target_bus(GVirConfigDomainDisk *disk)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.h b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
index 3359049..4b16b80 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
@@ -75,6 +75,15 @@ 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
@@ -100,6 +109,8 @@ void gvir_config_domain_disk_set_snapshot_type(GVirConfigDomainDisk *disk,
                                                GVirConfigDomainDiskSnapshotType type);
 void gvir_config_domain_disk_set_source(GVirConfigDomainDisk *disk,
                                         const char *source);
+void gvir_config_domain_disk_set_driver_cache(GVirConfigDomainDisk *disk,
+                                              GVirConfigDomainDiskCacheType cache_type);
 void gvir_config_domain_disk_set_driver_name(GVirConfigDomainDisk *disk,
                                              const char *driver_name);
 void gvir_config_domain_disk_set_driver_type(GVirConfigDomainDisk *disk,
@@ -113,6 +124,7 @@ GVirConfigDomainDiskType gvir_config_domain_disk_get_disk_type(GVirConfigDomainD
 GVirConfigDomainDiskGuestDeviceType gvir_config_domain_disk_get_guest_device_type(GVirConfigDomainDisk *disk);
 GVirConfigDomainDiskSnapshotType gvir_config_domain_disk_get_snapshot_type(GVirConfigDomainDisk *disk);
 char *gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk);
+GVirConfigDomainDiskCacheType gvir_config_domain_disk_get_driver_cache(GVirConfigDomainDisk *disk);
 char *gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk);
 char *gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk);
 GVirConfigDomainDiskBus gvir_config_domain_disk_get_target_bus(GVirConfigDomainDisk *disk);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index ab2c7bf..96ce58f 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -69,11 +69,14 @@ LIBVIRT_GCONFIG_0.0.4 {
 
 	gvir_config_domain_disk_get_type;
 	gvir_config_domain_disk_bus_get_type;
+	gvir_config_domain_disk_cache_type_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_get_driver_cache;
+	gvir_config_domain_disk_set_driver_cache;
 	gvir_config_domain_disk_get_driver_name;
 	gvir_config_domain_disk_set_driver_name;
 	gvir_config_domain_disk_get_driver_type;
diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
index 821e0b0..0cd8304 100644
--- a/libvirt-gconfig/tests/test-domain-create.c
+++ b/libvirt-gconfig/tests/test-domain-create.c
@@ -101,6 +101,8 @@ int main(int argc, char **argv)
     gvir_config_domain_disk_set_driver_name(disk, "foo");
     gvir_config_domain_disk_set_driver_type(disk, "bar");
     gvir_config_domain_disk_set_driver_name(disk, "qemu");
+    gvir_config_domain_disk_set_driver_cache(disk, GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE);
+    g_assert(gvir_config_domain_disk_get_driver_cache(disk) == GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE);
     gvir_config_domain_disk_set_driver_type(disk, "qcow2");
     gvir_config_domain_disk_set_target_bus(disk, GVIR_CONFIG_DOMAIN_DISK_BUS_IDE);
     gvir_config_domain_disk_set_target_dev(disk, "hda");
-- 
1.7.7.6

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