Commit Graph

3571 Commits

Author SHA1 Message Date
Daniel P. Berrange
33a198c1f6 Initialize gcrypt threading
GNUTLS uses gcrypt for its crypto functions. gcrypt requires
that the app/library initializes threading before using it.
We don't want to force apps using libvirt to know about
gcrypt, so we make virInitialize init threading on their
behalf. This location also ensures libvirtd has initialized
it correctly. This initialization is required even if libvirt
itself were only using one thread, since another non-libvirt
library (eg GTK-VNC) could also be using gcrypt from another
thread

* src/libvirt.c: Register thread functions for gcrypt
* configure.in: Add -lgcrypt to linker flags
2009-12-17 18:22:09 +00:00
Daniel P. Berrange
84961bd3f4 Fix bug in storage driver accessing wrong private data
* src/storage/storage_driver.c: Fix IsPersistent() and IsActivE()
  methods on storage pools to use 'storagePrivateData' instead
  of 'privateData'. Also fix naming convention of objects
2009-12-17 16:51:30 +00:00
Jim Meyering
de3e38a65e esx_vi.c: do not call through NULL function pointer
* src/esx/esx_vi.c (esxVI_List_CastFromAnyType): For invalid
inputs, fail right away.  Do not "goto failure" where a NULL
input pointer would be dereferenced.
2009-12-16 13:39:15 +01:00
Jim Meyering
fa479727ff esx_util.c: avoid NULL deref for invalid inputs
* src/esx/esx_util.c (esxUtil_ParseDatastoreRelatedPath): Return
right away for invalid inputs, rather than using them (which would
dereference NULL pointers) in clean-up code.
2009-12-16 13:39:15 +01:00
Matthias Bolte
576b2c7514 esx: Don't goto failure for invalid arguments in VMX code
This also fixes a NULL-deref of virtualDev in esxVMX_ParseSCSIController
found by Jim Meyering.
2009-12-15 23:49:56 +01:00
Matthias Bolte
2b844f1614 Fix memory leak in qemudBuildCommandLine 2009-12-15 22:53:45 +01:00
Jim Meyering
2e5efc3d6e avoid calling exit with a constant; use EXIT_* instead
This appeases a new gnulib-provided "syntax-check".
* daemon/libvirtd.c (main): Use EXIT_FAILURE, not 1.
* proxy/libvirt_proxy.c (main): Likewise, and EXIT_SUCCESS, not 0.
* tests/conftest.c (main): Likewise.
* tests/reconnect.c (main): Likewise.
* tests/testutils.h (EXIT_AM_SKIP): Define.
* tests/nodeinfotest.c (mymain): Use EXIT_AM_SKIP, not 77.
* tests/qemuargv2xmltest.c: Likewise.
* tests/qemuxml2xmltest.c: Likewise.
* tests/virshtest.c (mymain): Likewise.
2009-12-15 17:46:04 +01:00
Jim Meyering
e7c8ab8f0e maint: remove from VC two gnulib-provided files
* build-aux/link-warning.h: Remove file from version control.
* build-aux/mktempd: Likewise.
* build-aux/.gitignore: Adjust.
2009-12-15 17:46:04 +01:00
Jim Meyering
5baa463541 avoid malfunction when virFileResolveLink is applied to non-POSIX FS
The virFileResolveLink utility function relied on the POSIX guarantee
that stat.st_size of a symlink is the length of the value.  However,
on some types of file systems, it is invalid, so do not rely on it.
Use gnulib's areadlink module instead.
* bootstrap (modules): Add areadlink.
* src/util/util.c: Include "areadlink.h".
Let areadlink perform the readlink and malloc.
* configure.in (AC_CHECK_FUNCS): Remove readlink.  No need,
since it's presence is guaranteed by gnulib.
2009-12-15 17:46:04 +01:00
Jim Meyering
f3cbd24ddc build: update gnulib submodule to latest 2009-12-15 17:46:04 +01:00
Jim Meyering
11f6cc3279 xm_internal.c: remove misleading dead code
* src/xen/xm_internal.c (xenXMConfigGetULong): Remove useless and
misleading test (always false) for val->str == NULL before code that
always dereferences val->str.  "val" comes from virConfGetValue, and
at that point, val->str is guaranteed to be non-NULL.
(xenXMConfigGetBool): Likewise.
* src/util/conf.c (virConfSetValue): Ensure that vir->str is never NULL,
not even if someone tries to set such a value via virConfSetValue.
2009-12-15 17:46:04 +01:00
Jim Meyering
d37bca86d0 libvirt.c: don't let a NULL "cpumaps" argument provoke a NULL-deref
* src/libvirt.c (virDomainGetVcpus): Describe new, stronger
requirement on "maplen"s relationship to "cpumaps".
2009-12-15 17:44:15 +01:00
Jim Meyering
643ee3fa44 qemu migration: avoid NULL-deref given an invalid input
* src/qemu/qemu_driver.c (doNonTunnelMigrate): Don't let a
NULL "uri_out" provoke a NULL-dereference in doNativeMigrate:
supply omitted goto-after-qemudReportError.
2009-12-15 11:26:24 +01:00
Jim Meyering
1428704d2a qemu_driver.c: don't unlink(NULL) on OOM error path
* src/qemu/qemu_driver.c (qemudDomainMigratePrepareTunnel): Upon an
out of memory error, we would end up with unixfile==NULL and attempt
to unlink(NULL).  Skip the unlink when it's NULL.
2009-12-15 11:26:24 +01:00
Jim Meyering
49226d2ce4 remote_driver.c: also zero out ->saslDecodedOffset member
* src/remote/remote_driver.c (remoteIOReadMessage): ...rather than
zeroing out priv->saslDecodedLength twice.
2009-12-15 11:26:24 +01:00
Jim Meyering
dd16045041 qemu_driver.c: avoid double free on error path
* src/qemu/qemu_driver.c (qemudDomainMigrateFinish2): Set
"event" to NULL after qemuDomainEventQueue frees it, so a
subsequent free (after endjob label) upon qemuMonitorStartCPUs
failure does not cause a double free.
2009-12-15 07:53:44 +01:00
Jim Meyering
63a499d3f3 libvirtd: avoid a NULL dereference on error path
* daemon/libvirtd.c (qemudDispatchServer): Since "client" may be
NULL in the "cleanup:" block, free client->rx only when it's not.
2009-12-15 07:53:27 +01:00
Matthias Bolte
52a18abd94 Fix and improve domain xml video element description
The description mismatched the actual structure since the video element
was introduced. The nvram attribute is actually called vram. Specify the
unit of the vram attribute.
2009-12-14 22:14:06 +01:00
Matthias Bolte
d0857c0132 Fix install location for Python bindings
Commit 66137344fe changed the Python detection
mechanism in configure to use AM_PATH_PYTHON. This results in a changed
install location for the Python bindings, at least on Fedora 12 64bit systems.

Before this commit libvirt.py and libvirtmod.so were installed to

  /usr/lib64/python2.6/site-packages

After this commit they are installed to

  /usr/lib/python2.6/site-packages

Mixed Python packages (containing *.py and *.so files) should be installed to
the pyexecdir directory detected by AM_PATH_PYTHON.

This restores the install location from before the AM_PATH_PYTHON commit.

* configure.in: remove unnecessary pythondir export
* python/Makefile.am: switch from pythondir to pyexecdir
2009-12-14 22:14:06 +01:00
Daniel Veillard
803d320430 Relax the allowed values for machine type in schema
* docs/schemas/domain.rng: don't try to validate based on a list, open
  up the machine type to a regexp allowing a-z A-Z 0-9 _ - and .
2009-12-14 16:59:06 +01:00
Jim Meyering
21a2eba44f virsh: avoid double-free
* tools/virsh.c (vshCommandParse): Avoid double-free of "tkdata".
Set it to NULL immediately after free in the (cmd == NULL) case,
just as in the other case, in case the final free(tkdata) is
triggered by a syntax error.
2009-12-14 16:26:44 +01:00
Jim Meyering
b148318981 node_device_driver.c: don't write beyond EOB for 4K-byte symlink
* src/node_device/node_device_driver.c (update_driver_name): The
previous code would write one byte beyond the end of the 4KiB
stack buffer when presented with a symlink value of exactly that
length (very unlikely).  Remove the automatic buffer and use
virFileResolveLink in place of readlink.  Suggested by Daniel Veillard.
2009-12-14 16:26:38 +01:00
Matthew Booth
042956d558 Fix owner and group in example volume XML
The owner and group in the documentation examples were confusingly given as
'0744'. They should be numeric uid and gid. Changed the examples to use the
default uid and gid assigned to qemu in F12.

* docs/formatstorage.html.in: Change example owner and group in volume XML
2009-12-14 16:23:26 +01:00
Daniel Veillard
2aec15bc5a add missing doc for device <shareable/> option 2009-12-14 16:20:55 +01:00
Laine Stump
22f3ec27a3 Eliminate failure to delete empty storage pools
* src/storage/storage_backend_fs.c: virStorageBackendFileSystemDelete
  was incorrectly calling unlink() in an attempt to remove a directory.
  It should be calling rmdir() instead.
2009-12-14 16:15:28 +01:00
Jiri Denemark
a645c8f0fd Fix use of virEventAddHandleImpl()
src/node_device/node_device_udev.c was using a function available only
on the daemon code, fix this and use the function available globally

* src/node_device/node_device_udev.c: replace use of virEventAddHandleImpl
  by virEventAddHandle
2009-12-14 16:09:01 +01:00
Matthew Booth
057ad3a2f5 Cleanup temporary #define after use
* src/qemu/qemu_driver.c: #undef LOOKUP_PTYS after use in
  qemudFindCharDevicePTYsMonitor()
2009-12-14 16:05:45 +01:00
Dave Allan
94d599eccf Implement --pool option for virsh vol-path
This patch fixes the problem reported in:

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

The bug reporter says that vol-delete does not support the --pool
option, but that's not the case in the current head.  This patch makes
vol-path behave the same way as vol-delete

* tools/virsh.c: Modified vol-path to use the same logic as vol-delete,
  allowing the syntax: virsh vol-path --pool testdirpool testvol0
2009-12-14 15:17:35 +01:00
Cole Robinson
deae2bb57f nodedev: Add removable storage 'media_label' prop
Provides the CDROM label for current media. Only implemented for the
udev backend.
2009-12-14 14:58:23 +01:00
Dave Allan
a010165d27 expose SR IOV physical/virtual function relationships
exposes the relationships between physical
and virtual functions on SR IOV capable devices.
2009-12-14 14:44:12 +01:00
Paolo Bonzini
921d2225ba Fix possible NULL pointer dereference
If there are no references remaining to the object, vm is set to NULL
and vm->persistent cannot be accessed.  Fixed by this trivial patch.

* src/qemu/qemu_driver.c (qemudDomainCoreDump): Avoid possible
  NULL pointer dereference on --crash dump.
2009-12-14 14:09:10 +01:00
Jamie Strandboge
ad905a195e add AppArmor test and examples to dist
tests/virt-aa-helper-test and examples/apparmor are not included in
official tarballs, but should be. Attached is a patch to fix that
which works when apparmor is and is not available.
2009-12-14 13:40:42 +01:00
Paolo Bonzini
1fb7af40cd add --live support to "virsh dump"
This is trivial for QEMU since you just have to not stop the vm before
starting the dump.  And for Xen, you just pass the flag down to xend.

* include/libvirt/libvirt.h.in (virDomainCoreDumpFlags): Add VIR_DUMP_LIVE.
* src/qemu/qemu_driver.c (qemudDomainCoreDump): Support live dumping.
* src/xen/xend_internal.c (xenDaemonDomainCoreDump): Support live dumping.
* tools/virsh.c (opts_dump): Add --live. (cmdDump): Map it to VIR_DUMP_LIVE.
2009-12-14 12:10:38 +01:00
Paolo Bonzini
b927aed8a3 add --crash support to "virsh dump"
This patch adds the --crash option (already present in "xm dump-core")
to "virsh dump".  virDomainCoreDump already has a flags argument, so
the API/ABI is untouched.

* include/libvirt/libvirt.h.in (virDomainCoreDumpFlags): New flag for
  CoreDump
* src/test/test_driver.c (testDomainCoreDump): Do not crash
  after dump unless VIR_DUMP_CRASH is given.
* src/qemu/qemu_driver.c (qemudDomainCoreDump): Shutdown the domain
  instead of restarting it if --crash is passed.
* src/xen/xend_internal.c (xenDaemonDomainCoreDump): Support --crash.
* tools/virsh.c (opts_dump): Add --crash.
  (cmdDump): Map it to flags for virDomainCoreDump and pass them.
2009-12-14 11:59:27 +01:00
Paolo Bonzini
f509e16241 fix various breakages in qemu Dump command
1) qemuMigrateToCommand uses ">>" so we have to truncate the file
before starting the migration;

2) the command wasn't updated to chown the driver and set/restore
the security lavels;

3) the VM does not have to be resumed if migration fails;

4) the file is not removed when migration fails.

* src/qemu/qemu_driver.c (qemuDomainCoreDump): Truncate file before
  dumping, set/restore ownership and security labels for the file.
2009-12-14 11:27:41 +01:00
Daniel Veillard
a7d1eb3c44 Fix a couple of problems in last patch
Those were pointed by DanB in his review but not yet fixed

* src/qemu/qemu_driver.c: qemudWaitForMonitor() use EnterMonitorWithDriver()
  and ExitMonitorWithDriver() there
* src/qemu/qemu_monitor_text.c: checking fro strdu failure and hash
  table add error in qemuMonitorTextGetPtyPaths()
2009-12-14 11:05:55 +01:00
Matthew Booth
60e8977fdd Get QEMU pty paths from the monitor
This change makes the QEMU driver get pty paths from the output of the
monitor 'info chardev' command. This output is structured, and contains
both the name of the device and the path on the same line. This is
considerably more reliable than parsing the startup log output, which
requires the parsing code to know which order QEMU will print pty
information in.

Note that we still need to parse the log output as the monitor itself
may be on a pty. This should be rare, however, and the new code will
replace all pty paths parsed by the log output method once the monitor
is available.

* src/qemu/qemu_monitor.(c|h) src/qemu_monitor_text.(c|h): Implement
  qemuMonitorGetPtyPaths().
* src/qemu/qemu_driver.c: Get pty path information using
  qemuMonitorGetPtyPaths().
2009-12-14 10:50:01 +01:00
Matthew Booth
033eef4358 Extract the assigned pty device for QEmu channels
* src/qemu/qemu_driver.c: Parse pty devices for channels
2009-12-14 10:42:14 +01:00
Matthew Booth
a8eb010ea2 Make QEMU driver use -chardev everywhere if available
Change -monitor, -serial and -parallel output to use -chardev if it is
available.
* src/qemu/qemu_conf.c: Update qemudBuildCommandLine to use -chardev where
  available.
* tests/qemuxml2argvtest.c tests/qemuxml2argvdata/: Add -chardev equivalents
  for all current serial and parallel tests.
2009-12-14 10:38:44 +01:00
Ryota Ozaki
2597f8ecc9 Suppress cgroup error message on sucess startup
Even if qemudStartVMDaemon suceeds, an error was logged such as
'qemuRemoveCgroup:1778 : internal error Unable to find cgroup for'.
This is because qemudStartVMDaemon calls qemuRemoveCgroup to
ensure that old cgroup does not remain. This workaround makes
sense but leaving an error message may confuse users.
* src/qemu/qemu_driver.c: a an option to the function to suppress the
  error being logged
2009-12-14 10:30:49 +01:00
Matthias Bolte
e2692e25de Fix reference leak in remoteDispatchStorageVolCreateXmlFrom 2009-12-11 16:36:45 +01:00
Matthias Bolte
27ba0ad905 Fix memory leak in virStorageBackendCopyToFD 2009-12-11 16:36:45 +01:00
Daniel Veillard
0c3fb8d41c Fix 'make syntax-check' after iptables.c cleanup 2009-12-11 10:09:26 +01:00
Paolo Bonzini
5de41c06a4 retrieve paused/running state at migration start
This patch fixes the bug where paused/running state is not
transmitted during migration.  As a result, in the QEMU driver
for example the machine was always started on the destination
end.

In order to do so, just read the state and if it is appropriate and
set the VIR_MIGRATE_PAUSED flag.

* src/libvirt.c (virDomainMigrateVersion1, virDomainMigrateVersion2):
  Automatically add VIR_MIGRATE_PAUSED when appropriate.
* src/xen/xend_internal.c (xenDaemonDomainMigratePerform): Give a nicer
  error message when migration of paused domains is attempted.
2009-12-11 10:06:05 +01:00
Paolo Bonzini
edc9e78b48 add virsh --suspend arg to migrate command
This adds a new flag, VIR_MIGRATE_PAUSED, that mandates pausing
the migrated VM before starting it.

* include/libvirt/libvirt.h.in (virDomainMigrateFlags): Add VIR_MIGRATE_PAUSED.
* src/qemu/qemu_driver.c (qemudDomainMigrateFinish2): Handle VIR_MIGRATE_PAUSED.
* tools/virsh.c (opts_migrate): Add --suspend. (cmdMigrate): Handle it.
* tools/virsh.pod (migrate): Document it.
2009-12-11 10:00:44 +01:00
Paolo Bonzini
ba7d82c699 fix migration of paused vms upon failure
This makes a small change on the failed-migration path.  Up to now,
all VMs that failed non-live migration after the "stop" command
were restarted.  This must not be done when the VM was paused in
the first place.

* src/qemu/qemu_driver.c (qemudDomainMigratePerform): Do not restart
  a paused VM that fails migration.  Set paused state after "stop",
  reset it after failure.
2009-12-11 09:42:19 +01:00
Diego Elio Pettenò
25f7fa0583 Small change of RNG syntax for domain
* docs/schemas/domain.rng: As trang seems to bug with <optional><oneOrMore>
  replace it with <zeroOrMore>
2009-12-11 08:46:11 +01:00
Richard Jones
c11a82b62a qemu driver: Fix segfault in libvirt/libvirtd when uri->path is NULL.
See also:
https://bugzilla.redhat.com/show_bug.cgi?id=545400#c1
2009-12-10 16:39:07 +00:00
Diego Elio Pettenò
51ea18a844 Fix a wellformedness problem in secret.rng
* docs/schemas/secret.rng: ref tag for usagevolume wasn't closed
2009-12-10 17:03:47 +01:00
Mark McLoughlin
4ecf9c653e remove iptablesReloadRules() and related code
We don't use this method of reloading rules anymore, so we can just
kill the code.

This simplifies things a lot because we no longer need to keep a
table of the rules we've added.

* src/util/iptables.c: kill iptablesReloadRules()
2009-12-10 11:27:18 +00:00