From: Yu Zhiguo <yuzg@cn.fujitsu.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH] xl: support specifing '[vars]' in 'xl create'
Date: Wed, 28 Apr 2010 16:51:04 +0800 [thread overview]
Message-ID: <4BD7F6F8.30404@cn.fujitsu.com> (raw)
Add support of specifing '[vars]' in 'xl create'.
It is said '[vars]' can be used in help message of 'xl create',
but in fact cannot now, so add this function.
After this fix:
# xl create pvguest1.conf
# xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 2 r-- 161.0
pvguest1 29 256 2 r-- 0.5
# xl destroy pvguest1
# xl create pvguest1.conf vcpus=4 memory=512 'name="pv1"'
# xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 2 r-- 162.2
pv1 30 512 4 r-- 0.2
Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
diff -r c87ec146229a -r 51bb2db1ed51 tools/libxl/xl.c
--- a/tools/libxl/xl.c Fri Apr 23 15:04:26 2010 +0100
+++ b/tools/libxl/xl.c Thu Apr 29 00:02:02 2010 +0800
@@ -777,7 +777,9 @@
return r;
}
-static int create_domain(int debug, int daemonize, const char *config_file, const char *restore_file, int paused, int migrate_fd /* -1 means none */, char **migration_domname_r)
+static int create_domain(int debug, int daemonize, const char *config_file, const char *restore_file,
+ int paused, int migrate_fd /* -1 means none */, char **migration_domname_r,
+ const char *extra_config)
{
libxl_domain_create_info info1;
libxl_domain_build_info info2;
@@ -873,6 +875,21 @@
&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)) {
+ fprintf(stderr, "Failed to attach extra configration\n");
+ return ERROR_FAIL;
+ }
+ config_data = realloc(config_data, config_len + strlen(extra_config) + 2);
+ if (!config_data) {
+ fprintf(stderr, "Failed to realloc config_data\n");
+ return ERROR_FAIL;
+ }
+ strcat(config_data, "\n");
+ strcat(config_data, extra_config);
+ strcat(config_data, "\n");
+ config_len += (strlen(extra_config) + 2);
+ }
} else {
if (!config_data) {
fprintf(stderr, "Config file not specified and"
@@ -1935,7 +1952,7 @@
rc = create_domain(debug, daemonize,
0 /* no config file, use incoming */,
"incoming migration stream", 1,
- 0, &migration_domname);
+ 0, &migration_domname, NULL);
if (rc) {
fprintf(stderr, "migration target: Domain creation failed"
" (code %d).\n", rc);
@@ -2045,7 +2062,7 @@
exit(2);
}
rc = create_domain(debug, daemonize, config_file,
- checkpoint_file, paused, -1, 0);
+ checkpoint_file, paused, -1, 0, NULL);
exit(-rc);
}
@@ -2291,6 +2308,8 @@
{
char *filename = NULL;
int debug = 0, daemonize = 1;
+#define MAX_EXTRA 1024
+ char *p, extra_config[MAX_EXTRA];
int opt, rc;
while ((opt = getopt(argc, argv, "hde")) != -1) {
@@ -2310,14 +2329,26 @@
}
}
- if (optind >= argc) {
- help("create");
- exit(2);
+ memset(extra_config, 0, MAX_EXTRA);
+ while (optind < argc) {
+ if ((p = strchr(argv[optind], '='))) {
+ if (strlen(extra_config) + 1 < MAX_EXTRA) {
+ if (strlen(extra_config))
+ strcat(extra_config, "\n");
+ strcat(extra_config, argv[optind]);
+ }
+ } else if (!filename) {
+ filename = argv[optind];
+ } else {
+ help("create");
+ exit(2);
+ }
+
+ optind++;
}
- filename = argv[optind];
rc = create_domain(debug, daemonize, filename, NULL, 0,
- -1, 0);
+ -1, 0, extra_config);
exit(-rc);
}
next reply other threads:[~2010-04-28 8:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-28 8:51 Yu Zhiguo [this message]
2010-04-28 19:02 ` [PATCH] xl: support specifing '[vars]' in 'xl create' Stefano Stabellini
2010-04-29 4:32 ` Yu Zhiguo
2010-04-29 18:05 ` Stefano Stabellini
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=4BD7F6F8.30404@cn.fujitsu.com \
--to=yuzg@cn.fujitsu.com \
--cc=keir.fraser@eu.citrix.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.