summaryrefslogtreecommitdiffstats
path: root/inspector
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-06-27 15:27:46 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-06-28 18:41:54 +0100
commit7f16c346bbeba2f2fe3c31ccb85158178a284d84 (patch)
tree6d69f6b20598b05e8aa6eabeba96c40ade38f9f7 /inspector
parent5f26270c343bf543a7bf20cf3e6f182f6282f8ea (diff)
downloadlibguestfs-7f16c346bbeba2f2fe3c31ccb85158178a284d84.tar.gz
libguestfs-7f16c346bbeba2f2fe3c31ccb85158178a284d84.tar.xz
libguestfs-7f16c346bbeba2f2fe3c31ccb85158178a284d84.zip
New API: inspect-get-icon returns the guest icon.
This API returns the guest's favicon if found, else an icon representing the guest operating system. Currently supported by this patch: Fedora, RHEL and derivatives, Debian (but not Ubuntu), Windows XP, Windows 7. This also updates virt-inspector to include an <icon> element containing the icon in base64 encoding.
Diffstat (limited to 'inspector')
-rw-r--r--inspector/virt-inspector.c32
-rw-r--r--inspector/virt-inspector.rng6
2 files changed, 30 insertions, 8 deletions
diff --git a/inspector/virt-inspector.c b/inspector/virt-inspector.c
index 607e5ae0..4afce0e2 100644
--- a/inspector/virt-inspector.c
+++ b/inspector/virt-inspector.c
@@ -340,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"));
@@ -471,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));
}
@@ -652,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"));
diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng
index 480467ed..4fd208a3 100644
--- a/inspector/virt-inspector.rng
+++ b/inspector/virt-inspector.rng
@@ -1,4 +1,6 @@
-<grammar xmlns="http://relaxng.org/ns/structure/1.0">
+<grammar
+ xmlns="http://relaxng.org/ns/structure/1.0"
+ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<!-- -*- xml -*-
This is a RELAX NG schema for the output of 'virt-inspector'.
@@ -51,6 +53,8 @@
<optional><ref name="drive_mappings"/></optional>
<optional><ref name="applications"/></optional>
+ <optional><element name="icon"><data type="base64Binary"/></element></optional>
+
</interleave>
</element>
</oneOrMore>