Commit Graph

416 Commits

Author SHA1 Message Date
Eric Blake
146ba114a5 syntax: prefer space after semicolon in for loop
I noticed several unusual spacings in for loops, and decided to
fix them up.  See the next commit for the syntax check that found
all of these.

* examples/domsuspend/suspend.c (main): Fix spacing.
* python/libvirt-override.c: Likewise.
* src/conf/interface_conf.c: Likewise.
* src/security/virt-aa-helper.c: Likewise.
* src/util/virconf.c: Likewise.
* src/util/virhook.c: Likewise.
* src/util/virlog.c: Likewise.
* src/util/virsocketaddr.c: Likewise.
* src/util/virsysinfo.c: Likewise.
* src/util/viruuid.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* tools/virsh-domain-monitor.c (vshDomainStateToString): Drop
default case, to let compiler check us.
* tools/virsh-domain.c (vshDomainVcpuStateToString): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-28 07:56:07 -06:00
John Ferlan
677981d1be xen: Resolve Coverity FORWARD_NULL issue
Commit '18b14012' refactored the Xen code resulting in a Coverity
warning about possible NULL reference if the path where the XM driver
takes puts the def on it's list.  Moved/duplicated the virGetDomain()
call to pacify the possible NULL deref.
2013-05-23 19:19:21 -04:00
Michal Privoznik
5162a07651 Adapt to VIR_STRDUP and VIR_STRNDUP in src/xen/* 2013-05-23 17:29:49 +02:00
Osier Yang
0c38d36dcf src/xen: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
Daniel P. Berrange
fa9b8b046f Convert Xen domain core dump driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain coredump
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:39 +01:00
Daniel P. Berrange
89d819f285 Convert Xen domain stats/peek driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain stats &
peek APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:39 +01:00
Daniel P. Berrange
f6e95ac0d9 Convert Xen domain scheduler driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain scheduler
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:39 +01:00
Daniel P. Berrange
d305e8691e Convert Xen domain autostart driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain autostart
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:39 +01:00
Daniel P. Berrange
21213a4b13 Convert Xen domain device hotplug driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain hotplug
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:39 +01:00
Daniel P. Berrange
95e18efddd Convert Xen domain VCPU driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain VCPU
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:39 +01:00
Daniel P. Berrange
18b14012e4 Convert Xen domain create/define/getxml/migration APIs to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain create, migrate,
getxml, & define APIs to simplify introduction of ACL security
checks. The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:38 +01:00
Daniel P. Berrange
0a6fc8ab09 Convert Xen domain managed save driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain save
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:38 +01:00
Daniel P. Berrange
249fbea03d Convert Xen domain property driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain property
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:38 +01:00
Daniel P. Berrange
f547c520bf Convert Xen domain lifecycle driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain lifecycle
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:38 +01:00
Daniel P. Berrange
5ed5783bc7 Convert Xen domain lookup driver methods to use virDomainDefPtr
Introduce use of a virDomainDefPtr in the domain lookup
APIs to simplify introduction of ACL security checks.
The virDomainPtr cannot be safely used, since the app
may have supplied mis-matching name/uuid/id fields. eg
the name points to domain X, while the uuid points to
domain Y. Resolving the virDomainPtr to a virDomainDefPtr
ensures a consistent name/uuid/id set.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-21 16:11:38 +01:00
Eric Blake
d7f53c7b97 maint: use LGPL correctly
Several files called out COPYING or COPYING.LIB instead of using
the normal boilerplate.  It's especially important that we don't
call out COPYING from an LGPL file, since COPYING is traditionally
used for the GPL.  A few files were lacking copyright altogether.

* src/rpc/gendispatch.pl: Add missing copyright.
* Makefile.nonreentrant: Likewise.
* src/check-symfile.pl: Likewise.
* src/check-symsorting.pl: Likewise.
* src/driver.h: Likewise.
* src/internal.h: Likewise.
* tools/libvirt-guests.sh.in: Likewise.
* tools/virt-pki-validate.in: Mention copyright in comment, not just code.
* tools/virt-sanlock-cleanup.in: Likewise.
* src/rpc/genprotocol.pl: Spell out license terms.
* src/xen/xend_internal.h: Likewise.
* src/xen/xend_internal.c: Likewise.
* Makefile.am: Likewise.
* daemon/Makefile.am: Likewise.
* docs/Makefile.am: Likewise.
* docs/schemas/Makefile.am: Likewise.
* examples/apparmor/Makefile.am: Likewise.
* examples/domain-events/events-c/Makefile.am: Likewise.
* examples/dominfo/Makefile.am: Likewise.
* examples/domsuspend/Makefile.am: Likewise.
* examples/hellolibvirt/Makefile.am: Likewise.
* examples/openauth/Makefile.am: Likewise.
* examples/python/Makefile.am: Likewise.
* examples/systemtap/Makefile.am: Likewise.
* examples/xml/nwfilter/Makefile.am: Likewise.
* gnulib/lib/Makefile.am: Likewise.
* gnulib/tests/Makefile.am: Likewise.
* include/Makefile.am: Likewise.
* include/libvirt/Makefile.am: Likewise.
* python/Makefile.am: Likewise.
* python/tests/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* tests/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.
* configure.ac: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-20 14:03:48 -06:00
Daniel P. Berrange
7d73b11427 Ignore cast alignment warnings in inotify code for Xen.
The inotify Xen code causes a cast alignment warning, but this
is harmless since the kernel inotify interface will ensure
sufficient alignment of the inotify structs in the buffer being
read

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-14 15:00:22 +01:00
Laine Stump
bfe7721d50 util: move virFile* functions from virutil.c to virfile.c
These all existed before virfile.c was created, and for some reason
weren't moved.

This is mostly straightfoward, although the syntax rule prohibiting
write() had to be changed to have an exception for virfile.c instead
of virutil.c.

This movement pointed out that there is a function called
virBuildPath(), and another almost identical function called
virFileBuildPath(). They really should be a single function, which
I'll take care of as soon as I figure out what the arglist should look
like.
2013-05-10 13:09:30 -04:00
Daniel P. Berrange
eed1de14b5 Simplify the Xen domain stats/peek / node memory driver methods
Make the Xen domain stats / peek and node memory driver
methods unconditionally call the sub-drivers which are
guaranteed to be open.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
7329f91f26 Simplify the Xen domain autostart driver method
Unconditionally call into the XenD or XM drivers for autostart
handling, since they are guaranteed to be open
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
a8f3222a40 Simplify the Xen domain scheduler parameter driver methods
Make the Xen domain scheduler parameter methods directly
call into XenD or Xen hypervisor drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
758aea3098 Simplify the Xen domain attach/dettach driver methods
Make the domain attach/dettach driver methods directly call
into either the XenD or XM drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
6e66100155 Simplify the Xen domain define/undefine driver methods
Make the domain define/undefine driver methods directly call
into either the XenD or XM drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
2fc0660848 Simplify the Xen domain start driver method
Directly call either the XenD or XM driver when starting
a persistent domain

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
f53ffba6aa Simplify the Xen driver define domain driver methods
Directly call either XenD or the XM driver for handling
domain define operations.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
69b8c55714 Simplify the Xen domain migration driver methods
All the migration code is done by the XenD subdriver which
can be assumed to always be present

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
970092dcde Simplify the Xen domain get XML driver method
The xenUnifiedDomainGetXMLDesc driver can assume that
the XM and XenD drivers are always present

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
7c21e500a4 Simplify the Xen domain VCPU driver methods
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
48610ebecc Simplify the Xen domain save/restore driver methods
Unconditionally call the XenD APIs for save/restore, since that
driver will always be open.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
b5961c53d9 Simplify the Xen domain get info/state driver methods
Make the xenUnifiedDomainGetInfo and xenUnifiedDomainGetState drivers
call the correct sub-driver APIs directly.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
7a8029582f Simplify the Xen domain get/set (max) memory driver methods
Simplify the Xen memory limit driver methods to directly call
the most appropriate sub-driver

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:20 +01:00
Daniel P. Berrange
bedfaa58b6 Remove Xen get hostname driver method
The xenGetHostname entry point in the xenUnifiedDriver table
was unused.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
846576eb38 Simplify the Xen domain get OS type driver method
Make xenUnifiedDomainGetOSType directly call either the
xenHypervisorDomainGetOSType or xenDaemonDomainGetOSType
method depending on whether the domain is active or not.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
13c9ef29c0 Simplify the Xen domain destroy driver method
Unconditionally call the xenDaemonDomainDestroyFlags API
since the XenD driver is always available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
6d0d1ecce9 Simplify the Xen domain shutdown/reboot driver methods
Make the xenUnifiedDomainShutdownFlags and xenUnifiedDomainReboot
driver methods unconditionally call the XenD APIs for shutdown
and reboot. Delete the unreachable impls in the XenStore driver.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
0f62113d8a Simplify the Xen domain suspend/resume driver methods
Update xenUnifiedDomainSuspend and xenUnifiedDomainResume to
unconditionally invoke the XenD APIs for suspend/resume. Delete
the impls in the hypervisor driver which was unreachable.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
aead5166a5 Simplify the Xen domain is persistent driver method
Unconditionally call xenDaemonLookupByUUID, since the XenD
driver must always be present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
e920c5b6c9 Simplify the Xen domain lookup driver methods
Unconditionally invoke the xenHypervisorLookupDomainByID,
xenHypervisorLookupDomainByUUID or xenDaemonLookupByName
for looking up domains. Fallback to xenXMDomainLookupByUUID
and xenXMDomainLookupByName for legacy XenD without inactive
domain support

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
0177d11074 Simplify the Xen domain create driver method
Unconditionally call xenDaemonCreateXML in the
xenUnifiedDomainCreateXML driver, since the XenD
driver is always present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
ef3f38bed7 Simplify the Xen count/list domains driver methods
The XenStore driver is mandatory, so it can be used unconditonally
for the xenUnifiedConnectListDomains & xenUnifiedConnectNumOfDomains
drivers. Delete the unused XenD and Hypervisor driver code for
listing / counting domains

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
17f9852734 Simplify the Xen get max vcpus / node get info driver methods
Unconditionally call into xenHypervisorGetMaxVcpus and
xenDaemonNodeGetInfo respectively, since those drivers
are both mandatory

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
dfda6e1161 Simplify the Xen get version driver method
The hypervisor driver is mandatory, so the the call to
xenHypervisorGetVersion must always succeed. Thus there
is no need to ever run xenDaemonGetVersion

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
1cdc465e0e Simplify the Xen get type driver method
There is no point iterating over sub-drivers since the user
would not have a virConnectPtr instance at all if opening
the drivers failed. Just return 'Xen' immediately.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
61b7a872cc Simplify opening of Xen drivers
Since the Xen driver was changed to only execute inside libvirtd,
there is no scenario in which it will be opened from a non-privileged
context. Thus all the code dealing with opening the sub-drivers can
be simplified to assume that they are always privileged.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
71d7b20b3b Remove pointless GET_PRIVATE macro from Xen driver
The Xen driver uses a macro GET_PRIVATE as a supposed shorthand
for 'xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) (conn)->privateData'.
It does not in fact save any lines of code, and obscures what is
happening. Remove it, since it adds no value.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
8b7cb0025b Remove VIR_CONNECT_RO checks from xen drivers
Some of the Xen sub-drivers have checks against the
VIR_CONNECT_RO flag. This is not required, since such
checks are done at the top level before the driver
methods are invoked

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
a855556f88 Remove xen driver checks for priv->handle < 0
The Xen hypervisor driver checks for 'priv->handle < 0' and
returns -1, but without raising any error. Fortunately this
code will never be executed, since the main Xen driver always
checks 'priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]' prior
to invoking any hypervisor API. Just remove the redundant
checks for priv->handle

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-09 13:16:19 +01:00
Daniel P. Berrange
4a044d0256 Separate internal node suspend APIs from public API
The individual hypervisor drivers were directly referencing
APIs in virnodesuspend.c in their virDriverPtr struct. Separate
these methods, so there is always a wrapper in the hypervisor
driver. This allows the unused virConnectPtr args to be removed
from the virnodesuspend.c file. Again this will ensure that
ACL checks will only be performed on invocations that are
directly associated with public API usage.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-08 10:47:47 +01:00
Daniel P. Berrange
1c6d4ca557 Separate internal node device APIs from public API
The individual hypervisor drivers were directly referencing
APIs in src/nodeinfo.c in their virDriverPtr struct. Separate
these methods, so there is always a wrapper in the hypervisor
driver. This allows the unused virConnectPtr args to be
removed from the nodeinfo.c file. Again this will ensure that
ACL checks will only be performed on invocations that are
directly associated with public API usage.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-08 10:47:47 +01:00
Daniel P. Berrange
ead630319d Separate virGetHostname() API contract from driver APIs
Currently the virGetHostname() API has a bogus virConnectPtr
parameter. This is because virtualization drivers directly
reference this API in their virDriverPtr tables, tieing its
API design to the public virConnectGetHostname API design.

This also causes problems for access control checks since
these must only be done for invocations from the public
API, not internal invocation.

Remove the bogus virConnectPtr parameter, and make each
hypervisor driver provide a dedicated function for the
driver API impl. This will allow access control checks
to be easily inserted later.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-08 10:47:47 +01:00