Commit Graph

4553 Commits

Author SHA1 Message Date
Daniel P. Berrange
44f687297a Fix detection of errors in QEMU device_add command
The code assumed that 'device_add' returned an empty string upon
success. This is not true, it sometimes prints random debug info.
THus we need to check for an explicit fail string

* src/qemu/qemu_monitor_text.c: Fix error checking of the device_add
  monitor command
2010-03-03 14:56:15 +00:00
Eric Blake
a8464c516b esx: don't ignore failure on close
Another warning caught by coverity.  Continue to perform best-effort
closing and resource release, but warn the caller about the failure.

* src/esx/esx_driver.c (esxClose): Return an error on failure to close.
2010-03-03 11:22:46 +01:00
Eric Blake
4acbb29821 uml: avoid crash on partial read
Coverity detected a potential dereference of uninitialized memory
if recvfrom got cut short.

* src/uml/uml_driver.c (umlMonitorCommand): Validate complete read
prior to dereferencing res.
2010-03-03 10:17:31 +01:00
Eric Blake
2103d87c89 virsh: silence compiler warning
gcc warns:
virsh.c:1879: warning: '0' flag ignored with '-' flag in gnu_printf format

* tools/virsh.c (cmdDomjobinfo): Delete useless flag.
2010-03-03 10:17:31 +01:00
Jiri Denemark
a64e3b3e68 Fix safezero()
Various safezero() implementations used either -1, errno or -errno
return values. This patch fixes them all to return -1 and set errno
appropriately.

There was also a bug in size parameter passed to safewrite() which could
result in an attempt to write gigabytes out of a megabyte buffer.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-03-02 18:16:32 +01:00
Daniel P. Berrange
cf1045338e Fix QEMU domain state after a save attempt fails
When a VM save attempt failed, the VM would be left in a paused
state. It is neccessary to resume CPU execution upon failure
if it was running originally

* src/qemu/qemu_driver.c: Resume CPUs upon save failure
2010-03-02 16:23:31 +00:00
Daniel P. Berrange
04c7abd9c3 Support job cancellation in QEMU driver
This supports cancellation of jobs for the QEMU driver against
the virDomainMigrate, virDomainSave and virDomainCoreDump APIs.
It is not yet supported for the virDomainRestore API, although
it is desirable.

* src/qemu/qemu_driver.c: Issue 'migrate_cancel' command if
  virDomainAbortJob is issued during a migration operation
* tools/virsh.c: Add a domjobabort command
2010-03-02 16:23:31 +00:00
Daniel P. Berrange
b1a7ebfdec Remote driver implementation for the virDomainAbortJob APi
This defines the wire protocol for the new API

* src/remote/remote_protocol.x: Wire protocol definition
* src/remote/remote_driver.c,daemon/remote.c: Client and server
  side implementation
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_table.h, src/remote/remote_protocol.c,
  src/remote/remote_protocol.h: Re-generate from remote_protocol.x
2010-03-02 16:23:31 +00:00
Daniel P. Berrange
0d8aa35f60 Wire up internal entry points for virDomainAbortJob API
This provides the internal glue for the driver API

* src/driver.h: Internal API contract
* src/libvirt.c, src/libvirt_public.syms: Connect public API
  to driver API
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/test/test_driver.c src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/xen/xen_driver.c: Stub out entry points
2010-03-02 16:23:31 +00:00
Daniel P. Berrange
4fee63fe1c Introduce public API for cancelling async domain jobs
The new virDomainAbortJob() method provides a way for a second
thread to abort an ongoing job run by another thread. This
extends to any API with  which the virDomainGetJobInfo() API
is intended to work. Cancellation is not guarenteed, rather best
effort on part of the hypervisor and not required to be implmented.

* include/libvirt/libvirt.h.in: Define virDomainAbortJob()
2010-03-02 16:23:31 +00:00
Daniel P. Berrange
0d3eee7fe8 Add QEMU driver support for job info on migration ops
Introduce support for  virDomainGetJobInfo in the QEMU driver. This
allows for monitoring of any API that uses the 'info migrate' monitor
command. ie virDomainMigrate, virDomainSave and virDomainCoreDump

Unfortunately QEMU does not provide a way to monitor incoming migration
so we can't wire up virDomainRestore yet.

The virsh tool gets a new command 'domjobinfo' to query status

* src/qemu/qemu_driver.c: Record virDomainJobInfo and start time
  in qemuDomainObjPrivatePtr objects. Add generic shared handler
  for calling 'info migrate' with all migration based APIs.
* src/qemu/qemu_monitor_text.c: Fix parsing of 'info migration' reply
* tools/virsh.c: add new 'domjobinfo' command to query progress
2010-03-02 16:23:24 +00:00
Daniel P. Berrange
b85a53405c Remote driver implmentation of job info API
* src/remote/remote_protocol.x: Define wire protocol format
  for virDomainGetJobInfo API
* src/remote/remote_driver.c, daemon/remote.c: Implement client
  and server marshalling code for virDomainGetJobInfo()
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h,
  src/remote/remote_protocol.c, src/remote/remote_protocol.h: Rebuild
  files from src/remote/remote_protocol.x
2010-03-02 16:22:31 +00:00
Daniel P. Berrange
92bd859a29 Stub out internal driver entry points for job processing
The internal glue layer for the new pubic API

* src/driver.h: Define internal driver API contract
* src/libvirt.c, src/libvirt_public.syms: Wire up public
  API to internal driver API
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/xen/xen_driver.c: Stub new entry point
2010-03-02 16:22:31 +00:00
Daniel P. Berrange
7d575e09e2 Introduce public API for domain async job handling
Introduce a new public API that provides a way to get progress
info on currently running jobs on a virDomainpPtr. APIs that
are initially within scope of this idea are

 virDomainMigrate
 virDomainMigrateToURI
 virDomainSave
 virDomainRestore
 virDomainCoreDump

These all take a potentially long time and benefit from monitoring.
The virDomainJobInfo struct allows for various pieces of information
to be reported

 - Percentage completion
 - Time
 - Overall data
 - Guest memory data
 - Guest disk/file data

* include/libvirt/libvirt.h.in: Add virDomainGetJobInfo
* python/generator.py, python/libvirt-override-api.xml,
  python/libvirt-override.c: Override for virDomainGetJobInfo API
* python/typewrappers.c, python/typewrappers.h: Introduce wrapper
  for unsigned long long type
2010-03-02 16:22:30 +00:00
Eric Blake
84ef5aecca build: silence coverity warning in node_device
All other uses of get_str_prop in this file that ignored
failure explicitly cast to void.

* src/node_device/node_device_hal.c (dev_create): Silence coverity
warning.
2010-03-02 16:12:48 +01:00
Rolf Eike Beer
bc0f737dd7 Fix error messages when parsing USB devices in QEMU
A number of the error messages raised when parsing USB devices
refered to PCI devices by mistake

* src/qemu/qemu_conf.c: s/PCI/USB/ in qemuParseCommandLineUSB()
2010-03-02 12:30:18 +00:00
Rolf Eike Beer
06973f7065 Fix USB hotplug device string in QEMU driver
The USB hotplug method was mistakenly generating a PCI address
string

* src/qemu/qemu_driver.c: Fix USB hotplug device string
2010-03-02 12:30:18 +00:00
Wolfgang Mauerer
8540dadbe9 Use device_del to remove SCSI controllers
when the underlying qemu supports the drive/device model and the
controller has been added this way.
* src/qemu/qemu_driver.c: use qemuMonitorDelDevice() when detaching
  PCI controller and if supported
* src/qemu/qemu_monitor.[ch]: add new qemuMonitorDelDevice() function
* src/qemu/qemu_monitor_json.[ch]: JSON backend for DelDevice command
* src/qemu/qemu_monitor_text.[ch]: Text backend for DelDevice command
2010-03-02 09:40:51 +01:00
Wolfgang Mauerer
55946f23a6 Fix PCI address handling when controllers are deleted
* src/qemu/qemu_driver.c: in qemudDomainDetachPciControllerDevice()
  when a controller is not present in the system anymore, the PCI
  address must be deleted from libvirt's hashtable because it can
  be re-used for other purposes.
2010-03-02 09:28:26 +01:00
Wolfgang Mauerer
24cc058e5e Fix data structure handling when controllers are attached
* src/qemu/qemu_driver.c: in qemudDomainAttachDevice(), one must not
  delete the data part when the operation succeeds because it is
  required later on. The correct pattern to handlethe parsed
  representation of the device information on success
  is dev->data.controller = NULL; virDomainDeviceDefFree(dev);,
  which leaves the structure pointed at by data in memory.
2010-03-02 09:24:59 +01:00
Wolfgang Mauerer
553447ac3b Tiny spelling fix 2010-03-02 09:21:48 +01:00
Eric Blake
66d70a8f66 libvirtd: avoid false-positive NULL-deref warning from clang
* daemon/libvirtd.c (qemudWorker): Rewrite loop to silence a
warning.
2010-03-02 09:02:40 +01:00
Jim Meyering
e749d77619 x86Decode: avoid NULL-dereference upon questionable input
* src/cpu/cpu_x86.c (x86Decode): Don't dereference NULL when passed
a NULL "models" pointer, or when passed a nonzero "nmodels" value
and a corresponding NULL models[i].
2010-03-02 08:58:45 +01:00
Jim Meyering
23e93d95b5 phypUUIDTable_Push: do not corrupt output stream upon partial write
* src/phyp/phyp_driver.c (phypUUIDTable_Push): Move incr/decr
of ptr/nread into the loop where those variables are used.
Also, remove "exit" label and just-preceding "goto".
2010-03-02 08:58:07 +01:00
Jim Meyering
77d118b4ce openvzDomainDefineCmd: remove useless increment
* src/openvz/openvz_driver.c (openvzDomainDefineCmd): Remove
useless increment of "max_veid".
2010-03-02 08:58:00 +01:00
Jim Meyering
27efcfb7eb maint: disallow TAB-in-indentation also in *.rng files
* cfg.mk (sc_TAB_in_indentation): Also check .rng files.
2010-03-01 20:19:20 +01:00
Jim Meyering
aa7847d3ad maint: convert leading TABs in *.rng files to equivalent spaces
* docs/schemas/capability.rng: Likewise.
* docs/schemas/network.rng: Likewise.
* docs/schemas/nodedev.rng: Likewise.
* docs/schemas/storagepool.rng: Likewise.
* docs/schemas/storagevol.rng: Likewise.
Use these commands:
t=$'\t'
git ls-files | grep '\.rng$' | xargs grep -lE "^ *$t" \
  | xargs perl -MText::Tabs -ni -le \
    '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
2010-03-01 20:19:20 +01:00
Daniel P. Berrange
20578bda74 Expand docs about clock modes
* formatdomain.html.in: Document new clock options
2010-03-01 18:43:04 +00:00
Daniel P. Berrange
74042b8fba Allow configurable timezones with QEMU
Allow an arbitrary timezone with QEMU by setting the $TZ environment
variable when launching QEMU

* src/qemu/qemu_conf.c: Set TZ environment variable if a timezone
  is requested
* tests/qemuxml2argvtest.c: Add test case for timezones
* tests/qemuxml2argvdata/qemuxml2argv-clock-france.xml,
  tests/qemuxml2argvdata/qemuxml2argv-clock-france.args: Data
  for timezone tests
2010-03-01 18:43:04 +00:00
Daniel P. Berrange
e4d7433ef0 Allow a timezone to be specified instead of sync to host timezone
This extends the XML to allow for

  <clock offset='timezone' timezone='Europe/Paris'/>

This is useful if the admin has not configured any timezone on the
host OS, but still wants to synchronize a guest to a specific one.

* src/conf/domain_conf.h, src/conf/domain_conf.c: Support extra
  'timezone' attribute on clock configuration
* docs/schemas/domain.rng: Add 'timezone' attribute
* src/xen/xend_internal.c, src/xen/xm_internal.c: Reject configs
  with a configurable timezone
2010-03-01 18:42:55 +00:00
Daniel P. Berrange
200c83b29d Support variable clock offset mode in QEMU
This allows QEMU guests to be started with an arbitrary clock
offset

The test case can't actually be enabled, since QEMU argv expects
an absolute timestring, and this will obviously change every
time the test runs :-( Hopefully QEMU will allow a relative
time offset in the future.

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Use the -rtc arg
  if available to support variable clock offset mode
* tests/qemuhelptest.c: Add QEMUD_CMD_FLAG_RTC for qemu 0.12.1
* qemuxml2argvdata/qemuxml2argv-clock-variable.args,
  qemuxml2argvdata/qemuxml2argv-clock-variable.xml,
  qemuxml2argvtest.c: Test case, except we can't actually enable
  it yet.
2010-03-01 18:41:40 +00:00
Daniel P. Berrange
b9e2967a5e Add new clock mode allowing variable adjustments
This introduces a third option for clock offset synchronization,
that allows an arbitrary / variable adjustment to be set. In
essence the XML contains the time delta in seconds, relative to
UTC.

  <clock offset='variable' adjustment='123465'/>

The difference from 'utc' mode, is that management apps should
track adjustments and preserve them at next reboot.

* docs/schemas/domain.rng: Schema for new clock mode
* src/conf/domain_conf.c, src/conf/domain_conf.h: Parse
  new clock time delta
* src/libvirt_private.syms, src/util/xml.c, src/util/xml.h: Add
  virXPathLongLong() method
2010-03-01 18:36:01 +00:00
Daniel P. Berrange
eed2f8c3a9 Change the internal domain conf representation of localtime/utc
The XML will soon be extended to allow more than just a simple
localtime/utc boolean flag. This change replaces the plain
'int localtime' with a separate struct to prepare for future
extension

* src/conf/domain_conf.c, src/conf/domain_conf.h: Add a new
  virDomainClockDef structure
* src/libvirt_private.syms: Export virDomainClockOffsetTypeToString
  and virDomainClockOffsetTypeFromString
* src/qemu/qemu_conf.c, src/vbox/vbox_tmpl.c, src/xen/xend_internal.c,
  src/xen/xm_internal.c: Updated to use new structure for localtime
2010-03-01 17:00:30 +00:00
Jim Meyering
a3301b71f6 udevEnumerateDevices: remove dead code
* src/node_device/node_device_udev.c (udevEnumerateDevices): Remove
unnecessary call to udev_list_entry_get_name.
2010-03-01 16:29:42 +01:00
Jim Meyering
546d1f40a0 qemudNetworkIfaceConnect: remove dead store
* src/qemu/qemu_conf.c (qemudNetworkIfaceConnect): Remove extraneous
virSaveLastError call, whose result was unused.
2010-03-01 16:29:37 +01:00
Jim Meyering
3647515788 cmdPoolDiscoverSources: initialize earlier to avoid FP from clang
* tools/virsh.c (cmdPoolDiscoverSources): Always initialize srcSpec.
Otherwise, clang would report that srcSpec could be used uninitialized
in the call to virConnectFindStoragePoolSources.
2010-03-01 16:29:33 +01:00
Eric Blake
bef10f9a05 qemu: avoid null dereference on failed migration
* src/qemu/qemu_monitor_text.c: qemuMonitorTextGetMigrationStatus: Check for
  failed strchr, to silence a coverity warning.
2010-03-01 15:34:33 +01:00
Stefan Berger
b769339295 Free the macvtap mode string
* src/conf/domain_conf.c: forgot to free the attribute value in
  virDomainNetDefParseXML()
2010-03-01 13:09:42 +01:00
Daniel Veillard
74e3b5578e Update of indian, spanish and russian translations
and regeneration of the po/pot files
2010-03-01 12:14:23 +01:00
David Allan
b2111ba3cd Revert fs pool formatting
* We are reverting this patch pending a discussion of the right way to implement.
2010-02-26 03:33:27 -05:00
Jim Meyering
bd3ff6b348 build: update gnulib submodule to latest
* .gnulib: Update to latest.
Commit 89bdf84bcd inadvertently rewound the .gnulib
submodule by 51 commits.  This corrects it.
Spotted by Eric Blake.
2010-02-26 17:14:01 +01:00
Jim Meyering
303cf4dbff build: avoid warning about return-with-value in void function
* tools/virsh.c: Just "return;", not "return NULL;".
2010-02-26 17:12:00 +01:00
Jim Meyering
7ca954cf26 libvirtd: do not ignore failure to set group ID in privileged mode
* daemon/libvirtd.c (qemudListenUnix): Diagnose and fail upon
failure to set or restore group-ID.
2010-02-26 17:12:00 +01:00
Chris Lalancette
1204e41f01 Only build virDomainObjFormat if not building proxy.
While building under RHEL-5, I got a compile warning because
virDomainObjFormat was defined but not used.  That came about
because in RHEL-5 we build with "#define PROXY", and
virDomainObjFormat is only used with !PROXY.  Move the
define.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-02-26 08:46:17 -05:00
Jim Meyering
f3439c7eae openvzGetVEID: don't leak (memory + file descriptor)
* src/openvz/openvz_conf.c (openvzGetVEID): Always call fclose.
Diagnose parse failure also when vzlist output is empty.
If somehow we read a -1, diagnose that (albeit as a parse failure).
2010-02-25 19:28:59 +01:00
Cole Robinson
8ac0334ebd Use standard spacing for user/pass prompt
Kind of minor, but it annoys me that the default auth callback
doesn't put a space between the prompt and the input, like a typical
terminal, ssh, etc. This patch changes the current prompt:

Please enter your authentication name:myuser

to

Please enter your authentication name: myuser
2010-02-25 11:43:57 -05:00
Cole Robinson
b39c2068e4 libvirtd: Better initscript error reporting
From time to time I bork my install, and hate it when the initscript
returns no info. This patch removes the sanity check, which lets
the shell give us 'command not found' or 'permission denied' errors.
2010-02-25 11:43:57 -05:00
Cole Robinson
a09af3b004 qemu: Report binary path if error parsing -help 2010-02-25 11:43:57 -05:00
Cole Robinson
67b2eb1042 remote: Improve daemon startup error reporting
If I toggle enable_tcp in libvirtd.conf and add --listen in
/etc/init.d/libvirtd, I get the unhelpful error:

Starting libvirtd daemon: error: Unable to initialize network sockets.

Running without --daemon provides much more useful info:

sudo libvirtd --listen
11:29:26.117: error : remoteCheckCertFile:270 : Cannot access CA certificate '/etc/pki/CA/cacert.pem': No such file or directory

The daemon architecture makes it difficult to report this useful
info if daemonized, so point users to /var/log/messages and
dropping the --daemon flag if they want more info.
2010-02-25 11:43:57 -05:00
Cole Robinson
482869633a virsh: Show errors reported by nonAPI functions
Only API calls trigger the error callback, which is required for
proper virsh error reporting. Since we use non API functions from
util/, make sure we properly report these errors.

Fixes lack of error message from 'virsh create idontexit.xml'
2010-02-25 11:43:56 -05:00