Display "README" with markdown style on Github

The file "README" is a markdown file but as it doesn't have the suffix
".md", Github doesn't render it with markdown style.

Rename the symlink "README" in order to be displayed with markdown style
on Github. Also, tell Automake not to look for a file called "README".

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
pep8: Fix errors in all files

Some files are still not compliant with the PEP8 rules as they're not
listed in the PEP8_WHITELIST variable.

Fix those files in order to make the entire project compliant with the
PEP8 rules.

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
pep8: Use blacklist instead of whitelist

Currently, the command "make check-local" runs the PEP8 verification
rules only on files listed in a configuration file. New files must
still be added manually and not all files are being checked.

List the files which *shouldn't* be checked against the PEP8 rules
instead of listing the files which should be checked. Also, fix the
errors on those new files.

Reasons to blacklist each file:

- src/kimchi/config.py and tests/test_config.py: those files are
  generated automatically by replacing strings inside them. We cannot
  guarantee that every line will still be shorter than 80 characters
  after replacing a text coming from an external resource.
- src/kimchi/websocket.py and src/kimchi/websockify.py: those files
  are from a 3rd party library and weren't developed by the Kimchi team,
  so we don't need to check their style.
- src/kimchi/i18n.py: this file only contains translatable strings. It
  would not be nice to wrap every line to 80 characters as they're not
  Python code but natural language text.

Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com>
bug fix: Redirect user to the URL accessed prior to login

When a non-logged user tries to access a guest console:

https://localhost:8001/vnc_auto.html?port=64667&path=?token=dWJ1bnR1MTQuMDQ&encrypt=1

He/she will be asked to login and then he/she must be redirected back to the
same URL accessed prior to login (ie, the guest console).

To do that, we use the "next" query parameter. But commit 22eba438 wrongly
overrided this logic by only querying the last tab visited which was
redirecting user to the Kimchi main page instead of the guest console.
Fix it.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Add websockify as Kimchi dependency

websockify is present in all supported Linux distributions (RHEL6.5,
RHEL7, Fedora20, Ubuntu 14.04 and openSUSE 13.1) so instead of importing
its code into Kimchi source source structure we must add its package as
a Kimchi dependency and use it as is.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Delete imported websockify code

Now Kimchi depends on websockify package so the imported code can be
removed.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Enable remote libvirtd
Bugfix#414: Cannot login by clicking on the login button

This patch fixes the bug that without moving the mouse, user cannot log
in kimchi by clicking on "Log in" button in Chrome as well as Opera.

Signed-off-by: Wen Wang <wenwang@linux.vnet.ibm.com>
Add novnc as Kimchi dependency

novnc is present in all supported Linux distributions (RHEL6.5,
RHEL7, Fedora20, Ubuntu 14.04 and openSUSE 13.1) so instead of importing
its code into Kimchi source source structure we must add its package as
a Kimchi dependency and use it as is.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Delete imported novnc code

Now Kimchi depends on novnc package so the imported code can be removed.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Host device passthrough: List all types of host devices

The URI /host/devices only presents scsi_host (particularly fc_host)
device information. To implement host PCI pass through, we should list all
types of host devices. This patch adds support for parsing various host
devices information, and listing them on /host/devices. So the user is free
to choose any listed PCI device to pass through to guest. Since the
patch changes the device information dictionary format, the existing code
consuming the device information is also changed accordingly.

To get all types of host device, access the following URL.

curl -k -u root -H "Content-Type: application/json" \
  -H  "Accept: application/json" \
  https://127.0.0.1:8001/host/devices

To get only fc_host devices, change the URL to
  "https://127.0.0.1:8001/host/devices?_cap=fc_host"

To get only pci device, change the URL to
  "https://127.0.0.1:8001/host/devices?_cap=pci"

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Host device passthrough: List eligible device to passthrough

This patch adds a '_passthrough=true' filter to /host/devices, so it can
filter and shows all devices eligible to passthrough to guest.
Theoretically, all PCI, USB and SCSI devices can be assigned to guest
directly.

Linux kernel is able to recognize the host IOMMU group layout. If two
PCI devices are in the same IOMMU group, it means there are possible
interconnections between the devices, and the devices can talk to each
other bypassing IOMMU. This implies isolation is not pefect between those
devices, so all devices in a IOMMU group must be assigned to guest
together. On host that recognizes IOMMU groups, by accessing the URI
/host/devices?_passthrough_affected_by=DEVICE_NAME, it returns a list
containing the devices in the same IOMMU group as DEVICE_NAME, and all
of the children devices of them. So the front-end can show all the
affected devices to user, and it helps the user to determine which
host devices are to be assigned to guest.

How to test:

List all types of devices to passthrough
  curl -k -u root -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    'https://127.0.0.1:8001/host/devices?_passthrough=true'

List all eligible PCI devices to passthrough
  /host/devices?_passthrough=true&_cap=pci

List all USB devices to passthrough
  /host/devices?_passthrough=true&_cap=usb_device

List all SCSI devices to passthrough
  /host/devices?_passthrough=true&_cap=scsi

List devices in the same IOMMU group as pci_0000_00_19_0
  /host/devices?_passthrough_affected_by=pci_0000_00_19_0

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Host device passthrough: Directly assign and dissmis host device from VM

This patch enbales Kimchi's VM to use host devices directly, and it
greatly improves the related device performance. The user can assign
PCI, USB and SCSI LUN directly to VM, as long as the host supports one
of Intel VT-d, AMD IOMMU or POWER sPAPR technology and runs a recent
release of Linux kernel.

This patch adds a sub-collection "hostdevs" to the URI vms/vm-name/.
The front-end can GET
  vms/vm-name/hostdevs
and
  vms/vm-name/hostdevs/dev-name
or POST (assign)
  vms/vm-name/hostdevs
and DELETE (dismiss)
  vms/vm-name/hostdevs/dev-name

The eligible devices to assign are the devices listed by the URI
  host/devices?_passthrough=1
When assigning a host PCI device to VM, all the eligible PCI devices in
the same IOMMU group are also automatically assigned, and vice versa
when dismissing a host PIC device from the VM.

Some examples:

Assign a USB device:
curl -k -u root -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -X POST -d '{"name": "usb_1_1_6"}' \
  'https://127.0.0.1:8001/vms/rhel65/hostdevs'

Assign a PCI device:
  -d '{"name": "pci_0000_0d_00_0"}'

Assign a SCSI LUN:
  -d '{"name": "scsi_1_0_0_0"}'

List assigned devices:
curl -k -u root -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  'https://127.0.0.1:8001/vms/rhel65/hostdevs'
The above command should print following.
  [
    {
      "type":"scsi",
      "name":"scsi_1_0_0_0"
    },
    {
      "type":"usb",
      "name":"usb_1_1_6"
    },
    {
      "type":"pci",
      "name":"pci_0000_0d_00_0"
    },
    {
      "type":"pci",
      "name":"pci_0000_03_00_0"
    }
  ]
Notice that the device pci_0000_03_00_0 is also assigned automatically.

The assigned devices are hot-plugged to VM and also written to the
domain XML. When it's possible, it enables VFIO for PCI device
assignment.

On distribution with old Linux kernel, there are many limitations with
PCI passthrough and it's hardly useful. This patch tries to adapt to old
kernel but it's better to use a newer kernel with vfio support. Thus
this patch also provide a new capability in /config/capabilities. The
front-end can disable or freeze the related web UI if back-end reports
host does not support vfio.

curl -k -u root -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    'https://127.0.0.1:8001/config/capabilities'

The above command should print following.
{
  "blah": "blah",
  ...
  "kernel_vfio":true
}

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Host device passthrough: List VMs that are holding a host device

Add a "vm_holders" sub-collection under host device resource, so the
front-end can determine if a device is busy or not, and the user can
know which VMs are holding the device.

This patch scans all VM XML to check if a device is hold by a VM.

Example
  curl -k -u root -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    'https://127.0.0.1:8001/host/devices/usb_1_1_6/vm_holders'
Should output a list like following.
  [
    {
      "state":"shutoff",
      "name":"fedora20"
    },
    {
      "state":"running",
      "name":"f20xfce-slave"
    }
  ]

If there is no VM holding the device, it prints an empty list [].

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Host device passthrough: Add unit tests and documents

Add some basice unit tests for fetching host device information. Update
MockModel as well. Update "API.json" and "API.md" to reflect the change
in API.

Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Host device passthrough (Front-end): Add PCI Devices to VM

Signed-off-by: Yu Xin Huo <huoyuxin@linux.vnet.ibm.com>
Signed-off-by: Wen Wang <wenwang@linux.vnet.ibm.com>
Fix problems to open plugin's help pages

Kimchi is currently not able to configure and open help pages of any
plugin tab. This patch fixes this problem and removes the HELP button
if any Kimchi tab or plugin tab do not have a help configured properly
for the language being used.
(eg. if plugins/<tab_html>/help/<lang>/<tab_html>.html does not exist,
then the help button is disabled).

A help page for a plugin tab follow same Kimchi system:
   - html help file should have the same name of plugin html tab file;
   - html files should be placed in plugin's " ui/pages/help/<LANG> "
     path;
   - plugin should add following lines to <PLUGIN_NAME>.conf:
        * [/help]
        * tools.staticdir.on = True
        * tools.nocache.on = True
        * tools.staticdir.dir = '<HELP PAGE DIRECTORY>'

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
Changes in sample plugin to fix and improve help

This patch set changes the Sample plugin, adding a new tab, modifying
naming and other elements in order to show help pages properly.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com>
Import the latest spice-html5 code into Kimchi

All the imported files are a real copy of spice-html5 project
(http://cgit.freedesktop.org/spice/spice-html5) based on commit 097e2c2e

The spice_auto.html also supports wss:// protocol used by Kimchi.

The files are imported under ui/spice-html5 to make clear the files in
that directory are imported from a external project.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
Modify spice_auto.html for Kimchi proposals

The sources were updated according to Kimchi configuration to get the
Javascript and CSS files from the installed spice-html5 package.
Kimchi is not using the default spice_auto.html because Kimchi uses
wss:// for all connections and it is only supported by recent versions of
spice-html5.
In addition to it, Kimchi points user to the right token on URL which
requires a change on spice_auto.html

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>