[libvirt] [PATCH] Show also short-ids when calling --list-{os, platform}

As the short-id can be used to set the os/platform in the example program, let's expose them to the user. --- examples/virt-designer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/virt-designer.c b/examples/virt-designer.c index 7628449..12faf04 100644 --- a/examples/virt-designer.c +++ b/examples/virt-designer.c @@ -107,8 +107,8 @@ print_oses(const gchar *option_name, if (!db && !load_osinfo()) goto cleanup; - printf(" Operating System ID\n" - "-----------------------\n"); + printf(" Operating System ID (short ID)\n" + "--------------------------------\n"); list = osinfo_db_get_os_list(db); if (!list) @@ -119,6 +119,8 @@ print_oses(const gchar *option_name, OsinfoOs *os = OSINFO_OS(os_iter->data); const char *id = osinfo_entity_get_param_value(OSINFO_ENTITY(os), OSINFO_ENTITY_PROP_ID); + const char *short_id = osinfo_entity_get_param_value(OSINFO_ENTITY(os), + OSINFO_PRODUCT_PROP_SHORT_ID); printf("%s\n", id); } @@ -148,8 +150,8 @@ print_platforms(const gchar *option_name, if (!db && !load_osinfo()) goto cleanup; - printf(" Platform ID\n" - "---------------\n"); + printf(" Platform ID (short ID)\n" + "------------------------\n"); list = osinfo_db_get_platform_list(db); if (!list) @@ -160,6 +162,8 @@ print_platforms(const gchar *option_name, OsinfoPlatform *platform = OSINFO_PLATFORM(platform_iter->data); const char *id = osinfo_entity_get_param_value(OSINFO_ENTITY(platform), OSINFO_ENTITY_PROP_ID); + const char *short_id = osinfo_entity_get_param_value(OSINFO_ENTITY(platform), + OSINFO_PRODUCT_PROP_SHORT_ID); printf("%s\n", id); } @@ -577,9 +581,9 @@ main(int argc, char *argv[]) {"connect", 'c', 0, G_OPTION_ARG_STRING, &connect_uri, "libvirt connection URI used for querying capabilities", "URI"}, {"list-os", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, print_oses, - "list IDs of known OSes", NULL}, + "list IDs and short IDs of known OSes", NULL}, {"list-platform", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, print_platforms, - "list IDs of known hypervisors", NULL}, + "list IDs and short IDs of known hypervisors", NULL}, {"os", 'o', 0, G_OPTION_ARG_STRING, &os_str, "set domain OS", "OS"}, {"platform", 'p', 0, G_OPTION_ARG_STRING, &platform_str, -- 2.1.0

On 10/22/2014 08:16 AM, Fabiano Fidêncio wrote:
As the short-id can be used to set the os/platform in the example program, let's expose them to the user. --- examples/virt-designer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
Which project is this against? It may help to do 'git config format.subjectprefix "$proj PATCH"' to let reviewers know to look in libvirt-$proj.git instead of libvirt.git for applying this patch, for the appropriate value of $proj. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Eric, On Wed, 2014-10-22 at 11:55 -0600, Eric Blake wrote:
On 10/22/2014 08:16 AM, Fabiano Fidêncio wrote:
As the short-id can be used to set the os/platform in the example program, let's expose them to the user. --- examples/virt-designer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
Which project is this against? It may help to do 'git config format.subjectprefix "$proj PATCH"' to let reviewers know to look in libvirt-$proj.git instead of libvirt.git for applying this patch, for the appropriate value of $proj.
Yeah, thanks for the heads up. The patch is for libvirt-designer. I have just changed the subject. Best Regards, -- Fabiano Fidêncio

On 22.10.2014 16:16, Fabiano Fidêncio wrote:
As the short-id can be used to set the os/platform in the example program, let's expose them to the user. --- examples/virt-designer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/examples/virt-designer.c b/examples/virt-designer.c index 7628449..12faf04 100644 --- a/examples/virt-designer.c +++ b/examples/virt-designer.c @@ -107,8 +107,8 @@ print_oses(const gchar *option_name, if (!db && !load_osinfo()) goto cleanup;
- printf(" Operating System ID\n" - "-----------------------\n"); + printf(" Operating System ID (short ID)\n" + "--------------------------------\n");
list = osinfo_db_get_os_list(db); if (!list) @@ -119,6 +119,8 @@ print_oses(const gchar *option_name, OsinfoOs *os = OSINFO_OS(os_iter->data); const char *id = osinfo_entity_get_param_value(OSINFO_ENTITY(os), OSINFO_ENTITY_PROP_ID); + const char *short_id = osinfo_entity_get_param_value(OSINFO_ENTITY(os), + OSINFO_PRODUCT_PROP_SHORT_ID);
printf("%s\n", id); } @@ -148,8 +150,8 @@ print_platforms(const gchar *option_name, if (!db && !load_osinfo()) goto cleanup;
- printf(" Platform ID\n" - "---------------\n"); + printf(" Platform ID (short ID)\n" + "------------------------\n");
list = osinfo_db_get_platform_list(db); if (!list) @@ -160,6 +162,8 @@ print_platforms(const gchar *option_name, OsinfoPlatform *platform = OSINFO_PLATFORM(platform_iter->data); const char *id = osinfo_entity_get_param_value(OSINFO_ENTITY(platform), OSINFO_ENTITY_PROP_ID); + const char *short_id = osinfo_entity_get_param_value(OSINFO_ENTITY(platform), + OSINFO_PRODUCT_PROP_SHORT_ID);
printf("%s\n", id); } @@ -577,9 +581,9 @@ main(int argc, char *argv[]) {"connect", 'c', 0, G_OPTION_ARG_STRING, &connect_uri, "libvirt connection URI used for querying capabilities", "URI"}, {"list-os", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, print_oses, - "list IDs of known OSes", NULL}, + "list IDs and short IDs of known OSes", NULL}, {"list-platform", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, print_platforms, - "list IDs of known hypervisors", NULL}, + "list IDs and short IDs of known hypervisors", NULL}, {"os", 'o', 0, G_OPTION_ARG_STRING, &os_str, "set domain OS", "OS"}, {"platform", 'p', 0, G_OPTION_ARG_STRING, &platform_str,
The short_id variables are set, but not used anywhere. I guess the patch is incomplete. Moreover, I'd advise you to use '\t' as the separator between long and short IDs - we'll get nicely aligned output for nothing :) Looking forward to v2. Michal
participants (4)
-
Christophe Fergeau
-
Eric Blake
-
Fabiano Fidêncio
-
Michal Privoznik