From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@linux.vnet.ibm.com, agl@linux.vnet.ibm.com,
mdroth@linux.vnet.ibm.com
Subject: [Qemu-devel] [RFC][PATCH v2 03/10] virtagent: qemu-vp, integrate virtagent server
Date: Wed, 3 Nov 2010 06:35:32 -0500 [thread overview]
Message-ID: <1288784139-1110-4-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1288784139-1110-1-git-send-email-mdroth@linux.vnet.ibm.com>
This allows the guest RPC server to be integrated into the
qemu-vp/virtproxy i/o loop
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qemu-vp.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 106 insertions(+), 9 deletions(-)
diff --git a/qemu-vp.c b/qemu-vp.c
index 0cc0e67..8944e68 100644
--- a/qemu-vp.c
+++ b/qemu-vp.c
@@ -37,6 +37,7 @@
#include "qemu-option.h"
#include "qemu_socket.h"
#include "virtproxy.h"
+#include "virtagent-daemon.h"
static bool verbose_enabled = 0;
#define DEBUG_ENABLED
@@ -246,14 +247,18 @@ static void usage(const char *cmd)
"[-o <oforward_opts> ...]\n"
"QEMU virt-proxy communication channel\n"
"\n"
-" -c, --channel channel options of the form:\n"
-" <method>:<addr>:<port>[:channel_id]\n"
-" -o, --oforward oforward options of the form:\n"
-" <service_id>:<addr>:<port>[:channel_id]\n"
-" -i, --iforward iforward options of the form:\n"
-" <service_id>:<addr>:<port>[:channel_id]\n"
-" -v, --verbose display extra debugging information\n"
-" -h, --help display this help and exit\n"
+" -c, --channel channel options of the form:\n"
+" <method>:<addr>:<port>[:channel_id]\n"
+" -p, --host-agent host rpc server, options of the form:\n"
+" [channel_id]\n"
+" -g, --guest-agent guest rpc server, options of the form:\n"
+" [channel_id]\n"
+" -o, --oforward oforward options of the form:\n"
+" <service_id>:<addr>:<port>[:channel_id]\n"
+" -i, --iforward iforward options of the form:\n"
+" <service_id>:<addr>:<port>[:channel_id]\n"
+" -v, --verbose display extra debugging information\n"
+" -h, --help display this help and exit\n"
"\n"
" channels are used to establish a data connection between 2 end-points in\n"
" the host or the guest (connection method specified by <method>).\n"
@@ -527,13 +532,44 @@ static int init_iforwards(void) {
return 0;
}
+static int init_agent(const VPData *agent_iforward, bool is_host) {
+ QemuOpts *opts = agent_iforward->opts;
+ int listen_fd, ret;
+
+ INFO("initializing agent...");
+ if (verbose_enabled) {
+ qemu_opts_print(opts, NULL);
+ }
+
+ /* create unix socket pair that agent http/rpc daemon will listen on */
+ listen_fd = unix_listen_opts(agent_iforward->opts);
+ if (listen_fd < 0) {
+ return -1;
+ }
+
+ /* start RPC server */
+ ret = va_server_start(listen_fd, is_host);
+ if (ret != 0) {
+ warnx("error starting RPC server");
+ goto err;
+ }
+
+ return 0;
+
+err:
+ closesocket(listen_fd);
+ return -1;
+}
+
int main(int argc, char **argv)
{
- const char *sopt = "hVvi:o:c:";
+ const char *sopt = "hVvi:o:c:g::p::";
struct option lopt[] = {
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
{ "verbose", 0, NULL, 'v' },
+ { "host-agent", 0, NULL, 'p' },
+ { "guest-agent", 0, NULL, 'g' },
{ "iforward", 0, NULL, 'i' },
{ "oforward", 0, NULL, 'o' },
{ "channel", 0, NULL, 'c' },
@@ -543,10 +579,13 @@ int main(int argc, char **argv)
QTAILQ_INIT(&iforwards);
QTAILQ_INIT(&oforwards);
QTAILQ_INIT(&channels);
+ VPData *guest_agent_iforward = NULL;
+ VPData *host_agent_iforward = NULL;
while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
QemuOpts *opts;
VPData *data;
+ char optarg_tmp[VP_ARG_LEN];
switch (ch) {
case 'i':
opts = qemu_opts_create(&vp_opts, NULL, 0);
@@ -578,6 +617,50 @@ int main(int argc, char **argv)
data->opts = opts;
QTAILQ_INSERT_TAIL(&channels, data, next);
break;
+ case 'g':
+ /* create pre-baked iforward for guest agent */
+ if (guest_agent_iforward) {
+ errx(EXIT_FAILURE, "only one --guest-agent argument allowed");
+ }
+ opts = qemu_opts_create(&vp_opts, NULL, 0);
+ if (optarg == 0) {
+ sprintf(optarg_tmp, "%s:%s:-", GUEST_AGENT_SERVICE_ID,
+ GUEST_AGENT_PATH);
+ } else {
+ sprintf(optarg_tmp, "%s:%s:-:%d", GUEST_AGENT_SERVICE_ID,
+ GUEST_AGENT_PATH, atoi(optarg));
+ }
+ ret = vp_parse(opts, optarg_tmp, 0);
+ if (ret) {
+ errx(EXIT_FAILURE, "error parsing arg: %s", optarg);
+ }
+ data = qemu_mallocz(sizeof(VPData));
+ data->opts = opts;
+ QTAILQ_INSERT_TAIL(&iforwards, data, next);
+ guest_agent_iforward = data;
+ break;
+ case 'p':
+ /* create pre-baked iforward for host agent */
+ if (host_agent_iforward) {
+ errx(EXIT_FAILURE, "only one --host-agent argument allowed");
+ }
+ opts = qemu_opts_create(&vp_opts, NULL, 0);
+ if (optarg == 0) {
+ sprintf(optarg_tmp, "%s:%s:-", HOST_AGENT_SERVICE_ID,
+ HOST_AGENT_PATH);
+ } else {
+ sprintf(optarg_tmp, "%s:%s:-:%d", HOST_AGENT_SERVICE_ID,
+ HOST_AGENT_PATH, atoi(optarg));
+ }
+ ret = vp_parse(opts, optarg_tmp, 0);
+ if (ret) {
+ errx(EXIT_FAILURE, "error parsing arg: %s", optarg);
+ }
+ data = qemu_mallocz(sizeof(VPData));
+ data->opts = opts;
+ QTAILQ_INSERT_TAIL(&iforwards, data, next);
+ host_agent_iforward = data;
+ break;
case 'v':
verbose_enabled = 1;
break;
@@ -607,6 +690,20 @@ int main(int argc, char **argv)
"error initializing service mappings for incoming connections");
}
+ if (guest_agent_iforward) {
+ ret = init_agent(guest_agent_iforward, false);
+ if (ret) {
+ errx(EXIT_FAILURE,
+ "error initializing guest agent");
+ }
+ } else if (host_agent_iforward) {
+ ret = init_agent(host_agent_iforward, true);
+ if (ret) {
+ errx(EXIT_FAILURE,
+ "error initializing host agent");
+ }
+ }
+
/* main i/o loop */
for (;;) {
DEBUG("entering main_loop_wait()");
--
1.7.0.4
next prev parent reply other threads:[~2010-11-03 11:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-03 11:35 [Qemu-devel] [RFC][PATCH v2 00/10] virtagent: host/guest RPC communication agent Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 01/10] virtagent: add common rpc transport defs Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 02/10] virtagent: base definitions for host/guest RPC daemon Michael Roth
2010-11-03 11:35 ` Michael Roth [this message]
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 04/10] virtagent: base RPC client definitions Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 05/10] virtagent: add getfile RPC Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 06/10] virtagent: add agent_viewfile command Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 07/10] virtagent: add getdmesg RPC Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 08/10] virtagent: add agent_viewdmesg command Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 09/10] virtagent: Makefile/configure changes to build virtagent bits Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 10/10] virtproxy: add compat defs for linking against vl.c Michael Roth
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=1288784139-1110-4-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=agl@linux.vnet.ibm.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.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).