X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=inspector%2Fvirt-inspector.c;h=4afce0e25585923cd191766e7b6827d742ccf6ca;hb=8b2e60ce4b46e86da093ee64d4e0b0ae3c998d55;hp=7724be652c7d2e84b67b9584cbb9aae066d1fab4;hpb=13d8963d8c0203e1f72c519e5acf79ebf7cccb4c;p=libguestfs.git diff --git a/inspector/virt-inspector.c b/inspector/virt-inspector.c index 7724be6..4afce0e 100644 --- a/inspector/virt-inspector.c +++ b/inspector/virt-inspector.c @@ -20,11 +20,13 @@ #include #include +#include #include #include #include #include #include +#include #include #include @@ -338,6 +340,7 @@ output_root (xmlTextWriterPtr xo, char *root) int i, r; char buf[32]; char canonical_root[strlen (root) + 1]; + size_t size; XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "operatingsystem")); @@ -426,6 +429,14 @@ output_root (xmlTextWriterPtr xo, char *root) free (str); ); + str = guestfs_inspect_get_hostname (g, root); + if (!str) exit (EXIT_FAILURE); + if (STRNEQ (str, "unknown")) + XMLERROR (-1, + xmlTextWriterWriteElement (xo, BAD_CAST "hostname", + BAD_CAST str)); + free (str); + str = guestfs_inspect_get_format (g, root); if (!str) exit (EXIT_FAILURE); if (STRNEQ (str, "unknown")) @@ -461,8 +472,32 @@ output_root (xmlTextWriterPtr xo, char *root) output_drive_mappings (xo, root); + /* We need to mount everything up in order to read out the list of + * applications and the icon, ie. everything below this point. + */ + inspect_mount_root (root); + output_applications (xo, root); + /* Don't return favicon. XXX Should we? */ + str = guestfs_inspect_get_icon (g, root, &size, + GUESTFS_INSPECT_GET_ICON_FAVICON, 0, + -1); + if (!str) exit (EXIT_FAILURE); + if (size > 0) { + XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "icon")); + XMLERROR (-1, xmlTextWriterWriteBase64 (xo, str, 0, size)); + XMLERROR (-1, xmlTextWriterEndElement (xo)); + } + /* Note we must free (str) even if size == 0, because that indicates + * there was no icon. + */ + free (str); + + /* Unmount (see inspect_mount_root above). */ + if (guestfs_umount_all (g) == -1) + exit (EXIT_FAILURE); + XMLERROR (-1, xmlTextWriterEndElement (xo)); } @@ -642,19 +677,12 @@ output_applications (xmlTextWriterPtr xo, char *root) struct guestfs_application_list *apps; size_t i; - /* We need to mount everything up in order to read out the list of - * applications. - */ - inspect_mount_root (root); - /* This returns an empty list if we simply couldn't determine the * applications, so if it returns NULL then it's a real error. */ apps = guestfs_inspect_list_applications (g, root); if (apps == NULL) exit (EXIT_FAILURE); - if (guestfs_umount_all (g) == -1) - exit (EXIT_FAILURE); XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "applications"));