Add the gvir_config_domain_filesys_set_driver_format function to allow setting nbd driver type + image format for containers filesystems. --- libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 30 +++++++++++++++++++++++- libvirt-gconfig/libvirt-gconfig-domain-filesys.h | 4 ++++ libvirt-gconfig/libvirt-gconfig.sym | 5 ++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c index 006a407..fffbe88 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_add_child(GVIR_CONFIG_OBJECT(filesys), "driver"); + if (!(node = gvir_config_object_get_child(GVIR_CONFIG_OBJECT(filesys), "driver"))) { + 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( @@ -137,6 +139,32 @@ void gvir_config_domain_filesys_set_driver_type(GVirConfigDomainFilesys *filesys g_object_unref(G_OBJECT(node)); } +void gvir_config_domain_filesys_set_driver_format(GVirConfigDomainFilesys *filesys, + GVirConfigDomainDiskFormat format) +{ + GVirConfigObject *node; + GVirConfigDomainFilesysDriverType type = GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_LOOP; + + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys)); + if (!(node = gvir_config_object_get_child(GVIR_CONFIG_OBJECT(filesys), "driver"))) { + node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), "driver"); + } + g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node)); + if (format != GVIR_CONFIG_DOMAIN_DISK_FORMAT_RAW) + type = GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD; + + gvir_config_object_set_attribute_with_type( + node, "type", + GVIR_CONFIG_TYPE_DOMAIN_FILESYS_DRIVER_TYPE, + type, NULL); + + gvir_config_object_set_attribute_with_type( + node, "format", + GVIR_CONFIG_TYPE_DOMAIN_DISK_FORMAT, + format, NULL); + g_object_unref(G_OBJECT(node)); +} + void gvir_config_domain_filesys_set_source(GVirConfigDomainFilesys *filesys, const char *source) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h index 4f3973e..18c4069 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h @@ -75,6 +75,8 @@ typedef enum { GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_PATH, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_HANDLE, + GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_LOOP, + GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD, } GVirConfigDomainFilesysDriverType; GType gvir_config_domain_filesys_get_type(void); @@ -89,6 +91,8 @@ void gvir_config_domain_filesys_set_access_type(GVirConfigDomainFilesys *filesys GVirConfigDomainFilesysAccessType type); void gvir_config_domain_filesys_set_driver_type(GVirConfigDomainFilesys *filesys, GVirConfigDomainFilesysDriverType type); +void gvir_config_domain_filesys_set_driver_format(GVirConfigDomainFilesys *filesys, + GVirConfigDomainDiskFormat format); void gvir_config_domain_filesys_set_source(GVirConfigDomainFilesys *filesys, const char *source); void gvir_config_domain_filesys_set_ram_usage(GVirConfigDomainFilesys *filesys, diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 407a52f..6ce1511 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -719,4 +719,9 @@ global: gvir_config_storage_vol_target_set_compat; } LIBVIRT_GCONFIG_0.1.9; +LIBVIRT_GCONFIG_0.2.1 { +global: + gvir_config_domain_filesys_set_driver_format; +} LIBVIRT_GCONFIG_0.2.0; + # .... define new API here using predicted next version number .... -- 2.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list