summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-04-05 12:44:34 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-04-05 20:01:15 +0100
commit9e7c6a548353bde925c16434711bcc6208038d83 (patch)
treeb1b46b05e7319a36c38813a3b1eb15eb277ed948 /examples
parent9b945cfa781a0f25c3b81239e2fcddceeede6e44 (diff)
downloadlibguestfs-9e7c6a548353bde925c16434711bcc6208038d83.tar.gz
libguestfs-9e7c6a548353bde925c16434711bcc6208038d83.tar.xz
libguestfs-9e7c6a548353bde925c16434711bcc6208038d83.zip
New API: inspect-get-windows-current-control-set
This returns the actual registry key corresponding to CurrentControlSet (eg. it might be "ControlSet001"). Previously the inspection code was hard-coding ControlSet001. Now we use the correct control set, and also make it available to callers through the API. This commit also updates the virt-dhcp-address example so it uses this new API. virt-inspector displays the current control set when available.
Diffstat (limited to 'examples')
-rw-r--r--examples/virt-dhcp-address.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/examples/virt-dhcp-address.c b/examples/virt-dhcp-address.c
index c075a473..5b68313a 100644
--- a/examples/virt-dhcp-address.c
+++ b/examples/virt-dhcp-address.c
@@ -189,7 +189,7 @@ print_dhcp_address_linux (guestfs_h *g, char *root, const char *logfile)
/* Download the Windows SYSTEM hive and find DHCP configuration in there. */
static void
-print_dhcp_address_windows (guestfs_h *g, char *root_unused)
+print_dhcp_address_windows (guestfs_h *g, char *root_fs)
{
char *system_path;
char tmpfile[] = "/tmp/systemXXXXXX";
@@ -197,8 +197,7 @@ print_dhcp_address_windows (guestfs_h *g, char *root_unused)
hive_h *h;
hive_node_h root, node, *nodes;
hive_value_h value;
- int32_t dword;
- char controlset[] = "ControlSetXXX";
+ char *controlset;
size_t i;
char *p;
@@ -222,6 +221,10 @@ print_dhcp_address_windows (guestfs_h *g, char *root_unused)
free (system_path);
+ controlset = guestfs_inspect_get_windows_current_control_set (g, root_fs);
+ if (controlset == NULL)
+ exit (EXIT_FAILURE);
+
/* Open the hive to parse it. */
h = hivex_open (tmpfile, 0);
err = errno;
@@ -234,31 +237,11 @@ print_dhcp_address_windows (guestfs_h *g, char *root_unused)
exit (EXIT_FAILURE);
}
- /* Navigate to the Select key so we know which ControlSet is in use. */
root = hivex_root (h);
if (root == 0) {
perror ("hivex_root");
exit (EXIT_FAILURE);
}
- node = hivex_node_get_child (h, root, "Select");
- if (node == 0) {
- if (errno != 0)
- perror ("hivex_node_get_child");
- else
- fprintf (stderr, "virt-dhcp-address: HKLM\\System\\Select key not found.");
- exit (EXIT_FAILURE);
- }
- value = hivex_node_get_value (h, node, "Current");
- if (value == 0) {
- if (errno != 0)
- perror ("hivex_node_get_value");
- else
- fprintf (stderr, "virt-dhcp-address: HKLM\\System\\Select Default entry not found.");
- exit (EXIT_FAILURE);
- }
- /* XXX Should check the type. */
- dword = hivex_value_dword (h, value);
- snprintf (controlset, sizeof controlset, "ControlSet%03d", dword);
/* Get ControlSetXXX\Services\Tcpip\Parameters\Interfaces. */
const char *path[] = { controlset, "Services", "Tcpip", "Parameters",
@@ -311,6 +294,8 @@ print_dhcp_address_windows (guestfs_h *g, char *root_unused)
/* Close the hive handle. */
hivex_close (h);
+
+ free (controlset);
}
static int