* src/qemu/qemu.conf src/qemu/qemu_conf.c src/qemu/qemu_conf.h: there is
a new config type option for mac filtering
* src/qemu/qemu_bridge_filter.[ch]: new module for the ebtable entry points
* src/qemu/qemu_driver.c: plug the MAC filtering at the right places
in the domain life cycle
* src/Makefile.am po/POTFILES.in: add the new module
- Don't duplicate SystemError
- Use proper error code in domain_conf
- Fix a broken error call in qemu_conf
- Don't use VIR_ERR_ERROR in security driver (isn't a valid code in this case)
All drivers have copy + pasted inadequate error reporting which wraps
util.c:virGetHostname. Move all error reporting to this function, and improve
what we report.
Changes from v1:
Drop the driver wrappers around virGetHostname. This means we still need
to keep the new conn argument to virGetHostname, but I think it's worth
it.
introduced on commit 9231aa7d95
* src/qemu/qemu_driver.c: in qemudRemoveDomainStatus fix a reference
to an undefined variable buf and free up an allocated string
When building with --disable-nls, I got a few messages like this:
storage/storage_backend.c: In function 'virStorageBackendCreateQemuImg':
storage/storage_backend.c:571: warning: format not a string literal and no format arguments
Fix these up.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
qemudShutdownVMDaemon() calls qemudRemoveDomainStatus(), which
then calls virFileDeletePID(). qemudShutdownVMDaemon() then
unnecessarily calls virFileDeletePID() again. Remove this second
usage of it, and also slightly refactor qemudRemoveDomainStatus()
to VIR_WARN appropriate error messages.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
The LXC driver was mistakenly returning -1 for lxcStartup()
in scenarios that are not an error. This caused the libvirtd
to quit for unprivileged users. This fixes the return code
of LXC driver, and also adds a "name" field to the virStateDriver
struct and logging to make it easier to find these problems
in the future
* src/driver.h: Add a 'name' field to state driver to allow
easy identification during failures
* src/libvirt.c: Log name of failed driver for virStateInit
failures
* src/lxc/lxc_driver.c: Don't return a failure code for
lxcStartup() if LXC is not available on this host, simply
disable the driver.
* src/network/bridge_driver.c, src/node_device/node_device_devkit.c,
src/node_device/node_device_hal.c, src/opennebula/one_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/secret/secret_driver.c, src/storage/storage_driver.c,
src/uml/uml_driver.c, src/xen/xen_driver.c: Fill in name
field in virStateDriver struct
Rename virDomainIsActive to virDomainObjIsActive, and
virInterfaceIsActive to virInterfaceObjIsActive and finally
virNetworkIsActive to virNetworkObjIsActive.
* src/conf/domain_conf.c, src/conf/domain_conf.h,
src/conf/interface_conf.h, src/conf/network_conf.c,
src/conf/network_conf.h, src/lxc/lxc_driver.c,
src/network/bridge_driver.c, src/opennebula/one_driver.c,
src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c: Update for
renamed APIs.
Nearly all of the methods in src/util/util.h have error codes that
must be checked by the caller to correct detect & report failure.
Add ATTRIBUTE_RETURN_CHECK to ensure compile time validation of
this
* daemon/libvirtd.c: Add explicit check on return value of virAsprintf
* src/conf/domain_conf.c: Add missing check on virParseMacAddr return
value status & report error
* src/network/bridge_driver.c: Add missing OOM check on virAsprintf
and report error
* src/qemu/qemu_conf.c: Add missing check on virParseMacAddr return
value status & report error
* src/security/security_selinux.c: Remove call to virRandomInitialize
that's done in libvirt.c already
* src/storage/storage_backend_logical.c: Add check & log on virRun
return status
* src/util/util.c: Add missing checks on virAsprintf/Run status
* src/util/util.h: Annotate all methods with ATTRIBUTE_RETURN_CHECK
if they return an error status code
* src/vbox/vbox_tmpl.c: Add missing check on virParseMacAddr
* src/xen/xm_internal.c: Add missing checks on virAsprintf
* tests/qemuargv2xmltest.c: Remove bogus call to virRandomInitialize()
The virDomainObjPtr object stores state about a running domain.
This object is shared across all drivers so it is not appropriate
to include driver specific state here. This patch adds the ability
to request a blob of private data per domain object instance. The
driver must provide a allocator & deallocator for this purpose
THis patch abuses the virCapabilitiesPtr structure for storing the
allocator/deallocator callbacks, since it is already being abused
for other internal things relating to parsing. This should be moved
out into a separate object at some point.
* src/conf/capabilities.h: Add privateDataAllocFunc and
privateDataFreeFunc fields
* src/conf/domain_conf.c: Invoke the driver allocators / deallocators
when creating/freeing virDomainObjPtr instances.
* src/conf/domain_conf.h: Pass virCapsPtr into virDomainAssignDef
to allow access to the driver specific allocator function
* src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c: Update for
change in virDomainAssignDef contract
The current virDomainObjListPtr object stores domain objects in
an array. This means that to find a particular objects requires
O(n) time, and more critically acquiring O(n) mutex locks.
The new impl replaces the array with a virHashTable, keyed off
UUID. Finding a object based on UUID is now O(1) time, and only
requires a single mutex lock. Finding by name/id is unchanged
in complexity.
In changing this, all code which iterates over the array had
to be updated to use a hash table iterator function callback.
Several of the functions which were identically duplicating
across all drivers were pulled into domain_conf.c
* src/conf/domain_conf.h, src/conf/domain_conf.c: Change
virDomainObjListPtr to use virHashTable. Add a initializer
method virDomainObjListInit, and rename virDomainObjListFree
to virDomainObjListDeinit, since its not actually freeing
the container, only its contents. Also add some convenient
methods virDomainObjListGetInactiveNames,
virDomainObjListGetActiveIDs and virDomainObjListNumOfDomains
which can be used to implement the correspondingly named
public API entry points in drivers
* src/libvirt_private.syms: Export new methods from domain_conf.h
* src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
src/openvz/openvz_conf.c, src/openvz/openvz_driver.c,
src/qemu/qemu_driver.c, src/test/test_driver.c,
src/uml/uml_driver.c, src/vbox/vbox_tmpl.c: Update all code
to deal with hash tables instead of arrays for domains
If the the qemu and kvm binaries are the same, we don't include machine
types in the kvm domain info.
However, the code which refreshes the machine types info from the
previous capabilities structure first looks at the kvm domain's info,
finds it matches and then copies the empty machine types list over
for the top-level qemu domain.
That doesn't make sense, we shouldn't copy an empty machin types list.
* src/qemu/qemu_conf.c: qemudGetOldMachinesFromInfo(): don't copy an
empty machine types list.
Normally, when you migrate a domain from host A to host B,
the domain on host A remains defined but shutoff and the domain
on host B remains running but is a "transient". Add a new
flag to virDomainMigrate() to allow the original domain to be
undefined on source host A, and a new flag to virDomainMigrate() to
allow the new domain to be persisted on the destination host B.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
The logic for running the decompression programs was broken in
commit f238709304, so that for
non-raw formats the decompression program was never run, and
for raw formats, it tried to exec an argv[] with initial NULL
in the program name.
* src/qemu/qemu_driver.c: Fix logic in runing decompression program
Introduces several new public API options for migration
- VIR_MIGRATE_PEER2PEER: With this flag the client only
invokes the virDomainMigratePerform method, expecting
the source host driver to do whatever is required to
complete the entire migration process.
- VIR_MIGRATE_TUNNELLED: With this flag the actual data
for migration will be tunnelled over the libvirtd RPC
channel. This requires that VIR_MIGRATE_PEER2PEER is
also set.
- virDomainMigrateToURI: This is variant of the existing
virDomainMigrate method which does not require any
virConnectPtr for the destination host. Given suitable
driver support, this allows for all the same modes as
virDomainMigrate()
The URI for VIR_MIGRATE_PEER2PEER must be a valid libvirt
URI. For non-p2p migration a hypervisor specific migration
URI is used.
virDomainMigrateToURI without a PEER2PEER flag is only
support for Xen currently, and it involves XenD talking
directly to XenD, no libvirtd involved at all.
* include/libvirt/libvirt.h.in: Add VIR_MIGRATE_PEER2PEER
flag for migration
* src/libvirt_internal.h: Add feature flags for peer to
peer migration (VIR_FEATURE_MIGRATE_P2P) and direct
migration (VIR_MIGRATE_PEER2PEER mode)
* src/libvirt.c: Implement support for VIR_MIGRATE_PEER2PEER
and virDomainMigrateToURI APIs.
* src/xen/xen_driver.c: Advertise support for DIRECT migration
* src/xen/xend_internal.c: Add TODO item for p2p migration
* src/libvirt_public.syms: Export virDomainMigrateToURI
method
* src/qemu/qemu_driver.c: Add support for PEER2PEER and
migration, and adapt TUNNELLED migration.
* tools/virsh.c: Add --p2p and --direct args and use the
new virDomainMigrateToURI method where possible.
Re-arrange the doTunnelMigrate method putting all non-QEMU local
state setup steps first. This maximises chances of success before
then starting destination QEMU for receiving incoming migration.
Altogether this can reduce the number of goto cleanup labels to
something more managable.
* qemu/qemu_driver.c: Re-order steps in doTunnelMigrate
Simplify the doTunnelMigrate code by pulling out the code for
sending all tunnelled data into separate helper
* qemu/qemu_driver.c: introduce doTunnelSendAll() method
Simplify the doTunnelMigrate() method by pulling out the code
which opens/closes the virConnectPtr object into a parent
method
* qemu/qemu_driver.c: Add doPeer2PeerMigrate which then calls
doTunnelMigrate with dconn & dom_xml
virStreamAbort is needed when the caller wishes to terminate
the stream early, not when virStreamSend fails.
* qemu/qemu_driver.c: Fix calling of virStreamAbort during
tunnelled migration
The code for tunnelled migration was added in a dedicated method,
but the native migration code is still inline in the top level
qemudDomainMigratePerform() API. Move the native code out into
a dedicated method too to make things more maintainable.
* src/qemu/qemu_driver.c: Pull code for performing a native
QEMU migration out into separate method
Since virMigratePrepareTunnel() is used for migration over the
native libvirt connection, there is never any need to pass the
target URI to this method.
* daemon/remote.c, src/driver.h, src/libvirt.c, src/libvirt_internal.h,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_protocol.c, src/remote/remote_protocol.h,
src/remote/remote_protocol.x: Remove 'uri_in' parameter from
virMigratePrepareTunnel() method
When James Morris originally submitted his sVirt patches (as seen in
libvirt 0.6.1), he did not require on disk labelling for
virSecurityDomainRestoreImageLabel. A later commit[2] changed this
behavior to assume on disk labelling, which halts implementations for
path-based MAC systems such as AppArmor and TOMOYO where
vm->def->seclabel is required to obtain the label.
* src/security/security_driver.h src/qemu/qemu_driver.c
src/security/security_selinux.c: adds the 'virDomainObjPtr vm'
argument back to *RestoreImageLabel
Fix migration, broken in two different ways by the QEMU monitor
abstraction. Note that the QEMU console emits a "\r\n" as the
line-ending.
* src/qemu/qemu_monitor_text.c (qemuMonitorGetMigrationStatus):
Fix "info migrate" command and its output's parsing.
Implementation of tunnelled migration, using a Unix Domain Socket
on the qemu backend. Note that this requires very new versions of
qemu (0.10.7 at least) in order to get the appropriate bugfixes.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
The upcoming tunnelled migration needs to be able to set
a migration in progress in the background, as well as
be able to cancel a migration when a problem has happened.
This patch allows for both of these to properly work.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
When using VNC for graphics + keyboard + mouse, we shouldn't
then use the host OS for audio. Audio should go back over
VNC.
When using SDL for graphics, we should use the host OS for
audio since that's where the display is. We need to allow
certain QEMU env variables to be passed through to guest
too to allow choice of QEMU audio backend.
* qemud/libvirtd.sysconf: Mention QEMU/SDL audio env vars
* src/qemu_conf.c: Passthrough QEMU/SDL audio env for SDL display,
disable host audio for VNC display
* src/qemu/qemu_monitor_text.c: Always print command and reply
in qemuMonitorCommandWithHandler. Print all args in each monitor
command API & remove redundant relpy printing
* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add new
qemuMonitorRemoveHostNetwork() command for removing host
networks
* src/qemu/qemu_driver.c: Convert NIC hotplug methods over
to use qemuMonitorRemoveHostNetwork()
* src/qemu/qemu_conf.h, src/qemu/qemu_conf.c: Remove prefix arg
from qemuBuildHostNetStr which is no longer required
* src/qemu/qemu_driver.c: Refactor to use qemuMonitorAddHostNetwork()
API for adding host network
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
qemuMonitorAddHostNetwork() method for adding host networks
* src/qemu/qemu_conf.c: Remove separator from qemuBuildNicStr()
args, and remove hardcoded 'nic' prefix. Leave it upto callers
instead
* src/qemu/qemu_driver.c: Switch over to using the new
qemuMonitorAddPCINetwork() method for NIC hotplug
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
qemuMonitorAddPCINetwork API for PCI network device hotplug
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
qemuMonitorCloseFileHandle and qemuMonitorSendFileHandle
APIs for processing file handles
* src/qemu/qemu_driver.c: Convert NIC hotplug method over to
use qemuMonitorCloseFileHandle and qemuMonitorSendFileHandle
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
API qemuMonitorAddPCIDisk()
* src/qemu/qemu_driver.c: Convert over to using the new
qemuMonitorAddPCIDisk() method, and remove now obsolete
qemudEscape() method
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new API
qemuMonitorRemovePCIDevice() for removing PCI device
* src/qemu/qemu_driver.c: Convert all places removing PCI devices
over to new qemuMonitorRemovePCIDevice() API
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
API qemuMonitorAddPCIHostDevice()
* src/qemu/qemu_driver.c: Switch to using qemuMonitorAddPCIHostDevice()
for PCI host device hotplug
One API adds an exact device based on bus+dev, the other adds
any device matching vendor+product
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
qemuMonitorAddUSBDeviceExact() and qemuMonitorAddUSBDeviceMatch()
commands.
* src/qemu/qemu_driver.c: Switch over to using the new
qemuMonitorAddUSBDeviceExact() and qemuMonitorAddUSBDeviceMatch()
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
qemuMonitorAddUSBDisk() API
* src/qemu/qemu_driver.c: Switch USB disk hotplug to the new
src/qemu/qemu_driver.c API.
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
qemuMonitorMigrateToCommand() API
* src/qemu/qemu_driver.c: Switch over to using the
qemuMonitorMigrateToCommand() API for core dumps and save
to file APIs
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new API
qemuMonitorMigrateToHost() for doing TCP migration
* src/qemu/qemu_driver.c: Convert to use qemuMonitorMigrateToHost().
Also handle proper URIs (tcp:// as well as tcp:)
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
qemuMonitorGetMigrationStatus() command.
* src/qemu/qemu_driver.c: Use new qemuMonitorGetMigrationStatus()
command to check completion status.
* src/qemu/qemu_driver.c: Use new qemuMonitorSetMigrationSpeed()
API during migration
* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add new
qemuMonitorSetMigrationSpeed() API
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a new
qemuMonitorGetBlockStatsInfo() command
* src/qemu/qemu_driver.c: Remove directly use of blockstats in
favour of calling qemuMonitorGetBlockStatsInfo()
* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add new APIs
qemuMonitorSaveVirtualMemory() and qemuMonitorSavePhysicalMemory()
* src/qemu/qemu_driver.c: Use the new qemuMonitorSaveVirtualMemory()
and qemuMonitorSavePhysicalMemory() APIs
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new APis
qemuMonitorChangeMedia and qemuMonitorEjectMedia. Pull in code
for qemudEscape
* src/qemu/qemu_driver.c: Remove code that directly issues 'eject'
and 'change' commands in favour of API calls.
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add new
qemuMonitorSetBalloon() based on existing code in
qemudDomainSetMemoryBalloon
* src/qemu/qemu_driver.c: Remove use of qemudDomainSetMemoryBalloon()
in favour of qemuMonitorSetBalloon(). Fix error code when balloon
is not supported
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Pull old
qemudDomainGetMemoryBalloon() code into a new method called
qemuMonitorGetBalloonInfo()
* src/qemu/qemu_driver.c: Update to call qemuMonitorGetBalloonInfo()
and remove qemudDomainGetMemoryBalloon().
* src/qemu/qemu_driver.c: Remove use of 'system_powerdown'
* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add a new
qemuMonitorSystemPowerdown() api call
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a new
qemuMonitorStopCPUs() API
* src/qemu/qemu_driver.c: Replace direct monitor commands for 'stop'
with qemuMonitorStopCPUs()
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Rename
Rename qemudMonitorSendCont to qemuMonitorStartCPUs
* src/qemu/qemu_driver.c: Update callers for new name
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a
new qemuMonitorSetVNCPassword() API
* src/qemu/qemu_driver.c: Refactor qemudInitPasswords to
call qemuMonitorSetVNCPassword()
* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add a new
qemuMonitorGetCPUInfo() command
* src/qemu/qemu_driver.c: Refactor qemudDetectVcpuPIDs to
use qemuMonitorGetCPUInfo()
Pull out all the QEMU monitor interaction code to a separate
file. This will make life easier when we need to drop in a
new implementation for the forthcoming QMP machine friendly
monitor support.
Next step is to add formal APIs for each monitor command,
and remove direct commands for sending/receiving generic
data.
* src/Makefile.am: Add qemu_monitor.c to build
* src/qemu/qemu_driver.c: Remove code for monitor interaction
* src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: New
file for monitor interaction
* po/POTFILES.in: Add src/qemu/qemu_monitor_text.c
Add the virStrncpy function, which takes a dst string, source string,
the number of bytes to copy and the number of bytes available in the
dest string. If the source string is too large to fit into the
destination string, including the \0 byte, then no data is copied and
the function returns NULL. Otherwise, this function copies n bytes
from source into dst, including the \0, and returns a pointer to the
dst string. This function is intended to replace all unsafe uses
of strncpy in the code base, since strncpy does *not* guarantee that
the buffer terminates with a \0.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
Latest upstream QEMU can be built with Xen support, which introduces
a -xen-domid argument. This was mistakenly detected as -domid due
to old Xenner support. Adapt to cope with both syntax. Also only
set domid if the virt type is xen, or the guest type is xen
* src/qemu_conf.c, src/qemu_conf.h: Detect new -xen-domid flag in
preference to -domid.
* tests/qemuxml2argvdata/qemuxml2argv-bootloader.args,
tests/qemuxml2argvdata/qemuxml2argv-input-xen.args: Add missing
-domid param
* tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args: Remove bogus
-boot param.
* tests/qemuxml2argvtest.c: Add missing QEMUD_CMD_FLAG_DOMID params
* daemon/default-network.xml: Move to src/network/default.xml
* daemon/libvirtd_qemu.aug, daemon/test_libvirtd_qemu.aug: Move
to src/qemu/
* src/qemu.conf: Move to src/qemu/qemu.conf
* daemon/Makefile.am: Remove rules for default-nmetwork.xml and
libvirtd_qemu.aug and test_libvirtd_qemu.aug. Fix typo in
uninstall-local that would install polkit again.
* src/Makefile.am: Add rules for installing network/default.xml
and the qemu/*.aug files. Add test case for QEMU augeas files.
Add uninstall-local rule for files/directories created during
install. Rename install-exec-local to install-data-local.
Only install qemu.conf if WITH_QEMU is set.
* tests/networkschematest: Update for XML location move