]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
15 years agoRename virFileCreate to virFileOperation, add hook function
Laine Stump [Fri, 19 Feb 2010 16:43:22 +0000 (17:43 +0100)]
Rename virFileCreate to virFileOperation, add hook function

It turns out it is also useful to be able to perform other operations
on a file created while running as a different uid (eg, write things
to that file), and possibly to do this to a file that already
exists. This patch adds an optional hook function to the renamed (for
more accuracy of purpose) virFileOperation; the hook will be called
after the file has been opened (possibly created) and gid/mode
checked/set, before closing it.

As with the other operations on the file, if the VIR_FILE_OP_AS_UID
flag is set, this hook function will be called in the context of a
child process forked from the process that called virFileOperation.
The implication here is that, while all data in memory is available to
this hook function, any modification to that data will not be seen by
the caller - the only indication in memory of what happened in the
hook will be the return value (which the hook should set to 0 on
success, or one of the standard errno values on failure).

Another piece of making the function more flexible was to add an
"openflags" argument. This arg should contain exactly the flags to be
passed to open(2), eg O_RDWR | O_EXCL, etc.

In the process of adding the hook to virFileOperation, I also realized
that the bits to fix up file owner/group/mode settings after creation
were being done in the parent process, which could fail, so I moved
them to the child process where they should be.

* src/util/util.[ch]: rename and rework virFileCreate-->virFileOperation,
  and redo flags in virDirCreate
* storage/storage_backend.c, storage/storage_backend_fs.c: update the
  calls to virFileOperation/virDirCreate to reflect changes in the API,
  but don't yet take advantage of the hook.

15 years agoqemu: Check for IA64 kvm
Dustin Xiong [Thu, 18 Feb 2010 15:48:51 +0000 (10:48 -0500)]
qemu: Check for IA64 kvm

ACPI feature bit dropped: I asked internally if the -no-acpi option
had any meaning for IA64, and was told 'probably not'.

15 years agoremote: Print ssh stderr on connection failure
Cole Robinson [Thu, 11 Feb 2010 22:39:38 +0000 (17:39 -0500)]
remote: Print ssh stderr on connection failure

15 years agofix multiple veth problem for OpenVZ
Yuji NISHIDA [Fri, 19 Feb 2010 15:49:56 +0000 (16:49 +0100)]
fix multiple veth problem for OpenVZ

Fix multiple veth problem.
NETIF setting was overwritten after first CT because any CT could not be
found by name.
* src/openvz/openvz_conf.c src/openvz/openvz_conf.h: add the
  openvzGetVEID lookup function
* src/openvz/openvz_driver.c: use it in openvzDomainSetNetwork()

15 years agoBetter error reporting for failed migration
Chris Lalancette [Fri, 19 Feb 2010 15:15:21 +0000 (16:15 +0100)]
Better error reporting for failed migration

If the hostname as returned by "gethostname" resolves
to "localhost" (as it does with the broken Fedora-12
installer), then live migration will fail because the
source will try to migrate to itself.  Detect this
situation up-front and abort the live migration before
we do any real work.

* src/util/util.h src/util/util.c: add a new virGetHostnameLocalhost
  with an optional localhost check, and rewire virGetHostname() to use
  it
* src/libvirt_private.syms: expose the new function
* src/qemu/qemu_driver.c: use it in qemudDomainMigratePrepare2()

15 years agoMake virDomainObjFormat static
Chris Lalancette [Fri, 19 Feb 2010 15:06:08 +0000 (16:06 +0100)]
Make virDomainObjFormat static

* src/conf/domain_conf.c: make function static
* src/conf/domain_conf.h: remove it from header

15 years agoMake an error message in PCI util code clearer
Chris Lalancette [Fri, 19 Feb 2010 15:04:35 +0000 (16:04 +0100)]
Make an error message in PCI util code clearer

* src/util/pci.c: update 2 message on pciRead errors

15 years agomacvtap mac_filter support
Stefan Berger [Fri, 19 Feb 2010 14:41:30 +0000 (15:41 +0100)]
macvtap mac_filter support

This patch adds the mac_filter support to the macvtap device.

15 years agovirsh: be careful to return "FALSE" upon OOM
Jim Meyering [Thu, 18 Feb 2010 10:05:38 +0000 (11:05 +0100)]
virsh: be careful to return "FALSE" upon OOM

* tools/virsh.c (cmdCPUBaseline): Add an explicit "return" statement
after the "no_memory:" label.

15 years agovirBufferStrcat: do not skip va_end
Jim Meyering [Thu, 18 Feb 2010 19:46:24 +0000 (20:46 +0100)]
virBufferStrcat: do not skip va_end

* src/util/buf.c (virBufferStrcat): Do not skip va_end due to
an early return.

15 years agoqparams.c: do not skip va_end, twice
Jim Meyering [Thu, 18 Feb 2010 19:27:22 +0000 (20:27 +0100)]
qparams.c: do not skip va_end, twice

* src/util/qparams.c (new_qparam_set, append_qparams): Do not skip
va_end due to an early return.

15 years agoxenDaemonDomainSetAutostart: avoid appearance of impropriety
Jim Meyering [Wed, 17 Feb 2010 21:14:25 +0000 (22:14 +0100)]
xenDaemonDomainSetAutostart: avoid appearance of impropriety

* src/xen/xend_internal.c (xenDaemonDomainSetAutostart): Rewrite to
avoid dereferencing the result of sexpr_lookup.  While in this
particular case, it was guaranteed never to be NULL, due to the
preceding "if sexpr_node(...)" guard, it's cleaner to skip the
sexpr_node call altogether, and also saves a lookup.

15 years agomacvtap IFF_VNET_HDR configuration
Stefan Berger [Fri, 19 Feb 2010 10:38:57 +0000 (11:38 +0100)]
macvtap IFF_VNET_HDR configuration

This patch sets or unsets the IFF_VNET_HDR flag depending on what device
is used in the VM. The manipulation of the flag is done in the open
function and is only fatal if the IFF_VNET_HDR flag could not be cleared
although it has to be (or if an ioctl generally fails). In that case the
macvtap tap is closed again and the macvtap interface torn.

* src/qemu/qemu_conf.c src/qemu/qemu_conf.h: pass qemuCmdFlags to
  qemudPhysIfaceConnect()
* src/util/macvtap.c src/util/macvtap.h: add vnet_hdr boolean to
  openMacvtapTap(), and private function configMacvtapTap()
* src/qemu/qemu_driver.c: add extra qemuCmdFlags when calling
  qemudPhysIfaceConnect()

15 years agoUse virFork() in __virExec(), virFileCreate() and virDirCreate()
Laine Stump [Thu, 18 Feb 2010 21:20:07 +0000 (22:20 +0100)]
Use virFork() in __virExec(), virFileCreate() and virDirCreate()

For __virExec() this is a semantic NOP except for when fork()
fails. __virExec() would previously forget to restore the signal mask
in this case; virFork() corrects this behavior.

virFileCreate() and virDirCreate() gain the code to reset the logging
and properly deal with the signal handling race condition.

This also removes a log message that had a typo ("cannot fork o create
file '%s'") - this error is now logged in a more generic manner in
virFork() (more generic, but really just as informative, since the
fact that it's forking to create a file is immaterial to the fact that
it simply can't fork)

* src/util/util.c: use the generic virFork() in the 3 functions

15 years agoAdd virFork() function to utils
Laine Stump [Thu, 18 Feb 2010 21:13:48 +0000 (22:13 +0100)]
Add virFork() function to utils

virFork() contains bookkeeping that must be done any time a process
forks. Currently this includes:

1) Call virLogLock() prior to fork() and virLogUnlock() just after,
   to avoid a deadlock if some other thread happens to hold that lock
   during the fork.

2) Reset the logging hooks and send all child process log messages to
   stderr.

3) Block all signals prior to fork(), then either a) reset the signal
   mask for the parent process, or b) clear the signal mask for the
   child process.

Note that the signal mask handling in __virExec erroneously fails to
restore the signal mask when fork() fails. virFork() fixes this
problem.

Other than this, it attempts to behave as closely to fork() as
possible (including preserving errno for the caller), with a couple
exceptions:

1) The return value is 0 (success) or -1 (failure), while the pid is
   returned via the pid_t* argument. Like fork(), if pid < 0 there is
   no child process, otherwise both the child and the parent will
   return to the caller, and both should look at the return value,
   which will indicate if some of the extra processing outlined above
   encountered an error.

2) If virFork() returns with pid < 0 or with a return value < 0
   indicating an error condition, the error has already been
   reported. You can log an additional message if you like, but it
   isn't necessary, and may be awkwardly extraneous.

Note that virFork()'s child process will *never* call _exit() - if a
child process is created, it will return to the caller.

* util.c util.h: add virFork() function, based on what is currently
                 done in __virExec().

15 years agoAdd QEMU support for virtio channel
Matthew Booth [Thu, 18 Feb 2010 16:56:50 +0000 (17:56 +0100)]
Add QEMU support for virtio channel

Support virtio-serial controller and virtio channel in QEMU backend.
Will output
the following for virtio-serial controller:

-device
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4,max_ports=16,vectors=4

and the following for a virtio channel:

-chardev pty,id=channel0 \
-device
virtserialport,bus=virtio-serial0.0,chardev=channel0,name=org.linux-kvm.port.0

* src/qemu/qemu_conf.c: Add argument output for virtio
* tests/qemuxml2argvtest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args: Add test for
  QEMU command line generation

15 years agoAdd domain support for virtio channel
Matthew Booth [Thu, 18 Feb 2010 16:52:03 +0000 (17:52 +0100)]
Add domain support for virtio channel

Add support for virtio-serial by defining a new 'virtio' channel target type
and a virtio-serial controller. Allows the following to be specified in a
domain:

<controller type='virtio-serial' index='0' ports='16' vectors='4'/>
<channel type='pty'>
  <target type='virtio' name='org.linux-kvm.port.0'/>
  <address type='virtio-serial' controller='0' bus='0'/>
</channel>

* docs/schemas/domain.rng: Add virtio-serial controller and virtio
  channel type.
* src/conf/domain_conf.[ch]: Domain parsing/serialization for
  virtio-serial controller and virtio channel.
* tests/qemuxml2xmltest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml: add domain xml
  parsing test
* src/libvirt_private.syms src/qemu/qemu_conf.c:
  virDomainDefAddDiskControllers() renamed to
  virDomainDefAddImplicitControllers()

15 years agoRemove unused functions from domain_conf
Matthew Booth [Thu, 18 Feb 2010 15:45:18 +0000 (16:45 +0100)]
Remove unused functions from domain_conf

Remove virDomainDevicePCIAddressEqual and virDomainDeviceDriveAddressEqual,
which are defined but not used anywhere.

* src/conf/domain_conf.[ch] src/libvirt_private.syms: Remove
  virDomainDevicePCIAddressEqual and virDomainDeviceDriveAddressEqual.

15 years agoFix typo in comment
Matthew Booth [Thu, 18 Feb 2010 15:40:48 +0000 (16:40 +0100)]
Fix typo in comment

* src/qemu/qemu_driver.c: qemudStartVMDaemon() fix typo in comment

15 years agoget_virtual_functions_linux: would mistakenly always return zero
Jim Meyering [Thu, 18 Feb 2010 10:12:17 +0000 (11:12 +0100)]
get_virtual_functions_linux: would mistakenly always return zero

* src/node_device/node_device_linux_sysfs.c(get_virtual_functions_linux):
Return "ret", rather than always returning 0.

15 years agoqemu: Explicitly error if guest virtual network is inactive
Cole Robinson [Tue, 16 Feb 2010 18:11:27 +0000 (13:11 -0500)]
qemu: Explicitly error if guest virtual network is inactive

Currently we just error with ex. 'virbr0: No such device'.

Since we are using public API calls here, we need to ensure that any
raised error is properly saved and restored, since API entry points
always reset messages.

15 years agonetwork: bridge: Fix IsActive, IsPersistent
Cole Robinson [Tue, 16 Feb 2010 18:09:31 +0000 (13:09 -0500)]
network: bridge: Fix IsActive, IsPersistent

We were accessing the wrong private data structure, which would
cause a segfault.

15 years agovirterror: Make SetError work if no previous error was set
Cole Robinson [Tue, 16 Feb 2010 18:07:31 +0000 (13:07 -0500)]
virterror: Make SetError work if no previous error was set

virGetLastError returns NULL if no error has been set, not on
allocation error like virSetError assumed. Use virLastErrorObject
instead. This fixes virSetError when no error is currently stored.

15 years agolibvirt: Update docs for hotplug only commands
Cole Robinson [Tue, 16 Feb 2010 18:59:21 +0000 (13:59 -0500)]
libvirt: Update docs for hotplug only commands

The commands updated are SetMem, SetMaxMem, SetVcpus, and PinVcpu.

15 years agomacvtap teardown rework
Stefan Berger [Thu, 18 Feb 2010 14:13:48 +0000 (15:13 +0100)]
macvtap teardown rework

Rework and simplification of teardown of the macvtap device.

Basically all devices with the same MAC address and link device are kept
alive and not attempted to be torn down. If a macvtap device linked to a
physical interface with a certain MAC address 'M' is to be created it
will automatically fail if the interface is 'up'ed and another macvtap
with the same properties (MAC addr 'M', link dev) happens to be 'up'.
This will prevent the VM from starting or the device from being attached
to a running VM. Stale interfaces are assumed to be there for some
reason and not stem from libvirt.

In the VM shutdown path, it's assuming that an interface name is always
available so that if the device type is DIRECT it can be torn down
using its name.

* src/util/macvtap.h src/libvirt_macvtap.syms: change of deleting routine
* src/util/macvtap.c: cleanups and change of deleting routine
* src/qemu/qemu_driver.c: change cleanup on shutdown
* src/qemu/qemu_conf.c: don't delete Macvtap in qemudPhysIfaceConnect()

15 years agoFix whitespace in domain.rng
Matthew Booth [Wed, 17 Feb 2010 16:16:42 +0000 (17:16 +0100)]
Fix whitespace in domain.rng

* src/schemas/domain.rng: Replace tabs with 8 spaces

15 years agoUpdate QEMU JSON balloon command handling
Daniel P. Berrange [Tue, 16 Feb 2010 16:31:19 +0000 (16:31 +0000)]
Update QEMU JSON balloon command handling

The QEMU JSON monitor changed balloon commands to return/accept
bytes instead of kilobytes. Update libvirt to cope with this

* src/qemu/qemu_monitor_json.c: Expect/use bytes for ballooning

15 years agoopenvzLoadDomains: don't ignore failing virUUIDFormat
Jim Meyering [Wed, 17 Feb 2010 14:06:01 +0000 (15:06 +0100)]
openvzLoadDomains: don't ignore failing virUUIDFormat

* src/openvz/openvz_conf.c (openvzLoadDomains): Diagnose failure of
virUUIDFormat.

15 years agopython: Actually add virConnectGetVersion to generated bindings
Cole Robinson [Wed, 17 Feb 2010 20:55:46 +0000 (15:55 -0500)]
python: Actually add virConnectGetVersion to generated bindings

The recent commit to implement a python version of this function
didn't drop an explicit 'ignore' check in the generator, so this
never ended up in the bindings.

15 years agobuild: inform libtool of m4 directory
Eric Blake [Wed, 17 Feb 2010 13:45:10 +0000 (06:45 -0700)]
build: inform libtool of m4 directory

Silence a libtoolize warning.
*  configure.ac (AC_CONFIG_MACRO_DIR): Add.

15 years agoAdds a cpu-baseline command for virsh
Jiri Denemark [Wed, 17 Feb 2010 13:52:07 +0000 (14:52 +0100)]
Adds a cpu-baseline command for virsh

* tools/virsh.c: add a command to compute a CPU baseline based on
  multiple CPU definitions in an XML chunk
* tools/virsh.pod: add it to the man page

15 years agovshCommandParse: placate coverity
Jim Meyering [Tue, 16 Feb 2010 13:34:48 +0000 (14:34 +0100)]
vshCommandParse: placate coverity

There is no real leak here, but Coverity-Prevent thinks there is.
It does not see that while there are four ways to return from
vshCommandGetToken with VSH_TK_END, none of them results in allocation
of a result.
* tools/virsh.c (vshCommandParse): Add a (currently) useless VIR_FREE,
to ensure that we never leak when vshCommandGetToken returns VSH_TK_END.

15 years agoqemuMonitorTextAddUSBDisk: avoid unconditional leak
Jim Meyering [Tue, 16 Feb 2010 12:51:38 +0000 (13:51 +0100)]
qemuMonitorTextAddUSBDisk: avoid unconditional leak

* src/qemu/qemu_monitor_text.c (qemuMonitorTextAddUSBDisk): Free
command output buffer.

15 years agotests: avoid NULL deref upon OOM failure
Jim Meyering [Tue, 16 Feb 2010 08:36:57 +0000 (09:36 +0100)]
tests: avoid NULL deref upon OOM failure

* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Handle malloc
failure.

15 years agoqemuInitPasswords: avoid unconditional leak
Jim Meyering [Tue, 16 Feb 2010 08:22:02 +0000 (09:22 +0100)]
qemuInitPasswords: avoid unconditional leak

* src/qemu/qemu_driver.c (qemuInitPasswords): Free pass-phrase buffer.

15 years agoqemuMonitorTextAddDevice: avoid unconditional leak
Jim Meyering [Tue, 16 Feb 2010 07:22:34 +0000 (08:22 +0100)]
qemuMonitorTextAddDevice: avoid unconditional leak

* src/qemu/qemu_monitor_text.c (qemuMonitorTextAddDevice): Free the
device name buffer.

15 years agolibvirt-override.c: avoid a leak upon call with invalid argument
Jim Meyering [Tue, 16 Feb 2010 07:07:38 +0000 (08:07 +0100)]
libvirt-override.c: avoid a leak upon call with invalid argument

* python/libvirt-override.c (libvirt_virConnectBaselineCPU): Don't leak
the xmlcpus buffer upon encountering a non-string list element.

15 years agovboxDomainDumpXML: avoid a leak on OOM error path
Jim Meyering [Mon, 15 Feb 2010 19:09:55 +0000 (20:09 +0100)]
vboxDomainDumpXML: avoid a leak on OOM error path

* src/vbox/vbox_tmpl.c (vboxDomainDumpXML): Free vboxCallback buffer
upon OOM.

15 years agovirNodeDevCapScsiHostParseXML: avoid an unconditional leak
Jim Meyering [Mon, 15 Feb 2010 18:54:45 +0000 (19:54 +0100)]
virNodeDevCapScsiHostParseXML: avoid an unconditional leak

* src/conf/node_device_conf.c (virNodeDevCapScsiHostParseXML):
Free the "nodes" buffer allocated by virXPathNodeSet.

15 years agouml_driver.c: avoid leak upon failure
Jim Meyering [Mon, 15 Feb 2010 18:22:38 +0000 (19:22 +0100)]
uml_driver.c: avoid leak upon failure

* src/uml/uml_driver.c (umlMonitorCommand): This function would
sometimes return -1, yet fail to free the "reply" it had allocated.
Hence, no caller would know to free the corresponding argument.
When returning -1, be sure to free all allocated resources.

15 years agovbox_tmpl.c: avoid an unconditional leak
Jim Meyering [Mon, 15 Feb 2010 16:54:15 +0000 (17:54 +0100)]
vbox_tmpl.c: avoid an unconditional leak

* src/vbox/vbox_tmpl.c (vboxDomainDumpXML): Free def.
Improved by Matthias Bolte.

15 years agoopenvz (openvzFreeDriver): avoid leaks
Jim Meyering [Mon, 15 Feb 2010 17:33:38 +0000 (18:33 +0100)]
openvz (openvzFreeDriver): avoid leaks

* src/openvz/openvz_conf.c (openvzFreeDriver): Also free driver buffer.
Based on a suggestion from Matthias Bolte.

15 years agovirStorageBackendIsMultipath: avoid dead store
Jim Meyering [Thu, 11 Feb 2010 14:26:37 +0000 (15:26 +0100)]
virStorageBackendIsMultipath: avoid dead store

* src/storage/storage_backend_mpath.c (virStorageBackendIsMultipath):
The result of dm_get_next_target was never used (and isn't needed),
so don't store it.

15 years agoqemu: Make SetVcpu command hotplug only
Cole Robinson [Tue, 9 Feb 2010 21:31:51 +0000 (16:31 -0500)]
qemu: Make SetVcpu command hotplug only

Similar to the Set*Mem commands, this implementation was bogus and
misleading. Make it clear this is a hotplug only operation, and that the
hotplug piece isn't even implemented.

Also drop the overkill maxvcpus validation: we don't perform this check
at XML define time so clearly no one is missing it, and there is
always the risk that our info will be out of date, possibly preventing
legitimate CPU values.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
15 years agoqemu: Make Set*Mem commands hotplug only
Cole Robinson [Tue, 9 Feb 2010 21:25:06 +0000 (16:25 -0500)]
qemu: Make Set*Mem commands hotplug only

SetMem and SetMaxMem are hotplug only APIs, any persistent config
changes are supposed to go via XML definition. The original implementation
of these calls were incorrect and had the nasty side effect of making
a psuedo persistent change that would be lost after libvirtd restart
(I didn't know any better).

Fix these APIs to rightly reject non running domains.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
15 years agoTreat missing QEMU 'thread_id' as non-fatal in JSON monitor
Daniel P. Berrange [Mon, 15 Feb 2010 14:41:50 +0000 (14:41 +0000)]
Treat missing QEMU 'thread_id' as non-fatal in JSON monitor

The plain QEMU tree does not include 'thread_id' in the JSON
output. Thus we need to treat it as non-fatal if missing.

* src/qemu/qemu_monitor_json.c: Treat missing thread_id as non-fatal

15 years agoFix check for primary IDE controller in QEMU PCI slot assignment
Daniel P. Berrange [Mon, 15 Feb 2010 14:37:04 +0000 (14:37 +0000)]
Fix check for primary IDE controller in QEMU PCI slot assignment

A typo in the check for the primary IDE controller could cause
a crash on restore depending on the exact guest config.

* src/qemu/qemu_conf.c: Fix s/video/controller/ typo & slot
  number typo

15 years agoMake error reporting for QEMU JSON mode more friendly
Daniel P. Berrange [Fri, 12 Feb 2010 16:45:11 +0000 (16:45 +0000)]
Make error reporting for QEMU JSON mode more friendly

Current error reporting for JSON mode returns the full JSON
command string and full JSON error string. This is not very
user friendly, so this change makes the error report only
contain the basic command name, and friendly error message
description string. The full JSON data is logged instead.

* src/qemu/qemu_monitor_json.c: Always return the 'desc' field from
  the JSON error message to users.

15 years agoRun 'qmp_capabilities' command at QEMU monitor startup
Daniel P. Berrange [Fri, 12 Feb 2010 13:45:20 +0000 (13:45 +0000)]
Run 'qmp_capabilities' command at QEMU monitor startup

When in JSON mode, QEMU requires that 'qmp_capabilities' is run as
the first command in the monitor. This is a no-op when run in the
text mode monitor

* src/qemu/qemu_driver.c: Run capabilities negotiation when
  connecting to the monitor
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h: Add
  support for the 'qmp_capabilities' command, no-op in text mode.

15 years agomacvtap support for libvirt -- schema extensions
Stefan Berger [Mon, 15 Feb 2010 16:43:42 +0000 (17:43 +0100)]
macvtap support for libvirt -- schema extensions

* docs/schemas/domain.rng: extends the domain xml schema to support the
  new interface type 'direct'

15 years agomacvtap support for libvirt -- qemu support
Stefan Berger [Mon, 15 Feb 2010 16:41:14 +0000 (17:41 +0100)]
macvtap support for libvirt -- qemu support

This part adds support for qemu making a macvtap tap device available
via file descriptor passed to qemu command line. This also attempts to
tear down the macvtap device when a VM terminates. This includes support
for attachment and detachment to/from running VM.
* src/qemu/qemu_conf.[ch] src/qemu/qemu_driver.c: add support in the
  QEmu driver

15 years agomacvtap support for libvirt -- helper code
Stefan Berger [Mon, 15 Feb 2010 15:58:13 +0000 (16:58 +0100)]
macvtap support for libvirt -- helper code

This part adds the helper code to setup and tear down macvtap devices
using direct communication with the device driver via netlink sockets.
The rather short messages received from the netlink layer are now
written into a dynamically allocated buffer

* src/util/macvtap.h src/util/macvtap.c: provides the new module
* po/POTFILES.in: the module contains translated strings

15 years agomacvtap support for libvirt -- parse new interface XML
Stefan Berger [Fri, 12 Feb 2010 17:07:06 +0000 (18:07 +0100)]
macvtap support for libvirt -- parse new interface XML

This part adds support to domain_conf.{c|h} for parsing the new
interface XML of type 'direct'. The parsed mode is now stored as
an int.
* src/conf/domain_conf.c src/conf/domain_conf.h: extend parsing code
* src/util/macvtap.h: empty header to not break compilation

15 years agomacvtap support for libvirt -- build support
Stefan Berger [Fri, 12 Feb 2010 17:03:07 +0000 (18:03 +0100)]
macvtap support for libvirt -- build support

This patch adds build support for libvirt checking for certain contents
of /usr/include/linux/if_link.h to see whether macvtap support is
compilable on that system. One can disable macvtap support in libvirt
via --without-macvtap passed to configure.
* configure.ac src/Makefile.am: new build support
* src/libvirt_macvtap.syms: list of exported symbols
* src/util/macvtap.c: empty module to not break compilation

15 years agointerface: Use proper return codes in the open function
Matthias Bolte [Sun, 14 Feb 2010 22:15:56 +0000 (23:15 +0100)]
interface: Use proper return codes in the open function

The open function returned -1 in case of an error, but -1 maps
to VIR_DRV_OPEN_DECLINED instead of VIR_DRV_OPEN_ERROR.

15 years agoConvert virSecurityReportError into a macro
Matthias Bolte [Thu, 11 Feb 2010 23:18:54 +0000 (00:18 +0100)]
Convert virSecurityReportError into a macro

The virRaiseError macro inside of virSecurityReportError expands to
virRaiseErrorFull and includes the __FILE__, __FUNCTION__ and __LINE__
information. But this three values are always the same for every call
to virSecurityReportError and do not reflect the actual error context.

Converting virSecurityReportError into a macro results in getting the
correct __FILE__, __FUNCTION__ and __LINE__ information.

15 years agoAdd persistence of PCI addresses to QEMU
Daniel P. Berrange [Thu, 11 Feb 2010 16:19:34 +0000 (16:19 +0000)]
Add persistence of PCI addresses to QEMU

Current PCI addresses are allocated at time of VM startup.
To make them truely persistent, it is neccessary to do this
at time of virDomainDefine/virDomainCreate. The code in
qemuStartVMDaemon still remains in order to cope with upgrades
from older libvirt releases

* src/qemu/qemu_driver.c: Rename existing qemuAssignPCIAddresses
  to qemuDetectPCIAddresses. Add new qemuAssignPCIAddresses which
  does auto-allocation upfront. Call qemuAssignPCIAddresses from
  qemuDomainDefine and qemuDomainCreate to assign PCI addresses that
  can then be persisted. Don't clear PCI addresses at shutdown if
  they are intended to be persistent

15 years agoFix crash in LXC driver open method when URI has no path
Daniel P. Berrange [Thu, 11 Feb 2010 15:00:25 +0000 (15:00 +0000)]
Fix crash in LXC driver open method when URI has no path

If giving a lxc://  URI instead of lxc:/// the open method
would crash ona NULL pointer

* src/lxc/lxc_driver.c: Cope with a NULL URI path

15 years agoFix USB device path formatting mixup
Daniel P. Berrange [Thu, 11 Feb 2010 14:39:13 +0000 (14:39 +0000)]
Fix USB device path formatting mixup

* src/util/hostusb.c: The device path for a USB device wants the
  bus/device IDs in decimal not octal

15 years agoSupport 'block_passwd' command for QEMU disk encryption
Daniel P. Berrange [Thu, 11 Feb 2010 14:28:16 +0000 (14:28 +0000)]
Support 'block_passwd' command for QEMU disk encryption

The old text mode monitor prompts for a password when disks are
encrypted. This interactive approach doesn't work for JSON mode
monitor. Thus there is a new 'block_passwd' command that can be
used.

* src/qemu/qemu_driver.c: Split out code for looking up a disk
  secret from findVolumeQcowPassphrase, into a new method
  getVolumeQcowPassphrase. Enhance qemuInitPasswords() to also
  set the disk encryption password via the monitor
* 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
  support for the 'block_passwd' monitor command.

15 years agoImplement cpuBaseline in remote and qemu drivers
Jiri Denemark [Tue, 2 Feb 2010 14:19:14 +0000 (15:19 +0100)]
Implement cpuBaseline in remote and qemu drivers

15 years agoWire protocol format and dispatcher for virConnectBaselineCPU
Jiri Denemark [Tue, 2 Feb 2010 13:39:05 +0000 (14:39 +0100)]
Wire protocol format and dispatcher for virConnectBaselineCPU

15 years agovirConnectBaselineCPU public API implementation
Jiri Denemark [Mon, 25 Jan 2010 14:08:05 +0000 (15:08 +0100)]
virConnectBaselineCPU public API implementation

15 years agoInternal driver API for virConnectBaselineCPU
Jiri Denemark [Tue, 2 Feb 2010 11:34:01 +0000 (12:34 +0100)]
Internal driver API for virConnectBaselineCPU

15 years agovirConnectBaselineCPU public API
Jiri Denemark [Fri, 22 Jan 2010 13:52:41 +0000 (14:52 +0100)]
virConnectBaselineCPU public API

15 years agoImplement cpuArchBaseline in x86 CPU driver
Jiri Denemark [Wed, 27 Jan 2010 13:33:20 +0000 (14:33 +0100)]
Implement cpuArchBaseline in x86 CPU driver

15 years agoImplement cpuArchBaseline in generic CPU driver
Jiri Denemark [Tue, 26 Jan 2010 16:40:04 +0000 (17:40 +0100)]
Implement cpuArchBaseline in generic CPU driver

15 years agoFunctions for computing baseline CPU from a set of host CPUs
Jiri Denemark [Mon, 25 Jan 2010 17:27:56 +0000 (18:27 +0100)]
Functions for computing baseline CPU from a set of host CPUs

Baseline CPU is the best CPU which can be used for a guest on any of the
hosts.

15 years agoFix compliation of AppArmor related code
Matthias Bolte [Thu, 11 Feb 2010 23:09:59 +0000 (00:09 +0100)]
Fix compliation of AppArmor related code

Broken by the latest commits to remove the virConnectPtr parameter
from internal functions.

15 years agoqemu_driver.c: honor dname parameter once again
Jim Meyering [Thu, 11 Feb 2010 15:46:21 +0000 (16:46 +0100)]
qemu_driver.c: honor dname parameter once again

Since c26cb9234f4b9fa46d7caa3385ae36704167c53f, the dname
parameter has been ignored by these two functions.  Use it.
* src/qemu/qemu_driver.c (qemudDomainMigratePrepareTunnel): Honor dname
parameter once again.
(qemudDomainMigratePrepare2): Likewise.

15 years agoplug four virStoragePoolSourceFree-related leaks
Jim Meyering [Fri, 5 Feb 2010 16:09:43 +0000 (17:09 +0100)]
plug four virStoragePoolSourceFree-related leaks

* src/conf/storage_conf.c (virStoragePoolDefParseSourceString):
* src/storage/storage_backend_fs.c:
(virStorageBackendFileSystemNetFindPoolSourcesFunc):
(virStorageBackendFileSystemNetFindPoolSources):
* src/test/test_driver.c (testStorageFindPoolSources):

15 years agoremote_driver.c: avoid leak on OOM error path
Jim Meyering [Thu, 11 Feb 2010 11:51:31 +0000 (12:51 +0100)]
remote_driver.c: avoid leak on OOM error path

* src/remote/remote_driver.c (doRemoteOpen): Don't leak a qparam_set
buffer upon OOM error.

15 years agoMark all error messages for translation
Jiri Denemark [Thu, 11 Feb 2010 15:27:26 +0000 (16:27 +0100)]
Mark all error messages for translation

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
15 years agoAdd cpu_generic.c to the list of translated files
Jiri Denemark [Thu, 11 Feb 2010 15:27:14 +0000 (16:27 +0100)]
Add cpu_generic.c to the list of translated files

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
15 years agoSwap position of nmodels and models parameters in cpuDecode()
Jiri Denemark [Thu, 11 Feb 2010 09:47:43 +0000 (10:47 +0100)]
Swap position of nmodels and models parameters in cpuDecode()

All other libvirt functions use array first and then number of elements
in that array. Let's make cpuDecode follow this rule.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
15 years agoFix <cpu> element in domain XML schema
Jiri Denemark [Tue, 9 Feb 2010 14:53:03 +0000 (15:53 +0100)]
Fix <cpu> element in domain XML schema

The current schema is more permissive than the XML parsing code in
libvirt. Precisely, 'match' attribute is optional in schema while in
reality its use is bound to <model> element:

- <cpu> element without 'match' attribute is allowed only if <topology>
  element is the only child element of <cpu>

- <cpu> element with 'match' attribute requires <model> element to be
  present; <topology> and <feature> elements are optional

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
15 years agoFix up a misspelled comment.
Chris Lalancette [Wed, 10 Feb 2010 21:11:42 +0000 (16:11 -0500)]
Fix up a misspelled comment.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix disk stats retrieval with QEMU >= 0.12
Daniel P. Berrange [Wed, 10 Feb 2010 17:46:44 +0000 (17:46 +0000)]
Fix disk stats retrieval with QEMU >= 0.12

With QEMU >= 0.12 the host and guest side of disks no longer have
the same naming convention. Specifically the host side will now
get a 'drive-' prefix added to its name. The 'info blockstats'
monitor command returns the host side name, so it is neccessary
to strip this off when looking up stats since libvirt stores the
guest side name !

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Move 'drive-' prefix
  string to a defined constant
* src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_text.c: Strip
  off 'drive-' prefix (if found) when looking up disk stats

15 years agoqemu: Increase guest startup timeout to 30 seconds
Cole Robinson [Tue, 9 Feb 2010 20:10:41 +0000 (15:10 -0500)]
qemu: Increase guest startup timeout to 30 seconds

Currently the timeout for reading startup output is 3 seconds. If the
host is under any sort of load, we can easily trigger this. Lets bump
it to 30 seconds.

Since the polling loop checks to see if the process has died, we shouldn't
erroneously hit this timeout if qemu bombs (only if it is stuck in some
infinite loop).

15 years agoqemu: Properly report a startup timeout error
Cole Robinson [Tue, 9 Feb 2010 19:45:35 +0000 (14:45 -0500)]
qemu: Properly report a startup timeout error

The timeout errors were unconditionally being overwritten by the less
helpful 'unable to start guest' error.

15 years agotest: Fake security driver support in capabilities
Cole Robinson [Tue, 9 Feb 2010 17:16:00 +0000 (12:16 -0500)]
test: Fake security driver support in capabilities

Having some value in capabilities helps testing this stuff in
virt-manager.

15 years agoAnnotate some virConnectPtr as mandatory non-null
Daniel P. Berrange [Wed, 10 Feb 2010 13:19:17 +0000 (13:19 +0000)]
Annotate some virConnectPtr as mandatory non-null

Use the ATTRIBUTE_NONNULL annotation to mark some virConnectPtr
args as mandatory non-null so the compiler can warn of mistakes

* src/conf/domain_event.h: All virConnectPtr args must be non-null
* src/qemu/qemu_conf.h: qemudBuildCommandLine and
  qemudNetworkIfaceConnect() must be given non-null connection
* tests/qemuxml2argvtest.c: Provide a non-null (dummy) connection to
  qemudBuildCommandLine()

15 years agoRemove virConnectPtr from secret XML APIs
Daniel P. Berrange [Wed, 10 Feb 2010 12:33:34 +0000 (12:33 +0000)]
Remove virConnectPtr from secret XML APIs

The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in secret_conf.{h,c} and update all callers to
match

15 years agoRemove virConnectPtr from interface XML APIs
Daniel P. Berrange [Wed, 10 Feb 2010 12:28:05 +0000 (12:28 +0000)]
Remove virConnectPtr from interface XML APIs

The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in interface_conf.{h,c} and update all callers to
match

15 years agoRemove virConnectPtr from CPU XML APIs
Daniel P. Berrange [Wed, 10 Feb 2010 12:22:36 +0000 (12:22 +0000)]
Remove virConnectPtr from CPU XML APIs

The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in cpu_conf.{h,c} and update all callers to
match

15 years agoRemove virConnectPtr from storage APIs & driver
Daniel P. Berrange [Wed, 10 Feb 2010 11:42:56 +0000 (11:42 +0000)]
Remove virConnectPtr from storage APIs & driver

The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in storage_conf.{h,c} and storage_encryption_conf.{h,c}
and update all callers to match

15 years agoRemove virConnectPtr from all node device XML APIs
Daniel P. Berrange [Wed, 10 Feb 2010 10:40:18 +0000 (10:40 +0000)]
Remove virConnectPtr from all node device XML APIs

The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in node_device_conf.{h,c} and update all callers to
match

15 years agoRemove virConnectPtr from network XML APis
Daniel P. Berrange [Wed, 10 Feb 2010 10:22:52 +0000 (10:22 +0000)]
Remove virConnectPtr from network XML APis

The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in network_conf.{h,c} and update all callers to
match

15 years agoRemove virConnectPtr from USB/PCI device iterators
Daniel P. Berrange [Wed, 10 Feb 2010 09:55:39 +0000 (09:55 +0000)]
Remove virConnectPtr from USB/PCI device iterators

All callers now pass a NULL virConnectPtr into the USB/PCi device
iterator functions. Therefore the virConnectPtr arg can now be
removed from these functions

* src/util/hostusb.h, src/util/hostusb.c: Remove virConnectPtr
  from usbDeviceFileIterate
* src/util/pci.c, src/util/pci.h: Remove virConnectPtr arg from
  pciDeviceFileIterate
* src/qemu/qemu_security_dac.c, src/security/security_selinux.c: Update
  to drop redundant virConnectPtr arg

15 years agoFix generation of floppy disk arg for QEMU's -global arg
Daniel P. Berrange [Wed, 10 Feb 2010 09:22:42 +0000 (09:22 +0000)]
Fix generation of floppy disk arg for QEMU's -global arg

* src/qemu/qemu_conf.c: Fix ',' vs '.' typo in floppy disk arg

15 years agoFix compile error in Xen proxy from virConnectPtr changes
Daniel P. Berrange [Wed, 10 Feb 2010 12:51:08 +0000 (12:51 +0000)]
Fix compile error in Xen proxy from virConnectPtr changes

* proxy/libvirt_proxy.c: Remove 'conn' arg to virDomainDefFormat

15 years agoConvert qemu command line flags to 64-bit int
Daniel P. Berrange [Tue, 9 Feb 2010 13:06:56 +0000 (13:06 +0000)]
Convert qemu command line flags to 64-bit int

The QEMU flags are commonly stored as a signed or unsigned int,
allowing only 31 flags. This limit is rather close, so to aid
future patches, change it to a 64-bit int

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c,
  tests/qemuargv2xmltest.c, tests/qemuhelptest.c, tests/qemuxml2argvtest.c:
  Use 'unsigned long long' for QEMU flags

15 years agoRemove use of virConnectPtr from security driver APIs
Daniel P. Berrange [Tue, 9 Feb 2010 19:18:21 +0000 (19:18 +0000)]
Remove use of virConnectPtr from security driver APIs

The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in security_driver.{h,c} and update all callers to
match

15 years agoRemove virConnectPtr from all domain XML parsing/formatting APIs
Daniel P. Berrange [Tue, 9 Feb 2010 18:58:01 +0000 (18:58 +0000)]
Remove virConnectPtr from all domain XML parsing/formatting APIs

15 years agoRemove virConnectPtr from LXC driver
Daniel P. Berrange [Tue, 9 Feb 2010 18:22:56 +0000 (18:22 +0000)]
Remove virConnectPtr from LXC driver

15 years agoRemove passing of virConnectPtr throughout QEMU driver
Daniel P. Berrange [Tue, 9 Feb 2010 18:15:41 +0000 (18:15 +0000)]
Remove passing of virConnectPtr throughout QEMU driver

15 years agoFix security driver configuration
Daniel P. Berrange [Tue, 9 Feb 2010 13:17:39 +0000 (13:17 +0000)]
Fix security driver configuration

The security driver was mistakenly initialized before the QEMU
config file was loaded. This prevents it being turned off again.
The capabilities XML was also getting the wrong security driver
name, due to the stacked driver arrangement.

* src/qemu/qemu_driver.c: Fix initialization order and capabilities
  model name

15 years agovirAsprintf: remove its warn_unused_result attribute
Jim Meyering [Wed, 10 Feb 2010 11:00:38 +0000 (12:00 +0100)]
virAsprintf: remove its warn_unused_result attribute

* src/util/util.h (virAsprintf): Remove ATTRIBUTE_RETURN_CHECK, since
it is perfectly fine to ignore the return value, now that the pointer
is guaranteed to be set to NULL upon failure.
* src/util/storage_file.c (absolutePathFromBaseFile): Remove now-
unnecessary use of ignore_value.

15 years agoabsolutePathFromBaseFile: avoid an unnecessary use of assert
Jim Meyering [Wed, 10 Feb 2010 10:54:24 +0000 (11:54 +0100)]
absolutePathFromBaseFile: avoid an unnecessary use of assert

* src/util/storage_file.c (absolutePathFromBaseFile): While this use
of virAsprintf is slightly cleaner than using stpncpy(stpcpy(...,
it does impose an artificial limitation on the length of the base_file
name.  Rather than asserting that it does not exceed INT_MAX, return
NULL when it does.

15 years agoEscape strings serialized in XML
Daniel Veillard [Mon, 8 Feb 2010 17:03:43 +0000 (18:03 +0100)]
Escape strings serialized in XML

* src/conf/node_device_conf.c: string saved into XML should be escaped
  with the use of virBufferEscapeString()