[libvirt-glib 3/4] Deprecate gvir_config_domain_disk_[gs]et_driver_*

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

 



They are replaced by equivalent methods in GVirConfigDomainDiskDriver.
Initially, we had only one or two attributes to set on the 'driver' child
of the 'disk' node. Nowadays, we more than 5 attributes to set on this
node, mapping it as a separate object is more consistent with the rest of
libvirt-gconfig API.
---
 libvirt-gconfig/libvirt-gconfig-domain-disk.h | 10 ++++++++--
 libvirt-gconfig/tests/test-domain-create.c    | 23 +++++++++++++++--------
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.h b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
index a28f243..686e0ec 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
@@ -140,13 +140,16 @@ void gvir_config_domain_disk_set_startup_policy(GVirConfigDomainDisk *disk,
                                                 GVirConfigDomainDiskStartupPolicy policy);
 void gvir_config_domain_disk_set_source(GVirConfigDomainDisk *disk,
                                         const char *source);
+G_DEPRECATED_FOR(gvir_config_domain_disk_driver_set_cache)
 void gvir_config_domain_disk_set_driver_cache(GVirConfigDomainDisk *disk,
                                               GVirConfigDomainDiskCacheType cache_type);
+G_DEPRECATED_FOR(gvir_config_domain_disk_driver_set_name)
 void gvir_config_domain_disk_set_driver_name(GVirConfigDomainDisk *disk,
                                              const char *driver_name);
-G_DEPRECATED_FOR(gvir_config_domain_disk_set_driver_format)
+G_DEPRECATED_FOR(gvir_config_domain_disk_driver_set_format)
 void gvir_config_domain_disk_set_driver_type(GVirConfigDomainDisk *disk,
                                              const char *driver_type);
+G_DEPRECATED_FOR(gvir_config_domain_disk_driver_set_format)
 void gvir_config_domain_disk_set_driver_format(GVirConfigDomainDisk *disk,
                                                GVirConfigDomainDiskFormat format);
 void gvir_config_domain_disk_set_target_bus(GVirConfigDomainDisk *disk,
@@ -162,10 +165,13 @@ GVirConfigDomainDiskGuestDeviceType gvir_config_domain_disk_get_guest_device_typ
 GVirConfigDomainDiskSnapshotType gvir_config_domain_disk_get_snapshot_type(GVirConfigDomainDisk *disk);
 GVirConfigDomainDiskStartupPolicy gvir_config_domain_disk_get_startup_policy(GVirConfigDomainDisk *disk);
 const char *gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk);
+G_DEPRECATED_FOR(gvir_config_domain_disk_driver_get_cache)
 GVirConfigDomainDiskCacheType gvir_config_domain_disk_get_driver_cache(GVirConfigDomainDisk *disk);
+G_DEPRECATED_FOR(gvir_config_domain_disk_driver_get_name)
 const char *gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk);
-G_DEPRECATED_FOR(gvir_config_domain_disk_get_driver_format)
+G_DEPRECATED_FOR(gvir_config_domain_disk_driver_get_format)
 const char *gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk);
+G_DEPRECATED_FOR(gvir_config_domain_disk_driver_get_format)
 GVirConfigDomainDiskFormat gvir_config_domain_disk_get_driver_format(GVirConfigDomainDisk *disk);
 GVirConfigDomainDiskBus gvir_config_domain_disk_get_target_bus(GVirConfigDomainDisk *disk);
 const char *gvir_config_domain_disk_get_target_dev(GVirConfigDomainDisk *disk);
diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
index ae0b248..b5c2cf3 100644
--- a/libvirt-gconfig/tests/test-domain-create.c
+++ b/libvirt-gconfig/tests/test-domain-create.c
@@ -233,28 +233,35 @@ int main(int argc, char **argv)
 
     /* disk node */
     GVirConfigDomainDisk *disk;
+    GVirConfigDomainDiskDriver *driver;
+
+    driver = gvir_config_domain_disk_driver_new();
+    gvir_config_domain_disk_driver_set_name(driver, "foo");
+    gvir_config_domain_disk_driver_set_format(driver, GVIR_CONFIG_DOMAIN_DISK_FORMAT_BOCHS);
+    gvir_config_domain_disk_driver_set_name(driver, "qemu");
+    gvir_config_domain_disk_driver_set_cache(driver, GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE);
+    gvir_config_domain_disk_driver_set_format(driver, GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2);
 
     disk = gvir_config_domain_disk_new();
     gvir_config_domain_disk_set_type(disk, GVIR_CONFIG_DOMAIN_DISK_FILE);
     gvir_config_domain_disk_set_guest_device_type(disk, GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_DISK);
     gvir_config_domain_disk_set_source(disk, "/tmp/foo/bar");
     gvir_config_domain_disk_set_startup_policy (disk, GVIR_CONFIG_DOMAIN_DISK_STARTUP_POLICY_REQUISITE);
-    gvir_config_domain_disk_set_driver_name(disk, "foo");
-    gvir_config_domain_disk_set_driver_format(disk, GVIR_CONFIG_DOMAIN_DISK_FORMAT_BOCHS);
-    gvir_config_domain_disk_set_driver_name(disk, "qemu");
-    gvir_config_domain_disk_set_driver_cache(disk, GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE);
-    gvir_config_domain_disk_set_driver_format(disk, GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2);
     gvir_config_domain_disk_set_target_bus(disk, GVIR_CONFIG_DOMAIN_DISK_BUS_IDE);
     gvir_config_domain_disk_set_target_dev(disk, "hda");
+    gvir_config_domain_disk_set_driver(disk, driver);
+    g_object_unref(G_OBJECT(driver));
     devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(disk));
 
     g_assert(gvir_config_domain_disk_get_disk_type(disk) == GVIR_CONFIG_DOMAIN_DISK_FILE);
     g_assert(gvir_config_domain_disk_get_guest_device_type(disk) == GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_DISK);
     g_assert(gvir_config_domain_disk_get_startup_policy (disk) == GVIR_CONFIG_DOMAIN_DISK_STARTUP_POLICY_REQUISITE);
     g_str_const_check(gvir_config_domain_disk_get_source(disk), "/tmp/foo/bar");
-    g_assert(gvir_config_domain_disk_get_driver_cache(disk) == GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE);
-    g_str_const_check(gvir_config_domain_disk_get_driver_name(disk), "qemu");
-    g_assert(gvir_config_domain_disk_get_driver_format(disk) == GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2);
+    driver = gvir_config_domain_disk_get_driver(disk);
+    g_assert(driver != NULL);
+    g_assert(gvir_config_domain_disk_driver_get_cache(driver) == GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE);
+    g_str_const_check(gvir_config_domain_disk_driver_get_name(driver), "qemu");
+    g_assert(gvir_config_domain_disk_driver_get_format(driver) == GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2);
     g_assert(gvir_config_domain_disk_get_target_bus(disk) == GVIR_CONFIG_DOMAIN_DISK_BUS_IDE);
     g_str_const_check(gvir_config_domain_disk_get_target_dev(disk), "hda");
 
-- 
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]