]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
12 years agonetwork: fix dnsmasq/radvd binding to IPv6 on recent kernels
Benjamin Cama [Wed, 26 Sep 2012 19:02:20 +0000 (21:02 +0200)]
network: fix dnsmasq/radvd binding to IPv6 on recent kernels

I hit this problem recently when trying to create a bridge with an IPv6
address on a 3.2 kernel: dnsmasq (and, further, radvd) would not bind to
the given address, waiting 20s and then giving up with -EADDRNOTAVAIL
(resp. exiting immediately with "error parsing or activating the config
file", without libvirt noticing it, BTW). This can be reproduced with (I
think) any kernel >= 2.6.39 and the following XML (to be used with
"virsh net-create"):

        <network>
          <name>test-bridge</name>
          <bridge name='testbr0' />
          <ip family='ipv6' address='fd00::1' prefix='64'>
          </ip>
        </network>

(it happens even when you have an IPv4, too)

The problem is that since commit [1] (which, ironically, was made to
“help IPv6 autoconfiguration”) the linux bridge code makes bridges
behave like “real” devices regarding carrier detection. This makes the
bridges created by libvirt, which are started without any up devices,
stay with the NO-CARRIER flag set, and thus prevents DAD (Duplicate
address detection) from happening, thus letting the IPv6 address flagged
as “tentative”. Such addresses cannot be bound to (see RFC 2462), so
dnsmasq fails binding to it (for radvd, it detects that "interface XXX
is not RUNNING", thus that "interface XXX does not exist, ignoring the
interface" (sic)). It seems that this behavior was enhanced somehow with
commit [2] by avoiding setting NO-CARRIER on empty bridges, but I
couldn't reproduce this behavior on my kernel. Anyway, with the “dummy
tap to set MAC address” trick, this wouldn't work.

To fix this, the idea is to get the bridge's attached device to be up so
that DAD can happen (deactivating DAD altogether is not a good idea, I
think). Currently, libvirt creates a dummy TAP device to set the MAC
address of the bridge, keeping it down. But even if we set this device
up, it is not RUNNING as soon as the tap file descriptor attached to it
is closed, thus still preventing DAD. So, we must modify the API a bit,
so that we can get the fd, keep the tap device persistent, run the
daemons, and close it after DAD has taken place. After that, the bridge
will be flagged NO-CARRIER again, but the daemons will be running, even
if not happy about the device's state (but we don't really care about
the bridge's daemons doing anything when no up interface is connected to
it).

Other solutions that I envisioned were:
      * Keeping the *-nic interface up: this would waste an fd for each
        bridge during all its life. May be acceptable, I don't really
        know.
      * Stop using the dummy tap trick, and set the MAC address directly
        on the bridge: it is possible since quite some time it seems,
        even if then there is the problem of the bridge not being
        RUNNING when empty, contrary to what [2] says, so this will need
        fixing (and this fix only happened in 3.1, so it wouldn't work
        for 2.6.39)
      * Using the --interface option of dnsmasq, but I saw somewhere
        that it's not used by libvirt for backward compatibility. I am
        not sure this would solve this problem, though, as I don't know
        how dnsmasq binds itself to it with this option.

This is why this patch does what's described earlier.

This patch also makes radvd start even if the interface is
“missing” (i.e. it is not RUNNING), as it daemonizes before binding to
it, and thus sometimes does it after the interface has been brought down
by us (by closing the tap fd), and then originally stops. This also
makes it stop yelling about it in the logs when the interface is down at
a later time.

[1]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=1faa4356a3bd89ea11fb92752d897cff3a20ec0e
[2]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=b64b73d7d0c480f75684519c6134e79d50c1b341

12 years agoFix regression starting QEMU instances without query-events
Daniel P. Berrange [Thu, 27 Sep 2012 14:25:16 +0000 (15:25 +0100)]
Fix regression starting QEMU instances without query-events

If QEMU reports CommandNotFound for the 'query-events' command,
we must treat that as success, returning a zero-length array
of events

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix compilation of legacy xen driver with Xen 4.2
Jim Fehlig [Wed, 26 Sep 2012 21:20:35 +0000 (15:20 -0600)]
Fix compilation of legacy xen driver with Xen 4.2

In Xen 4.2, xs.h is deprecated in favor of xenstore.h.  xs.h now
contains

#warning xs.h is deprecated use xenstore.h instead
#include <xenstore.h>

which fails compilation when warnings are treated as errors.

Introduce a configure-time check for xenstore.h and if found,
use it instead of xs.h.

12 years agoPass the "raw" log message to each virLogOutputFunc
Miloslav Trmač [Thu, 27 Sep 2012 11:45:33 +0000 (12:45 +0100)]
Pass the "raw" log message to each virLogOutputFunc

In addition to the preformatted text line, pass the raw message as well,
to allow the output functions to use a different output format.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSplit priority conversion from virLogOutputToSyslog
Miloslav Trmač [Thu, 27 Sep 2012 11:34:04 +0000 (12:34 +0100)]
Split priority conversion from virLogOutputToSyslog

Allow for the code converting from libvirt log levels to syslog
log levels to be reused.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMove command/event capabilities detection out of QEMU monitor code
Daniel P. Berrange [Thu, 13 Sep 2012 14:54:02 +0000 (15:54 +0100)]
Move command/event capabilities detection out of QEMU monitor code

The qemuMonitorSetCapabilities() API is used to initialize the QMP
protocol capabilities. It has since been abused to initialize some
libvirt internal capabilities based on command/event existance too.
Move the latter code out into qemuCapsProbeQMP() in the QEMU
capabilities source file instead

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove some unused includes in QEMU code
Daniel P. Berrange [Thu, 13 Sep 2012 14:36:56 +0000 (15:36 +0100)]
Remove some unused includes in QEMU code

The qemu monitor does not require qemu_conf.h, and the
qemu capabilities code actually wants bitmap.h

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetTargetArch() method for QMP query-target command
Daniel P. Berrange [Wed, 22 Aug 2012 09:48:41 +0000 (10:48 +0100)]
Add a qemuMonitorGetTargetArch() method for QMP query-target command

Add a new qemuMonitorGetTargetArch() method to support invocation
of the 'query-target' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetObjectProps() method for QMP device-list-properties command
Daniel P. Berrange [Wed, 22 Aug 2012 09:48:41 +0000 (10:48 +0100)]
Add a qemuMonitorGetObjectProps() method for QMP device-list-properties command

Add a new qemuMonitorGetObjectProps() method to support invocation
of the 'device-list-properties' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetObjectTypes() method for QMP qom-list-types command
Daniel P. Berrange [Wed, 22 Aug 2012 09:48:41 +0000 (10:48 +0100)]
Add a qemuMonitorGetObjectTypes() method for QMP qom-list-types command

Add a new qemuMonitorGetObjectTypes() method to support invocation
of the 'qom-list-types' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetEvents() method for QMP query-events command
Daniel P. Berrange [Wed, 22 Aug 2012 09:48:41 +0000 (10:48 +0100)]
Add a qemuMonitorGetEvents() method for QMP query-events command

Add a new qemuMonitorGetEvents() method to support invocation
of the 'query-events' JSON monitor command. No HMP equivalent
is required, since this will only be used when JSON is available

The existing qemuMonitorJSONCheckEvents() method is refactored
to use this new method

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetCommands() method for QMP query-commands command
Daniel P. Berrange [Wed, 22 Aug 2012 09:25:20 +0000 (10:25 +0100)]
Add a qemuMonitorGetCommands() method for QMP query-commands command

Add a new qemuMonitorGetCPUCommands() method to support invocation
of the 'query-commands' JSON monitor command. No HMP equivalent
is required, since this will only be used when JSON is available

The existing qemuMonitorJSONCheckCommands() method is refactored
to use this new method

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetCPUDefinitions method for QMP query-cpu-definitions command
Daniel P. Berrange [Mon, 20 Aug 2012 14:58:20 +0000 (15:58 +0100)]
Add a qemuMonitorGetCPUDefinitions method for QMP query-cpu-definitions command

Add a new qemuMonitorGetCPUDefinitions() method to support invocation
of the 'query-cpu-definitions' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetMachines() method for QMP query-machines command
Daniel P. Berrange [Wed, 15 Aug 2012 15:18:41 +0000 (16:18 +0100)]
Add a qemuMonitorGetMachines() method for QMP query-machines command

Add a new qemuMonitorGetMachines() method to support invocation
of the 'query-machines' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetVersion() method for QMP query-version command
Daniel P. Berrange [Wed, 15 Aug 2012 14:04:09 +0000 (15:04 +0100)]
Add a qemuMonitorGetVersion() method for QMP query-version command

Add a new qemuMonitorGetVersion() method to support invocation
of the 'query-version' JSON monitor command. No HMP equivalent
is provided, since this will only be used for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRefactor guest init to support qemu-system-i386 binary too
Daniel P. Berrange [Wed, 22 Aug 2012 16:59:39 +0000 (17:59 +0100)]
Refactor guest init to support qemu-system-i386 binary too

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove xenner support
Daniel P. Berrange [Wed, 22 Aug 2012 16:29:01 +0000 (17:29 +0100)]
Remove xenner support

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMake qemuCapsProbeMachineTypes & qemuCapsProbeCPUModels static
Daniel P. Berrange [Wed, 22 Aug 2012 16:23:00 +0000 (17:23 +0100)]
Make qemuCapsProbeMachineTypes & qemuCapsProbeCPUModels static

The qemuCapsProbeMachineTypes & qemuCapsProbeCPUModels methods
do not need to be invoked directly anymore. Make them static
and refactor them to directly populate the qemuCapsPtr object

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove probing of CPU models when launching QEMU guests
Daniel P. Berrange [Wed, 22 Aug 2012 15:28:55 +0000 (16:28 +0100)]
Remove probing of CPU models when launching QEMU guests

When launching a QEMU guest the binary is probed to discover
the list of supported CPU names. Remove this probing with a
simple lookup of CPU models in the qemuCapsPtr object. This
avoids another invocation of the QEMU binary during the
startup path.

As a nice benefit we can now remove all the nasty hacks from
the test suite which were done to avoid having to exec QEMU
on the test system. The building of the -cpu command line
can just rely on data we pre-populate in qemuCapsPtr.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove probing of machine types when canonicalizing XML
Daniel P. Berrange [Wed, 22 Aug 2012 15:25:57 +0000 (16:25 +0100)]
Remove probing of machine types when canonicalizing XML

When XML for a new guest is received, the machine type is
immediately canonicalized into the version specific name.
This involves probing QEMU for supported machine types.
Replace this probing with a lookup of the machine types
in the (hopefully cached) qemuCapsPtr object

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove probing of flags when launching QEMU guests
Daniel P. Berrange [Wed, 22 Aug 2012 14:39:54 +0000 (15:39 +0100)]
Remove probing of flags when launching QEMU guests

Remove all use of the existing APIs for querying QEMU
capability flags. Instead obtain a qemuCapsPtr object
from the global cache. This avoids the execution of
'qemu -help' (and related commands) when launching new
guests.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSwitch over to use cache for building QEMU capabilities
Daniel P. Berrange [Wed, 22 Aug 2012 13:37:05 +0000 (14:37 +0100)]
Switch over to use cache for building QEMU capabilities

When building up a virCapsPtr instance, the QEMU driver
was copying the list of machine types across from the
previous virCapsPtr instance, if the QEMU binary had not
changed. Replace this ad-hoc caching of data with use
of the new qemuCapsCache global cache.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemu capabilities cache manager
Daniel P. Berrange [Wed, 22 Aug 2012 12:54:13 +0000 (13:54 +0100)]
Add a qemu capabilities cache manager

Introduce a qemuCapsCachePtr object to provide a global cache
of capabilities for QEMU binaries. The cache auto-populates
on first request for capabilities about a binary, and will
auto-refresh if the binary has changed since a previous cache
was populated

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix handling of itanium arch name in QEMU driver
Daniel P. Berrange [Wed, 26 Sep 2012 12:48:31 +0000 (13:48 +0100)]
Fix handling of itanium arch name in QEMU driver

For historical compat we use 'itanium' as the arch name, so
if the QEMU binary suffix is 'ia64' we need to translate it

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix potential deadlock when agent is closed
Daniel P. Berrange [Wed, 26 Sep 2012 15:23:24 +0000 (16:23 +0100)]
Fix potential deadlock when agent is closed

If the qemuAgentClose method is called from a place which holds
the domain lock, it is theoretically possible to get a deadlock
in the agent destroy callback. This has not been observed, but
the equivalent code in the QEMU monitor destroy callback has seen
a deadlock.

Remove the redundant locking while unrefing the object and the
bogus assignment

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoUse size_t instead of int for virDomainDefPtr struct
Daniel P. Berrange [Wed, 26 Sep 2012 15:12:28 +0000 (16:12 +0100)]
Use size_t instead of int for virDomainDefPtr struct

Many parts of virDomainDefPtr were using 'int' variables as
array length counts. Replace all these with size_t and update
various format strings & API signatures to adapt

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix (rare) deadlock in QEMU monitor callbacks
Daniel P. Berrange [Wed, 26 Sep 2012 14:54:58 +0000 (15:54 +0100)]
Fix (rare) deadlock in QEMU monitor callbacks

Some users report (very rarely) seeing a deadlock in the QEMU
monitor callbacks

 Thread 10 (Thread 0x7fcd11e20700 (LWP 26753)):
 #0  0x00000030d0e0de4d in __lll_lock_wait () from /lib64/libpthread.so.0
 #1  0x00000030d0e09ca6 in _L_lock_840 () from /lib64/libpthread.so.0
 #2  0x00000030d0e09ba8 in pthread_mutex_lock () from /lib64/libpthread.so.0
 #3  0x00007fcd162f416d in virMutexLock (m=<optimized out>)
     at util/threads-pthread.c:85
 #4  0x00007fcd1632c651 in virDomainObjLock (obj=<optimized out>)
     at conf/domain_conf.c:14256
 #5  0x00007fcd0daf05cc in qemuProcessHandleMonitorDestroy (mon=0x7fcccc0029e0,
     vm=0x7fcccc00a850) at qemu/qemu_process.c:1026
 #6  0x00007fcd0db01710 in qemuMonitorDispose (obj=0x7fcccc0029e0)
     at qemu/qemu_monitor.c:249
 #7  0x00007fcd162fd4e3 in virObjectUnref (anyobj=<optimized out>)
     at util/virobject.c:139
 #8  0x00007fcd0db027a9 in qemuMonitorClose (mon=<optimized out>)
     at qemu/qemu_monitor.c:860
 #9  0x00007fcd0daf61ad in qemuProcessStop (driver=driver@entry=0x7fcd04079d50,
     vm=vm@entry=0x7fcccc00a850,
     reason=reason@entry=VIR_DOMAIN_SHUTOFF_DESTROYED, flags=flags@entry=0)
     at qemu/qemu_process.c:4057
 #10 0x00007fcd0db323cf in qemuDomainDestroyFlags (dom=<optimized out>,
     flags=<optimized out>) at qemu/qemu_driver.c:1977
 #11 0x00007fcd1637ff51 in virDomainDestroyFlags (
     domain=domain@entry=0x7fccf00c1830, flags=1) at libvirt.c:2256

At frame #10 we are holding the domain lock, we call into
qemuProcessStop() to cleanup QEMU, which triggers the monitor
to close, which invokes qemuProcessHandleMonitorDestroy() which
tries to obtain the domain lock again. This is a non-recursive
lock, hence hang.

Since qemuMonitorPtr is a virObject, the unref call in
qemuProcessHandleMonitorDestroy no longer needs mutex
protection. The assignment of priv->mon = NULL, can be
instead done by the caller of qemuMonitorClose(), thus
removing all need for locking.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDon't skip over socket label cleanup
Daniel P. Berrange [Wed, 26 Sep 2012 14:46:47 +0000 (15:46 +0100)]
Don't skip over socket label cleanup

If QEMU quits immediately after we opened the monitor it was
possible we would skip the clearing of the SELinux process
socket context

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMove most of qemuProcessKill into virProcessKillPainfully
Daniel P. Berrange [Wed, 26 Sep 2012 14:42:58 +0000 (15:42 +0100)]
Move most of qemuProcessKill into virProcessKillPainfully

In the cgroups APIs we have a virCgroupKillPainfully function
which does the loop sending SIGTERM, then SIGKILL and waiting
for the process to exit. There is similar functionality for
simple processes in qemuProcessKill, but it is tangled with
the QEMU code. Untangle it to provide a virProcessKillPainfuly
function

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDon't ignore return value of qemuProcessKill
Daniel P. Berrange [Thu, 27 Sep 2012 09:07:03 +0000 (10:07 +0100)]
Don't ignore return value of qemuProcessKill

When calling qemuProcessKill from the virDomainDestroy impl
in QEMU, do not ignore the return value. This ensures that
if QEMU fails to respond to SIGKILL, the caller will know
about the failure.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix deadlock in handling EOF in LXC monitor
Daniel P. Berrange [Wed, 26 Sep 2012 14:08:20 +0000 (15:08 +0100)]
Fix deadlock in handling EOF in LXC monitor

Depending on the scenario in which LXC containers exit, it is
possible for the EOF callback of the LXC monitor to deadlock
the driver.

  #0  0x00000038a0a0de4d in __lll_lock_wait () from /lib64/libpthread.so.0
  #1  0x00000038a0a09ca6 in _L_lock_840 () from /lib64/libpthread.so.0
  #2  0x00000038a0a09ba8 in pthread_mutex_lock () from /lib64/libpthread.so.0
  #3  0x00007f4bd9579d55 in virMutexLock (m=<optimized out>) at util/threads-pthread.c:85
  #4  0x00007f4bcacc7597 in lxcDriverLock (driver=0x7f4bc40c8290) at lxc/lxc_conf.h:81
  #5  virLXCProcessMonitorEOFNotify (mon=<optimized out>, vm=0x7f4bb4000b00) at lxc/lxc_process.c:581
  #6  0x00007f4bd9645c91 in virNetClientCloseLocked (client=client@entry=0x7f4bb4009e60)
      at rpc/virnetclient.c:554
  #7  0x00007f4bd96460f8 in virNetClientIOEventLoopPassTheBuck (thiscall=0x0, client=0x7f4bb4009e60)
      at rpc/virnetclient.c:1306
  #8  virNetClientIOEventLoopPassTheBuck (client=0x7f4bb4009e60, thiscall=0x0)
      at rpc/virnetclient.c:1287
  #9  0x00007f4bd96467a2 in virNetClientCloseInternal (reason=3, client=0x7f4bb4009e60)
      at rpc/virnetclient.c:589
  #10 virNetClientCloseInternal (client=0x7f4bb4009e60, reason=3) at rpc/virnetclient.c:561
  #11 0x00007f4bcacc4a82 in virLXCMonitorClose (mon=0x7f4bb4000a00) at lxc/lxc_monitor.c:201
  #12 0x00007f4bcacc55ac in virLXCProcessCleanup (reason=<optimized out>, vm=0x7f4bb4000b00,
      driver=0x7f4bc40c8290) at lxc/lxc_process.c:240
  #13 virLXCProcessStop (driver=0x7f4bc40c8290, vm=vm@entry=0x7f4bb4000b00,
      reason=reason@entry=VIR_DOMAIN_SHUTOFF_DESTROYED) at lxc/lxc_process.c:735
  #14 0x00007f4bcacc5bd2 in virLXCProcessAutoDestroyDom (payload=<optimized out>,
      name=0x7f4bb4003c80, opaque=0x7fff41af2df0) at lxc/lxc_process.c:94
  #15 0x00007f4bd9586649 in virHashForEach (table=0x7f4bc409b270,
      iter=iter@entry=0x7f4bcacc5ab0 <virLXCProcessAutoDestroyDom>, data=data@entry=0x7fff41af2df0)
      at util/virhash.c:514
  #16 0x00007f4bcacc52d7 in virLXCProcessAutoDestroyRun (driver=driver@entry=0x7f4bc40c8290,
      conn=conn@entry=0x7f4bb8000ab0) at lxc/lxc_process.c:120
  #17 0x00007f4bcacca628 in lxcClose (conn=0x7f4bb8000ab0) at lxc/lxc_driver.c:128
  #18 0x00007f4bd95e67ab in virReleaseConnect (conn=conn@entry=0x7f4bb8000ab0) at datatypes.c:114

When the driver calls virLXCMonitorClose, there is really no
need for the EOF callback to be invoked in this case, since
the caller can easily handle events itself. In changing this,
the monitor needs to take a deep copy of the callback list,
not merely a reference.

Also adds debug statements in various places to aid
troubleshooting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSupport Xen sysctl version 9 in Xen 4.2
Jim Fehlig [Wed, 26 Sep 2012 16:34:17 +0000 (10:34 -0600)]
Support Xen sysctl version 9 in Xen 4.2

Xen upstream c/s 24102:dc8e55c9 bumped the sysctl version to 9.
Support this sysctl version in the xen_hypervisor sub-driver.

12 years agonetwork: backend for virNetworkUpdate of interface list
Laine Stump [Fri, 21 Sep 2012 16:50:53 +0000 (12:50 -0400)]
network: backend for virNetworkUpdate of interface list

<interface> elements are location inside the <forward> element of a
network. There is only one <forward> element in any network, but it
might have many <interface> elements. This element only contains a
single attribute, "dev", which is the name of a network device
(e.g. "eth0").

Since there is only a single attribute, the modify operation isn't
supported for this "section", only add-first, add-last, and
delete. Also, note that it's not permitted to delete an interface from
the list while any guest is using it. We may later decide this is safe
(because removing it from the list really only excludes it from
consideration in future guest allocations of interfaces, but doesn't
affect any guests currently connected), but for now this limitation
seems prudent (of course when changing the persistent config, this
limitation doesn't apply, because the persistent config doesn't
support the concept of "in used").

Another limitation - it is also possible for the interfraces in this
list to be described by PCI address rather than netdev name. However,
I noticed while writing this function that we currently don't support
defining interfaces that way in config - the only method of getting
interfaces specified as <adress type='pci' ..../> instead of
<interface dev='xx'/> is to provide a <pf dev='yy'/> element under
forward, and let the entries in the interface list be automatically
populated with the virtual functions (VF) of the physical function
device given in <pg>.

As with the other virNetworkUpdate section backends, support for this
section is completely contained within a single static function, no
other changes were required, and only functions already called from
elsewhere within the same file are used in the new content for this
existing function (i.e., adding this code should not cause a new build
problem on any platform).

12 years agobuild: avoid older gcc warning
Eric Blake [Wed, 26 Sep 2012 17:16:36 +0000 (11:16 -0600)]
build: avoid older gcc warning

Jim Fehlig reported a compilation error with older gcc 4.3.4:

libvirt.c: In function 'virDomainGetEmulatorPinInfo':
libvirt.c:9111: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]

It looks like someone programmed via too much copy-and-paste.

* src/libvirt.c (virDomainGetEmulatorPinInfo): Multiplying by 1 is
a no-op, and thus will never overflow.

12 years agoparallels: don't give null pointers to virBitmapEqual
Dmitry Guryanov [Wed, 26 Sep 2012 12:30:02 +0000 (16:30 +0400)]
parallels: don't give null pointers to virBitmapEqual

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
12 years agoparallels: remove unneded code from parallelsDoCmdRun
Dmitry Guryanov [Wed, 26 Sep 2012 12:30:01 +0000 (16:30 +0400)]
parallels: remove unneded code from parallelsDoCmdRun

scmd was used for debugging and I forgot to remove it before
commit, so remove it now.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
12 years agoparallels: fix memory allocation
Dmitry Guryanov [Wed, 26 Sep 2012 12:30:00 +0000 (16:30 +0400)]
parallels: fix memory allocation

size of videos array must be increased.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
12 years agoparallels: remove unused member 'os' from parallelsDomObj
Dmitry Guryanov [Wed, 26 Sep 2012 12:29:59 +0000 (16:29 +0400)]
parallels: remove unused member 'os' from parallelsDomObj

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
12 years agoqemu: wait for SPICE to migrate
Michal Privoznik [Thu, 20 Sep 2012 09:15:31 +0000 (11:15 +0200)]
qemu: wait for SPICE to migrate

Recently, there have been some improvements made to qemu so it
supports seamless migration or something very close to it.
However, it requires libvirt interaction. Once qemu is migrated,
the SPICE server needs to send its internal state to the destination.
Once it's done, it fires SPICE_MIGRATE_COMPLETED event and this
fact is advertised in 'query-spice' output as well.
We must not kill qemu until SPICE server finishes the transfer.

12 years agoFix typo in header file comment
Daniel P. Berrange [Wed, 26 Sep 2012 09:38:26 +0000 (10:38 +0100)]
Fix typo in header file comment

s/mmeory/memory/ in libvirt.h.in

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDon't use O_TRUNC when opening QEMU logfiles
Daniel P. Berrange [Fri, 21 Sep 2012 09:37:53 +0000 (10:37 +0100)]
Don't use O_TRUNC when opening QEMU logfiles

SELinux wants all log files opened with O_APPEND. When
running non-root though, libvirtd likes to use O_TRUNC
to avoid log files growing in size indefinitely. Instead
of using O_TRUNC though, we can use O_APPEND and then
call ftruncate() which keeps SELinux happier.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify some redundant locking while unref'ing objects
Daniel P. Berrange [Mon, 24 Sep 2012 14:19:34 +0000 (15:19 +0100)]
Simplify some redundant locking while unref'ing objects

There is no need to hold the mutex when unref'ing
virObject instances

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove pointless virLXCProcessMonitorDestroy method
Daniel P. Berrange [Mon, 24 Sep 2012 14:13:10 +0000 (15:13 +0100)]
Remove pointless virLXCProcessMonitorDestroy method

Asynchronously setting priv->mon to NULL was pointless,
just remove the destroy callback entirely.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoConvert virLXCMonitor to use virObject
Daniel P. Berrange [Fri, 21 Sep 2012 14:09:42 +0000 (15:09 +0100)]
Convert virLXCMonitor to use virObject

Remove custom reference counting from virLXCMonitor, using
virObject instead

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMove virProcess{Kill,Abort,TranslateStatus} into virprocess.{c,h}
Daniel P. Berrange [Mon, 24 Sep 2012 17:10:37 +0000 (18:10 +0100)]
Move virProcess{Kill,Abort,TranslateStatus} into virprocess.{c,h}

Continue consolidation of process functions by moving some
helpers out of command.{c,h} into virprocess.{c,h}

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMove virProcessKill into virprocess.{h,c}
Daniel P. Berrange [Mon, 24 Sep 2012 16:54:51 +0000 (17:54 +0100)]
Move virProcessKill into virprocess.{h,c}

There are a number of process related functions spread
across multiple files. Start to consolidate them by
creating a virprocess.{c,h} file

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRename virCommandTranslateStatus to virProcessTranslateStatus
Daniel P. Berrange [Mon, 24 Sep 2012 17:01:26 +0000 (18:01 +0100)]
Rename virCommandTranslateStatus to virProcessTranslateStatus

The virCommand prefix was inappropriate because the API
does not use any virCommandPtr object instance. This
API closely related to waitpid/exit, so use virProcess
as the prefix

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRename virPid{Abort,Wait} to virProcess{Abort,Wait}
Daniel P. Berrange [Mon, 24 Sep 2012 16:59:31 +0000 (17:59 +0100)]
Rename virPid{Abort,Wait} to virProcess{Abort,Wait}

Change "Pid" to "Process" to align with the virProcessKill
API naming prefix

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRename virKillProcess to virProcessKill
Daniel P. Berrange [Mon, 24 Sep 2012 15:29:20 +0000 (16:29 +0100)]
Rename virKillProcess to virProcessKill

Changing naming to follow the convention of "object" followed
by "action"

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix start of containers with custom root filesystem
Daniel P. Berrange [Tue, 25 Sep 2012 15:24:10 +0000 (16:24 +0100)]
Fix start of containers with custom root filesystem

A prefix change to unmount the SELinux filesystem broke starting
of LXC containers with a custom root filesystem

12 years agoUpdate how to compile with -Werror
Doug Goldstein [Mon, 24 Sep 2012 23:44:34 +0000 (18:44 -0500)]
Update how to compile with -Werror

--enable-compile-warnings=error has been renamed to --enable-werror so
update the HACKING and the hacking.html to reflect that.

12 years agoqemu: Avoid holding the driver lock in trivial snapshot API's
Peter Krempa [Mon, 24 Sep 2012 20:31:35 +0000 (22:31 +0200)]
qemu: Avoid holding the driver lock in trivial snapshot API's

In most of the snapshot API's there's no need to hold the driver lock
the whole time.

This patch adds helper functions that get the domain object in functions
that don't require the driver lock and simplifies call paths from
snapshot-related API's.

12 years agostorage: Add timeout for iscsi volume's stable path discovery
Osier Yang [Mon, 24 Sep 2012 08:44:20 +0000 (16:44 +0800)]
storage: Add timeout for iscsi volume's stable path discovery

It might need some time till the LUN's stable path shows up on
initiator host, and although the time window is not foreseeable,
as a better than nothing fix, this patch adds timeout for the
stable path discovery process.

12 years agobuild: fix detection of netcf linked with libnl1
Christophe Fergeau [Wed, 19 Sep 2012 15:00:55 +0000 (17:00 +0200)]
build: fix detection of netcf linked with libnl1

Commit 9298bfbcb introduced code to detect if netcf is linked with
libnl1, and to prefer libnl1 over libnl3 when this is the case.
This behaviour can be disabled by setting LIBNL_CFLAGS to any value,
including the empty string.
However, configure.ac sets LIBNL_CFLAGS to "" before attempting
libnl detection, so the libnl1 detection code is always disabled.
This caused issues on my f17 system where netcf is linked with libnl1
but libvirt got built with libnl3.

This commit removes the setting of the LIBNL_* variables to "" as
this does not appear to be needed. After this change, libnl1 is
used when building libvirt on my f17 system.

12 years agonode_memory: Improve the docs
Osier Yang [Mon, 24 Sep 2012 15:08:31 +0000 (23:08 +0800)]
node_memory: Improve the docs

To declare that it's not recommended to use the tuning API while
the outside tuning program (such as ksmtuned under Linux) is running.

12 years agotests: test previous commit
Eric Blake [Mon, 24 Sep 2012 23:04:46 +0000 (17:04 -0600)]
tests: test previous commit

Add a test to avoid virCommand regressions.

* tests/commandtest.c (test8): Explicitly test env-var overrides.

12 years agocommand: Change virCommandAddEnv so it replaces existing environment variables.
Richard W.M. Jones [Mon, 24 Sep 2012 16:35:47 +0000 (17:35 +0100)]
command: Change virCommandAddEnv so it replaces existing environment variables.

12 years agocommand: Move environ-adding code to common function virCommandAddEnv.
Richard W.M. Jones [Mon, 24 Sep 2012 16:30:18 +0000 (17:30 +0100)]
command: Move environ-adding code to common function virCommandAddEnv.

This is just code motion.  The semantics of the code should be
identical after this change.

12 years agoRelease of libvirt-0.10.2
Daniel Veillard [Mon, 24 Sep 2012 04:06:05 +0000 (12:06 +0800)]
Release of libvirt-0.10.2

* configure.ac docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: update from transifex and regenerate

12 years agoFix another rpmbuild failure
Daniel Veillard [Mon, 24 Sep 2012 04:41:56 +0000 (12:41 +0800)]
Fix another rpmbuild failure

without systemd we should not try to package the non-installed
%{_sysconfdir}/rc.d/init.d/libvirtd

12 years agoFix an rpmbuild failure
Daniel Veillard [Mon, 24 Sep 2012 04:37:02 +0000 (12:37 +0800)]
Fix an rpmbuild failure

$RPM_BUILD_ROOT was embedded in /etc/rc.d/init.d/libvirt-guests

12 years agoDon't install legacy initscripts at same time as systemd ones
Daniel P. Berrange [Fri, 21 Sep 2012 10:24:31 +0000 (11:24 +0100)]
Don't install legacy initscripts at same time as systemd ones

The Fedora policies don't want us installing the legacy initscripts
in parallel with the systemd ones, so switch to only install the
systemd unit

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agonetwork: log error for unknown virNetworkUpdate command codes
Laine Stump [Fri, 21 Sep 2012 16:11:51 +0000 (12:11 -0400)]
network: log error for unknown virNetworkUpdate command codes

Every level of the code for virNetworkUpdate was assuming that some
other level was checking for validity of the "command" arg, but none
actually were. The result was that an invalid command code would do
nothing, but also report success.

Since the command code isn't used until the very lowest level backend
functions, that's where I put the check. I made a separate one-line
function to log the error. The compiler would have combined the
identical strings used by multiple calls if I'd just called
virReportError directly in each location, but sending them all to the
same string in the source guards against inadvertant divergence (which
would lead to extra work for translators.)

12 years agonetwork: make virNetworkObjUpdate error detection/recovery better
Laine Stump [Fri, 21 Sep 2012 18:48:17 +0000 (14:48 -0400)]
network: make virNetworkObjUpdate error detection/recovery better

1) virNetworkObjUpdate should be an all or none operation, but in the
case that we want to update both the live state and persistent config
versions of the network, it was committing the update to the live
state before starting to update the persistent config. If update of
the persistent config failed, we would leave with things in an
inconsistent state - the live state would be updated (even though an
error was returned), but persistent config unchanged.

This patch changed virNetworkObjUpdate to use a separate pointer for
each copy of the virNetworkDef, and not commit either of them in the
virNetworkObj until both live and config parts of the update have
successfully completed.

2) The parsers for various pieces of the virNetworkDef have all sorts
of subtle limitations on them that may not be known by the
Update[section] function, making it possible for one of these
functions to make a modification directly to the object that may not
pass the scrutiny of a subsequent parse. But normally another parse
wouldn't be done on the data until the *next* time the object was
updated (which could leave the network definition in an unusable
state).

Rather than fighting the losing battle of trying to duplicate all the
checks from the parsers into the update functions as well, the more
foolproof solution to this is to simply do an extra
virNetworkDefCopy() operation on the updated networkdef -
virNetworkDefCopy() does a virNetworkFormat() followed by a
virNetworkParseString(), so it will do all the checks we need. If this
fails, then we don't commit the changed def.

12 years agonetwork: don't "refresh" iptables rules on rule-less networks
Laine Stump [Fri, 21 Sep 2012 19:28:11 +0000 (15:28 -0400)]
network: don't "refresh" iptables rules on rule-less networks

The bridge driver implementation of virNetworkUpdate() removes and
re-adds iptables rules any time a network has an <ip>, <forward>, or
<forward>/<interface> element updated. There are some types of
networks that have those elements and yet have no iptables rules
associated with them, and unfortunately the functions that remove/add
iptables rules don't check the type of network before attempting to
remove/add the rules, sometimes leading to an erroneous failure of the
entire update operation.

Under normal circumstances I would refactor the lower level functions
to be more robust, but to avoid code churn as much as possible, I've
just added extra checks directly to networkUpdate().

12 years agoDrop unused return value of virLogOutputFunc
Miloslav Trmač [Thu, 20 Sep 2012 18:24:00 +0000 (20:24 +0200)]
Drop unused return value of virLogOutputFunc

Nothing uses the return value, and creating it requries otherwise
unnecessary strlen () calls.

This cleanup is conceptually independent from the rest of the series
(although the later patches won't apply without it).  This just seems
a good opportunity to clean this up, instead of entrenching the unnecessary
return value in the virLogOutputFunc instance that will be added in this
series.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
12 years agoRemove redundant lines in src/qemu/qemu_driver.c
Tang Chen [Fri, 21 Sep 2012 09:50:10 +0000 (17:50 +0800)]
Remove redundant lines in src/qemu/qemu_driver.c

maxcpu and hostcpus are defined and calculated in qemudDomainPinVcpuFlags()
and qemudDomainPinEmulator(), but never used. So remove them including nodeinfo.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
12 years agoAdd <seclabel> to character devices.
Richard W.M. Jones [Thu, 20 Sep 2012 13:16:17 +0000 (14:16 +0100)]
Add <seclabel> to character devices.

This allows the user to control labelling of each character device
separately (the default is to inherit from the VM).

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
12 years agoMake virSecurityDeviceLabelDefParseXML into generic device <seclabel> parser.
Richard W.M. Jones [Thu, 20 Sep 2012 13:58:12 +0000 (14:58 +0100)]
Make virSecurityDeviceLabelDefParseXML into generic device <seclabel> parser.

This is just code motion, allowing us to reuse the same function to
parse the <seclabel> from character devices too.

However it also fixes a possible segfault in the original code if
VIR_ALLOC_N returns an error and the cleanup code (at the error:
label) tries to iterate over the unallocated array (thanks Michal
Privoznik for spotting this).

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
12 years agoqemu: Fix failure path in disk hotplug
Jiri Denemark [Thu, 20 Sep 2012 20:28:35 +0000 (22:28 +0200)]
qemu: Fix failure path in disk hotplug

Disk hotplug is a two phase action: qemuMonitorAddDrive followed by
qemuMonitorAddDevice. When the first part succeeds but the second one
fails, we need to rollback the drive addition.

12 years agolocking: Remove README file in favor of internals/locking.html
Jiri Denemark [Mon, 17 Sep 2012 13:18:57 +0000 (15:18 +0200)]
locking: Remove README file in favor of internals/locking.html

The README file seems to be a leftover from some previous version of
locking driver. It is not consistent with what the code does nor is it
consistent with existing documentation in internals/locking.html.

12 years agoImprove some debugging log messages in LXC mount setup
Daniel P. Berrange [Tue, 18 Sep 2012 11:27:07 +0000 (12:27 +0100)]
Improve some debugging log messages in LXC mount setup

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure existing selinux mount is removed before mounting new one in LXC
Daniel P. Berrange [Tue, 18 Sep 2012 11:25:56 +0000 (12:25 +0100)]
Ensure existing selinux mount is removed before mounting new one in LXC

Some kernel versions (at least RHEL-6 2.6.32) do not let you over-mount
an existing selinuxfs instance with a new one. Thus we must unmount the
existing instance inside our namespace.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix crash accessing a NULL URI when looking up auth credentials
Daniel P. Berrange [Wed, 12 Sep 2012 15:40:08 +0000 (16:40 +0100)]
Fix crash accessing a NULL URI when looking up auth credentials

When auto-probing hypervisor drivers, the conn->uri field will
initially be NULL. Care must be taken not to access members
when doing auth lookups in the config file

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove a redundant line in src/qemu/qemu_driver.c
Tang Chen [Fri, 21 Sep 2012 03:50:08 +0000 (11:50 +0800)]
Remove a redundant line in src/qemu/qemu_driver.c

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
12 years agonetwork: backend for virNetworkUpdate of portgroups
Laine Stump [Fri, 21 Sep 2012 02:25:41 +0000 (22:25 -0400)]
network: backend for virNetworkUpdate of portgroups

portgroup elements are located in the toplevel of <network>
objects. There can be multiple <portgroup> elements, and they each
have a unique name attribute.

Add, delete, and modify are all supported for portgroup. When deleting
a portgroup, only the name must be specified in the provided xml - all
other attributes and subelements are ignored for the purposes of
matching and existing portgroup.

The bridge driver and virsh already know about the portgroup element,
so providing this backend should cause the entire stack to work. Note
that in the case of portgroup, there is no external daemon based on
the portgroup config, so nothing must be restarted.

It is important to note that guests make a copy of the appropriate
network's portgroup data when they are started, so although an updated
portgroup's configuration will have an affect on new guests started
after the cahange, existing guests won't magically have their
bandwidth changed, for example. If something like that is desired, it
will take a lot of redesign work in the way network devices are setup
(there is currently no link from the network back to the individual
interfaces using it, much less from a portgroup within a network back
to the individual interfaces).

12 years agonetwork: backend for virNetworkUpdate of dhcp range
Laine Stump [Fri, 21 Sep 2012 02:25:40 +0000 (22:25 -0400)]
network: backend for virNetworkUpdate of dhcp range

The dhcp range element is contained in the <dhcp> element of one of a
network's <ip> elements. There can be multiple <range>
elements. Because there are only two attributes (start and end), and
those are exactly what you would use to identify a particular range,
it doesn't really make sense to modify an existing element, so
VIR_NETWORK_UPDATE_COMMAND_MODIFY isn't supported for this section,
only ADD_FIRST, ADD_LAST, and DELETE.

Since virsh already has support for understanding all the defined
sections, this new backend is automatically supported by virsh. You
would use it like this:

  virsh net-update mynet add ip-dhcp-range \
        "<range start='1.2.3.4' end='1.2.3.20'/>" --live --config

The bridge driver also already supports all sections, so it's doing
the correct thing in this case as well - since the dhcp range is
placed on the dnsmasq commandline, the bridge driver recreates the
dnsmasq commandline, and re-runs dnsmasq whenever a range is
added/deleted (and AFFECT_LIVE is specified in the flags).

12 years agovirsh: new net-update command
Laine Stump [Wed, 19 Sep 2012 11:38:43 +0000 (07:38 -0400)]
virsh: new net-update command

This command uses the new virNetworkUpdate() API to modify an existing
network definition, and optionally have those modifications take
effect immediately without restarting the network.

An example usage:

  virsh net-update mynet add-last ip-dhcp-host \
   "<host mac='00:11:22:33:44:55' ip='192.168.122.45'/>" \
   --live --config

If you like, you can instead put the xml into a file, and call like
this:

  virsh net-update mynet add ip-dhcp-host /tmp/myxml.xml
   --live --config

virsh will autodetect whether the argument is itself an xml element,
or if it's a file, by looking at the first character - the first
character of an xml element is always "<", and the first character of
a file is almost always *not* "<" (in the rare case that it is, the
user could specify "./<filename...").

A --parent-index option is also available (to give the index within a
list of parent objects, e.g. the index of the parent <ip> element when
updating ip-dhcp-host elements), but is optional and at least for now
will probably be used rarely.

--live, --config, and --current options - if you specify --live, only
the live state of the network will be updated. If you also specify
--config, then the persistent configuration will also be updated;
these two commands can be given separately, or both together. If you
don't specify either (you can optionally specify "--current" for the
same effect), then the "current" config will be updated (i.e. if the
network is active, then only its live config is affected, but if the
network is inactive, only the persistent config is affected).

12 years agodocs: fix typo in filesystem docs
Eric Blake [Fri, 21 Sep 2012 01:41:13 +0000 (19:41 -0600)]
docs: fix typo in filesystem docs

Noticed this by reading the page.  It would be so much nicer if our
tools could automatically flag things like this as part of 'make'.

* docs/formatdomain.html.in: Remove extra '>'.

12 years agomaint: fix up copyright notice inconsistencies
Eric Blake [Thu, 20 Sep 2012 22:30:55 +0000 (16:30 -0600)]
maint: fix up copyright notice inconsistencies

https://www.gnu.org/licenses/gpl-howto.html recommends that
the 'If not, see <url>.' phrase be a separate sentence.

* tests/securityselinuxhelper.c: Remove doubled line.
* tests/securityselinuxtest.c: Likewise.
* globally: s/;  If/.  If/

12 years agodoc: include article about libvirt+audit in relatedlinks.html
Marcelo Cerri [Thu, 20 Sep 2012 21:31:41 +0000 (18:31 -0300)]
doc: include article about libvirt+audit in relatedlinks.html

This patch adds to relatedlinks.html a link to an article about libvirt
describing how the Linux audit subsystem can be used to track qemu
guest's life-cycle.

12 years agoEnsure autogen.sh exists if bootstrap fails
Daniel P. Berrange [Wed, 19 Sep 2012 17:45:24 +0000 (18:45 +0100)]
Ensure autogen.sh exists if bootstrap fails

If any of the bootstrap tasks (autoconf/automake/etc) failed,
autogen.sh carried on running any pre-existing configure anyway.
Use 'set -e' to ensure autogen.sh immediately exists on error.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agotests: Add tests for dump-core option
Martin Kletzander [Wed, 15 Aug 2012 08:16:36 +0000 (10:16 +0200)]
tests: Add tests for dump-core option

12 years agoqemu: add support for dump-guest-core option
Martin Kletzander [Wed, 15 Aug 2012 07:59:24 +0000 (09:59 +0200)]
qemu: add support for dump-guest-core option

The "dump-guest-core' option is new option for the machine type
(-machine pc,dump-guest-core) that controls whether the guest memory
will be marked as dumpable.

While testing this, I've found out that the value for the '-M' options
is not parsed correctly when additional parameters are used. However,
when '-machine' is used for the same options, it gets parsed as
expected. That's why this patch also modifies the parsing and creating
of the command line, so both '-M' and '-machine' are recognized. In
QEMU's help there is only mention of the 'machine parameter now with
no sign of the older '-M'.

12 years agoAdd support for limiting guest coredump
Martin Kletzander [Wed, 15 Aug 2012 07:51:58 +0000 (09:51 +0200)]
Add support for limiting guest coredump

Sometimes when guest machine crashes, coredump can get huge due to the
guest memory. This can be limited using madvise(2) system call and is
being used in QEMU hypervisor. This patch adds an option for configuring
that in the domain XML and related documentation.

12 years agoQEMU Tests for reboot-timeout
Martin Kletzander [Tue, 18 Sep 2012 10:32:07 +0000 (12:32 +0200)]
QEMU Tests for reboot-timeout

12 years agoqemu: Add support for reboot-timeout
Martin Kletzander [Tue, 18 Sep 2012 10:31:30 +0000 (12:31 +0200)]
qemu: Add support for reboot-timeout

This patch adds support for "-boot reboot-timeout=rb_time" that is
added in QEMU.

12 years agoAdd support for reboot-timeout
Martin Kletzander [Tue, 18 Sep 2012 10:30:52 +0000 (12:30 +0200)]
Add support for reboot-timeout

Whenever the guest machine fails to boot, new parameter (reboot-timeout)
controls whether it should reboot and after how many ms it should do so.

Docs included.

12 years agosecurity: Don't ignore errors when parsing DAC security labels
Peter Krempa [Tue, 18 Sep 2012 10:20:41 +0000 (12:20 +0200)]
security: Don't ignore errors when parsing DAC security labels

The DAC security driver silently ignored errors when parsing the DAC
label and used default values instead.

With a domain containing the following label definition:

<seclabel type='static' model='dac' relabel='yes'>
  <label>sdfklsdjlfjklsdjkl</label>
</seclabel>

the domain would start normaly but the disk images would be still owned
by root and no error was displayed.

This patch changes the behavior if the parsing of the label fails (note
that a not present label is not a failure and in this case the default
label should be used) the error isn't masked but is raised that causes
the domain start to fail with a descriptive error message:

virsh #  start tr
error: Failed to start domain tr
error: internal error invalid argument: failed to parse DAC seclabel
'sdfklsdjlfjklsdjkl' for domain 'tr'

I also changed the error code to "invalid argument" from "internal
error" and tweaked the various error messages to contain correct and
useful information.

12 years agosimplify xenXMDomainPinVcpu function
liguang [Thu, 20 Sep 2012 05:31:57 +0000 (13:31 +0800)]
simplify xenXMDomainPinVcpu function

supersede tedious statements getting cpu bitmap
from parameter cpumap by virBitmapNewData function

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
12 years agoCleanup of domain_conf sentinels
Martin Kletzander [Wed, 19 Sep 2012 07:16:58 +0000 (09:16 +0200)]
Cleanup of domain_conf sentinels

This patch removes all commas after *_LAST sentinels in the enums.

12 years agoqemu: Cleanup boot parameter building
Martin Kletzander [Tue, 18 Sep 2012 09:38:18 +0000 (11:38 +0200)]
qemu: Cleanup boot parameter building

This patch cleans up building the "-boot" parameter and while on that
fixes one inconsistency by modifying these things:

 - I completed the unfinished virDomainBootMenu enum by specifying
   LAST, declaring it and also declaring the TypeFromString and
   TypeToString parameters.
 - Previously mentioned TypeFromString and TypeToString are used when
   parsing the XML.
 - Last, but not least, visible change is that the "-boot" parameter
   is built and parsed properly:
    - The "order=" prefix is used only when additional parameters are
      used (menu, etc.).
    - It's rewritten in a way that other parameters can be added
      easily in the future (used in following patch).
    - The "order=" parameter is properly parsed regardless to where it
      is placed in the string (e.g. "menu=on,order=nc").
    - The "menu=" parameter (and others in the future) are created
      when they should be (i.e. even when bootindex is supported and
      used, but not when bootloader is selected).

12 years agoqemu: Transition domain to PAUSED after 'stop' command
Michal Privoznik [Wed, 19 Sep 2012 09:23:11 +0000 (11:23 +0200)]
qemu: Transition domain to PAUSED after 'stop' command

Currently, we mark domain PAUSED (but not emit an event)
just before we issue 'stop' on monitor; This command can
take ages to finish, esp. when domain's doing a lot of
IO - users can enforce qemu to open files with O_DIRECT
which doesn't return from write() until data reaches the
block device. Having said that, we report PAUSED even if
domain is not paused yet.

12 years agonetwork: fix element size / length in memmove
Laine Stump [Wed, 19 Sep 2012 22:45:58 +0000 (18:45 -0400)]
network: fix element size / length in memmove

The memmove to move elements in the dhcp hosts array when inserting
and deleting items was mistakenly basing the length of the copy on the
size of a virNetworkDHCPHostDefPtr rather than virNetworkDHCPHostDef,
with the expected disastrous results.

The memmove to delete an entry commits two errors - along with the
size of each element being wrong, it also omits some required
parentheses.

12 years agovirsh: Move daemon to misc since its not a network
Doug Goldstein [Sun, 9 Sep 2012 22:07:27 +0000 (17:07 -0500)]
virsh: Move daemon to misc since its not a network

Move the 'Daemon' entry to the Miscellaneous section since its not a
networking driver or component.

12 years agonetwork: fix incorrect VIR_NETWORK_UPDATE_COMMAND_* values
Laine Stump [Wed, 19 Sep 2012 11:40:30 +0000 (07:40 -0400)]
network: fix incorrect VIR_NETWORK_UPDATE_COMMAND_* values

These enums originally were put into the flags for virNetworkUpdate,
and when they were moved into their own enum, the numbers weren't
appropriately changed, causing the commands to start with value 2
instead of 1. This causes problems for things like ENUM_IMPL, which
wants a string for every value in the requested range, including those
not used in the enum.

12 years agobuild: define WITH_INTERFACE for the driver
Doug Goldstein [Tue, 18 Sep 2012 01:27:06 +0000 (20:27 -0500)]
build: define WITH_INTERFACE for the driver

Based exclusively on work by Eric Blake in a patch posted with the same
subject. However some modifications related to comments and my plans to
add another backend.

Added WITH_INTERFACE as the only automake variable deciding whether to
build the driver and using WITH_NETCF to identify that we're wanting to
use the netcf library as the backend.

* configure.ac: Added with_interface
* src/interface/netcf_driver.c: Renamed..
* src/interface/interface_backend_netcf.c: ..to this to match storage.
* src/interface/netcf_driver.h: Renamed..
* src/interface/interface_driver.h: ..to this.
* daemon/Makefile.am: Respect WITH_INTERFACE and WITH_NETCF.
* libvirt.spec.in: Add RPM support for --with-interface

12 years agovirsh: Rename QEmu to QEMU to match upstream
Doug Goldstein [Sun, 9 Sep 2012 22:07:28 +0000 (17:07 -0500)]
virsh: Rename QEmu to QEMU to match upstream

Match upstream's naming of QEMU. There was a notice on the ML that said
the preferred spelling was QEMU a while back.

12 years agovirsh: Fix resource leaks when editing files.
Peter Krempa [Wed, 19 Sep 2012 09:31:44 +0000 (11:31 +0200)]
virsh: Fix resource leaks when editing files.

The cleanup path in virsh-edit helper was never reached when the edit
was successful leaking the document in memory as well as the temporary
file.

12 years agoutil: don't print free'd dmidecode path
Eric Blake [Tue, 18 Sep 2012 23:34:25 +0000 (17:34 -0600)]
util: don't print free'd dmidecode path

The path was freed before printing the error message, resulting in:
error : virSysinfoRead:773 : internal error Failed to execute command
(null)
But virCommandRun already gives a better error message.

* src/util/sysinfo.c (virSysinfoRead): Avoid overwriting error.