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

13 years agoRemove all linked list handling from remote client event loop
Daniel P. Berrange [Fri, 11 Nov 2011 15:26:16 +0000 (15:26 +0000)]
Remove all linked list handling from remote client event loop

Directly messing around with the linked list is potentially
dangerous. Introduce some helper APIs to deal with list
manipulating the list

* src/rpc/virnetclient.c: Create linked list handlers

13 years agoutil: Add netdev helper functions to private symbols
Eli Qiao [Wed, 16 Nov 2011 02:59:57 +0000 (10:59 +0800)]
util: Add netdev helper functions to private symbols

Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
13 years agoqemu/rbd: improve rbd device specification
Sage Weil [Tue, 1 Nov 2011 01:29:07 +0000 (18:29 -0700)]
qemu/rbd: improve rbd device specification

This improves the support for qemu rbd devices by adding support for a few
key features (e.g., authentication) and cleaning up the way in which
rbd configuration options are passed to qemu.

An <auth> member of the disk source xml specifies how librbd should
authenticate. The username attribute is the Ceph/RBD user to authenticate as.
The usage or uuid attributes specify which secret to use. Usage is an
arbitrary identifier local to libvirt.

The old RBD support relied on setting an environment variable to
communicate information to qemu/librbd.  Instead, pass those options
explicitly to qemu.  Update the qemu argument parsing and tests
accordingly.

Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
13 years agoFix build with polkit0
Jim Fehlig [Tue, 15 Nov 2011 22:11:49 +0000 (15:11 -0700)]
Fix build with polkit0

I missed adding libvirt_driver_remote.la to libvirtd_LDADD 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 agoFix strchr call triggering gcc 4.3 & 4.4 bug
Stefan Berger [Tue, 15 Nov 2011 17:48:07 +0000 (12:48 -0500)]
Fix strchr call triggering gcc 4.3 & 4.4 bug

Replacing the strchr call with two variables through a strstr call.
Calling strchr with two variables triggers a gcc 4.3/4.4
bug when used in combination with -Wlogical-op and at least -O1.

13 years agomaint: fix build
Stefan Berger [Tue, 15 Nov 2011 19:56:05 +0000 (14:56 -0500)]
maint: fix build

include stdint.h to fix the build

13 years agoRemove ifaceSetMac and ifaceGetMac APIs
Daniel P. Berrange [Wed, 2 Nov 2011 16:16:33 +0000 (16:16 +0000)]
Remove ifaceSetMac and ifaceGetMac APIs

The ifaceSetMac and ifaceGetMac APIs duplicate the functionality
of the virNetDevSetMAC and virNetDevGetMAC APIs, but returning
errno's instead of raising errors.

* src/util/interface.c, src/util/interface.h: Remove
  ifaceSetMac and ifaceGetMac APIs, adjusting callers
  for new error behaviour

13 years agoRemove ifaceUp, ifaceDown, ifaceCtrl & ifaceIsUp APIs
Daniel P. Berrange [Wed, 2 Nov 2011 16:10:56 +0000 (16:10 +0000)]
Remove ifaceUp, ifaceDown, ifaceCtrl & ifaceIsUp APIs

The ifaceUp, ifaceDown, ifaceCtrl & ifaceIsUp APIs can be replaced
with calls to virNetDevSetOnline and virNetDevIsOnline

* src/util/interface.c, src/util/interface.h: Delete ifaceUp,
  ifaceDown, ifaceCtrl & ifaceIsUp
* src/nwfilter/nwfilter_gentech_driver.c, src/util/macvtap.c:
  Update to use virNetDevSetOnline and virNetDevIsOnline

13 years agoMove LXC veth.c code into shared utility APIs
Daniel P. Berrange [Wed, 2 Nov 2011 16:03:09 +0000 (16:03 +0000)]
Move LXC veth.c code into shared utility APIs

Move the virNetDevSetName and virNetDevSetNamespace APIs out
of LXC's veth.c and into virnetdev.c.

Move the remaining content of the file to src/util/virnetdevveth.c

* src/lxc/veth.c: Rename to src/util/virnetdevveth.c
* src/lxc/veth.h: Rename to src/util/virnetdevveth.h
* src/util/virnetdev.c, src/util/virnetdev.h: Add
  virNetDevSetName and virNetDevSetNamespace
* src/lxc/lxc_container.c, src/lxc/lxc_controller.c,
  src/lxc/lxc_driver.c: Update include paths

13 years agoRename the LXC veth management APIs and delete duplicated APIs
Daniel P. Berrange [Wed, 2 Nov 2011 15:53:39 +0000 (15:53 +0000)]
Rename the LXC veth management APIs and delete duplicated APIs

The src/lxc/veth.c file contains APIs for managing veth devices,
but some of the APIs duplicate stuff from src/util/virnetdev.h.
Delete thed duplicate APIs and rename the remaining ones to
follow virNetDevVethXXXX

* src/lxc/veth.c, src/lxc/veth.h: Rename APIs & delete duplicates
* src/lxc/lxc_container.c, src/lxc/lxc_controller.c,
  src/lxc/lxc_driver.c: Update for API renaming

13 years agoSplit src/util/network.{c,h} into 5 pieces
Daniel P. Berrange [Wed, 2 Nov 2011 15:40:08 +0000 (15:40 +0000)]
Split src/util/network.{c,h} into 5 pieces

The src/util/network.c file is a dumping ground for many different
APIs. Split it up into 5 pieces, along functional lines

 - src/util/virnetdevbandwidth.c: virNetDevBandwidth type & helper APIs
 - src/util/virnetdevvportprofile.c: virNetDevVPortProfile type & helper APIs
 - src/util/virsocketaddr.c: virSocketAddr and APIs
 - src/conf/netdev_bandwidth_conf.c: XML parsing / formatting
   for virNetDevBandwidth
 - src/conf/netdev_vport_profile_conf.c: XML parsing / formatting
   for virNetDevVPortProfile

* src/util/network.c, src/util/network.h: Split into 5 pieces
* src/conf/netdev_bandwidth_conf.c, src/conf/netdev_bandwidth_conf.h,
  src/conf/netdev_vport_profile_conf.c, src/conf/netdev_vport_profile_conf.h,
  src/util/virnetdevbandwidth.c, src/util/virnetdevbandwidth.h,
  src/util/virnetdevvportprofile.c, src/util/virnetdevvportprofile.h,
  src/util/virsocketaddr.c, src/util/virsocketaddr.h: New pieces
* daemon/libvirtd.h, daemon/remote.c, src/conf/domain_conf.c,
  src/conf/domain_conf.h, src/conf/network_conf.c,
  src/conf/network_conf.h, src/conf/nwfilter_conf.h,
  src/esx/esx_util.h, src/network/bridge_driver.c,
  src/qemu/qemu_conf.c, src/rpc/virnetsocket.c,
  src/rpc/virnetsocket.h, src/util/dnsmasq.h, src/util/interface.h,
  src/util/iptables.h, src/util/macvtap.c, src/util/macvtap.h,
  src/util/virnetdev.h, src/util/virnetdevtap.c,
  tools/virsh.c: Update include files

13 years agoFix error reporting in port profile parsing/formatting APIs
Daniel P. Berrange [Wed, 2 Nov 2011 14:53:35 +0000 (14:53 +0000)]
Fix error reporting in port profile parsing/formatting APIs

The virtual port profile parsing/formatting APIs do not
correctly handle unknown profile type strings/numbers.
They behave as a no-op, instead of raising an error

* src/util/network.c, src/util/network.h: Fix error
  handling of port profile APIs
* src/conf/domain_conf.c, src/conf/network_conf.c: Update
  for API changes

13 years agoRename virVirtualPortProfileParams & APIs
Daniel P. Berrange [Wed, 2 Nov 2011 14:43:16 +0000 (14:43 +0000)]
Rename virVirtualPortProfileParams & APIs

Rename the virVirtualPortProfileParams struct to be
virNetDevVPortProfile, and rename the APIs to match
this prefix.

* src/util/network.c, src/util/network.h: Rename port profile
  APIs
* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/conf/network_conf.c, src/conf/network_conf.h,
  src/network/bridge_driver.c, src/qemu/qemu_hotplug.c,
  src/util/macvtap.c, src/util/macvtap.h: Update for
  renamed APIs/structs

13 years agomaint: Add Michael Wood as an author
Stefan Berger [Mon, 14 Nov 2011 20:26:55 +0000 (15:26 -0500)]
maint: Add Michael Wood as an author

Add Michael Wood <esiotrot@gmail.com> as an author.

13 years agoPATCH: Fix build without MACVTAP
Michael Wood [Sat, 12 Nov 2011 11:39:17 +0000 (13:39 +0200)]
PATCH: Fix build without MACVTAP

Hi

Commit c31d23a78715f1144c73862c46ab0436de8b5e85 removed the "conn"
parameter from qemuPhysIfaceConnect(), but it's still used if
WITH_MACVTAP is false.  Also, it's still mentioned in the comment
above the function:

/**
 * qemuPhysIfaceConnect:
 * @def: the definition of the VM (needed by 802.1Qbh and audit)
 * @conn: pointer to virConnect object
 * @driver: pointer to the qemud_driver
 * @net: pointer to he VM's interface description with direct device type
 * @qemuCaps: flags for qemu
 *
 * Returns a filedescriptor on success or -1 in case of error.
 */
int
qemuPhysIfaceConnect(virDomainDefPtr def,
                     struct qemud_driver *driver,
                     virDomainNetDefPtr net,
                     virBitmapPtr qemuCaps,
                     enum virVMOperationType vmop)
{
    int rc;
#if WITH_MACVTAP
[...]
#else
    (void)def;
    (void)conn;
    (void)net;
    (void)qemuCaps;
    (void)driver;
    (void)vmop;
    qemuReportError(VIR_ERR_INTERNAL_ERROR,
                    "%s", _("No support for macvtap device"));
    rc = -1;
#endif
    return rc;
}

--
Michael Wood <esiotrot@gmail.com>

From f4fc43b4111a4c099395c55902e497b8965e2b53 Mon Sep 17 00:00:00 2001
From: Michael Wood <esiotrot@gmail.com>
Date: Sat, 12 Nov 2011 13:37:53 +0200
Subject: [PATCH] Fix build without MACVTAP.

13 years agostorage: forbid rebuilding existing disk storage pools
Guido Günther [Sat, 12 Nov 2011 12:31:52 +0000 (13:31 +0100)]
storage: forbid rebuilding existing disk storage pools

which would blow away all volumes. Honor VIR_STORAGE_POOL_BUILD_OVERWRITE
to force a rebuild.

This was caught by libvirt-tck's storage/110-disk-pool.t.

13 years agoAPI: add trivial qemu support for VIR_TYPED_PARAM_STRING
Eric Blake [Tue, 1 Nov 2011 22:48:38 +0000 (16:48 -0600)]
API: add trivial qemu support for VIR_TYPED_PARAM_STRING

Qemu will be the first driver to make use of a typed string in the
next round of additions.  Separate out the trivial addition.

* src/qemu/qemu_driver.c (qemudSupportsFeature): Advertise feature.
(qemuDomainGetBlkioParameters, qemuDomainGetMemoryParameters)
(qemuGetSchedulerParametersFlags, qemudDomainBlockStatsFlags):
Allow typed strings flag where trivially supported.

13 years agoAPI: remote support for VIR_TYPED_PARAM_STRING
Eric Blake [Wed, 12 Oct 2011 09:26:34 +0000 (17:26 +0800)]
API: remote support for VIR_TYPED_PARAM_STRING

Send and receive string typed parameters across RPC.  This also
completes the back-compat mentioned in the previous patch - the
only time we have an older client talking to a newer server is
if RPC is in use, so filtering out strings during RPC prevents
returning an unknown type to the older client.

* src/remote/remote_protocol.x (remote_typed_param_value): Add
another union value.
* daemon/remote.c (remoteDeserializeTypedParameters): Handle
strings on rpc.
(remoteSerializeTypedParameters): Likewise; plus filter out
strings when replying to older clients.  Adjust callers.
* src/remote/remote_driver.c (remoteFreeTypedParameters)
(remoteSerializeTypedParameters)
(remoteDeserializeTypedParameters): Handle strings on rpc.
* src/rpc/gendispatch.pl: Properly clean up typed arrays.
* src/remote_protocol-structs: Update.
Based on an initial patch by Hu Tao, with feedback from
Daniel P. Berrange.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoAPI: add VIR_TYPED_PARAM_STRING
Eric Blake [Wed, 12 Oct 2011 09:26:34 +0000 (17:26 +0800)]
API: add VIR_TYPED_PARAM_STRING

This allows strings to be transported between client and server
in the context of name-type-value virTypedParameter functions.
For compatibility,

    o new clients will not send strings to old servers, based on
      a feature check
    o new servers will not send strings to old clients without the
      flag VIR_TYPED_PARAM_STRING_OKAY; this will be enforced at
      the RPC layer in the next patch, so that drivers need not
      worry about it in general.  The one exception is that
      virDomainGetSchedulerParameters lacks a flags argument, so
      it must not return a string; drivers that forward that
      function on to virDomainGetSchedulerParametersFlags will
      have to pay attention to the flag.
    o the flag VIR_TYPED_PARAM_STRING_OKAY is set automatically,
      based on a feature check (so far, no driver implements it),
      so clients do not have to worry about it

Future patches can then enable the feature on a per-driver basis.

This patch also ensures that drivers can blindly strdup() field
names (previously, a malicious client could stuff 80 non-NUL bytes
into field and cause a read overrun).

* src/libvirt_internal.h (VIR_DRV_FEATURE_TYPED_PARAM_STRING): New
driver feature.
* src/libvirt.c (virTypedParameterValidateSet)
(virTypedParameterSanitizeGet): New helper functions.
(virDomainSetMemoryParameters, virDomainSetBlkioParameters)
(virDomainSetSchedulerParameters)
(virDomainSetSchedulerParametersFlags)
(virDomainGetMemoryParameters, virDomainGetBlkioParameters)
(virDomainGetSchedulerParameters)
(virDomainGetSchedulerParametersFlags, virDomainBlockStatsFlags):
Use them.
* src/util/util.h (virTypedParameterArrayClear): New helper
function.
* src/util/util.c (virTypedParameterArrayClear): Implement it.
* src/libvirt_private.syms (util.h): Export it.
Based on an initial patch by Hu Tao, with feedback from
Daniel P. Berrange.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoutil: fix compile error on debian
Eli Qiao [Fri, 11 Nov 2011 05:50:46 +0000 (13:50 +0800)]
util: fix compile error on debian

Add virnetdev.h,virnetdevbridge.h,virnetdevtap.h to private symbols,
since debian linker no longer allows transitive link resolution

Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
13 years agoqemu: fix domjobabort regression
Eric Blake [Tue, 8 Nov 2011 19:01:48 +0000 (12:01 -0700)]
qemu: fix domjobabort regression

This reverts commit ef1065cf5ac; see also this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=751900

In qemu 0.15.1 and earlier, during migration to file, the
qemu_savevm_state_begin and qemu_savevm_state_iterate methods
will both process as much migration data as possible until either

  1. The file descriptor returns EAGAIN
  2. The bandwidth rate limit is reached

If we set the rate limit to ULONG_MAX, test 2 never becomes true. We're
passing a plain file descriptor to QEMU and POSIX does not support EAGAIN on
regular files / block devices, so test 1 never becomes true either.

In the 'virsh save --bypass-cache' case, we pass a pipe instead of a
regular fd, but using a pipe adds I/O overhead, so always passing a
pipe just so qemu can see EAGAIN doesn't seem nice.

The ultimate fix needs to come from qemu - background migration must
respect asynchronous abort requests, or else periodically return
control to the main handling loop without an EAGAIN and without
waiting to hit an insanely large amount of data.  But until a
version of qemu is fixed to support "unlimited" data rates while
still allowing cancellation, the best we can do is avoid the
automatic use of unlimited rates from within libvirt (users can
still explicitly change the migration rates, if they are aware that
they are giving up the ability to cancel a job).

Reverting the lone use of QEMU_DOMAIN_FILE_MIG_BANDWIDTH_MAX is
the simplest patch; this slows migration back down to a default
32M/sec cap, but also ensures that the main qemu processing loop
will still be responsive to cancellation requests.  Hopefully
upstream qemu will provide us a means of safely using unlimited
speed, including a runtime probe of that capability.

* src/qemu/qemu_migration.c (qemuMigrationToFile): Revert attempt
to use unlimited migration bandwidth when migrating to file.

Signed-off-by: Daniel Veillard <veillard@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agofix two bugs in bridge_driver.c
Hu Tao [Fri, 11 Nov 2011 08:20:19 +0000 (16:20 +0800)]
fix two bugs in bridge_driver.c

steps to reproduce:

1. having a network xml file(named default.xml) like this one:

<network>
  <name>default</name>
  <uuid>c5322c4c-81d0-4985-a363-ad6389780d89</uuid>
  <bridge name="virbr0" />
  <forward/>
  <ip address="192.168.122.1" netmask="255.255.255.0">
    <dhcp>
      <range start="192.168.122.2" end="192.168.122.254" />
    </dhcp>
  </ip>
</network>

in /etc/libvirt/qemu/networks/, and mark it as autostart:

$ ls -l /etc/libvirt/qemu/networks/autostart
total 0
lrwxrwxrwx 1 root root 14 Oct 12 14:02 default.xml -> ../default.xml

2. start libvirtd and the device virbr0 is not automatically up.

The reason is that the function virNetDevExists is now returns 1 if
the device exists, comparing to the former one returns 0 if the device
exists. But with only this fix will cause a segmentation fault(the same
steps as above)  that is fixed by the second chunk of code.

13 years agobuild: drop useless dirent.h includes
Eric Blake [Mon, 7 Nov 2011 17:47:31 +0000 (10:47 -0700)]
build: drop useless dirent.h includes

* .gnulib: Update to latest, for improved syntax-check.
* src/lxc/lxc_container.c (includes): Drop unused include.
* src/network/bridge_driver.c: Likewise.
* src/node_device/node_device_linux_sysfs.c: Likewise.
* src/openvz/openvz_driver.c: Likewise.
* src/qemu/qemu_conf.c: Likewise.
* src/storage/storage_backend_iscsi.c: Likewise.
* src/storage/storage_backend_mpath.c: Likewise.
* src/uml/uml_conf.c: Likewise.
* src/uml/uml_driver.c: Likewise.

13 years agoxenapi: remove unused variable
Eric Blake [Fri, 11 Nov 2011 18:10:18 +0000 (11:10 -0700)]
xenapi: remove unused variable

  CC     libvirt_driver_xenapi_la-xenapi_driver.lo
xenapi/xenapi_driver.c: In function 'xenapiDomainGetVcpus':
xenapi/xenapi_driver.c:1209:21: error: variable 'cpus' set but not used [-Werror=unused-but-set-variable]

* src/xenapi/xenapi_driver.c (xenapiDomainGetVcpus): Silence
compiler warning.

13 years agomaint: use mailmap, not AUTHORS, for secondary addresses
Eric Blake [Fri, 11 Nov 2011 15:22:23 +0000 (08:22 -0700)]
maint: use mailmap, not AUTHORS, for secondary addresses

* AUTHORS: Move Stefan's second entry...
* .mailmap: ...here.

13 years agomaint: fix make syntax-check
Stefan Berger [Thu, 10 Nov 2011 16:34:53 +0000 (11:34 -0500)]
maint: fix make syntax-check

Add my 2nd email to the list of AUTHORS to get 'make syntax-check'
to pass.

13 years agoRemove code instantiating filters on direct interfaces
Stefan Berger [Thu, 10 Nov 2011 16:16:22 +0000 (11:16 -0500)]
Remove code instantiating filters on direct interfaces

Remove the code that instantiates network filters on direct type
of interfaces. The parser already does not accept it.

13 years agoDisable numactl on ARM architectures too
Daniel P. Berrange [Thu, 10 Nov 2011 11:33:17 +0000 (11:33 +0000)]
Disable numactl on ARM architectures too

* libvirt.spec.in: Disable numactl on ARM

13 years agoAdd libvirt confdir to files section in mingw32 spec
Daniel P. Berrange [Thu, 10 Nov 2011 11:30:57 +0000 (11:30 +0000)]
Add libvirt confdir to files section in mingw32 spec

* mingw32-libvirt.spec.in: Ensure we own the confdir

13 years agonwfilter: simplify execution of ebiptables scripts
Eric Blake [Wed, 9 Nov 2011 17:29:57 +0000 (10:29 -0700)]
nwfilter: simplify execution of ebiptables scripts

It's not worth even worrying about a temporary file, unless we
ever expect the script to exceed maximum command-line argument
length limits.

* src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesExecCLI):
Run the commands as an argument to /bin/sh, rather than worrying
about a temporary file.
(ebiptablesWriteToTempFile): Delete unused function.

13 years agonwfilter: avoid failure with noexec /tmp
Eric Blake [Wed, 9 Nov 2011 17:23:49 +0000 (10:23 -0700)]
nwfilter: avoid failure with noexec /tmp

If /tmp is mounted with the noexec flag (common on security-conscious
systems), then nwfilter will fail to initialize, because we cannot
run any temporary script via virRun("/tmp/script"); but we _can_
use "/bin/sh /tmp/script".  For that matter, using /tmp risks collisions
with other unrelated programs; we already have /var/run/libvirt as a
dedicated temporary directory for use by libvirt.

* src/nwfilter/nwfilter_ebiptables_driver.c
(ebiptablesWriteToTempFile): Use internal directory, not /tmp;
drop attempts to make script executable; and detect close error.
(ebiptablesExecCLI): Switch to virCommand, and invoke the shell to
read the script, rather than requiring an executable script.

13 years agoAdjust naming of network device bandwidth management APIs
Daniel P. Berrange [Wed, 2 Nov 2011 14:29:05 +0000 (14:29 +0000)]
Adjust naming of network device bandwidth management APIs

Rename virBandwidth to virNetDevBandwidth, and virRate to
virNetDevBandwidthRate.

* src/util/network.c, src/util/network.h: Rename bandwidth
  structs and APIs
* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/conf/network_conf.c, src/conf/network_conf.h,
  src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/qemu/qemu_command.c, src/util/macvtap.c,
  src/util/macvtap.h, tools/virsh.c: Update for API changes.

13 years agoSantize naming of socket address APIs
Daniel P. Berrange [Wed, 2 Nov 2011 14:06:59 +0000 (14:06 +0000)]
Santize naming of socket address APIs

The socket address APIs in src/util/network.h either take the
form  virSocketAddrXXX, virSocketXXX or virSocketXXXAddr.

Sanitize this so everything is virSocketAddrXXXX, and ensure
that the virSocketAddr parameter is always the first one.

* src/util/network.c, src/util/network.h: Santize socket
  address API naming
* src/conf/domain_conf.c, src/conf/network_conf.c,
  src/conf/nwfilter_conf.c, src/network/bridge_driver.c,
  src/nwfilter/nwfilter_ebiptables_driver.c,
  src/nwfilter/nwfilter_learnipaddr.c,
  src/qemu/qemu_command.c, src/rpc/virnetsocket.c,
  src/util/dnsmasq.c, src/util/iptables.c,
  src/util/virnetdev.c, src/vbox/vbox_tmpl.c: Update for
  API renaming

13 years agoSplit bridge.h into three separate files
Daniel P. Berrange [Wed, 2 Nov 2011 13:41:58 +0000 (13:41 +0000)]
Split bridge.h into three separate files

Following the renaming of the bridge management APIs, we can now
split the source file into 3 corresponding pieces

 * src/util/virnetdev.c: APIs for any type of network interface
 * src/util/virnetdevbridge.c: APIs for bridge interfaces
 * src/util/virnetdevtap.c: APIs for TAP interfaces

* src/util/virnetdev.c, src/util/virnetdev.h,
  src/util/virnetdevbridge.c, src/util/virnetdevbridge.h,
  src/util/virnetdevtap.c, src/util/virnetdevtap.h: Copied
  from bridge.{c,h}
* src/util/bridge.c, src/util/bridge.h: Split into 3 pieces
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/openvz/openvz_driver.c, src/qemu/qemu_command.c,
  src/qemu/qemu_conf.h, src/uml/uml_conf.c, src/uml/uml_conf.h,
  src/uml/uml_driver.c: Update #include directives

13 years agoRemove usage of brctl command line tool
Daniel P. Berrange [Wed, 2 Nov 2011 13:05:27 +0000 (13:05 +0000)]
Remove usage of brctl command line tool

Convert the virNetDevBridgeSetSTP and virNetDevBridgeSetSTPDelay
to use ioctls instead of spawning brctl.

Implement the virNetDevBridgeGetSTP and virNetDevBridgeGetSTPDelay
methods which were declared in the header but never existed

* src/util/bridge.c: Convert to use bridge ioctls instead of brctl

13 years agoAdd an API for retrieving the MAC address of an interface
Daniel P. Berrange [Wed, 2 Nov 2011 13:00:09 +0000 (13:00 +0000)]
Add an API for retrieving the MAC address of an interface

* src/util/bridge.c, src/util/bridge.h: Add virNetDevGetMAC

13 years agoExpose MTU management APIs
Daniel P. Berrange [Wed, 2 Nov 2011 12:57:41 +0000 (12:57 +0000)]
Expose MTU management APIs

The MTU management APIs are useful to other code inside libvirt,
so should be exposed as non-static APIs.

* src/util/bridge.c, src/util/bridge.h: Expose virNetDevSetMTU,
  virNetDevSetMTUFromDevice & virNetDevGetMTU

13 years agoTurn two int parameters into bools in bridge APIs
Daniel P. Berrange [Wed, 2 Nov 2011 12:54:45 +0000 (12:54 +0000)]
Turn two int parameters into bools in bridge APIs

* src/util/bridge.c, src/util/bridge.h: s/int/bool/ in
  virNetDevSetOnline and virNetDevBridgeSetSTP

13 years agoRename all brXXXX APIs to follow new convention
Daniel P. Berrange [Wed, 2 Nov 2011 12:35:18 +0000 (12:35 +0000)]
Rename all brXXXX APIs to follow new convention

The existing brXXX APIs in src/util/bridge.h are renamed to
follow one of three different conventions

 - virNetDevXXX       - operations for any type of interface
 - virNetDevBridgeXXX - operations for bridge interfaces
 - virNetDevTapXXX    - operations for tap interfaces

* src/util/bridge.h, src/util/bridge.c: Rename all APIs
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/qemu/qemu_command.c, src/uml/uml_conf.c,
  src/uml/uml_driver.c: Update for API renaming

13 years agoMake all brXXX APIs raise errors, instead of returning errnos
Daniel P. Berrange [Wed, 2 Nov 2011 12:00:28 +0000 (12:00 +0000)]
Make all brXXX APIs raise errors, instead of returning errnos

Currently every caller of the brXXX APIs has to store the returned
errno value and then raise an error message. This results in
inconsistent error messages across drivers, additional burden on
the callers and makes the error reporting inaccurate since it is
hard to distinguish different scenarios from 1 errno value.

* src/util/bridge.c: Raise errors instead of returning errnos
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/qemu/qemu_command.c, src/uml/uml_conf.c,
  src/uml/uml_driver.c: Remove error reporting code

13 years agoRemove 'brControl' object
Daniel P. Berrange [Wed, 2 Nov 2011 10:56:38 +0000 (10:56 +0000)]
Remove 'brControl' object

The bridge management APIs in src/util/bridge.c require a brControl
object to be passed around. This holds the file descriptor for the
control socket. This extra object complicates use of the API for
only a minor efficiency gain, which is in turn entirely offset by
the need to fork/exec the brctl command for STP configuration.

This patch removes the 'brControl' object entirely, instead opening
the control socket & closing it again within the scope of each method.

The parameter names for the APIs are also made to consistently use
'brname' for bridge device name, and 'ifname' for an interface
device name. Finally annotations are added for non-NULL parameters
and return check validation

* src/util/bridge.c, src/util/bridge.h: Remove brControl object
  and update API parameter names & annotations.
* src/lxc/lxc_driver.c, src/network/bridge_driver.c,
  src/uml/uml_conf.h, src/uml/uml_conf.c, src/uml/uml_driver.c,
  src/qemu/qemu_command.c, src/qemu/qemu_conf.h,
  src/qemu/qemu_driver.c: Remove reference to 'brControl' object

13 years agobuild: fix mingw build of gnulib openpty
Eric Blake [Wed, 9 Nov 2011 00:14:34 +0000 (17:14 -0700)]
build: fix mingw build of gnulib openpty

Commit f7bd00c12 pulled in a gnulib module that fails to compile
on mingw.  Work around it while waiting for an upstream gnulib fix.

* gnulib/local/lib/pty.in.h (openpty): Provide forward
declarations of opaque structs not present on mingw.
* gnulib/local/lib/openpty.c (openpty): Provide stub for mingw.

13 years agobuild: allow for local gnulib diffs
Eric Blake [Wed, 9 Nov 2011 00:06:27 +0000 (17:06 -0700)]
build: allow for local gnulib diffs

Commit f7bd00c12 pulled in a gnulib module that fails to compile
on mingw.  While it would be nice to pull in a newer version of
.gnulib that fixes this, it is difficult to backport any .gnulib
update to older releases.  So, it makes sense to take advantage
of gnulib-tool's ability to support local diffs, where we can
apply specific diffs in our use of gnulib without waiting for
upstream gnulib to pick up those changes, as well as avoiding
a wholesale .gnulib update.  The existence of local diffs will
also make it easier to backport fixes against a tarball (as long
as a tarball and libvirt.git share the same .gnulib commit, then
the tarball can be patched by applying the same local diffs as
a post-release libvirt.git commit, without having to rerun an
entire gnulib-tool bootstrap).

This patch introduces the framework for supporting local diffs,
without actually introducing any.

* bootstrap.conf (local_gl_dir): New variable.
* autogen.sh (bootstrap_hash): Hash any local diffs, to force a
re-bootstrap if just diffs change.
* cfg.mk (_update_required): Likewise.

13 years agolxc: free error object to avoid memory leak
Alex Jia [Wed, 9 Nov 2011 06:20:28 +0000 (14:20 +0800)]
lxc: free error object to avoid memory leak

Detected by Coverity. Leak introduced in commit 9d201a5.

* src/lxc/lxc_driver.c: Clean up on failure.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agolxc: free 'ttyFDs' array on return from lxcVmStart
Alex Jia [Wed, 9 Nov 2011 06:51:26 +0000 (14:51 +0800)]
lxc: free 'ttyFDs' array on return from lxcVmStart

Detected by Coverity. Leak introduced in commit 0f31f7b.

* src/lxc/lxc_driver.c: Clean up on failure.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: Fix improper error message for disk detaching
Osier Yang [Wed, 9 Nov 2011 05:58:51 +0000 (13:58 +0800)]
qemu: Fix improper error message for disk detaching

s/virDomainDeviceTypeToString/virDomainDiskDeviceTypeToString/

Report by Xu He Jie <xuhj@linux.vnet.ibm.

13 years agovirsh: Add VSH_OFLAG_EMPTY_OK for attach-disk command
Xu He Jie [Tue, 8 Nov 2011 07:16:34 +0000 (15:16 +0800)]
virsh: Add VSH_OFLAG_EMPTY_OK for attach-disk command

As the description of removing CDROM media from
  http://wiki.libvirt.org/page/QEMUSwitchToLibvirt#eject_DEV

Add flag 'VSH_OFLAG_EMPTY_OK' to the option 'source' of attach-disk

Then avoid outputting <source> in the XML if 'source' was empty,
rather than trusting libvirt domain_conf.c to understand an empty
string.

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoRelease of libvirt-0.9.7
Daniel Veillard [Tue, 8 Nov 2011 06:55:25 +0000 (14:55 +0800)]
Release of libvirt-0.9.7

* confiure.ac docs/news.html.in libvirt.spec.in: update for release
* po/*.po*: update localizations and rebuilt

13 years agobuild: fix build on platforms without ptsname_r
Eric Blake [Thu, 3 Nov 2011 20:56:13 +0000 (14:56 -0600)]
build: fix build on platforms without ptsname_r

MacOS lacks ptsname_r, and gnulib doesn't (yet) provide it.
But we can avoid it altogether, by using gnulib openpty()
instead.  Note that we do _not_ want the pt_chown module;
gnulib uses it only to implement a replacement openpty() if
the system lacks both openpty() and granpt(), but all
systems that we currently port to either have at least one of
openpty() and/or grantpt(), or lack ptys altogether.  That is,
we aren't porting to any system that requires us to deal with
the hassle of installing a setuid pt_chown helper just to use
gnulib's ability to provide openpty() on obscure platforms.

* .gnulib: Update to latest, for openpty fixes
* bootstrap.conf (gnulib_modules): Add openpty, ttyname_r.
(gnulib_tool_option_extras): Exclude pt_chown module.
* src/util/util.c (virFileOpenTty): Rewrite in terms of openpty
and ttyname_r.
* src/util/util.h (virFileOpenTtyAt): Delete dead prototype.

13 years agoAdd missing defaultConsoleTargetType callback for AppArmour
Daniel P. Berrange [Mon, 7 Nov 2011 10:17:28 +0000 (10:17 +0000)]
Add missing defaultConsoleTargetType callback for AppArmour

Every instance of virCapsPtr must have the defaultConsoleTargetType
field set.

* src/security/virt-aa-helper.c: Add defaultConsoleTargetType to
  virCapsPtr

13 years agoFix sending/receiving of FDs when stream returns EAGAIN
Daniel P. Berrange [Fri, 4 Nov 2011 16:02:14 +0000 (16:02 +0000)]
Fix sending/receiving of FDs when stream returns EAGAIN

The code calling sendfd/recvfd was mistakenly assuming those
calls would never block. They can in fact return EAGAIN and
this is causing us to drop the client connection when blocking
ocurrs while sending/receiving FDs.

Fixing this is a little hairy on the incoming side, since at
the point where we see the EAGAIN, we already thought we had
finished receiving all data for the packet. So we play a little
trick to reset bufferOffset again and go back into polling for
more data.

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Update
  virNetSocketSendFD/RecvFD to return 0 on EAGAIN, or 1
  on success
* src/rpc/virnetclient.c: Move decoding of header & fds
  out of virNetClientCallDispatch and into virNetClientIOHandleInput.
  Handling blocking when sending/receiving FDs
* src/rpc/virnetmessage.h: Add a 'donefds' field to track
  how many FDs we've sent / received
* src/rpc/virnetserverclient.c: Handling blocking when
  sending/receiving FDs

13 years agobuild: silence compiler warning on BSD
Eric Blake [Fri, 4 Nov 2011 22:32:30 +0000 (16:32 -0600)]
build: silence compiler warning on BSD

Building on 64-bit FreeBSD 8.2 complained about a cast between
a pointer and a smaller integer.  Going through an intermediate
cast shuts up the compiler.

* src/util/threads-pthread.c (virThreadSelfID): Silence a warning.

13 years agobuild: fix linking on BSD
Eric Blake [Fri, 4 Nov 2011 20:53:15 +0000 (14:53 -0600)]
build: fix linking on BSD

While building on FreeBSD (and after fixing a ptsname_r link error),
I got this failure:

./.libs/libvirt_util.a(libvirt_util_la-threads.o)(.text+0x240): In function `virThreadCreate':
util/threads-pthread.c:185: undefined reference to `pthread_create'

It turns out that gnulib used only pthread_join for LIB_PTHREAD,
but on FreeBSD, libc provides that (as a stub function); whereas
the more complex pthread_create really does require -pthread,
which gnulib tracked under [LT]LIBMULTITHREAD.

* configure.ac (LIBS): Check LIBMULTITHREAD alongside LIB_PTHREAD.
* src/Makefile.am (THREAD_LIBS): New variable.
(libvirt_util_la_LIBADD, libvirt_lxc_LDADD): Use it.

13 years agoremote: fix mingw32 build
Laine Stump [Fri, 4 Nov 2011 20:10:54 +0000 (16:10 -0400)]
remote: fix mingw32 build

tty is initialized, and later set in code that is compiled for all
platforms, but is only used in a section that's inside #ifndef WIN32.

13 years agolxc: avoid use-after-free
Eric Blake [Thu, 3 Nov 2011 23:24:32 +0000 (17:24 -0600)]
lxc: avoid use-after-free

I got this weird failure:

error: Failed to start domain simple
error: internal error cannot mix caller fds with blocking execution

and tracked it down to a use-after-free - virCommandSetOutputFD
was storing the address of a stack-local variable, which then
went out of scope before the virCommandRun that dereferenced it.

Bug introduced in commit 451cfd05 (0.9.2).

* src/lxc/lxc_driver.c (lxcBuildControllerCmd): Move log fd
registration...
(lxcVmStart): ...to caller.

13 years agoFix naming of constant for disk event
Daniel P. Berrange [Fri, 4 Nov 2011 12:16:19 +0000 (12:16 +0000)]
Fix naming of constant for disk event

All constants related to events should have a prefix of
VIR_DOMAIN_EVENT_

* include/libvirt/libvirt.h.in, src/qemu/qemu_domain.c:
  Rename VIR_DOMAIN_DISK_CHANGE_MISSING_ON_START to
  VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START

13 years agoconf: Don't free uninitialized pointer
Jiri Denemark [Fri, 4 Nov 2011 08:25:20 +0000 (09:25 +0100)]
conf: Don't free uninitialized pointer

This causes libvirtd to crash when both <boot dev='...'/> and <boot
order='...'/> are used in one domain XML. Introduced by
5fa3d775a9f8cdb3423373eb084219aaf778df11

13 years agobuild: fix deep VPATH builds
Eric Blake [Thu, 3 Nov 2011 19:50:13 +0000 (13:50 -0600)]
build: fix deep VPATH builds

I ran into the following build failure:
$ mkdir -p build1 build2/a/very/deep/hierarcy
$ cd build2/a/very/deep/hierarcy
$ ../../../../../configure && make
$ cd ../../../../build1
$ ../configure && make
...
../../src/remote/remote_protocol.c:7:55: fatal error: ../../../../../src/remote/remote_protocol.h: No such file or directory

Turns out that we were sometimes generating the remote_protocol.c
file with information from the VPATH build, which is bad, since
any file shipped in the tarball should be idempotent no matter how
deep the VPATH build tree that created it.

* src/rpc/genprotocol.pl: Don't embed VPATH into generated file.

13 years agodoc: Add <deviceboot> capability.
Philipp Hahn [Tue, 1 Nov 2011 09:27:47 +0000 (10:27 +0100)]
doc: Add <deviceboot> capability.

Allow /capabilities/guest/features/deviceboot.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agolxc: use common code for process cleanup
Eric Blake [Fri, 21 Oct 2011 17:09:23 +0000 (11:09 -0600)]
lxc: use common code for process cleanup

Based on a Coverity report - the return value of waitpid() should
always be checked, to avoid problems with leaking resources.

* src/lxc/lxc_controller.c (lxcControllerRun): Use simpler virPidAbort.

13 years agoFix default console type setting
Daniel P. Berrange [Thu, 20 Oct 2011 13:56:20 +0000 (14:56 +0100)]
Fix default console type setting

The default console type may vary based on the OS type. ie a Xen
paravirt guests wants a 'xen' console, while a fullvirt guests
wants a 'serial' console.

A plain integer default console type in the capabilities does
not suffice. Instead introduce a callback that is passed the
OS type.

* src/conf/capabilities.h: Use a callback for default console
  type
* src/conf/domain_conf.c, src/conf/domain_conf.h: Use callback
  for default console type. Add missing LXC/OpenVZ console types.
* src/esx/esx_driver.c, src/libxl/libxl_conf.c,
  src/lxc/lxc_conf.c, src/openvz/openvz_conf.c,
  src/phyp/phyp_driver.c, src/qemu/qemu_capabilities.c,
  src/uml/uml_conf.c, src/vbox/vbox_tmpl.c,
  src/vmware/vmware_conf.c, src/xen/xen_hypervisor.c,
  src/xenapi/xenapi_driver.c: Set default console type callback

13 years agoSet aliases for LXC/UML console devices
Daniel P. Berrange [Thu, 20 Oct 2011 13:57:10 +0000 (14:57 +0100)]
Set aliases for LXC/UML console devices

To allow virDomainOpenConsole to access non-primary consoles,
device aliases are required to be set. Until now only the QEMU
driver has done this. Update LXC & UML to set aliases for any
console devices

* src/lxc/lxc_driver.c, src/uml/uml_driver.c: Set aliases
  for console devices

13 years agoDefault console target type with no <target> element
Daniel P. Berrange [Thu, 20 Oct 2011 13:56:30 +0000 (14:56 +0100)]
Default console target type with no <target> element

When no <target> element was set at all, the default console
target type was not being honoured

* src/conf/domain_conf.c: Set default target type for consoles
  with no <target>

13 years agoAdd support for multiple consoles in LXC
Daniel P. Berrange [Thu, 20 Oct 2011 08:44:31 +0000 (09:44 +0100)]
Add support for multiple consoles in LXC

Currently the LXC controller only supports setup of a single
text console. This is wired up to the container init's stdio,
as well as /dev/console and /dev/tty1. Extending support for
multiple consoles, means wiring up additional PTYs to /dev/tty2,
/dev/tty3, etc, etc. The LXC controller is passed multiple open
file handles, one for each console requested.

* src/lxc/lxc_container.c, src/lxc/lxc_container.h: Wire up
  all the /dev/ttyN links required to symlink to /dev/pts/NN
* src/lxc/lxc_container.h: Open more container side /dev/pts/NN
  devices, and adapt event loop to handle I/O from all consoles
* src/lxc/lxc_driver.c: Setup multiple host side PTYs

13 years agoRewrite LXC I/O forwarding to use main event loop
Daniel P. Berrange [Wed, 19 Oct 2011 15:22:24 +0000 (16:22 +0100)]
Rewrite LXC I/O forwarding to use main event loop

The current I/O code for LXC uses a hand crafted event loop
to forward I/O between the container & host app, based on
epoll to handle EOF on PTYs. This event loop is not easily
extensible to add more consoles, or monitor other types of
file descriptors.

Remove the custom event loop and replace it with a normal
libvirt event loop. When detecting EOF on a PTY, disable
the event watch on that FD, and fork off a background thread
that does a edge-triggered epoll() on the FD. When the FD
finally shows new incoming data, the thread re-enables the
watch on the FD and exits.

When getting EOF from a read() on the PTY, the existing code
would do waitpid(WNOHANG) to see if the container had exited.
Unfortunately there is a race condition, because even though
the process has closed its stdio handles, it might still
exist.

To deal with this the new event loop uses a SIG_CHILD handler
to perform the waitpid only when the container is known to
have actually exited.

* src/lxc/lxc_controller.c: Rewrite the event loop to use
  the standard APIs.

13 years agoFix crash formatting virtio console
Daniel P. Berrange [Wed, 19 Oct 2011 10:45:10 +0000 (11:45 +0100)]
Fix crash formatting virtio console

qemuBuildVirtioSerialPortDevStr was mistakenly accessing the
target.name field in the virDomainChrDef object for chardevs
belonging to a console. Those chardevs only have port set,
and if there's > 1 console, the > 1port number results in
trying to access a target.name with address 0x1

* src/qemu/qemu_command.c: Fix target.name handling and
  make code more robust wrt error reporting

* src/qemu/qemu_command.c: Conditionally access target.name

13 years agoAllow multiple consoles per virtual guest
Daniel P. Berrange [Wed, 23 Feb 2011 18:27:23 +0000 (18:27 +0000)]
Allow multiple consoles per virtual guest

While Xen only has a single paravirt console, UML, and
QEMU both support multiple paravirt consoles. The LXC
driver can also be trivially made to support multiple
consoles. This patch extends the XML to allow multiple
<console> elements in the XML. It also makes the UML
and QEMU drivers support this config.

* src/conf/domain_conf.c, src/conf/domain_conf.h: Allow
  multiple <console> devices
* src/lxc/lxc_driver.c, src/xen/xen_driver.c,
  src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c: Update for
  internal API changes
* src/security/security_selinux.c, src/security/virt-aa-helper.c:
  Only label consoles that aren't a copy of the serial device
* src/qemu/qemu_command.c, src/qemu/qemu_driver.c,
  src/qemu/qemu_process.c, src/uml/uml_conf.c,
  src/uml/uml_driver.c: Support multiple console devices
* tests/qemuxml2xmltest.c, tests/qemuxml2argvtest.c: Extra
  tests for multiple virtio consoles. Set QEMU_CAPS_CHARDEV
  for all console /channel tests
* tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.args,
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
  tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args: Update
  for correct chardev syntax
* tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.args,
  tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.xml: New
  test file

13 years agoRemove translations in socket test case
Daniel P. Berrange [Thu, 3 Nov 2011 10:52:44 +0000 (10:52 +0000)]
Remove translations in socket test case

The test case errors should not be translated since they're only
targetted at developers, not users.

* tests/virnetsockettest.c: Remove error reporting with translations

13 years agovirnetsockettest: Use a temporary directory in /tmp
Guido Günther [Wed, 2 Nov 2011 21:06:44 +0000 (22:06 +0100)]
virnetsockettest: Use a temporary directory in /tmp

to avoid exceeding UNIX_PATH_MAX

13 years agoUse ENAMETOOLONG if the the socket path is longer than UNIX_PATH_MAX
Guido Günther [Wed, 2 Nov 2011 20:39:31 +0000 (21:39 +0100)]
Use ENAMETOOLONG if the the socket path is longer than UNIX_PATH_MAX

13 years agoxen: allow getting < max typed parameters
Eric Blake [Wed, 2 Nov 2011 17:57:29 +0000 (11:57 -0600)]
xen: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.

* src/xen/xen_hypervisor.c (xenHypervisorGetSchedulerParameters):
Allow fewer than max.
* src/xen/xend_internal.c (xenDaemonGetSchedulerParameters):
Likewise.

13 years agotest: drop redundant check
Eric Blake [Wed, 2 Nov 2011 17:53:33 +0000 (11:53 -0600)]
test: drop redundant check

libvirt.c guarantees that nparams is non-zero for scheduler parameters.

* src/test/test_driver.c (testDomainGetSchedulerParamsFlags): Drop
redundant check.  Avoid strcpy.

13 years agolxc: allow getting < max typed parameters
Eric Blake [Wed, 2 Nov 2011 17:50:08 +0000 (11:50 -0600)]
lxc: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.
Also, libvirt.c filters out nparams of 0 for scheduler parameters.

* src/lxc/lxc_driver.c (lxcDomainGetMemoryParameters): Allow fewer
than max.
(lxcGetSchedulerParametersFlags): Drop redundant check.

13 years agolibxl: allow getting < max typed parameters
Eric Blake [Wed, 2 Nov 2011 17:42:38 +0000 (11:42 -0600)]
libxl: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.

* src/libxl/libxl_driver.c
(libxlDomainGetSchedulerParametersFlags): Allow fewer than max.

13 years agoesx: allow getting < max typed parameters
Eric Blake [Wed, 2 Nov 2011 17:36:12 +0000 (11:36 -0600)]
esx: allow getting < max typed parameters

Allow the user to call with nparams too small, per API documentation.

* src/esx/esx_driver.c (esxDomainGetMemoryParameters): Drop
redundant check.
(esxDomainGetSchedulerParametersFlags): Allow fewer than max.

13 years agoAPI: document scheduler parameter names
Eric Blake [Tue, 1 Nov 2011 20:38:42 +0000 (14:38 -0600)]
API: document scheduler parameter names

Document the parameter names that will be used by
virDomain{Get,Set}SchedulerParameters{,Flags}, rather than
hard-coding those names in each driver, to match what is
done with memory, blkio, and blockstats parameters.

* include/libvirt/libvirt.h.in (VIR_DOMAIN_SCHEDULER_CPU_SHARES)
(VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)
(VIR_DOMAIN_SCHEDULER_VCPU_QUOTA, VIR_DOMAIN_SCHEDULER_WEIGHT)
(VIR_DOMAIN_SCHEDULER_CAP, VIR_DOMAIN_SCHEDULER_RESERVATION)
(VIR_DOMAIN_SCHEDULER_LIMIT, VIR_DOMAIN_SCHEDULER_SHARES): New
field name macros.
* src/qemu/qemu_driver.c (qemuSetSchedulerParametersFlags)
(qemuGetSchedulerParametersFlags): Use new defines.
* src/test/test_driver.c (testDomainGetSchedulerParamsFlags)
(testDomainSetSchedulerParamsFlags): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorGetSchedulerParameters)
(xenHypervisorSetSchedulerParameters): Likewise.
* src/xen/xend_internal.c (xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters): Likewise.
* src/lxc/lxc_driver.c (lxcSetSchedulerParametersFlags)
(lxcGetSchedulerParametersFlags): Likewise.
* src/esx/esx_driver.c (esxDomainGetSchedulerParametersFlags)
(esxDomainSetSchedulerParametersFlags): Likewise.
* src/libxl/libxl_driver.c (libxlDomainGetSchedulerParametersFlags)
(libxlDomainSetSchedulerParametersFlags): Likewise.

13 years agoFix off-by-one printing month in logging code
Daniel P. Berrange [Mon, 24 Oct 2011 16:33:00 +0000 (17:33 +0100)]
Fix off-by-one printing month in logging code

The field 'mon' in 'struct tm' gives months 0-11, where as
humans tend to expect months 1-12. Thus the month number
needing adjusting by 1

* src/util/logging.c: Use human friendly month number