]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

12 years agobuild: avoid unused symbol
Eric Blake [Tue, 18 Sep 2012 23:09:00 +0000 (17:09 -0600)]
build: avoid unused symbol

Commit f36309d added an export with no matching implementation;
probably a misspelling of an earlier version of the final addition
of virNetworkObjSetDefTransient.

* src/libvirt_private.syms (network_conf.h): Drop bogus
virNetworkSetDefTransient.

12 years agobuild: fix nodeinfo build on non-Linux platforms
Eric Blake [Tue, 18 Sep 2012 23:04:50 +0000 (17:04 -0600)]
build: fix nodeinfo build on non-Linux platforms

Commit aaa8ab3 added new static functions that are only used on Linux;
but commit 22acfdc didn't go far enough to fix compiler issues.

* src/nodeinfo.c (nodeSetMemoryParameterValue)
(nodeGetMemoryParameterValue): Conditionally compile based on use.

12 years agobitmap: fix problems in previous commit
Eric Blake [Tue, 18 Sep 2012 23:20:03 +0000 (17:20 -0600)]
bitmap: fix problems in previous commit

Commit ee3d3893 missed the fact that (unsigned char)<<(int)
is truncated to int, and therefore failed for any bitmap data
longer than four bytes.

Also, I failed to run 'make syntax-check' on my commit 4bba6579;
for whatever odd reason, ffs lives in a different header than ffsl.

* src/util/bitmap.c (virBitmapNewData): Use correct shift type.
(includes): Glibc (and therefore gnulib) decided ffs is in
<strings.h>, but ffsl is in <string.h>.
* tests/virbitmaptest.c (test5): Test it.

12 years agobuild: avoid non-portable byte-swapping
Eric Blake [Tue, 18 Sep 2012 19:53:15 +0000 (13:53 -0600)]
build: avoid non-portable byte-swapping

Commit 0fc89098 used functions only available on glibc, completely
botched 32-bit environments, and risked SIGBUS due to unaligned
memory access on platforms that aren't as forgiving as x86_64.

* bootstrap.conf (gnulib_modules): Import ffsl.
* src/util/bitmap.c (includes): Use <strings.h> for ffsl.
(virBitmapNewData, virBitmapToData): Avoid 64-bit assumptions and
non-portable functions.

12 years agoFix minor details not only in apic eoi
Martin Kletzander [Tue, 18 Sep 2012 09:40:52 +0000 (11:40 +0200)]
Fix minor details not only in apic eoi

The introduction of APIC EOI patches had a few little details that
could look better, so this patch fixes that and one more place in the
file as well (same problem).

12 years agosecret: Fix error for private secrets
Martin Kletzander [Tue, 18 Sep 2012 10:01:46 +0000 (12:01 +0200)]
secret: Fix error for private secrets

When trying to get the value of a private secret, the code used
'operation denied' error. That error is specified as a error for
read-only connections trying to perform denied operation. The
following error seems more accurate.

To compare the difference:
 - BEFORE
error: operation secret is private forbidden for read only access

 - AFTER
error: Invalid secret: secret is private

12 years agovirNetDevBandwidthClear: Improve error handling
Martin Kletzander [Tue, 18 Sep 2012 10:01:18 +0000 (12:01 +0200)]
virNetDevBandwidthClear: Improve error handling

Two changes are introduced in this patch:

 - The first change removes ATTRIBUTE_RETURN_CHECK from
   virNetDevBandwidthClear, because it was called with ignore_value
   always, anyway. The function is used even when it's not necessary
   to call it, just for cleanup purposes.

 - The second change is added ignoring of the command's exit status,
   since it may report an error even when run just as "to be sure we
   clean up" function. No libvirt errors are suppresed by this.

12 years agosyntax-check: fix run.in
Martin Kletzander [Tue, 18 Sep 2012 11:59:53 +0000 (13:59 +0200)]
syntax-check: fix run.in

Two more problems in "run.in" made the syntax-check fail.

12 years agoAdhere to copyright_address check
Guido Günther [Tue, 18 Sep 2012 11:07:26 +0000 (13:07 +0200)]
Adhere to copyright_address check

to fix "make syntax-check"

Found by http://honk.sigxcpu.org:8001/job/libvirt-syntax-check/

12 years agoAdd a ./run script for running programs from the local directory.
Richard W.M. Jones [Fri, 14 Sep 2012 09:08:54 +0000 (10:08 +0100)]
Add a ./run script for running programs from the local directory.

With this script you can run libvirt programs without needing to
install them first.  You just have to do for example:

  ./run ./tools/virsh [args ...]

If you are already in the tools/ subdirectory, then the following
command will also work:

  ../run ./virsh [...]

You can also run the C programs under valgrind like this:

  ./run valgrind [valgrind opts...] ./program

or under gdb:

  ./run gdb --args ./program

This also works with sudo (eg. if you need root access for libvirt):

  sudo ./run ./tools/virsh list --all

Derived from libguestfs and simplified.  The ./run script in
libguestfs is much more sophisticated:

https://github.com/libguestfs/libguestfs/blob/master/run.in

12 years agorpc: Fix name of member in remote_protocol-structs
Peter Krempa [Tue, 18 Sep 2012 09:42:03 +0000 (11:42 +0200)]
rpc: Fix name of member in remote_protocol-structs

Commit 7a99b0abafb69e1686198ac3473892a9aaeb8255 adds a new RPC struct
but one of the members has different names in remote_protocol.x and
remote_protocol-struct breaking make check.

12 years agovirBitmap: fix build without HAVE_NUMACTL
Ján Tomko [Tue, 18 Sep 2012 09:13:20 +0000 (11:13 +0200)]
virBitmap: fix build without HAVE_NUMACTL

Commit 75b198b3e7b2c8b4106afbd42f8bb795c4773511 forgot to change
arguments of dummy qemuProcessInitNumaMemoryPolicy from char* to
virBitmapPtr.

12 years agoqemuhelptest: convert runaway tab to spaces
Ján Tomko [Tue, 18 Sep 2012 09:17:26 +0000 (11:17 +0200)]
qemuhelptest: convert runaway tab to spaces

Make syntax-check happy and smiling again.

12 years agodaemon: Fix error message when libvirtd is missing.
Richard W.M. Jones [Fri, 14 Sep 2012 09:32:18 +0000 (10:32 +0100)]
daemon: Fix error message when libvirtd is missing.

Currently we search along the hard-coded names:
  SBINDIR "/libvirtd"
  SBINDIR "/libvirtd_dbg"
but if the environment variable $LIBVIRTD_PATH is set to the
name of the libvirtd binary, that is used instead.  Fix the
error message so it accurately reflects current behaviour
($PATH is NOT searched).

12 years agogitignore: Ignore .gdb_history file.
Richard W.M. Jones [Fri, 14 Sep 2012 09:09:51 +0000 (10:09 +0100)]
gitignore: Ignore .gdb_history file.

12 years agoFix the augea test for qemu libvirtd options
Daniel Veillard [Tue, 18 Sep 2012 08:28:43 +0000 (16:28 +0800)]
Fix the augea test for qemu libvirtd options

Commit 1ccf22277be013beb3f26f0083867c9c9eddca18 forgot to
add the output to the augeas test

12 years agonetwork: implement backend of virNetworkUpdate(IP_DHCP_HOST)
Laine Stump [Mon, 17 Sep 2012 21:03:11 +0000 (17:03 -0400)]
network: implement backend of virNetworkUpdate(IP_DHCP_HOST)

This patch fills in the first implementation for one of the
virNetworkUpdate sections. With this code, you can now add/delete/edit
<host> entries in a network's <ip> address <dhcp> element (by
specifying a section of VIR_NETWORK_SECTION_IP_DHCP_HOST).

If you pass in a parentIndex of -1, the code will automatically find
the one ip element that has a <dhcp> section and make the updates
there. Otherwise, you can specify an index >= 0, and libvirt will look
for that particular instance of <ip> in the network, and modify its
<dhcp> element. (This currently isn't very useful, because libvirt
only supports having dhcp information on a single IP address, but that
could change in the future).

When adding a new host entry
(VIR_NETWORK_UPDATE_COMMAND_ADD_(FIRST|LAST)), the existing entries
will be compared to the new entry, and if any non-empty attribute
matches, the add will fail. When updating an existing entry
(VIR_NETWORK_UPDATE_COMMAND_MODIFY), the mac address or name will be
used to find the existing entry, and other fields will only be updated
(note there is some potential for ambiguity here if you specify the
mac address from one entry and the name from another).  When deleting
an existing entry (VIR_NETWORK_UPDATE_COMMAND_DELETE), all non-empty
attributes in the supplied xml arg will be compared - all of them must
match before libvirt will delete the host.

The xml should be a fully formed <host> element as it would appear in
a network definition, e.g. "<host mac=00:11:22:33:44:55 ip=10.1.23.22
name='testbox'/>" (when adding/updating, ip and one of mac|name is
required; when deleting, you can specify any one, two, or all
attributes, but they all must match the target element).

As with the update of any other section, you can choose to affect the
live config (with flag VIR_NETWORK_UPDATE_AFFECT_LIVE), the persistent
config (VIR_NETWORK_UPDATE_AFFECT_CONFIG), or both. If you've chosen
to affect the live config, those changes will take effect immediately,
with no need to destroy/restart the network.

An example of adding a host entry:

   virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_ADD_LAST,
                     VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
                    "<host mac='00:11:22:33:44:55' ip='192.168.122.5'/>",
                    VIR_NETWORK_UPDATE_AFFECT_LIVE
                    | VIR_NETWORK_UPDATE_AFFECT_CONFIG);

To delete that same entry:

   virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_DELETE,
                    VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
                    "<host mac='00:11:22:33:44:55'/>",
                    VIR_NETWORK_UPDATE_AFFECT_LIVE
                    | VIR_NETWORK_UPDATE_AFFECT_CONFIG);

(you could also delete it by replacing "mac='00:11:22:33:44:55'" with
"ip='192.168.122.5'".)

12 years agonetwork: restart radvd/dnsmasq if needed when libvirtd is restarted
Laine Stump [Mon, 17 Sep 2012 01:22:27 +0000 (21:22 -0400)]
network: restart radvd/dnsmasq if needed when libvirtd is restarted

A user on IRC had accidentally killed all of his libvirt-started
dnsmasq instances (due to a buggy dnsmasq service script in Fedora
16), and had hoped that libvirtd would notice this on restart and
reload all the dnsmasq daemons (as it does with iptables
rules). Unfortunately this was not the case - as long as the network
object had a pid registered for dnsmasq and/or radvd, it assumed that
the processes were running.

This patch takes advantage of the new utility functions in
bridge_driver.c to do a "refresh" of all radvd and dnsmasq processes
started by libvirt each time libvirtd is restarted - this function
attempts to do a SIGHUP of each existing process, and if that fails,
it restarts the process, rebuilding all the associated config files
and commandline parameters in the process. This normally has no
effect, but will be useful in solving the occasional "odd situation"
without needing to take the drastic step of destroying/re-starting the
network.

12 years agonetwork: implement virNetworkUpdate for test_driver
Laine Stump [Mon, 20 Aug 2012 05:01:53 +0000 (01:01 -0400)]
network: implement virNetworkUpdate for test_driver

The test driver does nothing outside of keeping track of each
network's config/state in the in-memory database maintained by
network_conf functions, so all we have to do is call the function that
updates the network's entry in the in-memory database.

12 years agonetwork: implement virNetworkUpdate for bridge_driver
Laine Stump [Sun, 16 Sep 2012 20:42:01 +0000 (16:42 -0400)]
network: implement virNetworkUpdate for bridge_driver

Call the network_conf function that modifies the live/persistent/both
config, then refresh/restart dnsmasq/radvd if necessary, and finally
save the config in the proper place(s).

This patch also needed to uncomment a few utility functions that were
added inside #if 0 in the previous commit (to avoid compiler errors
due to unreferenced static functions).

12 years agonetwork: reorganize dnsmasq and radvd config file / startup
Laine Stump [Mon, 20 Aug 2012 04:59:46 +0000 (00:59 -0400)]
network: reorganize dnsmasq and radvd config file / startup

This patch splits the starting of dnsmasq and radvd into multiple
files, and adds new networkRefreshXX() and networkRestartXX()
functions for each. These new functions are currently commented out
because they won't be used until the next commit, and the compile options
require all static functions to be used.

networkRefreshXX() - rewrites any file-based config for dnsmasq/radvd,
and sends SIGHUP to the process to make it reread its config. If the
program isn't already running, it's just started.

networkRestartXX() - kills the given program, waits for it to exit
(see the comments in the function networkKillDaemon()), then calls
networkStartXX().

This commit is here mostly as a checkpoint to verify no change in
functional behavior after refactoring networkStartXX() functions to
fit in with these new functions.

12 years agoconf: implement NetworkObj backend of virNetworkUpdate API
Laine Stump [Fri, 14 Sep 2012 19:14:57 +0000 (15:14 -0400)]
conf: implement NetworkObj backend of virNetworkUpdate API

virNetworkObjUpdate takes care of all virNetworkUpdate-related changes
to the data stored in the in-memory virNetworkObj list. It should be
called by network drivers that use this in-memory list.

virNetworkObjUpdate *does not* take care of updating any disk-based
copies of the config, nor does it perform any other operations
necessary to have the new config data take effect (e.g. it won't
re-write dnsmasq host files, nor will it send a SIGHUP to dnsmasq) -
those things should all be taken care of in the network driver
function that calls virNetworkObjUpdate (assuming that it returns
success).

12 years agonetwork: utility functions for updating network config
Laine Stump [Fri, 14 Sep 2012 15:35:35 +0000 (11:35 -0400)]
network: utility functions for updating network config

These new functions are highly inspired by those in domain_conf.c (but
not identical), and are intended to make it simpler to update the
various combinations of live/persistent network configs.

The network driver wasn't previously as careful about the separation
between the live "status" in network->def and the persistent "config"
in network->newDef (or sometimes in network->def). This series
attempts to remedy some of that, but probably doesn't go all the way
(enough to get these functions working and enable continued work on
virNetworkUpdate though).

bridge_driver.c and test_driver.c were updated in a few places to take
advantage of the new functions and/or account for changes in argument
lists.

12 years agonetwork: implement RPC calls for virNetworkUpdate
Laine Stump [Mon, 20 Aug 2012 03:54:57 +0000 (23:54 -0400)]
network: implement RPC calls for virNetworkUpdate

This is very short, because almost everything is autogenerated. All
that's needed are:

* src/remote/remote_driver.c: add pointer to autogenerated
    remoteNetworkUpdate to the function table for the remote
    network driver.

* src/remote/remote_protocol.x: add the "args" struct and add one more
    item to the remote_procedure enum for this function.

* src/remote_protocol-struct: update to match remote_protocol.x

12 years agonetwork: define new API virNetworkUpdate
Laine Stump [Mon, 20 Aug 2012 03:35:47 +0000 (23:35 -0400)]
network: define new API virNetworkUpdate

This patch adds a new public API virNetworkUpdate that will permit
updating an existing network configuration without requiring that the
network be destroyed/restarted for the changes to take effect.

12 years agotests: add qemu-1.2.0 help data
Ján Tomko [Mon, 17 Sep 2012 07:59:55 +0000 (09:59 +0200)]
tests: add qemu-1.2.0 help data

Generated with:

qemu-system-x86_64 -help >tests/qemuhelpdata/qemu-1.2.0
qemu-system-x86_64 \
    -device ? \
    -device pci-assign,? \
    -device virtio-blk-pci,? \
    -device virtio-net-pci,? \
    -device scsi-disk,? 2>tests/qemuhelpdata/qemu-1.2.0-device