From: Don Slutz <dslutz@verizon.com>
To: xen-devel@lists.xen.org
Cc: Don Slutz <dslutz@verizon.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [RFC][PATCH v1 3/3] Add xen-list-vmware-guestinfo
Date: Tue, 2 Sep 2014 08:07:20 -0400 [thread overview]
Message-ID: <1409659640-20615-4-git-send-email-dslutz@verizon.com> (raw)
In-Reply-To: <1409659640-20615-1-git-send-email-dslutz@verizon.com>
A tool to list currently set VMware guestinfo
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
.gitignore | 1 +
tools/misc/Makefile | 7 ++-
tools/misc/xen-list-vmware-guestinfo.c | 88 ++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+), 2 deletions(-)
create mode 100644 tools/misc/xen-list-vmware-guestinfo.c
diff --git a/.gitignore b/.gitignore
index d3602be..bcf317f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -181,6 +181,7 @@ tools/misc/xenpm
tools/misc/xen-hvmctx
tools/misc/xen-hvm-param
tools/misc/xen-vmware-guestinfo
+tools/misc/xen-list-vmware-guestinfo
tools/misc/gtraceview
tools/misc/gtracestat
tools/misc/xenlockprof
diff --git a/tools/misc/Makefile b/tools/misc/Makefile
index f2ffe1a..3e7d216 100644
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -10,7 +10,7 @@ CFLAGS += $(CFLAGS_libxenstore)
HDRS = $(wildcard *.h)
TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xencov
-TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
+TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-list-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
TARGETS-$(CONFIG_MIGRATE) += xen-hptool
TARGETS := $(TARGETS-y)
@@ -22,7 +22,7 @@ INSTALL_BIN := $(INSTALL_BIN-y)
INSTALL_SBIN-y := xen-bugtool xen-python-path xenperf xenpm xen-tmem-list-parse gtraceview \
gtracestat xenlockprof xenwatchdogd xen-ringwatch xencov
-INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
+INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-list-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
INSTALL_SBIN := $(INSTALL_SBIN-y)
@@ -63,6 +63,9 @@ xen-hvm-param: xen-hvm-param.o
xen-vmware-guestinfo: xen-vmware-guestinfo.o
$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
+xen-list-vmware-guestinfo: xen-list-vmware-guestinfo.o
+ $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
+
xen-hvmcrash: xen-hvmcrash.o
$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
diff --git a/tools/misc/xen-list-vmware-guestinfo.c b/tools/misc/xen-list-vmware-guestinfo.c
new file mode 100644
index 0000000..2d253b6
--- /dev/null
+++ b/tools/misc/xen-list-vmware-guestinfo.c
@@ -0,0 +1,88 @@
+/*
+ * tools/misc/xen-list-vmware-guestinfo.c
+ *
+ * Copyright (C) 2014 Verizon Corporation
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 (GPLv2)
+ * as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <err.h>
+
+#include <xenctrl.h>
+
+
+int
+main(int argc, char **argv)
+{
+ xc_interface *xch;
+ int domid;
+ int ret = 0;
+
+ unsigned int idx = 0;
+ char key[128];
+ unsigned int key_len;
+ char value[8192];
+ unsigned int value_len;
+
+ if ( argc != 2 )
+ errx(1, "usage: %s domid", argv[0]);
+
+ xch = xc_interface_open(0, 0, 0);
+ if ( !xch )
+ err(1, "failed to open control interface");
+
+ domid = atoi(argv[1]);
+
+ while ( !xc_fetch_vmport_guest_info(xch, domid, idx, sizeof(key),
+ &key_len, key, sizeof(value),
+ &value_len, value) )
+ {
+ if ( key_len )
+ {
+ char *keys = "";
+ char *vals = "";
+
+ /* Make sure this is a c-string */
+ if ( key_len < sizeof(key) )
+ key[key_len] = 0;
+ else
+ {
+ key[sizeof(key) - 1] = 0;
+ keys = "...";
+ }
+ /* Make sure this is a c-string */
+ if ( value_len < sizeof(value) )
+ value[value_len] = 0;
+ else
+ {
+ value[sizeof(value) - 1] = 0;
+ vals = "...";
+ }
+ printf("VMware guestinfo '%s'%s='%s'%s\n",
+ key, keys, value, vals);
+ }
+ idx++;
+ }
+ xc_interface_close(xch);
+
+ return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
1.8.4
prev parent reply other threads:[~2014-09-02 12:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 12:07 [RFC][PATCH v1 0/3] Optional unit test tools for VMware tools support Don Slutz
2014-09-02 12:07 ` [RFC][PATCH v1 1/3] Add xen-hvm-param Don Slutz
2014-09-02 12:47 ` Andrew Cooper
2014-09-02 15:11 ` Don Slutz
2014-09-02 12:07 ` [RFC][PATCH v1 2/3] Add xen-vmware-guestinfo Don Slutz
2014-09-02 12:07 ` Don Slutz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409659640-20615-4-git-send-email-dslutz@verizon.com \
--to=dslutz@verizon.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).