]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agoqemu_hotplug: Rework media changing process
Michal Privoznik [Thu, 24 Jan 2013 14:14:14 +0000 (15:14 +0100)]
qemu_hotplug: Rework media changing process

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

It seems like with new udev within guest OS, the tray is locked,
so we need to:
- 'eject'
- wait for tray to open
- 'change'

Moreover, even when doing bare 'eject', we should check for
'tray_open' as guest may have locked the tray. However, the
waiting phase shouldn't be unbounded, so I've chosen 10 retries
maximum, each per 500ms. This should give enough time for guest
to eject a media and open the tray.

12 years agomaint: one missed syms file
Eric Blake [Sat, 26 Jan 2013 16:59:12 +0000 (09:59 -0700)]
maint: one missed syms file

Commit f0aa493 missed a file.

* src/libvirt_driver_modules.syms: Add editor hint.

12 years agovbox: Adjust the UTF FREE macros
John Ferlan [Thu, 24 Jan 2013 00:34:48 +0000 (19:34 -0500)]
vbox: Adjust the UTF FREE macros

Adjust the macros to free memory allocated during various calls to
perform the check if parameter is NULL prior to really freeing and to
set the pointer to NULL after done freeing.

12 years agovbox: Address false positive for NULL dereference
John Ferlan [Thu, 24 Jan 2013 00:34:47 +0000 (19:34 -0500)]
vbox: Address false positive for NULL dereference

Resolve a false positive from 'vboxIIDFromUUID_v2_x()'. The code sets
'iid->value = &iid->backing' unconditionally prior to calling 'nsIDFromChar()'.
The 'vboxIIDUnalloc_v2_x()' checks iid->value to not be &iid->backing. The
iid->backing is a static buffer within the initialized structure.

12 years agoMake sure we only abort without libcurl if $with_esx = yes
Guido Günther [Fri, 25 Jan 2013 21:06:53 +0000 (22:06 +0100)]
Make sure we only abort without libcurl if $with_esx = yes

12 years agovirsh: Add --print-xml flag for attach-disk command
Peter Krempa [Fri, 25 Jan 2013 12:21:23 +0000 (13:21 +0100)]
virsh: Add --print-xml flag for attach-disk command

The flag causes the XML of the disk that would be attached to be printed
instead.

12 years agolibxl: Domain event handler improvements
Jim Fehlig [Mon, 21 Jan 2013 17:36:03 +0000 (10:36 -0700)]
libxl: Domain event handler improvements

Since libxl provides the domain ID in the event handler callback,
find the domain object based on the ID.  This approach prevents
processing the callback on a domain that has already been reaped.

Also, similar to the xl implementation, ignore the SUSPEND shutdown
reason.  By calling libxl_domain_suspend(), we know a shutdown
event with SUSPEND reason will be generated, but it can be safely
ignored since any subsequent cleanup will be done by the callers.

12 years agolibxl: Fix removing non-persistent domain after save
Jim Fehlig [Mon, 21 Jan 2013 17:32:34 +0000 (10:32 -0700)]
libxl: Fix removing non-persistent domain after save

libxlDoDomainSave() was removing non-persistent domains, but
required callers to have the virDomainObj locked.  Callers could
potentially unlock an already freed virDomainObj.  Move this
logic to the callers of libxlDoDomainSave().

12 years agolibxl: Explicitly remove timeouts
Jim Fehlig [Mon, 21 Jan 2013 17:30:29 +0000 (10:30 -0700)]
libxl: Explicitly remove timeouts

I've noticed that libxl can invoke timeout reregister/modify hooks
after returning from libxl_ctx_free.  Explicitly remove the
timeouts before freeing the libxl ctx to avoid executing hooks on
stale objects.

12 years agolibxl: Fix race between destruction of objects
Jim Fehlig [Mon, 21 Jan 2013 17:22:07 +0000 (10:22 -0700)]
libxl: Fix race between destruction of objects

It is possible to destroy and cleanup a VM, resulting in freeing the
libxlDomainObjPrivate object and associated libxl ctx, before all fds and
timeouts have been deregistered and destroyed.

Fix this race by incrementing the reference count on libxlDomainObjPrivate
for each fd and timeout registration.  Only when all fds and timeouts are
deregistered and destroyed will the libxlDomainObjPrivate be destroyed.

12 years agolibxl: Fix races in libxl event code
Jim Fehlig [Mon, 21 Jan 2013 17:09:05 +0000 (10:09 -0700)]
libxl: Fix races in libxl event code

The libxl driver is racy in it's interactions with libxl and libvirt's
event loop.  The event loop can invoke callbacks after libxl has
deregistered the event, and possibly access freed data associated with
the event.

This patch fixes the race by converting libxlDomainObjPrivate to a
virObjectLockable, and locking it while executing libxl upcalls and
libvirt event loop callbacks.

Note that using the virDomainObj lock is not satisfactory since it may
be desirable to hold the virDomainObj lock even when libxl events such
as reading and writing to xenstore need processed.

12 years agolibxl: Fix handling of timeouts
Jim Fehlig [Mon, 21 Jan 2013 16:59:28 +0000 (09:59 -0700)]
libxl: Fix handling of timeouts

xen-unstable changeset 26469 makes changes wrt modifying and deregistering
timeouts.

First, timeout modify callbacks will only be invoked with an
abs_t of {0,0}, i.e. make the timeout fire immediately.  Prior to this
commit, timeout modify callbacks were never invoked.

Second, timeout deregister hooks will no longer be called.

This patch makes changes in the libvirt libxl driver that should be
compatible before and after changeset 26469.

While at it, fix a potential overflow in the timeout register callback.

12 years agoconf: avoid NULL deref for pmsuspended domain state
Eric Blake [Thu, 24 Jan 2013 00:06:06 +0000 (17:06 -0700)]
conf: avoid NULL deref for pmsuspended domain state

While working with a pmsuspend vs. snapshot issue, I noticed that
the state file in /var/run/libvirt/qemu/dom.xml contained a rather
suspicious "(null)" string, which does not round-trip well through
a libvirtd restart.  Had I been on a platform other than glibc
where printf("%s",NULL) crashes instead of printing (null), we might
have noticed the problem much sooner.

And in fixing that problem, I also noticed that we had several
missing states, because we were #defining several *_LAST names
to a value _different_ than what they were already given as enums
in libvirt.h.  Yuck.  I got rid of default: labels in the case
statements, because they get in the way of gcc's -Wswitch helping
us ensure we cover all enum values.

* src/conf/domain_conf.c (virDomainStateReasonToString)
(virDomainStateReasonFromString): Fill in missing domain states;
rewrite case statement to let compiler enforce checking.
(VIR_DOMAIN_NOSTATE_LAST, VIR_DOMAIN_RUNNING_LAST)
(VIR_DOMAIN_BLOCKED_LAST, VIR_DOMAIN_PAUSED_LAST)
(VIR_DOMAIN_SHUTDOWN_LAST, VIR_DOMAIN_SHUTOFF_LAST)
(VIR_DOMAIN_CRASHED_LAST): Drop dead defines.
(VIR_DOMAIN_PMSUSPENDED_LAST): Drop dead define.
(virDomainPMSuspendedReason): Add missing enum function.
(virDomainRunningReason, virDomainPausedReason): Add missing enum
value.
* src/conf/domain_conf.h (virDomainPMSuspendedReason): Declare
missing functions.
* src/libvirt_private.syms (domain_conf.h): Export them.

12 years agomaint: make it easier to sort syms files
Eric Blake [Thu, 24 Jan 2013 01:20:01 +0000 (18:20 -0700)]
maint: make it easier to sort syms files

I got bit by 'make check' complaining that the sort order I got
by emacs' sort-lines function differed from expectations.

* src/libvirt_private.syms: Add emacs trailer.
* src/libvirt_atomic.syms: Likewise.
* src/libvirt_daemon.syms: Likewise.
* src/libvirt_esx.syms: Likewise.
* src/libvirt_libssh2.syms: Likewise.
* src/libvirt_linux.syms: Likewise.
* src/libvirt_openvz.syms: Likewise.
* src/libvirt_sasl.syms: Likewise.
* src/libvirt_vmx.syms: Likewise.
* src/libvirt_xenxs.syms: Likewise.

12 years agoqemu_monitor: Fix tray-open attribute in query-block
Michal Privoznik [Fri, 25 Jan 2013 11:56:48 +0000 (12:56 +0100)]
qemu_monitor: Fix tray-open attribute in query-block

With our code, we fail to query for tray-open attribute currently.
That's because in HMP it is 'tray-open' and in QMP it's 'tray_open'.
It always has been. However, we got it exactly the opposite.

12 years agoFix bogus reporting of KVM support for non-native emulators
Daniel P. Berrange [Fri, 25 Jan 2013 10:46:49 +0000 (10:46 +0000)]
Fix bogus reporting of KVM support for non-native emulators

A logic bug meant we reported KVM was possible for every
architecture, merely based on whether the query-kvm command
exists. We should instead have been doing it based on whether
the query-kvm command returns 'present: 1'

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMove QEMU capabilities initialization later in QEMU startup
Daniel P. Berrange [Thu, 24 Jan 2013 18:32:31 +0000 (18:32 +0000)]
Move QEMU capabilities initialization later in QEMU startup

Currently QEMU capabilities are initialized before the QEMU driver
sets ownership on its various directories. The upshot is that if
you change the user/group in the qemu.conf file, libvirtd will fail
to probe QEMU the first time it is run after the config change.
Moving QEMU capabilities initialization to after the chown() calls
fixes this

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix performance & reliabilty of QMP probing
Daniel P. Berrange [Thu, 24 Jan 2013 18:21:23 +0000 (18:21 +0000)]
Fix performance & reliabilty of QMP probing

This previous commit

  commit 1a50ba2cb07d8bb2aa724062889deb9efd7ad9e9
  Author: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
  Date:   Mon Nov 26 15:17:13 2012 +0100

    qemu: Fix QMP Capabability Probing Failure

which attempted to make sure the QEMU process used for probing
ran as the right user id, caused serious performance regression
and unreliability in probing. The -daemonize switch in QEMU
guarantees that the monitor socket is present before the parent
process exits. This means libvirtd is guaranteed to be able to
connect immediately. By switching from -daemonize to the
virCommandDaemonize API libvirtd was no longer synchronized with
QEMU's startup process. The result was that the QEMU monitor
failed to open and went into its 200ms sleep loop. This happened
for all 25 binaries resulting in 5 seconds worth of sleeping
at libvirtd startup. In addition sometimes when libvirt connected,
QEMU would be partially initialized and crash causing total
failure to probe that binary.

This commit reverts the previous change, ensuring we do use the
-daemonize flag to QEMU. Startup delay is cut from 7 seconds
to 2 seconds on my machine, which is on a par with what it was
prior to the capabilities rewrite.

To deal with the fact that QEMU needs to be able to create the
pidfile, we switch pidfile location fron runDir to libDir, which
QEMU is guaranteed to be able to write to.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemuDomainSendKey: Relax the qemu driver locking
Michal Privoznik [Thu, 24 Jan 2013 09:39:06 +0000 (10:39 +0100)]
qemuDomainSendKey: Relax the qemu driver locking

Currently, there is no reason to hold qemu driver locked
throughout whole API execution. Moreover, we can use the
new qemuDomObjFromDomain() internal API to lookup domain then.

12 years agonode_memory: Add '\n' to help message
Satoru Moriya [Thu, 24 Jan 2013 19:40:51 +0000 (19:40 +0000)]
node_memory: Add '\n' to help message

Linefeed is missed in the help of node-memory-tune.
This patch just adds '\n' to get a correct help message.

Signed-off-by: Satoru Moriya <satoru.moriya@hds.com>
12 years agoqemu: escape ipv6 for rbd network disk hosts
Josh Durgin [Fri, 25 Jan 2013 02:45:31 +0000 (18:45 -0800)]
qemu: escape ipv6 for rbd network disk hosts

Hosts for rbd are ceph monitor daemons. These have fixed IP addresses,
so they are often referenced by IP rather than hostname for
convenience, or to avoid relying on DNS. Using IPv4 addresses as the
host name works already, but IPv6 addresses require rbd-specific
escaping because the colon is used as an option separator in the
string passed to qemu.

Escape these colons, and enclose the IPv6 address in square brackets
so it is distinguished from the port, which is currently mandatory.

Acked-by: Osier Yang <jyang@redhat.com>
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
12 years agosnapshot: fix state after external snapshot of S3 domain
Eric Blake [Wed, 9 Jan 2013 04:54:45 +0000 (21:54 -0700)]
snapshot: fix state after external snapshot of S3 domain

https://bugzilla.redhat.com/show_bug.cgi?id=876829 complains that
if a guest is put into S3 state (such as via virsh dompmsuspend)
and then an external snapshot is taken, qemu forcefully transitions
the domain to paused, but libvirt doesn't reflect that change
internally.  Thus, a user has to use 'virsh suspend' to get libvirt
back in sync with qemu state, and if the user doesn't know this
trick, then the guest appears hung.

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateActiveExternal):
Track fact that qemu wakes up a suspended domain on migration.

12 years agolocking: use virStrcpyStatic instead of memcpy
John Ferlan [Fri, 18 Jan 2013 13:50:37 +0000 (08:50 -0500)]
locking: use virStrcpyStatic instead of memcpy

12 years agopython: Fix bindings for virDomainSnapshotGet{Domain,Connect}
Jiri Denemark [Wed, 23 Jan 2013 11:14:57 +0000 (12:14 +0100)]
python: Fix bindings for virDomainSnapshotGet{Domain,Connect}

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

virDomainSnapshot.getDomain() and virDomainSnapshot.getConnect()
wrappers around virDomainSnapshotGet{Domain,Connect} were not supposed
to be ever implemented. The class should contain proper domain() and
connect() accessors that fetch python objects stored internally within
the class. While domain() was already provided, connect() was missing.

This patch adds connect() method to virDomainSnapshot class and
reimplements getDomain() and getConnect() methods as aliases to domain()
and connect() for backward compatibility.

12 years agoFix crash free'ing securityDriverNames in QEMU driver
Daniel P. Berrange [Thu, 24 Jan 2013 18:36:04 +0000 (18:36 +0000)]
Fix crash free'ing securityDriverNames in QEMU driver

The previous fix to avoid leaking securityDriverNames forgot to
handle the case of securityDriverNames being NULL, leading to
a crash

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMake python objects inherit from 'object' base class
Daniel P. Berrange [Thu, 24 Jan 2013 13:15:06 +0000 (13:15 +0000)]
Make python objects inherit from 'object' base class

As of python >= 2.2, it is recommended that all objects inherit
from the 'object' base class. We already require python >= 2.3
for libvirt for thread macro support, so we should follow this
best practice.

See also

  http://stackoverflow.com/questions/4015417/python-class-inherits-object

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix leak of securityDriverNames
Daniel P. Berrange [Wed, 23 Jan 2013 17:42:15 +0000 (17:42 +0000)]
Fix leak of securityDriverNames

When shutting down, the QEMU driver forgot to free the
securityDriverNames string list

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAvoid use of free'd memory in auto destroy callback
Daniel P. Berrange [Wed, 23 Jan 2013 17:22:27 +0000 (17:22 +0000)]
Avoid use of free'd memory in auto destroy callback

The autodestroy callback code has the following function
called from a hash iterator

  qemuDriverCloseCallbackRun(void *payload,
                             const void *name,
                             void *opaque)
  {
    ...
    char *uuidstr = name
    ...

    dom = closeDef->cb(data->driver, dom, data->conn);
    if (dom)
        virObjectUnlock(dom);

    virHashRemoveEntry(data->driver->closeCallbacks, uuidstr);
  }

The closeDef->cb function may well cause the current callback
to be removed, if it shuts down 'dom'. As such the use of
'uuidstr' in virHashRemoveEntry is accessing free'd memory.
We must make a copy of the uuid str before invoking the
callback to be safe.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure nodeinfo struct is initialized to zero
Daniel P. Berrange [Wed, 23 Jan 2013 15:43:21 +0000 (15:43 +0000)]
Ensure nodeinfo struct is initialized to zero

When linuxNodeInfoCPUPopulate() method triggered use of an
uninitialize value, since it did not initialize the 'sockets'
field in the virNodeInfoPtr struct:

==30020== Conditional jump or move depends on uninitialised value(s)
==30020==    at 0x5125DBD: linuxNodeInfoCPUPopulate (nodeinfo.c:513)
==30020==    by 0x51261A0: nodeGetInfo (nodeinfo.c:884)
==30020==    by 0x149B9B10: qemuCapsInit (qemu_capabilities.c:846)
==30020==    by 0x14A11B25: qemuCreateCapabilities (qemu_driver.c:424)
==30020==    by 0x14A12426: qemuStartup (qemu_driver.c:874)
==30020==    by 0x512A7AF: virStateInitialize (libvirt.c:822)
==30020==    by 0x40DE04: daemonRunStateInit (libvirtd.c:877)
==30020==    by 0x50ADCE5: virThreadHelper (virthreadpthread.c:161)
==30020==    by 0x328CA07D14: start_thread (pthread_create.c:308)
==30020==    by 0x328C6F246C: clone (clone.S:114)
(happened twice)

        if (socks > nodeinfo->sockets)    <--- here
            nodeinfo->sockets = socks;

Rather than doing this for each field, just make the caller memset
the entire struct to zero.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoselinux: Properly indent preprocessor directives
Jiri Denemark [Thu, 24 Jan 2013 13:10:50 +0000 (14:10 +0100)]
selinux: Properly indent preprocessor directives

12 years agoapparmor: Avoid freeing uninitialized pointer
Jiri Denemark [Thu, 24 Jan 2013 12:53:22 +0000 (13:53 +0100)]
apparmor: Avoid freeing uninitialized pointer

12 years agoxen: Actually fix the uninitialized variable
Peter Krempa [Thu, 24 Jan 2013 13:02:49 +0000 (14:02 +0100)]
xen: Actually fix the uninitialized variable

0eedb1d9bff672b24d6957dfaa0a8b42d9e851a7 fixed the wrong variable

12 years agoxen: Initialize variable before using
Peter Krempa [Thu, 24 Jan 2013 12:57:14 +0000 (13:57 +0100)]
xen: Initialize variable before using

Commit 87b4c10c6cf02251dd8c29b5b895bebc6ec297f9 added code that may call
the virCapabilitiesClearHostNUMACellCPUTopology function with
uninitialized second argument. Although the value wouldn't be used some
compilers whine about that.

12 years agoselinux: Only create the selabel_handle once.
Richard W.M. Jones [Wed, 23 Jan 2013 20:09:04 +0000 (20:09 +0000)]
selinux: Only create the selabel_handle once.

According to Eric Paris this is slightly more efficient because it
only loads the regular expressions in libselinux once.

12 years agoparallels_utils: Check return status properly from virCommandRun()
John Ferlan [Wed, 23 Jan 2013 22:04:48 +0000 (17:04 -0500)]
parallels_utils: Check return status properly from virCommandRun()

12 years agoutil: Need to add virCommandFree()
John Ferlan [Wed, 23 Jan 2013 22:04:47 +0000 (17:04 -0500)]
util: Need to add virCommandFree()

12 years agostorage: Need to add virCommandFree()
John Ferlan [Wed, 23 Jan 2013 22:04:46 +0000 (17:04 -0500)]
storage: Need to add virCommandFree()

12 years agosecurity: Need to add virCommandFree()
John Ferlan [Wed, 23 Jan 2013 22:04:45 +0000 (17:04 -0500)]
security: Need to add virCommandFree()

12 years agoparallels: Resolve some resource leaks
John Ferlan [Wed, 23 Jan 2013 22:04:44 +0000 (17:04 -0500)]
parallels: Resolve some resource leaks

Be sure to VIR_FREE(accel) and moved virDomainVideoDefFree() within no_memory
label to be consistent

Resolve resource leak in parallelsApplyIfaceParams() when the 'oldnet' is
allocated locally. Also virCommandFree(cmd) as necessary.

12 years agotest: Add support for thread and core information for the test driver
Peter Krempa [Tue, 22 Jan 2013 21:18:19 +0000 (22:18 +0100)]
test: Add support for thread and core information for the test driver

This patch adds demo processor topology information for the test driver.

12 years agocapabilities: Add additional data to the NUMA topology info
Peter Krempa [Fri, 18 Jan 2013 22:06:55 +0000 (23:06 +0100)]
capabilities: Add additional data to the NUMA topology info

This patch adds data gathering to the NUMA gathering files and adds
support for outputting the data. The test driver and xend driver need to
be adapted to fill sensible data to the structure in a future patch.

12 years agocapabilities: Switch CPU data in NUMA topology to a struct
Peter Krempa [Tue, 22 Jan 2013 17:42:08 +0000 (18:42 +0100)]
capabilities: Switch CPU data in NUMA topology to a struct

This will allow storing additional topology data in the NUMA topology
definition.

This patch changes the storage type and fixes fallout of the change
across the drivers using it.

This patch also changes semantics of adding new NUMA cell information.
Until now the data were re-allocated and copied to the topology
definition. This patch changes the addition function to steal the
pointer to a pre-allocated structure to simplify the code.

12 years agoconf: Split out NUMA topology formatting to simplify access to data
Peter Krempa [Fri, 18 Jan 2013 19:39:00 +0000 (20:39 +0100)]
conf: Split out NUMA topology formatting to simplify access to data

12 years agoschemas: Add schemas for more CPU topology information in the caps XML
Peter Krempa [Fri, 18 Jan 2013 18:30:00 +0000 (19:30 +0100)]
schemas: Add schemas for more CPU topology information in the caps XML

This patch adds RNG schemas for adding more information in the topology
output of the NUMA section in the capabilities XML.

The added elements are designed to provide more information about the
placement and topology of the processors in the system to management
applications.

A demonstration of supported XML added by this patch:
<capabilities>
  <host>
    <topology>
      <cells num='3'>
        <cell id='0'>
          <cpus num='4'> <!-- this is node with Hyperthreading -->
            <cpu id='0' socket_id='0' core_id='0' siblings='0-1'/>
            <cpu id='1' socket_id='0' core_id='0' siblings='0-1'/>
            <cpu id='2' socket_id='0' core_id='1' siblings='2-3'/>
            <cpu id='3' socket_id='0' core_id='1' siblings='2-3'/>
          </cpus>
        </cell>
        <cell id='1'>
          <cpus num='4'> <!-- this is node with modules (Bulldozer) -->
            <cpu id='4' socket_id='0' core_id='2' siblings='4-5'/>
            <cpu id='5' socket_id='0' core_id='3' siblings='4-5'/>
            <cpu id='6' socket_id='0' core_id='4' siblings='6-7'/>
            <cpu id='7' socket_id='0' core_id='5' siblings='6-7'/>
          </cpus>
         </cell>
        <cell id='2'>
          <cpus num='4'> <!-- this is a normal multi-core node -->
            <cpu id='8' socket_id='1' core_id='0' siblings='8'/>
            <cpu id='9' socket_id='1' core_id='1' siblings='9'/>
            <cpu id='10' socket_id='1' core_id='2' siblings='10'/>
            <cpu id='11' socket_id='1' core_id='3' siblings='11'/>
          </cpus>
         </cell>
      </cells>
    </topology>
  </host>
</capabilities>

The socket_id field represents identification of the physical socket the
CPU is plugged in. This ID may not be identical to the physical socket
ID reported by the kernel.

The core_id identifies a core within a socket. Also this field may not
accurately represent physical ID's.

The core_id is guaranteed to be unique within a cell and a socket. There
may be duplicates between sockets. Only cores sharing core_id within one
cell and one socket can be considered as threads. Cores sharing core_id
within sparate cells are distinct cores.

The siblings field is a list of CPU id's the cpu id's the CPU is sibling
with - thus a thread. The list is in the cpuset format.

12 years agoschema: Make the cpuset type reusable across schema files
Peter Krempa [Fri, 18 Jan 2013 18:29:40 +0000 (19:29 +0100)]
schema: Make the cpuset type reusable across schema files

12 years agoS390: Enhance memballoon handling for virtio-s390
Viktor Mihajlovski [Fri, 11 Jan 2013 15:30:07 +0000 (16:30 +0100)]
S390: Enhance memballoon handling for virtio-s390

The way in that memory balloon suppression was handled for S390
is flawed for a number or reasons.
1. Just preventing the default balloon to be created in the case
   of VIR_ARCH_S390[X] is not sufficient. An explicit memballoon
   element in the guest definition will still be honored, resulting
   both in a -balloon option and the allocation of a PCI bus address,
   neither being supported.
2. Prohibiting balloon for S390 altogether at a domain_conf level
   is no good solution either as there's work in progress on the QEMU
   side to implement a virtio-balloon device, although in
   conjunction with a new machine type. Suppressing the balloon
   should therefore be done at the QEMU driver level depending
   on the present capabilities.

Therefore we remove the conditional suppression of the default
balloon in domain_conf.c.
Further, we are claiming the memballoon device for virtio-s390
during device address assignment to prevent it from being considered
as a PCI device.
Finally, we suppress the generation of the balloon command line option
if this is a virtio-s390 machine.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoqemu: Re-add driver unlock to qemuDomainSendKey
Viktor Mihajlovski [Wed, 23 Jan 2013 13:55:15 +0000 (14:55 +0100)]
qemu: Re-add driver unlock to qemuDomainSendKey

Should have been done in commit 56fd513 already, but was missed
due to oversight: qemuDomainSendKey didn't release the driver lock
in its cleanup section. This fixes an issue introduced by commit
8c5d2ba.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoconf: Fix usage of virBitmapParse
Peter Krempa [Wed, 23 Jan 2013 14:43:47 +0000 (15:43 +0100)]
conf: Fix usage of virBitmapParse

virNetworkObjUpdateParseFile used ',' as the termination character for
virBitmapParse. This would break if an non-contiguous range would be
parsed.

12 years agoutil: Fix docs for virBitmapParse
Peter Krempa [Wed, 23 Jan 2013 14:18:09 +0000 (15:18 +0100)]
util: Fix docs for virBitmapParse

This patch changes the name of the @sep argument to @terminator and
clarifies it's usage. This patch also explicitly documents that
whitespace can't be used as @terminator as it is skipped multiple times
in the implementation.

12 years agorng: Have colorful *.rng with editor
Osier Yang [Wed, 23 Jan 2013 15:03:17 +0000 (23:03 +0800)]
rng: Have colorful *.rng with editor

Just add the head line to let the editor know it's XML document.

12 years agoqemu_agent: Ignore expected EOFs
Michal Privoznik [Mon, 21 Jan 2013 10:52:44 +0000 (11:52 +0100)]
qemu_agent: Ignore expected EOFs

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

One of my previous patches (f2a4e5f176c408) tried to fix crashing
libvirtd on domain detroy. However, we need to copy pattern from
qemuProcessHandleMonitorEOF() instead of decrementing reference
counter. The rationale for this is, if qemu process is dying due
to domain being destroyed, we obtain EOF on both the monitor and
agent sockets. However, if the exit is expected, qemuProcessStop
is called, which cleans both agent and monitor sockets up. We
want qemuAgentClose() to be called iff the EOF is not expected,
so we don't leak an FD and memory. Moreover, there could be race
with qemuProcessHandleMonitorEOF() which could have already
closed the agent socket, in which case we don't want to do
anything.

12 years agovirbitmaptest: Resolve Coverity errors
John Ferlan [Tue, 22 Jan 2013 22:09:28 +0000 (17:09 -0500)]
virbitmaptest: Resolve Coverity errors

test1: Need to check for bitmap before using as well as free it properly
test2: need to check for bitsString2 before using it.

12 years agorpc: Revert Coverity tag message
John Ferlan [Tue, 22 Jan 2013 22:09:27 +0000 (17:09 -0500)]
rpc: Revert Coverity tag message

Turns out the fix for VIR_FREE made this particular Coverity tag
unnecessary, so I'm removing it.

12 years agolxc_process: Avoid passing NULL iface->iname
John Ferlan [Tue, 22 Jan 2013 22:09:26 +0000 (17:09 -0500)]
lxc_process: Avoid passing NULL iface->iname

A followon to commit id: 68dceb635 - if iface->iname is NULL, then
neither virNetDevOpenvswitchRemovePort() nor virNetDevVethDelete()
should be called.  Found by Coverity.

12 years agolxc_driver: Need to check for vm before calling virDomainUnlock(vm)
John Ferlan [Tue, 22 Jan 2013 22:09:25 +0000 (17:09 -0500)]
lxc_driver: Need to check for vm before calling virDomainUnlock(vm)

12 years agotests: Remove VIR_FREE() on static/stack buffer (der.data)
John Ferlan [Tue, 22 Jan 2013 22:09:24 +0000 (17:09 -0500)]
tests: Remove VIR_FREE() on static/stack buffer (der.data)

12 years agonodeinfo: Use sa_assert() instead of Coverity error tag
John Ferlan [Tue, 22 Jan 2013 22:09:23 +0000 (17:09 -0500)]
nodeinfo: Use sa_assert() instead of Coverity error tag

12 years agoFix nwfilter driver reload/shutdown handling when unprivileged
Daniel P. Berrange [Wed, 16 Jan 2013 13:12:16 +0000 (13:12 +0000)]
Fix nwfilter driver reload/shutdown handling when unprivileged

Although the nwfilter driver skips startup when running in a
session libvirtd, it did not skip reload or shutdown. This
caused errors to be reported when sending SIGHUP to libvirtd,
and caused an abort() in libdbus on shutdown due to trying
to remove a dbus filter that was never added

12 years agobuild: allow virObject to have no parent
Eric Blake [Tue, 22 Jan 2013 17:13:01 +0000 (10:13 -0700)]
build: allow virObject to have no parent

When building with static analysis enabled, we turn on attribute
nonnull checking.  However, this caused the build to fail with:

../../src/util/virobject.c: In function 'virObjectOnceInit':
../../src/util/virobject.c:55:40: error: null argument where non-null required (argument 1) [-Werror=nonnull]

Creation of the virObject class is the one instance where the
parent class is allowed to be NULL.  Making things conditional
will let us keep static analysis checking for all other .c file
callers, without breaking the build on this one exception.

* src/util/virobject.c: Define witness.
* src/util/virobject.h (virClassNew): Use it to force most callers
to pass non-null parameter.

12 years agoqemu: Support ram bar size for qxl devices
Alon Levy [Fri, 18 Jan 2013 18:36:36 +0000 (20:36 +0200)]
qemu: Support ram bar size for qxl devices

Adds a "ram" attribute globally to the video.model element, that changes
the resulting qemu command line only if video.type == "qxl".

<video>
  <model type='qxl' ram='65536' vram='65536' heads='1'/>
</video>

That attribute gets a default value of 64*1024. The schema is unchanged
for other video element types.

The resulting qemu command line change is the addition of

-global qxl-vga.ram_size=<ram>*1024

or

-global qxl.ram_size=<ram>*1024

For the main and secondary qxl devices respectively.

The default for the qxl ram bar is 64*1024 kilobytes (the same as the
default qxl vram bar size).

12 years agoviralloc: Adjust definition of VIR_FREE() for Coverity
John Ferlan [Tue, 22 Jan 2013 14:15:37 +0000 (09:15 -0500)]
viralloc: Adjust definition of VIR_FREE() for Coverity

The Coverity static analyzer was generating many false positives for the
unary operation inside the VIR_FREE() definition as it was trying to evaluate
the else portion of the "?:" even though the if portion was (1).

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoconf: Improve error messages if parsing of vCPU count fails
Peter Krempa [Tue, 22 Jan 2013 14:28:38 +0000 (15:28 +0100)]
conf: Improve error messages if parsing of vCPU count fails

12 years agoconf: Check if number of vCPUs fits in the storage variable
Peter Krempa [Tue, 22 Jan 2013 14:27:04 +0000 (15:27 +0100)]
conf: Check if number of vCPUs fits in the storage variable

The count of vCPUs for a domain is extracted as a usingned long variable
but is stored in a unsigned short. If the actual number was too large,
a faulty number was stored.

12 years agovirsh-domain: Refactor error paths for cmdCPUStats
Peter Krempa [Tue, 22 Jan 2013 11:17:18 +0000 (12:17 +0100)]
virsh-domain: Refactor error paths for cmdCPUStats

This patch fixes the following issues in the cpu-stats virsh command:

1) Renames label failed_params to no_memory to match coding style
2) Uses proper typed parameter cleanup in error paths to avoid leaks
3) Adds a ret variable and simplifies error labels
4) Changes error message to a slightly more descriptive one and gets rid
   of the newline at the end:

Before:
$ virsh cpu-stats tr
error: Failed to virDomainGetCPUStats()

error: Requested operation is not valid: domain is not running

After:
$ tools/virsh cpu-stats tr
error: Failed to retrieve CPU statistics for domain 'tr'
error: Requested operation is not valid: domain is not running

12 years agotests: Need to initialize 'test' properly on error path
John Ferlan [Tue, 22 Jan 2013 14:15:50 +0000 (09:15 -0500)]
tests: Need to initialize 'test' properly on error path

In the error path, the test buffer is free'd, but due to how the free
routine is written the 'test' buffer pointer does not return to the caller
as NULL and then the free'd buffer address is returned to the caller.

12 years agovirkeepalive: Remove erroneous VIR_FREE(msg)
John Ferlan [Tue, 22 Jan 2013 14:15:49 +0000 (09:15 -0500)]
virkeepalive: Remove erroneous VIR_FREE(msg)

The 'msg' free is handled via virNetMessageFree() already.

12 years agosecurity: Need to initialize 'sens'
John Ferlan [Tue, 22 Jan 2013 14:15:48 +0000 (09:15 -0500)]
security: Need to initialize 'sens'

It was possible to call VIR_FREE in cleanup prior to initialization

12 years agointerface: Need to initialize 'ifaces_list'
John Ferlan [Tue, 22 Jan 2013 14:15:47 +0000 (09:15 -0500)]
interface: Need to initialize 'ifaces_list'

It was possible to call VIR_FREE in cleanup prior to initialization

12 years agostorage: Need to initialize 'zerobuf'
John Ferlan [Tue, 22 Jan 2013 14:15:46 +0000 (09:15 -0500)]
storage: Need to initialize 'zerobuf'

It was possible to call VIR_FREE in cleanup prior to initialization.

12 years agovirsh: Need to intialize 'str'
John Ferlan [Tue, 22 Jan 2013 14:15:45 +0000 (09:15 -0500)]
virsh: Need to intialize 'str'

It was possible to call VIR_FREE in error prior to initialization.

12 years agolxc: Need to initialize 'dst'
John Ferlan [Tue, 22 Jan 2013 14:15:44 +0000 (09:15 -0500)]
lxc: Need to initialize 'dst'

It was possible to call VIR_FREE in cleanup prior to initialization

12 years agovirfile: Need to initialize 'looppath'
John Ferlan [Tue, 22 Jan 2013 14:15:43 +0000 (09:15 -0500)]
virfile: Need to initialize 'looppath'

It was possible to call VIR_FREE in cleanup prior to initialization.

12 years agocommandtest: Need to initialize 'errbuf'
John Ferlan [Tue, 22 Jan 2013 14:15:42 +0000 (09:15 -0500)]
commandtest: Need to initialize 'errbuf'

It was possible to call VIR_FREE in cleanup prior to initialization

12 years agovirnetdev: Need to initialize 'pciConfigAddr'
John Ferlan [Tue, 22 Jan 2013 14:15:41 +0000 (09:15 -0500)]
virnetdev: Need to initialize 'pciConfigAddr'

It was possible to call VIR_FREE in cleanup prior to initialization

12 years agovirnetsockettest: Need to initialize 'path'
John Ferlan [Tue, 22 Jan 2013 14:15:40 +0000 (09:15 -0500)]
virnetsockettest: Need to initialize 'path'

It was possible to call VIR_FREE in cleanup prior to initialization

12 years agovirnetserver: Need to initialize 'sigdata'
John Ferlan [Tue, 22 Jan 2013 14:15:39 +0000 (09:15 -0500)]
virnetserver: Need to initialize 'sigdata'

It was possible to call VIR_FREE in error prior to initialization

12 years agoconf: Need to initialize variables before VIR_FREE
John Ferlan [Tue, 22 Jan 2013 14:15:38 +0000 (09:15 -0500)]
conf: Need to initialize variables before VIR_FREE

Resolve a couple of instances where variables were not initialized
prior to potential VIR_FREE call in cleanup path.

12 years agouml: Avoid resource leak of event in umlInofityEvent
John Ferlan [Tue, 22 Jan 2013 14:20:06 +0000 (09:20 -0500)]
uml: Avoid resource leak of event in umlInofityEvent

If there was more than one inotify_event found in the read/while loop,
then only the last event found would have been queued.

12 years agofix typos in comments for VIR_DOMAIN_PROCESS_SIGNAL_{PWR,SYS}
Claudio Bley [Tue, 22 Jan 2013 15:55:35 +0000 (16:55 +0100)]
fix typos in comments for VIR_DOMAIN_PROCESS_SIGNAL_{PWR,SYS}

12 years agostorage: Add coverity[dead_error_condition] to avoid error
John Ferlan [Tue, 22 Jan 2013 14:41:04 +0000 (09:41 -0500)]
storage: Add coverity[dead_error_condition] to avoid error

The local redefinition of PED_PARTITION_PROTECTED results in the error
but is not a problem especially if the built code doesn't have the latest
definitions.

12 years agonetwork: Add coverity[leaked_handle] to ignore error
John Ferlan [Tue, 22 Jan 2013 14:41:03 +0000 (09:41 -0500)]
network: Add coverity[leaked_handle] to ignore error

On error, the 'tapfd' in networkStartNetworkVirtual() is synonymous
with 'macTapIfName' and will be closed in the appropriate error path.

12 years agoremote: Avoid coverity[leaked_storage] message.
John Ferlan [Tue, 22 Jan 2013 14:41:02 +0000 (09:41 -0500)]
remote: Avoid coverity[leaked_storage] message.

Upon successful return of virNetClientStreamEventAddCallback() the
allocated cbdata field will be freed by virNetClientStreamEventRemoveCallback()
as cbOpaque using the free function remoteStreamCallbackFree().

12 years agoqemu: Add coverity[negative_returns] tag
John Ferlan [Tue, 22 Jan 2013 14:41:01 +0000 (09:41 -0500)]
qemu: Add coverity[negative_returns] tag

This avoids "Event negative_returns: A negative constant "-1" is passed as
an argument to a parameter that cannot be negative.".  The called function
uses -1 to determine whether it needs to traverse all the hostdevs.

12 years agorpc: Add coverity[dead_error_begin] tag
John Ferlan [Tue, 22 Jan 2013 14:41:00 +0000 (09:41 -0500)]
rpc: Add coverity[dead_error_begin] tag

Coverity misses the nuance of VIR_FREE(privkey) setting privkey = NULL when
if (!(virFileExists(privkey))) is true and thus declares the code dead.

12 years agoxen: Add coverity[ptr_arith] and [sign_extension] tags
John Ferlan [Tue, 22 Jan 2013 14:40:59 +0000 (09:40 -0500)]
xen: Add coverity[ptr_arith] and [sign_extension] tags

The old cpu bitmap setting algorithm causes a couple of complaints which
have been tagged.

12 years agonodeinfo: Add coverity[dead_error_begin] and [returned_null] tags
John Ferlan [Tue, 22 Jan 2013 14:40:58 +0000 (09:40 -0500)]
nodeinfo: Add coverity[dead_error_begin] and [returned_null] tags

The use of switch statements inside a bounded for loop resulted in some
false positives regarding the "default:" label which cannot be reached
since each of the other case statements use the possible for loop values.
A [dead_error_begin] was added before the default label.

Commit id ebdbe25a adjusted the algorithm and the caller guarantees that
the 'params' will have a '_' in the name being searched. Add the [returned_null]
tag to the two instances.

12 years agolxc: Add coverity[dead_error_begin] tag in switch stmts
John Ferlan [Tue, 22 Jan 2013 14:40:57 +0000 (09:40 -0500)]
lxc: Add coverity[dead_error_begin] tag in switch stmts

The use of switch statements inside a bounded for loop resulted in some
false positives regarding the "default:" label which cannot be reached
since each of the other case statements use the possible for loop values.

12 years agoxend: Address some Coverity false positives
John Ferlan [Tue, 22 Jan 2013 14:40:56 +0000 (09:40 -0500)]
xend: Address some Coverity false positives

The various _for_i loops with both u.s.car and u.s.cdr were being reported
as COPY_PASTE errors by Coverity.  This just quiets those messages.

12 years agoselinux: Resolve resource leak using the default disk label
John Ferlan [Fri, 18 Jan 2013 14:34:13 +0000 (09:34 -0500)]
selinux: Resolve resource leak using the default disk label

Commit id a994ef2d1 changed the mechanism to store/update the default
security label from using disk->seclabels[0] to allocating one on the
fly. That change allocated the label, but never saved it.  This patch
will save the label. The new virDomainDiskDefAddSecurityLabelDef() is
a copy of the virDomainDefAddSecurityLabelDef().

12 years agoutil: Need to check child JSON allocation before use
John Ferlan [Fri, 18 Jan 2013 14:31:53 +0000 (09:31 -0500)]
util: Need to check child JSON allocation before use

12 years agoparallels: Need to handle virJSONValueObjectGetString error
John Ferlan [Fri, 18 Jan 2013 14:30:40 +0000 (09:30 -0500)]
parallels: Need to handle virJSONValueObjectGetString error

12 years agorpc: Remove unnecessary calls
John Ferlan [Fri, 18 Jan 2013 14:29:05 +0000 (09:29 -0500)]
rpc: Remove unnecessary calls

The code is not reachable as of commit id: bb85f229. Removed
virKeepAliveStop() and virObjectUnref() because 'ka' cannot be
anything but NULL at the cleanup label.

12 years agosecurity: Use virStrcpy to move the label
John Ferlan [Fri, 18 Jan 2013 14:27:05 +0000 (09:27 -0500)]
security: Use virStrcpy to move the label

12 years agoqemu: Forbid snapshot names starting with '.'
Peter Krempa [Mon, 21 Jan 2013 21:09:33 +0000 (22:09 +0100)]
qemu: Forbid snapshot names starting with '.'

Forbid the names to match the loading procedure of snapshots.

12 years agosafe{read,write}: Document usage with nonblocking FD
Michal Privoznik [Thu, 17 Jan 2013 07:35:53 +0000 (08:35 +0100)]
safe{read,write}: Document usage with nonblocking FD

Currently, whenever somebody calls saferead() on nonblocking FD
(safewrite() is totally interchangeable for purpose of this message)
he might get wrong return value. For instance, in the first iteration
some data is read. The number of bytes read is stored into local
variable 'nread'. However, in next iterations we can get -1 from
read() with errno == EAGAIN, in which case the -1 is returned despite
fact some data has already been read. So the caller gets confused.
Bare read() should be used for nonblocking FD.

12 years agodocs: Generate documentation for virTypedParams* APIs
Jiri Denemark [Mon, 21 Jan 2013 17:41:26 +0000 (18:41 +0100)]
docs: Generate documentation for virTypedParams* APIs

12 years agodocs: event.c source file was renamed as virevent.c
Jiri Denemark [Mon, 21 Jan 2013 17:40:28 +0000 (18:40 +0100)]
docs: event.c source file was renamed as virevent.c

12 years agospec: indent %if to make it easier to see conditions
Eric Blake [Wed, 9 Jan 2013 20:50:03 +0000 (13:50 -0700)]
spec: indent %if to make it easier to see conditions

Nested conditionals are hard to read if they are not indented.
We can't add arbitrary whitespace to everything in spec files,
but we CAN add spaces before %if and %define.  Use this trick,
plus a fancy sed script that rewrites a spec file into a C
file, so we can use cppi to keep our spec file nice.

For reference, the sed script converts code like:

|# RHEL-5 builds are client-only for s390, ppc
|%if 0%{?rhel} == 5
|    %ifnarch %{ix86} x86_64 ia64
|        %define client_only        1
|    %endif
|%endif

into the following for cppi:

|// # RHEL-5 builds are client-only for s390, ppc
|#if a // 0%{?rhel} == 5
|# if a // %{ix86} x86_64 ia64
|#  define client_only        1
|# endif
|#endif

and errors from 'make syntax-check' look like:
spec_indentation
cppi: mingw-libvirt.spec.in: line 130: not properly indented
maint.mk: incorrect preprocessor indentation

* libvirt.spec.in: Add some indentation to make it easier to follow
various conditionals.
* mingw-libvirt-spec.in: Likewise.
* cfg.mk (sc_spec_indentation): New syntax check to enforce it.

12 years agoqemu: Reject attempts to create snapshots with names containig '/'
Peter Krempa [Thu, 17 Jan 2013 13:07:10 +0000 (14:07 +0100)]
qemu: Reject attempts to create snapshots with names containig '/'

The snapshot name is used to create path to the definition save file.
When the name contains slashes the creation of the file fails. Reject
such names.

12 years agoqemu: Don't return success if creation of snapshot save file fails
Peter Krempa [Thu, 17 Jan 2013 13:04:01 +0000 (14:04 +0100)]
qemu: Don't return success if creation of snapshot save file fails

When the snapshot definition can't be saved, the
qemuDomainSnapshotCreate function succeeded without filling some of the
fields in the internal definition.

This patch removes the snapshot and returns failure if the XML file
cannot be written.