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

Re: [libvirt] [libvirt-glib 2/4] Implement gvir_config_domain_disk_[gs]et_driver()



On Fri, Dec 6, 2013 at 11:13 AM, Christophe Fergeau <cfergeau redhat com> wrote:
> ---
>  libvirt-gconfig/libvirt-gconfig-domain-disk.c | 42 +++++++++++++++++++
>  libvirt-gconfig/libvirt-gconfig-domain-disk.h | 58 +++++++++++++++------------
>  libvirt-gconfig/libvirt-gconfig.sym           |  3 ++
>  3 files changed, 77 insertions(+), 26 deletions(-)
>
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
> index db0416a..85d2bea 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
> @@ -390,3 +390,45 @@ gvir_config_domain_disk_set_readonly(GVirConfigDomainDisk *disk,
>      } else
>          gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(disk), "readonly", NULL);
>  }
> +
> +
> +/**
> + * gvir_config_domain_disk_set_driver:
> + * @disk: a #GVirConfigDomainDisk
> + * @driver: (allow-none): a #GVirConfigDomainDiskDriver
> + *
> + * Uses @driver as the driver configuration for @disk.
> + */
> +void gvir_config_domain_disk_set_driver(GVirConfigDomainDisk *disk,
> +                                        GVirConfigDomainDiskDriver *driver)
> +{
> +    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk));
> +    g_return_if_fail(driver == NULL || GVIR_CONFIG_IS_DOMAIN_DISK_DRIVER(driver));
> +
> +    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(disk),
> +                                      "driver",
> +                                      GVIR_CONFIG_OBJECT(driver));
> +}
> +
> +
> +/**
> + * gvir_config_domain_disk_get_driver:
> + * @disk: a #GVirConfigDomainDisk
> + *
> + * Gets the driver configuration for @disk.
> + *
> + * Returns: (transfer full): A #GVirConfigDomainDiskDriver. The returned
> + * object should be unreffed with g_object_unref() when no longer needed.
> + */
> +GVirConfigDomainDiskDriver *gvir_config_domain_disk_get_driver(GVirConfigDomainDisk *disk)
> +{
> +    GVirConfigObject *object;
> +
> +    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk), NULL);
> +
> +    object = gvir_config_object_get_child_with_type(GVIR_CONFIG_OBJECT(disk),
> +                                                    "driver",
> +                                                    GVIR_CONFIG_TYPE_DOMAIN_DISK_DRIVER);
> +
> +    return GVIR_CONFIG_DOMAIN_DISK_DRIVER(object);
> +}
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.h b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
> index 3b82eb5..a28f243 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain-disk.h
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
> @@ -29,6 +29,35 @@
>
>  G_BEGIN_DECLS
>
> +/* These enum definitions are needed by libvirt-gconfig-domain-disk-driver.h */

Why not just move these enums to that header then?

> +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_FORMAT_RAW,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_DIR,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_BOCHS,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_CLOOP,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_COW,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_DMG,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_ISO,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_QED,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VMDK,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VPC,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_FAT,
> +      GVIR_CONFIG_DOMAIN_DISK_FORMAT_VHD,
> +} GVirConfigDomainDiskFormat;
> +

Looks good otherwise.


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