WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 3/3]xl: Add "xl rename" command

To: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 3/3]xl: Add "xl rename" command
From: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
Date: Mon, 10 May 2010 08:53:14 +0800
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Sun, 09 May 2010 17:53:07 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <alpine.DEB.2.00.1005071644200.11380@kaball-desktop>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4BE3ADD1.7090703@xxxxxxxxxxxxxx> <alpine.DEB.2.00.1005071644200.11380@kaball-desktop>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100415 Thunderbird/3.0.4
Hi Stefano,
On 05/07/2010 11:45 PM, Stefano Stabellini wrote:
> On Fri, 7 May 2010, Yang Hongyang wrote:
>> 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@xxxxxxxxxxxxxx>
>>
>> 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);
>> +}
> 
> There is no need to explicitly handle the transaction here, just pass 0
> to libxl_domain_rename.
> In the near future libxl_domain_rename won't take a transaction anymore
> (libxl clients shouldn't know about xenstore).
> 
> 

I will send a patch to fix it.

> 
> 


-- 
Regards
Yang Hongyang

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>