[PATCH] Add echo_daemon command
echo_daemon is a simple echo which can be used to test connectivity between the client and daemon. --- daemon/Makefile.am | 1 + daemon/echo_daemon.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + src/MAX_PROC_NR | 2 +- src/generator.ml | 7 +++++ 5 files changed, 76 insertions(+), 1 deletions(-) create mode 100644 daemon/echo_daemon.c diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 83ee408..ae74699 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -36,6 +36,7 @@ guestfsd_SOURCES = \ dmesg.c \ dropcaches.c \ du.c \ + echo_daemon.c \ ext2.c \ fallocate.c \ file.c \ diff --git a/daemon/echo_daemon.c b/daemon/echo_daemon.c new file mode 100644 index 0000000..dbede2f --- /dev/null +++ b/daemon/echo_daemon.c @@ -0,0 +1,66 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <config.h> + +#include <string.h> + +#include "actions.h" + +char * +do_echo_daemon (char *const *argv) +{ + char *out = NULL; + size_t out_len = 0; + + /* Iterate over argv entries until reaching the NULL terminator */ + while (*argv) { + char add_space = 0; + + /* Store the end of current output */ + size_t out_end = out_len; + + /* Calculate the new output size */ + size_t arg_len = strlen(*argv); + out_len += arg_len; + + /* We will prepend a space if this isn't the first argument added */ + if (NULL != out) { + out_len++; + add_space = 1; + } + + /* Make the output buffer big enough for the string and its terminator */ + out = realloc (out, out_len + 1); + + /* Prepend a space if required */ + if (add_space) { + out[out_end++] = ' '; + } + + /* Copy the argument to the output */ + memcpy(&out[out_end], *argv, arg_len); + + argv++; + } + + /* NULL terminate the output */ + out[out_len] = '\0'; + + return out; +} diff --git a/po/POTFILES.in b/po/POTFILES.in index 1b2f82a..44e472b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ daemon/dir.c daemon/dmesg.c daemon/dropcaches.c daemon/du.c +daemon/echo_daemon.c daemon/ext2.c daemon/fallocate.c daemon/file.c diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 205a12b..6bb2f98 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -194 +195 diff --git a/src/generator.ml b/src/generator.ml index 439c9c4..f820e1f 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3595,6 +3595,13 @@ This loads a kernel module in the appliance. The kernel module must have been whitelisted when libguestfs was built (see C<appliance/kmod.whitelist.in> in the source)."); + ("echo_daemon", (RString "output", [StringList "words"]), 195, [], + [InitNone, Always, TestRun [["echo_daemon"; "\"This is a test\""]]], + "echo arguments back to the client", + "\ +This commands works much like the unix echo command. It returns its arguments as +a string."); + ] let all_functions = non_daemon_functions @ daemon_functions -- 1.6.2.5
On Fri, Sep 11, 2009 at 02:39:24PM +0100, Matthew Booth wrote:
echo_daemon is a simple echo which can be used to test connectivity between the client and daemon. --- daemon/Makefile.am | 1 + daemon/echo_daemon.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + src/MAX_PROC_NR | 2 +- src/generator.ml | 7 +++++ 5 files changed, 76 insertions(+), 1 deletions(-) create mode 100644 daemon/echo_daemon.c
diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 83ee408..ae74699 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -36,6 +36,7 @@ guestfsd_SOURCES = \ dmesg.c \ dropcaches.c \ du.c \ + echo_daemon.c \ ext2.c \ fallocate.c \ file.c \ diff --git a/daemon/echo_daemon.c b/daemon/echo_daemon.c new file mode 100644 index 0000000..dbede2f --- /dev/null +++ b/daemon/echo_daemon.c @@ -0,0 +1,66 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <config.h> + +#include <string.h> + +#include "actions.h" + +char * +do_echo_daemon (char *const *argv) +{ + char *out = NULL; + size_t out_len = 0; + + /* Iterate over argv entries until reaching the NULL terminator */ + while (*argv) { + char add_space = 0; + + /* Store the end of current output */ + size_t out_end = out_len; + + /* Calculate the new output size */ + size_t arg_len = strlen(*argv); + out_len += arg_len; + + /* We will prepend a space if this isn't the first argument added */ + if (NULL != out) { + out_len++; + add_space = 1; + } + + /* Make the output buffer big enough for the string and its terminator */ + out = realloc (out, out_len + 1);
In the daemon we have to check the return value from malloc/realloc very carefully. The reason is that the daemon runs in limited space.
+ /* Prepend a space if required */ + if (add_space) { + out[out_end++] = ' '; + } + + /* Copy the argument to the output */ + memcpy(&out[out_end], *argv, arg_len); + + argv++; + } + + /* NULL terminate the output */ + out[out_len] = '\0'; + + return out; +} diff --git a/po/POTFILES.in b/po/POTFILES.in index 1b2f82a..44e472b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ daemon/dir.c daemon/dmesg.c daemon/dropcaches.c daemon/du.c +daemon/echo_daemon.c daemon/ext2.c daemon/fallocate.c daemon/file.c diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 205a12b..6bb2f98 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -194 +195 diff --git a/src/generator.ml b/src/generator.ml index 439c9c4..f820e1f 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3595,6 +3595,13 @@ This loads a kernel module in the appliance. The kernel module must have been whitelisted when libguestfs was built (see C<appliance/kmod.whitelist.in> in the source).");
+ ("echo_daemon", (RString "output", [StringList "words"]), 195, [], + [InitNone, Always, TestRun [["echo_daemon"; "\"This is a test\""]]],
This should test the return value using TestOutput. Also note that this is passing a list of length four. (Handling of lists in the test code is very hairy).
+ "echo arguments back to the client", + "\ +This commands works much like the unix echo command. It returns its arguments as +a string.");
A better description: This command concatenates the list of C<words> passed with single spaces between them and returns the resulting string. You can use this to test the connection through to the daemon. See also C<guestfs_ping_daemon>. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
On 11/09/09 15:51, Richard W.M. Jones wrote:
On Fri, Sep 11, 2009 at 02:39:24PM +0100, Matthew Booth wrote:
+ /* Make the output buffer big enough for the string and its terminator */ + out = realloc (out, out_len + 1);
In the daemon we have to check the return value from malloc/realloc very carefully. The reason is that the daemon runs in limited space.
Good catch.
+ /* Prepend a space if required */ + if (add_space) { + out[out_end++] = ' '; + } + + /* Copy the argument to the output */ + memcpy(&out[out_end], *argv, arg_len); + + argv++; + } + + /* NULL terminate the output */ + out[out_len] = '\0'; + + return out; +} diff --git a/po/POTFILES.in b/po/POTFILES.in index 1b2f82a..44e472b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ daemon/dir.c daemon/dmesg.c daemon/dropcaches.c daemon/du.c +daemon/echo_daemon.c daemon/ext2.c daemon/fallocate.c daemon/file.c diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 205a12b..6bb2f98 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -194 +195 diff --git a/src/generator.ml b/src/generator.ml index 439c9c4..f820e1f 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3595,6 +3595,13 @@ This loads a kernel module in the appliance. The kernel module must have been whitelisted when libguestfs was built (see C<appliance/kmod.whitelist.in> in the source).");
+ ("echo_daemon", (RString "output", [StringList "words"]), 195, [], + [InitNone, Always, TestRun [["echo_daemon"; "\"This is a test\""]]],
This should test the return value using TestOutput. Also note that this is passing a list of length four. (Handling of lists in the test code is very hairy).
Ok.
+ "echo arguments back to the client", + "\ +This commands works much like the unix echo command. It returns its arguments as +a string.");
A better description:
This command concatenates the list of C<words> passed with single spaces between them and returns the resulting string.
You can use this to test the connection through to the daemon.
See also C<guestfs_ping_daemon>.
Ok. Updated patch to follow. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
echo_daemon is a simple echo which can be used to test connectivity between the client and daemon. --- daemon/Makefile.am | 1 + daemon/echo_daemon.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + src/MAX_PROC_NR | 2 +- src/generator.ml | 13 +++++++++ 5 files changed, 87 insertions(+), 1 deletions(-) create mode 100644 daemon/echo_daemon.c diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 83ee408..ae74699 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -36,6 +36,7 @@ guestfsd_SOURCES = \ dmesg.c \ dropcaches.c \ du.c \ + echo_daemon.c \ ext2.c \ fallocate.c \ file.c \ diff --git a/daemon/echo_daemon.c b/daemon/echo_daemon.c new file mode 100644 index 0000000..650b57d --- /dev/null +++ b/daemon/echo_daemon.c @@ -0,0 +1,71 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <config.h> + +#include <string.h> + +#include "actions.h" +#include "daemon.h" + +char * +do_echo_daemon (char *const *argv) +{ + char *out = NULL; + size_t out_len = 0; + + /* Iterate over argv entries until reaching the NULL terminator */ + while (*argv) { + char add_space = 0; + + /* Store the end of current output */ + size_t out_end = out_len; + + /* Calculate the new output size */ + size_t arg_len = strlen(*argv); + out_len += arg_len; + + /* We will prepend a space if this isn't the first argument added */ + if (NULL != out) { + out_len++; + add_space = 1; + } + + /* Make the output buffer big enough for the string and its terminator */ + out = realloc (out, out_len + 1); + if (NULL == out) { + reply_with_perror ("realloc"); + return 0; + } + + /* Prepend a space if required */ + if (add_space) { + out[out_end++] = ' '; + } + + /* Copy the argument to the output */ + memcpy(&out[out_end], *argv, arg_len); + + argv++; + } + + /* NULL terminate the output */ + out[out_len] = '\0'; + + return out; +} diff --git a/po/POTFILES.in b/po/POTFILES.in index 1b2f82a..44e472b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ daemon/dir.c daemon/dmesg.c daemon/dropcaches.c daemon/du.c +daemon/echo_daemon.c daemon/ext2.c daemon/fallocate.c daemon/file.c diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 205a12b..6bb2f98 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -194 +195 diff --git a/src/generator.ml b/src/generator.ml index 433c60a..32537df 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3569,6 +3569,19 @@ This loads a kernel module in the appliance. The kernel module must have been whitelisted when libguestfs was built (see C<appliance/kmod.whitelist.in> in the source)."); + ("echo_daemon", (RString "output", [StringList "words"]), 195, [], + [InitNone, Always, TestOutput ( + [["echo_daemon"; "This is a test"]], "This is a test" + )], + "echo arguments back to the client", + "\ +This command concatenate the list of C<words> passed with single spaces between +them and returns the resulting string. + +You can use this command to test the connection through to the daemon. + +See also C<guestfs_ping_daemon>."); + ] let all_functions = non_daemon_functions @ daemon_functions -- 1.6.2.5
On Fri, Sep 11, 2009 at 05:50:30PM +0100, Matthew Booth wrote:
+ out = realloc (out, out_len + 1); + if (NULL == out) { + reply_with_perror ("realloc"); + return 0; + }
Unfortunately this leaves the original buffer [out] still allocated on the error path. [...] As before, this needs tests. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 75 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
echo_daemon is a simple echo which can be used to test connectivity between the client and daemon. --- daemon/Makefile.am | 1 + daemon/echo_daemon.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + src/MAX_PROC_NR | 2 +- src/generator.ml | 13 +++++++++ 5 files changed, 88 insertions(+), 1 deletions(-) create mode 100644 daemon/echo_daemon.c diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 83ee408..ae74699 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -36,6 +36,7 @@ guestfsd_SOURCES = \ dmesg.c \ dropcaches.c \ du.c \ + echo_daemon.c \ ext2.c \ fallocate.c \ file.c \ diff --git a/daemon/echo_daemon.c b/daemon/echo_daemon.c new file mode 100644 index 0000000..27d3b95 --- /dev/null +++ b/daemon/echo_daemon.c @@ -0,0 +1,72 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <config.h> + +#include <string.h> + +#include "actions.h" +#include "daemon.h" + +char * +do_echo_daemon (char *const *argv) +{ + char *out = NULL; + size_t out_len = 0; + + /* Iterate over argv entries until reaching the NULL terminator */ + while (*argv) { + char add_space = 0; + + /* Store the end of current output */ + size_t out_end = out_len; + + /* Calculate the new output size */ + size_t arg_len = strlen(*argv); + out_len += arg_len; + + /* We will prepend a space if this isn't the first argument added */ + if (NULL != out) { + out_len++; + add_space = 1; + } + + /* Make the output buffer big enough for the string and its terminator */ + char *out_new = realloc (out, out_len + 1); + if (NULL == out_new) { + reply_with_perror ("realloc"); + return 0; + } + out = out_new; + + /* Prepend a space if required */ + if (add_space) { + out[out_end++] = ' '; + } + + /* Copy the argument to the output */ + memcpy(&out[out_end], *argv, arg_len); + + argv++; + } + + /* NULL terminate the output */ + out[out_len] = '\0'; + + return out; +} diff --git a/po/POTFILES.in b/po/POTFILES.in index 1b2f82a..44e472b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ daemon/dir.c daemon/dmesg.c daemon/dropcaches.c daemon/du.c +daemon/echo_daemon.c daemon/ext2.c daemon/fallocate.c daemon/file.c diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 205a12b..6bb2f98 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -194 +195 diff --git a/src/generator.ml b/src/generator.ml index 433c60a..32537df 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3569,6 +3569,19 @@ This loads a kernel module in the appliance. The kernel module must have been whitelisted when libguestfs was built (see C<appliance/kmod.whitelist.in> in the source)."); + ("echo_daemon", (RString "output", [StringList "words"]), 195, [], + [InitNone, Always, TestOutput ( + [["echo_daemon"; "This is a test"]], "This is a test" + )], + "echo arguments back to the client", + "\ +This command concatenate the list of C<words> passed with single spaces between +them and returns the resulting string. + +You can use this command to test the connection through to the daemon. + +See also C<guestfs_ping_daemon>."); + ] let all_functions = non_daemon_functions @ daemon_functions -- 1.6.2.5
On Mon, Sep 14, 2009 at 09:48:43AM +0100, Matthew Booth wrote:
+ /* Make the output buffer big enough for the string and its terminator */ + char *out_new = realloc (out, out_len + 1); + if (NULL == out_new) { + reply_with_perror ("realloc"); + return 0; + } + out = out_new;
No this is still wrong. It should call "free (out);" on the error path. Garbage collection FTW. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On 14/09/09 10:01, Richard W.M. Jones wrote:
On Mon, Sep 14, 2009 at 09:48:43AM +0100, Matthew Booth wrote:
+ /* Make the output buffer big enough for the string and its terminator */ + char *out_new = realloc (out, out_len + 1); + if (NULL == out_new) { + reply_with_perror ("realloc"); + return 0; + } + out = out_new;
No this is still wrong. It should call "free (out);" on the error path.
Garbage collection FTW.
That's what I get for shooting from the hip :) New patch to follow. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
echo_daemon is a simple echo which can be used to test connectivity between the client and daemon. --- daemon/Makefile.am | 1 + daemon/echo_daemon.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + src/MAX_PROC_NR | 2 +- src/generator.ml | 13 +++++++++ 5 files changed, 89 insertions(+), 1 deletions(-) create mode 100644 daemon/echo_daemon.c diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 83ee408..ae74699 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -36,6 +36,7 @@ guestfsd_SOURCES = \ dmesg.c \ dropcaches.c \ du.c \ + echo_daemon.c \ ext2.c \ fallocate.c \ file.c \ diff --git a/daemon/echo_daemon.c b/daemon/echo_daemon.c new file mode 100644 index 0000000..658974b --- /dev/null +++ b/daemon/echo_daemon.c @@ -0,0 +1,73 @@ +/* libguestfs - the guestfsd daemon + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <config.h> + +#include <string.h> + +#include "actions.h" +#include "daemon.h" + +char * +do_echo_daemon (char *const *argv) +{ + char *out = NULL; + size_t out_len = 0; + + /* Iterate over argv entries until reaching the NULL terminator */ + while (*argv) { + char add_space = 0; + + /* Store the end of current output */ + size_t out_end = out_len; + + /* Calculate the new output size */ + size_t arg_len = strlen(*argv); + out_len += arg_len; + + /* We will prepend a space if this isn't the first argument added */ + if (NULL != out) { + out_len++; + add_space = 1; + } + + /* Make the output buffer big enough for the string and its terminator */ + char *out_new = realloc (out, out_len + 1); + if (NULL == out_new) { + reply_with_perror ("realloc"); + free(out); + return 0; + } + out = out_new; + + /* Prepend a space if required */ + if (add_space) { + out[out_end++] = ' '; + } + + /* Copy the argument to the output */ + memcpy(&out[out_end], *argv, arg_len); + + argv++; + } + + /* NULL terminate the output */ + out[out_len] = '\0'; + + return out; +} diff --git a/po/POTFILES.in b/po/POTFILES.in index 1b2f82a..44e472b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ daemon/dir.c daemon/dmesg.c daemon/dropcaches.c daemon/du.c +daemon/echo_daemon.c daemon/ext2.c daemon/fallocate.c daemon/file.c diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 205a12b..6bb2f98 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -194 +195 diff --git a/src/generator.ml b/src/generator.ml index 433c60a..32537df 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3569,6 +3569,19 @@ This loads a kernel module in the appliance. The kernel module must have been whitelisted when libguestfs was built (see C<appliance/kmod.whitelist.in> in the source)."); + ("echo_daemon", (RString "output", [StringList "words"]), 195, [], + [InitNone, Always, TestOutput ( + [["echo_daemon"; "This is a test"]], "This is a test" + )], + "echo arguments back to the client", + "\ +This command concatenate the list of C<words> passed with single spaces between +them and returns the resulting string. + +You can use this command to test the connection through to the daemon. + +See also C<guestfs_ping_daemon>."); + ] let all_functions = non_daemon_functions @ daemon_functions -- 1.6.2.5
On Mon, Sep 14, 2009 at 10:08:12AM +0100, Matthew Booth wrote:
echo_daemon is a simple echo which can be used to test connectivity between the client and daemon.
ACK. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 75 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
On 12/09/09 11:05, Richard W.M. Jones wrote:
On Fri, Sep 11, 2009 at 05:50:30PM +0100, Matthew Booth wrote:
+ out = realloc (out, out_len + 1); + if (NULL == out) { + reply_with_perror ("realloc"); + return 0; + }
Unfortunately this leaves the original buffer [out] still allocated on the error path.
Another good catch :) I'll have to check my string list patch for this too, although I think I always exit() there. Updated patch sent.
[...]
As before, this needs tests.
It contains a test! It's a pretty simple function. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
On Mon, Sep 14, 2009 at 09:50:33AM +0100, Matthew Booth wrote:
On 12/09/09 11:05, Richard W.M. Jones wrote:
On Fri, Sep 11, 2009 at 05:50:30PM +0100, Matthew Booth wrote:
+ out = realloc (out, out_len + 1); + if (NULL == out) { + reply_with_perror ("realloc"); + return 0; + }
Unfortunately this leaves the original buffer [out] still allocated on the error path.
Another good catch :) I'll have to check my string list patch for this too, although I think I always exit() there. Updated patch sent.
[...]
As before, this needs tests.
It contains a test! It's a pretty simple function.
Sorry, I was confusing the echo_daemon command with the purpose of adding this command (the quoting stuff). It's the quoting stuff that (will) need tests. This patch is OK if you fix the realloc problem. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
participants (2)
-
Matthew Booth -
Richard W.M. Jones