All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel De Graaf <dgdegra@tycho.nsa.gov>
To: Ian.Campbell@citrix.com
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>,
	Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org
Subject: [PATCH v2] libxl: Support backend domain ID for disks
Date: Wed,  5 Sep 2012 13:05:13 -0400	[thread overview]
Message-ID: <1346864713-28732-1-git-send-email-dgdegra@tycho.nsa.gov> (raw)
In-Reply-To: <1346400260.27277.93.camel@zakaz.uk.xensource.com>

Allow specification of backend domains for disks, either in the config
file or via xl block-attach. This functionality was supported in xend
(via an optional command line parameter to block-attach), so should also
be supported with libxl.

In order to support named backend domains like network-attach, a valid
libxl_ctx must now be passed to xlu_cfg_init.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>

---

This patch does not include the changes to tools/libxl/libxlu_disk_l.c
and tools/libxl/libxlu_disk_l.h because the diffs contain unrelated
changes due to different generator versions.

 docs/misc/xl-disk-configuration.txt | 12 ++++++++++++
 tools/libxl/libxlu_cfg.c            |  4 +++-
 tools/libxl/libxlu_disk_l.l         |  9 +++++++++
 tools/libxl/libxlu_internal.h       |  1 +
 tools/libxl/libxlutil.h             |  3 ++-
 tools/libxl/xl.c                    |  2 +-
 tools/libxl/xl_cmdimpl.c            | 20 +++++++++-----------
 7 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/docs/misc/xl-disk-configuration.txt b/docs/misc/xl-disk-configuration.txt
index 86c16be..5bd456d 100644
--- a/docs/misc/xl-disk-configuration.txt
+++ b/docs/misc/xl-disk-configuration.txt
@@ -139,6 +139,18 @@ cdrom
 Convenience alias for "devtype=cdrom".
 
 
+backend=<domain-name>
+---------------------
+
+Description:           Designates a backend domain for the device
+Supported values:      Valid domain names
+Mandatory:             No
+
+Specifies the backend domain which this device should attach to. This
+defaults to domain 0. Specifying another domain requires setting up a
+driver domain which is outside the scope of this document.
+
+
 backendtype=<backend-type>
 --------------------------
 
diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c
index 22adcb0..1d086b4 100644
--- a/tools/libxl/libxlu_cfg.c
+++ b/tools/libxl/libxlu_cfg.c
@@ -25,13 +25,15 @@
 #include "libxlu_cfg_l.h"
 #include "libxlu_cfg_i.h"
 
-XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) {
+XLU_Config *xlu_cfg_init(FILE *report, const char *report_source,
+                         libxl_ctx *ctx) {
     XLU_Config *cfg;
 
     cfg= malloc(sizeof(*cfg));
     if (!cfg) return 0;
 
     cfg->report= report;
+    cfg->ctx = ctx;
     cfg->config_source= strdup(report_source);
     if (!cfg->config_source) { free(cfg); return 0; }
 
diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libxl/libxlu_disk_l.l
index bee16a1..8cfc16e 100644
--- a/tools/libxl/libxlu_disk_l.l
+++ b/tools/libxl/libxlu_disk_l.l
@@ -33,6 +33,7 @@
 
 %{
 #include "libxlu_disk_i.h"
+#include "libxl_utils.h"
 
 #define YY_NO_INPUT
 
@@ -113,6 +114,13 @@ static void setbackendtype(DiskParseContext *dpc, const char *str) {
     else xlu__disk_err(dpc,str,"unknown value for backendtype");
 }
 
+/* Sets ->backend_domid from the string. */
+static void setbackend(DiskParseContext *dpc, const char *str) {
+    if (libxl_name_to_domid(dpc->cfg->ctx, str, &dpc->disk->backend_domid)) {
+        xlu__disk_err(dpc,str,"unknown domain for backend");
+    }
+}
+
 #define DEPRECATE(usewhatinstead) /* not currently reported */
 
 /* Handles a vdev positional parameter which includes a devtype. */
@@ -168,6 +176,7 @@ devtype=disk,?	{ DPC->disk->is_cdrom = 0; }
 devtype=[^,]*,?	{ xlu__disk_err(DPC,yytext,"unknown value for type"); }
 
 access=[^,]*,?	{ STRIP(','); setaccess(DPC, FROMEQUALS); }
+backend=[^,]*,? { STRIP(','); setbackend(DPC,FROMEQUALS); }
 backendtype=[^,]*,? { STRIP(','); setbackendtype(DPC,FROMEQUALS); }
 
 vdev=[^,]*,?	{ STRIP(','); SAVESTRING("vdev", vdev, FROMEQUALS); }
diff --git a/tools/libxl/libxlu_internal.h b/tools/libxl/libxlu_internal.h
index 7579158..5a9cf6d 100644
--- a/tools/libxl/libxlu_internal.h
+++ b/tools/libxl/libxlu_internal.h
@@ -39,6 +39,7 @@ struct XLU_Config {
     XLU_ConfigSetting *settings;
     FILE *report;
     char *config_source;
+    libxl_ctx *ctx;
 };
 
 typedef struct {
diff --git a/tools/libxl/libxlutil.h b/tools/libxl/libxlutil.h
index 0333e55..1de23e7 100644
--- a/tools/libxl/libxlutil.h
+++ b/tools/libxl/libxlutil.h
@@ -24,7 +24,8 @@
 typedef struct XLU_Config XLU_Config;
 typedef struct XLU_ConfigList XLU_ConfigList;
 
-XLU_Config *xlu_cfg_init(FILE *report, const char *report_filename);
+XLU_Config *xlu_cfg_init(FILE *report, const char *report_filename,
+                         libxl_ctx *ctx);
   /* 0 means we got ENOMEM. */
   /* report_filename is copied; report is saved and must remain valid
    *  until the Config is destroyed. */
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index f31e836..32a5c32 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -56,7 +56,7 @@ static void parse_global_config(const char *configfile,
     int e;
     const char *buf;
 
-    config = xlu_cfg_init(stderr, configfile);
+    config = xlu_cfg_init(stderr, configfile, ctx);
     if (!config) {
         fprintf(stderr, "Failed to allocate for configuration\n");
         exit(1);
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 2d6ab97..eaebbeb 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -427,7 +427,7 @@ static void parse_disk_config_multistring(XLU_Config **config,
     libxl_device_disk_init(disk);
 
     if (!*config) {
-        *config = xlu_cfg_init(stderr, "command line");
+        *config = xlu_cfg_init(stderr, "command line", ctx);
         if (!*config) { perror("xlu_cfg_init"); exit(-1); }
     }
 
@@ -583,7 +583,7 @@ static void parse_config_data(const char *config_source,
     libxl_domain_create_info *c_info = &d_config->c_info;
     libxl_domain_build_info *b_info = &d_config->b_info;
 
-    config= xlu_cfg_init(stderr, config_source);
+    config= xlu_cfg_init(stderr, config_source, ctx);
     if (!config) {
         fprintf(stderr, "Failed to allocate for configuration\n");
         exit(1);
@@ -2473,7 +2473,7 @@ static void pcidetach(const char *dom, const char *bdf, int force)
 
     libxl_device_pci_init(&pcidev);
     
-    config = xlu_cfg_init(stderr, "command line");
+    config = xlu_cfg_init(stderr, "command line", ctx);
     if (!config) { perror("xlu_cfg_inig"); exit(-1); }
 
     if (xlu_pci_parse_bdf(config, &pcidev, bdf)) {
@@ -2520,7 +2520,7 @@ static void pciattach(const char *dom, const char *bdf, const char *vs)
 
     libxl_device_pci_init(&pcidev);
 
-    config = xlu_cfg_init(stderr, "command line");
+    config = xlu_cfg_init(stderr, "command line", ctx);
     if (!config) { perror("xlu_cfg_inig"); exit(-1); }
 
     if (xlu_pci_parse_bdf(config, &pcidev, bdf)) {
@@ -2586,7 +2586,7 @@ static void pciassignable_add(const char *bdf, int rebind)
 
     libxl_device_pci_init(&pcidev);
 
-    config = xlu_cfg_init(stderr, "command line");
+    config = xlu_cfg_init(stderr, "command line", ctx);
     if (!config) { perror("xlu_cfg_init"); exit(-1); }
 
     if (xlu_pci_parse_bdf(config, &pcidev, bdf)) {
@@ -2624,7 +2624,7 @@ static void pciassignable_remove(const char *bdf, int rebind)
 
     libxl_device_pci_init(&pcidev);
 
-    config = xlu_cfg_init(stderr, "command line");
+    config = xlu_cfg_init(stderr, "command line", ctx);
     if (!config) { perror("xlu_cfg_init"); exit(-1); }
 
     if (xlu_pci_parse_bdf(config, &pcidev, bdf)) {
@@ -5321,7 +5321,7 @@ int main_networkattach(int argc, char **argv)
         return 1;
     }
 
-    config= xlu_cfg_init(stderr, "command line");
+    config= xlu_cfg_init(stderr, "command line", ctx);
     if (!config) {
         fprintf(stderr, "Failed to allocate for configuration\n");
         return 1;
@@ -5467,7 +5467,7 @@ int main_networkdetach(int argc, char **argv)
 int main_blockattach(int argc, char **argv)
 {
     int opt;
-    uint32_t fe_domid, be_domid = 0;
+    uint32_t fe_domid;
     libxl_device_disk disk = { 0 };
     XLU_Config *config = 0;
 
@@ -5483,8 +5483,6 @@ int main_blockattach(int argc, char **argv)
     parse_disk_config_multistring
         (&config, argc-optind, (const char* const*)argv + optind, &disk);
 
-    disk.backend_domid = be_domid;
-
     if (dryrun_only) {
         char *json = libxl_device_disk_to_json(ctx, &disk);
         printf("disk: %s\n", json);
@@ -6078,7 +6076,7 @@ int main_cpupoolcreate(int argc, char **argv)
         config_len += strlen(extra_config) + 1;
     }
 
-    config = xlu_cfg_init(stderr, config_src);
+    config = xlu_cfg_init(stderr, config_src, ctx);
     if (!config) {
         fprintf(stderr, "Failed to allocate for configuration\n");
         goto out;
-- 
1.7.11.4

  reply	other threads:[~2012-09-05 17:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-06 21:51 [PATCH RFC/for-4.2?] libxl: Support backend domain ID for disks Daniel De Graaf
2012-08-07  9:36 ` Ian Campbell
2012-08-07 10:38   ` Ian Jackson
2012-08-07 13:56   ` Daniel De Graaf
2012-08-31  8:04 ` Ian Campbell
2012-09-05 17:05   ` Daniel De Graaf [this message]
2012-09-06  7:26     ` [PATCH v2] " Ian Campbell
2012-09-06 12:24       ` Daniel De Graaf
2012-10-09 15:23     ` Ian Jackson
2012-10-09 18:41       ` Daniel De Graaf

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=1346864713-28732-1-git-send-email-dgdegra@tycho.nsa.gov \
    --to=dgdegra@tycho.nsa.gov \
    --cc=Ian.Campbell@citrix.com \
    --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.