]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agoAdd support for setting socket MLS level in SELinux driver
Daniel J Walsh [Thu, 27 May 2010 15:44:47 +0000 (16:44 +0100)]
Add support for setting socket MLS level in SELinux driver

When SELinux is running in MLS mode, libvirtd will have a
different security level to the VMs. For libvirtd to be
able to connect to the monitor console, the client end of
the UNIX domain socket needs a different label. This adds
infrastructure to set the socket label via the security
driver framework

* src/qemu/qemu_driver.c: Call out to socket label APIs in
  security driver
* src/qemu/qemu_security_stacked.c: Wire up socket label
  drivers
* src/security/security_driver.h: Define security driver
  entry points for socket labelling
* src/security/security_selinux.c: Set socket label based on
  VM label

14 years agoNetwork duplicate UUID/name checking
Daniel P. Berrange [Thu, 27 May 2010 15:44:31 +0000 (16:44 +0100)]
Network duplicate UUID/name checking

The network driver is not doing correct checking for
duplicate UUID/name values. This introduces a new method
virNetworkObjIsDuplicate, based on the previously
written virDomainObjIsDuplicate.

* src/conf/network_conf.c, src/conf/network_conf.c,
  src/libvirt_private.syms: Add virNetworkObjIsDuplicate,
* src/network/bridge_driver.c: Call virNetworkObjIsDuplicate
  for checking uniqueness of uuid/names

14 years agoFix error codes for missing storage pools
Daniel P. Berrange [Thu, 27 May 2010 12:30:34 +0000 (13:30 +0100)]
Fix error codes for missing storage pools

The storage pool driver is mistakenly using the error code
VIR_ERR_INVALID_STORAGE_POOL which is for diagnosing invalid
pointers. This patch switches it to use VIR_ERR_NO_STORAGE_POOL
which is the correct code for cases where the storage pool does
not exist

* src/storage/storage_driver.c: Replace VIR_ERR_INVALID_STORAGE_POOL
  with VIR_ERR_NO_STORAGE_POOL

14 years agoStorage pool duplicate UUID/name checking
Daniel P. Berrange [Thu, 27 May 2010 11:41:30 +0000 (12:41 +0100)]
Storage pool duplicate UUID/name checking

The storage pool driver is not doing correct checking for
duplicate UUID/name values. This introduces a new method
virStoragePoolObjIsDuplicate, based on the previously
written virDomainObjIsDuplicate.

* src/conf/storage_conf.c, src/conf/storage_conf.c,
  src/libvirt_private.syms: Add virStoragePoolObjIsDuplicate,
* src/storage/storage_driver.c: Call virStoragePoolObjIsDuplicate
  for checking uniqueness of uuid/names

14 years agoFix auto-adding of virtio serial controllers
Daniel P. Berrange [Thu, 3 Jun 2010 12:49:35 +0000 (13:49 +0100)]
Fix auto-adding of virtio serial controllers

The domain parsing code would auto-add a virtio serial controller
if it saw any virtio serial channel defined. Unfortunately it
always added a controller with index=0, even if the channel address
specified an index != 0. It only added one controller, even if
multiple controllers were referenced by channels. Finally, it let
the ports+vectors parameters initialize to zero instead of -1, which
prevented the controllers accepting any ports.

* src/conf/domain_conf.c: Initialize ports+vectors when adding
  virtio serial controllers. Add all neccessary virtio serial
  controllers, instead of hardcoding controller 0
* qemuxml2argvdata/qemuxml2argv-channel-virtio.args,
  qemuxml2argvdata/qemuxml2argv-channel-virtio.xml: Expand to
  test controller auto-add behaviour

14 years agoInclude port number with virtio serial devices
Daniel P. Berrange [Wed, 2 Jun 2010 15:58:39 +0000 (16:58 +0100)]
Include port number with virtio serial devices

To ensure that the device addressing scheme is stable across
hotplug/unplug, all virtio serial channels needs to have an
associated port number in their address. This is then specified
to QEMU using the nr=NNN parameter

* src/conf/domain_conf.c, src/conf/domain_conf.h: Parsing
  for port number in vioserial address types.
* src/qemu/qemu_conf.c: Set 'nr=NNN' parameter with virtio
  serial port number
* tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args,
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml: Expand
  data set to ensure coverage of port addressing

14 years agoDisable use of 'reason' field in block IO event in QEMU
Daniel P. Berrange [Thu, 3 Jun 2010 14:05:30 +0000 (15:05 +0100)]
Disable use of 'reason' field in block IO event in QEMU

QEMU upstream decided against adding a 'reason' field to
the block IO event in QMP. Disable this code to remove a
annoying warning message. It will be renabled when the
error string reason is re-introduced in QEMU

14 years agoEnsure UNIX domain sockets are removed on daemon shutdown
Daniel P. Berrange [Thu, 3 Jun 2010 13:36:34 +0000 (14:36 +0100)]
Ensure UNIX domain sockets are removed on daemon shutdown

When libvirtd exits it is leaving UNIX domain sockets on
the filesystem. These need to be removed.

The qemudInitPaths() method has signficant code churn to
switch from using a pre-allocated buffer on the stack, to
dynamically allocating on the heap.

* daemon/libvirtd.c, daemon/libvirtd.h: Store a reference
  to the UNIX domain socket path and unlink it on shutdown

14 years agovirsh: fix minor virsh man page typos and formatting problems
Justin Clift [Tue, 8 Jun 2010 00:18:01 +0000 (18:18 -0600)]
virsh: fix minor virsh man page typos and formatting problems

Signed-off-by: Eric Blake <eblake@redhat.com>
14 years agoFix AppArmor save/restore.Add stdin_path to qemudStartVMDaemon() args.
Jamie Strandboge [Fri, 4 Jun 2010 16:20:29 +0000 (12:20 -0400)]
Fix AppArmor save/restore.Add stdin_path to qemudStartVMDaemon() args.

Refactor to update AppArmor security driver to adjust profile for
save/restore. This addresses the following bugs:

 https://bugzilla.redhat.com/show_bug.cgi?id=529363
 https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/457716

14 years agoAdd stdin_path to qemudStartVMDaemon() args.
Jamie Strandboge [Fri, 4 Jun 2010 16:20:29 +0000 (12:20 -0400)]
Add stdin_path to qemudStartVMDaemon() args.

Adjust args to qemudStartVMDaemon() to also specify path to stdin_fd,
so this can be passed to the AppArmor driver via SetSecurityAllLabel().

This updates all calls to qemudStartVMDaemon() as well as setting up
the non-AppArmor security driver *SetSecurityAllLabel() declarations
for the above. This is required for the following
"apparmor-fix-save-restore" patch since AppArmor resolves the passed
file descriptor to the pathname given to open().

14 years agoavoid syntax-check failure
Jim Meyering [Sun, 6 Jun 2010 08:27:28 +0000 (10:27 +0200)]
avoid syntax-check failure

* .mailmap: Map a stray commit-author email address to the canonical one.
Reported by Justin Clift.

14 years agoAdjust block size used by dd to speed QEMU domain save operations.
Laine Stump [Fri, 4 Jun 2010 03:36:00 +0000 (23:36 -0400)]
Adjust block size used by dd to speed QEMU domain save operations.

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

Saving a paused 512MB domain took 3m47s with the old block size of 512
bytes. Changing the block size to 1024*1024 decreased the time to 56
seconds. (Doubling again to 2048*1024 yielded 0 improvement; lowering
to 512k increased the save time to 1m10s, about 20%)

14 years agoFix dereference of potentially freed pointer in qemudDomainSaveFlags
Laine Stump [Fri, 4 Jun 2010 03:25:58 +0000 (23:25 -0400)]
Fix dereference of potentially freed pointer in qemudDomainSaveFlags

The pointer to the xml describing the domain is saved into an object
prior to calling VIR_REALLOC_N() to make the size of the memory it
points to a multiple of QEMU_MONITOR_MIGRATE_TO_FILE_BS. If that
operation needs to allocate new memory, the pointer that was saved is
no longer valid.

To avoid this situation, adjust the size *before* saving the pointer.

(This showed up when experimenting with very large values of
QEMU_MONITOR_MIGRATE_TO_FILE_BS).

14 years agoFixes for commit 211dd1e9
Jim Fehlig [Fri, 4 Jun 2010 16:04:03 +0000 (10:04 -0600)]
Fixes for commit 211dd1e9

Fixes for issues in commit 211dd1e9 noted by by Jim Meyering.

1. Allocate content buffer of size content_length + 1 to ensure
   NUL-termination.
2. Limit content buffer size to 64k
3. Fix whitespace issue

V2:
  - Add comment to clarify allocation of content buffer
  - Add ATTRIBUTE_NONNULL where appropriate
  - User NULLSTR macro

14 years agoautobuild.sh: avoid bashism
Eric Blake [Fri, 4 Jun 2010 03:07:09 +0000 (21:07 -0600)]
autobuild.sh: avoid bashism

* autobuild.sh: Replace 'set -o pipefail' with POSIX alternative.
Reported by Matthias Bolte.

14 years agoAllocate buffer to hold xend response
Jim Fehlig [Thu, 3 Jun 2010 00:07:17 +0000 (18:07 -0600)]
Allocate buffer to hold xend response

There are cases when a response from xend can exceed 4096 bytes, in
which case anything beyond 4096 is ignored. This patch changes the
current fixed-size, stack-allocated buffer to a dynamically allocated
buffer based on Content-Length in HTTP header.

14 years agoUpdate nodedev scsi_host data before use
David Allan [Thu, 3 Jun 2010 03:24:51 +0000 (23:24 -0400)]
Update nodedev scsi_host data before use

* It appears that the udev event for HBA creation arrives before the
  associated sysfs data is fully populated, resulting in bogus data
  for the nodedev entry until the entry is refreshed.  This problem is
  particularly troublesome when creating NPIV vHBAs because it results
  in libvirt failing to find the newly created adapter and waiting for
  the full timeout period before erroneously failing the create
  operation.  This patch forces an update before any attempt to use
  any scsi_host nodedev entry.

14 years agoFix device destroy return value
David Allan [Thu, 3 Jun 2010 01:59:16 +0000 (21:59 -0400)]
Fix device destroy return value

* Set return value in error cases
* Clarify error message when parent device is not vport capable

14 years agophyp: Strict check when listing domains
Eduardo Otubo [Tue, 1 Jun 2010 23:17:49 +0000 (20:17 -0300)]
phyp: Strict check when listing domains

14 years agoadd 802.1Qbh and 802.1Qbg handling
Stefan Berger [Thu, 3 Jun 2010 01:35:22 +0000 (21:35 -0400)]
add 802.1Qbh and 802.1Qbg handling

This patch that adds support for configuring 802.1Qbg and 802.1Qbh
switches. The 802.1Qbh part has been successfully tested with real
hardware. The 802.1Qbg part has only been tested with a (dummy)
server that 'behaves' similarly to how we expect lldpad to 'behave'.

The following changes were made during the development of this patch:

 - Merging Scott's v13-pre1 patch
 - Fixing endptr related bug while using virStrToLong_ui() pointed out
   by Jim Meyering
 - Addressing Jim Meyering's comments to v11
 - requiring mac address to the vpDisassociateProfileId() function to
   pass it further to the 802.1Qbg disassociate part (802.1Qbh untouched)
 - determining pid of lldpad daemon by reading it from /var/run/libvirt.pid
   (hardcode as is hardcode alson in lldpad sources)
 - merging netlink send code for kernel target and user space target
   (lldpad) using one function nlComm() to send the messages
 - adding a select() after the sending and before the reading of the
   netlink response in case lldpad doesn't respond and so we don't hang
 - when reading the port status, in case of 802.1Qbg, no status may be
   received while things are 'in progress' and only at the end a status
   will be there.
 - when reading the port status, use the given instanceId and vf to pick
   the right IFLA_VF_PORT among those nested under IFLA_VF_PORTS.
 - never sending nor parsing IFLA_PORT_SELF type of messages in the
   802.1Qbg case
 - iterating over the elements in a IFLA_VF_PORTS to pick the right
   IFLA_VF_PORT by either IFLA_PORT_PROFILE and given profileId
   (802.1Qbh) or IFLA_PORT_INSTANCE_UUID and given instanceId (802.1Qbg)
   and reading the current status in IFLA_PORT_RESPONSE.
 - recycling a previous patch that adds functionality to interface.c to
   - get the vlan identifier on an interface
   - get the flags of an interface and some convenience function to
     check whether an interface is 'up' or not (not currently used here)
 - adding function to determine the root physical interface of an
   interface. For example if a macvtap is linked to eth0.100, it will
   find eth0. Also adding a function that finds the vlan on the 'way to
   the root physical interface'
 - conveying the root physical interface name and index in case of 802.1Qbg
 - conveying mac address of macvlan device and vlan identifier in
   IFLA_VFINFO_LIST[ IFLA_VF_INFO[ IFLA_VF_MAC(mac), IFLA_VF_VLAN(vlan) ] ]
   to (future) lldpad via netlink
  - To enable build with --without-macvtap rename the
    [dis|]associatePortProfileId functions, prepend 'vp' before their
    name and make them non-static functions.
  - Renaming variable multicast to nltarget_kernel and inverting
    the logic
  - Addressing Jim Meyering's comments; this also touches existing
    code for example for correcting indentation of break statements or
    simplification of switch statements.
  - Renamed occurrencvirVirtualPortProfileDef to virVirtualPortProfileParamses
  - 802.1Qbg part prepared for sending a RTM_SETLINK and getting
    processing status back plus a subsequent RTM_GETLINK to
    get IFLA_PORT_RESPONSE.
    Note: This interface for 802.1Qbg may still change
  - [David Allan] move getPhysfn inside IFLA_VF_PORT_MAX to avoid
compiler
    warning when latest if_link.h isn't available
  - move from Stefan's 802.1Qb{g|h} XML v8 to v9
  - move hostuuid and vf index calcs to inside doPortProfileOp8021Qbh
  - remove debug fprintfs
  - use virGetHostUUID (thanks Stefan!)
  - fix compile issue when latest if_link.h isn't available
  - change poll timeout to 10s, at 1/8 intervals
     - if polling times out, log msg and return -ETIMEDOUT
  - Add Stefan's code for getPortProfileStatus
  - Poll for up to 2 secs for port-profile status, at 1/8 sec intervals:
     - if status indicates error, abort openMacvtapTap
     - if status indicates success, exit polling
     - if status is "in-progress" after 2 secs of polling, exit
       polling loop silently, without error

My patch finishes out the 802.1Qbh parts, which Stefan had mostly complete.
I've tested using the recent kernel updates for VF_PORT netlink msgs and
enic for Cisco's 10G Ethernet NIC.  I tested many VMs, each with several
direct interfaces, each configured with a port-profile per the XML.  VM-to-VM,
and VM-to-external work as expected.  VM-to-VM on same host (using same NIC)
works same as VM-to-VM where VMs are on diff hosts.  I'm able to change
settings on the port-profile while the VM is running to change the virtual
port behaviour.  For example, adjusting a QoS setting like rate limit.  All
VMs with interfaces using that port-profile immediatly see the effect of the
change to the port-profile.

I don't have a SR-IOV device to test so source dev is a non-SR-IOV device,
but most of the code paths include support for specifing the source dev and
VF index.  We'll need to complete this by discovering the PF given the VF
linkdev.  Once we have the PF, we'll also have the VF index.  All this info-
mation is available from sysfs.

14 years agobitmap: reject zero-size bitmap
Eric Blake [Wed, 2 Jun 2010 15:03:57 +0000 (09:03 -0600)]
bitmap: reject zero-size bitmap

* src/util/bitmap.c (virBitmapAlloc): Tighten sanity check.

14 years agohostusb: Properly handle 'usbX' sysfs files
Cole Robinson [Tue, 1 Jun 2010 18:46:26 +0000 (14:46 -0400)]
hostusb: Properly handle 'usbX' sysfs files

Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=598272

Some files under /sys/bus/usb/devices/ have the format 'usbX', where
X is the USB bus number. Use STRPREFIX to correctly parse the bus numbers.

14 years agoAdd --source-format argument to virsh pool-define-as and pool-create-as
Justin Clift [Sun, 30 May 2010 14:24:51 +0000 (00:24 +1000)]
Add --source-format argument to virsh pool-define-as and pool-create-as

This is the corresponding patch for the virsh man page (virsh.pod).

14 years agoAdd --source-format argument to virsh pool-define-as and pool-create-as
Justin Clift [Sun, 30 May 2010 14:24:45 +0000 (00:24 +1000)]
Add --source-format argument to virsh pool-define-as and pool-create-as

When creating pools from dedicated disks, the existing pool-define-as
and pool-create-as commands are a bit non-optimal.

Ideally, a person would be able to specify all of the required options
directly on the command line instead of having to edit the XML.

At the moment, there is no way to specify the format type (ie gpt) so it
gets included in the XML the pool is constructed with.

Please find attached a simple (tested) patch to add an optional
"--source-format 'type'" to virsh.  This is patched against current git
master and will apply cleanly.

Also created a Red Hat BZ ticket for this (#597790) for tracking.

14 years agoTrivial virsh.pod additions --all for "list" command and similar
Justin Clift [Sun, 30 May 2010 03:28:42 +0000 (13:28 +1000)]
Trivial virsh.pod additions --all for "list" command and similar

This is just a trivial patch to virsh.pod (from git master). It adds the
following pieces to the virsh man page:

  + Shows the --inactive and --all optional parameters for the list
    command.

    Closes Bugzilla #575512, reported by Renich Bon Ciric
    https://bugzilla.redhat.com/show_bug.cgi?id=575512

  + Corrects the existing description of the list command, to now say
    that only running domains are listed if no domains are specified.

    The man page up until this point has said all domains are listed if
    no domains are specified, which is incorrect.

  + Adds the "shut off" state to the list of states for the list
    command.

  + Adds a missing =back around line 755, that pod2man was complaining
    was missing.

14 years agobuild: fix VPATH 'make syntax-check'
Eric Blake [Tue, 1 Jun 2010 22:34:25 +0000 (16:34 -0600)]
build: fix VPATH 'make syntax-check'

* cfg.mk (sc_check_author_list): Look in correct location.

14 years agobuild: depend on correct file
Eric Blake [Tue, 1 Jun 2010 20:39:24 +0000 (14:39 -0600)]
build: depend on correct file

Otherwise, VPATH builds fail with:

make[1]: *** No rule to make target `libvirt-guests.init', needed by `all'.

Regression introduced in commit 482e08a9.

* daemon/Makefile.am (%.init): Look in correct place for
config.status.

14 years agoqemu: Add a qemu.conf option for clearing capabilities
Cole Robinson [Thu, 27 May 2010 23:17:55 +0000 (19:17 -0400)]
qemu: Add a qemu.conf option for clearing capabilities

Currently there is no way to opt out of libvirt dropping POSIX
capabilities for qemu. This at least is a useful debugging tool, but
is also wanted by users (and distributors):

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

v2: Clarify qemu.conf comment, warn about security implications

v3: Add .aug changes

14 years agobuild: make cpp indentation conform
Jim Meyering [Sat, 29 May 2010 07:45:21 +0000 (09:45 +0200)]
build: make cpp indentation conform

* src/storage/storage_backend.h (VIR_STORAGE_VOL_OPEN_DEFAULT):
Adjust s/#define/# define/, and align continued lines.

14 years agostorage: Check for invalid storage mode before opening
Cole Robinson [Thu, 20 May 2010 18:25:01 +0000 (14:25 -0400)]
storage: Check for invalid storage mode before opening

If a directory pool contains pipes or sockets, a pool start can fail or hang:

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

We already try to avoid these special files, but only attempt after
opening the path, which is where the problems lie. Unify volume opening
into helper functions, which use the proper open() flags to avoid error,
followed by fstat to validate storage mode.

Previously, virStorageBackendUpdateVolTargetInfoFD attempted to enforce the
storage mode check, but allowed callers to detect this case and silently
continue. In practice, only the FS backend was using this feature, the rest
were treating unknown mode as an error condition. Unfortunately the InfoFD
function wasn't raising an error message here, so error reporting was
busted.

This patch adds 2 functions: virStorageBackendVolOpen, and
virStorageBackendVolOpenModeSkip. The latter retains the original opt out
semantics, the former now throws an explicit error.

This patch maintains the previous volume mode checks: allowing specific
modes for specific pool types requires a bit of surgery, since VolOpen
is called through several different helper functions.

v2: Use ATTRIBUTE_NONNULL. Drop stat check, just open with
    O_NONBLOCK|O_NOCTTY.

v3: Move mode check logic back to VolOpen. Use 2 VolOpen functions with
    different error semantics.

v4: Make second VolOpen function more extensible. Didn't opt to change
    FS backend defaults, this can just be to fix the original bug.

v5: Prefix default flags with VIR_, use ATTRIBUTE_RETURN_CHECK

14 years agomacvtap: cannot support target device name
Stefan Berger [Fri, 28 May 2010 17:00:58 +0000 (13:00 -0400)]
macvtap: cannot support target device name

Since the macvtap device needs active tear-down and the teardown logic
is based on the interface name, it can happen that if for example 1 out
of 3 interfaces was successfully created, that during the failure path
the macvtap's target device name is used to tear down an interface that
is doesn't own (owned by another VM).

So, in this patch, the target interface name is reset so that there is
no target interface name and the interface name is always cleared after
a tear down.

14 years agoImprove nodedev parent/child relationships
David Allan [Thu, 27 May 2010 21:36:54 +0000 (17:36 -0400)]
Improve nodedev parent/child relationships

* If a nodedev has a parent that we don't want to display, we should
  continue walking up the udev device tree to see if any of its
  earlier ancestors are devices that we display.  It makes the tree
  much nicer looking than having a whole lot of devices hanging off
  the root node.

14 years agoFix libvirt-guests init script
Jiri Denemark [Thu, 27 May 2010 12:47:11 +0000 (14:47 +0200)]
Fix libvirt-guests init script

Firstly, the init script has to touch its file under /var/lock/subsys
when started, otherwise the system would think it's not running and
won't stop it during shutdown.

Secondly, for some reason there is a policy to automatically enable
init scripts when they are installed, so let the specfile do this. We
also need to start the init script to ensure it will be stopped during
the first shutdown after installing the package.

Also $LISTFILE should be enclosed by quotes everywhere as suggested by
Eric.

14 years agomaint: new syntax-check rule to ensure that AUTHORS stays in sync
Jim Meyering [Fri, 28 May 2010 09:27:12 +0000 (11:27 +0200)]
maint: new syntax-check rule to ensure that AUTHORS stays in sync

* cfg.mk (sc_check_AUTHOR_list): New rule.
* .mailmap: New file, to tell git log how to map email addresses.

14 years agohooks: fix typo
Paolo Smiraglia [Fri, 28 May 2010 12:54:28 +0000 (06:54 -0600)]
hooks: fix typo

* src/util/hooks.c (virHookLxcOp): Use correct bound.

14 years agobuild: silence cppi warning, clarify vbox headers
Eric Blake [Thu, 27 May 2010 22:35:06 +0000 (16:35 -0600)]
build: silence cppi warning, clarify vbox headers

These files are borrowed from upstream release versions, and should
not need further edits in the context of libvirt (instead, a new
upstream vbox release would entail adding a new header file).  We do
not re-generate these files as part of libvirt, nor do we want to lose
our minor edits (such as cppi cleanups).

* src/vbox/vbox_CAPI_v2_2.h: Clarify file origins.
* src/vbox/vbox_CAPI_v3_0.h: Likewise.
* src/vbox/vbox_CAPI_v3_1.h: Likewise.
* src/vbox/vbox_CAPI_v3_2.h: Likewise.  Reindent with cppi.

14 years agonetwork: bridge: Don't start network if it collides with host routing
Cole Robinson [Thu, 20 May 2010 23:31:16 +0000 (19:31 -0400)]
network: bridge: Don't start network if it collides with host routing

Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=235961

If using the default virtual network, an easy way to lose guest network
connectivity is to install libvirt inside the VM. The autostarted
default network inside the guest collides with host virtual network
routing. This is a long standing issue that has caused users quite a
bit of pain and confusion.

On network startup, parse /proc/net/route and compare the requested
IP+netmask against host routing destinations: if any matches are found,
refuse to start the network.

v2: Drop sscanf, fix a comment typo, comment that function could use
    libnl instead of /proc

v3: Consider route netmask. Compare binary data rather than convert to
    string.

v4: Return to using sscanf, drop inet functions in favor of virSocket,
    parsing safety checks. Don't make parse failures fatal, in case
    expected format changes.

v5: Try and continue if we receive unexpected. Delimit parsed lines to
    prevent scanning past newline

14 years agomaint: update AUTHORS with recent contributors
Eric Blake [Thu, 27 May 2010 21:24:19 +0000 (15:24 -0600)]
maint: update AUTHORS with recent contributors

git shortlog $(git log -1 --format=%H AUTHORS).. | grep -v "^ "

then add missing entries to AUTHORS.

* AUTHORS: Update.

14 years agoxen: Fix chardev listen sexpr formatting
Cole Robinson [Wed, 26 May 2010 02:31:27 +0000 (22:31 -0400)]
xen: Fix chardev listen sexpr formatting

'listen' isn't a valid qemu-dm option, as reported a long time ago here:

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

Matches the near identical logic in qemu_conf.c

v2: When parsing sexpr, only match on ",server", rather than
    full ',server,nowait'.

14 years agoxen: Remove unused function
Cole Robinson [Wed, 26 May 2010 02:27:53 +0000 (22:27 -0400)]
xen: Remove unused function

Signed-off-by: Cole Robinson <crobinso@redhat.com>
14 years agov2 of Cole's wlan support
David Allan [Thu, 27 May 2010 14:44:02 +0000 (10:44 -0400)]
v2 of Cole's wlan support

* Incorporated Jim's feedback (v1 & v2)

* Moved case of DEVTYPE == "wlan" up as it's definitive that we have a network interface.

* Made comment more detailed about the wired case to explain better
  how it differentiates between wired network interfaces and USB
  devices.

14 years agoAdd docs on drive <serial> element
Марк Коренберг [Thu, 27 May 2010 11:44:41 +0000 (12:44 +0100)]
Add docs on drive <serial> element

* docs/formatdomain.html.in: Document <serial> element within
  <disk> and fix typo on <driver/> element

14 years agoesx: Simplify goto usage
Matthias Bolte [Wed, 19 May 2010 20:59:32 +0000 (22:59 +0200)]
esx: Simplify goto usage

Eliminate almost all backward jumps by replacing this common pattern:

int
some_random_function(void)
{
    int result = 0;
    ...

  cleanup:
    <unconditional cleanup code>
    return result;

  failure:
    <cleanup code in case of an error>
    result = -1;
    goto cleanup
}

with this simpler pattern:

int
some_random_function(void)
{
    int result = -1;
    ...
    result = 0;

  cleanup:
    if (result < 0) {
        <cleanup code in case of an error>
    }

    <unconditional cleanup code>
    return result;
}

Add a bool success variable in functions that don't have a int result
that can be used for the new pattern.

Also remove some unnecessary memsets in error paths.

14 years agoSupport for VirtualBox version 3.2
Jean-Baptiste Rouault [Wed, 26 May 2010 11:54:16 +0000 (13:54 +0200)]
Support for VirtualBox version 3.2

14 years agoUse printf instead of echo -e in libvirt.spec.in
Matthias Bolte [Wed, 26 May 2010 21:06:09 +0000 (23:06 +0200)]
Use printf instead of echo -e in libvirt.spec.in

make rpm created dummy tests containing '-e #!/bin/sh' for me.

14 years agoInstall, distribute and package domainsnapshot.rng
Matthias Bolte [Wed, 26 May 2010 21:03:47 +0000 (23:03 +0200)]
Install, distribute and package domainsnapshot.rng

14 years agobuild: support 'make check' in pristine tree
Eric Blake [Wed, 26 May 2010 21:56:04 +0000 (15:56 -0600)]
build: support 'make check' in pristine tree

Otherwise, 'make check' in the python dir tries to reference a file in
docs that is built by 'make' but not by 'make check'.

* docs/Makefile.am (check-local): New rule.
Reported by Matthias Bolte.

14 years agoesx: Expose host UUID in the capabilities XML
Matthias Bolte [Wed, 26 May 2010 11:05:49 +0000 (13:05 +0200)]
esx: Expose host UUID in the capabilities XML

Parse the BIOS UUID. This information may not be available, in that
case no host UUID is exposed in the capabilities XML.

14 years agoFix integer overflow in hotplug methods
Daniel P. Berrange [Wed, 26 May 2010 12:34:45 +0000 (13:34 +0100)]
Fix integer overflow in hotplug methods

The hotplug methods still had the qemuCmdFlags variable declared
as an int, instead of unsigned long long. This caused flag checks
to be incorrect for flags > 31

* src/qemu/qemu_driver.c: Fix integer overflow in hotplug

14 years agoPass pre-opened PCI device sysfs config file to QEMU
Alex Williamson [Wed, 26 May 2010 12:32:38 +0000 (13:32 +0100)]
Pass pre-opened PCI device sysfs config file to QEMU

This allows libvirt to open the PCI device sysfs config file prior
to dropping privileges so qemu can access the full config space.
Without this, a de-privileged qemu can only access the first 64
bytes of config space.

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Detect support
  for pci-assign.configfd option. Use this option when formatting
  PCI device string if possible
* src/qemu/qemu_driver.c: Pre-open PCI sysfs config file and pass
  to QEMU

14 years agodaemon: sysconf: Update comment about VNC audio
Cole Robinson [Wed, 26 May 2010 14:51:36 +0000 (10:51 -0400)]
daemon: sysconf: Update comment about VNC audio

14 years agoFix failing virGetHostname.
Chris Lalancette [Thu, 20 May 2010 17:16:30 +0000 (13:16 -0400)]
Fix failing virGetHostname.

We've been running into a lot of situations where
virGetHostname() is returning "localhost", where a plain
gethostname() would have returned the correct thing.  This
is because virGetHostname() is *always* trying to canonicalize
the name returned from gethostname(), even when it doesn't
have to.

This patch changes virGetHostname so that if the value returned
from gethostname() is already FQDN or localhost, it returns
that string directly.  If the value returned from gethostname()
is a shortened hostname, then we try to canonicalize it.  If
that succeeds, we returned the canonicalized hostname.  If
that fails, and/or returns "localhost", then we just return
the original string we got from gethostname() and hope for
the best.

Note that after this patch it is up to clients to check whether
"localhost" is an allowed return value.  The only place
where it's currently not is in qemu migration.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agoxen-proxy build broken
Matthias Bolte [Wed, 26 May 2010 10:45:28 +0000 (06:45 -0400)]
xen-proxy build broken

The virVirtualPortProfileFormat just went below the
virVirtualPortProfileParamsParseXML function and got inside the

The attached patch moves virVirtualPortProfileFormat below the #ifndef
PROXY block.

14 years agoesx: Add read-only storage pool access
Matthias Bolte [Tue, 18 May 2010 16:11:59 +0000 (18:11 +0200)]
esx: Add read-only storage pool access

Allows listing existing pools and requesting information about them.

Alter the esxVI_ProductVersion enum in a way that allows to check for
product type by masking.

14 years agobuild: fix HTML errors in nwfilter docs
Eric Blake [Tue, 25 May 2010 23:20:51 +0000 (17:20 -0600)]
build: fix HTML errors in nwfilter docs

A build on Ubuntu reported:

|| Generating formatnwfilter.html.tmp
/dados/develop/libvirt/docs/formatnwfilter.html.in|390| HTML parser error : Unexpected end tag : p
||     </p>
||         ^
/dados/develop/libvirt/docs/formatnwfilter.html.in|705| HTML parser error : Unexpected end tag : code
||          <td>End of range of valid source ports</code></td>
||                                                       ^
/dados/develop/libvirt/docs/formatnwfilter.html.in|710| HTML parser error : Unexpected end tag : code
||          <td>Start of range of valid destination ports</code></td>
||                                                              ^

* docs/formatnwfilter.html.in: Fix invalid HTML constructs.
Reported by Eduardo Otubo.

14 years agobuild: fix compilation without macvtap
Eric Blake [Tue, 25 May 2010 22:44:05 +0000 (16:44 -0600)]
build: fix compilation without macvtap

* src/util/macvtap.c: (associatePortProfileId)
(disassociatePortProfileId): Move inside HAVE_MACVTAP
conditional.
Reported by Eduardo Otubo.

14 years agotests: avoid new failure of the daemon-conf test
Jim Meyering [Tue, 25 May 2010 19:12:01 +0000 (21:12 +0200)]
tests: avoid new failure of the daemon-conf test

* tests/daemon-conf: Accommodate the fact that out template,
daemon/libvirtd.conf now contains an invalid host_uuid.
Convert it to a valid one before the final libvirtd-running
test that must terminate normally.

14 years agolibvirtd: diagnose invalid host UUID
Jim Meyering [Tue, 25 May 2010 19:12:01 +0000 (21:12 +0200)]
libvirtd: diagnose invalid host UUID

* daemon/libvirtd.c (remoteReadConfigFile): Diagnose an invalid
host UUID rather than silently exiting with status 7.

14 years agovepa: parsing for 802.1Qb{g|h} XML
Stefan Berger [Tue, 25 May 2010 21:37:00 +0000 (17:37 -0400)]
vepa: parsing for 802.1Qb{g|h} XML

This patch parses the following two XML descriptions, one for
802.1Qbg and one for 802.1Qbh, and stores the data internally.
The actual triggering of the switch setup protocol has not been
implemented here but the relevant code to do that should go into
the functions associatePortProfileId() and disassociatePortProfileId().

   <interface type='direct'>
      <source dev='eth0.100' mode='vepa'/>
      <model type='virtio'/>
      <virtualport type='802.1Qbg'>
        <parameters managerid='12' typeid='0x123456' typeidversion='1'
         instanceid='fa9b7fff-b0a0-4893-8e0e-beef4ff18f8f'/>
      </virtualport>
      <filterref filter='clean-traffic'/>
    </interface>

    <interface type='direct'>
      <source dev='eth0.100' mode='vepa'/>
      <model type='virtio'/>
      <virtualport type='802.1Qbh'>
        <parameters profileid='my_profile'/>
      </virtualport>
    </interface>

I'd suggest to use this patch as a base for triggering the setup
protocol with the 802.1Qb{g|h} switch.

Several rounds of changes were made to this patch. The
following is a list of these changes.
- Renamed structure virVirtualPortProfileDef to virVirtualPortProfileParams
  as per Daniel Berrange's request
- Addressing Daniel Berrange's comments:
 - removing macvtap.h's dependency on domain_conf.h by
   moving the virVirtualPortProfileDef structure into macvtap.h
   and not passing virtDomainNetDefPtr to any functions in
   macvtap.c
- Addressed most of Chris Wright's comments:
  - indicating error in case virtualport XML node cannot be parsed
    properly
  - parsing hex and decimal numbers using virStrToLong_ui() with
    parameter '0' for base
  - tgifname (target interface name) variable wasn't necessary
    to pass to openMacvtapTap function anymore
- assigning the virtual port data structure to the virDomainNetDef
  only if it was previously parsed
- make sure that the error code returned by openMacvtapTap() is a negative n
  in case the associatePortProfileId() function failed.
- renaming vsi in the XML to virtualport
- replace all occurrences of vsi in the source as well
- removing mode and MAC address parameters from the functions that
  will communicate with the hareware diretctly or indirectly
- moving the associate and disassociate functions to the end of the
  file for subsequent patches to easier make them generally available
  for export
- passing the macvtap interface name rather than the link device since
  this otherwise gives funny side effects when using netlink messages
  where IFLA_IFNAME and IFLA_ADDRESS are specified and the link dev
  all of a sudden gets the MAC address of the macvtap interface.
- Removing rc = -1 error indications in the case of 802.1Qbg|h setup in case
  we wanted to use hook scripts for the setup and so the setup doesn't fail
  here.
- if instance ID UUID is not supplied it will automatically be generated
  - adapted schema to make instance ID UUID optional
  - added test case
- parser and XML generator have been separated into their own
  functions so they can be re-used elsewhere (passthrough case
  for example)
- Adapted XML parser and generator support the above shown type
  (802.1Qbg, 802.1Qbh).
- Adapted schema to above XML
- Adapted test XML to above XML
- Passing through the VM's UUID which seems to be necessary for
  802.1Qbh -- sorry no host UUID
- adding virtual function ID to association function, in case it's
  necessary to use (for SR-IOV)

14 years agovepa+vsi: Introduce dependency on libnl
Stefan Berger [Tue, 25 May 2010 19:31:38 +0000 (15:31 -0400)]
vepa+vsi: Introduce dependency on libnl

This patch introduces a dependency on libnl, which subsequent patches
will then use.

Changes from V1 to V2:
- added diffstats
- following changes in tree

14 years agostorage: Sanitize pool target paths
Cole Robinson [Thu, 20 May 2010 15:41:31 +0000 (11:41 -0400)]
storage: Sanitize pool target paths

Spurious / in a pool target path makes life difficult for apps using the
GetVolByPath, and doing other path based comparisons with pools. This
has caused a few issues for virt-manager users:

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

Add a new util API which removes spurious /, virFileSanitizePath. Sanitize
target paths when parsing pool XML, and for paths passed to GetVolByPath.

v2: Leading // must be preserved, properly sanitize path=/, sanitize
    away /./ -> /

v3: Properly handle starting ./ and ending /.

v4: Drop all '.' handling, just sanitize / for now.

14 years agoExpose a host UUID in the capabilities XML
Daniel P. Berrange [Tue, 25 May 2010 14:33:51 +0000 (15:33 +0100)]
Expose a host UUID in the capabilities XML

Allow for a host UUID in the capabilities XML. Local drivers
will initialize this from the SMBIOS data. If a sanity check
shows SMBIOS uuid is invalid, allow an override from the
libvirtd.conf configuration file

* daemon/libvirtd.c, daemon/libvirtd.conf: Support a host_uuid
  configuration option
* docs/schemas/capability.rng: Add optional host uuid field
* src/conf/capabilities.c, src/conf/capabilities.h: Include
  host UUID in XML
* src/libvirt_private.syms: Export new uuid.h functions
* src/lxc/lxc_conf.c, src/qemu/qemu_driver.c,
  src/uml/uml_conf.c: Set host UUID in capabilities
* src/util/uuid.c, src/util/uuid.h: Support for host UUIDs
* src/node_device/node_device_udev.c: Use the host UUID functions
* tests/confdata/libvirtd.conf, tests/confdata/libvirtd.out: Add
  new host_uuid config option to test

14 years agoFix handling of disk backing stores with cgroups
Daniel P. Berrange [Wed, 28 Apr 2010 15:25:42 +0000 (16:25 +0100)]
Fix handling of disk backing stores with cgroups

The cgroups ACL code was only allowing the primary disk image.
It is possible to chain images together, so we need to search
for backing stores and add them to the ACL too. Since the ACL
only handles block devices, we ignore the EINVAL we get from
plain files. In addition it was missing code to teardown the
cgroup when hot-unplugging a disk

* src/qemu/qemu_driver.c: Allow backing stores in cgroup ACLs
  and add missing teardown code in unplug path

14 years agoFix up basic migration.
Chris Lalancette [Thu, 20 May 2010 19:25:41 +0000 (15:25 -0400)]
Fix up basic migration.

Basic live migration was broken by the commit that added
non-shared block support in two ways:

1)  It added a virCheckFlags() to doNativeMigrate().  Besides
the fact that typical usage of virCheckFlags() is in driver
entry points, and doNativeMigrate() is not an entry point,
it was missing important flags like VIR_MIGRATE_LIVE.  Move
the virCheckFlags to the top-level qemuDomainMigratePrepare2
and friends.

2)  It also added a memory leak in qemuMonitorTextMigrate()
by not freeing the memory used by virBufferContentAndReset().
This is fixed by storing the pointer in a temporary variable
and freeing it at the end.

With this patch in place, normal live migration works again.

v3: Instead of the churn for virCheckFlagsUI and UL, instead
always promote flags to an unsigned long and always use %lx
for the fprintf.
v2: Add back flags check, which required adding virCheckFlagsUI
and virCheckFlagsUL

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agoqemu: Allow using regular audio backends with VNC
Cole Robinson [Wed, 19 May 2010 20:41:01 +0000 (16:41 -0400)]
qemu: Allow using regular audio backends with VNC

Currently all host audio backends are disabled if a VM is using VNC, in
favor of the QEMU VNC audio extension. Unfortunately no released VNC
client supports this extension, so users have no way of getting audio
to work if using VNC.

Add a new config option in qemu.conf which allows changing libvirt's
behavior, but keep the default intact.

v2: Fix doc typos, change name to vnc_allow_host_audio

14 years agostorage: mpath: Fix incorrect VIR_ERROR use
Cole Robinson [Mon, 24 May 2010 18:41:14 +0000 (14:41 -0400)]
storage: mpath: Fix incorrect VIR_ERROR use

14 years agoAllow nwfilter functions to be compiled with C++
Chris Lalancette [Mon, 24 May 2010 15:55:55 +0000 (11:55 -0400)]
Allow nwfilter functions to be compiled with C++

Unfortunately the NWFilter functions were outside of the
"extern C { ... }" declaration in include/libvirt/libvirt.h.in,
which means that they couldn't be properly used with C++.  Move
them inside of the braces, which should fix the problem.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agonwfilter: documentation
Stefan Berger [Tue, 25 May 2010 11:09:31 +0000 (07:09 -0400)]
nwfilter: documentation

This patch adds documentation of the nwfilter subsystem of libvirt to
the existing (web) docs.

14 years agomaint: update AUTHORS with recent contributors
Eric Blake [Mon, 24 May 2010 22:29:06 +0000 (16:29 -0600)]
maint: update AUTHORS with recent contributors

git shortlog $(git log -1 --format=%H AUTHORS).. | grep -v "^ "

then add missing entries to AUTHORS.

* AUTHORS: Update.

14 years agoqemu: Release bus address on PCI host device remove
Alex Williamson [Mon, 24 May 2010 17:33:48 +0000 (13:33 -0400)]
qemu: Release bus address on PCI host device remove

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
14 years agoqemu: avoid corrupting guest info struct on host device PCI hot add
Alex Williamson [Mon, 24 May 2010 17:33:27 +0000 (13:33 -0400)]
qemu: avoid corrupting guest info struct on host device PCI hot add

The device path doesn't make use of guestAddr, so the memcpy corrupts
the guest info struct.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
14 years agoQuery block allocation extent from QEMU monitor
Daniel P. Berrange [Fri, 14 May 2010 13:10:01 +0000 (09:10 -0400)]
Query block allocation extent from QEMU monitor

The virDomainGetBlockInfo API allows query physical block
extent and allocated block extent. These are normally the
same value unless storing a special format like qcow2
inside a block device. In this scenario we can query QEMU
to get the actual allocated extent.

Since last time:

 - Return fatal error in text monitor
 - Only invoke monitor command for block devices
 - Fix error handling JSON code

* src/qemu/qemu_driver.c: Fill in block aloction extent when VM
  is running
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
  API to query the highest block extent via info blockstats

14 years agolxcSetSchedulerParameters: reverse order of tests; diagnose a failure
Jim Meyering [Tue, 11 May 2010 13:51:46 +0000 (15:51 +0200)]
lxcSetSchedulerParameters: reverse order of tests; diagnose a failure

* src/lxc/lxc_driver.c (lxcSetSchedulerParameters): Ensure that
"->field" is "cpu_shares" before possibly giving a diagnostic about
a type for a "cpu_shares" value.
Also, virCgroupSetCpuShares could fail without evoking a diagnostic.
Add one.

14 years agoDon't overwrite virDomainAssignDef errors.
Chris Lalancette [Tue, 11 May 2010 20:44:09 +0000 (16:44 -0400)]
Don't overwrite virDomainAssignDef errors.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agostorage: Combine some duplicate code
Cole Robinson [Thu, 20 May 2010 17:29:24 +0000 (13:29 -0400)]
storage: Combine some duplicate code

Volume detection in the scsi backend was duplicating code already
present in storage_backend.c. Let's drop the duplicate code.

Also, change the shared function name to be less generic, and remove
some error squashing in the other call site.

14 years agostorage: mpath: Clean up some error handling
Cole Robinson [Thu, 20 May 2010 18:16:54 +0000 (14:16 -0400)]
storage: mpath: Clean up some error handling

We were squashing error messages in a few cases. Recode to follow common
ret = -1 convention.

v2: Handle more error squashing issues further up in MakeNewVol and
    CreateVols. Use ret = -1 convention in MakeVols.

14 years agoRemove dead code after refactoring qemudDomainStart
Jiri Denemark [Fri, 21 May 2010 09:32:03 +0000 (11:32 +0200)]
Remove dead code after refactoring qemudDomainStart

The event is already generated and sent by qemudDomainObjStart, no need
to do anything about here.

14 years agolibvirtd: start each diagnostic with "argv0: "
Jim Meyering [Thu, 20 May 2010 19:40:54 +0000 (21:40 +0200)]
libvirtd: start each diagnostic with "argv0: "

Some diagnostics had a hard-coded "libvirtd: " prefix, some used
"error: " and some used "argv[0]: ".  Always use "argv[0]: ".
* daemon/libvirtd.c (argv0): New global.
(main): Set it.
(version, usage): Remove argv0 parameter.  Use global; update callers.
(daemonForkIntoBackground): Use argv0:, not error:.
(qemudWritePidFile): Start each diagnostic with argv0:.
Suggested by Eric Blake.

14 years agolibvirtd: mark strings for translation, including --help output
Jim Meyering [Thu, 20 May 2010 08:01:32 +0000 (10:01 +0200)]
libvirtd: mark strings for translation, including --help output

* daemon/libvirtd.c (daemonForkIntoBackground, main): Mark strings
for translation.
(usage): Rework --help so that it is translatable, replacing
each embedded, configuration-dependent, macro with an `%s'.

libvirtd: don't ignore virInitialize failure
* daemon/libvirtd.c (main): Diagnose virInitialize failure
and exit nonzero.

14 years agobuild: fix cppi warnings
Eric Blake [Fri, 21 May 2010 22:02:18 +0000 (16:02 -0600)]
build: fix cppi warnings

* src/util/bitmap.h (includes): Placate cppi.

14 years agobuild: force init scripts to rebuild on changed --prefix
Eric Blake [Fri, 21 May 2010 21:18:24 +0000 (15:18 -0600)]
build: force init scripts to rebuild on changed --prefix

Otherwise, './configure --prefix=/foo && make &&
 ./configure --prefix=/bar && make' leaves the wrong files
in libvirtd.init (/foo instead of /bar).

* daemon/Makefile.am (libvirtd.init): Add dependency on
config.status.  Reported by Cole Robinson.

14 years agobuild: Distribute the whole tests/qemuhelpdata directory
Matthias Bolte [Fri, 21 May 2010 18:00:24 +0000 (20:00 +0200)]
build: Distribute the whole tests/qemuhelpdata directory

Instead of distributing the individual files.

Now it's less error prone and consistent with the rest of
the data directories in the tests directory.

14 years ago.gitignore: Add libvirt-guests.init
Cole Robinson [Fri, 21 May 2010 17:58:08 +0000 (13:58 -0400)]
.gitignore: Add libvirt-guests.init

14 years agoFix race in finding available vnc port
Jim Fehlig [Fri, 21 May 2010 13:52:09 +0000 (07:52 -0600)]
Fix race in finding available vnc port

The qemu driver contains a subtle race in the logic to find next
available vnc port.  Currently it iterates through all available ports
and returns the first for which bind(2) succeeds.  However it is possible
that a previously issued port has not yet been bound by qemu, resulting
in the same port used for a subsequent domain.

This patch addresses the race by using a simple bitmap to "reserve" the
ports allocated by libvirt.

V2:
  - Put port bitmap in struct qemud_driver
  - Initialize bitmap in qemudStartup

V3:
  - Check for failure of virBitmapGetBit
  - Additional check for port != -1 before calling virbitmapClearBit

V4:
  - Check for failure of virBitmap{Set,Clear}Bit

14 years agoAdd defines for QEMU_VNC_PORT_{MIN,MAX} and use them
Jim Fehlig [Fri, 21 May 2010 04:25:16 +0000 (22:25 -0600)]
Add defines for QEMU_VNC_PORT_{MIN,MAX} and use them

14 years agoAdd simple bitmap operations to utils
Jim Fehlig [Fri, 21 May 2010 04:23:48 +0000 (22:23 -0600)]
Add simple bitmap operations to utils

V2:
  - Move bitmap impl to src/util/bitmap.[ch]
  - Use CHAR_BIT instead of explicit '8'
  - Use size_t instead of unsigned int
  - Fix calculation of bitmap size in virBitmapAlloc
  - Ensure bit is within range of map in the set, clear, and get
    operations
  - Use bool in virBitmapGetBit
  - Add virBitmapFree to free-like funcs in cfg.mk

V3:
  - Check for overflow in virBitmapAlloc
  - Fix copy and paste bug in virBitmapAlloc
  - Use size_t in prototypes
  - Add ATTRIBUTE_NONNULL in prototypes where appropriate
    and remove NULL check from impl

V4:
  - Add ATTRIBUTE_RETURN_CHECK in prototypes where appropriate.

14 years agodaemon: Export SDL audio environment variables
Cole Robinson [Wed, 19 May 2010 20:03:52 +0000 (16:03 -0400)]
daemon: Export SDL audio environment variables

/etc/sysconfig/libvirtd has a few environment variables for configuring
libvirt SDL audio. The libvirtd process doesn't see these, however, because
they are never exported. Let's export the variables after sourcing the
sysconfig script.

There is another problem here that the commented out values in the
sysconfig script are not neccessarily the actual defaults, we are qemus
mercy here. Not sure how to solve that.

14 years agoRemove isValidIfname.
Chris Lalancette [Thu, 20 May 2010 17:20:24 +0000 (13:20 -0400)]
Remove isValidIfname.

We shouldn't be checking validity in domain_conf, since
it can be used by multiple different hosts and hypervisors.
Remove the check completely.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
14 years agoInit script for handling guests on shutdown/boot
Jiri Denemark [Fri, 14 May 2010 13:37:55 +0000 (15:37 +0200)]
Init script for handling guests on shutdown/boot

Example output during shutdown:

Running guests on default URI: console, rhel6-1, rhel5-64
Running guests on lxc:/// URI: lxc-shell
Running guests on xen:/// URI: error: no hypervisor driver available for xen:///
error: failed to connect to the hypervisor
Running guests on vbox+tcp://orkuz/system URI: no running guests.
Suspending guests on default URI...
Suspending console: done
Suspending rhel6-1: done
Suspending rhel5-64: done
Suspending guests on lxc:/// URI...
Suspending lxc-shell: error: Failed to save domain 9cba8bfb-56f4-6589-2d12-8a58c886dd3b state
error: this function is not supported by the hypervisor: virDomainManagedSave

Note, the "Suspending $guest: " shows progress during the suspend phase
if domjobinfo gives meaningful output.

Example output during boot:

Resuming guests on default URI...
Resuming guest rhel6-1: done
Resuming guest rhel5-64: done
Resuming guest console: done
Resuming guests on lxc:/// URI...
Resuming guest lxc-shell: already active

Configuration used for generating the examples above:
URIS='default lxc:/// xen:/// vbox+tcp://orkuz/system'

The script uses /var/lib/libvirt/libvirt-guests files to note all active
guest it should try to resume on next boot. It's content looks like:

default 7f8b9d93-30e1-f0b9-47a7-cb408482654b 085b4c95-5da2-e8e1-712f-6ea6a4156af2 fb4d8360-5305-df3a-2da1-07d682891b8c
lxc:/// 9cba8bfb-56f4-6589-2d12-8a58c886dd3b

14 years agoAutostart domains using virDomainObjStart
Jiri Denemark [Thu, 20 May 2010 10:02:58 +0000 (12:02 +0200)]
Autostart domains using virDomainObjStart

14 years agoRefactor qemudDomainStart
Jiri Denemark [Thu, 20 May 2010 10:01:16 +0000 (12:01 +0200)]
Refactor qemudDomainStart

We need a common internal function for starting managed domains to be
used during autostart. This patch factors out relevant code from
qemudDomainStart into qemudDomainObjStart and makes it use the
refactored code for domain restore instead of calling qemudDomainRestore
API directly.

14 years agoFactor out def assignment to existing domain from virDomainAssignDef
Jiri Denemark [Thu, 20 May 2010 09:36:24 +0000 (11:36 +0200)]
Factor out def assignment to existing domain from virDomainAssignDef

We need to be able to assign new def to an existing virDomainObj which
is already locked. This patch factors out the relevant code from
virDomainAssignDef into virDomainObjAssignDef.

14 years agoRefactor qemudDomainRestore
Jiri Denemark [Thu, 20 May 2010 09:55:32 +0000 (11:55 +0200)]
Refactor qemudDomainRestore

We need to be able to restore a domain which we already locked and
started a job for it without undoing these steps. This patch factors
out internals of qemudDomainRestore into separate functions which work
for locked objects.

14 years agomaint: update po/POTFILES.in
Jim Meyering [Thu, 20 May 2010 06:59:01 +0000 (08:59 +0200)]
maint: update po/POTFILES.in

* po/POTFILES.in: Add 3 files.

14 years agomaint: enforce policy wrt VIR_DEBUG and VIR_DEBUG0
Jim Meyering [Thu, 20 May 2010 06:56:48 +0000 (08:56 +0200)]
maint: enforce policy wrt VIR_DEBUG and VIR_DEBUG0

* cfg.mk (sc_prohibit_gettext_markup): Just like VIR_WARN*.

14 years agomaint: don't mark VIR_DEBUG or VIR_DEBUG0 diagnostics for translation
Jim Meyering [Thu, 20 May 2010 06:57:06 +0000 (08:57 +0200)]
maint: don't mark VIR_DEBUG or VIR_DEBUG0 diagnostics for translation

Run this command:
  git grep -l VIR_DEBUG|xargs perl -pi -e \
    's/(VIR_DEBUG0?)\s*\(_\((".*?")\)/$1($2/'

14 years agomaint: enforce policy wrt VIR_ERROR and VIR_ERROR0
Jim Meyering [Thu, 20 May 2010 06:44:23 +0000 (08:44 +0200)]
maint: enforce policy wrt VIR_ERROR and VIR_ERROR0

* cfg.mk (msg_gen_function): Add VIR_ERROR and VIR_ERROR0,
so that sc_libvirt_unmarked_diagnostics will check them, too.

14 years agomaint: change "" in err ? err->message : "" to _("unknown error"), ...
Jim Meyering [Thu, 20 May 2010 06:44:27 +0000 (08:44 +0200)]
maint: change "" in err ? err->message : "" to _("unknown error"), ...

These changes avoid false-positive syntax-check failure,
and also make the resulting diagnostics more comprehensible.

14 years agomaint: more of same, but manual: convert VIR_ERROR("%s" to VIR_ERROR0(
Jim Meyering [Thu, 20 May 2010 06:40:16 +0000 (08:40 +0200)]
maint: more of same, but manual: convert VIR_ERROR("%s" to VIR_ERROR0(