Commit Graph

7516 Commits

Author SHA1 Message Date
Laine Stump
21ea73e8f4 util: eliminate union in virNetDevVPortProfile
virNetDevVPortProfile has (had) a type field that can be set to one of
several values, and a union of several structs, one for each
type. When a domain's interface object is of type "network", the
domain config may not know beforehand which type of virtualport is
going to be provided in the actual device handed down from the network
driver at runtime, but may want to set some values in the virtualport
that may or may not be used, depending on the type. To support this
usage, this patch replaces the union of structs with toplevel fields
in the struct, making it possible for all of the fields to be set at
the same time.
2012-08-14 15:47:08 -04:00
Laine Stump
85d9c17d70 util: make return value of virUUIDFormat and virMacAddrFormat useful
Both of these functions returned void, but it's convenient for them to
return a const char* of the char* that is passed in. This was you can
call the function and use the result in the same expression/arg.
2012-08-14 15:47:02 -04:00
Eric Blake
37f3cd416c build: fix link error with appArmor
Commit bb705e25 missed that the appArmor helper file also needs to
resolve the new symbols dragged in by domain_conf.c.

* src/Makefile.am (SECURITY_DRIVER_APPARMOR_HELPER_SOURCES): Pull
in datatypes.c.
2012-08-14 11:44:40 -06:00
Dmitry Guryanov
cf24bed098 openvz: unlock virDomainObj objects in openvzOpen
openvzOpen fucntion must leave unlocked virDomainObj objects in
driver->domains.

Now even simple commands like list or domain lookup hang,
for example virsh -c openvz:///system list --all.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-14 09:57:42 -06:00
Daniel P. Berrange
b6e66cb6dd Pull code which finds a free MCS label out into its own method
The code for picking a MCS label is about to get significantly
more complicated, so it deserves to be in a standlone method,
instead of a switch/case body.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-14 15:31:26 +01:00
Daniel P. Berrange
b77e9814e4 Honour current user and role in SELinux label generation
When generating an SELinux context for a VM from the template
"system_u:system_r:svirt_t:s0", copy the role + user from the
current process instead of the template context. So if the
current process is

   unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

then the VM context ends up as

  unconfined_u:unconfined_r:svirt_t:s0:c386,c703

instead of

   system_u:system_r:svirt_t:s0:c177,c424

Ideally the /etc/selinux/targeted/contexts/virtual_domain_context
file would have just shown the 'svirt_t' type, and not the full
context, but that can't be changed now for compatibility reasons.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-14 15:31:26 +01:00
Daniel P. Berrange
cbe67ff9b0 Fix error reporting in virSecuritySELinuxGenNewContext
The virSecuritySELinuxGenNewContext method was not reporting any
errors, leaving it up to the caller to report a generic error.
In addition it could potentially trigger a strdup(NULL) in an
OOM scenario. Move all error reporting into the
virSecuritySELinuxGenNewContext method where accurate info
can be provided

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-14 15:31:26 +01:00
Daniel P. Berrange
51b23ed31a Use VIR_ERR_CONFIG_UNSUPPORTED if requested security driver is disabled
There is currently no way to distinguish the case that a requested
security driver was disabled, from the case where no security driver
was available. Use VIR_ERR_CONFIG_UNSUPPORTED as the error when an
explicitly requested security driver was disabled

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-14 15:31:26 +01:00
Daniel P. Berrange
fd016806df Add missing domain_conf.h include in security_manager.h
The security_manager.h header is not self-contained because it
uses the virDomainDefPtr without first including domain_conf.h

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-14 15:31:26 +01:00
Daniel P. Berrange
aa5bd8b9b9 Add virRandom() API to generate numbers with non-power-of-2 limit
The current virRandomBits() API is only usable if the caller wants
a random number in the range [0, n-1) where n is a power of two.
This adds a virRandom() API which generates a double in the
range [0.0,1.0) with 48 bits of entropy. It then also adds a
virRandomInt(uint32_t max) API which generates an unsigned
in the range [0,@max)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-14 15:31:25 +01:00
Martin Kletzander
0a6504d40c util: typos in fallback code fo virDoubleToStr
Fixes for some typos that somehow didn't get to the final push of the
commit 43bfa23e6f.
2012-08-14 12:12:38 +02:00
Osier Yang
bb705e2519 Destroy virdomainlist.[ch]
As the consensus in:
https://www.redhat.com/archives/libvir-list/2012-July/msg01692.html,
this patch is to destroy conf/virdomainlist.[ch], folding the
helpers into conf/domain_conf.[ch].

* src/Makefile.am:
  - Various indention fixes incidentally
  - Add macro DATATYPES_SOURCES (datatypes.[ch])
  - Link datatypes.[ch] for libvirt_lxc

* src/conf/domain_conf.c:
  - Move all the stuffs from virdomainlist.c into it
  - Use virUnrefDomain and virUnrefDomainSnapshot instead of
    virDomainFree and virDomainSnapshotFree, which are defined
    in libvirt.c, and we don't want to link to it.
  - Remove "if" before "free" the object, as virObjectUnref
    is in the list "useless_free_options".

* src/conf/domain_conf.h:
  - Move all the stuffs from virdomainlist.h into it
  - s/LIST_FILTER/LIST_DOMAINS_FILTER/

* src/libxl/libxl_driver.c:
  - s/LIST_FILTER/LIST_DOMAINS_FILTER/
  - no (include "virdomainlist.h")

* src/libxl/libxl_driver.c: Likewise

* src/lxc/lxc_driver.c: Likewise

* src/openvz/openvz_driver.c: Likewise

* src/parallels/parallels_driver.c: Likewise

* src/qemu/qemu_driver.c: Likewise

* src/test/test_driver.c: Likewise

* src/uml/uml_driver.c: Likewise

* src/vbox/vbox_tmpl.c: Likewise

* src/vmware/vmware_driver.c: Likewise

* tools/virsh-domain-monitor.c: Likewise

* tools/virsh.c: Likewise
2012-08-14 17:27:49 +08:00
Martin Kletzander
43bfa23e6f json: fix interface locale dependency
libvirt creates invalid commands if wrong locale is selected. For
example with locale that uses comma as a decimal point, JSON commands
created with decimal numbers are invalid because comma separates the
entries in JSON. Fortunately even when decimal point is affected,
thousands grouping is not, because for grouping to be enabled with
*printf, there has to be an apostrophe flag specified (and supported).

This patch adds specific internal function for converting doubles to
strings with C locale.
2012-08-14 07:30:14 +02:00
Asad Saeed
ff73c6d3bc sanlock: don't unlink lockspace if registration fails
This is a patch for bug 847848
If registering an existing lockspace with the sanlock daemon
returns an error, libvirt should not proceed to unlink the lockspace.

Signed-off-by: Asad Saeed <asad.saeed@acidseed.com>
2012-08-13 17:11:30 -06:00
Cole Robinson
7e6f80107c build: Distribute check-symfile.pl
Otherwise distcheck can fail with:

  GEN      check-symfile
  Can't open perl script "../../src/check-symfile.pl": No such file or directory
  make[4]: *** [check-symfile] Error 2
2012-08-13 15:26:13 -04:00
Frido Roose
a58cb1ac40 Release only specific sanlock resource
This is a patch for bug 826704
All sanlock resources get released when hot-dettaching a disk from the domain
because virLockManagerSanlockRelease uses the wrong function parameters/flags.
With the patch only the resources that should be released are cleaned up.

Signed-off-by: Frido Roose <frido.roose@gmail.com>
2012-08-13 10:29:12 -06:00
Peter Krempa
e9a24e3e3d virterror: Add error message for unsupported operations.
This patch introduces a new error code VIR_ERR_OPERATION_UNSUPPORTED to
mark error messages regarding operations that failed due to lack of
support on the hypervisor or other than libvirt issues.

The code is first used in reporting error if qemu does not support block
IO tuning variables yielding error message:
error: Unable to get block I/O throttle parameters
error: Operation not supported: block_io_throttle field
'total_bytes_sec' missing in qemu's output

instead of:
error: Unable to get block I/O throttle parameters
error: internal error cannot read total_bytes_sec
2012-08-11 10:03:00 +02:00
Laine Stump
54264111ff build: fix binary location in stap files --with-driver-modules
libvirt_qemu_probes.stp stopped working after switching to a build
that used --with-driver-modules. This was because the symbols listed
int libvirt_qemu_probes.stp are no longer in $(bindir)/libvirtd, but
are now in $(libdir)/connection-driver/libvirt_driver_qemu.so.

This patch enhances dtrace2systemtap.pl (which generates the .stp
files from .d files) to look for a new "module" setting in the
comments of the .d file (similar to the existing "binary" setting),
and to look for a --with-modules option. If the --with-modules option
is set *and* a "module" setting is present in the .d file, the process
name for the stap line is set to

   $libdir/$module

If either of these isn't true, it reverts to the old behavior.

src/Makefile.am was also modified to add the --with-modules option
when the build calls for it, and src/libvirt_qemu_probes.d has added a
"module" line pointing to the correct .so file for the qemu driver.
2012-08-10 23:11:26 -04:00
Laine Stump
b8a56f12f5 nwfilter: fix crash during filter define when lxc driver failed startup
The meat of this patch is just moving the calls to
virNWFilterRegisterCallbackDriver from each hypervisor's "register"
function into its "initialize" function. The rest is just code
movement to allow that, and a new virNWFilterUnRegisterCallbackDriver
function to undo what the register function does.

The long explanation:

There is an array in nwfilter called callbackDrvArray that has
pointers to a table of functions for each hypervisor driver that are
called by nwfilter. One of those function pointers is to a function
that will lock the hypervisor driver. Entries are added to the table
by calling each driver's "register" function, which happens quite
early in libvirtd's startup.

Sometime later, each driver's "initialize" function is called. This
function allocates a driver object and stores a pointer to it in a
static variable that was previously initialized to NULL. (and here's
the important part...) If the "initialize" function fails, the driver
object is freed, and that pointer set back to NULL (but the entry in
nwfilter's callbackDrvArray is still there).

When the "lock the driver" function mentioned above is called, it
assumes that the driver was successfully loaded, so it blindly tries
to call virMutexLock on "driver->lock".

BUT, if the initialize never happened, or if it failed, "driver" is
NULL. And it just happens that "lock" is always the first field in
driver so it is also NULL.

Boom.

To fix this, the call to virNWFilterRegisterCallbackDriver for each
driver shouldn't be called until the end of its (*already guaranteed
successful*) "initialize" function, not during its "register" function
(which is currently the case). This implies that there should also be
a virNWFilterUnregisterCallbackDriver() function that is called in a
driver's "shutdown" function (although in practice, that function is
currently never called).
2012-08-09 23:28:00 -04:00
Eric Blake
51ee43aa55 build: fix PROBE() usage of intptr_t
Otherwise, in locations like virobject.c where PROBE is used,
for certain configure options, the compiler warns:

util/virobject.c:110:1: error: 'intptr_t' undeclared (first use in this function)

As long as we are making this header always available, we can
clean up several other files.

* src/internal.h (includes): Pull in <stdint.h>.
* src/conf/nwfilter_conf.h: Rely on internal.h.
* src/storage/storage_backend.c: Likewise.
* src/storage/storage_backend.h: Likewise.
* src/util/cgroup.c: Likewise.
* src/util/sexpr.h: Likewise.
* src/util/virhashcode.h: Likewise.
* src/util/virnetdevvportprofile.h: Likewise.
* src/util/virnetlink.h: Likewise.
* src/util/virrandom.h: Likewise.
* src/vbox/vbox_driver.c: Likewise.
* src/xenapi/xenapi_driver.c: Likewise.
* src/xenapi/xenapi_utils.c: Likewise.
* src/xenapi/xenapi_utils.h: Likewise.
* src/xenxs/xenxs_private.h: Likewise.
* tests/storagebackendsheepdogtest.c: Likewise.
2012-08-09 15:40:42 -06:00
Matthias Bolte
b8fa5fd071 esx: Implement network driver
An ESX server has one or more PhysicalNics that represent the actual
hardware NICs. Those can be listed via the interface driver.

A libvirt virtual network is mapped to a HostVirtualSwitch. On the
physical side a HostVirtualSwitch can be connected to PhysicalNics.
On the virtual side a HostVirtualSwitch has HostPortGroups that are
mapped to libvirt virtual network's portgroups. Typically there is
HostPortGroups named 'VM Network' that is used to connect virtual
machines to a HostVirtualSwitch. A second HostPortGroup typically
named 'Management Network' is used to connect the hypervisor itself
to the HostVirtualSwitch. This one is not mapped to a libvirt virtual
network's portgroup. There can be more HostPortGroups than those
typical two on a HostVirtualSwitch.

         +---------------+-------------------+
   ...---|               |                   |   +-------------+
         | HostPortGroup |                   |---| PhysicalNic |
         |   VM Network  |                   |   |    vmnic0   |
   ...---|               |                   |   +-------------+
         +---------------+ HostVirtualSwitch |
                         |     vSwitch0      |
         +---------------+                   |
         | HostPortGroup |                   |
   ...---|   Management  |                   |
         |    Network    |                   |
         +---------------+-------------------+

The virtual counterparts of the PhysicalNic is the HostVirtualNic for
the hypervisor and the VirtualEthernetCard for the virtual machines
that are grouped into HostPortGroups.

   +---------------------+   +---------------+---...
   | VirtualEthernetCard |---|               |
   +---------------------+   | HostPortGroup |
   +---------------------+   |   VM Network  |
   | VirtualEthernetCard |---|               |
   +---------------------+   +---------------+
                                             |
                             +---------------+
   +---------------------+   | HostPortGroup |
   |    HostVirtualNic   |---|   Management  |
   +---------------------+   |    Network    |
                             +---------------+---...

The currently implemented network driver can list, define and undefine
HostVirtualSwitches including HostPortGroups for virtual machines.
Existing HostVirtualSwitches cannot be edited yet. This will be added
in a followup patch.
2012-08-09 22:31:47 +02:00
Matthias Bolte
ba86e5cd3f esx: Remove redundant checks for esxVI_LookupHostSystemProperties result
esxVI_LookupHostSystemProperties guarantees that hostSystem is non-NULL.
Remove redundant NULL checks from callers.

Also prefer esxVI_GetStringValue over open-coding the logic.
2012-08-09 22:31:47 +02:00
Matthias Bolte
c10cc25470 esx: Fix dynamic deep copy
The static deep copy allocates storage for the copy. The dynamic
version injected the dynamic dispatch after the allocation. This
triggered the invalid argument check in the dynamically dispatched
deep copy call. The deep copy function expects its dest parameter
to be a pointer to a NULL-pointer. This expectation wasn't met due
to the dispatching deep copy doing the allocation before the call.

Fix this by dynamically dispatching to the correct type before the
allocation.
2012-08-09 22:31:47 +02:00
Matthias Bolte
b9dfbf5723 esx: Implement interface driver
Lists available PhysicalNic devices. A PhysicalNic is always active
and can neither be defined nor undefined.

A PhysicalNic is used to bridge a HostVirtualSwitch to the physical
network.
2012-08-09 22:31:46 +02:00
Stefan Berger
98c7d8b278 nwfilter: remove target table before renaming it
Remove the target table before renaming a table to it, i.e.,
remove table B before renaming A to B. This makes the
renaming more robust against unconnected left-over tables.
2012-08-09 16:17:13 -04:00
Daniel P. Berrange
efd6824cfc Add APIs for obtaining the unique ID of LVM & SCSI volumes
Both LVM volumes and SCSI LUNs have a globally unique
identifier associated with them. It is useful to be able
to query this identifier to then perform disk locking,
rather than try to figure out a stable pathname.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-09 16:12:01 +01:00
Jiri Denemark
e18396f36d qemu: Fix debug message in p2p migration
When entering "confirm" phase, we are interested in the value of
cancelled rather then ret variable which was interesting before "finish"
phase and didn't change since then.
2012-08-09 15:37:05 +02:00
Jiri Denemark
6cfdeaac55 qemu: Migrate at unlimited speed by default
Previously, qemu did not respond to monitor commands during migration if
the limit was too high. This prevented us from raising the limit
earlier. The qemu issue seems to be fixed (according to my testing) and
we may remove the 32Mb/s limit.
2012-08-09 15:34:47 +02:00
Peter Krempa
aba9abc5b7 qemu: Refactor parsing of block device IO tuning parameters.
This patch refactors the JSON parsing function that extracts the block
IO tuning parameters from qemu's output. The most impacting change
concerns the error message that is returned if the reply from qemu does
not contain the needed data. The data for IO parameter tuning were added
in qemu 1.1 and the previous error message was confusing.

This patch also breaks long lines and extracts a multiple time used code
pattern to a macro.
2012-08-09 13:59:08 +02:00
Peter Krempa
6758ad4f9e remote: Clean up coding style and refactor remote connection opening
Remove spaces before function calls and some other coding nits in some
parts of the remote driver and refactor getting of URI argument
components into variables used by libvirt later on.
2012-08-09 11:36:03 +02:00
Peter Feiner
16d3ab8662 Allow rbd backing stores
Prevents libvirt from treating RBD backing stores as files. Without this
patch, creating a domain with a qcow2 overlay on an RBD would fail.

This patch essentially extends 9c7c4a4fc5,
which allows nbd backing stores, to allow rbd backing stores.
2012-08-08 15:57:14 -06:00
Peter Feiner
bfa74ebe1f Fix errno check, prevent spurious errors under heavy load
From man poll(2), poll does not set errno=EAGAIN on interrupt, however
it does set errno=EINTR. Have libvirt retry on the appropriate errno.

Under heavy load, a program of mine kept getting libvirt errors 'poll on
socket failed: Interrupted system call'. The signals were SIGCHLD from
processes forked by threads unrelated to those using libvirt.
2012-08-08 15:50:58 -06:00
Guannan Ren
d7d468f02c qemu:rename qemuCheckScsiControllerModel function 2012-08-08 23:13:23 +08:00
Guannan Ren
4118592786 rpc: fix a virObject typo error in struct _virNetServer
This typo will crash libvirtd when it recevies signal SIGINT
2012-08-08 17:32:22 +08:00
Guannan Ren
015c603bcd qemu: add two qemu caps for lsi and virtio-scsi SCSI controllers
Rename qemuDefaultScsiControllerModel to qemuCheckScsiControllerModel.
When scsi model is given explicitly in XML(model > 0) checking if the
underlying QEMU supports it or not first, raise an error on checking
failure.
When the model is not given(mode <= 0), return LSI by default, if
the QEMU doesn't support it, raise an error.
2012-08-08 15:06:33 +08:00
Guannan Ren
8694c716ae qemu: add capabilities flags related to scsi controller
QEMU_CAPS_SCSI_LSI
    set the flag when "lsi53c895a", bus PCI, alias "lsi" in
    the output of "qemu -device ?"
    -device lsi in qemu command line

  QEMU_CAPS_VIRTIO_SCSI_PCI
    set the flag when "name "virtio-scsi-pci", bus PCI" in
    the output of qemu devices query.
    -device virtio-scsi-pci in qemu command line
2012-08-08 14:25:24 +08:00
Laine Stump
b8c298d301 util: include stderr in log message when an external command fails
This patch is in response to:

  https://bugzilla.redhat.com/show_bug.cgi?id=818467

If a caller to virCommandRun doesn't ask for the exitstatus of the
program it's running, the virCommand functions assume that they should
log an error message and return failure if the exit code isn't
0. However, only the commandline and exit status are logged, while
potentially useful information sent by the program to stderr is
discarded.

Fortunately, virCommandRun is already checking if the caller had asked
for stderr to be saved and, if not, sets things up to save it in
*cmd->errbuf. This makes it fairly simple for virCommandWait to
include *cmd->errbuf in the error log (there are still other callers
that don't setup errbuf, and even virCommandRun won't set it up if the
command is being daemonized, so we have to check that it's non-zero).
2012-08-07 15:25:40 -04:00
Daniel P. Berrange
05e4e7b46e Turn virNetClient* into virObject instances
Make all the virNetClient* objects use virObject APIs for
reference counting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:55 +01:00
Daniel P. Berrange
958499b0c1 Turn virNetServer* into virObject instances
Make all the virNetServer* objects use the virObject APIs
for reference counting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:55 +01:00
Daniel P. Berrange
410a5dac42 Turn virSocket into a virObject
Make virSocket use the virObject APIs for reference counting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:41 +01:00
Daniel P. Berrange
2303e92086 Turn virKeepAlive into a virObject
Make virKeepAlive use the virObject APIs for reference counting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:41 +01:00
Daniel P. Berrange
0b4d3fe556 Turn virNetSASLContext and virNetSASLSession into virObject instances
Make virNetSASLContext and virNetSASLSession use virObject APIs
for reference counting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:41 +01:00
Daniel P. Berrange
e10e1969d5 Turn virNetTLSContext and virNetTLSSession into virObject instances
Make virNetTLSContext and virNetTLSSession use the virObject
APIs for reference counting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:41 +01:00
Daniel P. Berrange
b57ee0921e Turn qemuAgentPtr and qemuMonitorPtr into virObjectPtr instances
Make qemuAgentPtr and qemuMonitorPtr types use the virObject APIs
for reference counting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:41 +01:00
Daniel P. Berrange
31cb030ab6 Turn virDomainObjPtr into a virObjectPtr
Switch virDomainObjPtr to use the virObject APIs for reference
counting. The main change is that virObjectUnref does not return
the reference count, merely a bool indicating whether the object
still has any refs left. Checking the return value is also not
mandatory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:41 +01:00
Daniel P. Berrange
46ec5f85c8 Convert public datatypes to inherit from virObject
This converts the following public API datatypes to use the
virObject infrastructure:

  virConnectPtr
  virDomainPtr
  virDomainSnapshotPtr
  virInterfacePtr
  virNetworkPtr
  virNodeDevicePtr
  virNWFilterPtr
  virSecretPtr
  virStreamPtr
  virStorageVolPtr
  virStoragePoolPtr

The code is significantly simplified, since the mutex in the
virConnectPtr object now only needs to be held when accessing
the per-connection virError object instance. All other operations
are completely lock free.

* src/datatypes.c, src/datatypes.h, src/libvirt.c: Convert
  public datatypes to use virObject
* src/conf/domain_event.c, src/phyp/phyp_driver.c,
  src/qemu/qemu_command.c, src/qemu/qemu_migration.c,
  src/qemu/qemu_process.c, src/storage/storage_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xend_internal.c,
  tests/qemuxml2argvtest.c, tests/qemuxmlnstest.c,
  tests/sexpr2xmltest.c, tests/xmconfigtest.c: Convert
  to use virObjectUnref/virObjectRef

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:41 +01:00
Daniel P. Berrange
784a99f794 Add a generic reference counted virObject type
This introduces a fairly basic reference counted virObject type
and an associated virClass type, that use atomic operations for
ref counting.

In a global initializer (recommended to be invoked using the
virOnceInit API), a virClass type must be allocated for each
object type. This requires a class name, a "dispose" callback
which will be invoked to free memory associated with the object's
fields, and the size in bytes of the object struct.

eg,

   virClassPtr  connclass = virClassNew("virConnect",
                                        sizeof(virConnect),
                                        virConnectDispose);

The struct for the object, must include 'virObject' as its
first member

eg

  struct _virConnect {
    virObject object;

    virURIPtr uri;
  };

The 'dispose' callback is only responsible for freeing
fields in the object, not the object itself. eg a suitable
impl for the above struct would be

  void virConnectDispose(void *obj) {
     virConnectPtr conn = obj;
     virURIFree(conn->uri);
  }

There is no need to reset fields to 'NULL' or '0' in the
dispose callback, since the entire object will be memset
to 0, and the klass pointer & magic integer fields will
be poisoned with 0xDEADBEEF before being free()d

When creating an instance of an object, one needs simply
pass the virClassPtr eg

   virConnectPtr conn = virObjectNew(connclass);
   if (!conn)
      return NULL;
   conn->uri = virURIParse("foo:///bar")

Object references can be manipulated with

   virObjectRef(conn)
   virObjectUnref(conn)

The latter returns a true value, if the object has been
freed (ie its ref count hit zero)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-07 11:47:41 +01:00
Richa Marwaha
e060f86495 Add -netdev bridge support
This patch adds the support to run the QEMU network helper
under unprivileged user. It also adds the support for
attach-interface option in virsh to run under unprivileged
user.

Signed-off-by: Richa Marwaha <rmarwah@linux.vnet.ibm.com>
Signed-off-by: Corey Bryant<coreyb@linux.vnet.ibm.com>
2012-08-06 16:56:59 +02:00
Richa Marwaha
756fe7868b Add -netdev bridge capabilities
This patch adds the capability in libvirt to check if
-netdev bridge option is supported or not.

Signed-off-by: Richa Marwaha <rmarwah@linux.vnet.ibm.com>
Signed-off-by: Corey Bryant<coreyb@linux.vnet.ibm.com>
2012-08-06 16:56:59 +02:00
Eric Blake
87de27b7f9 virrandom: make virRandomInitialize an automatic one-shot
All callers used the same initialization seed (well, the new
viratomictest forgot to look at getpid()); so we might as well
make this value automatic.  And while it may feel like we are
giving up functionality, I documented how to get it back in the
unlikely case that you actually need to debug with a fixed
pseudo-random sequence.  I left that crippled by default, so
that a stray environment variable doesn't cause a lack of
randomness to become a security issue.

* src/util/virrandom.c (virRandomInitialize): Rename...
(virRandomOnceInit): ...and make static, with one-shot call.
Document how to do fixed-seed debugging.
* src/util/virrandom.h (virRandomInitialize): Drop prototype.
* src/libvirt_private.syms (virrandom.h): Don't export it.
* src/libvirt.c (virInitialize): Adjust caller.
* src/lxc/lxc_controller.c (main): Likewise.
* src/security/virt-aa-helper.c (main): Likewise.
* src/util/iohelper.c (main): Likewise.
* tests/seclabeltest.c (main): Likewise.
* tests/testutils.c (virtTestMain): Likewise.
* tests/viratomictest.c (mymain): Likewise.
2012-08-06 08:15:13 -06:00
Eric Blake
1d5bc38220 build: drop conditional use of mdns code
Commit 1f6f723 missed a step.  At first I was worried that scrubbing
the conditionals would lead to a runtime failure when compiled without
avahi, but my testing makes it appear that the runtime error will only
occur if the .conf files in /etc request mdns advertisement; and the
old behavior was to silently ignore the request, so this is actually
a better behavior of only failing when the config requests the
impossible.

* src/rpc/virnetserver.c: Drop HAVE_AVAHI conditionals; all
callers already passed NULL if mdns_adv was not configured.
2012-08-06 07:55:29 -06:00
Michal Privoznik
addeb7cd05 qemu: Set reasonable RSS limit on domain startup
If there's a memory leak in qemu or qemu is exploited the host's
system will sooner or later start trashing instead of killing
the bad process. This however has impact on performance and other
guests as well. Therefore we should set a reasonable RSS limit
even when user hasn't set any. It's better to be secure by default.
2012-08-06 08:06:44 +02:00
Jim Fehlig
1fbdfc53be xen-xm: Generate UUID if not specified
Parsing xen-xm format configuration will fail if UUID is not
specified, e.g.

virsh domxml-from-native xen-xm some-config-without-uuid
error: internal error parsing xm config failed

Initially I thought to skip parsing the UUID in xenParseXM() when
not present in the configuration, but this results in a UUID of
all zeros since it is never set

virsh domxml-from-native xen-xm /tmp/jim/bug-773621_pierre-test
<domain type='xen'>
  <name>test</name>
  <uuid>00000000-0000-0000-0000-000000000000</uuid>
  ...

which certainly can't be correct since this is the UUID the xen
tools use for dom0.

This patch takes the approach of generating a UUID when it is not
specified in the configuration.
2012-08-03 16:16:56 -06:00
Peter Krempa
45edefc7a7 conf: Remove console stream callback only when freeing console helper
Commit ba226d334a tried to fix crash of
the daemon when a domain with an open console was destroyed. The fix was
wrong as it tried to remove the callback also when the stream was
aborted, where at that point the fd stream driver was already freed and
removed.

This patch clears the callbacks with a helper right before the hash is
freed, so that it doesn't interfere with other codepaths where the
stream object is freed.
2012-08-03 23:42:45 +02:00
Peter Krempa
f8ef393ee3 client: Free message when freeing client
The last message of the client was not freed leaking 4 bytes of memory
in the client when the remote daemon crashed while processing a message.
2012-08-03 23:30:01 +02:00
Ata E Husain Bohra
54f9cf803d ESX: Add "Byte" datatype
Append "Byte" to set of predefined datatype objects.

Signed-off-by: Ata E Husain Bohra <ata.husain@hotmail.com>
2012-08-03 20:43:56 +02:00
Eric Blake
41cb804820 parallels: translate error message
Without this patch, the English phrase 'no name' would appear
literally within the remaining translated message.

* src/parallels/parallels_driver.c (parallelsCreateVm)
(parallelsDomainDefineXML): Tweak error message.
2012-08-03 10:25:52 -06:00
Daniel P. Berrange
554612c104 Export virUUIDIsValid to libvirt internal code 2012-08-03 15:35:02 +01:00
Daniel P. Berrange
7de158cf68 Fix typo s/AM_CLFAGS/AM_CFLAGS/ in sanlock link 2012-08-03 15:34:58 +01:00
Peter Krempa
2b01761d5e remote: Fill snapshot argument in remoteDomainSnapshotListAllChildren
The remote driver did not fill the required snapshot parent argument in
the RPC call structure that caused a client crash when trying to use
this new API.
2012-08-03 12:56:15 +02:00
Osier Yang
ed1e711b99 qemu: Allow to attach/detach controller device persistently
* src/conf/domain_conf.c:
  - Add virDomainControllerFind to find controller device by type
    and index.
  - Add virDomainControllerRemove to remove the controller device
    from maintained controler list.

* src/conf/domain_conf.h:
  - Declare the two new helpers.

* src/libvirt_private.syms:
  - Expose private symbols for the two new helpers.

* src/qemu/qemu_driver.c:
  - Support attach/detach controller device persistently

* src/qemu/qemu_hotplug.c:
  - Use the two helpers to simplify the codes.
2012-08-03 12:19:16 +08:00
Hendrik Schwartke
7383c1d762 Added timestamps to storage volumes
The access, birth, modification and change times are added to
storage volumes and corresponding xml representations.  This
shows up in the XML in this format:

<timestamps>
  <atime>1341933637.027319099</atime>
  <mtime>1341933637.027319099</mtime>
</timestamps>

Signed-off-by: Eric Blake <eblake@redhat.com>
2012-08-02 17:14:17 -06:00
Ján Tomko
37a10129c2 Update xml schemas according to libvirt source
capability.rng: Guest features can be in any order.
nodedev.rng: Added <driver> element, <capability> phys_function and
virt_functions for PCI devices.
storagepool.rng: Owner or group ID can be -1.

schema tests: New capabilities and nodedev files; changed owner and
group to -1 in pool-dir.xml.
storage_conf: Print uid_t and gid_t as signed to storage pool XML.
2012-08-02 14:36:23 -06:00
Eric Blake
1f6f723ce1 build: add stubs so mdns code can be unconditionally compiled
The recent changes to the testsuite to validate exported symbols
flushed out a case of unconditionally exporting symbols that
were only conditionally compiled under HAVE_AVAHI.

* src/Makefile.am (libvirt_net_rpc_server_la_SOURCES): Compile
virnetservermdns unconditionally.
* configure.ac (HAVE_AVAHI): Drop unused automake conditional.
* src/rpc/virnetservermdns.c: Add fallbacks when Avahi is not
present.
2012-08-02 13:35:21 -06:00
Michal Privoznik
e94c0a09ee qemu: Fix typo in qemuDomainModifyDeviceFlags
One of our latest commits fbe87126 introduced this nasty typo:
func(vmdef, ...); where func() dereference vmdef->ncontrollers,
and vmdef was initialized to NULL. This leaves us with unconditional
immediate segfault. It should be vm->def instead.
2012-08-02 16:43:57 +02:00
Jiri Denemark
d3084c2a24 build: Rename security manager library
Security manager is not a dynamically loadable driver. Let's avoid the
confusion by renaming libvirt_driver_security library as
libvirt_security_manager.
2012-08-02 16:17:07 +02:00
Jiri Denemark
2f2ca02195 build: Link security manager into libvirt.so
Security manager is not a dynamically loadable driver, it's a common
infrastructure similar to util, conf, cpu, etc. used by individual
drivers. Such code is allowed to be linked into libvirt.so.

This reverts commit ec5b7bd2ec and most of
aae5cfb699.

This patch is supposed to fix virdrivermoduletest failures for qemu and
lxc drivers as well as libvirtd's ability to load qemu and lxc drivers.
2012-08-02 16:17:00 +02:00
Eric Blake
1d170d3f9a build: commit to 0.10.0 release naming
With 0.10.0-rc0 out the door, we are committed to the next version
number.

* src/libvirt_public.syms (LIBVIRT_0.9.14): Rename...
(LIBVIRT_0.10.0): ...to this.
* docs/formatdomain.html.in: Fix fallout.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
2012-08-02 18:55:43 +08:00
Daniel P. Berrange
03be7ab586 Remove unused uuidstr variable from datatypes.c
Several APIs in src/datatypes.c were formatting an UUID to a
uuidstr variable and then not using it.
2012-08-02 11:51:13 +01:00
Daniel P. Berrange
0c9fd4cfe9 Rewrite virAtomic APIs using GLib's atomic ops code
There are a few issues with the current virAtomic APIs

 - They require use of a virAtomicInt struct instead of a plain
   int type
 - Several of the methods do not implement memory barriers
 - The methods do not implement compiler re-ordering barriers
 - There is no Win32 native impl

The GLib library has a nice LGPLv2+ licensed impl of atomic
ops that works with GCC, Win32, or pthreads.h that addresses
all these problems. The main downside to their code is that
the pthreads impl uses a single global mutex, instead of
a per-variable mutex. Given that it does have a Win32 impl
though, we don't expect anyone to seriously use the pthread.h
impl, so this downside is not significant.

* .gitignore: Ignore test case
* configure.ac: Check for which atomic ops impl to use
* src/Makefile.am: Add viratomic.c
* src/nwfilter/nwfilter_dhcpsnoop.c: Switch to new atomic
  ops APIs and plain int datatype
* src/util/viratomic.h: inline impls of all atomic ops
  for GCC, Win32 and pthreads
* src/util/viratomic.c: Global pthreads mutex for atomic
  ops
* tests/viratomictest.c: Test validate to validate safety
  of atomic ops.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-02 11:50:59 +01:00
Daniel P. Berrange
b49890de82 Remove manual one-shot global initializers
Remove the use of a manually run virLogStartup and
virNodeSuspendInitialize methods. Instead make sure they
are automatically run using VIR_ONCE_GLOBAL_INIT

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-08-02 11:50:46 +01:00
Peter Krempa
fbe871263c qemu: Add support for "none" USB controller
This patch enables the "none" USB controller for qemu guests and adds
valdiation on hot-plugged devices if the guest has USB disabled.

This patch also adds a set of tests to check parsing of domain XMLs that
use the "none" controller and some forbidden situations concerning it.
2012-08-02 12:13:48 +02:00
Peter Krempa
317badb213 domain_conf: Add helpers to verify if device configuration is valid
This patch adds helpers that validate domain's device configuration.
This will be needed later on to verify devices being hot-plugged to
guests. If the guest has no USB bus, then it's not valid to plug a USB
device to that guest.
2012-08-02 11:54:50 +02:00
Peter Krempa
0925189713 domain_conf: Add USB controler model "none"
Libvirt adds a USB controller to the guest even if the user does not
specify any in the XML. This is due to back-compat reasons.

To allow disabling USB for a guest this patch adds a new USB controller
type "none" that disables USB support for the guest.
2012-08-02 11:54:14 +02:00
Osier Yang
7ee395a80d Fix indentions
Some of the macros use tab, while the left use spaces, this patch
change it to always use the spaces. And a few aligning fixes.
2012-08-02 15:20:13 +08:00
Guannan Ren
4057048891 storage: netfs and iscsi need option srcSpec for resource discovery
The option 'srcSpec' to virsh command find-storage-pool-sources
is optional for logical type of storage pool, but mandatory for
netfs and iscsi type.
When missing the option for netfs and iscsi, libvirt reports XML
parsing error due to null string option srcSpec.

before
error: Failed to find any netfs pool sources
error: (storage_source_specification):1: Document is empty
(null)

after:
error: pool type 'iscsi' requires option --srcSpec for source discovery
2012-08-02 11:06:02 +08:00
Daniel Veillard
04cd70bfd3 Add missing parallels_utils.h to Makefile.am
Otherwise the file is missing from the dist tarball and distcheck fails
2012-08-01 14:12:09 +08:00
Dmitry Guryanov
7024ddfc09 parallels: implement VM creation
To create a new VM in Parallels Clud Server we should issue
"prlctl create" command, and give path to the directory,
where VM should be created. VM's storage will be in that
directory later. So in this first version find out location
of first VM's hard disk and create VM there.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:49:10 +08:00
Dmitry Guryanov
aa296e6c29 parallels: add storage driver
Parallels Cloud Server has one serious discrepancy with libvirt:
libvirt stores domain configuration files in one place, and storage
files in other places (with the API of storage pools and storage volumes).
Parallels Cloud Server stores all domain data in a single directory,
for example, you may have domain with name fedora-15, which will be
located in '/var/parallels/fedora-15.pvm', and it's hard disk image will be
in '/var/parallels/fedora-15.pvm/harddisk1.hdd'.

I've decided to create storage driver, which produces pseudo-volumes
(xml files with volume description), and they will be 'converted' to
real disk images after attaching to a VM.

So if someone creates VM with one hard disk using virt-manager,
at first virt-manager creates a new volume, and then defines a
domain. We can lookup a volume by path in XML domain definition
and find out location of new domain and size of its hard disk.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:48:01 +08:00
Dmitry Guryanov
e356f6100d parallels: implement virDomainDefineXML operation for existing domains
Add parallelsDomainDefineXML function, it works only for existing
domains for the present.

It's too hard to convert libvirt's XML domain configuration into
Parallel's one, so I've decided to compare virDomainDef structures:
current domain definition and the one created from XML, given to
the function. And change only different parameters.

Currently only name, description, number of cpus, memory amount
and video memory can be changed.

Video device and console added, because libvirt supposes that
VM must always have one video device, if there are some
graphics and one console.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:44:50 +08:00
Dmitry Guryanov
d71145ad07 parallels: add support of VNC remote display
Add support for reading VNC parameters of the VM.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:44:46 +08:00
Dmitry Guryanov
e172cd50ae parallels: get info about serial ports
Add support of collecting information about serial
ports. This change is needed mostly as an example,
support of other devices will be added later.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:44:43 +08:00
Dmitry Guryanov
0740e1bb01 parallels: implement functions for domain life cycle management
Add functions for create/shutdown/destroy and suspend/resume domain.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:44:40 +08:00
Dmitry Guryanov
e93c33a987 parallels: add functions to list domains and get info
Parallels driver is 'stateless', like vmware or openvz drivers.
It collects information about domains during startup using
command-line utility prlctl. VMs in Parallels are identified by UUIDs
or unique names, which can be used as respective fields in
virDomainDef structure. Currently only basic info, like
description, virtual cpus number and memory amount, is implemented.
Querying devices information will be added in the next patches.

Parallels doesn't support non-persistent domains - you can't run
a domain having only disk image, it must always be registered
in system.

Functions for querying domain info have been just copied from
test driver with some changes - they extract needed data from
previously created list of virDomainObj objects.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:44:36 +08:00
Dmitry Guryanov
4033df7ed8 add function virCommandNewVAList
Add function virCommandNewVAList which is equivalent to the
virCommandNewArgList but with va_list instead of a variable number
of arguments.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:44:32 +08:00
Dmitry Guryanov
cafc26ff5f parallels: add driver skeleton
Parallels Cloud Server is a cloud-ready virtualization
solution that allows users to simultaneously run multiple virtual
machines and containers on the same physical server.

More information can be found here: http://www.parallels.com/products/pcs/
Also beta version of Parallels Cloud Server can be downloaded there.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2012-08-01 11:44:26 +08:00
Marc-André Lureau
2beed2daaf qemu: syntax fix
Pushed without ack, under the trivial rule.
2012-07-31 19:51:41 +02:00
Daniel P. Berrange
8c63ff3937 Only perform symbol check against libvirt.so
The 'check-symfile' test case was checking the contents of
libvirt.syms against libvirt.so + all of libvirt_driver_XXX.so
This was in fact bogus - libvirt.syms should only refer to
stuff in libvirt.so, but it had some symbols from the various
driver modules in it too. Now that libvirt.syms has been
fixed, the check-symfile test can be simplified to only
consider libvirt.so
2012-07-31 17:49:41 +01:00
Daniel P. Berrange
aae5cfb699 Don't link nwfilter or secrets driver to libvirt.so
The nwfilter and secrets drivers are both stateful and are already
linked directly to libvirtd. Linking them to libvirt.so is thus
wrong, likewise exporting their symbols in libvirt.so is wrong
2012-07-31 17:49:41 +01:00
Daniel P. Berrange
5830c72e15 Remove bogus libvirt_network.syms file
The network driver is stateful, so it is linked directly to libvirtd,
rather than libvirt.so. Thus there are no network symbols to be exported
in libvirt.so, and libvirt_network.syms can be deleted
2012-07-31 17:49:41 +01:00
Eric Blake
665c8cdecc qemu: fix use after free
Detected by Coverity.

* src/qemu/qemu_hotplug.c (qemuDomainAttachHostDevice): Avoid
double free of usb on failure.
2012-07-31 08:10:59 -06:00
Jiri Denemark
73bc94c56a build: Don't export xenLinuxDomainBlockStats symbol
The symbol is only used within Xen driver.
2012-07-31 11:28:32 +02:00
Eric Blake
6f926c5ef6 build: fix build without HAVE_CAPNG
Otherwise, a build may fail with:

lxc/lxc_conatiner.c: In function 'lxcContainerDropCapabilities':
lxc/lxc_container.c:1662:46: error: unused parameter 'keepReboot' [-Werror=unused-parameter]

* src/lxc/lxc_container.c (lxcContainerDropCapabilities): Mark
parameter unused.
2012-07-30 11:59:25 -06:00
Peter Krempa
ba226d334a conf: Remove callback from stream when freeing entries in console hash
When a domain has a active console connection and is destroyed the
callback is called on private data that no longer exist causing a
segfault.
2012-07-30 15:38:07 +02:00
Peter Krempa
7550bc66f7 conf: Remove dead code from virConsoleOpen() 2012-07-30 15:38:07 +02:00
Daniel P. Berrange
ac97c2ba4c Improve error message in LXC startup with network is not active
If an LXC container is using a virtual network and that network
is not active, currently the user gets a rather unhelpful
error message about tap device setup failure. Add an explicit
check for whether the network is active, in exactly the same
way as the QEMU driver
2012-07-30 13:09:57 +01:00
Daniel P. Berrange
92c5924a05 Remove tabs from all perl files & enforce this
The cfg.mk file rule to check for tab characters was not
applied to perl files. Much of our Perl code is full of
tabs as a result. Kill them, kill them all !
2012-07-30 13:09:57 +01:00
Daniel P. Berrange
cb612ee489 Add handling for reboots of LXC containers
The reboot() syscall is allowed by new kernels for LXC containers.
The LXC controller can detect whether a reboot was requested
(instead of a normal shutdown) by looking at the "init" process
exit status. If a reboot was triggered, the exit status will
record SIGHUP as the kill reason.

The LXC controller has cleared all its capabilities, and the
veth network devices will no longer exist at this time. Thus
it cannot restart the container init process itself. Instead
it emits an event which is picked up by the LXC driver in
libvirtd. This will then re-create the container, using the
same configuration as it was previously running with (ie it
will not activate 'newDef').

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 13:09:56 +01:00
Daniel P. Berrange
b46b1c762a Allow CAP_SYS_REBOOT on new enough kernels
Check whether the reboot() system call is virtualized, and if
it is, then allow the container to keep CAP_SYS_REBOOT.

Based on an original patch by Serge Hallyn

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 13:07:45 +01:00
Daniel P. Berrange
9117fcb263 Run an RPC protocol over the LXC controller monitor
This defines a new RPC protocol to be used between the LXC
controller and the libvirtd LXC driver. There is only a
single RPC message defined thus far, an asynchronous "EXIT"
event that is emitted just before the LXC controller process
exits. This provides the LXC driver with details about how
the container shutdown - normally, or abnormally (crashed),
thus allowing the driver to emit better libvirt events.

Emitting the event in the LXC controller requires a few
little tricks with the RPC service. Simply calling the
virNetServiceClientSendMessage does not work, since this
merely queues the message for asynchronous processing.
In addition the main event loop is no longer running at
the point the event is emitted, so no I/O is processed.

Thus after invoking virNetServiceClientSendMessage it is
necessary to mark the client as being in "delayed close"
mode. Then the event loop is run again, until the client
completes its close - this happens only after the queued
message has been fully transmitted. The final complexity
is that it is not safe to run virNetServerQuit() from the
client close callback, since that is invoked from a
context where the server is locked. Thus a zero-second
timer is used to trigger shutdown of the event loop,
causing the controller to finally exit.

* src/Makefile.am: Add rules for generating RPC protocol
  files and dispatch methods
* src/lxc/lxc_controller.c: Emit an RPC event immediately
  before exiting
* src/lxc/lxc_domain.h: Record the shutdown reason
  given by the controller
* src/lxc/lxc_monitor.c, src/lxc/lxc_monitor.h: Register
  RPC program and event handler. Add callback to let
  driver receive EXIT event.
* src/lxc/lxc_process.c: Use monitor exit event to decide
  what kind of domain event to emit
* src/lxc/lxc_protocol.x: Define wire protocol for LXC
  controller monitor.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 13:07:43 +01:00
Daniel P. Berrange
ca5ab84073 Make RPC code generator a little more flexible
Update the gendispatch.pl script to get a little closer to
being able to generate code for the LXC monitor, by passing
in the struct prefix separately from the procedure prefix.
Also allow method names using virCapitalLetters instead
of vir_underscore_separator

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 12:50:23 +01:00
Daniel P. Berrange
de4b32e4bf Move LXC monitor code out into separate file
Move the code that handles the LXC monitor out of the
lxc_process.c file and into lxc_monitor.{c,h}

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 12:50:22 +01:00
Daniel P. Berrange
357866c379 Convert the LXC driver to use virNetClient
Update the LXC driver to use the virNetClient APIs for
connecting to the libvirt_lxc monitor, instead of the
low-level socket APIs. This is a step towards running
a full RPC protocol with libvirt_lxc

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 12:49:07 +01:00
Daniel P. Berrange
4343fee0a8 Replace use of lxcError with virReportError
Update all LXC code to use virReportError instead of the custom
lxcError macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 12:35:08 +01:00
Daniel P. Berrange
1935471542 Rename lxc_driver_t to virLXCDriver
Rename the lxc_driver_t struct typedef to virLXCDriver to more
closely follow normal libvirt naming conventions

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 12:35:08 +01:00
Daniel P. Berrange
ced272efc5 Rename all APIs in lxc_domain.c to have a virLXCDomain prefix
For consistency all the APIs in the lxc_domain.c file should
have a virLXCDomain prefix in their name

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 12:35:08 +01:00
Daniel P. Berrange
eaf10b84ed Rename all APIs in lxc_process.c to have a virLXCProcess prefix
For consistency all the APIs in the lxc_process.c file should
have a virLXCProcess prefix in their name

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 12:35:08 +01:00
Daniel P. Berrange
b536e193a2 Process all pending I/O for a RPC client before checking EOF
In the socket event handler for the RPC client we must deal
with read/write events, before checking for EOF, otherwise
we might close the socket before we've read & acted upon the
last RPC messages

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 12:35:08 +01:00
Daniel P. Berrange
b1029b6f6f Update remote driver to support the connection close callbacks
Update the remote driver to use the virNetClient close callback
to trigger the virConnectPtr close callbacks

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 10:08:41 +01:00
Daniel P. Berrange
0f7f4b160b Add callback to virNetClient to be invoked on connection close
Allow detection of socket close in virNetClient via a callback
function, triggered on any condition that causes the socket to
be closed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 10:08:41 +01:00
Daniel P. Berrange
e5a1bee07a Ensure client is marked for close in all error paths
Currently if the keepalive timer triggers, the 'markClose'
flag is set on the virNetClient. A controlled shutdown will
then be performed. If an I/O error occurs during read or
write of the connection an error is raised back to the
caller, but the connection isn't marked for close. This
patch ensures that all I/O error scenarios always result
in the connection being marked for close.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 10:08:41 +01:00
Daniel P. Berrange
6ed5a1b9bd Add public API to register a callback to be invoked on connection close
Define new virConnect{Register,Unregister}CloseCallback() public APIs
which allows registering/unregistering a callback to be invoked when
the connection to a hypervisor is closed. The callback is provided
with the reason for the close, which may be 'error', 'eof', 'client'
or 'keepalive'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-30 10:08:40 +01:00
Matthias Bolte
1679353496 esx: Improve error reporting for unknown VI types
Print the actual unknown type name instead of <other> for AnyType objects.
2012-07-29 07:32:25 +02:00
Jiri Denemark
ce53382ba2 security: Skip labeling resources when seclabel defaults to none
If a domain is explicitly configured with <seclabel type="none"/> we
correctly ensure that no labeling will be done by setting
norelabel=true. However, if no seclabel element is present in domain XML
and hypervisor is configured not to confine domains by default, we only
set type to "none" without turning off relabeling. Thus if such a domain
is being started, security driver wants to relabel resources with
default label, which doesn't make any sense.

Moreover, with SELinux security driver, the generated image label lacks
"s0" sensitivity, which causes setfilecon() fail with EINVAL in
enforcing mode.
2012-07-27 18:58:48 +02:00
Eric Blake
3ad13c92a7 maint: avoid regression on copyright listings
Commit f9ce7dad6 tried to kill uses of a raw street address, but
missed a few instances.  Automate things so we don't introduce
new problems in the future.

* cfg.mk (sc_copyright_address): New rule.
(exclude_file_name_regexp--sc_copyright_address): Add exemption.
* bootstrap.conf: Adjust offenders.
* build-aux/augeas-gentest.pl: Likewise.
* examples/systemtap/events.stp: Likewise.
* examples/systemtap/qemu-monitor.stp: Likewise.
* examples/systemtap/rpc-monitor.stp: Likewise.
* src/dtrace2systemtap.pl: Likewise.
* src/esx/esx_vi_generator.py: Likewise.
* src/hyperv/hyperv_wmi_generator.py: Likewise.
* src/remote/qemu_protocol.x: Likewise.
* src/remote/remote_protocol.x: Likewise.
* src/rpc/gensystemtap.pl: Likewise.
* src/rpc/virnetprotocol.x: Likewise.
* tests/object-locking.ml: Likewise.
* tools/virt-xml-validate.in: Likewise.
2012-07-27 07:42:34 -06:00
Osier Yang
a4bcefbcff maint: Use consistent copyright.
This is a follow up patch of commit f9ce7dad6, it modifies all
the files which declare the copyright like "See COPYING.LIB for
the License of this software" to use the detailed/consistent one.

And deserts the outdated comments like:

 * libvirt-qemu.h:
 * Summary: qemu specific interfaces
 * Description: Provides the interfaces of the libvirt library to handle
 *              qemu specific methods
 *
 * Copy:  Copyright (C) 2010, 2012 Red Hat, Inc.

Uses the more compact style like:

 * libvirt-qemu.h: Interfaces specific for QEMU/KVM driver
 *
 * Copyright (C) 2010, 2012 Red Hat, Inc.
2012-07-27 18:27:21 +08:00
Daniel P. Berrange
536a1d7d0a Add a test case that checks there are no bogus entries in .syms
During refactoring of code, it has proved common to forget to
remove old symbols from the .syms file. While the Win32 linker
will complain about this, the Linux ELF linker does not. The
new test case validates that every symbol listed in the .syms
file actually exists in the built ELF libraries.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-27 10:54:38 +01:00
Daniel P. Berrange
25b0988974 Remove accidentally commited virNetClientSetEOFNotify symbol
The virNetClientSetEOFNotify symbol was accidentally added to
the libvirt_private.syms file due to an out-of-order cherry-pick
2012-07-27 10:53:50 +01:00
Daniel P. Berrange
609df0dcde Remove two non-existant NWFilter driver symbols from .syms
virNWFilterGetIpAddrForIfname and virNWFilterDelIpAddrForIfname
do not exist, so remove them from libvirt_nwfilter.syms

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-27 10:53:14 +01:00
Eric Blake
768007aedc maint: don't permit format strings without %
Any time we have a string with no % passed through gettext, a
translator can inject a % to cause a stack overread.  When there
is nothing to format, it's easier to ask for a string that cannot
be used as a formatter, by using a trivial "%s" format instead.

In the past, we have used --disable-nls to catch some of the
offenders, but that doesn't get run very often, and many more
uses have crept in.  Syntax check to the rescue!

The syntax check can catch uses such as
virReportError(code,
               _("split "
                 "string"));
by using a sed script to fold context lines into one pattern
space before checking for a string without %.

This patch is just mechanical insertion of %s; there are probably
several messages touched by this patch where we would be better
off giving the user more information than a fixed string.

* cfg.mk (sc_prohibit_diagnostic_without_format): New rule.
* src/datatypes.c (virUnrefConnect, virGetDomain)
(virUnrefDomain, virGetNetwork, virUnrefNetwork, virGetInterface)
(virUnrefInterface, virGetStoragePool, virUnrefStoragePool)
(virGetStorageVol, virUnrefStorageVol, virGetNodeDevice)
(virGetSecret, virUnrefSecret, virGetNWFilter, virUnrefNWFilter)
(virGetDomainSnapshot, virUnrefDomainSnapshot): Add %s wrapper.
* src/lxc/lxc_driver.c (lxcDomainSetBlkioParameters)
(lxcDomainGetBlkioParameters): Likewise.
* src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML)
(virDomainDiskDefParseXML, virDomainGraphicsDefParseXML):
Likewise.
* src/conf/network_conf.c (virNetworkDNSHostsDefParseXML)
(virNetworkDefParseXML): Likewise.
* src/conf/nwfilter_conf.c (virNWFilterIsValidChainName):
Likewise.
* src/conf/nwfilter_params.c (virNWFilterVarValueCreateSimple)
(virNWFilterVarAccessParse): Likewise.
* src/libvirt.c (virDomainSave, virDomainSaveFlags)
(virDomainRestore, virDomainRestoreFlags)
(virDomainSaveImageGetXMLDesc, virDomainSaveImageDefineXML)
(virDomainCoreDump, virDomainGetXMLDesc)
(virDomainMigrateVersion1, virDomainMigrateVersion2)
(virDomainMigrateVersion3, virDomainMigrate, virDomainMigrate2)
(virStreamSendAll, virStreamRecvAll)
(virDomainSnapshotGetXMLDesc): Likewise.
* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
(virNWFilterDHCPSnoopReq): Likewise.
* src/openvz/openvz_driver.c (openvzUpdateDevice): Likewise.
* src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupCgroup): Likewise.
* src/qemu/qemu_command.c (qemuBuildHubDevStr, qemuBuildChrChardevStr)
(qemuBuildCommandLine): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/rpc/virnetsaslcontext.c (virNetSASLSessionGetIdentity):
Likewise.
* src/rpc/virnetsocket.c (virNetSocketNewConnectUNIX)
(virNetSocketSendFD, virNetSocketRecvFD): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskBuildPool): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemProbe)
(virStorageBackendFileSystemBuild): Likewise.
* src/storage/storage_backend_rbd.c
(virStorageBackendRBDOpenRADOSConn): Likewise.
* src/storage/storage_driver.c (storageVolumeResize): Likewise.
* src/test/test_driver.c (testInterfaceChangeBegin)
(testInterfaceChangeCommit, testInterfaceChangeRollback):
Likewise.
* src/vbox/vbox_tmpl.c (vboxListAllDomains): Likewise.
* src/xenxs/xen_sxpr.c (xenFormatSxprDisk, xenFormatSxpr):
Likewise.
* src/xenxs/xen_xm.c (xenXMConfigGetUUID, xenFormatXMDisk)
(xenFormatXM): Likewise.
2012-07-26 14:32:30 -06:00
Guannan Ren
7aea9b8cf7 util: set minimum value of nodesuspend duration to 60 seconds
Change the permissible minimum value of nodesuspend duration time
to 60 seconds. If option is less than the value, reports error.
Update virsh help and manpage the infomation.
2012-07-26 15:29:03 +08:00
Jiri Denemark
f53904e4b5 conf: Fix typo in virDomainHostdevSubsys comment 2012-07-25 16:31:43 +02:00
Guannan Ren
72e59a3b74 util: Fix typoes on return value and comments
virNetDevTapCreateInBridgePort: Fix return value to -1
virNetDevTapCreate: Fix comments
2012-07-25 18:05:38 +08:00
Martin Kletzander
5eef74320b fixed SegFault in virauth
No check for conn->uri being NULL in virAuthGetConfigFilePath (valid
state) made the client segfault. This happens for example with these
settings:
 - no virtualbox driver installed (modifies conn->uri)
 - no default URI set (VIRSH_DEFAULT_CONNECT_URI="",
   LIBVIRT_DEFAULT_URI="", uri_default="")
 - auth_sock_rw="sasl"
 - virsh run as root

That are unfortunately the settings with fresh Fedora 17 installation
with VDSM.

The check ought to be enough as conn->uri being NULL is valid in later
code and is handled properly.
2012-07-25 10:37:51 +02:00
Daniel P. Berrange
1bfb47dfe6 Make ESX & Hyper-V code generator safe with parallel builds
If from a clean GIT checkout 'make -j 8' is run, the ESX
and Hyper-V code will be generated multiple times over.
This is because there are multiple files being generated
from one invocation of the generator script. make does not
realize this and so invokes the generator once per file.
This doesn't matter with serialized builds, but with
parallel builds multiple instances of the generator get
run at once.

make[2]: Entering directory `/home/berrange/src/virt/libvirt/src'
  GEN    util/virkeymaps.h
  GEN    remote/remote_protocol.h
  GEN    remote/remote_client_bodies.h
  GEN    remote/qemu_protocol.h
  GEN    remote/qemu_client_bodies.h
  GEN    esx/esx_vi_methods.generated.c
  GEN    esx/esx_vi_methods.generated.h
  GEN    esx/esx_vi_methods.generated.macro
  GEN    esx/esx_vi_types.generated.c
  GEN    esx/esx_vi_types.generated.h
  GEN    esx/esx_vi_types.generated.typedef
  GEN    esx/esx_vi_types.generated.typedef
  GEN    esx/esx_vi_types.generated.typeenum
  GEN    esx/esx_vi_types.generated.typetostring
  GEN    esx/esx_vi_types.generated.typefromstring
  GEN    esx/esx_vi_types.generated.h
  GEN    esx/esx_vi_types.generated.c
  GEN    esx/esx_vi_methods.generated.h
  GEN    esx/esx_vi_methods.generated.c
  GEN    esx/esx_vi_methods.generated.macro
  GEN    esx/esx_vi.generated.h
  GEN    esx/esx_vi.generated.c
  GEN    esx/esx_vi_types.generated.typeenum
  GEN    esx/esx_vi_types.generated.typedef
  GEN    esx/esx_vi_types.generated.typeenum
  GEN    esx/esx_vi_types.generated.typetostring
  GEN    esx/esx_vi_types.generated.typefromstring
  GEN    esx/esx_vi_types.generated.h
  GEN    esx/esx_vi_types.generated.c
  GEN    esx/esx_vi_methods.generated.h
  ...snip...
  GEN    hyperv/hyperv_wmi.generated.h
  GEN    libvirt_qemu_probes.h
  GEN    locking/qemu-sanlock.conf
  GEN    hyperv/hyperv_wmi.generated.c
  GEN    rpc/virnetprotocol.h
  GEN    hyperv/hyperv_wmi_classes.generated.typedef
  GEN    hyperv/hyperv_wmi_classes.generated.h
  GEN    hyperv/hyperv_wmi_classes.generated.c
  GEN    rpc/virkeepaliveprotocol.h
  GEN    remote/remote_protocol.c
  GEN    remote/qemu_protocol.c
  GEN    rpc/virkeepaliveprotocol.c
  GEN    rpc/virnetprotocol.c
  GEN    libvirt.def

Prevent this using a timestamp file to control generation,
as was previously done for the python bindings in commit
a7868e0131

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-23 15:49:15 +01:00
Peter Krempa
8e0f7faf56 maint: Clean up coding style and fix error message spelling
This patch cleans up coding style breaks some long lines and fixes error
message spelling on various places in domain_conf.c and in the qemu
driver.
2012-07-23 13:37:56 +02:00
Osier Yang
f9ce7dad60 Desert the FSF address in copyright
Per the FSF address could be changed from time to time, and GNU
recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)

  You should have received a copy of the GNU General Public License
  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

This patch removes the explicit FSF address, and uses above instead
(of course, with inserting 'Lesser' before 'General').

Except a bunch of files for security driver, all others are changed
automatically, the copyright for securify files are not complete,
that's why to do it manually:

  src/security/security_selinux.h
  src/security/security_driver.h
  src/security/security_selinux.c
  src/security/security_apparmor.h
  src/security/security_apparmor.c
  src/security/security_driver.c
2012-07-23 10:50:50 +08:00
Ata E Husain Bohra
04d9cf8e6c ESX: Fix ESX_VI__TEMPLATE__DYNAMIC_DEEP_COPY
Fix addresses two issues:
1. Fix generator code to allow deep copy operation for objects with
   Dynamic_Cast capabilities.
2. Add missing deep copy routine to Long datatype.

Signed-off-by: Ata E Husain Bohra <ata.husain@hotmail.com>
2012-07-21 23:24:25 +02:00
Jean-Baptiste Rouault
d4611c0ee3 vmx: handle shared folders parsing
This patch adds support for parsing vmx files with
shared folders enabled.

Update test suite accordingly.
2012-07-21 20:15:02 +02:00
Jean-Baptiste Rouault
1f2bd1072a vmx: handle shared folders formatting
This patch adds support for generating vmx files with
shared folders enabled.

Update test suite accordingly.
2012-07-21 19:45:02 +02:00
Guido Günther
be7e61a67e openvz: Implement domainGetHostname 2012-07-20 21:54:35 +02:00
Guido Günther
4e8468045c openvz: Add openvzVEGetStringParam
to retrieve a VEs config parameters as a single string. This will be
used by the upcoming domainGetHostname implementation.
2012-07-20 21:54:35 +02:00
Guido Günther
6869b59709 remote: Provide RPC call for domainGetHostname 2012-07-20 21:54:35 +02:00
Guido Günther
a91067fa0d Add virDomainGetHostname
to query a guests's hostname. Containers like LXC and OpenVZ allow to
set a hostname different from the hosts name and QEMU's guest agent
could provide similar functionality.
2012-07-20 21:54:34 +02:00
Daniel P. Berrange
2ef6f69a1b Report 'errno' in int1 field of virErrorPtr
When reporting a system error (VIR_ERR_SYSTEM_ERROR) via
virReportSystemError, we should copy the errno value into
the 'int1' field of the virErrorPtr struct. This allows
callers to detect certain errno conditions & discard the
error

* src/util/virterror.c: Place errno value in int1 field
2012-07-20 20:36:06 +01:00
Daniel P. Berrange
3399875965 Only enforce check for YAJL when starting a VM
The previous check for YAJL would have many undesirable
consequences, the most important being that it caused the
capabilities XML to lose all <guest> elements. There is
no user visible feedback as to what is wrong in this respect,
merely a syslog message. The empty capabilities causes
libvirtd to then throw away all guest XML configs that are
stored.

This changes the code so that the check for YAJL is only
performed at the time we attempt to spawn a QEMU process

error: Failed to start domain vm-vnc
error: unsupported configuration: this qemu binary requires libvirt to be compiled with yajl

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 20:31:46 +01:00
Daniel P. Berrange
a56c347080 Use a hash table for storing MCS labels
Instead of using an O(n) efficiency linked list for storing
MCS labels, use a hash table. Instead of having the list
be global, put it in the SELinux driver private data struct
to ensure uniqueness across different instances of the driver.
This also ensures thread safety when multiple hypervisor
drivers are used in the same libvirtd process

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 20:17:24 +01:00
Daniel P. Berrange
2e668a61d5 Fix error handling when adding MCS labels
When adding MCS labels, OOM was not being handled correctly.
In addition when reserving an existing label, no check was
made to see if it was already reserved

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 20:17:19 +01:00
Daniel P. Berrange
12b187fb95 Use standard naming prefix for SELinux driver function names
The function names in the SELinux driver all start with
SELinux or 'mcs' as a prefix. Sanitize this so that they
all use 'virSecuritySELinux' as the prefix

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 20:17:14 +01:00
Daniel P. Berrange
f8ab364c5f Disable NWFilter driver completely when unprivileged
Running libvirtd unprivileged results in a warning message from
the NWFilter driver

  virNWFilterSnoopLeaseFileRefresh:1882 : open("/var/run/libvirt/network/nwfilter.ltmp"): No such file or directory

Since it requires privileged network access, this driver should
not even run when unprivileged.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 17:32:26 +01:00
Daniel P. Berrange
e48daff7bb Replace use of custom macros with virReportError in the Xen drivers
Update the legacy Xen drivers to use virReportError instead of
the statsError, virXenInotifyError, virXenStoreError,
virXendError, xenUnifiedError, xenXMError custom macros

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 15:10:54 +01:00
Daniel P. Berrange
95218aa49f Make sure xenHypervisorInit correctly reports errors
The xenHypervisorInit method was called from two different
locations, during initial driver registration and also while
opening a Xen connection. The former can't report any useful
errors to the end user/app, so remove it. To ensure thread
safety use a VIR_ONCE_GLOBAL_INIT call to invoke
xenHypervisorInit from the xenHypervisorOpen method.
2012-07-20 15:10:54 +01:00
Daniel P. Berrange
489900e3de Ensure failure to talk to Xen hypervisor is fatal when privileged
As per the comment, the Xen hypervisor driver is considered to
be mandatory when running privileged. When it fails to open,
we should thus return an error, not ignore it.
2012-07-20 15:07:09 +01:00
Daniel P. Berrange
9b13660ee7 Using virOnce for global initialization is desirable since it
ensures that initialization will always take place when it is
needed, and guarantees it only occurs once. The problem is that
the code to setup a global initializer with proper error
propagation is tedious. This introduces VIR_ONCE_GLOBAL_INIT
macro to simplify this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 15:03:39 +01:00
Daniel P. Berrange
c7af2c125e Replace use of VMX_ERROR with virReportError
Update the VMX shared code to use virReportError instead of
the VMX_ERROR custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 14:40:28 +01:00
Daniel P. Berrange
f14993ffb7 Replace use of virNetError with virReportError
Update the libvirtd dispatch code to use virReportError
instead of the virNetError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 14:39:53 +01:00
Daniel P. Berrange
47ab34e232 Replace use of nodeReportError with virReportError
Update the nodeinfo helper code to use virReportError instead
of the nodeReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 14:04:08 +01:00
Daniel P. Berrange
b8605b22e5 Replace use of virSecurityReportError with virReportError
Update the security drivers to use virReportError instead of
the virSecurityReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 13:59:58 +01:00
Daniel P. Berrange
0653554bc5 Replace use of PHYP_ERROR with virReportError
Update the Power-Hypervisor driver to use virReportError
instead of the PHYP_ERROR custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 13:52:20 +01:00
Daniel P. Berrange
d9de122052 Replace use of HYPERV_ERROR with virReportError
Update the Hyper-V driver to use virReportError instead
of the HYPERV_ERROR custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 13:52:06 +01:00
Daniel P. Berrange
cf8cff035c Replace use of ESX_ERROR & ESX_VI_ERROR with virReportError
Update the ESX driver to use virReportError instead of
the ESX_ERROR & ESX_VI_ERROR custom macros

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 13:51:57 +01:00
Daniel P. Berrange
7f4ed3ec99 Replace use of virLockError with virReportError
Update the lock manager drivers to use virReportError instead
of the virLockError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 13:18:49 +01:00
Daniel P. Berrange
3445a3ec2f Replace use of libxlError with virReportError
Update the libxl driver to use virReportError instead of
the libxlError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 13:18:49 +01:00
Jiri Denemark
73a5c94e50 Add missing "%s" format string to constant error messages in lock manager
Updates the lock manager code so that it passes "%s" as the format
string whenever raising an error message with a const string.
2012-07-20 13:18:47 +01:00
Jiri Denemark
d1f8d6edbf Add missing "%s" format string to constant error messages in libxl driver
Updates the libxl driver code so that it passes "%s" as the format
string whenever raising an error message with a const string.
2012-07-20 13:09:07 +01:00
Gao feng
110f08e821 Make the 'lxc_driver' global variable non-static
The 'lxc_driver' global variable is now used from several of
the LXC sources files. Thus it needs to be non-static to
avoid runtime linkage errors

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
2012-07-20 12:47:20 +01:00
Daniel P. Berrange
0e9047ced5 Replace use of streamsReportError with virReportError
Update the streams code to use virReportError instead of
the streamsReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 12:42:53 +01:00
Daniel P. Berrange
4e28b322d4 Replace use of remoteError with virReportError
Update the remote driver to use virReportError instead of
the remoteError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 12:42:03 +01:00
Daniel P. Berrange
76a0ecd2cd Replace use of XENXS_ERROR with virReportError
Update the XenXS shared code to use virReportError instead
of the XENXS_ERROR custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 12:41:52 +01:00
Daniel P. Berrange
29bf82593c Replace use of openvzError with virReportError
Update the OpenVZ driver to use virReportError instead of
the openvzError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-20 12:41:47 +01:00
Daniel P. Berrange
a8483d425e Fix Xen driver to have sensible error messages
The Xen driver had a number of error reports which passed a
constant string without format specifiers and was missing
"%s". Furthermore the errors were related to failing system
calls, but virReportSystemError was not used. So the only
useful piece of info (the errno) was being discarded
2012-07-20 12:40:10 +01:00
Daniel P. Berrange
fdf588a63d Move LXC process management code into separate file
Move all the code that manages stop/start of LXC processes
into separate lxc_process.{c,h} file to make the lxc_driver.c
file smaller

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 16:55:23 +01:00
Daniel P. Berrange
43e532d321 Move cgroup setup code out of lxc_controller.c
Move the cgroup setup code out of the lxc_controller.c file
and into lxc_cgroup.{c,h}. This reduces the size of the
lxc_controller.c file and paves the way to invoke cgroup
setup from lxc_driver.c instead of lxc_controller.c in the
future

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 16:55:00 +01:00
Daniel P. Berrange
f93518c7ef Move LXC domain private data into separate file
Move the LXC driver code related to the virDomainObjPtr
private data into separate lxc_domain.{c,h} files
to reduce the size of lxc_driver.c

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 16:54:54 +01:00
Daniel P. Berrange
cb78198aa6 Replace use of vmwareError with virReportError
Update the VMWare driver to use virReportError instead of
the vmwareError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 16:20:28 +01:00
Daniel P. Berrange
e578bc2683 Replace use of virCPUReportError with virReportError
Update the CPU helper APIs to use virReportError instead
of the virCPUReportError custom macor

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 16:20:01 +01:00
Daniel P. Berrange
3de99600b1 Replace use of testError with virReportError
Update the test driver to use virReportError instead of the
testError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 16:19:51 +01:00
Daniel P. Berrange
51f6e5a6ef Replace use of vboxError with virReportError
Update the VirtualBox driver to use virReportError instead of
the vboxError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 16:19:40 +01:00
Daniel P. Berrange
bd7c36c57e Replace use of xenapiError with virReportError
Update the XenAPI driver to use virReportError instead of
the xenapiError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 14:42:53 +01:00
Daniel P. Berrange
3b7399b5c9 Replace use of qemuReportError with virReportError
Update the QEMU driver to use virReportError instead of
the qemuReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 14:42:28 +01:00
Peter Krempa
4e532f2e3d qemu: Add missing "%s" before translation macros
This patch cleans up some missing "%s" before translation macros,
for strings which are const without format specifiers
2012-07-19 14:41:55 +01:00
Daniel P. Berrange
e2038d2d30 Replace use of umlReportError with virReportError
Update the UML driver to use virReportError instead of the
umlReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 14:41:49 +01:00
Daniel P. Berrange
9093ab7734 Add lots of internal symbols to libvirt_private.syms
Make sure that libvirt_private.syms has all the internal symbols
from APIs in src/rpc/*.h and src/util/cgroup.h, since the LXC
controller/driver will shortly need them

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 10:18:26 +01:00
Daniel P. Berrange
3fc73cd339 Reset the 'quit' flag in virNetServerRun
To allow virNetServerRun/virNetServerQuit to be invoked multiple
times, we must reset the 'quit' flag in virNetServerRun

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 10:18:26 +01:00
Daniel P. Berrange
be873da538 If in delay close mode for an RPC client, don't read further data
In the delayed close mode, we're just waiting for final data to
be written back to the client. While waiting, we should not
bother to read more data from the client.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 10:18:26 +01:00
Daniel P. Berrange
95c2c19f06 Don't autostart domains when reloading config
When sending SIGHUP to libvirtd, it will trigger the virStateDriver
reload operation. This is intended to reload the configuration files
for guests. For unknown historical reasons this is also triggering
autostart of all guests. Autostart is generally expected to be
something that happens on OS startup. Starting VMs on SIGHUP will
violate that expectation and potentially cause dangerous scenarios
if the admin has explicitly shutdown a misbehaving VM that has
been marked as autostart

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 10:18:26 +01:00
Daniel P. Berrange
19f128eef3 Replace use of networkReportError with virReportError
Update the linux bridge driver to use virReportError instead
of the networkReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-19 10:15:38 +01:00
Guannan Ren
5b924be906 rpc: remove trailing whitespace character in error string
Instead of only removing the ending newline character, it is
better to remove all of standard whitespace character for the
sake of log format.

One example that we have to do this is:
After three times incorrect password input, virsh command
virsh -c qemu://remoteserver/system will report error like:

: Connection reset by peerey,gssapi-keyex,gssapi-with-mic,password).

But it should be:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
: Connection reset by peer

The reason is that we dropped the newline, but have a '\r' left.
The terminal interprets it as "move the cursor back to the start
of the current line", so the error string is messed up.
2012-07-19 11:22:52 +08:00
Eric Blake
99f1faf777 po: avoid spurious double spaces in messages
Noticed during the recent error cleanups.

* src/network/bridge_driver.c (networkStartRadvd): Fix spacing.
* src/openvz/openvz_conf.c (openvzReadMemConf): Likewise.
* src/qemu/qemu_command.c (qemuNetworkIfaceConnect): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainDetachNetDevice): Likewise.
* src/qemu/qemu_process.c (qemuProcessStop): Likewise.
* src/security/virt-aa-helper.c (vah_add_file): Likewise.
2012-07-18 17:47:03 -06:00
Eric Blake
68a97bd85f build: fix compilation without struct ifreq
Detected on Cygwin.  Broken in commit 387117ad.

* src/util/virnetdev.c (virNetDevValidateConfig)
(virNetDevReplaceNetConfig): Fix prototypes.
* src/util/virnetlink.c (virNetlinkEventAddClient)
(virNetlinkEventRemoveClient): Likewise.
2012-07-18 17:36:36 -06:00
Matthias Bolte
466b306b39 esx: Fix esxVI_String_Deserialize
It was broken since forever as it expected a libxml2
XML_ELEMENT_NODE containing a XML_TEXT_NODE instead of
just a XML_TEXT_NODE.

This problem was not discovered for so long because
esxVI_String_Deserialize was not used until now.

Reported by Ata Bohra
2012-07-19 01:31:32 +02:00
Eric Blake
03e0ec10b4 nodeinfo: deal with offline cpus in a node
Commit 80533ca forgot to think about offline cpus.  When a node
cpu is offline, then its topology/ subdirectory is not present,
leading to spurious error messages leaked to the user such as:

libvir:  error : cannot open /home/dummy/libvirt/tests/nodeinfodata/linux-nodeinfo-sysfs-test-6/node/node0/cpu7/topology/physical_package_id: No such file or directory

Fix that, as well as test it; the test data is gathered from a
machine with one NUMA node, hyperthreading, and with 2 of the
8 cpus offline.

* src/nodeinfo.c (virNodeParseNode): Don't parse topology of
offline cpus.
* tests/nodeinfotest.c (mymain): Run new test.
* tests/nodeinfodata/linux-nodeinfo-sysfs-test-6*: New data.
2012-07-18 17:11:42 -06:00
Matthias Bolte
675aef9ef6 esx: Extend esxVI_CURL_Download for partial downloads
Also ensure that the virBuffer used to store the downloaded data
does not overflow.
2012-07-18 22:47:11 +02:00
Daniel P. Berrange
4423f3bece Replace use of interfaceReportError with virReportError
Update the netcf driver to use virReportError instead of the
interfaceReportError custom macro
2012-07-18 21:27:30 +01:00
Daniel P. Berrange
fa7ebc174f Replace use of virNWFilterReportError with virReportError
Update the network filter driver to use virReportError instead
of the virNWFilterReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 21:16:25 +01:00
Daniel P. Berrange
6d964bcf66 Add missing "%s" with constant string error message in nwfilter_dhcpsnoop.c
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 21:15:43 +01:00
Dan Walsh
9f5ef4d9b3 lxcContainerMountCGroups also mounts a tmpfs that needs to be labeled.
This patch passes down the sec_mount_options to the
lxcContainerMountCGroups function and then mounts the tmpfs with
the correct label.
2012-07-18 20:52:18 +01:00
Sebastian Wiedenroth
29bc4fe646 Add a sheepdog backend for the storage driver
This patch brings support to manage sheepdog pools and volumes to libvirt.
It uses the "collie" command-line utility that comes with sheepdog for that.

A sheepdog pool in libvirt maps to a sheepdog cluster.
It needs a host and port to connect to, which in most cases
is just going to be the default of localhost on port 7000.

A sheepdog volume in libvirt maps to a sheepdog vdi.
To create one specify the pool, a name and the capacity.
Volumes can also be resized later.

In the volume XML the vdi name has to be put into the <target><path>.
To use the volume as a disk source for virtual machines specify
the vdi name as "name" attribute of the <source>.
The host and port information from the pool are specified inside the host tag.

  <disk type='network'>
    ...
    <source protocol="sheepdog" name="vdi_name">
      <host name="localhost" port="7000"/>
    </source>
  </disk>

To work right this patch parses the output of collie,
so it relies on the raw output option. There recently was a bug which caused
size information to be reported wrong. This is fixed upstream already and
will be in the next release.

Signed-off-by: Sebastian Wiedenroth <wiedi@frubar.net>
2012-07-18 20:08:27 +01:00
Daniel J Walsh
e00184291e Mount all tmpfs filesystems with correct SELinux label
Basically within a Secure Linux Container (virt-sandbox) we want all content
that the process within the container can write to be labeled the same.  We
are labeling the physical disk correctly but when we create "RAM" based file
systems
libvirt is not labeling them, and they are defaulting to tmpfs_t, which will
will not allow the processes to write.  This patch labels the RAM based file
systems correctly.
2012-07-18 19:49:22 +01:00
Daniel P. Berrange
df5232f554 Replace use of virNodeDeviceReportError with virReportError
Update the node device driver to use virReportError instead of
the virNodeDeviceReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 19:34:26 +01:00
Daniel P. Berrange
54e520d3aa Replace use of virSecretReportError with virReportError
Update the secret driver to use virReportError instead of the
virSecretReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 19:34:21 +01:00
Daniel P. Berrange
d8a1c4c49f Replace use of virStorageReportError with virReportError
Update the storage driver to use virReportError instead of
the virStorageReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 19:34:16 +01:00
Daniel P. Berrange
89e23562c9 Add missing "%s" format to const error message in RBD storage driver
When passing a const message string to the error reporting APIs
RBD forgot to use "%s" to avoid GCC format string warnings

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 19:33:03 +01:00
Daniel P. Berrange
1e0bb184a7 Convert all files in src/conf/ to use virReportError()
This removes all the per-file error reporting macros
from the code in src/conf/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 19:01:50 +01:00
Daniel P. Berrange
7c7d01e15f Add missing _(...) around 2 error messages in test driver
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 16:38:54 +01:00
Daniel P. Berrange
db582fa25f Fix parameter passed with VIR_ERR_INVALID_ARG in sanlock driver
The VIR_ERR_INVALID_ARG is typically given the function name
via __FUNCTION__

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 16:37:48 +01:00
Daniel P. Berrange
7c45ad4ba2 Convert all files in src/rpc/ to use virReportError()
This rmoves all the per-file error reporting macros
from the code in src/rpc/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 16:31:40 +01:00
Daniel P. Berrange
f6d4405e3c Convert (nearly) all files in src/util/ to use virReportError()
This removes nearly all the per-file error reporting macros
from the code in src/util/. A few custom macros remain for the
case, where the file needs to report errors with a variety of
different codes or parameters

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 16:31:35 +01:00
Daniel P. Berrange
8a89c08069 Fix bogus cast to (int) in virNetServerMDNSTimeoutNew
The virNetServerMDNSTimeoutNew method was casting a long long
to an int when reporting errors. This should just be using
%lld instead of %d, avoiding the need to cast

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 16:31:31 +01:00
Daniel P. Berrange
605df4f4d9 Add missing "%s" with constant string error message in stats_linux.c
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 16:31:23 +01:00