]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agoqemu: avoid corrupting guest info struct on host device PCI hot add
Alex Williamson [Mon, 24 May 2010 17:33:27 +0000 (13:33 -0400)]
qemu: avoid corrupting guest info struct on host device PCI hot add

The device path doesn't make use of guestAddr, so the memcpy corrupts
the guest info struct.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
14 years agoQuery block allocation extent from QEMU monitor
Daniel P. Berrange [Fri, 14 May 2010 13:10:01 +0000 (09:10 -0400)]
Query block allocation extent from QEMU monitor

The virDomainGetBlockInfo API allows query physical block
extent and allocated block extent. These are normally the
same value unless storing a special format like qcow2
inside a block device. In this scenario we can query QEMU
to get the actual allocated extent.

Since last time:

 - Return fatal error in text monitor
 - Only invoke monitor command for block devices
 - Fix error handling JSON code

* src/qemu/qemu_driver.c: Fill in block aloction extent when VM
  is running
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
  API to query the highest block extent via info blockstats

14 years agolxcSetSchedulerParameters: reverse order of tests; diagnose a failure
Jim Meyering [Tue, 11 May 2010 13:51:46 +0000 (15:51 +0200)]
lxcSetSchedulerParameters: reverse order of tests; diagnose a failure

* src/lxc/lxc_driver.c (lxcSetSchedulerParameters): Ensure that
"->field" is "cpu_shares" before possibly giving a diagnostic about
a type for a "cpu_shares" value.
Also, virCgroupSetCpuShares could fail without evoking a diagnostic.
Add one.

14 years agoDon't overwrite virDomainAssignDef errors.
Chris Lalancette [Tue, 11 May 2010 20:44:09 +0000 (16:44 -0400)]
Don't overwrite virDomainAssignDef errors.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agostorage: Combine some duplicate code
Cole Robinson [Thu, 20 May 2010 17:29:24 +0000 (13:29 -0400)]
storage: Combine some duplicate code

Volume detection in the scsi backend was duplicating code already
present in storage_backend.c. Let's drop the duplicate code.

Also, change the shared function name to be less generic, and remove
some error squashing in the other call site.

14 years agostorage: mpath: Clean up some error handling
Cole Robinson [Thu, 20 May 2010 18:16:54 +0000 (14:16 -0400)]
storage: mpath: Clean up some error handling

We were squashing error messages in a few cases. Recode to follow common
ret = -1 convention.

v2: Handle more error squashing issues further up in MakeNewVol and
    CreateVols. Use ret = -1 convention in MakeVols.

14 years agoRemove dead code after refactoring qemudDomainStart
Jiri Denemark [Fri, 21 May 2010 09:32:03 +0000 (11:32 +0200)]
Remove dead code after refactoring qemudDomainStart

The event is already generated and sent by qemudDomainObjStart, no need
to do anything about here.

14 years agolibvirtd: start each diagnostic with "argv0: "
Jim Meyering [Thu, 20 May 2010 19:40:54 +0000 (21:40 +0200)]
libvirtd: start each diagnostic with "argv0: "

Some diagnostics had a hard-coded "libvirtd: " prefix, some used
"error: " and some used "argv[0]: ".  Always use "argv[0]: ".
* daemon/libvirtd.c (argv0): New global.
(main): Set it.
(version, usage): Remove argv0 parameter.  Use global; update callers.
(daemonForkIntoBackground): Use argv0:, not error:.
(qemudWritePidFile): Start each diagnostic with argv0:.
Suggested by Eric Blake.

14 years agolibvirtd: mark strings for translation, including --help output
Jim Meyering [Thu, 20 May 2010 08:01:32 +0000 (10:01 +0200)]
libvirtd: mark strings for translation, including --help output

* daemon/libvirtd.c (daemonForkIntoBackground, main): Mark strings
for translation.
(usage): Rework --help so that it is translatable, replacing
each embedded, configuration-dependent, macro with an `%s'.

libvirtd: don't ignore virInitialize failure
* daemon/libvirtd.c (main): Diagnose virInitialize failure
and exit nonzero.

14 years agobuild: fix cppi warnings
Eric Blake [Fri, 21 May 2010 22:02:18 +0000 (16:02 -0600)]
build: fix cppi warnings

* src/util/bitmap.h (includes): Placate cppi.

14 years agobuild: force init scripts to rebuild on changed --prefix
Eric Blake [Fri, 21 May 2010 21:18:24 +0000 (15:18 -0600)]
build: force init scripts to rebuild on changed --prefix

Otherwise, './configure --prefix=/foo && make &&
 ./configure --prefix=/bar && make' leaves the wrong files
in libvirtd.init (/foo instead of /bar).

* daemon/Makefile.am (libvirtd.init): Add dependency on
config.status.  Reported by Cole Robinson.

14 years agobuild: Distribute the whole tests/qemuhelpdata directory
Matthias Bolte [Fri, 21 May 2010 18:00:24 +0000 (20:00 +0200)]
build: Distribute the whole tests/qemuhelpdata directory

Instead of distributing the individual files.

Now it's less error prone and consistent with the rest of
the data directories in the tests directory.

14 years ago.gitignore: Add libvirt-guests.init
Cole Robinson [Fri, 21 May 2010 17:58:08 +0000 (13:58 -0400)]
.gitignore: Add libvirt-guests.init

14 years agoFix race in finding available vnc port
Jim Fehlig [Fri, 21 May 2010 13:52:09 +0000 (07:52 -0600)]
Fix race in finding available vnc port

The qemu driver contains a subtle race in the logic to find next
available vnc port.  Currently it iterates through all available ports
and returns the first for which bind(2) succeeds.  However it is possible
that a previously issued port has not yet been bound by qemu, resulting
in the same port used for a subsequent domain.

This patch addresses the race by using a simple bitmap to "reserve" the
ports allocated by libvirt.

V2:
  - Put port bitmap in struct qemud_driver
  - Initialize bitmap in qemudStartup

V3:
  - Check for failure of virBitmapGetBit
  - Additional check for port != -1 before calling virbitmapClearBit

V4:
  - Check for failure of virBitmap{Set,Clear}Bit

14 years agoAdd defines for QEMU_VNC_PORT_{MIN,MAX} and use them
Jim Fehlig [Fri, 21 May 2010 04:25:16 +0000 (22:25 -0600)]
Add defines for QEMU_VNC_PORT_{MIN,MAX} and use them

14 years agoAdd simple bitmap operations to utils
Jim Fehlig [Fri, 21 May 2010 04:23:48 +0000 (22:23 -0600)]
Add simple bitmap operations to utils

V2:
  - Move bitmap impl to src/util/bitmap.[ch]
  - Use CHAR_BIT instead of explicit '8'
  - Use size_t instead of unsigned int
  - Fix calculation of bitmap size in virBitmapAlloc
  - Ensure bit is within range of map in the set, clear, and get
    operations
  - Use bool in virBitmapGetBit
  - Add virBitmapFree to free-like funcs in cfg.mk

V3:
  - Check for overflow in virBitmapAlloc
  - Fix copy and paste bug in virBitmapAlloc
  - Use size_t in prototypes
  - Add ATTRIBUTE_NONNULL in prototypes where appropriate
    and remove NULL check from impl

V4:
  - Add ATTRIBUTE_RETURN_CHECK in prototypes where appropriate.

14 years agodaemon: Export SDL audio environment variables
Cole Robinson [Wed, 19 May 2010 20:03:52 +0000 (16:03 -0400)]
daemon: Export SDL audio environment variables

/etc/sysconfig/libvirtd has a few environment variables for configuring
libvirt SDL audio. The libvirtd process doesn't see these, however, because
they are never exported. Let's export the variables after sourcing the
sysconfig script.

There is another problem here that the commented out values in the
sysconfig script are not neccessarily the actual defaults, we are qemus
mercy here. Not sure how to solve that.

14 years agoRemove isValidIfname.
Chris Lalancette [Thu, 20 May 2010 17:20:24 +0000 (13:20 -0400)]
Remove isValidIfname.

We shouldn't be checking validity in domain_conf, since
it can be used by multiple different hosts and hypervisors.
Remove the check completely.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agoInit script for handling guests on shutdown/boot
Jiri Denemark [Fri, 14 May 2010 13:37:55 +0000 (15:37 +0200)]
Init script for handling guests on shutdown/boot

Example output during shutdown:

Running guests on default URI: console, rhel6-1, rhel5-64
Running guests on lxc:/// URI: lxc-shell
Running guests on xen:/// URI: error: no hypervisor driver available for xen:///
error: failed to connect to the hypervisor
Running guests on vbox+tcp://orkuz/system URI: no running guests.
Suspending guests on default URI...
Suspending console: done
Suspending rhel6-1: done
Suspending rhel5-64: done
Suspending guests on lxc:/// URI...
Suspending lxc-shell: error: Failed to save domain 9cba8bfb-56f4-6589-2d12-8a58c886dd3b state
error: this function is not supported by the hypervisor: virDomainManagedSave

Note, the "Suspending $guest: " shows progress during the suspend phase
if domjobinfo gives meaningful output.

Example output during boot:

Resuming guests on default URI...
Resuming guest rhel6-1: done
Resuming guest rhel5-64: done
Resuming guest console: done
Resuming guests on lxc:/// URI...
Resuming guest lxc-shell: already active

Configuration used for generating the examples above:
URIS='default lxc:/// xen:/// vbox+tcp://orkuz/system'

The script uses /var/lib/libvirt/libvirt-guests files to note all active
guest it should try to resume on next boot. It's content looks like:

default 7f8b9d93-30e1-f0b9-47a7-cb408482654b 085b4c95-5da2-e8e1-712f-6ea6a4156af2 fb4d8360-5305-df3a-2da1-07d682891b8c
lxc:/// 9cba8bfb-56f4-6589-2d12-8a58c886dd3b

14 years agoAutostart domains using virDomainObjStart
Jiri Denemark [Thu, 20 May 2010 10:02:58 +0000 (12:02 +0200)]
Autostart domains using virDomainObjStart

14 years agoRefactor qemudDomainStart
Jiri Denemark [Thu, 20 May 2010 10:01:16 +0000 (12:01 +0200)]
Refactor qemudDomainStart

We need a common internal function for starting managed domains to be
used during autostart. This patch factors out relevant code from
qemudDomainStart into qemudDomainObjStart and makes it use the
refactored code for domain restore instead of calling qemudDomainRestore
API directly.

14 years agoFactor out def assignment to existing domain from virDomainAssignDef
Jiri Denemark [Thu, 20 May 2010 09:36:24 +0000 (11:36 +0200)]
Factor out def assignment to existing domain from virDomainAssignDef

We need to be able to assign new def to an existing virDomainObj which
is already locked. This patch factors out the relevant code from
virDomainAssignDef into virDomainObjAssignDef.

14 years agoRefactor qemudDomainRestore
Jiri Denemark [Thu, 20 May 2010 09:55:32 +0000 (11:55 +0200)]
Refactor qemudDomainRestore

We need to be able to restore a domain which we already locked and
started a job for it without undoing these steps. This patch factors
out internals of qemudDomainRestore into separate functions which work
for locked objects.

14 years agomaint: update po/POTFILES.in
Jim Meyering [Thu, 20 May 2010 06:59:01 +0000 (08:59 +0200)]
maint: update po/POTFILES.in

* po/POTFILES.in: Add 3 files.

14 years agomaint: enforce policy wrt VIR_DEBUG and VIR_DEBUG0
Jim Meyering [Thu, 20 May 2010 06:56:48 +0000 (08:56 +0200)]
maint: enforce policy wrt VIR_DEBUG and VIR_DEBUG0

* cfg.mk (sc_prohibit_gettext_markup): Just like VIR_WARN*.

14 years agomaint: don't mark VIR_DEBUG or VIR_DEBUG0 diagnostics for translation
Jim Meyering [Thu, 20 May 2010 06:57:06 +0000 (08:57 +0200)]
maint: don't mark VIR_DEBUG or VIR_DEBUG0 diagnostics for translation

Run this command:
  git grep -l VIR_DEBUG|xargs perl -pi -e \
    's/(VIR_DEBUG0?)\s*\(_\((".*?")\)/$1($2/'

14 years agomaint: enforce policy wrt VIR_ERROR and VIR_ERROR0
Jim Meyering [Thu, 20 May 2010 06:44:23 +0000 (08:44 +0200)]
maint: enforce policy wrt VIR_ERROR and VIR_ERROR0

* cfg.mk (msg_gen_function): Add VIR_ERROR and VIR_ERROR0,
so that sc_libvirt_unmarked_diagnostics will check them, too.

14 years agomaint: change "" in err ? err->message : "" to _("unknown error"), ...
Jim Meyering [Thu, 20 May 2010 06:44:27 +0000 (08:44 +0200)]
maint: change "" in err ? err->message : "" to _("unknown error"), ...

These changes avoid false-positive syntax-check failure,
and also make the resulting diagnostics more comprehensible.

14 years agomaint: more of same, but manual: convert VIR_ERROR("%s" to VIR_ERROR0(
Jim Meyering [Thu, 20 May 2010 06:40:16 +0000 (08:40 +0200)]
maint: more of same, but manual: convert VIR_ERROR("%s" to VIR_ERROR0(

14 years agomaint: VIR_ERROR/VIR_ERROR0: mark up the remaining ones manually
Jim Meyering [Thu, 20 May 2010 06:28:53 +0000 (08:28 +0200)]
maint: VIR_ERROR/VIR_ERROR0: mark up the remaining ones manually

Handle concatenated strings manually.

14 years agomaint: mark translatable string args of VIR_ERROR
Jim Meyering [Thu, 20 May 2010 06:15:46 +0000 (08:15 +0200)]
maint: mark translatable string args of VIR_ERROR

Run this:
  git grep -l 'VIR_ERROR\s*("'|xargs perl -pi -e \
    's/(VIR_ERROR)\s*\((".*?"),/$1(_($2),/'

14 years agomaint: mark translatable string args of VIR_ERROR0
Jim Meyering [Thu, 20 May 2010 06:14:50 +0000 (08:14 +0200)]
maint: mark translatable string args of VIR_ERROR0

Run this:
  git grep -l 'VIR_ERROR0\s*("'|xargs perl -pi -e \
    's/(VIR_ERROR0)\s*\((".*?")\)/$1(_($2))/'

14 years agomaint: use VIR_ERROR0 rather than VIR_ERROR with a bare "%s"
Jim Meyering [Thu, 20 May 2010 06:10:38 +0000 (08:10 +0200)]
maint: use VIR_ERROR0 rather than VIR_ERROR with a bare "%s"

Change VIR_ERROR("%s", "..."
to     VIR_ERROR0("..."

and

Change VIR_ERROR("%s", _("...")
to     VIR_ERROR0(_("...")

Use this command:
  git grep -E -l 'VIR_ERROR\("%s", (_\()?"'|xargs perl -pi -e \
  's/VIR_ERROR\("%s", (_\()?"/VIR_ERROR0($1"/'

14 years agoqemu driver: fix version check typos
Chris Wright [Wed, 19 May 2010 22:37:26 +0000 (15:37 -0700)]
qemu driver: fix version check typos

* src/qemu/qemu_conf.c (qemudParseHelpStr): Fix errors that made
it impossible to diagnose invalid minor and micro version number
components.

Signed-off-by: Chris Wright <chrisw@redhat.com>
14 years agodaemon: A few initscript corrections
Cole Robinson [Wed, 19 May 2010 19:57:56 +0000 (15:57 -0400)]
daemon: A few initscript corrections

Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=565238

- Avahi service is called 'avahi-daemon'
- chkconfig descriptions must use \ for line continuations

14 years agoqemu: Use ShutdownVMDaemon for all startup cleanup paths
Cole Robinson [Mon, 17 May 2010 16:37:52 +0000 (12:37 -0400)]
qemu: Use ShutdownVMDaemon for all startup cleanup paths

The current cleanup: in StartVMDaemon path is a poor duplication.
qemuShutdownVMDaemon can handle teardown for inactive VMs, so let's use it.

v2: Remove old abort: label, only use cleanup:

14 years agoDomain snapshot RNG and tests.
Chris Lalancette [Mon, 3 May 2010 21:15:18 +0000 (17:15 -0400)]
Domain snapshot RNG and tests.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agoFix up the python bindings for snapshotting.
Chris Lalancette [Wed, 19 May 2010 13:02:30 +0000 (09:02 -0400)]
Fix up the python bindings for snapshotting.

This involved a few fixes.  To start with,
an virDomainSnapshot object is really tied to a
domain, not a connection, so we have to generate
a slightly different object so that we can get
at self._dom for the object.

Next, we had to "dummy" up an override piece of
XML with a bogus argument that the function doesn't
actually take.  That's so that the generator places
virDomainRevertToSnapshot underneath the correct
class (namely, the virDomain class).

Finally, we had to hand-implement the
virDomainRevertToSnapshot implementation, ignoring the
bogus pointer we are being passed.

With all of this in place, I was able to successfully
take a snapshot and revert to it using only the
Python bindings.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agoqemu_conf.c: also recognize new first line of qemu -help output
Jim Meyering [Thu, 20 May 2010 13:43:47 +0000 (15:43 +0200)]
qemu_conf.c: also recognize new first line of qemu -help output

* src/qemu/qemu_conf.c (QEMU_VERSION_STR_1, QEMU_VERSION_STR_2):
Define these instead of...
(QEMU_VERSION_STR): ... this.  Remove definition.
(qemudParseHelpStr): Check first for the new, shorter prefix,
"QEMU emulator version", and then for the old one,
"QEMU PC emulator version" when trying to parse the version number.
Based on a patch by Chris Wright.

14 years agolxc_controller.c: don't ignore failed "accept"
Jim Meyering [Thu, 20 May 2010 12:30:36 +0000 (14:30 +0200)]
lxc_controller.c: don't ignore failed "accept"

* src/lxc/lxc_controller.c (ignorable_epoll_accept_errno): New function.
(lxcControllerMain): Handle a failed accept carefully:
most errno values indicate legitimate failure and must be fatal.
However, ignore a special case: that in which an incoming client quits
between the poll() indicating its presence, and our accept() which
is trying to process it.

14 years agoqemu: Don't deny ShutdownVMDaemon for non-running VMs
Cole Robinson [Mon, 17 May 2010 16:48:47 +0000 (12:48 -0400)]
qemu: Don't deny ShutdownVMDaemon for non-running VMs

Clients that require this already seem to do so. Calling this function
with pid < 1 also should not cause problems.

14 years agoqemu: Remove explicit VNC XML cleanup
Cole Robinson [Mon, 17 May 2010 15:47:21 +0000 (11:47 -0400)]
qemu: Remove explicit VNC XML cleanup

This only exists for a certain cleanup path in StartVMDaemon, but is
unneeded since domain_conf.c handles this for us automatically.

14 years agoqemu: Properly cleanup in security startup error path
Cole Robinson [Mon, 17 May 2010 15:24:16 +0000 (11:24 -0400)]
qemu: Properly cleanup in security startup error path

Everything after hostdev setup needs to jump to cleanup on error.

14 years agolibvirtd: don't ignore virInitialize failure
Jim Meyering [Thu, 20 May 2010 07:52:20 +0000 (09:52 +0200)]
libvirtd: don't ignore virInitialize failure

* daemon/libvirtd.c (main): Diagnose virInitialize failure
and exit nonzero.

14 years agoRename qemuBuildCommandLine tapfds -> vmfds.
Alex Williamson [Thu, 20 May 2010 14:03:17 +0000 (10:03 -0400)]
Rename qemuBuildCommandLine tapfds -> vmfds.

There doesn't seem to be anything specific to tap devices for this
array of file descriptors which need to stay open of the guest to use.
Rename then for others to make use of.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agomaint: prohibit newline at end of diagnostic
Jim Meyering [Thu, 20 May 2010 09:13:41 +0000 (11:13 +0200)]
maint: prohibit newline at end of diagnostic

* cfg.mk (sc_prohibit_newline_at_end_of_diagnostic): New rule.
Idea proposed by Jiri Denemark.

14 years agomaint: remove unwanted newline at end of diagnostic
Jim Meyering [Thu, 20 May 2010 09:12:17 +0000 (11:12 +0200)]
maint: remove unwanted newline at end of diagnostic

* src/xen/xend_internal.c (xenDaemonDomainDefineXML): Remove \n.
* src/network/bridge_driver.c (networkAddMasqueradingIptablesRules):
Likewise.

14 years agoqemudDomainMigrateFinish2: handle a case of virDomainSaveStatus failure
Jim Meyering [Wed, 19 May 2010 15:48:03 +0000 (17:48 +0200)]
qemudDomainMigrateFinish2: handle a case of virDomainSaveStatus failure

* src/qemu/qemu_driver.c (qemudDomainMigrateFinish2): Don't ignore
virDomainSaveStatus failure.
* src/conf/domain_conf.h (virDomainSaveStatus): Use
ATTRIBUTE_RETURN_CHECK, so this doesn't happen again.

14 years agodocs: distribute more coding convention documentation
Eric Blake [Wed, 19 May 2010 17:51:49 +0000 (11:51 -0600)]
docs: distribute more coding convention documentation

These files may be useful for anyone making modifications to
source files in a tarball distribution.

* src/Makefile.am (EXTRA_DIST): Add THREADS.txt.
* daemon/Makefile.am (EXTRA_DIST): Add THREADING.txt.

14 years agobuild: distribute missing file
Eric Blake [Wed, 19 May 2010 22:16:47 +0000 (16:16 -0600)]
build: distribute missing file

Commit f30ccb2458829 was incomplete.

* .gitignore: Ignore intermediate directory during failed 'make
distcheck'.
* tests/Makefile.am (qemuhelpdata): Distribute new file.

14 years agoesx: Make esxVI_*_CastFromAnyType dynamically dispatched
Matthias Bolte [Tue, 18 May 2010 15:53:12 +0000 (17:53 +0200)]
esx: Make esxVI_*_CastFromAnyType dynamically dispatched

This will be used in the ESX storage driver in order to handle
the DatastoreInfo type and inheriting types properly.

14 years agoesx: Allow esxVI_X_DynamicCast to be called successfully on X objects
Matthias Bolte [Tue, 18 May 2010 15:37:45 +0000 (17:37 +0200)]
esx: Allow esxVI_X_DynamicCast to be called successfully on X objects

This semantic will be used in the ESX storage driver.

14 years agotests: the remote_protocol check also accommodates older pdwtags
Jim Meyering [Wed, 19 May 2010 13:36:27 +0000 (15:36 +0200)]
tests: the remote_protocol check also accommodates older pdwtags

This test was failing on systems using pdwtags from dwarves-1.3.
Reported by Matthias Bolte.
Two-pronged fix:
  - use --verbose to work also with dwarves-1.3; adapt regular
    expressions to handle now-varying separators
  - require a minimum number of post-split clauses, in order to
    skip upon any future format change.
    Currently there are 318; if there are 300 or fewer,
    give a warning similar to when pdwtags is missing.
* src/Makefile.am (remote_protocol-structs): Use pdwtags' --verbose
option to make 1.3 emit member sizes and offsets.
Consistently output WARNING messages to stderr.

14 years agoinitialize "meta" in virStorageFileGetMetadata, not in each caller
Jim Meyering [Tue, 18 May 2010 05:53:31 +0000 (07:53 +0200)]
initialize "meta" in virStorageFileGetMetadata, not in each caller

Do not require each caller of virStorageFileGetMetadata and
virStorageFileGetMetadataFromFD to first clear the storage of the
"meta" buffer.  Instead, initialize that storage in
virStorageFileGetMetadataFromFD.
* src/util/storage_file.c (virStorageFileGetMetadataFromFD): Clear
"meta" here, not before each of the following callers.
* src/qemu/qemu_driver.c (qemuSetupDiskCgroup): Don't clear "meta" here.
(qemuTeardownDiskCgroup): Likewise.
* src/qemu/qemu_security_dac.c (qemuSecurityDACSetSecurityImageLabel):
Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityImageLabel):
Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.

14 years ago(qemu*DiskCgroup): avoid dead code
Jim Meyering [Mon, 17 May 2010 20:50:21 +0000 (22:50 +0200)]
(qemu*DiskCgroup): avoid dead code

* src/qemu/qemu_driver.c (qemuTeardownDiskCgroup): Remove
bogus empty-body while-loop.
(qemuSetupDiskCgroup): Likewise.

14 years agomaint: more VIR_WARN corrections: now manually
Jim Meyering [Wed, 19 May 2010 11:03:35 +0000 (13:03 +0200)]
maint: more VIR_WARN corrections: now manually

* po/POTFILES.in: Remove src/util/logging.c and src/util/uuid.c.
* src/phyp/phyp_driver.c (phypUUIDTable_ReadFile): Correct more
VIR_WARN uses, now manually.
(phypUUIDTable_Init, phypUUIDTable_Pull): Likewise.

14 years agomaint: use VIR_WARN0("...") rather than VIR_WARN("%s", "...")
Jim Meyering [Wed, 19 May 2010 10:59:15 +0000 (12:59 +0200)]
maint: use VIR_WARN0("...") rather than VIR_WARN("%s", "...")

Run this command:
  git grep -l 'VIR_WARN("%s", "'|xargs perl -pi -e \
    's/VIR_WARN\("%s", "/VIR_WARN0("/'
* src/phyp/phyp_driver.c (phypDomainGetInfo): Perform the above.
(phypDomainCreateAndStart, phypUUIDTable_ReadFile): Likewise.

14 years agomaint: enforce no-markup policy wrt VIR_WARN-like macros
Jim Meyering [Wed, 19 May 2010 10:51:11 +0000 (12:51 +0200)]
maint: enforce no-markup policy wrt VIR_WARN-like macros

* cfg.mk (sc_prohibit_gettext_markup): New rule, to enforce
this policy.  Contrary to most diagnostic-emitting functions,
where we require _(...) markup, here, we require that _() *not*
be used for certain functions (or function-like macros).

14 years agomaint: remove _(...) from VIR_WARN arg manually
Jim Meyering [Wed, 19 May 2010 10:52:23 +0000 (12:52 +0200)]
maint: remove _(...) from VIR_WARN arg manually

* src/util/uuid.c (virUUIDGenerate): Remove _(...) manually.

14 years agomaint: don't mark VIR_WARN or VIR_WARN0 diagnostics for translation
Jim Meyering [Wed, 19 May 2010 10:00:18 +0000 (12:00 +0200)]
maint: don't mark VIR_WARN or VIR_WARN0 diagnostics for translation

Approximately 60 messages were marked.  Since these diagnostics are
intended solely for developers and maintainers, encouraging translation
is deemed to be counterproductive:
http://thread.gmane.org/gmane.comp.emulators.libvirt/25050/focus=25052

Run this command:
  git grep -l VIR_WARN|xargs perl -pi -e \
    's/(VIR_WARN0?)\s*\(_\((".*?")\)/$1($2/'

14 years agonote a typo: VIR_MIGRATE_TUNNELLED should be VIR_MIGRATE_TUNNELED,
Jim Meyering [Tue, 18 May 2010 17:13:20 +0000 (19:13 +0200)]
note a typo: VIR_MIGRATE_TUNNELLED should be VIR_MIGRATE_TUNNELED,

so that searches for properly spelled "TUNNELED" turn up
the surprising spelling of this public symbol.
* include/libvirt/libvirt.h.in: Add a comment.

14 years agoAdd support for SSE4.1 and SSE4.2 CPU features
Jiri Denemark [Tue, 18 May 2010 14:26:04 +0000 (16:26 +0200)]
Add support for SSE4.1 and SSE4.2 CPU features

14 years agoFix potential NULL dereference in remoteDomainMigratePrepare2
Jiri Denemark [Wed, 12 May 2010 14:52:06 +0000 (16:52 +0200)]
Fix potential NULL dereference in remoteDomainMigratePrepare2

14 years agodo not ignore qemuMonitorAddDrive failure; make uses identical
Jim Meyering [Tue, 18 May 2010 14:02:12 +0000 (16:02 +0200)]
do not ignore qemuMonitorAddDrive failure; make uses identical

There were three very similar uses of qemuMonitorAddDrive.
This change makes the three 17-line sequences identical.
* src/qemu/qemu_driver.c (qemudDomainAttachPciDiskDevice): Detect
failure.  Add VIR_WARN and braces.
(qemudDomainAttachSCSIDisk): Add VIR_WARN and braces.
(qemudDomainAttachUsbMassstorageDevice): Likewise.

14 years agoebtablesAddRemoveRule, iptablesAddRemoveRule: don't skip va_end
Jim Meyering [Tue, 18 May 2010 12:42:33 +0000 (14:42 +0200)]
ebtablesAddRemoveRule, iptablesAddRemoveRule: don't skip va_end

* src/util/ebtables.c (ebtablesAddRemoveRule): Don't skip
va_end(args) on an error path.
* src/util/iptables.c (iptablesAddRemoveRule): Identical change.

14 years agoqemudDomainRestore: handle a case of virDomainSaveStatus failure
Jim Meyering [Tue, 18 May 2010 12:07:18 +0000 (14:07 +0200)]
qemudDomainRestore: handle a case of virDomainSaveStatus failure

* src/qemu/qemu_driver.c (qemudDomainRestore): Don't ignore
virDomainSaveStatus failure.

14 years agopython: don't ignore virInitialize failure in module initialization
Jim Meyering [Tue, 18 May 2010 11:46:27 +0000 (13:46 +0200)]
python: don't ignore virInitialize failure in module initialization

* python/libvirt-override.c (initlibvirtmod): Upon virInitialize
failure, skip the Py_InitModule call.

14 years agotests: do not ignore virInitialize failure
Jim Meyering [Tue, 18 May 2010 10:32:39 +0000 (12:32 +0200)]
tests: do not ignore virInitialize failure

* tests/nodeinfotest.c (mymain): Do not ignore virInitialize failure.
Most other callers of virInitialize test for failure.

14 years agoqemuMonitorTextMigrate: avoid leak on OOM-error path
Jim Meyering [Tue, 18 May 2010 10:17:23 +0000 (12:17 +0200)]
qemuMonitorTextMigrate: avoid leak on OOM-error path

* src/qemu/qemu_monitor_text.c (qemuMonitorTextMigrate): Also
free "safedest" buffer when failing.

14 years agovirNWFilterDefParseXML: avoid leak on error paths
Jim Meyering [Tue, 18 May 2010 10:05:53 +0000 (12:05 +0200)]
virNWFilterDefParseXML: avoid leak on error paths

* src/conf/nwfilter_conf.c (virNWFilterDefParseXML): Also free "ret"
via cleanup.

14 years agolinuxNodeInfoCPUPopulate: avoid used-uninitialized via a test
Jim Meyering [Tue, 18 May 2010 09:58:32 +0000 (11:58 +0200)]
linuxNodeInfoCPUPopulate: avoid used-uninitialized via a test

* tests/nodeinfotest.c (linuxTestCompareFiles): Don't use
nodeinfo->member uninitialized.  linuxNodeInfoCPUPopulate requires
that some of its nodeinfo members (including threads) be initialized
upon input.  The nodeinfotest.c program lacked the initialization,
while the only other use (nodeGetInfo) did perform it.
It's not trivial to move the initialization into the function,
since nodeGetInfo sets at least one member after clearing the
buffer but before calling linuxNodeInfoCPUPopulate.

14 years agovirDomainNetDefParseXML: avoid leak upon multiple "filterref"
Jim Meyering [Tue, 18 May 2010 08:19:30 +0000 (10:19 +0200)]
virDomainNetDefParseXML: avoid leak upon multiple "filterref"

* src/conf/domain_conf.c (virDomainNetDefParseXML): Don't leak
memory when parsing two or more "filterref" elements.

14 years agoebiptablesWriteToTempFile: don't close a negative file descriptor
Jim Meyering [Tue, 18 May 2010 08:11:23 +0000 (10:11 +0200)]
ebiptablesWriteToTempFile: don't close a negative file descriptor

* src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesWriteToTempFile):
Skip the close if "fd" is negative.

14 years agoProtect against NULL pointer flaws in monitor usage
Daniel P. Berrange [Mon, 17 May 2010 11:43:36 +0000 (07:43 -0400)]
Protect against NULL pointer flaws in monitor usage

History has shown that there are frequent bugs in the QEMU driver
code leading to the monitor being invoked with a NULL pointer.
Although the QEMU driver code should always report an error in
this case before invoking the monitor, as a safety net put in a
generic check in the monitor code entry points.

* src/qemu/qemu_monitor.c: Safety net to check for NULL monitor
  object

14 years agoFix multiple potential NULL pointer references in monitor usage
Daniel P. Berrange [Mon, 17 May 2010 11:38:05 +0000 (07:38 -0400)]
Fix multiple potential NULL pointer references in monitor usage

Any method which intends to invoke a monitor command must have
a check for virDomainObjIsActive() before using the monitor to
ensure that priv->mon != NULL.

There is one subtle edge case in this though. If a method invokes
multiple monitor commands, and calls qemuDomainObjExitMonitor()
in between two of these commands then there is no guarentee that
priv->mon != NULL anymore. This is because the QEMU process may
exit or die at any time, and because qemuDomainObjEnterMonitor()
releases the lock on virDomainObj, it is possible for the background
thread to close the monitor handle and thus qemuDomainObjExitMonitor
will release the last reference allowing priv->mon to become NULL.

This affects several methods, most notably migration but also some
hotplug methods. This patch takes a variety of approaches to solve
the problem, depending on the particular usage scenario. Generally
though it suffices to add an extra virDomainObjIsActive() check
if qemuDomainObjExitMonitor() was called during the method.

* src/qemu/qemu_driver.c: Fix multiple potential NULL pointer flaws
  in usage of the monitor

14 years agomaint: add more free-like functions to the list and deal with fallout
Jim Meyering [Mon, 17 May 2010 20:38:59 +0000 (22:38 +0200)]
maint: add more free-like functions to the list and deal with fallout

* cfg.mk (useless_free_options): Add many vir*Free* function names,
and then remove the useless if-before-free tests exposed by running
make syntax-check.
* src/conf/interface_conf.c (virInterfaceDefFree): Remove useless "if".
(virInterfaceAssignDef): Likewise.
* src/conf/network_conf.c (virNetworkAssignDef): Likewise.
* src/conf/storage_conf.c (virStoragePoolObjAssignDef): Likewise.
* src/node_device/node_device_hal.c (dev_create): Likewise.
* src/security/virt-aa-helper.c (vahDeinit): Likewise.
* src/test/test_driver.c (testNodeDeviceCreateXML): Likewise.
* src/util/conf.c (virConfSetValue): Likewise.

14 years agomaint: add virCgroupFree to the list of free-like functions
Jim Meyering [Mon, 17 May 2010 17:38:35 +0000 (19:38 +0200)]
maint: add virCgroupFree to the list of free-like functions

This makes the useless-if-before-free test in maint.mk spot
uses of virCgroupFree just like it does for free and the other
listed functions.
* cfg.mk (useless_free_options): Add virCgroupFree.
Prompted by suggestion from Eric Blake.

14 years agoqemudDomainSetVcpus: avoid NULL-deref on failed uuid look-up
Jim Meyering [Mon, 17 May 2010 17:28:44 +0000 (19:28 +0200)]
qemudDomainSetVcpus: avoid NULL-deref on failed uuid look-up

* src/qemu/qemu_driver.c (qemudDomainSetVcpus): Upon look-up failure,
i.e., vm==NULL, goto cleanup, rather than to "endjob", superficially
since the latter would dereference vm, but more fundamentally because
we certainly don't want to call qemuDomainObjEndJob before we've
even attempted qemuDomainObjBeginJob.

14 years agolxcFreezeContainer: avoid test-after-deref of never-NULL pointer
Jim Meyering [Mon, 17 May 2010 17:18:12 +0000 (19:18 +0200)]
lxcFreezeContainer: avoid test-after-deref of never-NULL pointer

* src/lxc/lxc_driver.c (lxcFreezeContainer): Remove test-after-deref.
Correct indentation in expression.

14 years agoAdd CIFS to the list of network file systems
Matthias Bolte [Mon, 17 May 2010 23:24:32 +0000 (01:24 +0200)]
Add CIFS to the list of network file systems

ESX supports NFS and CIFS. The ESX storage driver will reflect this.

14 years agoAdd VIR_STORAGE_POOL_INACCESSIBLE to denote inaccessible storage pools
Matthias Bolte [Mon, 17 May 2010 23:18:38 +0000 (01:18 +0200)]
Add VIR_STORAGE_POOL_INACCESSIBLE to denote inaccessible storage pools

This status will be used by the ESX storage driver.

For example a running NFS pool is inaccessible when the NFS server is
currently unreachable.

14 years agoqemu_conf: fix flag value
Eric Blake [Thu, 13 May 2010 03:07:00 +0000 (21:07 -0600)]
qemu_conf: fix flag value

(gdb) p/x QEMUD_CMD_FLAG_VNET_HOST
$7 = 0xffffffff80000000

Oops - that meant we were incorrectly setting QEMU_CMD_FLAG_RTC_TD_HACK
for qemu-kvm-0.12.3 (and probably botching a few other settings as well).

Fixes Red Hat BZ#592070

* src/qemu/qemu_conf.h (QEMUD_CMD_FLAG_VNET_HOST): Avoid sign
extension.
* tests/qemuhelpdata/qemu-kvm-0.12.3: New file.
* tests/qemuhelptest.c (mymain): Add another case.

14 years agoqemu: Clarify a couple error messages
Cole Robinson [Mon, 17 May 2010 19:19:27 +0000 (15:19 -0400)]
qemu: Clarify a couple error messages

A fedora translator filed:

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

Pointing out these two error messages as unclear: "write save" sounds
like a typo without context, and lack of a colon made the second message
difficult to parse.

14 years agovirFileResolveLink: fix return value
Eric Blake [Fri, 14 May 2010 20:50:27 +0000 (14:50 -0600)]
virFileResolveLink: fix return value

virFileResolveLink was returning a positive value on error,
thus confusing callers that assumed failure was < 0.  The
confusion is further evidenced by callers that would have
ended up calling virReportSystemError with a negative value
instead of a valid errno.

Fixes Red Hat BZ #591363.

* src/util/util.c (virFileResolveLink): Live up to documentation.
* src/qemu/qemu_security_dac.c
(qemuSecurityDACRestoreSecurityFileLabel): Adjust callers.
* src/security/security_selinux.c
(SELinuxRestoreSecurityFileLabel): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskDeleteVol): Likewise.

14 years agotests: Skip daemon-conf test if dir exceeds UNIX_PATH_MAX
Cole Robinson [Mon, 17 May 2010 16:32:45 +0000 (12:32 -0400)]
tests: Skip daemon-conf test if dir exceeds UNIX_PATH_MAX

The max path length for unix sockets is pretty small (108, see man 7 unix).
If 'make check' is run from a directory that exceeds this, one of the tests
will fail, and in such a way that requires manually editting the test to
determine why.

There are certainly other ways to handle this, but I've chosen just to skip
the offending test if we will exceed the length limitation.

v2: Drop bashism, use test infrastructure to warn and skip

14 years agopci: Give an explicit error if device not found
Cole Robinson [Fri, 30 Apr 2010 15:44:19 +0000 (11:44 -0400)]
pci: Give an explicit error if device not found

v2: Use intended F_OK. Drop devdir param, just check dev->path for device
existence.

v3: Use virReportSystemError, include dev->path in error message.

14 years agobuild: fix cygwin build, correctly this time
Eric Blake [Sat, 15 May 2010 00:19:58 +0000 (18:19 -0600)]
build: fix cygwin build, correctly this time

Fix the cygwin regression introduced in commit 48445ccff, but
without repeating the fresh build regression of commit
2d550542e.

* src/Makefile.am (libvirt_test_la_LIBADD): Split out subset of
locally-built libraries...
(libvirt_test_la_BUILT_LIBADD): ...into new variable.
(libvirt_test_la_DEPENDENCIES): Depend only on the subset that
automake would have given us for free if we didn't have to add our
own extra file.

14 years agoumlAutostartDomain: avoid NULL-deref upon virGetLastError failure
Jim Meyering [Mon, 17 May 2010 12:38:14 +0000 (14:38 +0200)]
umlAutostartDomain: avoid NULL-deref upon virGetLastError failure

* src/uml/uml_driver.c (umlAutostartDomain): Handle a NULL return
from virGetLastError.

14 years agobuild: fix up some compiler flags
Eric Blake [Fri, 14 May 2010 22:45:52 +0000 (16:45 -0600)]
build: fix up some compiler flags

Matthias noted that the line:
virt_aa_helper_LDFLAGS = $(WARN_CFLAGS)
looks inconsistent, so I did an audit.

Currently, the set of compiler warning flags passed to gcc as $CC are
equally permitted as the set of linker flags passed to gcc as $LD, so
there was no problem with that usage.  But if we ever get in a
situation where $CC and $LD treat particular flags differently, using
the right variable form will make it easier.

In the process, I spotted a couple of typos that were omitting useful
flags, as well as specifying a -l under the wrong variable.

* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Define WARN_LDFLAGS as
an alias for WARN_CFLAGS.
* tools/Makefile.am (virsh_LDFLAGS): Use more canonical spelling.
* proxy/Makefile.am (libvirt_proxy_LDFLAGS): Likewise. Move
library...
(libvirt_proxy_LDADD): ...here.
* src/Makefile.am (virt_aa_helper_LDFLAGS): Use more canonical
spelling of WARN_LDFLAGS.
(libvirt_parthelper_LDFLAGS, libvirt_lxc_LDFLAGS): Likewise.  Use
correct spelling of COVERAGE_LDFLAGS.
Reported by Matthias Bolte.

14 years agobuild: avoid compile failure on linux kernels older than 2.6.19
Jim Meyering [Mon, 17 May 2010 14:17:08 +0000 (16:17 +0200)]
build: avoid compile failure on linux kernels older than 2.6.19

* configure.ac: Check for <linux/magic.h>.
* src/util/storage_file.c: Include <linux/magic.h> only if present.
Linux kernels prior to 2.6.19 lacked it.
[__linux__] (NFS_SUPER_MAGIC): Define if not already defined.

14 years agox86ModelHasFeature: avoid NULL-dereference for unmatched CPU "feature"
Jim Meyering [Mon, 17 May 2010 12:06:13 +0000 (14:06 +0200)]
x86ModelHasFeature: avoid NULL-dereference for unmatched CPU "feature"

* src/cpu/cpu_x86.c (x86ModelHasFeature): Do not dereference the pointer
returned by x86cpuidFind without first ensuring it is non-NULL.

14 years agoqemu: Report cmdline output if VM dies early
Cole Robinson [Mon, 17 May 2010 14:15:53 +0000 (10:15 -0400)]
qemu: Report cmdline output if VM dies early

qemuReadLogOutput early VM death detection is racy and won't always work.
Startup then errors when connecting to the VM monitor. This won't report
the emulator cmdline output which is typically the most useful diagnostic.

Check if the VM has died at the very end of the monitor connection step,
and if so, report the cmdline output.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=581381

14 years agoqemu: Fix previous commit, use comparision in if()
Cole Robinson [Mon, 17 May 2010 13:39:11 +0000 (09:39 -0400)]
qemu: Fix previous commit, use comparision in if()

14 years agoqemu_driver: avoid NULL dereference
Jim Meyering [Mon, 17 May 2010 10:10:52 +0000 (12:10 +0200)]
qemu_driver: avoid NULL dereference

* src/qemu/qemu_driver.c (qemudDomainStart): After setting vm to NULL,
goto cleanup, rather than dereferencing the NULL pointer.

14 years agoRemove debugging fprintf() calls
Daniel P. Berrange [Mon, 17 May 2010 09:44:49 +0000 (10:44 +0100)]
Remove debugging fprintf() calls

* src/qemu/qemu_driver.c: Remove debugging fprintf() calls
  accidentally left in code

14 years agoqemudDomainSetVcpus: avoid NULL-deref
Jim Meyering [Fri, 14 May 2010 10:38:43 +0000 (12:38 +0200)]
qemudDomainSetVcpus: avoid NULL-deref

* src/qemu/qemu_driver.c (qemudDomainSetVcpus): Avoid NULL-deref
upon unknown UUID.  Call qemuDomainObjBeginJob(vm) only after
ensuring that vm != NULL, not before.  This potential NULL-deref
was introduced by commit 2c555d87b0041e0d1ec4742386d2161d1b2f0600.

14 years agoRevert "build: fix cygwin build"
Eric Blake [Fri, 14 May 2010 23:46:47 +0000 (17:46 -0600)]
Revert "build: fix cygwin build"

This reverts commit 2d550542ee729c1d9a4d92de344892650817b213.

The patch worked for incremental builds, but broke fresh
builds, because it interfered with automake's automatic
dependency generation.  Until I figure out how to make
automake do what we want, I'd rather leave cygwin broken
but fresh Linux builds working.

14 years agobuild: fix cygwin build
Eric Blake [Fri, 14 May 2010 21:14:58 +0000 (15:14 -0600)]
build: fix cygwin build

make[3]: *** No rule to make target `-lxml2', needed by `libvirt.la'.  Stop.

Due to treating the wrong string as a dependency.

* src/Makefile.am (libvirt_la_DEPENDENCIES): Depend only on
locally-built file, not on strings that might resolve as '-lxml2'.

14 years agonwfilter: Add missing driver lock in qemu driver
Stefan Berger [Fri, 14 May 2010 18:22:39 +0000 (14:22 -0400)]
nwfilter: Add missing driver lock in qemu driver

This adds a missing driver lock in the qemu driver to protect
the list of domains.

14 years agoFix a misuse of virAsprintf in qemudDomainMemoryPeek
Ryota Ozaki [Fri, 14 May 2010 10:08:59 +0000 (19:08 +0900)]
Fix a misuse of virAsprintf in qemudDomainMemoryPeek

The code specifies driver->cacheDir as the format string,
but it usually doesn't contain '%s', so the subsequent
argument, "/qemu.mem.XXXXXX", is always ignored.

The patch fixes the misuse.