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

Re: [virt-tools-list] [libosinfo 5/8] Add osinfo_db_identify_media



On Mon, Dec 3, 2012 at 1:23 PM, Christophe Fergeau <cfergeau redhat com> wrote:
> ---
>  osinfo/libosinfo.syms |   2 +
>  osinfo/osinfo_db.c    | 105 +++++++++++++++++++++++++++++++++-----------------
>  osinfo/osinfo_db.h    |   2 +
>  test/test-isodetect.c |  10 ++---
>  tools/osinfo-detect.c |  12 ++++--
>  5 files changed, 87 insertions(+), 44 deletions(-)
>
> diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
> index 2824678..d45e58e 100644
> --- a/osinfo/libosinfo.syms
> +++ b/osinfo/libosinfo.syms
> @@ -328,6 +328,8 @@ LIBOSINFO_0.2.2 {
>         osinfo_product_relationship_get_type;
>         osinfo_path_format_get_type;
>
> +       osinfo_db_identify_media;
> +
>         osinfo_entity_get_param_value_enum;
>         osinfo_entity_set_param_enum;
>
> diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
> index 665554c..1e8a93c 100644
> --- a/osinfo/osinfo_db.c
> +++ b/osinfo/osinfo_db.c
> @@ -391,40 +391,6 @@ static gint media_volume_compare (gconstpointer a, gconstpointer b)
>          return 1;
>  }
>
> -static void fill_media (OsinfoMedia *media, OsinfoMedia *matched_media)
> -{
> -    gboolean is_installer;
> -    gboolean is_live;
> -    gint reboots;
> -    const gchar *kernel_path;
> -    const gchar *initrd_path;
> -    const gchar *arch;
> -    const gchar *url;
> -
> -    arch = osinfo_media_get_architecture(matched_media);
> -    if (arch != NULL)
> -        g_object_set(G_OBJECT(media), "architecture", arch, NULL);
> -    url = osinfo_media_get_url(matched_media);
> -    if (url != NULL)
> -        g_object_set(G_OBJECT(media), "url", url, NULL);
> -
> -    kernel_path = osinfo_media_get_kernel_path(matched_media);
> -    if (kernel_path != NULL)
> -        g_object_set(G_OBJECT(media), "kernel_path", kernel_path, NULL);
> -
> -    initrd_path = osinfo_media_get_initrd_path(matched_media);
> -    if (initrd_path != NULL)
> -        g_object_set(G_OBJECT(media), "initrd_path", initrd_path, NULL);
> -    is_installer = osinfo_media_get_installer(matched_media);
> -    is_live = osinfo_media_get_live(matched_media);
> -    reboots = osinfo_media_get_installer_reboots(matched_media);
> -    g_object_set(G_OBJECT(media),
> -                 "installer", is_installer,
> -                 "live", is_live,
> -                 "installer-reboots", reboots,
> -                 NULL);
> -}
> -
>  /**
>   * osinfo_db_guess_os_from_media:
>   * @db: the database
> @@ -477,7 +443,6 @@ OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db,
>                  match_regex (os_system, media_system) &&
>                  match_regex (os_publisher, media_publisher)) {
>                  ret = os;
> -                fill_media(media, os_media);
>                  if (matched_media != NULL)
>                      *matched_media = os_media;
>                  break;
> @@ -496,6 +461,76 @@ OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db,
>      return ret;
>  }
>
> +static void fill_media (OsinfoMedia *media, OsinfoMedia *matched_media, OsinfoOs *os)
> +{
> +    gboolean is_installer;
> +    gboolean is_live;
> +    gint reboots;
> +    const gchar *kernel_path;
> +    const gchar *initrd_path;
> +    const gchar *arch;
> +    const gchar *url;
> +
> +    arch = osinfo_media_get_architecture(matched_media);
> +    if (arch != NULL)
> +        g_object_set(G_OBJECT(media), "architecture", arch, NULL);
> +    url = osinfo_media_get_url(matched_media);
> +    if (url != NULL)
> +        g_object_set(G_OBJECT(media), "url", url, NULL);
> +
> +    kernel_path = osinfo_media_get_kernel_path(matched_media);
> +    if (kernel_path != NULL)
> +        g_object_set(G_OBJECT(media), "kernel_path", kernel_path, NULL);
> +
> +    initrd_path = osinfo_media_get_initrd_path(matched_media);
> +    if (initrd_path != NULL)
> +        g_object_set(G_OBJECT(media), "initrd_path", initrd_path, NULL);
> +    is_installer = osinfo_media_get_installer(matched_media);
> +    is_live = osinfo_media_get_live(matched_media);
> +    g_object_set(G_OBJECT(media),
> +                 "installer", is_installer,
> +                 "live", is_live,
> +                 NULL);
> +    if (is_installer) {
> +        reboots = osinfo_media_get_installer_reboots(matched_media);
> +        g_object_set(G_OBJECT(media), "installer-reboots", reboots, NULL);
> +    }
> +    if (os != NULL)
> +        osinfo_media_set_os(media, os);
> +}
> +
> +/**
> + * osinfo_db_identify_media:
> + * @db: a #OsinfoDb database
> + * @media: the installation media
> + * data
> + *
> + * Try to match the @media created using osinfo_media_create_from_location()

This makes it sound like app developer doesn't have a choice. As an
app developer, I'd think why is libosinfo not creating the media
instance for me if it knows that I'll be doing that just before this
call anyways.

I recall that you are doing it this way because implementing async
version of this method will than be very difficult?

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124


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