Commit Graph

7478 Commits

Author SHA1 Message Date
Jim Fehlig
41828514bb Skip some xen tests if xend is not running
Currently, the xen statstest and reconnect tests are only compiled
if xend is running.  Compile them unconditionally if xen headers
are present, but skip the tests at runtime if xend is not running.

This is in response to Eric's suggestion here

https://www.redhat.com/archives/libvir-list/2011-July/msg00367.html
2011-07-07 17:23:09 -06:00
Eric Blake
17da0669e0 util: drop unused safezero argument
No caller was using the flags argument, and this function is internal
only, so we might as well skip it.

* src/util/util.h (safezero): Update signature.
* src/util/util.c (safezero): Update function.
* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockSetupLockspace)
(virLockManagerSanlockCreateLease): Update all callers.
* src/storage/storage_backend.c (createRawFile): Likewise.
2011-07-07 14:15:38 -06:00
Eric Blake
7931639b7a conf: prefer unsigned int for flags
* src/conf/domain_conf.c (virDomainGraphicsDefParseXML)
(virDomainDeviceInfoFormat, virDomainDeviceInfoParseXML)
(virDomainDiskDefParseXML, virDomainControllerDefParseXML)
(virDomainFSDefParseXML, virDomainNetDefParseXML)
(virDomainChrDefParseTargetXML, virDomainChrDefParseXML)
(virDomainSmartcardDefParseXML, virDomainInputDefParseXML)
(virDomainTimerDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainMemballoonDefParseXML)
(virDomainVideoDefParseXML)
(virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevDefParseXML, virSecurityLabelDefParseXML)
(virDomainVcpuPinDefParseXML, virDomainDefParseXML)
(virDomainDefParse, virDomainDiskDefFormat)
(virDomainControllerDefFormat, virDomainFSDefFormat)
(virDomainNetDefFormat, virDomainChrSourceDefFormat)
(virDomainChrDefFormat, virDomainSmartcardDefFormat)
(virDomainSoundDefFormat, virDomainMemballoonDefFormat)
(virDomainWatchdogDefFormat, virDomainVideoDefFormat)
(virDomainInputDefFormat, virDomainGraphicsDefFormat)
(virDomainHostdevDefFormat, virDomainObjFormat): Switch signature.
(virDomainObjTaint, virDomainSaveStatus): Use unsigned flags.
2011-07-07 14:15:38 -06:00
Eric Blake
1740c38116 drivers: prefer unsigned int for flags
Now that the public APIs always use unsigned flags, the internal
driver callbacks might as well do likewise.

* src/driver.h (vrDrvOpen, virDrvDomainCoreDump)
(virDrvDomainGetXMLDesc, virDrvNetworkGetXMLDesc)
(virDrvNWFilterGetXMLDesc): Update type.
* src/remote/remote_protocol.x (remote_open_args)
(remote_domain_core_dump_args, remote_domain_get_xml_desc_args)
(remote_network_get_xml_desc_args)
(remote_nwfilter_get_xml_desc_args): Likewise.
* src/test/test_driver.c: Update clients.
* src/remote/remote_driver.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* src/xen/xen_hypervisor.h: Likewise.
* src/xen/xen_driver.c: Likewise.
* src/xen/xend_internal.c: Likewise.
* src/xen/xend_internal.h: Likewise.
* src/xen/xm_internal.c: Likewise.
* src/xen/xm_internal.h: Likewise.
* src/xen/xs_internal.c: Likewise.
* src/xen/xs_internal.h: Likewise.
* src/xen/xen_inotify.c: Likewise.
* src/xen/xen_inotify.h: Likewise.
* src/phyp/phyp_driver.c: Likewise.
* src/openvz/openvz_driver.c: Likewise.
* src/vmware/vmware_driver.c: Likewise.
* src/vbox/vbox_driver.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xenapi/xenapi_driver.c: Likewise.
* src/esx/esx_driver.c: Likewise.
* src/esx/esx_interface_driver.c: Likewise.
* src/esx/esx_network_driver.c: Likewise.
* src/esx/esx_storage_driver.c: Likewise.
* src/esx/esx_device_monitor.c: Likewise.
* src/esx/esx_secret_driver.c: Likewise.
* src/esx/esx_nwfilter_driver.c: Likewise.
* src/interface/netcf_driver.c: Likewise.
* src/nwfilter/nwfilter_driver.c: Likewise.
* src/libxl/libxl_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/secret/secret_driver.c: Likewise.
* src/storage/storage_driver.c: Likewise.
* src/node_device/node_device_hal.c: Likewise.
* src/node_device/node_device_udev.c: Likewise.
* src/remote_protocol-structs: Likewise.
2011-07-07 14:15:37 -06:00
Eric Blake
18d561c7a4 public API: prefer unsigned int for flags
Most APIs use 'unsigned int flags'; but a few stragglers were using
a signed value.  In particular, the vir*GetXMLDesc APIs were
split-brain, with inconsistent choice of types.  Although it is
an API break to use 'int' instead of 'unsigned int', it is ABI
compatible (pre-compiled apps will have no difference in behavior),
and generally apps can be recompiled without any issue (only rare
apps that compiled with extremely high warning levels, or which
pass libvirt API around as typed function pointers, would have to
make any code changes to deal with the change).

The migrate APIs use 'unsigned long flags', which can't be changed,
due to ABI constraints.

This patch intentionally touches only the public API, to prove the
claim that most existing code (including driver callbacks and virsh)
still compiles just fine in spite of the type change.

* include/libvirt/libvirt.h.in (virConnectOpenAuth)
(virDomainCoreDump, virDomainGetXMLDesc, virNetworkGetXMLDesc)
(virNWFilterGetXMLDesc): Use unsigned int for flags.
(virDomainHasCurrentSnapshot): Use consistent spelling.
* src/libvirt.c (virConnectOpenAuth, virDomainCoreDump)
(virDomainGetXMLDesc, virNetworkGetXMLDesc)
(virNWFilterGetXMLDesc, do_open): Update accordingly.
2011-07-07 14:15:32 -06:00
Eric Blake
313ac7fd39 maint: print flags in hex during debug
Debugging decimal flags is a pain.

* src/libvirt.c: Always print flags in hex.
2011-07-07 13:12:50 -06:00
Eric Blake
085d241531 virsh: make destroy sound less scary
Destroy has a rather negative English connotation.  Try to reduce
the impact, so newbies aren't as scared to use it.

* tools/virsh.c: Tweak all destroy documentation.
* tools/virsh.pod: Likewise.
2011-07-07 13:12:50 -06:00
Eric Blake
8437e738fa build: use gnulib pthread_sigmask
Gnulib finally learned how to do pthread_sigmask on mingw.

* .gnulib: Update to latest, for pthread_sigmask.
* bootstrap.conf (gnulib_modules): Add pthread_sigmask.
* configure.ac (AC_CHECK_FUNCS): Drop redundant check.
* src/rpc/virnetclient.c (virNetClientSetTLSSession)
(virNetClientIOEventLoop): Make code unconditional.
* src/util/command.c (virFork): Likewise.
* tools/virsh.c (doMigrate, cmdMigrate): Likewise.
2011-07-07 13:12:44 -06:00
Eric Blake
c2dda6ebb3 build: fix virBufferVasprintf on mingw
Gnulib documents that mingw vsnprintf is broken (it returns -1
on out-of-space, instead of the count of what would have been
printed); but while we were using the snprintf wrapper, we had
not yet been using the vsnprintf wrapper.

Meanwhile, mingw (but not mingw64) has a replacement snprintf
that fixes return values, but still lacks %1$s support; so in
that case, gnulib didn't replace snprintf, but libintl then
went ahead and installed a version that supported %1$s but not
return values.  Gnulib has since been fixed to guarantee that
the snprintf module will always guarantee the constraints needed
by libintl.

Also, we want to guarantee that strdup sets errno on failure.

* .gnulib: Update to latest, for vsnprintf fix.
* bootstrap.conf (gnulib_modules): Add vsnprintf, strdup-posix.
Reported by Matthias Bolte.
2011-07-07 12:34:19 -06:00
Jim Fehlig
a34e193fb7 Fix compilation of statstest.c during make check 2011-07-07 10:15:05 -06:00
Matthias Bolte
94538e14e2 python: Fix bogus label placement 2011-07-07 13:24:22 +02:00
Laine Stump
24442b60b9 util: close the ioctl socket at the end of if(Get|Set)MacAddress
Otherwise this will leak an fd each time one of these functions is
called.
2011-07-06 20:16:51 -04:00
Laine Stump
de796a328d util: rename err_exit to cleanup in interface.c
This brings it in line with the recommendations in HACKING.
2011-07-06 20:16:51 -04:00
Minoru Usui
107ee906ff sysinfo: delete unnecessary white space of sysinfo.
* Trim each element and delete null entry of sysinfo by
  virSkipSpacesBackwards().

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
2011-07-06 15:19:28 -06:00
Eric Blake
01374ec8b1 util: add virTrimSpaces
The next patch wants to adjust an end pointer to trim trailing
spaces but without modifying the underlying string, but a more
generally useful ability to trim trailing spaces in place is
also worth providing.

* src/util/util.h (virTrimSpaces, virSkipSpacesBackwards): New
prototypes.
* src/util/util.c (virTrimSpaces, virSkipSpacesBackwards): New
functions.
* src/libvirt_private.syms (util.h): Export new functions.
Inspired by a patch by Minoru Usui.
2011-07-06 15:17:14 -06:00
Eric Blake
82162316b6 util: fix virSkipSpaces
Most clients of virSkipSpaces don't want to omit backslashes.
Also, open-coding the list of spaces is not as nice as using
c_isspace.

* src/util/util.c (virSkipSpaces): Use c_isspace.
(virSkipSpacesAndBackslash): New function.
* src/util/util.h (virSkipSpacesAndBackslash): New prototype.
* src/xen/xend_internal.c (sexpr_to_xend_topology): Update caller.
* src/libvirt_private.syms (util.h): Export new function.
2011-07-06 14:52:43 -06:00
Eric Blake
864e9457ca docs: minor whitespace cleanups
No change in wording.  One spacing change in a <pre>, noticed because
of odd XML formatting online; the rest is in free-flowing text to
make it easier to see nesting levels in the document.

* docs/formatdomain.html.in: Adjust spacing.  Break long lines.
2011-07-06 14:48:51 -06:00
Matthias Bolte
cd9a4232e5 Reduce code duplication in virFileMakePath(Helper)
Move stat and mkdir to virFileMakePathHelper.

Also use the stat result to detect whether the existing path
is a directory and set errno accordingly if it's not.
2011-07-06 16:03:12 +02:00
Matthias Bolte
2d2d6a01d7 apparmor: Finish incomplete renaming of relabel to norelabel
Commit 693eac388f was incomplete here.
2011-07-06 14:15:05 +02:00
Daniel P. Berrange
693eac388f Fix default value of security label 'relabel' attribute
When no <seclabel> is present in the XML, the virDomainSeclabelDef
struct is left as all zeros. Unfortunately, this means it gets setup
as type=dynamic, with relabel=no, which is an illegal combination.

Change the 'bool relabel' attribute in virDomainSeclabelDef to
the inverse 'bool norelabel' so that the default initialization
is sensible

* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/security/security_apparmor.c, src/security/security_selinux.c:
  Replace 'relabel' with 'norelabel'
2011-07-06 12:45:09 +01:00
Matthias Bolte
e123e1ee6b Fix return value semantic of virFileMakePath
Some callers expected virFileMakePath to set errno, some expected
it to return an errno value. Unify this to return 0 on success and
-1 on error. Set errno to report detailed error information.

Also optimize virFileMakePath if stat fails with an errno different
from ENOENT.
2011-07-06 09:27:06 +02:00
Matthias Bolte
c7694e3e50 nodedev: Let check_fc_host_linux report errors to the caller 2011-07-06 08:51:11 +02:00
Jean-Baptiste Rouault
11bd53e322 Fix compilation error when SASL support is disabled
This patch adds #if HAVE_SASL where needed in libvirtd.h
2011-07-06 08:41:17 +02:00
Guannan Ren
416814e66a pci: initialize state values on reattach
add a new API pciDeviceReAttachInit() in pci.c to initialize state values for nodedev reattach

Initialize three state value of device driver to 1. This is just for a new call to
qemudNodeDeviceReAttach()
2011-07-05 11:42:38 -06:00
Laine Stump
0c97dc4159 xml: create an RNG file for common types and move some definitions there
domain.rng, network.rng, and interface.rng already use a few of the
same types (or in some cases *should* but don't), and an upcoming code
change will have them sharing even more. To prepare for that, this
patch takes those common data type definitions and moves them into
basictypes.rng.

This may break some rule about the need to RNG files to be autonomous
or something, but I saw that storageencryption.rng is used in this
way, so I figured it must not be completely against the law...
2011-07-05 12:33:21 -04:00
Laine Stump
b2bf813e58 docs: sort the file list in the schemas Makefile 2011-07-05 12:33:21 -04:00
Laine Stump
834ce603f9 qemu: check flags in qemuDomainGetXMLDesc
Although most functions with flags check to verify no application is
passing in flag bits that are currently undefined, for some reason
this function wasn't.
2011-07-05 12:33:21 -04:00
Laine Stump
d3f7c7b151 conf: fix domain parse flags
* Change all flags args from int to unsigned int

* Allow passing flags in virDomainObjParseFile (and propogate those
  flags all the way down the call chain). Previously the flags were
  hardcoded (to VIR_DOMAIN_XML_INTERNAL_STATUS) several layers down
  the chain. Pass that value in at the one place that is currently
  calling virDomainObjParseFile.
2011-07-05 12:33:21 -04:00
Matthias Bolte
3ab1776b7f tests: Disable networkxml2argvtest when configured without network
Reported by Ruben Kerkhof.
2011-07-05 15:26:18 +02:00
Matthias Bolte
4a03db81cd qemu: Fix virFileMakePath error handling in snapshot creation
virFileMakePath returns an errno value on error, that will never
be negative. An virFileMakePath error would have been ignored here,
instead of being reported correctly.
2011-07-05 10:49:36 +02:00
Matthias Bolte
4a6d4d4285 conf: Fix declaration of virNetworkDNS(Hosts)Def struct
The struct A {} A; construct triggers a linker error on OSX about
duplicate symbols. This also differs from the common struct style.

Switch to common style to fix this.

Reported by Justin Clift.
2011-07-05 10:40:27 +02:00
Daniel P. Berrange
6bcd732ead Add documentation for the seclabel XML element
The domain XML documentation is missing information about the
<seclabel> element used by security drivers

* formatdomain.html.in: Document <seclabel>
2011-07-04 11:19:20 +01:00
Daniel P. Berrange
6321fd9798 Allow for resource relabelling with static labels
Add a new attribute to the <seclabel> XML to allow resource
relabelling to be enabled with static label usage.

  <seclabel model='selinux' type='static' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c392,c662</label>
  </seclabel>

* docs/schemas/domain.rng: Add relabel attribute
* src/conf/domain_conf.c, src/conf/domain_conf.h: Parse
  the 'relabel' attribute
* src/qemu/qemu_process.c: Unconditionally clear out the
  'imagelabel' attribute
* src/security/security_apparmor.c: Skip based on 'relabel'
  attribute instead of label type
* src/security/security_selinux.c: Skip based on 'relabel'
  attribute instead of label type and fill in <imagelabel>
  attribute if relabel is enabled.
2011-07-04 11:18:57 +01:00
Daniel P. Berrange
4ebfc42716 Allow a base label to be specified in dynamic labelling mode
Normally the dynamic labelling mode will always use a base
label of 'svirt_t' for VMs. Introduce a <baselabel> field
in the <seclabel> XML to allow this base label to be changed

eg

   <seclabel type='dynamic' model='selinux'>
     <baselabel>system_u:object_r:virt_t:s0</baselabel>
   </seclabel>

* docs/schemas/domain.rng: Add <baselabel>
* src/conf/domain_conf.c, src/conf/domain_conf.h: Parsing
  of base label
* src/qemu/qemu_process.c: Don't reset 'model' attribute if
  a base label is specified
* src/security/security_apparmor.c: Refuse to support base label
* src/security/security_selinux.c: Use 'baselabel' when generating
  label, if available
2011-07-04 11:17:19 +01:00
Osier Yang
49826eda7a storage: Do not override the exact error of createRawFile
virStorageBackendCreateRaw: createRawFile already reported the
exact error.

Before the fix:

error: Failed to create vol vol-create.img
error: cannot create path '/var/lib/libvirt/images/vol-create.img': Unknown error 18446744073709551597

After the fix:

error: Failed to create vol vol-create.img
error: cannot fill file '/var/lib/libvirt/images/vol-create.img': No space left on device
2011-07-04 16:13:23 +08:00
Daniel Veillard
7976d96dd7 Release of libvirt-0.9.3
* configure.ac docs/news.html.in libvirt.spec.in: update for the
  new release
* po/*.po*: updated and regenerated localizations
2011-07-04 15:54:36 +08:00
Wen Congyang
1aa5f85bb8 initialize pointer to NULL
cmd is not initialized to NULL, but we try to freed it if we
meet some error.
2011-07-04 14:00:28 +08:00
Eric Blake
5dc404b71d storage: avoid crash on parse error
Coverity detected that we could crash on bogus input.  Meanwhile,
strtok_r is rather heavy compared to strchr.

* src/storage/storage_backend_iscsi.c (virStorageBackendIQNFound):
  Check for parse failure, and use lighter-weight functions.
2011-07-04 10:41:38 +08:00
Eric Blake
222f6233b4 vmware: avoid null deref on failed lookup
* src/vmware/vmware_driver.c (vmwareDomainReboot): Check error
  before dereferencing memory.
2011-07-04 10:32:22 +08:00
Eric Blake
74d224fac3 qemu: avoid null deref on low memory
Detected by Coverity.  qemuDomainEventQueue requires a non-NULL
pointer; most callers silently drop the event if we encountered
and OOM situation trying to create the event.

* src/qemu/qemu_migration.c (qemuMigrationFinish): Check for OOM.
2011-07-04 10:30:43 +08:00
Eric Blake
3f81f8e4c1 cgroup: silence coverity warning
Coverity noted that most clients reacted to failure to hash; but in
a best-effort kill loop, we can ignore failure.

* src/util/cgroup.c (virCgroupKillInternal): Ignore hash failure.
2011-07-04 10:28:27 +08:00
Eric Blake
dd0c42abd4 rpc: silence coverity warning
Coverity noted that 4 out of 5 calls to virNetClientStreamRaiseError
checked the return value.  This case expects a particular value, so
warn if our expectations went wrong due to some bug elsewhere.

* src/rpc/virnetclient.c (virNetClientCallDispatchStream): Warn on
  unexpected scenario.
2011-07-04 10:26:05 +08:00
Eric Blake
aaea56dc99 qemu: silence coverity warnings
Coverity warns if the majority of callers check a function for
errors, but a few don't; but in qemu_audit and qemu_domain, the
choice to not check for failures was safe.  In qemu_command, the
failure to generate a uuid can only occur on a bad pointer.

* src/qemu/qemu_audit.c (qemuAuditCgroup): Ignore failure to get
  cgroup controller.
* src/qemu/qemu_domain.c (qemuDomainObjEnterMonitor)
  (qemuDomainObjEnterMonitorWithDriver): Ignore failure to get
  timestamp.
* src/qemu/qemu_command.c (qemuParseCommandLine): Check for error.
2011-07-04 10:23:46 +08:00
Eric Blake
6e07f72ee5 rpc: avoid memory leak on error
Detected by Coverity.  The leak is on an error path, but I'm not
sure whether that path is likely to be triggered in practice.

* src/rpc/virnetserverservice.c (virNetServerServiceAccept): Plug leak.
2011-07-04 10:22:50 +08:00
Eric Blake
2aa83b43d3 rpc: fix logic bug
Spotted by Coverity.  If we don't update tmp each time through
the loop, then if the filter being removed was not the head of
the list, we accidentally lose all filters prior to the one we
wanted to remove.

* src/rpc/virnetserverclient.c (virNetServerClientRemoveFilter):
    Don't lose unrelated filters.
2011-07-04 09:45:21 +08:00
Eric Blake
95eaf7ba7f pci: avoid memory leak on error
Detected by Coverity.  Some, but not all, error paths were clean;
but they were repetitive so I refactored them.

* src/util/pci.c (pciGetDevice): Plug leak.
2011-07-01 16:46:20 -06:00
Eric Blake
9e8b7c1523 interface: avoid memory leak on parse error
Detected by Coverity.  Unlikely to hit unless the file contents
were corrupted.

* src/util/interface.c (ifaceRestoreMacAddress): Plug leak.
2011-07-01 16:46:20 -06:00
Eric Blake
e07e9a9456 libvirtd: avoid memory leak on OOM
Detected by Coverity; only strikes on OOM so not serious.

* daemon/libvirtd.c (daemonPidFilePath): Plug leak.
2011-07-01 16:46:20 -06:00
Eric Blake
5d382c57a1 build: avoid 'make syntax-check' failure
* tests/utiltest.c (DO_TEST): Fix indentation for cppi.
2011-07-01 16:46:20 -06:00
Matthias Bolte
ab0b2c1996 tests: Add a general util test
Move non-esx specific tests from esxutilstest there and add a
test for virParseVersionString.
2011-07-01 19:58:15 +02:00