[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v10 04/24] xen-xsplice: Tool to manipulate xsplice payloads
On Wed, Apr 27, 2016 at 8:27 PM, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> wrote: > A simple tool that allows an system admin to perform > basic xsplice operations: > > - Upload a xsplice file (with an unique name) > - List all the xsplice payloads loaded. > - Apply, revert, replace, or unload the payload using the > unique name. > - Do all two - upload, and apply the payload in one go (load). > Also will use the name of the file as the <name> > > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> > Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx> > Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> [snip] > diff --git a/tools/misc/xen-xsplice.c b/tools/misc/xen-xsplice.c > new file mode 100644 > index 0000000..0f1ab5a > --- /dev/null > +++ b/tools/misc/xen-xsplice.c > @@ -0,0 +1,463 @@ > +/* > + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. > + */ > + > +#include <fcntl.h> > +#include <libgen.h> > +#include <stdio.h> > +#include <stdlib.h> > +#include <string.h> > +#include <sys/mman.h> > +#include <sys/stat.h> > +#include <unistd.h> > +#include <xenctrl.h> > +#include <xenstore.h> > + > +static xc_interface *xch; > + > +void show_help(void) > +{ > + fprintf(stderr, > + "xen-xsplice: Xsplice test tool\n" > + "Usage: xen-xsplice <command> [args]\n" > + " <name> An unique name of payload. Up to %d characters.\n" > + "Commands:\n" > + " help display this help\n" > + " upload <name> <file> upload file <file> with <name> name\n" > + " list list payloads uploaded.\n" > + " apply <name> apply <name> patch.\n" > + " revert <name> revert name <name> patch.\n" > + " replace <name> apply <name> patch and revert all > others.\n" > + " unload <name> unload name <name> patch.\n" > + " load <file> upload and apply <file>.\n" > + " name is the <file> name\n", > + XEN_XSPLICE_NAME_SIZE); > +} > + > +/* wrapper function */ > +static int help_func(int argc, char *argv[]) > +{ > + show_help(); > + return 0; > +} > + > +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) > + > +static const char *state2str(unsigned int state) > +{ > +#define STATE(x) [XSPLICE_STATE_##x] = #x > + static const char *const names[] = { > + STATE(CHECKED), > + STATE(APPLIED), > + }; > +#undef STATE > + if (state >= ARRAY_SIZE(names) || !names[state]) > + return "unknown"; > + > + return names[state]; > +} > + > +/* This value was choosen adhoc. It could be 42 too. */ > +#define MAX_LEN 11 > +static int list_func(int argc, char *argv[]) > +{ > + unsigned int idx, done, left, i; > + xen_xsplice_status_t *info = NULL; > + char *name = NULL; > + uint32_t *len = NULL; > + int rc = ENOMEM; > + > + if ( argc ) > + { > + show_help(); > + return -1; > + } > + idx = left = 0; > + info = malloc(sizeof(*info) * MAX_LEN); > + if ( !info ) > + return rc; > + name = malloc(sizeof(*name) * XEN_XSPLICE_NAME_SIZE * MAX_LEN); > + if ( !name ) > + { > + free(info); > + return rc; > + } > + len = malloc(sizeof(*len) * MAX_LEN); > + if ( !len ) { > + free(name); > + free(info); > + return rc; > + } > + > + fprintf(stdout," ID | status\n" > + > "----------------------------------------+------------\n"); > + do { > + done = 0; > + /* The memset is done to catch errors. */ > + memset(info, 'A', sizeof(*info) * MAX_LEN); > + memset(name, 'B', sizeof(*name * MAX_LEN * XEN_XSPLICE_NAME_SIZE)); Did you mean to put the "* MAX_LEN * XEN_XSPLICE_NAME_SIZE" inside the sizeof()? Coverity thinks it's "suspicious", and I do to. :-) -George _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |