[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 0/9] Add xl PCI daemon (server for libxl PCI)



From: Anastasiia Lukianenko <anastasiia_lukianenko@xxxxxxxx>

This work introduces xl PCI daemon that acts as a server for the client
in the libxl PCI. The toolstack in Dom0 accesses sysfs to get information
about PCI devices and in case of Hardware Domain that sysfs lives in
Hardware Domain, so Dom0 can't read that information directly anymore.
For that reason we introduce a "proxy" which directs requests from Dom0 to
the domain which owns PCI devices, being it Dom0 itself or any other domain,
e.g. Hardware Domain. xl PCI daemon is based on vchan-node2 tool and uses
the libxenvchan library for messaging transport.

It was verified that this model works both remotely (in different domains)
and locally (within one domain) as requested by Xen community [1]. The
server processes the requests that come from the client. For better
interoperability between guest OSes, e.g. Linux vs FreeBSD, the path in the
request is not a direct sysfs entry as seen in Dom0, but instead it is a
key-word defined in the protocol. For now libxl PCI refers to sysfs in the
following functions, therefore such a subset was implemented in xl PCI
daemon commands handling:
* ‘ls’ - the server receives "dir_id" as a parameter. Xl pcid server
  transmits information about devices assigned to the PCI driver by sending
  a reply with the remote directory listing. Client cannot pass the sysfs
  path, as it is not the same on different operating systems. Therefore,
  for example, we pass parameter "pciback_driver" and on the server side
  we refer to "/sys/bus/pci/drivers/pciback" if Linux is used);
* ‘write’- the server receives the file name and value as parameters where
  and what to write;
* ‘read_hex’ - xl PCI daemon returns hex value read from the given path;
* ‘exists’ - check if path exists;
* ‘read_resources’ - returns an array of PCI device resources (start, end,
   flags) read from given path;
* ‘unbind’ - unbinds PCI device;
* ‘reset’ - resets PCI device.

Requests and responses are formed in the form of a json which is already
used by libxenlight (xl). The commands are aimed at preventing the libxl
PCI from reading / writing from / to the local sysfs directly. To do this,
the libxl PCI itself was changed, vchan and pcid support was added to
libxl - instead of working with the read and write functions from / to the
sysfs, functionality was added to send requests to the server, then receive
and process the response.

Libxl vchan is used as transport between libxl and the server side. Libxl
vchan adds support for JSON messages processing. Libxl pcid functions allow
to process the received message from PCI server and to generate a reply in
JSON format for the client. The pcid functions in the libxl allow the use
of internal libxl structures and functions, so there is no code duplications
on server side.

The issue of simultaneous access of several processes to the channel is not
resolved as well. For example, the commands “xl pci-assignable-list” and
“xl pci-assignable-add” will be sent at the same time. Due to the fact that
there is only one channel, the processing of two requests will cause
undefined behavior on the server side. In the future, it is necessary to
take into account cases when from different domains there can be several
requests from a client at the same time or from the same but xl commands are
executed concurrently.

[1] - https://www.mail-archive.com/xen-devel@xxxxxxxxxxxxxxxxxxxx/msg84452.html

Regards,
Anastasiia

Anastasiia Lukianenko (9):
  tools/libs/light: Add vchan support to libxl
  tools/libs/light: Add functions for handling PCI messages in JSON
    format
  tools/xl: Add pcid daemon to xl
  tools/libs/light: Add "ls" command processing to xl pcid daemon and
    libxl PCI
  tools/libs/light: Add "write" command to xl pcid and libxl PCI
  tools/libs/light: Add "read" command to xl pcid and libxl PCI
  tools/libs/light: Make Libxl PCI get values from xl pcid instead of
    libxl side
  tools/libs/light: Add "unbind" and "read resources" commands to libxl
    PCI and xl pcid
  tools/libs/light: Add "reset" and "remove" PCI dev commands to xl pcid
    daemon and libxl PCI

 tools/configure                           |   5 +-
 tools/helpers/Makefile                    |   4 +-
 tools/hotplug/FreeBSD/rc.d/xlpcid.in      |  75 +++
 tools/hotplug/Linux/init.d/xlpcid.in      |  76 +++
 tools/hotplug/NetBSD/rc.d/xlpcid.in       |  75 +++
 tools/include/pcid.h                      |  73 +++
 tools/libs/light/Makefile                 |   8 +-
 tools/libs/light/libxl_pci.c              | 566 ++++++++++++++--------
 tools/libs/light/libxl_pcid.c             | 527 ++++++++++++++++++++
 tools/libs/light/libxl_types.idl          |   1 +
 tools/libs/light/libxl_types_internal.idl |   6 +
 tools/libs/light/libxl_vchan.c            | 359 ++++++++++++++
 tools/libs/light/libxl_vchan.h            |  81 ++++
 tools/xl/Makefile                         |   5 +-
 tools/xl/xl.h                             |   1 +
 tools/xl/xl_cmdtable.c                    |   7 +
 tools/xl/xl_pcid.c                        |  79 +++
 17 files changed, 1727 insertions(+), 221 deletions(-)
 create mode 100644 tools/hotplug/FreeBSD/rc.d/xlpcid.in
 create mode 100644 tools/hotplug/Linux/init.d/xlpcid.in
 create mode 100644 tools/hotplug/NetBSD/rc.d/xlpcid.in
 create mode 100644 tools/include/pcid.h
 create mode 100644 tools/libs/light/libxl_pcid.c
 create mode 100644 tools/libs/light/libxl_vchan.c
 create mode 100644 tools/libs/light/libxl_vchan.h
 create mode 100644 tools/xl/xl_pcid.c

-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.