[glib] Don't overwrite filesystem type when writing format

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

 



When setting filesystem driver format first and type, only the type
remained and vice-versa.
---
 libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 8 ++++++--
 tests/test-gconfig.c                             | 2 +-
 tests/xml/gconfig-domain-device-filesys.xml      | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
index 9b73af5..4e33d5f 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
@@ -125,7 +125,9 @@ void gvir_config_domain_filesys_set_driver_type(GVirConfigDomainFilesys *filesys
     GVirConfigObject *node;
 
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys));
-    node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(filesys), "driver");
+    node = gvir_config_object_get_child(GVIR_CONFIG_OBJECT(filesys), "driver");
+    if (!node)
+        node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), "driver");
     g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
     if (type != GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT)
         gvir_config_object_set_attribute_with_type(
@@ -143,7 +145,9 @@ void gvir_config_domain_filesys_set_driver_format(GVirConfigDomainFilesys *files
     GVirConfigObject *node;
 
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys));
-    node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(filesys), "driver");
+    node = gvir_config_object_get_child(GVIR_CONFIG_OBJECT(filesys), "driver");
+    if (!node)
+        node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), "driver");
     g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
 
     gvir_config_object_set_attribute_with_type(
diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c
index bd2daa6..0eec53e 100644
--- a/tests/test-gconfig.c
+++ b/tests/test-gconfig.c
@@ -368,7 +368,7 @@ static void test_domain_device_filesystem(void)
     fs = gvir_config_domain_filesys_new();
     gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_FILE);
     gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_MAPPED);
-    gvir_config_domain_filesys_set_driver_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT);
+    gvir_config_domain_filesys_set_driver_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD);
     gvir_config_domain_filesys_set_driver_format(fs, GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2);
     gvir_config_domain_filesys_set_source(fs, "/path/to/source");
     gvir_config_domain_filesys_set_target(fs, "/path/to/target1");
diff --git a/tests/xml/gconfig-domain-device-filesys.xml b/tests/xml/gconfig-domain-device-filesys.xml
index 30152d2..a831c02 100644
--- a/tests/xml/gconfig-domain-device-filesys.xml
+++ b/tests/xml/gconfig-domain-device-filesys.xml
@@ -1,7 +1,7 @@
 <domain>
   <devices>
     <filesystem type="file" accessmode="mapped">
-      <driver format="qcow2"/>
+      <driver type="nbd" format="qcow2"/>
       <source file="/path/to/source"/>
       <target dir="/path/to/target1"/>
       <readonly/>
-- 
2.1.4

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