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

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

 



Hey,

On Tue, Jul 07, 2015 at 04:26:02PM +0200, Cédric Bosdonnat wrote:
> 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");

This is unintuitive, but after looking at the code and a quick test, I
think _add_child() will create the node if it does not exist, and return
the existing node if it already exists. So I think this could become:

+        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");

and same here.

Christophe

Attachment: pgpcZUaOuKwhM.pgp
Description: PGP signature

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