Commit Graph

2898 Commits

Author SHA1 Message Date
Daniel P. Berrange
575b18c0f0 Misc fixes to secrets API code
* proxy/Makefile.am: Build storage_encryption_conf.c since its a
  dependancy of domain_conf.c
* src/storage_encryption_conf.c: Disable XML parsing APis when
  build under proxy
* src/test.c: Add a dummy no-op secrets driver for test suite
2009-09-01 21:37:42 +01:00
Daniel P. Berrange
6a035507fd Only add glusterfs dep for Fedora >= 11
* libvirt.spec.in: Conditionalize glusterfs requires line for
  Fedora >= 11, since other distros don't have it available
2009-09-01 21:19:38 +01:00
Daniel P. Berrange
721d3f06c9 Remove redundant base64 include file
* src/storage_encryption_conf.c: Remove base64.h
2009-09-01 21:17:51 +01:00
Daniel P. Berrange
24121aa9da Add Miloslav Trmač to AUTHORS file 2009-09-01 18:37:38 +01:00
Miloslav Trmač
28b8cc31f6 Make handling of monitor prompts more general.
* src/qemu_driver.c: Support arbitrary callbacks for "secondary
  prompts".  Reimplement qemudMonitorCommandExtra using such a
  callback.
2009-09-01 18:37:06 +01:00
Miloslav Trmač
077cd91773 Don't assume buffered output echoes the command.
The if ((nlptr...)) implicitly assumes commptr != NULL (and that "buf"
starts with "cmd").  Make the assumption explicit, it will be broken in
a future patch.

* src/qemu_driver.c: Don't assume buffered monitor output echoes the
  command.
2009-09-01 18:36:59 +01:00
Miloslav Trmač
f340964dc9 Attach encryption information to virDomainDiskDef.
The XML allows <encryption format='unencrypted'/>, this implementation
canonicalizes the internal representation so that "disk->encryption" is
non-NULL iff encryption information is available.

A domain with partial encryption information can be defined,
completeness of the information is not verified.  The domain won't
start until the remaining information is added, of course.

* docs/formatdomain.html, docs/formatdomain.html.in: Document
  new encryption options for disks
* docs/schemas/domain.rng: Pull in storage encryption schema
  rules
* src/domain_conf.h, src/domain_conf.c: Wire up storage encryption
  XML parsing/formatting APIs
2009-09-01 18:36:53 +01:00
Miloslav Trmač
46acb0f2b7 Add support for encrypted (qcow) volume creation.
Supports only virStorageVolCreateXML, not virStorageVolCreateXMLFrom.

Curiously, qemu-img does not need the passphrase for anything to create
an encrypted volume.  This implementation thus does not need to touch
any secrets to work with cooperating clients.  More generic passphrase
handling is added in the next patch.

* src/storage_backend.c: Request encryption when creating qcow/qcow2
  files
* src/storage_backend_disk.c, src/storage_backend_fs.c,
  src/storage_backend_logical.c: Refuse to create volumes with
  encryption params set.
2009-09-01 18:27:51 +01:00
Miloslav Trmač
d288703d57 Recognize encryption format of qcow volumes.
(The implementation is not very generic, but that can be very
easily rectified if/when new encryption formats appear.)

* src/storage_backend_fs.c: Probe for qcow/qcow2 encryption
  algorithm field
2009-09-01 18:27:44 +01:00
Miloslav Trmač
eda3af2488 Attach encryption information to virStorageVolDef.
The XML allows <encryption format='unencrypted'/>, this implementation
canonicalizes the internal representation so that "vol->encryption" is
non-NULL iff the volume is encrypted.

Note that partial encryption information (e.g. specifying an encryption
format, but not the key/passphrase) is valid, libvirt will automatically
choose value for the missing information during volume creation.  The
user can read the volume XML, and use the unmodified <encryption> tag in
future operations (without having to be able to understand) its contents.

* docs/formatstorage.html, docs/formatstorage.html.in: Document
  storage volume encryption options
* src/storage_conf.c, src/storage_conf.h: Hook up storage
  encryption XML handling
* tests/storagevolschemadata/vol-qcow2.xml: Test case for encryption
  schema changes
2009-09-01 18:27:38 +01:00
Miloslav Trmač
05b9b8fda3 Add volume encryption information handling.
Define an <encryption> tag specifying volume encryption format and
format-depenedent parameters (e.g. passphrase, cipher name, key
length, key).

Currently the only defined parameter is a reference to a "secret"
(passphrase/key) managed using the virSecret* API.

Only the qcow/qcow2 encryption format, and a "default" format used to
let libvirt choose the format during volume creation, is currently
supported.

This patch does not add any users; the <encryption> tag is added in
the following patches to both volumes (to support encrypted volume
creation) and domains.

* docs/*.html: Re-generate
* docs/formatstorageencryption.html.in, docs/sitemap.html.in:
  Add page describing storage encryption data format
* docs/schemas/Makefile.am, docs/schemas/storageencryption.rng:
  Add RNG schema for storage encryption format
* po/POTFILES.in: Add src/storage_encryption_conf.c
* src/libvirt_private.syms: Export virStorageEncryption* functions
* src/storage_encryption_conf.h, src/storage_encryption_conf.c: Internal
  helper APIs for dealing with storage encryption format
* libvirt.spec.in, mingw32-libvirt.spec.in: Add storageencryption.rng
  RNG schema
2009-09-01 18:27:28 +01:00
Miloslav Trmač
9dc3b99345 Secret manipulation API docs refresh & wire up python generator
Sample session:

>>> import libvirt
>>> c = libvirt.open('qemu:///session')

>>> c.listSecrets()
['12247729-47d2-a783-88ce-b329d4781cd3', 'reee', 'abc']

>>> s = c.secretDefineXML("<secret ephemeral='no' private='no'>\n<description>Something for use</description>\n<volume>/foo/bar</volume>\n</secret>\n")

>>> s.UUIDString()
'340c2dfb-811b-eda8-da9e-25ccd7bfd650'

>>> s.XMLDesc()
"<secret ephemeral='no' private='no'>\n  <uuid>340c2dfb-811b-eda8-da9e-25ccd7bfd650</uuid>\n  <description>Something for use</description>\n  <volume>/foo/bar</volume>\n</secret>\n"

>>> s.setValue('abc\0xx\xffx')
0

>>> s.value()
'abc\x00xx\xffx'

>>> s.undefine()
0

* python/generator.py: Add rules for virSecret APIs
* python/libvir.c, python/libvirt-python-api.xml: Manual impl of
  virSecretSetValue, virSecretGetValue$ and virConnectListSecrets APIs
* python/libvirt_wrap.h, python/types.c: Wrapper for virSecret objects
* docs/libvirt-api.xml, docs/libvirt-refs.xml,
  docs/html/libvirt-virterror.html, docs/html/libvirt-libvirt.html,
  docs/devhelp/libvirt-virterror.html, docs/devhelp/libvirt-libvirt.html:
  Re-generate with 'make api'
2009-09-01 18:27:06 +01:00
Miloslav Trmač
f68c91faa6 Secret manipulation remote client
* src/remote_internal.c: Implement client binding for new secrets
  APIs
* src/datatypes.h: Add 'void *secretPrivateData' to virConnectPtr
  struct
2009-09-01 17:39:25 +01:00
Miloslav Trmač
0de63c6745 Secret manipulation libvirtd wire protocol & remote dispatcher
* qemud/remote_protocol.x: Define wire protocol for secrets public
  APIs
* qemud/remote_protocol.h, qemud/remote_protocol.c,
  qemud/remote_dispatch_table.h, qemud/remote_dispatch_ret.h,
  qemud/remote_dispatch_prototypes.h, qemud/remote_dispatch_args.h:
  Re-generate from updated protocol definition
* qemud/remote.c: Implement RPC dispatchers for new secrets APIs
2009-09-01 17:39:19 +01:00
Miloslav Trmač
b35f0131e6 Secret manipulation public API implementation
* include/libvirt/virterror.h, src/virterror.c: Add VIR_ERR_INVALID_SECRET
  and VIR_FROM_SECRET
* src/libvirt.c: Define stubs for every new public API
2009-09-01 17:39:07 +01:00
Miloslav Trmač
eb42e0ab5c Secret manipulation internal API
* include/libvirt/virterror.h, src/virterror.c: Add VIR_WAR_NO_SECRET
* src/libvirt_private.syms, src/datatypes.h, src/datatypes.c: Type
  virSecret struct definition and helper APIs
* src/driver.h: Sub-driver API definitions for secrets
* src/libvirt.c: Define new sub-driver for secrets
2009-09-01 17:38:59 +01:00
Miloslav Trmač
6acc17af8c Secret manipulation public API
This patch adds a "secret" as a separately managed object, using a
special-purpose API to transfer the secret values between nodes and
libvirt users.

* docs/schemas/secret.rng, docs/schemas/Makefilem.am: Add new
  schema for virSecret objects
* docs/*html: Re-generated
* docs/formatsecret.html.in, docs/sitemap.html.in: Add page
  describing the virSecret XML schema
* include/libvirt/libvirt.h.in: Define the new virSecret public
  API
* src/libvirt_public.syms: Export symbols for new public APIs
* mingw32-libvirt.spec.in, libvirt.spec.in: Add secret.rng to
  files list
2009-09-01 17:38:52 +01:00
Daniel Veillard
3697a0cef6 Update chinese, polish and spanish localizations
* po/*: and update the po set
2009-09-01 15:09:21 +02:00
Charles Duffy
cc76cf31d7 support lzop save compression for qemu
Per prior discussion -- this was, indeed, trivial.

I'm a little disappointed to be breaking the ordering characteristics of
the enum (as it had been ordered by increasing time requirements and
decreasing output size), but breaking any save files with the old
constants in the headers would of course be worse.

>From 2a9cdcfc88de091a8d34aa3fc3b1208d7681790e Mon Sep 17 00:00:00 2001
From: Charles Duffy <Charles_Duffy@dell.com>
Date: Fri, 28 Aug 2009 11:49:54 -0500
Subject: [PATCH] support lzop save compression for qemu

One of the larger disincentives towards use of compression for migrated-out save
files is performance impact. This patch adds support for lzop; CPU time for
compression is about 5x faster than gzip (the next most performant algorithm)
and decompression is about 3x faster.

Signed-off-by: Charles Duffy <Charles_Duffy@dell.com>
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-31 21:11:51 +02:00
Chris Lalancette
1dac1b3726 OpenVZ: accept NULL as type for GetMaxVCPUs.
All of the other drivers that support the getMaxVcpus callback
also accept a NULL value for type.  Make openvz also accept a
NULL value.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-31 21:03:02 +02:00
Chris Lalancette
776f527926 Remove use of strncpy in qemudExtractMonitorPath.
qemudExtractMonitorPath() was doing a VIR_ALLOC_N followed by a
strncpy.  However, this isn't necessary; we can do the same thing
using strndup, which is much safer.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-31 21:01:36 +02:00
Chris Lalancette
bf878aa97e Fix up virNodeGetCellsFreeMemory
The documentation for virNodeGetCellsFreeMemory claims the values
returned are in kilobytes, but that's actually wrong; the value
returned is actually in bytes.  Fix up the documentation to be
correct.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-31 21:01:00 +02:00
Jim Fehlig
8fd7eee90e Fix sexpr2string() to handle empty list.
S-expression containing empty lists, e.g. (cpus (() () () ())),
was not being handled properly in sexpr2string() serialization.
Emit an empty list when encountering NIL sexpr kind.
2009-08-30 11:56:03 +01:00
Daniel P. Berrange
83af050800 Fix driver entry table for UML numa APIs
* src/uml_driver.c: Fix numa API driver entries to avoid
  infinite loop
2009-08-27 19:13:11 +01:00
Pritesh Kothari
544cd63062 Fix crash in virsh vol-key command
* src/virsh.c: Pass in pool object to avoid crash in key lookup
2009-08-27 18:47:41 +01:00
Daniel P. Berrange
3badeffb05 Refactor policycode auth code to avoid compiler warnings
* src/remote_internal.c: Split remoteAuthPolkit into separate
  impls for v0 and v1 to avoid compile warnings due to unused
  variables/params
* qemud/remote.c: Remove accidental tabs
2009-08-25 17:24:12 +01:00
Daniel P. Berrange
8e06c8b3da Support new PolicyKit 1.0 API
* configure.in: Check for pkcheck which indicates new policykit
* qemud/Makefile.am: Install different versions of policy
* qemud/libvirtd.policy: Rename to libvirtd.policy-0
* qemud/libvirtd.policy-1: new style policy
* qemud/qemud.c, qemud/qemud.h, qemud/remote.c: Support new
  policykit API via external pkcheck helper
* src/remote_internal.c: Don't prompt for polkit auth with new
  policykit API
* libvirt.spec.in: deal with new policy install locations & deps
2009-08-25 11:59:14 +01:00
Darryl L. Pierce
777fc2e9d6 517157 fix selinux problem with images on NFS
* src/security_selinux.c: ignores EOPNOTSUPP when attempting to access an
  NFS share
2009-08-21 16:57:29 +02:00
Mark McLoughlin
ce1783ccc1 spec file: add URL to Source tag
See https://fedoraproject.org/wiki/Packaging:SourceURL
2009-08-21 11:10:37 +01:00
Mattias Bolte
40d46934d0 Fix phypOpen() escape_specialcharacters
Matthias correctly points out that escape_specialcharaters() takes a
length, and since we are now malloc()'ing string in phypOpen instead of
making it a static array, we can't use sizeof(string) anymore.  Calculate
the proper strlen and then use that both to allocate the string and also
pass it to escape_specialcharacters().

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-20 13:59:07 +02:00
Mattias Bolte
1aa1683377 Power Hypervisor: fix potential segfault
I came across this line in the phypOpen function:

char string[strlen(conn->uri->path)];

Here the path part of the given URI is used without checking it for
NULL, this can cause a segfault as strlen expects a string != NULL.
Beside that uuid_db and connection_data leak in case of an error.

In this line

conn->uri->path = string;

the original path of the URI leaks. The patch adds a VIR_FREE call
before setting the new path.

The attached patch is compile-tested but I don't have a Power
Hypervisor installation at hand to test it for real.

Matthias

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-20 12:53:17 +02:00
Chris Lalancette
2e7c8b0b6f Small fixes for qemu save compression.
Fix up a small memory leak pointed out by DanB; I was forgetting
to release memory allocated to driver->saveImageFormat.
Also add the "save_image_format" and "security" entries to
the augeas lens.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-20 09:27:03 +02:00
Daniel P. Berrange
da8b7c9f89 Add test for recently fixed crash with latest XenD
Test case for the fix applied in

  commit 14435163a0
  Author: Daniel Veillard <veillard@redhat.com>
  Date:   Fri Jun 26 18:14:16 2009 +0000

* tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.sexpr,
  tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml: Data
  files exhibiting the crash
* tests/sexpr2xmltest.c: Process new data files
2009-08-19 17:44:50 +01:00
Daniel P. Berrange
14194f1d56 Fix some typos & remove unhelpful acronyms in QEMU docs 2009-08-19 17:02:45 +01:00
Daniel P. Berrange
690b4ad329 Add documentation about the QEMU driver security features
* docs/drvqemu.html.in: Document DAC usage, SELinux integration,
  Linux capabilities, and Cgroups device ACLs
2009-08-19 14:19:16 +01:00
Mark McLoughlin
3ec80d0112 Fix bridge/tap system error reporting
* src/qemu_conf.c, src/uml_conf.c: use virReportSystemError() to report
  system errors
2009-08-18 14:15:58 +01:00
Mark McLoughlin
2b1f67d418 Don't expose 'vnet%d' to the user
https://bugzilla.redhat.com/517371

Matt Booth points out that if you use a non-existent bridge name when
start a guest you get a weird error message:

  Failed to add tap interface 'vnet%d' to bridge 'virbr0'

and dev='vnet%d' appears in the dumpxml output.

Fix that by not including 'vnet%d' in the error message and freeing the
'vnet%d' string if adding the tap device to the bridge fails.

* src/qemu_conf.c, src/uml_conf.c: fix qemudNetworkIfaceConnect()
  and umlConnectTapDevice() to not expose 'vnet%d' to the user
2009-08-18 13:36:37 +01:00
Mark McLoughlin
e8ad339312 Maintain a list of active PCI hostdevs and use it in pciResetDevice()
As we start/shutdown guests, or hotplug/hot-unplug devices, we can add
or delete devices as appropriate from a list of active devices.

Then, in pciReset(), we can use this to determine whether its safe to
reset a device as a side effect of resetting another device.

* src/qemu_conf.h: add activePciHostdevs to qemud_driver

* src/qemu_driver.c: maintain the activePciHostdevs list, and pass it
  to pciResetDevice()

* src/pci.[ch]: pass the activeDevs list to pciResetDevice() and use
  it to determine whether a Secondary Bus Reset is safe
2009-08-18 09:41:57 +01:00
Mark McLoughlin
78675b228b Simplify PCI hostdev prepare/re-attach using a pciDeviceList type
The qemuPrepareHostDevices() and qemuDomainReAttachHostDevices()
functions are clutter with a bunch of calls to pciGetDevice() and
pciFreeDevice() obscuring the basic logic.

Add a pciDeviceList type and add a qemuGetPciHostDeviceList() function
to build a list from a domain definition. Use this in prepare/re-attach
fto simplify things and eliminate the multiple pciGetDevice calls.

This is especially useful because in the next patch we need to iterate
the hostdevs list a third time and we also need a list type for keeping
track of active devices.

* src/pci.[ch]: add pciDeviceList type and also a per-device 'managed'
  property

* src/libvirt_private.syms: export the new functions

* src/qemu_driver.c: add qemuGetPciHostDeviceList() and re-write
  qemuPrepareHostDevices() and qemuDomainReAttachHostDevices() to use it
2009-08-18 09:41:57 +01:00
Mark McLoughlin
60ff07585c Use pci_addr=auto with QEMU's pci_add monitor command
Newer versions of QEMU accept 'pci_add auto', but older versions require
'pci_add pci_addr=auto'

* src/qemu_driver.c: use pci_addr= in qemudDomainAttachHostPciDevice()
  for older versions of QEMU
2009-08-18 09:41:57 +01:00
Mark McLoughlin
457e050628 Fix thinko in PCI hostdev detach
* src/qemu_driver.c: Add missing break statement in
  qemudDomainDetachHostDevice()
2009-08-18 09:41:57 +01:00
Mark McLoughlin
12edef9a6a Reset PCI host devices after hot-unplug
When we hot-unplug a PCI host device from a guest, we should reset it.

Both managed and unmanaged devices should be reset, but only managed
devices should be re-attached.

* src/qemu_driver.c: reset devices in qemudDomainDetachHostPciDevice()
2009-08-18 09:41:57 +01:00
Mark McLoughlin
4dbecff9fb Reset unmanaged PCI host devices before hotplug
Right now we're only resetting managed devices before hotplug, but we
should reset them irrespective of whether they are managed.

* src/qemu_driver.c: reset all PCI hostdevs before hotplug
2009-08-18 09:41:57 +01:00
Mark McLoughlin
4954e079c8 Revert changes to allow pciResetDevice() reset multiple devices
It turns out that the previous attempt at this doesn't work well
in the case of hotplug. We need qemuCheckPciHostDevice() to
disallow the reset affecting devices already attach to the guest,
but we still need to avoid double locking the virDomainObjPtr.

This is all getting messy, I've a better idea.

This reverts commit 6318808270 and
c106c8a18c.

* src/qemu_driver.c, src/pci.[ch], src/xen_unified.c,
  src/libvirt_private.syms: revert a bunch of stuff.
2009-08-18 09:41:56 +01:00
Mark McLoughlin
0b973381dc Fix list updating after disk/network/hostdev hot-unplug
The current code makes a poor effort at updating the device arrays after
hot-unplug. Fix that and combine the two code paths into one.

* src/qemu_driver.c: fix list updating in qemudDomainDetachNetDevice(),
  qemudDomainDetachPciDiskDevice() and qemudDomainDetachHostPciDevice()
2009-08-18 09:41:56 +01:00
Mark McLoughlin
331e1fcbee Re-name remote_internal.c:driver to remote_driver
Confused me when poking at another 'driver' variable in gdb which gcc
had optimized away

* src/remote_internal.c: rename driver to remote_driver
2009-08-18 09:41:56 +01:00
Mark McLoughlin
097c818bf0 Cosmetic change to 'virsh nodedev-list --tree' output
Maybe it's just me, but I try to select an item from the tree using
double-click and get annoyed when "+-" gets included in the selection.

* src/virsh.c: add a space between "+-" and the node device name
  in 'virsh nodedev-list --tree'
2009-08-18 09:41:56 +01:00
Chris Lalancette
cb51aa48a7 Fix up connection reference counting.
Currently the reference counting for connections is busted.  I
first noticed it while trying to use virConnectRef; it would
eventually cause a crash in the remote_internal driver, although
that was really just a victim.  Really, we should only call the
close callbacks on the methods when the references drop to 0.  To
accomplish this, move all of the close callbacks into
virUnrefConnect (since there are lots of internal users of that
function), and arrange for virConnectClose to call that.

V2: Make sure to drop the connection lock before we call the close
    callbacks, otherwise we could deadlock the daemon
V3: Fix up a crash when we got an error from one of the drivers

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-18 09:26:26 +02:00
Daniel P. Berrange
e403f8d43e Fix LXC driver crash when kernel doesn't support clone
* src/domain_conf.c: Make virDomainObjListFree a no-op if list
  is NULL
* src/domain_event.c: make virDomainEventCallbackListFree a no-op
  if event list is NULL
* src/lxc_driver.c: Log a message if LXC driver does not startup
  due to lacking kernel support
2009-08-17 16:20:57 +01:00
Chris Lalancette
2d6a581960 Compressed save image format for Qemu.
Implement a compressed save image format for qemu.  While ideally
we would have the choice between compressed/non-compressed
available to the libvirt API, unfortunately there is no "flags"
parameter to the virDomainSave() API.  Therefore, implement this
as a qemu.conf option.  gzip, bzip2, and lzma are implemented, and
it should be very easy to implement additional compression
methods.

One open question is if/how we should detect the compression
binaries.  One way to do it is to do compile-time setting of the
paths (via configure.in), but that doesn't seem like a great thing
to do.  My preferred solution is not to detect at all;
when we go to run the commands that need them, if they
aren't available, or aren't available in one of the standard paths,
then we'll fail.  That's also the solution implemented in this patch.

In the future, we'll have a more robust (managed) save/restore API,
at which time we can expose this functionality properly in the API.

V2: get rid of redundant dd command and just use >> to append data.
V3: Add back the missing pieces for the enum and bumping the save version.
V4: Make the compressed field in the save_header an int.
    Implement LZMA compression.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-17 09:00:19 +02:00