All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 3/3]xl: Add "xl rename" command
Date: Fri, 07 May 2010 14:06:09 +0800	[thread overview]
Message-ID: <4BE3ADD1.7090703@cn.fujitsu.com> (raw)

Hi Keir, Stefano,

It's based on my previous 2 patchs: Add "xl domid" command / Add "xl domname" command

==========================================================

Add "xl rename" command, a clone of "xm rename".

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>

diff -r 357eab43f7ee -r 636a21458395 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri May 07 20:06:28 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.c	Fri May 07 22:01:41 2010 +0800
@@ -1227,6 +1227,9 @@
     } else if (!strcmp(command, "domname")) {
         printf("Usage: xl domname <DomainId>\n\n");
         printf("Convert a domain id to domain name.\n");
+    } else if (!strcmp(command, "rename")) {
+        printf("Usage: xl rename <Domain> <NewDomainName>\n\n");
+        printf("Rename a domain.\n");
     }
 }
 
@@ -3024,3 +3027,45 @@
 
     exit(0);
 }
+
+int main_rename(int argc, char **argv)
+{
+    int opt;
+    char *dom;
+    char *new_name;
+    xs_transaction_t t;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("rename");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    dom = argv[optind++];
+    if (!dom || !argv[optind]) {
+        fprintf(stderr, "'xl rename' requires 2 arguments.\n\n");
+        help("rename");
+        exit(1);
+    }
+
+    find_domain(dom);
+    new_name = argv[optind];
+
+retry_transaction:
+    t = xs_transaction_start(ctx.xsh);
+    if (libxl_domain_rename(&ctx, domid, common_domname, new_name, t)) {
+        fprintf(stderr, "Can't rename domain '%s'.\n", dom);
+        exit(1);
+    }
+
+    if (!xs_transaction_end(ctx.xsh, t, 0))
+        if (errno == EAGAIN)
+            goto retry_transaction;
+
+    exit(0);
+}
diff -r 357eab43f7ee -r 636a21458395 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Fri May 07 20:06:28 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.h	Fri May 07 22:01:41 2010 +0800
@@ -37,5 +37,6 @@
 int main_sched_credit(int argc, char **argv);
 int main_domid(int argc, char **argv);
 int main_domname(int argc, char **argv);
+int main_rename(int argc, char **argv);
 
 void help(char *command);
diff -r 357eab43f7ee -r 636a21458395 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Fri May 07 20:06:28 2010 +0800
+++ b/tools/libxl/xl_cmdtable.c	Fri May 07 22:01:41 2010 +0800
@@ -38,6 +38,7 @@
     { "sched-credit", &main_sched_credit, "get/set credit scheduler parameters" },
     { "domid", &main_domid, "convert a domain name to domain id"},
     { "domname", &main_domname, "convert a domain id to domain name"},
+    { "rename", &main_rename, "rename a domain"},
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

             reply	other threads:[~2010-05-07  6:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-07  6:06 Yang Hongyang [this message]
2010-05-07 15:45 ` [PATCH 3/3]xl: Add "xl rename" command Stefano Stabellini
2010-05-07 15:56   ` Christoph Egger
2010-05-10  0:53   ` Yang Hongyang

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=4BE3ADD1.7090703@cn.fujitsu.com \
    --to=yanghy@cn.fujitsu.com \
    --cc=xen-devel@lists.xensource.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.