Skip to contentSkip to conversation

: xl/libxl: add support for 'channels'

PATCH Applied David Scott 5 participants 19 messages Oct 9, 2014 – Oct 20, 2014

lore
Share & tools
lore
#1 lore raw

PATCH v7 1/7 libxl: replace memset() with libxl__device_console_init

In reply to David Scott

The current implementation of libxl__device_console_init does the same memset() so this is identical for now.

If libxl__device_console_init changes in future (e.g. to prefer a non-zero default value for some field) then this will continue to work.

---
 tools/libxl/libxl_create.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_create.c +1 -1
index 8b82584..543c1b3 100644
@@ -389,7 +389,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
 
 static int init_console_info(libxl__device_console *console, int dev_num)
 {
-    memset(console, 0x00, sizeof(libxl__device_console));
+    libxl__device_console_init(console);
     console->devid = dev_num;
     console->consback = LIBXL__CONSOLE_BACKEND_XENCONSOLED;
     console->output = strdup("pty");
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH v7 3/7 xl: add 'xstrdup' next to 'xrealloc'

In reply to David Scott
---
 tools/libxl/xl_cmdimpl.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/libxl/xl_cmdimpl.c +13 -0
index 698b3bc..7b87298 100644
@@ -300,6 +300,19 @@ static void *xrealloc(void *ptr, size_t sz) {
     return r;
 }
 
+static char *xstrdup(const char *x) __attribute__ ((unused));
+static char *xstrdup(const char *x)
+{
+    char *r;
+    r = strdup(x);
+    if (!r) {
+        fprintf(stderr, "xl: Unable to strdup a string of length %zu.\n",
+                strlen(x));
+        exit(-ERROR_FAIL);
+    }
+    return r;
+}
+
 #define ARRAY_EXTEND_INIT(array,count,initfn)                           \
     ({                                                                  \
         typeof((count)) array_extend_old_count = (count);               \
Signature · 1 line
1.7.10.4
#12 lore raw

PATCH v7 7/7 xl: add support for 'channels'

In reply to David Scott

This adds support for channel declarations of the form:

channel = [ "name=...,connection=...[,path=...][,backend=...]" ]

where 'name' is a label to identify the channel to the frontend.

If 'connection = pty' then the channel is connected to a pty in the
backend domain
If 'connection = socket' then the channel is connected to a Unix domain
socket given by 'path = ...' in the backend domain.

This patch also adds the command:

xl channel-list <domain>

which allows the state of channels to be queried. In particular if 'connection=pty' this will show the path of the pty slave device.

---
 docs/man/xl.cfg.pod.5     |   53 ++++++++++++++++++
 docs/man/xl.pod.1         |   10 ++++
 tools/libxl/xl.h          |    1 +
 tools/libxl/xl_cmdimpl.c  |  133 ++++++++++++++++++++++++++++++++++++++++++---
 tools/libxl/xl_cmdtable.c |    5 ++
 5 files changed, 194 insertions(+), 8 deletions(-)
docs/man/xl.cfg.pod.5 +53 -0
index 517ae2f..2c53b5c 100644
@@ -530,6 +530,59 @@ L<qemu(1)> manpage. The default is B<en-us>.
 
 =back
 
+=item B<channel=[ "CHANNEL_SPEC_STRING", "CHANNEL_SPEC_STRING", ...]>
+
+Specifies the virtual channels to be provided to the guest. A
+channel is a low-bandwidth, bidirectional byte stream, which resembles
+a serial link. Typical uses for channels include transmitting VM
+configuration after boot and signalling to in-guest agents. Please see
+F<docs/misc/channels.txt> for more details.
+
+Each B<CHANNEL_SPEC_STRING> is a comma-separated list of C<KEY=VALUE>
+seettings. Leading and trailing whitespace is ignored in both KEY and
+VALUE. Neither KEY nor VALUE may contain ',', '=' or '"'. Defined values
+are:
+
+=over 4
+
+=item C<backend=DOMAIN>
+
+Specify the backend domain name or id. This parameter is optional. If
+this parameter is omitted then the toolstack domain will be assumed.
+
+=item C<name=NAME>
+
+Specify the string name for this device. This parameter is mandatory.
+This should be a well-known name for the specific application (e.g.
+guest agent) and should be used by the frontend to connect the
+application to the right channel device. There is no formal registry
+of channel names, so application authors are encouraged to make their
+names unique by including domain name and version number in the string
+(e.g. org.mydomain.guestagent.1).
+
+=item C<connection=CONNECTION>
+
+Specify how the backend will be implemented. This following options are
+available:
+
+=over 4
+
+=item B<connection=SOCKET>
+
+The backend will bind a Unix domain socket (at the path given by
+B<path=PATH>), call listen and accept connections. The backend will proxy
+data between the channel and the connected socket.
+
+=item B<connection=PTY>
+
+The backend will create a pty and proxy data between the channel and the
+master device. The command B<xl channel-list> can be used to discover the
+assigned slave device.
+
+=back
+
+=back
+
 =item B<pci=[ "PCI_SPEC_STRING", "PCI_SPEC_STRING", ... ]>
 
 Specifies the host PCI devices to passthrough to this guest. Each B<PCI_SPEC_STRING>
docs/man/xl.pod.1 +10 -0
index f1e95db..35aa3a4 100644
@@ -1215,6 +1215,16 @@ List virtual network interfaces for a domain.
 
 =back
 
+=head2 CHANNEL DEVICES
+
+=over 4
+
+=item B<channel-list> I<domain-id>
+
+List virtual channel interfaces for a domain.
+
+=back
+
 =head2 VTPM DEVICES
 
 =over 4
tools/libxl/xl.h +1 -0
index 10a2e66..afc5f8b 100644
@@ -78,6 +78,7 @@ int main_top(int argc, char **argv);
 int main_networkattach(int argc, char **argv);
 int main_networklist(int argc, char **argv);
 int main_networkdetach(int argc, char **argv);
+int main_channellist(int argc, char **argv);
 int main_blockattach(int argc, char **argv);
 int main_blocklist(int argc, char **argv);
 int main_blockdetach(int argc, char **argv);
tools/libxl/xl_cmdimpl.c +125 -8

175 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +5 -0
index 35f02c4..a6df234 100644
@@ -337,6 +337,11 @@ struct cmd_spec cmd_table[] = {
       "Destroy a domain's virtual network device",
       "<Domain> <DevId|mac>",
     },
+    { "channel-list",
+      &main_channellist, 0, 0,
+      "List virtual channel devices for a domain",
+      "<Domain(s)>",
+    },
     { "block-attach",
       &main_blockattach, 1, 1,
       "Create a new virtual block device",
Signature · 1 line
1.7.10.4
#8 lore raw

PATCH v7 5/7 xl: 'replace_string' now uses xstrdup

In reply to David Scott

This catches the out-of-memory exception and exits the program.

---
 tools/libxl/xl_cmdimpl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +1 -1
index 1fc2171..e5d20e6 100644
@@ -815,7 +815,7 @@ static void parse_vcpu_affinity(libxl_domain_build_info *b_info,
 static void replace_string(char **str, const char *val)
 {
     free(*str);
-    *str = strdup(val);
+    *str = xstrdup(val);
 }
 
 static void parse_config_data(const char *config_source,
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH v7 6/7 xl: add 'trim' and 'split_string_into_pair' functions

In reply to David Scott
---
 tools/libxl/xl_cmdimpl.c |   68 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 67 insertions(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +67 -1
index e5d20e6..af294e2 100644
@@ -300,7 +300,6 @@ static void *xrealloc(void *ptr, size_t sz) {
     return r;
 }
 
-static char *xstrdup(const char *x) __attribute__ ((unused));
 static char *xstrdup(const char *x)
 {
     char *r;
@@ -564,6 +563,73 @@ static void split_string_into_string_list(const char *str,
     free(s);
 }
 
+/* NB: this follows the interface used by <ctype.h>. See 'man 3 ctype'
+   and look for CTYPE in libxl_internal.h */
+typedef int (*char_predicate_t)(const int c);
+
+static void trim(char_predicate_t predicate, const char *input, char **output) __attribute__ ((unused));
+static void trim(char_predicate_t predicate, const char *input, char **output)
+{
+    char *p, *q, *tmp;
+
+    *output = NULL;
+    if (*input == '\000')
+        return;
+    /* Input has length >= 1 */
+
+    p = tmp = xstrdup(input);
+    /* Skip past the characters for which predicate is true */
+    while ((*p != '\000') && (predicate((unsigned char)*p)))
+        p ++;
+    q = p + strlen(p) - 1;
+    /* q points to the last non-NULL character */
+    while ((q > p) && (predicate((unsigned char)*q)))
+        q --;
+    /* q points to the last character we want */
+    q ++;
+    *q = '\000';
+    *output = xstrdup(p);
+    free(tmp);
+}
+
+static int split_string_into_pair(const char *str,
+                                  const char *delim,
+                                  char **a,
+                                  char **b) __attribute__ ((unused));
+static int split_string_into_pair(const char *str,
+                                  const char *delim,
+                                  char **a,
+                                  char **b)
+{
+    char *s, *p, *saveptr, *aa = NULL, *bb = NULL;
+    int rc = 0;
+
+    s = xstrdup(str);
+
+    p = strtok_r(s, delim, &saveptr);
+    if (p == NULL) {
+        rc = ERROR_INVAL;
+        goto out;
+    }
+    aa = xstrdup(p);
+    p = strtok_r(NULL, delim, &saveptr);
+    if (p == NULL) {
+        rc = ERROR_INVAL;
+        goto out;
+    }
+    bb = xstrdup(p);
+
+    *a = aa;
+    aa = NULL;
+    *b = bb;
+    bb = NULL;
+out:
+    free(s);
+    free(aa);
+    free(bb);
+    return rc;
+}
+
 static int parse_range(const char *str, unsigned long *a, unsigned long *b)
 {
     const char *nstr;
Signature · 1 line
1.7.10.4
#0 lore raw

PATCH v7 1/1 : xl/libxl: add support for 'channels'

Hi,

Here's the latest spin of these patches, hopefully with everything addressed (mainly memory leaks).

Quoting IanC in
http://lists.xenproject.org/archives/html/xen-devel/2014-10/msg00943.html

Quoted 12 lines

The most major comment I saw was this one from Ian J which Wei reposted as:

Ian Jackson asked one question which remained unanswered in the last iteration.

QUOTE
There are also unfortunate security implications to reading the backend directory like that - if we have a driver domain, the qemu might get untrustworthy paths.
ENDQUOTE

Quoted 3 lines

Has that question become moot? Did I miss anything?

Wei.

When Wei highlighted my omission I went back to the original thread and tried to answer there. The answer may have gotten buried -- I'll repeat it inline here.

Quoting myself in
http://lists.xenproject.org/archives/html/xen-devel/2014-09/msg04206.html

Quoted 14 lines

I agree that we must be careful not to start a driver domain and tell it ‘talk to the socket at path x’ when in fact ‘x’ is in a different domain. At the moment paths are in the driver domain and the person who writes the domain config must consider this when they choose their driver domain.

Thinking about the future, although we could arrange it such that the data gets routed to other places (e.g. run qemu/xenconsoled in the driver domain, have it proxy the data over a vchan, have a thing in dom0 proxy to the right socket) I suspect that we’ll want to add additional ‘connection’ behaviours which reference resources via global names rather than local ones. I quite like the idea of adding some kind of URI to name a network endpoint and have the driver domain proxy all the data to/from there.

Quoted 2 lines

I’m not totally sure that’s what you were getting at — sorry if I’ve missed the point!

I'm still not totally sure that I've adequately answered IanJ's question.

Sorry for the confusion!

The blurb:

Several libvirt applications (e.g. oVirt, CloudStack) make use of 'channels':
low-bandwidth private host <-> guest communication links which resemble serial ports. Typical uses include:

* initial VM configuration without using the network: read the config data directly from the channel on boot

* controlling a guest agent: signal shutdown reqests, exchange clipboard data, trigger resolution changes

This patch set re-uses the existing PV console protocol implemented by qemu to provide this service.

If you declare a channel in your .xl file as follows:

channel = [ "connection=socket,path=/tmp/mysock,name=org.mydomain.guest-agent" ]

then an extra PV console will be added to your guest. This console has the extra key in the frontend

name = guest-agent

which allows udev scripts in the VM to create a named device in a well-known location (e.g. /dev/xen-channels/guest-agent, similar to the KVM /dev/vports). The qemu process in the backend domain will proxy the data to/from the named Unix domain socket (in this case /tmp/mysock).

Note this mechanism is intended for low-bandwidth communication only. If an application requires a high-bandwith connection then it should use a direct vchan connection (and not proxy it via a qemu).

Changes since v6:
* libxl: init_console_from_channel: perform validation before allocation
* libxl: init_console_info now reurns void (NB libxl__strdup handles allocation failure by _exit, so no need to return ERROR_ENOMEM)
* libxl: split out replace of memset with libxl__device_console_init to make review easier
* libxl: call libxl_channel_dispose on the error path to be safe
* xl: add a case for CONNECTION_PTY and exit(1) for an unexpected case
* xl: trim: always set output to NULL to avoid returning garbage
* xl: trim: fix a broken comment
* docs: add example udev rule (although the actual udev rule should go upstream to udev)
* docs: name the linux driver (CONFIG_HVC_XEN_FRONTEND)
* lots of whitespace fixes

Changes since v5:
* Fix use of <ctype.h> functions, and add a warning note
* Split out string fiddling into separate squash-able patches. (Note I've added __attribute__((unused)) to keep it building)
* doc: clearly describe leading/trailing whitespace handling and that [,="] are banned characters
* doc: mention the xenstore key 'name' (oops)
* doc: mention in the IDL and libxl.h that channels manifest as consoles with names. Note that consoles are still considered an internal type (in libxl_types_internal.idl) and don't appear in libxl_domain_config.

Changes since v4:
* doc: highlight that the 'output' key in the console configuration should be considered an internal implementation artifact
* return EINVAL if a primary console has invalid configuration
* Use LOG(ERROR,... rather than LIBXL__LOG(CTX, LIBXL__LOG_ERROR
* Use an abort() when implementation code is missing
* move READ_BACKEND to the top of the file (since it's generally useful)
* Remove stray tab

Changes since v3:
* docs: coalesce the docs patch into the libxl patch
* docs: in channels.txt give high-level usage information, pitfalls and channgle registry
* docs: move the xenstore paths into the existing console.txt, which is referenced from xenstore-paths.markdown
* idl: rename 'kind' to 'connection'
* xl: add parser functions for comma-separated lists of pairs

Changes since v2:
* trim down the 'kinds' of channels to PTY and SOCKET -- these seem the most useful and we can add more later
* add a channelinfo (queryable by 'channel-list') to check the state of each channel, and for a kind=PTY discover the slave device path
* IDL: switched to KeyedUnion for both the channel and channelinfo since each 'kind' will have different parameters (e.g. only SOCKET has PATH)
* write all the backend configuration parameters to xenstore -- where we were using qemu -chardev some crucial information was only on the command-line.
* add LIBXL_HAVE_DEVICE_CHANNEL
* docs: replace 'should' with 'will' e.g. the backend will be connected to a Unix domain socket
* squash all the libxl patches together into a coherent whole
* explain that there is no registry of channel names and so people should use unique information to create them (e.g. include domain name and interface version)

Changes since v1:
* extend xl.cfg(5)
* add docs/misc/channel.txt
* libxl_types.idl: omit unnecessary init_val = 0
* xl_cmdimpl.c: fixed over-long lines
* xl_cmdimpl.c: use xrealloc (via ARRAY_EXTEND_INIT)
* xl_cmdimpl.c: exit() on parse failure rather than ignore configuration
* libxl_create.c: use libxl__device_console_init instead of memset
* libxl_create.c: use libxl__strdup(NOGC rather than raw strdup
* libxl.c: add name=<name> to console frontend
* libxl.c: resolve the backend_domid from backend_domname
* libxl_dm.c: channels[i].devid rather than i
* libxl_dm.c: fix indentation
* libxl_dm.c: use GCSPRINTF convenience macro

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

PATCH v7 4/7 xl: move 'replace_string' further up the file

This allows the function to be reused more easily.

---
 tools/libxl/xl_cmdimpl.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
tools/libxl/xl_cmdimpl.c +6 -7
index 7b87298..1fc2171 100644
@@ -812,6 +812,12 @@ static void parse_vcpu_affinity(libxl_domain_build_info *b_info,
     }
 }
 
+static void replace_string(char **str, const char *val)
+{
+    free(*str);
+    *str = strdup(val);
+}
+
 static void parse_config_data(const char *config_source,
                               const char *config_data,
                               int config_len,
@@ -1927,13 +1933,6 @@ static int match_option_size(const char *prefix, size_t len,
 #define MATCH_OPTION(prefix, arg, oparg) \
     match_option_size((prefix "="), sizeof((prefix)), (arg), &(oparg))
 
-static void replace_string(char **str, const char *val)
-{
-    free(*str);
-    *str = strdup(val);
-}
-
-
 /* Preserve a copy of a domain under a new name. Updates *r_domid */
 static int preserve_domain(uint32_t *r_domid, libxl_event *event,
                            libxl_domain_config *d_config)
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v7 2/7 libxl: add support for 'channels'

In reply to David Scott

A 'channel':
- is a low-bandwidth private communication channel that resembles a physical serial port.
- is implemented as a PV console with a well-known string name which is used to hook the channel to the appropriate software in the guest (i.e. some kind of guest agent).
- has a backend 'connection' which describes what should happen to the data.

The following 'connection' types are defined:

* PTY: the I/O surfaces as a pty in the backend domain
* SOCKET: a listening Unix domain socket accepts a connection in the backend domain and proxies

Channels may be listed but don't currently support hotplug/unplug.

---
 docs/misc/channel.txt                |  106 +++++++++++++
 docs/misc/console.txt                |   69 ++++++---
 tools/libxl/libxl.c                  |  273 +++++++++++++++++++++++++++++++---
 tools/libxl/libxl.h                  |   20 +++
 tools/libxl/libxl_create.c           |   43 ++++--
 tools/libxl/libxl_dm.c               |   46 +++++-
 tools/libxl/libxl_internal.h         |   10 +-
 tools/libxl/libxl_types.idl          |   37 +++++
 tools/libxl/libxl_types_internal.idl |    5 +
 9 files changed, 555 insertions(+), 54 deletions(-)
 create mode 100644 docs/misc/channel.txt
docs/misc/channel.txt new file +106 -0
new file mode 100644
index 0000000..9fc701a
@@ -0,0 +1,106 @@
+Xen PV Channels
+===============
+
+A channel is a low-bandwidth private byte stream similar to a serial
+link. Typical uses of channels are
+
+  1. to provide initial configuration information to a VM on boot
+     (example use: CloudStack's cloud-early-config service)
+  2. to signal/query an in-guest agent
+     (example use: oVirt's guest agent)
+
+Channels are similar to virtio-serial devices and emulated serial links.
+Channels are intended to be used in the implementation of libvirt <channel>s
+when running on Xen.
+
+Note: if an application requires a high-bandwidth link then it should use
+vchan instead.
+
+How to use channels: an example
+-------------------------------
+
+Consider a cloud deployment where VMs are cloned from pre-made templates,
+and customised on first boot by an in-guest agent which sets the IP address,
+hostname, ssh keys etc. To install the system the cloud administrator would
+first:
+
+  1. Install a guest as normal (no channel configuration necessary)
+  2. Install the in-guest agent specific to the cloud software. This will
+     prepare the guest to communicate over the channel, and also prepare
+     the guest to be cloned safely (sometimes known as "sysprepping")
+  3. Shutdown the guest
+  4. Register the guest as a template with the cloud orchestration software
+  5. Install the cloud orchestration agent in dom0
+
+At runtime, when a cloud tenant requests that a VM is created from the template,
+the sequence of events would be: (assuming a Linux domU)
+
+  1. A VM is "cloned" from the template
+  2. A unique Unix domain socket path in dom0 is allocated
+     (e.g. /my/cloud/software/talk/to/domain/<vm uuid>)
+  3. Domain configuration is created for the VM, listing the channel
+     name expected by the in-guest agent. In xl syntax this would be:
+
+     channel = [ "connection=socket, name=org.my.cloud.software.agent.version1,
+                  path = /my/cloud/software/talk/to/domain/<vm uuid>" ]
+
+  4. The VM is started
+  5. In dom0 the cloud orchestration agent connects to the Unix domain
+     socket, writes a handshake message and waits for a reply
+  6. Assuming the guest kernel has CONFIG_HVC_XEN_FRONTEND set then the console
+     driver will generate a hotplug event
+  7. A udev rule is activated by the hotplug event.
+
+     The udev rule would look something like:
+
+     SUBSYSTEM=="xen", DEVPATH=="/devices/console-[0-9]", RUN+="xen-console-setup"
+
+     where the "xen-console-setup" script would read the channel name and
+     make a symlink in /dev/xen-channel/org.my.cloud.software.agent.version1
+
+  8. The in-guest agent uses inotify to see the creation of the /dev/xen-channel
+     symlink and opens the device.
+  9. The in-guest agent completes the handshake with the dom0 agent
+ 10. The dom0 agent transmits the unique VM configuration: hostname, IP
+     address, ssh keys etc etc
+ 11. The in-guest agent receives the configuration and applies it.
+
+Using channels avoids having to use a temporary disk device or network
+connection.
+
+Design recommendations and pitfalls
+-----------------------------------
+
+It's necessary to install channel-specific software (an "agent") into the guest
+before you can use a channel. By default a channel will appear as a device
+which could be mistaken for a serial port or regular console. It is known
+that some software will proactively seek out serial ports and issue AT commands
+at them; make sure such software is disabled!
+
+Since channels are identified by names, application authors must ensure their
+channel names are unique to avoid clashes. We recommend that channel names
+include parts unique to the application such as a domain names. To assist
+prevent clashes we recommend authors add their names to our global channel
+registry at the end of this document.
+
+Limitations
+-----------
+
+Hotplug and unplug of channels is not currently implemented.
+
+Channel name registry
+---------------------
+
+It is important that channel names are globally unique. To help ensure
+that no-one's name clashes with yours, please add yours to this list.
+
+Key:
+N: Name
+C: Contact
+D: Short description of use, possibly including a URL to your software
+   or API
+
+N: org.xenproject.guest.clipboard.0.1
+C: David Scott <[email protected]>
+D: Share clipboard data via an in-guest agent. See:
+   http://wiki.xenproject.org/wiki/Clipboard_sharing_protocol
docs/misc/console.txt +52 -17

97 lines not on this page · raw message

tools/libxl/libxl.c +255 -18

329 lines not on this page · raw message

tools/libxl/libxl.h +20 -0
index bc68cac..300e489 100644
@@ -583,6 +583,15 @@ typedef struct libxl__ctx libxl_ctx;
  */
 #define LIBXL_HAVE_BUILDINFO_KERNEL 1
 
+/*
+ * LIBXL_HAVE_DEVICE_CHANNEL
+ *
+ * If this is defined, then the libxl_device_channel struct exists
+ * and channels can be attached to a domain. Channels manifest as consoles
+ * with names, see docs/misc/console.txt.
+ */
+#define LIBXL_HAVE_DEVICE_CHANNEL 1
+
 /* Functions annotated with LIBXL_EXTERNAL_CALLERS_ONLY may not be
  * called from within libxl itself. Callers outside libxl, who
  * do not #include libxl_internal.h, are fine. */
@@ -1129,6 +1138,17 @@ libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx, uint32_t domid, int *num
 int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
                               libxl_device_nic *nic, libxl_nicinfo *nicinfo);
 
+/*
+ * Virtual Channels
+ * Channels manifest as consoles with names, see docs/misc/channels.txt
+ */
+libxl_device_channel *libxl_device_channel_list(libxl_ctx *ctx,
+                                                uint32_t domid,
+                                                int *num);
+int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid,
+                                 libxl_device_channel *channel,
+                                 libxl_channelinfo *channelinfo);
+
 /* Virtual TPMs */
 int libxl_device_vtpm_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vtpm *vtpm,
                           const libxl_asyncop_how *ao_how)
tools/libxl/libxl_create.c +29 -14

83 lines not on this page · raw message

tools/libxl/libxl_dm.c +43 -3

83 lines not on this page · raw message

tools/libxl/libxl_internal.h +8 -2
index f61673c..151c474 100644
@@ -1033,7 +1033,8 @@ _hidden int libxl__device_disk_dev_number(const char *virtpath,
 
 _hidden int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
                                       libxl__device_console *console,
-                                      libxl__domain_build_state *state);
+                                      libxl__domain_build_state *state,
+                                      libxl__device *device);
 
 /* Returns 1 if device exists, 0 if not, ERROR_* (<0) on error. */
 _hidden int libxl__device_exists(libxl__gc *gc, xs_transaction_t t,
@@ -1049,6 +1050,10 @@ _hidden int libxl__wait_for_backend(libxl__gc *gc, const char *be_path,
                                     const char *state);
 _hidden int libxl__nic_type(libxl__gc *gc, libxl__device *dev,
                             libxl_nic_type *nictype);
+_hidden int libxl__init_console_from_channel(libxl__gc *gc,
+                                             libxl__device_console *console,
+                                             int dev_num,
+                                             libxl_device_channel *channel);
 
 /*
  * For each aggregate type which can be used as an input we provide:
@@ -1468,7 +1473,8 @@ _hidden const char *libxl__domain_device_model(libxl__gc *gc,
 _hidden int libxl__need_xenpv_qemu(libxl__gc *gc,
         int nr_consoles, libxl__device_console *consoles,
         int nr_vfbs, libxl_device_vfb *vfbs,
-        int nr_disks, libxl_device_disk *disks);
+        int nr_disks, libxl_device_disk *disks,
+        int nr_channels, libxl_device_channel *channels);
 
 /*
  * This function will cause the whole libxl process to hang
tools/libxl/libxl_types.idl +37 -0
index f1fcbc3..59c3d0b 100644
@@ -69,6 +69,12 @@ libxl_domain_type = Enumeration("domain_type", [
     (2, "PV"),
     ], init_val = "LIBXL_DOMAIN_TYPE_INVALID")
 
+libxl_channel_connection = Enumeration("channel_connection", [
+    (0, "UNKNOWN"),
+    (1, "PTY"),
+    (2, "SOCKET"), # a listening Unix domain socket
+    ])
+
 libxl_device_model_version = Enumeration("device_model_version", [
     (0, "UNKNOWN"),
     (1, "QEMU_XEN_TRADITIONAL"), # Historical qemu-xen device model (qemu-dm)
@@ -269,6 +275,22 @@ libxl_cpupoolinfo = Struct("cpupoolinfo", [
     ("cpumap",      libxl_bitmap)
     ], dir=DIR_OUT)
 
+libxl_channelinfo = Struct("channelinfo", [
+    ("backend", string),
+    ("backend_id", uint32),
+    ("frontend", string),
+    ("frontend_id", uint32),
+    ("devid", libxl_devid),
+    ("state", integer),
+    ("evtch", integer),
+    ("rref", integer),
+    ("u", KeyedUnion(None, libxl_channel_connection, "connection",
+           [("unknown", None),
+            ("pty", Struct(None, [("path", string),])),
+            ("socket", None),
+           ])),
+    ], dir=DIR_OUT)
+
 libxl_vminfo = Struct("vminfo", [
     ("uuid", libxl_uuid),
     ("domid", libxl_domid),
@@ -491,6 +513,18 @@ libxl_device_vtpm = Struct("device_vtpm", [
     ("uuid",             libxl_uuid),
 ])
 
+libxl_device_channel = Struct("device_channel", [
+    ("backend_domid", libxl_domid),
+    ("backend_domname", string),
+    ("devid", libxl_devid),
+    ("name", string),
+    ("u", KeyedUnion(None, libxl_channel_connection, "connection",
+           [("unknown", None),
+            ("pty", None),
+            ("socket", Struct(None, [("path", string)])),
+           ])),
+])
+
 libxl_domain_config = Struct("domain_config", [
     ("c_info", libxl_domain_create_info),
     ("b_info", libxl_domain_build_info),
@@ -501,6 +535,9 @@ libxl_domain_config = Struct("domain_config", [
     ("vfbs", Array(libxl_device_vfb, "num_vfbs")),
     ("vkbs", Array(libxl_device_vkb, "num_vkbs")),
     ("vtpms", Array(libxl_device_vtpm, "num_vtpms")),
+    # a channel manifests as a console with a name,
+    # see docs/misc/channels.txt
+    ("channels", Array(libxl_device_channel, "num_channels")),
 
     ("on_poweroff", libxl_action_on_shutdown),
     ("on_reboot", libxl_action_on_shutdown),
tools/libxl/libxl_types_internal.idl +5 -0
index 800361b..5e55685 100644
@@ -34,6 +34,11 @@ libxl__device_console = Struct("device_console", [
     ("devid", integer),
     ("consback", libxl__console_backend),
     ("output", string),
+    # A regular console has no name.
+    # A console with a name is called a 'channel', see docs/misc/channels.txt
+    ("name", string),
+    ("connection", string),
+    ("path", string),
     ])
 
 libxl__device_action = Enumeration("device_action", [
Signature · 1 line
1.7.10.4
Acked-by on v7 1/7
#2 lore raw

Re: [PATCH v7 for-4.5 1/7] libxl: replace memset() with libxl__device_console_init

In reply to David Scott
Quoted 7 lines · David Scott

The current implementation of libxl__device_console_init does the same memset() so this is identical for now.

If libxl__device_console_init changes in future (e.g. to prefer a non-zero default value for some field) then this will continue to work.

Quoted 19 lines
---
 tools/libxl/libxl_create.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_create.c +1 -1
index 8b82584..543c1b3 100644
@@ -389,7 +389,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
 
 static int init_console_info(libxl__device_console *console, int dev_num)
 {
-    memset(console, 0x00, sizeof(libxl__device_console));
+    libxl__device_console_init(console);
     console->devid = dev_num;
     console->consback = LIBXL__CONSOLE_BACKEND_XENCONSOLED;
     console->output = strdup("pty");
Signature · 1 line
1.7.10.4
Acked-by on v7 2/7
#4 lore raw

Re: [PATCH v7 for-4.5 2/7] libxl: add support for 'channels'

In reply to David Scott

David Scott writes ("[PATCH v7 for-4.5 2/7] libxl: add support for 'channels'"):

Quoted 9 lines

A 'channel':
- is a low-bandwidth private communication channel that resembles a physical serial port.
- is implemented as a PV console with a well-known string name which is used to hook the channel to the appropriate software in the guest (i.e. some kind of guest agent).
- has a backend 'connection' which describes what should happen to the data.

Quoted 7 lines

The following 'connection' types are defined:

* PTY: the I/O surfaces as a pty in the backend domain
* SOCKET: a listening Unix domain socket accepts a connection in the backend domain and proxies

Channels may be listed but don't currently support hotplug/unplug.

Acked-by on v7 7/7
#13 lore raw

Re: [PATCH v7 for-4.5 7/7] xl: add support for 'channels'

In reply to David Scott

David Scott writes ("[PATCH v7 for-4.5 7/7] xl: add support for 'channels'"):

Quoted 11 lines

This adds support for channel declarations of the form:

channel = [ "name=...,connection=...[,path=...][,backend=...]" ]

where 'name' is a label to identify the channel to the frontend.

If 'connection = pty' then the channel is connected to a pty in the
backend domain
If 'connection = socket' then the channel is connected to a Unix domain
socket given by 'path = ...' in the backend domain.

Quoted 8 lines

This patch also adds the command:

xl channel-list <domain>

which allows the state of channels to be queried. In particular if 'connection=pty' this will show the path of the pty slave device.

#15 lore raw
In reply to David Scott
Quoted 4 lines · David Scott

Hi,

Here's the latest spin of these patches, hopefully with everything addressed (mainly memory leaks)

I think this now has all the relevant maintainer acks. What's the release-ack status of it?

I vaguely recall seeing something in a subthread of the development status mail, but I can't find it now...

Ian.

author
#16 lore raw
Quoted 11 lines · Ian Campbell
Quoted 4 lines · David Scott

Hi,

Here's the latest spin of these patches, hopefully with everything addressed (mainly memory leaks)

I think this now has all the relevant maintainer acks. What's the release-ack status of it?

I vaguely recall seeing something in a subthread of the development status mail, but I can't find it now…

I think this is the subthread here:

http://lists.xenproject.org/archives/html/xen-devel/2014-09/msg04061.html

Quoted 2 lines · Konrad added “Reviewed-by:” to some of the patches (3, 4, 6) and wrote:

Also, while my Reviewed-by is nice, either of the three maintainers:
Wei, IanJ, and IanC would need to Review these patches as well.

Konrad, what do you think?

Thanks,
Dave

#17 lore raw
Quoted 17 lines · Dave Scott
Quoted 11 lines · Ian Campbell
Quoted 4 lines · David Scott

Hi,

Here's the latest spin of these patches, hopefully with everything addressed (mainly memory leaks)

I think this now has all the relevant maintainer acks. What's the release-ack status of it?

I vaguely recall seeing something in a subthread of the development status mail, but I can't find it now…

I think this is the subthread here:

Quoted 8 lines

http://lists.xenproject.org/archives/html/xen-devel/2014-09/msg04061.html

Quoted 2 lines · Konrad added “Reviewed-by:” to some of the patches (3, 4, 6) and wrote:

Also, while my Reviewed-by is nice, either of the three maintainers:
Wei, IanJ, and IanC would need to Review these patches as well.

Konrad, what do you think?

The questions of mine had been answered and I believe the regression vs feature question has been answered too (it is minimal).

And since it has Acks from the maintainers, then

Quoted 3 lines

Thanks,
Dave

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Applied
#18 lore raw
Quoted 25 lines · Konrad Rzeszutek Wilk
Quoted 24 lines · Dave Scott
Quoted 11 lines · Ian Campbell
Quoted 4 lines · David Scott

Hi,

Here's the latest spin of these patches, hopefully with everything addressed (mainly memory leaks)

I think this now has all the relevant maintainer acks. What's the release-ack status of it?

I vaguely recall seeing something in a subthread of the development status mail, but I can't find it now…

I think this is the subthread here:

http://lists.xenproject.org/archives/html/xen-devel/2014-09/msg04061.html

Quoted 2 lines · Konrad added “Reviewed-by:” to some of the patches (3, 4, 6) and wrote:

Also, while my Reviewed-by is nice, either of the three maintainers:
Wei, IanJ, and IanC would need to Review these patches as well.

Quoted 7 lines
Quoted 1 line

Konrad, what do you think?

The questions of mine had been answered and I believe the regression vs feature question has been answered too (it is minimal).

And since it has Acks from the maintainers, then

Applied.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel