All of lore.kernel.org
 help / color / mirror / Atom feed
From: "W. Michael Petullo" <mike@flyn.org>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: Using "xl create" without domain config file
Date: Mon, 11 Jun 2012 15:22:24 -0500	[thread overview]
Message-ID: <20120611202224.GA22246@imp.flyn.org> (raw)
In-Reply-To: <20437.62868.542710.418122@mariner.uk.xensource.com>

[...]
> Thanks, this is going in the right direction I think.  Just two
> niggles:
 
>> diff -r 435493696053 tools/libxl/xl_cmdimpl.c
>> --- a/tools/libxl/xl_cmdimpl.c  Fri May 25 08:18:47 2012 +0100
>> +++ b/tools/libxl/xl_cmdimpl.c  Thu Jun 07 22:40:58 2012 -0500
>> @@ -1454,10 +1454,13 @@ static int create_domain(struct domain_c
>> 
>>      if (config_file) {
>>          free(config_data);  config_data = 0;
[...]
>> +        // /dev/null represents special case (read config. from command line)
 
> libxl coding style uses /*...*/ comments.
 
>> +        if (strcmp(config_file, "/dev/null")) {
>> +            ret = libxl_read_file_contents(&ctx, config_file,
>> +                                           &config_data, &config_len);
 
> I think this fails to set config_len to 0 in the /dev/null case, which
> it should do.  Although config_len is initialised to 0 it may have
> been set to a non-0 value from the length of the old config file if
> we're doing a restore, and in this case it needs to be rezeroed.
 
>> +            if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
>> +                               config_file, strerror(errno)); return ERROR_FAIL; }
>> +        }
>>          if (!restore_file && extra_config && strlen(extra_config)) {
>>              if (config_len > INT_MAX - (strlen(extra_config) + 2 + 1)) {
>>                  fprintf(stderr, "Failed to attach extra configration\n");

This version addresses the two issues above:

# HG changeset patch
# Parent 435493696053a079ec17d6e1a63e5f2be3a2c9d0
xl: Allow use of /dev/null with xl create to enable command-line definition

xm allows specifying /dev/null as the domain configuration argument to its
create option; add same functionality to xl. xl treats the configuration
argument /dev/null as a special case.  This allows specifying an entire
domain configuration on the command line.

Signed-off-by: W. Michael Petullo <mike@flyn.org>

diff -r 435493696053 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri May 25 08:18:47 2012 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Mon Jun 11 15:18:23 2012 -0500
@@ -1454,10 +1454,15 @@ static int create_domain(struct domain_c
 
     if (config_file) {
         free(config_data);  config_data = 0;
-        ret = libxl_read_file_contents(&ctx, config_file,
-                                       &config_data, &config_len);
-        if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
-                           config_file, strerror(errno)); return ERROR_FAIL; }
+        /* /dev/null represents special case (read config. from command line) */
+        if (!strcmp(config_file, "/dev/null")) {
+            config_len = 0;
+        } else {
+            ret = libxl_read_file_contents(&ctx, config_file,
+                                           &config_data, &config_len);
+            if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
+                               config_file, strerror(errno)); return ERROR_FAIL; }
+        }
         if (!restore_file && extra_config && strlen(extra_config)) {
             if (config_len > INT_MAX - (strlen(extra_config) + 2 + 1)) {
                 fprintf(stderr, "Failed to attach extra configration\n");

  reply	other threads:[~2012-06-11 20:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-31  4:50 Using "xl create" without domain config file W. Michael Petullo
2012-06-01  5:45 ` Ian Campbell
2012-06-01 18:01 ` Ian Jackson
2012-06-02 14:19   ` W. Michael Petullo
2012-06-06 10:40     ` Ian Jackson
2012-06-07 17:41       ` Ian Jackson
2012-06-08 18:31         ` W. Michael Petullo
2012-06-11 13:41           ` Ian Jackson
2012-06-11 20:22             ` W. Michael Petullo [this message]
2012-07-04 14:48               ` Ian Campbell
2012-08-17 21:37                 ` W. Michael Petullo

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=20120611202224.GA22246@imp.flyn.org \
    --to=mike@flyn.org \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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.