Re: [libvirt-designer][PATCH v2 2/4] domain: Introduce disk support

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

 



On 09/10/2012 03:58 PM, Michal Privoznik wrote:
> Let users add either files or devices as disks to domains.
> ---
>  libvirt-designer/libvirt-designer-domain.c |  259 ++++++++++++++++++++++++++++
>  libvirt-designer/libvirt-designer-domain.h |    7 +
>  libvirt-designer/libvirt-designer.sym      |    3 +
>  3 files changed, 269 insertions(+), 0 deletions(-)
> 
> diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c
> index a8cabde..8e649d7 100644
> --- a/libvirt-designer/libvirt-designer-domain.c
> +++ b/libvirt-designer/libvirt-designer-domain.c
> @@ -37,6 +37,12 @@ struct _GVirDesignerDomainPrivate
>      GVirConfigCapabilities *caps;
>      OsinfoOs *os;
>      OsinfoPlatform *platform;
> +
> +    OsinfoDeployment *deployment;
> +    /* next disk targets */
> +    unsigned int ide;
> +    unsigned int virtio;
> +    unsigned int sata;
>  };
>  
>  G_DEFINE_TYPE(GVirDesignerDomain, gvir_designer_domain, G_TYPE_OBJECT);
> @@ -134,6 +140,8 @@ static void gvir_designer_domain_finalize(GObject *object)
>      g_object_unref(priv->os);
>      g_object_unref(priv->platform);
>      g_object_unref(priv->caps);
> +    if (priv->deployment)
> +        g_object_unref(priv->deployment);
>  
>      G_OBJECT_CLASS(gvir_designer_domain_parent_class)->finalize(object);
>  }
> @@ -663,3 +671,254 @@ cleanup:
>          g_object_unref(guest);
>      return ret;
>  }
> +
> +static GList *
> +gvir_designer_domain_get_supported_disk_bus_types(GVirDesignerDomain *design)
> +{
> +    GVirDesignerDomainPrivate *priv = design->priv;
> +    OsinfoDeviceList *dev_list;
> +    GHashTable *bus_hash = g_hash_table_new(g_str_hash, g_str_equal);
> +    GList *ret = NULL;
> +    int i;
> +
> +    dev_list = osinfo_os_get_devices_by_property(priv->os, "class", "block", TRUE);
> +    if (!dev_list)
> +        goto cleanup;
> +
> +    for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(dev_list)); i++) {
> +        OsinfoDevice *dev = OSINFO_DEVICE(osinfo_list_get_nth(OSINFO_LIST(dev_list), i));
> +        const gchar *bus = osinfo_device_get_bus_type(dev);
> +
> +        if (bus)
> +            g_hash_table_add(bus_hash, g_strdup(bus));
> +    }

Here you can use Java-style list iteration as well (the one you use in
virtxml.c).

[...]

otherwise looks good, so (as I said earlier) FWIW ACK from me.

Martin

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