From: Jes Sorensen <Jes.Sorensen@redhat.com>
To: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com,
agl@linux.vnet.ibm.com, qemu-devel@nongnu.org,
abeekhof@redhat.com
Subject: Re: [Qemu-devel] [RFC][PATCH v4 04/18] virtagent: base RPC client definitions
Date: Thu, 18 Nov 2010 15:10:20 +0100 [thread overview]
Message-ID: <4CE533CC.80604@redhat.com> (raw)
In-Reply-To: <1289923320-5638-5-git-send-email-mdroth@linux.vnet.ibm.com>
On 11/16/10 17:01, Michael Roth wrote:
> diff --git a/monitor.c b/monitor.c
> index 8cee35d..cb81cd7 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -42,6 +42,7 @@
> #include "audio/audio.h"
> #include "disas.h"
> #include "balloon.h"
> +#include "virtagent.h"
> #include "qemu-timer.h"
> #include "migration.h"
> #include "kvm.h"
You are adding an include here without modifying any code to actually
use something from this file.
> +static int va_client_ready(void)
> +{
> + if (client_state != NULL && client_state->vp != NULL
> + && client_state->socket_path != NULL) {
Please put the && up on the previous line, makes it easier for a reader
to notice that the next line is part of the first portion.
> + return 0;
> + }
> +
> + return -1;
> +}
-EAGAIN? -EBUSY?
> +static void va_set_capabilities(QList *qlist)
> +{
> + TRACE("called");
> +
> + if (client_state == NULL) {
> + LOG("client is uninitialized, unable to set capabilities");
> + return;
> + }
Why no error value returned here?
> +int va_client_init(VPDriver *vp_drv, bool is_host)
> +{
> + const char *service_id, *path;
> + QemuOpts *opts;
> + int fd, ret;
> +
> + if (client_state) {
> + LOG("virtagent client already initialized");
> + return -1;
> + }
-1 again :(
> + /* setup listening socket to forward connections over */
> + opts = qemu_opts_create(qemu_find_opts("net"), "va_client_opts", 0);
> + qemu_opt_set(opts, "path", path);
> + fd = unix_listen_opts(opts);
> + qemu_opts_del(opts);
> + if (fd < 0) {
> + LOG("error setting up listening socket");
> + goto out_bad;
> + }
> +
> + /* tell virtproxy to forward connections to this socket to
> + * virtagent service on other end
> + */
> + ret = vp_set_oforward(vp_drv, fd, service_id);
> + if (ret < 0) {
> + LOG("error setting up virtproxy iforward");
> + goto out_bad;
> + }
> +
> + return 0;
> +out_bad:
> + qemu_free(client_state);
> + client_state = NULL;
> + return -1;
> +}
You know why you ended up here, please pass that information up the stack.
> +static int rpc_has_error(xmlrpc_env *env)
> +{
> + if (env->fault_occurred) {
> + LOG("An RPC error has occurred (%i): %s\n", env->fault_code, env->fault_string);
> + //qerror_report(QERR_RPC_FAILED, env->fault_code, env->fault_string);
> + return -1;
> + }
> + return 0;
> +}
-1 again
> +/*
> + * Get a connected socket that can be used to make an RPC call
> + * This interface will eventually return the connected virtproxy socket for the
> + * virt-agent channel
> + */
> +static int get_transport_fd(void)
> +{
> + /* TODO: eventually this will need a path that is unique to other
> + * instances of qemu-vp/qemu. for the integrated qemu-vp we should
> + * explore the possiblity of not requiring a unix socket under the
> + * covers, as well as having client init code set up the oforward
> + * for the service rather than qemu-vp
> + */
> + int ret;
> + int fd = unix_connect(client_state->socket_path);
> + if (fd < 0) {
> + LOG("failed to connect to virtagent service");
> + }
> + ret = fcntl(fd, F_GETFL);
> + ret = fcntl(fd, F_SETFL, ret | O_NONBLOCK);
> + return fd;
> +}
You are forgetting to check the return from fcntl() for errors.
> +static int rpc_execute(xmlrpc_env *const env, const char *function,
> + xmlrpc_value *params, VARPCData *rpc_data)
> +{
> + xmlrpc_mem_block *call_xml;
> + int fd, ret;
> +
> + ret = va_client_ready();
> + if (ret < 0) {
> + LOG("client in uninitialized state, unable to execute RPC");
> + ret = -1;
> + goto out;
> + }
> +
> + if (!va_has_capability(function)) {
> + LOG("guest agent does not have required capability");
> + ret = -1;
> + goto out;
> + }
> +
> + fd = get_transport_fd();
> + if (fd < 0) {
> + LOG("invalid fd");
> + ret = -1;
> + goto out;
> + }
You just got a proper error value back, why replace it with -1? It is
all over this function.
> diff --git a/virtagent.h b/virtagent.h
> new file mode 100644
> index 0000000..53efa29
> --- /dev/null
> +++ b/virtagent.h
> +#define GUEST_AGENT_PATH_CLIENT "/tmp/virtagent-guest-client.sock"
> +#define HOST_AGENT_PATH_CLIENT "/tmp/virtagent-host-client.sock"
> +#define VA_MAX_CHUNK_SIZE 4096 /* max bytes at a time for get/send file */
Config file please!
Jes
next prev parent reply other threads:[~2010-11-18 14:10 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 16:01 [Qemu-devel] [RFC][PATCH v4 00/18] virtagent: host/guest RPC communication agent Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 01/18] virtagent: add common rpc transport defs Michael Roth
2010-11-18 13:53 ` Jes Sorensen
2010-11-18 16:33 ` Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 02/18] virtagent: base definitions for host/guest RPC server Michael Roth
2010-11-18 13:57 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 03/18] virtagent: qemu-vp, integrate virtagent server Michael Roth
2010-11-18 14:02 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 04/18] virtagent: base RPC client definitions Michael Roth
2010-11-18 14:10 ` Jes Sorensen [this message]
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 05/18] virtagent: add getfile RPC Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 06/18] virtagent: add agent_viewfile command Michael Roth
2010-11-18 14:13 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 07/18] virtagent: add getdmesg RPC Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 08/18] virtagent: add agent_viewdmesg command Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 09/18] virtagent: add va_shutdown RPC Michael Roth
2010-11-18 14:17 ` Jes Sorensen
2010-11-18 15:35 ` Anthony Liguori
2010-11-18 15:41 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 10/18] virtagent: add agent_shutdown monitor command Michael Roth
2010-11-18 14:19 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 11/18] virtagent: add va_ping RPC Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 12/18] virtagent: add agent_ping monitor command Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 13/18] virtagent: add agent_capabilities monitor function Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 14/18] virtagent: add client capabilities init function Michael Roth
2010-11-18 14:22 ` Jes Sorensen
2010-11-18 16:43 ` Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 15/18] virtagent: add va_hello RPC function Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 16/18] virtagent: add va_send_hello() client function Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 17/18] virtagent: qemu-vp, va_send_hello() on startup Michael Roth
2010-11-18 14:22 ` Jes Sorensen
2010-11-16 16:02 ` [Qemu-devel] [RFC][PATCH v4 18/18] virtagent: Makefile/configure changes to build virtagent bits Michael Roth
2010-11-18 13:50 ` [Qemu-devel] [RFC][PATCH v4 00/18] virtagent: host/guest RPC communication agent Jes Sorensen
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=4CE533CC.80604@redhat.com \
--to=jes.sorensen@redhat.com \
--cc=abeekhof@redhat.com \
--cc=agl@linux.vnet.ibm.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=ryanh@us.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.