]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoImplement keepalive protocol in libvirt daemon
Jiri Denemark [Wed, 24 Aug 2011 13:33:34 +0000 (15:33 +0200)]
Implement keepalive protocol in libvirt daemon

13 years agovirsh: Always run event loop
Jiri Denemark [Tue, 11 Oct 2011 13:05:52 +0000 (15:05 +0200)]
virsh: Always run event loop

Since virsh already implements event loop, it has to also run it. So far
the event loop was only running during virsh console command.

13 years agoIntroduce virConnectSetKeepAlive
Jiri Denemark [Thu, 22 Sep 2011 11:47:07 +0000 (13:47 +0200)]
Introduce virConnectSetKeepAlive

virConnectSetKeepAlive public API can be used by a client connecting to
remote server to start using keepalive protocol. The API is handled
directly by remote driver and not transmitted over the wire to the
server.

13 years agoImplement common keepalive handling
Jiri Denemark [Thu, 22 Sep 2011 11:40:00 +0000 (13:40 +0200)]
Implement common keepalive handling

These APIs are used by both client and server RPC layer to handle
processing of keepalive messages.

13 years agoDefine keepalive protocol
Jiri Denemark [Thu, 22 Sep 2011 10:51:55 +0000 (12:51 +0200)]
Define keepalive protocol

The keepalive program has two procedures: PING, and PONG.
Both are used only in asynchronous messages and the sender doesn't wait
for any reply. However, the party which receives PING messages is
supposed to react by sending PONG message the other party, but no
explicit binding between PING and PONG messages is made. For backward
compatibility neither server nor client are allowed to send keepalive
messages before checking that remote party supports them.

13 years agorpc: Add some debug messages to virNetClient
Jiri Denemark [Tue, 22 Nov 2011 14:14:43 +0000 (15:14 +0100)]
rpc: Add some debug messages to virNetClient

13 years agorpc: Fix handling of non-blocking calls that could not be sent
Jiri Denemark [Tue, 22 Nov 2011 13:11:02 +0000 (14:11 +0100)]
rpc: Fix handling of non-blocking calls that could not be sent

When virNetClientIOEventLoop is called for a non-blocking call and not
even a single byte can be sent from this call without blocking, we
properly reported that to the caller which properly frees the call. But
we never removed the call from a call queue.

13 years agorpc: Fix a typo in virNetClientSendNonBlock documentation
Jiri Denemark [Tue, 22 Nov 2011 14:12:05 +0000 (15:12 +0100)]
rpc: Fix a typo in virNetClientSendNonBlock documentation

13 years agorpc: Pass the buck only to the first available thread
Jiri Denemark [Tue, 22 Nov 2011 14:10:06 +0000 (15:10 +0100)]
rpc: Pass the buck only to the first available thread

13 years agonwfilter: remove virConnectPtr from internal API calls
Stefan Berger [Wed, 23 Nov 2011 19:13:03 +0000 (14:13 -0500)]
nwfilter: remove virConnectPtr from internal API calls

Remove the virConnectPtr from the nwfilter's internal API calls as
far as possible.

13 years agoqemu: Avoid dereference of NULL pointer
Peter Krempa [Wed, 23 Nov 2011 14:51:28 +0000 (15:51 +0100)]
qemu: Avoid dereference of NULL pointer

If something fails while initializing qemu job object in
qemuDomainObjPrivateAlloc(), memory to the private pointer is freed, but
after that, the pointer is still dereferenced, which may result in a
segfault.

* qemuDomainObjPrivateAlloc() - Don't dereference NULL pointer.

13 years agoqemu: fix a const-correctness issue
Eric Blake [Wed, 23 Nov 2011 14:26:32 +0000 (07:26 -0700)]
qemu: fix a const-correctness issue

Generally, functions which return malloc'd strings should be typed
as 'char *', not 'const char *', to make it obvious that the caller
is responsible to free things.  free(const char *) fails to compile,
and although we have a cast embedded in VIR_FREE to work around poor
code that frees const char *, it's better to not rely on that hack.

* src/qemu/qemu_driver.c (qemuDiskPathToAlias): Change return type.
(qemuDomainBlockJobImpl): Update caller.

13 years agoAPI: prefer 'disk' over 'block' or 'path'
Eric Blake [Wed, 23 Nov 2011 00:15:43 +0000 (17:15 -0700)]
API: prefer 'disk' over 'block' or 'path'

Given that we can now handle the target's disk shorthand, in addition
to an absolute path to the file or block device used on the host,
the term 'disk' fits a bit better as the parameter name than 'path'.

* include/libvirt/libvirt.h.in: Update some parameter names.
* src/libvirt.c (virDomainBlockStats, virDomainBlockStatsFlags)
(virDomainBlockPeek, virDomainGetBlockInfo, virDomainBlockJobAbort)
(virDomainGetBlockJobInfo, virDomainBlockJobSetSpeed)
(virDomainBlockPull): Likewise.

13 years agoblockstats: support lookup by path in blockstats
Eric Blake [Tue, 22 Nov 2011 22:55:30 +0000 (15:55 -0700)]
blockstats: support lookup by path in blockstats

Commit 89b6284f made it possible to pass either a source name or
the target device to most API demanding a disk designation, but
forgot to update the documentation.  It also failed to update
virDomainBlockStats to take both forms. This patch fixes both the
documentation and the remaining function.

Xen continues to use just device shorthand (that is, I did not
implement path lookup there, since xen does not track a domain_conf
to quickly tie a path back to the device shorthand).

* src/libvirt.c (virDomainBlockStats, virDomainBlockStatsFlags)
(virDomainGetBlockInfo, virDomainBlockPeek)
(virDomainBlockJobAbort, virDomainGetBlockJobInfo)
(virDomainBlockJobSetSpeed, virDomainBlockPull): Document
acceptable disk naming conventions.
* src/qemu/qemu_driver.c (qemuDomainBlockStats)
(qemuDomainBlockStatsFlags): Allow lookup by source name.
* src/test/test_driver.c (testDomainBlockStats): Likewise.

13 years agonwfilter: Initialize virNWFilterAddIpAddrForIfname return variable
Michal Privoznik [Wed, 23 Nov 2011 12:43:17 +0000 (07:43 -0500)]
nwfilter: Initialize virNWFilterAddIpAddrForIfname return variable

Latest nwfilter patch ad6c67cf introduced uninitialized return
value. This was spotted by 4.6.2 gcc.

13 years agoFix disabling of virtual port profile code on old hosts
Daniel P. Berrange [Wed, 23 Nov 2011 12:29:37 +0000 (12:29 +0000)]
Fix disabling of virtual port profile code on old hosts

The WITH_VIRTUALPORT macro is defined to 0 when disabled, not
left undefined. So #if must be used instead of #ifdef

* src/util/virnetdevvportprofile.c: s/#ifdef/#if/

13 years agoFix uninitialized variable in NWfilter IP learning code
Daniel P. Berrange [Wed, 23 Nov 2011 12:16:01 +0000 (12:16 +0000)]
Fix uninitialized variable in NWfilter IP learning code

* src/nwfilter/nwfilter_learnipaddr.c: Initialize ret variable

13 years agovirsh: Increase device-detach intelligence
Michal Prívozník [Mon, 6 Jun 2011 10:20:11 +0000 (12:20 +0200)]
virsh: Increase device-detach intelligence

Up to now users have to give a full XML description on input when
device-detaching. If they omitted something it lead to unclear
error messages (like generated MAC wasn't found, etc.).
With this patch users can specify only those information which
specify one device sufficiently precise. Remaining information is
completed from domain.

13 years agoEnable detection of multiple IP addresses
Stefan Berger [Wed, 23 Nov 2011 00:05:45 +0000 (19:05 -0500)]
Enable detection of multiple IP addresses

In preparation of DHCP Snooping and the detection of multiple IP
addresses per interface:

The hash table that is used to collect the detected IP address of an
interface can so far only handle one IP address per interface. With
this patch we extend this to allow it to handle a list of IP addresses.

Above changes the returned variable type of virNWFilterGetIpAddrForIfname()
from char * to virNWFilterVarValuePtr; adapt all existing functions calling
this function.

13 years agofix error message when using wrong URI alias
Eli Qiao [Tue, 22 Nov 2011 22:08:14 +0000 (15:08 -0700)]
fix error message when using wrong URI alias

Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
When configuring a URI alias like this in 'libvirt.conf':

uri_aliases = [
  "jj#j=qemu+ssh://root@127.0.0.1/system",
  "sleet=qemu+ssh://root@sleet.cloud.example.com/system",
]
virsh -c jj#j

It will show this error message:
'no connection driver available for No connection for URI jj#j'
Actually,we expect this message below:
Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only contain 'a-Z, 0-9, _, -'

Give this patch to fix this error.

13 years agoPass additional parameter into applyDHCPOnly function
Stefan Berger [Tue, 22 Nov 2011 20:59:26 +0000 (15:59 -0500)]
Pass additional parameter into applyDHCPOnly function

In preparation for the DHCP Snooping code:
Pass an additional parameter into the applyDHCPOnly function
of the 'techdriver'.

13 years agonwfilter: use shell variable to invoke 'ip(6)tables' command
Stefan Berger [Tue, 22 Nov 2011 20:12:04 +0000 (15:12 -0500)]
nwfilter: use shell variable to invoke 'ip(6)tables' command

Introduce a shell variable 'IBT' to invoke the ip(6)tables command.

Tested with libvirt-tck.

13 years agonwfilter: use shell variable to invoke 'ebtables' command
Stefan Berger [Tue, 22 Nov 2011 20:12:04 +0000 (15:12 -0500)]
nwfilter: use shell variable to invoke 'ebtables' command

Introduce a shell variable 'EBT' to invoke the ebtables command.
Hard-code the used ebtables table to '-t nat'.

Tested with libvirt-tck.

13 years agoImprove error reporting of failures to apply filtering rules
Stefan Berger [Tue, 22 Nov 2011 20:12:04 +0000 (15:12 -0500)]
Improve error reporting of failures to apply filtering rules

Display the executed command and failure message if a command failed to
execute.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd documentation for STP filtering support
Stefan Berger [Tue, 22 Nov 2011 20:12:03 +0000 (15:12 -0500)]
Add documentation for STP filtering support

Add documentation for the STP filtering support. Describe the XML attributes
that are supported.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd test cases for STP traffic filtering
Stefan Berger [Tue, 22 Nov 2011 20:12:03 +0000 (15:12 -0500)]
Add test cases for STP traffic filtering

This patch adds a few test cases for the XML parsing of STP filtering nodes.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd support for STP filtering
Stefan Berger [Tue, 22 Nov 2011 20:12:03 +0000 (15:12 -0500)]
Add support for STP filtering

This patch adds support for filtering of STP (spanning tree protocol) traffic
to the parser and makes us of the ebtables support for STP filtering. This code
now enables the filtering of traffic in chains with prefix 'stp'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd a 'mac' chain
Stefan Berger [Tue, 22 Nov 2011 20:12:03 +0000 (15:12 -0500)]
Add a 'mac' chain

With hunks borrowed from one of David Steven's previous patches, we now
add the capability of having a 'mac' chain which is useful to filter
for multiple valid MAC addresses.

Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agodocs: fix grammar of capabilities
Eric Blake [Tue, 22 Nov 2011 17:30:07 +0000 (10:30 -0700)]
docs: fix grammar of capabilities

* docs/formatcaps.html.in: Avoid run-on sentence, wrap lines.

13 years agoAdd strings.h include to capabilities.h for ffs() function prototype
Daniel P. Berrange [Tue, 22 Nov 2011 09:45:47 +0000 (09:45 +0000)]
Add strings.h include to capabilities.h for ffs() function prototype

On Mingw32 the ffs() function was not declared due to missing header
include

* src/conf/capabilities.c: The ffs() function lives in strings.h

13 years agobuild: Update AUTHORS
Osier Yang [Tue, 22 Nov 2011 07:34:40 +0000 (15:34 +0800)]
build: Update AUTHORS

Add Chang Liu to the AUTHORS' list.

13 years agostorage: Fallback to use lvchange first if lvremove fails
Chang Liu [Tue, 22 Nov 2011 07:24:25 +0000 (15:24 +0800)]
storage: Fallback to use lvchange first if lvremove fails

virStorageBackendLogicalDeleteVol() could not remove the lv with error
"could not remove open logical volume" sometimes. Generally it's caused
by the volume is still active, even if lvremove tries to remove it with
option "--force".

This patch is to fix it by disbale the lv first using "lvchange -aln"
and "lvremove -f" afterwards if the direct "lvremove -f" failed.

13 years agoExport KVM Host Power Management capabilities
Srivatsa S. Bhat [Tue, 22 Nov 2011 03:31:22 +0000 (11:31 +0800)]
Export KVM Host Power Management capabilities

This patch exports KVM Host Power Management capabilities as XML so that
higher-level systems management software can make use of these features
available in the host.

The script "pm-is-supported" (from pm-utils package) is run to discover if
Suspend-to-RAM (S3) or Suspend-to-Disk (S4) is supported by the host.
If either of them are supported, then a new tag "<power_management>" is
introduced in the XML under the <host> tag.

However in case the query to check for power management features succeeded,
but the host does not support any such feature, then the XML will contain
an empty <power_management/> tag. In the event that the PM query itself
failed, the XML will not contain any "power_management" tag.

To use this, new APIs could be implemented in libvirt to exploit power
management features such as S3/S4.

13 years agoconf: don't modify cpu set string during parsing
Eric Blake [Fri, 18 Nov 2011 18:27:24 +0000 (11:27 -0700)]
conf: don't modify cpu set string during parsing

None of the callers cared if str was updated to point to the next
byte after the parsed cpuset; simplifying this results in quite
a few code simplifications.  Additionally, virCPUDefParseXML was
strdup()'ing a malloc()'d string; avoiding a memory copy resulted
in less code.

* src/conf/domain_conf.h (virDomainCpuSetParse): Alter signature.
* src/conf/domain_conf.c (virDomainCpuSetParse): Don't modify str.
(virDomainVcpuPinDefParseXML, virDomainDefParseXML): Adjust
callers.
* src/conf/cpu_conf.c (virCPUDefParseXML): Likewise.
* src/xen/xend_internal.c (sexpr_to_xend_topology): Likewise.
* src/xen/xm_internal.c (xenXMDomainPinVcpu): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxpr): Likewise.
* src/xenxs/xen_xm.c (xenParseXM): Likewise.

13 years agoqemu: don't release network actual device twice
Roopa Prabhu [Thu, 17 Nov 2011 02:34:32 +0000 (18:34 -0800)]
qemu: don't release network actual device twice

For direct attach devices, in qemuBuildCommandLine, we seem to be freeing
actual device on error path (with networkReleaseActualDevice). But the actual
device is not deleted.

qemuProcessStop eventually deletes the direct attach device and releases
actual device. But by the time qemuProcessStop is called qemuBuildCommandLine
has already freed actual device, leaving stray macvtap devices behind on error.
So the simplest fix is to remove the networkReleaseActualDevice in
qemuBuildCommandLine. This patch does just that.

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
13 years agoqemu: Copy console definition from serial
Michal Privoznik [Tue, 15 Nov 2011 08:01:31 +0000 (09:01 +0100)]
qemu: Copy console definition from serial

Now, when we support multiple consoles per domain,
the vm->def->console[0] can still remain an alias
for vm->def->serial[0]; However, we need to copy
it's source definition as well otherwise we'll regress
on virDomainOpenConsole.

13 years agoFix distribution of .syms files for previous commit
Daniel P. Berrange [Mon, 21 Nov 2011 13:17:26 +0000 (13:17 +0000)]
Fix distribution of .syms files for previous commit

* src/Makefile.am: Remove libvirt_bridge.syms and libvirt_macvtap.syms
  from EXTRA_DIST. Add libvirt_dbus.syms

13 years agoFix build on Mingw32 wrt export of virNetServerGetDBusConn
Daniel P. Berrange [Mon, 21 Nov 2011 11:45:42 +0000 (11:45 +0000)]
Fix build on Mingw32 wrt export of virNetServerGetDBusConn

Mingw32 complains if you request export of a symbol which does
not in fact exist.

* src/libvirt_bridge.syms, src/libvirt_macvtap.syms: Delete
  obsolete files
* src/libvirt_private.syms: Remove virNetServerGetDBusConn
* src/libvirt_dbus.syms: Add virNetServerGetDBusConn

13 years agostorage: Skips backingStore of virtual snapshot lv
Osier Yang [Fri, 18 Nov 2011 11:15:10 +0000 (19:15 +0800)]
storage: Skips backingStore of virtual snapshot lv

lvs outputs "[$lvname_vorigin]" for the virtual snapshot lv
(created with "--virtualsize"), and the original device pointed
by "$lvname_vorigin" is just for lvm internal use, one should
never use it.

Per lvm's nameing rules, "[" is not valid as part of the vg/lv name.
(man 8 lvm).

<quote>
VALID NAMES
The following characters are valid for VG and LV names: a-z A-Z 0-9 + _
. -

VG and LV names cannot begin with a hyphen.   There  are  also  various
reserved  names that are used internally by lvm that can not be used as
LV or VG names.  A VG cannot be called anything that exists in /dev/ at
the time of creation, nor can it be called '.' or '..'.  A LV cannot be
called '.' '..' 'snapshot' or 'pvmove'. The LV name may also  not  con‐
tain the strings '_mlog' or '_mimage'
</quote>

So we can skip the set the lv's backingStore by checking if the name
begins with a "[".

13 years agoAdd documentation for VLAN filtering support
Stefan Berger [Sat, 19 Nov 2011 12:26:56 +0000 (07:26 -0500)]
Add documentation for VLAN filtering support

Add documentation for the VLAN filtering support. Describe the XML attributes
that are supported.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd test cases for VLAN traffic filtering
Stefan Berger [Sat, 19 Nov 2011 12:26:56 +0000 (07:26 -0500)]
Add test cases for VLAN traffic filtering

This patch adds a few test cases for the XML parsing of VLAN filtering nodes.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd support for VLAN filtering
Stefan Berger [Sat, 19 Nov 2011 12:26:56 +0000 (07:26 -0500)]
Add support for VLAN filtering

This patch adds support for filtering of VLAN (802.1Q) traffic to the
parser and makes us of the ebtables support for VLAN filtering. This code
now enables the filtering of traffic in chains with prefix 'vlan'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoDon't copy sexpr node value that is an empty string
Jim Fehlig [Fri, 18 Nov 2011 21:54:38 +0000 (14:54 -0700)]
Don't copy sexpr node value that is an empty string

Xen4.1 initializes some unspecified sexpr config items to an empty
string, unlike previous Xen versions that would leave the item unset.
E.g. the kernel item for an HVM guest (non-direct kernel boot):

Xen4.0 and earlier
  ...
  (image
    (hvm
      (kernel )
  ...

Xen4.1
  ...
  (image
    (hvm
      (kernel '')
  ...

The empty string for kernel causes some grief in subsequent parsing
where existence of specified kernel is checked, e.g.

  if (!def->os.kernel)
  ...

This patch solves the problem in sexpr_node_copy() by not copying
a node containing an empty string.

13 years agotests: avoid xend ABRT crash report
Eric Blake [Fri, 18 Nov 2011 21:21:54 +0000 (14:21 -0700)]
tests: avoid xend ABRT crash report

I installed the xen development packages on my non-Xen F16 machine
in order to compile-test xen code and ensure we don't break things
on that front, but being a non-xen machine, /usr/sbin/xend is
obviously not running.  Unfortunately, xen-4.1.2-1.fc16 has a bug
where merely trying to probe xend status on a non-xen kernel causes
xend to issue an ABRT crash report:

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

Even though libvirt (correctly) skips the test, the xend crash report
is unnecessary noise.  Fix this by first filtering out non-xen
kernels even before attempting to probe xend.  The test still runs
and passes on a RHEL 5 xen kernel after this patch.

* tests/reconnect.c (mymain): Skip xend probe on non-xen kernel.
* tests/statstest.c (mymain): Likewise.

13 years agobuild: fix compile error with no macvtap
Eric Blake [Fri, 18 Nov 2011 21:40:32 +0000 (14:40 -0700)]
build: fix compile error with no macvtap

Since commit 6ec8288a, compilation has failed on RHEL 5:

util/virnetdevmacvlan.c:672: error: conflicting types for 'virNetDevMacVLanCreateWithVPortProfile'

* src/util/virnetdevmacvlan.c
(virNetDevMacVLanCreateWithVPortProfile): Add missing parameter.

13 years agoenable cgroup cpuset by default
Hu Tao [Thu, 17 Nov 2011 09:44:12 +0000 (17:44 +0800)]
enable cgroup cpuset by default

This prepares for subsequent patches which introduce dependence
on cgroup cpuset. Enable cgroup cpuset by default so users don't
have to modify configuration file before encountering a cpuset
error.

13 years agobuild: fix accidental POTFILES.in regression
Eric Blake [Fri, 18 Nov 2011 17:36:35 +0000 (10:36 -0700)]
build: fix accidental POTFILES.in regression

The original patch for commit 4789fb2 considered renaming a file,
then backed out the name change, but forgot to back out the POTFILES.in
change, resulting in 'make syntax-check' failure.

13 years agotests: test recent hash addition
Eric Blake [Thu, 17 Nov 2011 22:04:17 +0000 (15:04 -0700)]
tests: test recent hash addition

Excercise the new hash API, to ensure we avoid regressions.

* tests/hashtest.c (testHashGetItems): New test.

13 years agoAdd test cases for parsing of list values
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Add test cases for parsing of list values

This patch adds test cases for parsing of parameters with
multiple occurrances of the same name.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoExtend NWFilter parameter parser to cope with lists of values
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Extend NWFilter parameter parser to cope with lists of values

This patch modifies the NWFilter parameter parser to support multiple
elements with the same name and to internally build a list of items.
An example of the XML looks like this:

        <parameter name='TEST' value='10.1.2.3'/>
        <parameter name='TEST' value='10.2.3.4'/>
        <parameter name='TEST' value='10.1.1.1'/>

The list of values is then stored in the newly introduced data type
virNWFilterVarValue.

The XML formatter is also adapted to print out all items in alphabetical
order sorted by 'name'.

This patch also fixes a bug in the XML schema on the way.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoCreate rules for each member of a list
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Create rules for each member of a list

This patch extends the NWFilter driver for Linux (ebiptables) to create
rules for each member of a previously introduced list. If for example
an attribute value (internally) looks like this:

IP = [10.0.0.1, 10.0.0.2, 10.0.0.3]

then 3 rules will be generated for a rule accessing the variable 'IP',
one for each member of the list. The effect of this is that this now
allows for filtering for multiple values in one field. This can then be
used to support for filtering/allowing of multiple IP addresses per
interface.

An iterator is introduced that extracts each member of a list and
puts it into a hash table which then is passed to the function creating
a rule. For the above example the iterator would cause 3 loops.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoRework value part of name-value pairs
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Rework value part of name-value pairs

NWFilters can be provided name-value pairs using the following
XML notation:

      <filterref filter='xyz'>
        <parameter name='PORT' value='80'/>
        <parameter name='VAL' value='abc'/>
      </filterref>

The internal representation currently is so that a name is stored as a
string and the value as well. This patch now addresses the value part of it
and introduces a data structure for storing a value either as a simple
value or as an array for later support of lists.

This patch adjusts all code that was handling the values in hash tables
and makes it use the new data type.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoDocumentation about chains' priorities, lists of elements etc.
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Documentation about chains' priorities, lists of elements etc.

This patch adds several aspects of documentation about the network filtering
system:

- chains, chains' priorities and chains' default priorities
- talks about lists of elements, i.e., a variable assigned multiple values
  (part of already ACK-ed series)
- already mentions the vlan, stp and mac chains added later on
  (https://www.redhat.com/archives/libvir-list/2011-October/msg01238.html)
- mentions limitations of vlan filtering (when sent by VM) on Linux systems

13 years agoAdd test cases
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Add test cases

Add test case for the chain names with known prefixes and the chain
priority.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoInterleave jumping into chains with filtering rules in 'root' table
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Interleave jumping into chains with filtering rules in 'root' table

The previous patch extends the priority of filtering rules into negative
numbers. We now use this possibility to interleave the jumping into
chains with filtering rules to for example create the 'root' table of
an interface with the following sequence of rules:

Bridge chain: libvirt-I-vnet0, entries: 6, policy: ACCEPT
-p IPv4 -j I-vnet0-ipv4
-p ARP -j I-vnet0-arp
-p ARP -j ACCEPT
-p 0x8035 -j I-vnet0-rarp
-p 0x835 -j ACCEPT
-j DROP

The '-p ARP -j ACCEPT' rule now appears between the jumps.
Since the 'arp' chain has been assigned priority -700 and the 'rarp'
chain -600, the above ordering can now be achieved with the following
rule:

  <rule action='accept' direction='out' priority='-650'>
    <mac protocolid='arp'/>
  </rule>

This patch now sorts the commands generating the above shown jumps into
chains and interleaves their execution with those for generating rules.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoExtend rule priorities into negative numbers
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Extend rule priorities into negative numbers

So far rules' priorities have only been valid in the range [0,1000].
Now I am extending their priority into the range [-1000, 1000] for subsequently
being able to sort rules and the access of (jumps into) chains following
priorities.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoEnable chains with names having a known prefix
Stefan Berger [Fri, 18 Nov 2011 16:58:18 +0000 (11:58 -0500)]
Enable chains with names having a known prefix

This patch enables chains that have a known prefix in their name.
Known prefixes are: 'ipv4', 'ipv6', 'arp', 'rarp'. All prefixes
are also protocols that can be evaluated on the ebtables level.

Following the prefix they will be automatically connected to an interface's
'root' chain and jumped into following the protocol they evaluate, i.e.,
a table 'arp-xyz' will be accessed from the root table using

ebtables -t nat -A <iface root table> -p arp -j I-<ifname>-arp-xyz

thus generating a 'root' chain like this one here:

Bridge chain: libvirt-O-vnet0, entries: 5, policy: ACCEPT
-p IPv4 -j O-vnet0-ipv4
-p ARP -j O-vnet0-arp
-p 0x8035 -j O-vnet0-rarp
-p ARP -j O-vnet0-arp-xyz
-j DROP

where the chain 'arp-xyz' is accessed for filtering of ARP packets.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoExtend the filter XML to support priorities of chains
Stefan Berger [Fri, 18 Nov 2011 16:58:17 +0000 (11:58 -0500)]
Extend the filter XML to support priorities of chains

This patch extends the filter XML to support priorities of chains
in the XML. An example would be:

<filter name='allow-arpxyz' chain='arp-xyz' priority='200'>
[...]
</filter>

The permitted values for priorities are [-1000, 1000].
By setting the priority of a chain the order in which it is accessed
from the interface root chain can be influenced.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoUse the actual names of chains in data structure
Stefan Berger [Fri, 18 Nov 2011 16:58:17 +0000 (11:58 -0500)]
Use the actual names of chains in data structure

Use the name of the chain rather than its type index (enum).
This pushes the later enablement of chains with user-given names
into the XML parser. For now we still only allow those names that
are well known ('root', 'arp', 'rarp', 'ipv4' and 'ipv6').

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoUse scripting for cleaning and renaming of chains
Stefan Berger [Fri, 18 Nov 2011 16:58:17 +0000 (11:58 -0500)]
Use scripting for cleaning and renaming of chains

Use scripts for the renaming and cleaning up of chains. This allows us to get
rid of some of the code that is only capable of renaming and removing chains
whose names are hardcoded.

A shell function 'collect_chains' is introduced that is given the name
of an ebtables chain and then recursively determines the names of all
chains that are accessed from this chain and its sub-chains using 'jumps'.

The resulting list of chain names is then used to delete all the found
chains by first flushing and then deleting them.

The same function is also used for renaming temporary filters to their final
names.

I tested this with the bash and dash as script interpreters.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoMake filter creation in root table more flexible
Stefan Berger [Fri, 18 Nov 2011 16:58:17 +0000 (11:58 -0500)]
Make filter creation in root table more flexible

Use the previously introduced chain priorities to sort the chains for access
from an interface's 'root' table and have them created in the proper order.
This gets rid of a lot of code that was previously creating the chains in a
more hardcoded way.

To determine what protocol a filter is used for evaluation do prefix-
matching, i.e., the filter 'arp' is used to filter for the 'arp' protocol,
'ipv4' for the 'ipv4' protocol and 'arp-xyz' will also be used to filter
for the 'arp' protocol following the prefix 'arp' in its name.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoIntroduce an internal priority for chains
Stefan Berger [Fri, 18 Nov 2011 16:58:17 +0000 (11:58 -0500)]
Introduce an internal priority for chains

For better handling of the sorting of chains introduce an internally used
priority. Use a lookup table to store the priorities. For now their actual
values do not matter just that the values cause the chains to be properly
sorted through changes in the following patches. However, the values are
chosen as negative so that once they are sorted along with filtering rules
(whose priority may only be positive for now) they will always be instantiated
before them (lower values cause instantiation before higher values). This
is done to maintain backwards compatibility.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd function to get hash table's key/value pairs
Stefan Berger [Fri, 18 Nov 2011 16:58:17 +0000 (11:58 -0500)]
Add function to get hash table's key/value pairs

Add a function to the virHashTable for getting an array of the hash table's
key-value pairs and have the keys (optionally) sorted.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd support for systemd init service
Daniel P. Berrange [Thu, 7 Jul 2011 13:45:07 +0000 (14:45 +0100)]
Add support for systemd init service

This patch adds support for a systemd init service for libvirtd
and libvirt-guests. The libvirtd.service is *not* written to use
socket activation, since we want libvirtd to start on boot so it
can do guest auto-start.

The libvirt-guests.service is pretty lame, just exec'ing the
original init script for now. Ideally we would factor out the
functionality, into some shared tool.

Instead of

  ./configure --with-init-script=redhat

You can now do

  ./configure --with-init-script=systemd

Or better still:

  ./configure --with-init-script=systemd+redhat

We can also now support install of the upstart init script

* configure.ac: Add systemd, and systemd+redhat options to
  --with-init-script option
* daemon/Makefile.am: Install systemd services
* daemon/libvirtd.sysconf: Add note about unused env variable
  with systemd
* daemon/libvirtd.service.in: libvirtd systemd service unit
* libvirt.spec.in: Add scripts to installing systemd services
  and migrating from legacy init scripts
* tools/Makefile.am: Install systemd services
* tools/libvirt-guests.init.sh: Rename to tools/libvirt-guests.init.in
* tools/libvirt-guests.service.in: systemd service unit

13 years agoAdd support for interfaces with type=direct to LXC
Daniel P. Berrange [Thu, 10 Nov 2011 11:09:13 +0000 (11:09 +0000)]
Add support for interfaces with type=direct to LXC

Support creation of macvlan devices for LXC containers. Do not
allow setting of bandwidth controls or vport profiles due to the
complication that there is no host side visible device to work
with.

* src/lxc/lxc_driver.c: Support type=direct interfaces

13 years agoAllow creation of plain macvlan devices
Daniel P. Berrange [Thu, 10 Nov 2011 10:29:09 +0000 (10:29 +0000)]
Allow creation of plain macvlan devices

Update virNetDevMacVLanCreateWithVPortProfile to allow creation
of plain macvlan devices, as well as macvtap devices. The former
is useful for LXC containers

* src/qemu/qemu_command.c: Explicitly request a macvtap device
* src/util/virnetdevmacvlan.c, src/util/virnetdevmacvlan.h: Add
  new flag to allow switching between macvlan and macvtap
  creation

13 years agoRefactor LXC network setup to allow future enhancements
Daniel P. Berrange [Thu, 10 Nov 2011 09:19:25 +0000 (09:19 +0000)]
Refactor LXC network setup to allow future enhancements

The current lxcSetupInterfaces() method directly performs setup
of the bridge devices. Since it will shortly need to also create
macvlan devices, move the bridge related code into a separate
method

* src/lxc/lxc_driver.c: Split lxcSetupInterfaces() to create a
  new lxcSetupInterfaceBridge()

13 years agoAdd missing 'const' annotations for internal domain conf helpers
Daniel P. Berrange [Thu, 10 Nov 2011 11:18:57 +0000 (11:18 +0000)]
Add missing 'const' annotations for internal domain conf helpers

The virDomainNetGetActualBridgeName and virDomainNetGetActualDirectDev
methods both return strings that point to data in the virDomainDefPtr
struct, and should therefore not be freed. The return values should
thus be 'const char *' not 'char *'.

* src/conf/domain_conf.c, src/conf/domain_conf.h: Mark const
* src/network/bridge_driver.c: Update to use a const char *

13 years agoFix up ordering of private symbols file
Daniel P. Berrange [Fri, 18 Nov 2011 16:07:48 +0000 (16:07 +0000)]
Fix up ordering of private symbols file

Fix ordering of symbols after re-arranging network device
management API source files

* src/libvirt_private.syms: Fix ordering

13 years agoMove ifaceMacvtapLinkDump and ifaceGetNthParent functions
Daniel P. Berrange [Thu, 3 Nov 2011 13:41:40 +0000 (13:41 +0000)]
Move ifaceMacvtapLinkDump and ifaceGetNthParent functions

Move the ifaceMacvtapLinkDump and ifaceGetNthParent functions
into virnetdevvportprofile.c since they are specific to that
code. This avoids polluting the headers with the Linux specific
netlink data types

* src/util/interface.c, src/util/interface.h: Move
  ifaceMacvtapLinkDump and ifaceGetNthParent functions and delete
  remaining file
* src/util/virnetdevvportprofile.c: Add ifaceMacvtapLinkDump
  and ifaceGetNthParent functions
* src/network/bridge_driver.c, src/nwfilter/nwfilter_gentech_driver.c,
  src/nwfilter/nwfilter_learnipaddr.c, src/util/virnetdevmacvlan.c:
  Remove include of interface.h

13 years agoMove functions for dealing with physical/virtual devices
Daniel P. Berrange [Thu, 3 Nov 2011 12:40:33 +0000 (12:40 +0000)]
Move functions for dealing with physical/virtual devices

Move virNetDevIsVirtualFunction, virNetDevGetVirtualFunctionIndex
and virNetDevGetPhysicalFunction to virnetdev.c

* src/util/interface.c, src/util/interface.h, src/util/virnetdev.c,
  src/util/virnetdev.h: Move APIs

13 years agoRename APIs for dealing with virtual/physical functions
Daniel P. Berrange [Thu, 3 Nov 2011 12:37:07 +0000 (12:37 +0000)]
Rename APIs for dealing with virtual/physical functions

Rename ifaceIsVirtualFunction to virNetDevIsVirtualFunction,
ifaceGetVirtualFunctionIndex to virNetDevGetVirtualFunctionIndex
and ifaceGetPhysicalFunction to virNetDevGetPhysicalFunction

* src/util/interface.c, src/util/interface.h: Rename APIs
* src/util/virnetdevvportprofile.c: Update for API rename

13 years agoMove virNetDevValidateConfig to virnetdev.c
Daniel P. Berrange [Thu, 3 Nov 2011 12:32:38 +0000 (12:32 +0000)]
Move virNetDevValidateConfig to virnetdev.c

* src/util/interface.c, src/util/interface.h: Remove virNetDevValidateConfig
* src/util/virnetdev.c, src/util/virnetdev.h: Add virNetDevValidateConfig

13 years agoRename ifaceCheck to virNetDevValidateConfig
Daniel P. Berrange [Thu, 3 Nov 2011 12:28:17 +0000 (12:28 +0000)]
Rename ifaceCheck to virNetDevValidateConfig

Rename the ifaceCheck method to virNetDevValidateConfig and change
so that it always raises an error and returns -1 on error.

* src/util/interface.c, src/util/interface.h: Rename ifaceCheck
  to virNetDevValidateConfig
* src/nwfilter/nwfilter_gentech_driver.c,
  src/nwfilter/nwfilter_learnipaddr.c: Update for API rename

13 years agoMove virNetDevGetIPv4Address to virnetdev.c
Daniel P. Berrange [Thu, 3 Nov 2011 10:35:17 +0000 (10:35 +0000)]
Move virNetDevGetIPv4Address to virnetdev.c

Move the virNetDevGetIPv4Address function to virnetdev.c

* util/interface.c, util/interface.h: Remove virNetDevGetIPv4Address
* util/virnetdev.c, util/virnetdev.h: Add virNetDevGetIPv4Address

13 years agoRename ifaceGetIPAddress to virNetDevGetIPv4Address
Daniel P. Berrange [Thu, 3 Nov 2011 10:31:01 +0000 (10:31 +0000)]
Rename ifaceGetIPAddress to virNetDevGetIPv4Address

To match up with the existing virNetDevSetIPv4Address, rename
ifaceGetIPAddress to virNetDevGetIPv4Address

* util/interface.h, util/interface.c: Rename API
* network/bridge_driver.c: Update for API rename

13 years agoMove virNetDevGetIndex & virNetDevGetVLanID to virnetdev.c
Daniel P. Berrange [Thu, 3 Nov 2011 09:27:45 +0000 (09:27 +0000)]
Move virNetDevGetIndex & virNetDevGetVLanID to virnetdev.c

Move virNetDevGetIndex & virNetDevGetVLanID to virnetdev.c to
suit their functional purpose

* util/interface.c, util/interface.h: Remove virNetDevGetIndex &
  virNetDevGetVLanID
* util/virnetdev.c, util/virnetdev.h: Add virNetDevGetIndex &
  virNetDevGetVLanID

13 years agoRename ifaceGetIndex and ifaceGetVLAN
Daniel P. Berrange [Thu, 3 Nov 2011 09:21:35 +0000 (09:21 +0000)]
Rename ifaceGetIndex and ifaceGetVLAN

Rename the ifaceGetIndex method to virNetDevGetIndex and
ifaceGetVlanID to virNetDevGetVLanID. Also change the error
reporting behaviour to always raise errors and return -1 on
failure

* util/interface.c, util/interface.h: Rename ifaceGetIndex
  and ifaceGetVLAN
* nwfilter/nwfilter_gentech_driver.c, nwfilter/nwfilter_learnipaddr.c,
  nwfilter/nwfilter_learnipaddr.c, util/virnetdevvportprofile.c: Update
  for API renames and error handling changes

13 years agoMove MAC address replacement functions to virnetdev.c
Daniel P. Berrange [Wed, 2 Nov 2011 17:40:50 +0000 (17:40 +0000)]
Move MAC address replacement functions to virnetdev.c

Move virNetDevReplaceMacAddress and virNetDevRestoreMacAddress
to the virnetdev.c file where they naturally belong

* util/interface.c, util/interface.h: Remove
  virNetDevReplaceMacAddress and virNetDevRestoreMacAddress
* util/virnetdev.c, util/virnetdev.h: Add
  virNetDevReplaceMacAddress and virNetDevRestoreMacAddress

13 years agoRename interface MAC address replacement APIs
Daniel P. Berrange [Wed, 2 Nov 2011 17:38:26 +0000 (17:38 +0000)]
Rename interface MAC address replacement APIs

Rename ifaceReplaceMacAddress to virNetDevReplaceMacAddress
and ifaceRestoreMacAddress to virNetDevRestoreMacAddress.

* util/interface.c, util/interface.h, util/virnetdevmacvlan.c:
  Rename APIs

13 years agoMove the low level macvlan creation APIs
Daniel P. Berrange [Wed, 2 Nov 2011 17:34:41 +0000 (17:34 +0000)]
Move the low level macvlan creation APIs

Move the low level macvlan creation APIs into the
virnetdevmacvlan.c file where they more naturally
belong

* util/interface.c, util/interface.h: Remove virNetDevMacVLanCreate
  and virNetDevMacVLanDelete
* util/virnetdevmacvlan.c, util/virnetdevmacvlan.h: Add
  virNetDevMacVLanCreate and virNetDevMacVLanDelete

13 years agoRename low level macvlan creation APIs
Daniel P. Berrange [Wed, 2 Nov 2011 17:26:11 +0000 (17:26 +0000)]
Rename low level macvlan creation APIs

Rename ifaceMacvtapLinkAdd to virNetDevMacVLanCreate and
ifaceLinkDel to virNetDevMacVLanDelete. Strictly speaking
the latter isn't restricted to macvlan devices, but that's
the only use libvirt has for it.

* util/interface.c, util/interface.h,
  util/virnetdevmacvlan.c: Rename APIs

13 years agoRename high level macvlan creation APIs
Daniel P. Berrange [Wed, 2 Nov 2011 17:19:48 +0000 (17:19 +0000)]
Rename high level macvlan creation APIs

Rename virNetDevMacVLanCreate to virNetDevMacVLanCreateWithVPortProfile
and virNetDevMacVLanDelete to virNetDevMacVLanDeleteWithVPortProfile

To make way for renaming the other macvlan creation APIs in
interface.c

* util/virnetdevmacvlan.c, util/virnetdevmacvlan.h,
  qemu/qemu_command.c, qemu/qemu_hotplug.c, qemu/qemu_process.c:
  Rename APIs

13 years agoRename and split the macvtap.c file
Daniel P. Berrange [Wed, 2 Nov 2011 17:11:02 +0000 (17:11 +0000)]
Rename and split the macvtap.c file

Rename the macvtap.c file to virnetdevmacvlan.c to reflect its
functionality. Move the port profile association code out into
virnetdevvportprofile.c. Make the APIs available unconditionally
to callers

* src/util/macvtap.h: rename to src/util/virnetdevmacvlan.h,
* src/util/macvtap.c: rename to src/util/virnetdevmacvlan.c
* src/util/virnetdevvportprofile.c, src/util/virnetdevvportprofile.h:
  Pull in vport association code
* src/Makefile.am, src/conf/domain_conf.h, src/qemu/qemu_conf.c,
  src/qemu/qemu_conf.h, src/qemu/qemu_driver.c: Update include
  paths & remove conditional compilation

13 years agoRename Macvtap management APIs
Daniel P. Berrange [Wed, 2 Nov 2011 16:51:01 +0000 (16:51 +0000)]
Rename Macvtap management APIs

In preparation for code re-organization, rename the Macvtap
management APIs to have the following patterns

  virNetDevMacVLanXXXXX     - macvlan/macvtap interface management
  virNetDevVPortProfileXXXX - virtual port profile management

* src/util/macvtap.c, src/util/macvtap.h: Rename APIs
* src/conf/domain_conf.c, src/network/bridge_driver.c,
  src/qemu/qemu_command.c, src/qemu/qemu_command.h,
  src/qemu/qemu_driver.c, src/qemu/qemu_hotplug.c,
  src/qemu/qemu_migration.c, src/qemu/qemu_process.c,
  src/qemu/qemu_process.h: Update for renamed APIs

13 years agoFix use of uninitialized variable in QEMU driver
Daniel P. Berrange [Fri, 18 Nov 2011 16:09:35 +0000 (16:09 +0000)]
Fix use of uninitialized variable in QEMU driver

13 years agoqemu: Generate -numa option
Bharata B Rao [Fri, 11 Nov 2011 12:53:04 +0000 (18:23 +0530)]
qemu: Generate -numa option

Add routines to generate -numa QEMU command line option based on
<numa> ... </numa> XML specifications.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
13 years agoXML definitions for guest NUMA and parsing routines
Bharata B Rao [Fri, 11 Nov 2011 12:51:45 +0000 (18:21 +0530)]
XML definitions for guest NUMA and parsing routines

This patch adds XML definitions for guest NUMA specification and contains
routines to parse the same. The guest NUMA specification looks like this:

<cpu>
        ...
        <topology sockets='2' cores='4' threads='2'/>
        <numa>
                <cell cpus='0-7' memory='512000'/>
                <cell cpus='8-15' memory='512000'/>
        </numa>
        ...
</cpu>

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
13 years agosnapshot: refuse to generate names for non-regular backing files
Eric Blake [Wed, 16 Nov 2011 00:19:20 +0000 (17:19 -0700)]
snapshot: refuse to generate names for non-regular backing files

For whatever reason, the kernel allows you to create a regular
file named /dev/sdc.12345; although this file will disappear the
next time devtmpfs is remounted.  If you let libvirt generate
the name of the external snapshot for a disk image originally
using the block device /dev/sdc, then the domain will be rendered
unbootable once the qcow2 file is lost on the next devtmpfs
remount.  In this case, the user should have used 'virsh
snapshot-create --xmlfile' or 'virsh snapshot-create-as --diskspec'
to specify the name for the qcow2 file in a sane location, rather
than relying on libvirt generating a name that is most likely to
be wrong.  We can help avoid naive mistakes by enforcing that
the user provide the external name for any backing file that is
not a regular file.

* src/conf/domain_conf.c (virDomainSnapshotAlignDisks): Only
generate names if backing file exists as regular file.
Reported by MATSUDA Daiki.

13 years agoFix build with polkit0
Jim Fehlig [Wed, 16 Nov 2011 18:35:08 +0000 (11:35 -0700)]
Fix build with polkit0

I missed adding virNetServerGetDBusConn() to libvirtd_private.syms
in commit b8adfcc6, which didn't cause a problem in 0.9.6 but
results in this build error in 0.9.7

libvirtd-remote.o: In function `remoteDispatchAuthPolkit':
remote.c:(.text+0x188dd): undefined reference to `virNetServerGetDBusConn'

13 years agoRevert commit 0f590c62
Jim Fehlig [Wed, 16 Nov 2011 18:29:14 +0000 (11:29 -0700)]
Revert commit 0f590c62

As noted by Daniel Berrange [1], the proper fix for the older
PolicyKit build issue is to add virNetServerGetDBusConn to
libvirt_private.syms.  Revert unnecessary changes to
daemon/Makefile.am

[1] https://www.redhat.com/archives/libvir-list/2011-November/msg00852.html

13 years agovirsh: add iface-bridge and iface-unbridge commands
Laine Stump [Mon, 7 Nov 2011 16:15:58 +0000 (11:15 -0500)]
virsh: add iface-bridge and iface-unbridge commands

One of the top questions by libvirt users is how to create a host
bridge device so that guests can be directly on the physical
network. There are several example documents that explain how to do
this manually, but following them often results in confusion and
failure. virt-manager does a good job of creating a bridge based on an
existing network device, but not everyone wants to use virt-manager.

This patch adds a new command, iface-bridge that makes it just about
as simple as possible to create a new bridge device based on an
existing ethernet/vlan/bond device (including associating IP
configuration with the bridge rather than the now-attached device),
and start that new bridge up ready for action, eg:

    virsh iface-bridge eth0 br0

For symmetry's sake, it also adds a command to remove a device from a
bridge, restoring the IP config to the now-unattached device:

    virsh iface-unbridge br0

(I had a short debate about whether to do "iface-unbridge eth0"
instead, but that would involve searching through all bridge devices
for the one that contained eth0, which seems like a bit too much
trouble).

NOTE: These two commands require that the netcf library be available
on the host. Hopefully this will provide some extra incentive for
people using suse, debian, ubuntu, and other similar systems to polish
up (and push downstream) the ports to those distros recently pushed to
the upstream netcf repo by Dan Berrange. Anyone interested in helping
with that effort in any way should join the netcf-devel mailing list
(subscription info at
https://fedorahosted.org/mailman/listinfo/netcf-devel)

During creation of the bridge, it's possible to specify whether or not
the STP protocol should be started up on the bridge and, if so, how
many seconds the bridge should squelch traffic from newly added
devices while learning new topology (defaults are stp='on' and
delay='0', which seems to usually work best for bridges used in the
context of libvirt guests).

There is also an option to not immediately start the bridge (and a
similar option to not immediately start the un-attached device after
destroying the bridge. Default is to start the new device, because in
the case of iface-unbridge not starting is strongly discouraged as it
will leave the system with no network connectivity on that interface
(because it's necessary to destroy/undefine the bridge device before
the unattached device can be defined), and it seemed better to make
the option for iface-bridge behave consistently.

NOTE TO THOSE TRYING THESE COMMANDS FOR THE FIRST TIME: to guard
against any "unexpected" change to configuration, it is advisable to
issue an "virsh iface-begin" command before starting any interface
config changes, and "virsh iface-commit" only after you've verified
that everything is working as you expect. If something goes wrong,
you can always run "virsh iface-rollback" or reboot the system (which
should automatically do iface-rollback).

Aside from adding the code for these two functions, and the two
entries into the command table, the only other change to virsh.c was
to add the option name to vshCommandOptInterfaceBy(), because the
iface-unbridge command names its interface option as "bridge".

virsh.pod has also been updated with short descriptions of these two
new commands.

13 years agofix a bug in remoteSerializeTypedParameters
Hu Tao [Wed, 16 Nov 2011 08:38:11 +0000 (16:38 +0800)]
fix a bug in remoteSerializeTypedParameters

This is a fatal typo believed to be very likely to happen when using
both i and j at the same time for indexing.

13 years agoDon't return a fatal error if receiving unexpected stream data
Daniel P. Berrange [Wed, 9 Nov 2011 13:54:01 +0000 (13:54 +0000)]
Don't return a fatal error if receiving unexpected stream data

Due to the asynchronous nature of streams, we might continue to
receive some stream packets from the server even after we have
shutdown the stream on the client side. These should be discarded
silently, rather than raising an error in the RPC layer.

* src/rpc/virnetclient.c: Discard stream data silently

13 years agoFix handling of stream EOF
Daniel P. Berrange [Fri, 7 Oct 2011 16:38:59 +0000 (17:38 +0100)]
Fix handling of stream EOF

Very occasionally the sequence of events from poll would result
in getting a HANGUP on its own, instead of a HANGUP+READABLE
at the same time. In the former case we would send back an error
event to the client, but never send the empty packet to indicate
EOF.

13 years agoAllow non-blocking message sending on virNetClient
Daniel P. Berrange [Tue, 8 Nov 2011 09:13:27 +0000 (09:13 +0000)]
Allow non-blocking message sending on virNetClient

Add a new virNetClientSendNonBlock which returns 2 on
full send, 1 on partial send, 0 on no send, -1 on error

If a partial send occurs, then a subsequent call to any
of the virNetClientSend* APIs will finish any outstanding
I/O.

TODO: the virNetClientEvent event handler could be used
to speed up completion of partial sends if an event loop
is present.

* src/rpc/virnetsocket.h, src/rpc/virnetsocket.c: Add new
  virNetSocketHasPendingData() API to test for cached
  data pending send.
* src/rpc/virnetclient.c, src/rpc/virnetclient.h: Add new
  virNetClientSendNonBlock() API to send non-blocking API

13 years agoRefactor code for enabling/disabling I/O callback in remote client
Daniel P. Berrange [Fri, 11 Nov 2011 15:45:44 +0000 (15:45 +0000)]
Refactor code for enabling/disabling I/O callback in remote client

* src/rpc/virnetclient.c: Add helper for setting I/O callback events

13 years agoSplit virNetClientSend into 2 methods
Daniel P. Berrange [Fri, 11 Nov 2011 15:42:46 +0000 (15:42 +0000)]
Split virNetClientSend into 2 methods

Stop multiplexing virNetClientSend for two different purposes,
instead add virNetClientSendWithReply and virNetClientSendNoReply

* src/rpc/virnetclient.c, src/rpc/virnetclient.h: Replace
  virNetClientSend with virNetClientSendWithReply and
  virNetClientSendNoReply
* src/rpc/virnetclientprogram.c, src/rpc/virnetclientstream.c:
  Update for new API names

13 years agoRefactor code for passing the buck in the remote client
Daniel P. Berrange [Fri, 11 Nov 2011 15:34:08 +0000 (15:34 +0000)]
Refactor code for passing the buck in the remote client

Remove some duplication by pulling the code for passing the
buck out into a helper method

* src/rpc/virnetclient.c: Introduce virNetClientIOEventLoopPassTheBuck

13 years agoExplicitly track whether the buck is held in remote client
Daniel P. Berrange [Fri, 11 Nov 2011 15:28:41 +0000 (15:28 +0000)]
Explicitly track whether the buck is held in remote client

Instead of inferring whether the buck is held from the waitDispatch
pointer, use an explicit 'bool haveTheBuck' field

* src/rpc/virnetclient.c: Explicitly track the buck