[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 4/4] XXX a command to test the locking facility
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/xl/xl.h | 2 ++ tools/xl/xl_cmdtable.c | 5 +++++ tools/xl/xl_misc.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 8d667ff444..9cb135baf2 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -209,6 +209,8 @@ int main_psr_cat_show(int argc, char **argv); #endif int main_qemu_monitor_command(int argc, char **argv); +int main_lock(int argc, char **argv); + void help(const char *command); extern const char *common_domname; diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 30eb93c17f..01db5fb8f4 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -591,6 +591,11 @@ struct cmd_spec cmd_table[] = { "Issue a qemu monitor command to the device model of a domain", "<Domain> <Command>", }, + { "lock", + &main_lock, 0, 0, + "Lock a domain, prevent other xl processes from manipulating it", + "<Domain>", + }, }; int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec); diff --git a/tools/xl/xl_misc.c b/tools/xl/xl_misc.c index 9c6227af23..772fd7adb4 100644 --- a/tools/xl/xl_misc.c +++ b/tools/xl/xl_misc.c @@ -14,6 +14,7 @@ #include <limits.h> #include <stdlib.h> +#include <unistd.h> #include <libxl.h> #include <libxl_utils.h> @@ -344,6 +345,42 @@ int main_config_update(int argc, char **argv) return 0; } +struct lock_arg { + uint32_t domid; +}; + +static int lock_fn(void *p) +{ + struct lock_arg *arg = p; + + fprintf(stderr, "Now I have the lock for %u\n", arg->domid); + + sleep(10); + + fprintf(stderr, "Done\n"); + + return 0; +} + +int main_lock(int argc, char **argv) +{ + uint32_t domid; + struct lock_arg arg; + int rc; + + domid = find_domain(argv[optind++]); + + fprintf(stderr, "About to lock %u\n", domid); + + arg.domid = domid; + + rc = with_lock(domid, lock_fn, &arg); + fprintf(stderr, "with_lock returned, rc = %d\n", rc); + if (rc) + return EXIT_FAILURE; + return EXIT_SUCCESS; +} + /* * Local variables: * mode: C -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |