[virt-tools-list] [libosinfo 4/4] Replace OsinfoDb.guess_os_from_location() by guess_os_from_media()

Daniel P. Berrange berrange at redhat.com
Tue Aug 30 15:39:29 UTC 2011


On Tue, Aug 23, 2011 at 12:31:26AM +0300, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
> 
> ---
>  docs/reference/Libosinfo-sections.txt |    2 +-
>  osinfo/libosinfo.syms                 |    2 +-
>  osinfo/osinfo_db.c                    |   25 +++++--------------------
>  osinfo/osinfo_db.h                    |    5 +----
>  4 files changed, 8 insertions(+), 26 deletions(-)
> 
> diff --git a/docs/reference/Libosinfo-sections.txt b/docs/reference/Libosinfo-sections.txt
> index 80816e6..69cd863 100644
> --- a/docs/reference/Libosinfo-sections.txt
> +++ b/docs/reference/Libosinfo-sections.txt
> @@ -18,7 +18,7 @@ osinfo_db_add_os
>  osinfo_db_add_platform
>  osinfo_db_add_device
>  osinfo_db_add_deployment
> -osinfo_db_guess_os_from_location
> +osinfo_db_guess_os_from_media
>  osinfo_db_unique_values_for_property_in_os
>  osinfo_db_unique_values_for_property_in_platform
>  osinfo_db_unique_values_for_property_in_device
> diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
> index e64156a..0e9751d 100644
> --- a/osinfo/libosinfo.syms
> +++ b/osinfo/libosinfo.syms
> @@ -15,7 +15,7 @@ LIBOSINFO_0.0.1 {
>  	osinfo_db_add_platform;
>  	osinfo_db_add_device;
>  	osinfo_db_add_deployment;
> -	osinfo_db_guess_os_from_location;
> +	osinfo_db_guess_os_from_media;
>  	osinfo_db_unique_values_for_property_in_os;
>  	osinfo_db_unique_values_for_property_in_platform;
>  	osinfo_db_unique_values_for_property_in_device;
> diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
> index 42ca7eb..a766a3c 100644
> --- a/osinfo/osinfo_db.c
> +++ b/osinfo/osinfo_db.c
> @@ -322,25 +322,17 @@ void osinfo_db_add_deployment(OsinfoDb *db, OsinfoDeployment *deployment)
>  }
>  
>  /**
> - * osinfo_db_guess_os_from_location:
> + * osinfo_db_guess_os_from_media:
>   * @db: the database
> - * @location: the location of an installation media
> - * @cancellable (allow-none): a #GCancellable, or %NULL
> - * @error: The location where to store any error, or %NULL
> + * @media: the installation media
>   *
> - * The @location could be any URI that GIO can handle or a local path.
> - *
> - * NOTE: Currently this only works for ISO images/devices.
> + * Guess operating system given a #OsinfoMedia object.
>   *
>   * Returns: (transfer none): the operating system, or NULL if guessing failed
>   */
> -OsinfoOs *osinfo_db_guess_os_from_location(OsinfoDb *db,
> -                                           const gchar *location,
> -                                           GCancellable *cancellable,
> -                                           GError **error)
> +OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db, OsinfoMedia *media)
>  {
>      OsinfoOs *ret = NULL;
> -    OsinfoMedia *media;
>      GList *oss = NULL;
>      GList *os_iter;
>      const gchar *media_volume;
> @@ -348,12 +340,7 @@ OsinfoOs *osinfo_db_guess_os_from_location(OsinfoDb *db,
>      const gchar *media_publisher;
>  
>      g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
> -    g_return_val_if_fail(location != NULL, NULL);
> -    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
> -
> -    media = osinfo_media_new_from_location (location, cancellable, error);
> -    if (*error != NULL)
> -        goto EXIT;
> +    g_return_val_if_fail(media != NULL, NULL);
>  
>      media_volume = osinfo_media_get_volume_id(media);
>      media_system = osinfo_media_get_system_id(media);
> @@ -387,9 +374,7 @@ OsinfoOs *osinfo_db_guess_os_from_location(OsinfoDb *db,
>              break;
>      }
>  
> -EXIT:
>      g_list_free(oss);
> -    g_clear_object(&media);
>  
>      return ret;
>  }
> diff --git a/osinfo/osinfo_db.h b/osinfo/osinfo_db.h
> index f3ba37e..0165c30 100644
> --- a/osinfo/osinfo_db.h
> +++ b/osinfo/osinfo_db.h
> @@ -93,10 +93,7 @@ void osinfo_db_add_platform(OsinfoDb *db, OsinfoPlatform *platform);
>  void osinfo_db_add_device(OsinfoDb *db, OsinfoDevice *device);
>  void osinfo_db_add_deployment(OsinfoDb *db, OsinfoDeployment *deployment);
>  
> -OsinfoOs *osinfo_db_guess_os_from_location(OsinfoDb *db,
> -                                           const gchar *location,
> -                                           GCancellable *cancellable,
> -                                           GError **error);
> +OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db, OsinfoMedia *media);
>  
>  // Get me all unique values for property "vendor" among operating systems
>  GList *osinfo_db_unique_values_for_property_in_os(OsinfoDb *db, const gchar *propName);

ACK

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the virt-tools-list mailing list