]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
15 years agodocs: Emphasize that devices have to be inside the <devices> element
Matthias Bolte [Thu, 4 Feb 2010 14:27:52 +0000 (15:27 +0100)]
docs: Emphasize that devices have to be inside the <devices> element

Also cleanup indentation of domain XML examples.

15 years agovirt-pki-validate contains unexpanded SYSCONFDIR variable
Doug Goldstein [Thu, 4 Feb 2010 15:47:29 +0000 (16:47 +0100)]
virt-pki-validate contains unexpanded SYSCONFDIR variable

* tools/virt-pki-validate.in: use an automake variable instead of a
  shell variable so the resulting shell actually work

15 years agoRelease of libvirt-0.7.6
Daniel Veillard [Wed, 3 Feb 2010 17:16:25 +0000 (18:16 +0100)]
Release of libvirt-0.7.6

* configure.ac docs/news.html.in libvirt.spec.in: version bump and doc
  updates
* po/*.po*: updated and regenerated the localizations

15 years agoFix restore of QEMU guests with PCI device reservation
Daniel P. Berrange [Wed, 3 Feb 2010 16:11:29 +0000 (16:11 +0000)]
Fix restore of QEMU guests with PCI device reservation

When restoring from a saved guest image, the XML would already
contain the PCI slot ID of the IDE controller & video card.
The attempt to explicitly reserve this upfront would thus fail
everytime.

* src/qemu/qemu_conf.c: Reserve IDE controller / video card
  slot at time of need, rather than upfront

15 years agoAnother fork() log locking cleanup in file creation
Laine Stump [Wed, 3 Feb 2010 16:19:39 +0000 (17:19 +0100)]
Another fork() log locking cleanup in file creation

Similar fix as previous one but for fork() usage when creating
a file or directory

* src/util/util.c: virLogLock() and virLogUnlock() around fork()
  in virFileCreate() and virDirCreateSimple()

15 years agoFix log locking problem when using fork() in the library
Cole Robinson [Wed, 3 Feb 2010 16:12:57 +0000 (17:12 +0100)]
Fix log locking problem when using fork() in the library

Ad pointed out by Dan Berrange:
So if some thread in libvirtd is currently executing a logging call,
while another thread calls virExec(), that other thread no longer
exists in the child, but its lock is never released. So when the
child then does virLogReset() it deadlocks.

The only way I see to address this, is for the parent process to call
virLogLock(), immediately before fork(), and then virLogUnlock()
afterwards in both parent & child. This will ensure that no other
thread
can be holding the lock across fork().

* src/util/logging.[ch] src/libvirt_private.syms: export virLogLock() and
  virLogUnlock()
* src/util/util.c: lock just before forking and unlock just after - in
  both parent and child.

15 years agoFix locking for udev device add/remove
David Allan [Wed, 3 Feb 2010 15:56:33 +0000 (16:56 +0100)]
Fix locking for udev device add/remove

The original udev node device backend neglected to lock the driverState
struct containing the device list when adding and removing devices
* src/node_device/node_device_udev.c: add necessary locks in
  udevRemoveOneDevice() and udevAddOneDevice()

15 years agointerface_conf.c: don't use a negative value as allocation size
Jim Meyering [Tue, 2 Feb 2010 19:54:01 +0000 (20:54 +0100)]
interface_conf.c: don't use a negative value as allocation size

* src/conf/interface_conf.c (virInterfaceDefParseProtoIPv4): If
virXPathNodeSet returns -1, indicate failure by returning -1 right away.
(virInterfaceDefParseProtoIPv6): Likewise.

15 years agovirStoragePoolSourceListNewSource: avoid unconditional leak
Jim Meyering [Tue, 2 Feb 2010 18:59:14 +0000 (19:59 +0100)]
virStoragePoolSourceListNewSource: avoid unconditional leak

* src/conf/storage_conf.c (virStoragePoolSourceListNewSource):
Remove an unused (and leaked) allocation.

15 years agoxs_internal.c: don't use a negative value as allocation size
Jim Meyering [Tue, 2 Feb 2010 11:22:17 +0000 (12:22 +0100)]
xs_internal.c: don't use a negative value as allocation size

* src/xen/xs_internal.c (xenStoreDomainIntroduced): Don't use -1
as an allocation size upon xenStoreNumOfDomains failure.
(xenStoreDomainReleased): Likewise.

15 years agoEnsure QEMU DAC security driver is activated at all times
Daniel P. Berrange [Tue, 2 Feb 2010 16:19:20 +0000 (16:19 +0000)]
Ensure QEMU DAC security driver is activated at all times

If the primary security driver (SELinux/AppArmour) was disabled
then the secondary QEMU DAC security driver was also disabled.
This is mistaken, because the latter must be active at all times

* src/qemu/qemu_driver.c: Ensure DAC driver is always active

15 years agoxen_hypervisor.c: remove all "domain == NULL" tests, ...
Jim Meyering [Wed, 27 Jan 2010 12:34:03 +0000 (13:34 +0100)]
xen_hypervisor.c: remove all "domain == NULL" tests, ...

* src/xen/xen_hypervisor.c: Remove all "domain == NULL" tests.
* src/xen/xen_hypervisor.h: Instead, use ATTRIBUTE_NONNULL to
mark each "domain" parameter as "known always to be non-NULL".

15 years agoxen_hypervisor.c: avoid NULL deref for NULL domain argument
Jim Meyering [Tue, 26 Jan 2010 19:17:07 +0000 (20:17 +0100)]
xen_hypervisor.c: avoid NULL deref for NULL domain argument

* src/xen/xen_hypervisor.c (xenHypervisorGetVcpus): Don't attempt
to diagnose an unlikely NULL-domain or NULL-domain->conn error.

15 years agoTweak USB hostdevice XML handling
Daniel P. Berrange [Mon, 1 Feb 2010 17:21:05 +0000 (17:21 +0000)]
Tweak USB hostdevice XML handling

When attaching a USB host device based on vendor/product, libvirt
will resolve the vendor/product into a device/bus pair. This means
that when printing XML we should allow device/bus info to be printed
at any time if present

* src/conf/domain_conf.c, docs/schemas/domain.rng: Allow USB device
  bus info alongside vendor/product

15 years agoFix QEMU hotplug device alias assignment
Daniel P. Berrange [Mon, 1 Feb 2010 16:28:46 +0000 (16:28 +0000)]
Fix QEMU hotplug device alias assignment

To allow devices to be hot(un-)plugged it is neccessary to ensure
they all have a unique device aliases. This fixes the hotplug
methods to assign device aliases before invoking the monitor
commands which need them

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Expose methods
  for assigning device aliases for disks, host devices and
  controllers
* src/qemu/qemu_driver.c: Assign device aliases when hotplugging
  all types of device
* tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.args,
  tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args:
  Update for changed hostdev naming scheme

15 years agoDisable QEMU monitor IO debugging by default
Daniel P. Berrange [Mon, 1 Feb 2010 16:28:27 +0000 (16:28 +0000)]
Disable QEMU monitor IO debugging by default

15 years agoRe-arrange QEMU device alias assignment code
Daniel P. Berrange [Mon, 1 Feb 2010 15:58:38 +0000 (15:58 +0000)]
Re-arrange QEMU device alias assignment code

This patch re-arranges the QEMU device alias assignment code to
make it easier to call into the same codeblock when performing
device hotplug. The new code has the ability to skip over already
assigned names to facilitate hotplug

* src/qemu/qemu_driver.c: Call qemuAssignDeviceNetAlias()
  instead of qemuAssignNetNames
* src/qemu/qemu_conf.h: Export qemuAssignDeviceNetAlias()
  instead of qemuAssignNetNames
* src/qemu/qemu_driver.c: Merge the legacy disk/network alias
  assignment code into the main methods

15 years agoRemove direct storage of hostnet_name & vlan
Daniel P. Berrange [Mon, 1 Feb 2010 15:06:36 +0000 (15:06 +0000)]
Remove direct storage of hostnet_name & vlan

The current way of assigning names to the host network backend and
NIC device in QEMU was over complicated, by varying naming scheme
based on the NIC model and backend type. This simplifies the naming
to simply be 'net0' and 'hostnet0', allowing code to easily determine
the host network name and vlan based off the primary device alias
name 'net0'. This in turn allows removal of alot of QEMU specific
code from the XML parser, and makes it easier to assign new unique
names for NICs that are hotplugged

* src/conf/domain_conf.c, src/conf/domain_conf.h: Remove hostnet_name
  and vlan fields from virNetworkDefPtr
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c:
  Use a single network alias naming scheme regardless of NIC type
  or backend type. Determine VLANs from the alias name.
* tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args,
  tests/qemuxml2argvdata/qemuxml2argv-net-virtio-device.args,
  tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev.args: Update
  for new simpler naming scheme

15 years agoRemove use of -netdev arg with QEMU
Daniel P. Berrange [Fri, 29 Jan 2010 18:07:04 +0000 (18:07 +0000)]
Remove use of -netdev arg with QEMU

The QEMU 0.12.x tree has the -netdev command line argument, but not
corresponding monitor command. We can't enable the former, without
the latter since it will break hotplug/unplug.

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Disable -netdev usage
  until 0.13 at earliest
* tests/qemuxml2argvtest.c: Add test for -netdev syntax
* tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev.args,
  tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev.xml: Test
  data files for -netdev syntax

15 years agoAssign PCI addresses before hotplugging devices
Daniel P. Berrange [Wed, 27 Jan 2010 17:49:19 +0000 (17:49 +0000)]
Assign PCI addresses before hotplugging devices

PCI disk, disk controllers, net devices and host devices need to
have PCI addresses assigned before they are hot-plugged

* src/qemu/qemu_conf.c: Add APIs for ensuring a device has an
  address and releasing unused addresses
* src/qemu/qemu_driver.c: Ensure all devices have addresses
  when hotplugging.

15 years agoRewrite way QEMU PCI addresses are allocated
Daniel P. Berrange [Wed, 27 Jan 2010 17:03:54 +0000 (17:03 +0000)]
Rewrite way QEMU PCI addresses are allocated

The current QEMU code allocates PCI addresses incrementally starting
at 4. This is not satisfactory because the user may have given some
addresses in their XML config, which need to be skipped over when
allocating addresses to remaining devices.

It is thus neccessary to maintain a list of already allocated PCI
addresses and then only allocate ones that remain unused. This is
also required for domain device hotplug to work properly later.

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Add APIs for creating
  list of existing PCI addresses, and allocating new addresses.
  Refactor address assignment to use this code
* src/qemu/qemu_driver.c: Pull PCI address assignment up into the
  qemuStartVMDaemon() method, as a prelude to moving it into the
  'define' method. Update list of allocated addresses when connecting
  to a running VM at daemon startup.
* tests/qemuxml2argvtest.c, tests/qemuargv2xmltest.c,
  tests/qemuxml2xmltest.c: Remove USB product test since all
  passthrough is done based on address
* tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args,
  tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml: Kil
  unused data files

15 years agoIntroduce generic virDomainDeviceInfo iterator function
Daniel P. Berrange [Wed, 27 Jan 2010 15:10:34 +0000 (15:10 +0000)]
Introduce generic virDomainDeviceInfo iterator function

The virDomainDeviceInfoIterate() function will provide a
convenient way to iterate over all devices in a domain.

* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/libvirt_private.syms: Add virDomainDeviceInfoIterate()
  function.

15 years agoMake hotplug use new device_add where possible
Daniel P. Berrange [Tue, 26 Jan 2010 17:40:19 +0000 (17:40 +0000)]
Make hotplug use new device_add where possible

Since QEMU startup uses the new -device argument, the hotplug
code needs todo the same. This converts disk, network and
host device hotplug to use the device_add command

* src/qemu/qemu_driver.c: Use new device_add monitor APIs
  whereever possible

15 years agoIntroduce internal QEMU monitor APIs for drive + device hotadd
Daniel P. Berrange [Tue, 26 Jan 2010 15:34:46 +0000 (15:34 +0000)]
Introduce internal QEMU monitor APIs for drive + device hotadd

The way QEMU is started has been changed to use '-device' and
the new style '-drive' syntax. This needs to be mirrored in
the hotplug code, requiring addition of two new APIs.

* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Define APIs
  qemuMonitorAddDevice() and qemuMonitorAddDrive()
* src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
  Implement the new monitor APIs

15 years agoSplit out QEMU code for building PCI/USB hostdev arg values
Daniel P. Berrange [Tue, 26 Jan 2010 13:44:12 +0000 (13:44 +0000)]
Split out QEMU code for building PCI/USB hostdev arg values

To allow for better code reuse from hotplug methods, the code for
generating PCI/USB hostdev arg values is split out into separate
methods

* qemu/qemu_conf.h, qemu/qemu_conf.c: Introduce new APis for
  qemuBuildPCIHostdevPCIDevStr, qemuBuildUSBHostdevUsbDevStr
  and qemuBuildUSBHostdevDevStr

15 years agoStandard internal API syntax for building QEMU command line arguments
Daniel P. Berrange [Tue, 26 Jan 2010 13:00:18 +0000 (13:00 +0000)]
Standard internal API syntax for building QEMU command line arguments

All the helper functions for building command line arguments
now return a 'char *', instead of acepting a 'char **' or
virBufferPtr argument

* qemu/qemu_conf.c: Standardize syntax for building args
* qemu/qemu_conf.h: Export all functions for building args
* qemu/qemu_driver.c: Update for changed syntax for building
  NIC/hostnet args

15 years agolibvirtd.c: avoid closing a negative socket file descriptor
Jim Meyering [Tue, 2 Feb 2010 10:27:25 +0000 (11:27 +0100)]
libvirtd.c: avoid closing a negative socket file descriptor

* daemon/libvirtd.c (qemudListenUnix): Close socket only if non-negative.

15 years agostorage_backend.c: avoid closing a negative file descriptor
Jim Meyering [Tue, 2 Feb 2010 10:11:49 +0000 (11:11 +0100)]
storage_backend.c: avoid closing a negative file descriptor

* src/storage/storage_backend.c (virStorageBackendRunProgRegex):
Don't close a negative (read-only) file descriptor.

15 years agoavoid a probable EINVAL from lseek
Jim Meyering [Mon, 1 Feb 2010 21:17:44 +0000 (22:17 +0100)]
avoid a probable EINVAL from lseek

* src/qemu/qemu_driver.c (qemudLogReadFD): Don't pass a negative
offset (from a preceding failed attempt to seek to EOF) to this use
of lseek.

15 years agoudev: Don't let strtoul parse USB busnum and devnum as octal
Matthias Bolte [Sat, 30 Jan 2010 23:53:40 +0000 (00:53 +0100)]
udev: Don't let strtoul parse USB busnum and devnum as octal

udevGetUintProperty was called with base set to 0 for busnum and devnum.
With base 0 strtoul parses the number as octal if it start with a 0. But
busnum and devnum are decimal and udev returns them padded with leading
zeros. So strtoul parses them as octal. This works for certain decimal
values like 001-007, but fails for values like 008.

Change udevProcessUSBDevice to use base 10 for busnum and devnum.

15 years agoutil.c (two more): don't use a negative value as allocation size
Jim Meyering [Mon, 1 Feb 2010 20:45:06 +0000 (21:45 +0100)]
util.c (two more): don't use a negative value as allocation size

* src/util/util.c (virGetUserID, virGetGroupID): In the unlikely event
that sysconf(_SC_GETPW_R_SIZE_MAX) fails, don't use -1 as the size in
the subsequent allocation.

15 years agojson.c: avoid an unconditional leak from most qemuMonitorJSON* functions
Jim Meyering [Wed, 27 Jan 2010 08:58:12 +0000 (09:58 +0100)]
json.c: avoid an unconditional leak from most qemuMonitorJSON* functions

* src/util/json.c (virJSONValueFree): Free the "value" pointer, too.

15 years agoavoid format-related warnings
Jim Meyering [Mon, 1 Feb 2010 17:25:23 +0000 (18:25 +0100)]
avoid format-related warnings

* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetAllPCIAddresses):
Use %s.
* src/storage/storage_backend_iscsi.c (virStorageBackendCreateIfaceIQN):
Likewise.
* tools/virsh.c (cmdSecretSetValue): Likewise.

15 years agomaint: avoid excess parens in STREQ
Eric Blake [Wed, 27 Jan 2010 13:59:02 +0000 (06:59 -0700)]
maint: avoid excess parens in STREQ

* src/internal.h (STREQ, STRCASEEQ, STRNEQ, STRCASENEQ, STREQLEN)
(STRCASEEQLEN, STRNEQLEN, STRCASENEQLEN, STRPREFIX): Avoid
redundant parenthesis.
* examples/domain-events/events-c/event-test.c (STREQ): Likewise.
* src/storage/parthelper.c (STREQ): Likewise.

15 years agoMove models/nmodels mismatch checking one level up
Jiri Denemark [Mon, 1 Feb 2010 11:42:27 +0000 (12:42 +0100)]
Move models/nmodels mismatch checking one level up

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
15 years agoLog flags in virConnectCompareCPU
Jiri Denemark [Mon, 1 Feb 2010 15:22:33 +0000 (16:22 +0100)]
Log flags in virConnectCompareCPU

* src/libvirt.c: extend the debug statement to log flags too

15 years agoFix PCI host reattach on domain detach.
Chris Lalancette [Tue, 26 Jan 2010 15:01:23 +0000 (10:01 -0500)]
Fix PCI host reattach on domain detach.

Similar to the race fixed by
be34c3c7efbb1ea8999530f98b99c5dde3793f84, make sure
to wait around for KVM to release the resources from
a hot-detached PCI device before attempting to
rebind that device to the host driver.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoClarify controllers -device string in QEMU driver
Matthew Booth [Mon, 1 Feb 2010 15:08:36 +0000 (16:08 +0100)]
Clarify controllers -device string in QEMU driver

The QEMU driver contained code to generate a -device string for piix4-ide, but
wasn't using it. This change removes this string generation. It also adds a
comment explaining why IDE and FDC controllers don't generate -device strings.

The change also generates an error if a sata controller is specified for a QEMU
domain, as this isn't supported.

* src/qemu/qemu_conf.c: Remove VIR_DOMAIN_CONTROLLER_TYPE_IDE handler in
  qemuBuildControllerDevStr(). Ignore IDE and FDC controllers. Error if
  SATA controller is discovered. Add comments.

15 years agoFix up a comment in virHashUpdateEntry
Chris Lalancette [Sun, 31 Jan 2010 02:27:12 +0000 (21:27 -0500)]
Fix up a comment in virHashUpdateEntry

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoLook in /usr/libexec for the qemu-kvm binary.
Chris Lalancette [Mon, 25 Jan 2010 15:01:15 +0000 (10:01 -0500)]
Look in /usr/libexec for the qemu-kvm binary.

On RHEL-5 the qemu-kvm binary is located in /usr/libexec.
To reduce confusion for people trying to run upstream libvirt
on RHEL-5 machines, make the qemu driver look in /usr/libexec
for the qemu-kvm binary.

To make this work, I modified virFindFileInPath to handle an
absolute path correctly.  I also ran into an issue where
NULL was sometimes being passed for the file parameter
to virFindFileInPath; it didn't crash prior to this patch
since it was building paths like /usr/bin/(null).  This
is non-standard behavior, though, so I added a NULL
check at the beginning.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agomaint: fix spelling error in hacking
Eric Blake [Wed, 27 Jan 2010 13:33:58 +0000 (06:33 -0700)]
maint: fix spelling error in hacking

* HACKING: STRCASEEQ is case insensitive.
* docs/hacking.html.in: Likewise.

15 years agoutil.c (virGetUserEnt): don't use a negative value as allocation size
Jim Meyering [Thu, 28 Jan 2010 12:37:05 +0000 (13:37 +0100)]
util.c (virGetUserEnt): don't use a negative value as allocation size

* src/util/util.c (virGetUserEnt): In the unlikely event that
sysconf(_SC_GETPW_R_SIZE_MAX) fails, don't use -1 as the size in
the subsequent allocation.

15 years agoSupport Xen 4.0 sysctl version 7
Jim Fehlig [Wed, 27 Jan 2010 17:56:18 +0000 (10:56 -0700)]
Support Xen 4.0 sysctl version 7

xen-unstable c/s 20762 bumped XEN_SYSCTL_INTERFACE_VERSION to 7.  The
interface change does not affect libvirt, other than xenHypervisorInit()
failing since version 7 is not tried.

The attached patch accommodates the upcoming Xen 4.0 release by checking
for XEN_SYSCTL_INTERFACE_VERSION 7.  If found, it sets
XEN_DOMCTL_INTERFACE_VERSION to 6, which is also new to Xen 4.0.

15 years agoAdd missing sata controller type to domain.rng
Matthew Booth [Wed, 27 Jan 2010 13:26:49 +0000 (14:26 +0100)]
Add missing sata controller type to domain.rng

* docs/schemas/domain.rng: Add sata controller type

15 years agocpu_x86.c: avoid NULL-deref for invalid arguments
Jim Meyering [Tue, 26 Jan 2010 18:58:48 +0000 (19:58 +0100)]
cpu_x86.c: avoid NULL-deref for invalid arguments

* src/cpu/cpu_x86.c (x86Decode): Do not dereference NULL
when "models" is NULL and nmodels is 1 or greater.

15 years agoportability to non-glibc: don't use realpath(..., NULL)
Jim Meyering [Tue, 26 Jan 2010 16:13:45 +0000 (17:13 +0100)]
portability to non-glibc: don't use realpath(..., NULL)

it causes a NULL-dereference on some systems like Solaris 10.
* src/node_device/node_device_linux_sysfs.c. Include <stdlib.h>.
(get_sriov_function): Use canonicalize_file_name, not realpath.
* bootstrap (modules): Add canonicalize-lgpl.

15 years agopci.c: correct an erroneous expression
Jim Meyering [Tue, 26 Jan 2010 19:36:58 +0000 (20:36 +0100)]
pci.c: correct an erroneous expression

* src/util/pci.c (pciDeviceDownstreamLacksACS): Fix a typo
that rendered a subexpression always false.

15 years agoudev: Set the state driver name
Matthias Bolte [Tue, 26 Jan 2010 02:13:08 +0000 (03:13 +0100)]
udev: Set the state driver name

15 years agoRemove undefined symbols from libvirt_private.syms
Matthias Bolte [Tue, 26 Jan 2010 02:07:18 +0000 (03:07 +0100)]
Remove undefined symbols from libvirt_private.syms

15 years agoudev: Remove event handle on shutdown
Matthias Bolte [Tue, 26 Jan 2010 01:58:37 +0000 (02:58 +0100)]
udev: Remove event handle on shutdown

This fixes a segfault when the event handler is called after shutdown
when the global driver state is NULL again.

Also fix a locking issue in an error path.

15 years agoDon't call disabled timer callbacks in event-test.c
Matthias Bolte [Tue, 26 Jan 2010 01:54:34 +0000 (02:54 +0100)]
Don't call disabled timer callbacks in event-test.c

This fixes a segfault in the remote driver that occurs for example when
the event-test is run inside a domain-0 and libvirtd is also running.

15 years agoesx: Output error details from libcurl
Matthias Bolte [Tue, 26 Jan 2010 01:05:45 +0000 (02:05 +0100)]
esx: Output error details from libcurl

15 years agoAdd missing function parameter documentation
Matthias Bolte [Tue, 26 Jan 2010 00:59:48 +0000 (01:59 +0100)]
Add missing function parameter documentation

15 years agohostusb: closedir only if non-NULL; rename labels: s/error/cleanup/
Jim Meyering [Mon, 25 Jan 2010 15:54:06 +0000 (16:54 +0100)]
hostusb: closedir only if non-NULL; rename labels: s/error/cleanup/

* src/util/hostusb.c (usbSysReadFile): Rename labels s/error/cleanup/
(usbFindBusByVendor): Likewise.  And closedir only if non-NULL.

15 years agoCleanup of large buffer on stack in virFileMakePath
Laine Stump [Tue, 26 Jan 2010 13:47:02 +0000 (14:47 +0100)]
Cleanup of large buffer on stack in virFileMakePath

virFileMakePath is a recursive function that was creates a buffer
PATH_MAX bytes long for each recursion (one recursion for each element
in the path). This changes it to have no buffers on the stack, and to
allocate just one buffer total, no matter how many elements are in the
path. Because the modified algorithm requires a char* to be passed in
rather than const char *, it is now 2 functions - a toplevel API
function that remains identical in function, and a 2nd helper function
called for the recursions, which 1) doesn't allocate anything, and 2)
takes a char* arg, so it can modify the contents.
* src/util/util.c: rewrite virFileMakePath

15 years agoesx: Stop passing around virConnectPtr for error reporting
Matthias Bolte [Fri, 15 Jan 2010 22:05:26 +0000 (23:05 +0100)]
esx: Stop passing around virConnectPtr for error reporting

15 years agoRevert "Fix libvirtd restart for domains with PCI passthrough devices"
Chris Lalancette [Mon, 25 Jan 2010 18:35:05 +0000 (13:35 -0500)]
Revert "Fix libvirtd restart for domains with PCI passthrough devices"

This reverts commit cdc42d0a4865199a941d330dbb6ca1ef426323ae.
As DanB pointed out, this patch is actually wrong.  The real
bug that was causing me to see this problem is a bug
introduced in a RHEL-5 libvirt snapshot, and I'm going to
fix the real bug there.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix a crash when restarting libvirtd.
Chris Lalancette [Mon, 25 Jan 2010 16:13:41 +0000 (11:13 -0500)]
Fix a crash when restarting libvirtd.

If you shutdown libvirtd while a domain with PCI
devices is running, then try to restart libvirtd,
libvirtd will crash.

This happens because qemuUpdateActivePciHostdevs() is calling
pciDeviceListSteal() with a dev of 0x0 (NULL), and then trying
to dereference it.  This patch fixes it up so that
qemuUpdateActivePciHostdevs() steals the devices after first
Get()'ting them, avoiding the crash.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix two instances of misspelled 'pseudo'
Chris Lalancette [Mon, 25 Jan 2010 14:58:40 +0000 (09:58 -0500)]
Fix two instances of misspelled 'pseudo'

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoqemuMonitorTextAttachDrive: avoid two leaks
Jim Meyering [Mon, 25 Jan 2010 19:19:01 +0000 (20:19 +0100)]
qemuMonitorTextAttachDrive: avoid two leaks

* src/qemu/qemu_monitor_text.c (qemuMonitorTextAttachDrive): Most other
failures in this function would "goto cleanup", but one mistakenly
returned directly, skipping the cleanup and resulting in a leak.
In addition, iterating the "try_command" loop would clobber, and
thus leak, the "cmd" allocated on the first iteration,
so be careful to free it in addition to "reply" beforehand.

15 years agoqemu: Search binaries in PATH instead of hardcoding /usr/bin
Matthias Bolte [Tue, 19 Jan 2010 23:24:47 +0000 (00:24 +0100)]
qemu: Search binaries in PATH instead of hardcoding /usr/bin

15 years agoImplement QMP support for extracting CPU thread ID
Daniel P. Berrange [Fri, 22 Jan 2010 14:52:05 +0000 (14:52 +0000)]
Implement QMP support for extracting CPU thread ID

The KVM build of QEMU includs the thread ID of each vCPU in the
'query-cpus' output. This is required for pinning guests to
particular host CPUs

* src/qemu/qemu_monitor_json.c: Extract 'thread_id' from CPU info

15 years agoMisc fixes to QMP monitor support for QEMU
Daniel P. Berrange [Fri, 22 Jan 2010 13:22:53 +0000 (13:22 +0000)]
Misc fixes to QMP monitor support for QEMU

* src/util/json.c, src/util/json.h: Declare returned strings
  to be const
* src/qemu/qemu_monitor.c: Wire up JSON mode for qemuMonitorGetPtyPaths
* src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h: Fix
  const correctness. Add missing error message in the function
  qemuMonitorJSONGetAllPCIAddresses. Add implementation of the
  qemuMonitorGetPtyPaths function calling 'query-chardev'.

15 years agoAdd some missing include files which break build in certain platforms
Daniel P. Berrange [Fri, 22 Jan 2010 13:21:16 +0000 (13:21 +0000)]
Add some missing include files which break build in certain platforms

Two files were using functions from <sys/stat.h> but not including
in. Most of the time they got this automatically via another header,
but certain build flag combinations can reveal the problem

* src/lxc/lxc_container.c, src/node_device/node_device_linux_sysfs.c:
  Add <sys/stat.h>

15 years agoFix setup of compatability serial devices from console device
Daniel P. Berrange [Fri, 22 Jan 2010 13:19:24 +0000 (13:19 +0000)]
Fix setup of compatability serial devices from console device

The <console> tag is supposed to result in addition of a single
<serial> device for HVM guests. The 'targetType' attribute was
missing though causing the compatibility code to add a second
<console> device

* src/conf/domain_conf.c: Set targetType for serial device

15 years agousbGetDevice: don't leak a "usbDevice" buffer on failure path
Jim Meyering [Mon, 25 Jan 2010 15:44:13 +0000 (16:44 +0100)]
usbGetDevice: don't leak a "usbDevice" buffer on failure path

* src/util/hostusb.c (usbGetDevice): Free "dev" when returning NULL.

15 years agoqemuMonitorTextGetMemoryStats: plug a leak on an error path
Jim Meyering [Wed, 20 Jan 2010 17:24:47 +0000 (18:24 +0100)]
qemuMonitorTextGetMemoryStats: plug a leak on an error path

* src/qemu/qemu_monitor_text.c (qemuMonitorCommandWithHandler):
Always free *reply, upon failure.

15 years agousbFindBusByVendor: don't leak a DIR buffer and FD
Jim Meyering [Mon, 25 Jan 2010 15:36:07 +0000 (16:36 +0100)]
usbFindBusByVendor: don't leak a DIR buffer and FD

* src/util/hostusb.c (usbFindBusByVendor): Don't leak a DIR buffer
and file descriptor.

15 years agoStart modernizing configure
Eric Blake [Mon, 25 Jan 2010 15:00:43 +0000 (16:00 +0100)]
Start modernizing configure

* configure.ac: reanmed configura.in, use AC_CONFIG_HEADERS instead of
  AM_CONFIG_HEADER

15 years agoFix libvirtd restart for domains with PCI passthrough devices
Chris Lalancette [Fri, 22 Jan 2010 17:39:15 +0000 (18:39 +0100)]
Fix libvirtd restart for domains with PCI passthrough devices

When libvirtd shuts down, it places a <state/> tag in the XML
state file it writes out for guests with PCI passthrough
devices.  For devices that are attached at bootup time, the
state tag is empty.  However, at libvirtd startup time, it
ignores anything with a <state/> tag in the XML, effectively
hiding the guest.
This patch remove the check for VIR_DOMAIN_XML_INTERNAL_STATUS
when parsing the XML.
* src/conf/domain_conf.c: remove VIR_DOMAIN_XML_INTERNAL_STATUS
  flag check in virDomainHostdevSubsysPciDefParseXML()

15 years agoqemu: Fix race between device rebind and kvm cleanup
Chris Lalancette [Wed, 20 Jan 2010 20:53:59 +0000 (15:53 -0500)]
qemu: Fix race between device rebind and kvm cleanup

Certain hypervisors (like qemu/kvm) map the PCI bar(s) on
the host when doing device passthrough.  This can lead to a race
condition where the hypervisor is still cleaning up the device while
libvirt is trying to re-attach it to the host device driver.  To avoid
this situation, we look through /proc/iomem, and if the hypervisor is
still holding onto the bar (denoted by the string in the matcher variable),
then we can wait around a bit for that to clear up.

v2: Thanks to review by DV, make sure we wait the full timeout per-device

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix device assignment with root devices
Chris Lalancette [Tue, 19 Jan 2010 16:26:54 +0000 (11:26 -0500)]
Fix device assignment with root devices

The patches to add ACS checking to PCI device passthrough
introduced a bug.  With the current code, if you try to
passthrough a device on the root bus (i.e. bus 0), then
it denies the passthrough.  This is because the code in
pciDeviceIsBehindSwitchLackingACS() to check for a parent
device doesn't take into account the possibility of the
root bus.  If we are on the root bus, it means we
legitimately can't find a parent, and it also means that
we don't have to worry about whether ACS is enabled.
Therefore return 0 (indicating we don't lack ACS) from
pciDeviceIsBehindSwitchLackingACS().

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoAdd a rule to check for uses of readlink.
Chris Lalancette [Mon, 21 Dec 2009 19:14:46 +0000 (14:14 -0500)]
Add a rule to check for uses of readlink.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoUse virFileResolveLink instead of readlink in AppArmor
Chris Lalancette [Wed, 20 Jan 2010 21:12:43 +0000 (16:12 -0500)]
Use virFileResolveLink instead of readlink in AppArmor

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix a compile warning in parthelper.c
Chris Lalancette [Thu, 10 Dec 2009 16:53:55 +0000 (17:53 +0100)]
Fix a compile warning in parthelper.c

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoAdd virConnectGetVersion Python API
Taizo ITO [Fri, 22 Jan 2010 10:01:09 +0000 (11:01 +0100)]
Add virConnectGetVersion Python API

adds a new python API call for retrieving the running
hypervisor version used by a connection: virConnectGetVersion

* python/generator.py: skip virConnectGetVersion from autogenerated
* python/libvirt-override-api.xml python/libvirt-override.c: define
  direct native bindings

15 years agoRemove AppArmor compile warnings
Jamie Strandboge [Fri, 22 Jan 2010 09:48:34 +0000 (10:48 +0100)]
Remove AppArmor compile warnings

* src/security/security_apparmor.c: unused variable in
  AppArmorSetSecurityAllLabel and unused parameter in
  AppArmorReleaseSecurityLabel

15 years agoRemove unused PROC_MOUNT_BUF_LEN #define
Chris Lalancette [Fri, 22 Jan 2010 09:25:44 +0000 (10:25 +0100)]
Remove unused PROC_MOUNT_BUF_LEN #define

15 years agoUpdate polish translation and regenerate localizations
Daniel Veillard [Fri, 22 Jan 2010 09:02:16 +0000 (10:02 +0100)]
Update polish translation and regenerate localizations

15 years agoAdd docs about new mailing list
Daniel P. Berrange [Thu, 21 Jan 2010 15:48:11 +0000 (16:48 +0100)]
Add docs about new mailing list

* docs/contact.html.in: Document new users mailing list

15 years agodomMemoryStats / qemu: Fix parsing of unknown stats
Adam Litke [Thu, 21 Jan 2010 15:26:35 +0000 (16:26 +0100)]
domMemoryStats / qemu: Fix parsing of unknown stats

Fix a small problem with the qemu memory stats parsing algorithm.  If qemu
reports a stat that libvirt does not recognize, skip past it so parsing can
continue.  This corrects a potential infinite loop in the parsing code that can
only be triggered if new statistics are added to qemu.

* src/qemu/qemu_monitor_text.c: qemuMonitorParseExtraBalloonInfo add a
  skip for extra ','

15 years agoCorrected log level of WWN path message
David Allan [Thu, 21 Jan 2010 14:55:13 +0000 (15:55 +0100)]
Corrected log level of WWN path message

* src/node_device/node_device_linux_sysfs.c: open_wwn_file() the
  VIR_ERROR resllay should be just a VIR_DEBUG

15 years agoFix an error when looking for devices in syspath
Daniel Veillard [Thu, 21 Jan 2010 14:45:44 +0000 (15:45 +0100)]
Fix an error when looking for devices in syspath

* src/node_device/node_device_udev.c: udevSetupSystemDev() only print the
  error message if lookup failed in both DMI_DEVPATH and DMI_DEVPATH_FALLBACK

15 years agoAllow surrounding whitespace in uuid
Dan Kenigsberg [Thu, 21 Jan 2010 14:28:56 +0000 (15:28 +0100)]
Allow surrounding whitespace in uuid

* src/util/uuid.c: extend virUUIDParse to allow leading and trailing
  spaces in UUIDs

15 years agofix "make distcheck" failure
Jim Meyering [Thu, 21 Jan 2010 14:24:15 +0000 (15:24 +0100)]
fix "make distcheck" failure

* tests/Makefile.am (qemuhelpdata): Add qemu-0.12.1.

15 years agoavoid more format-related warnings
Jim Meyering [Thu, 21 Jan 2010 14:12:12 +0000 (15:12 +0100)]
avoid more format-related warnings

* src/qemu/qemu_conf.c (qemuBuildDriveStr): Use "%s".
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetGuestPCIAddress):
(qemuMonitorJSONGetGuestDriveAddress): Likewise.

15 years agoavoid format-related warnings
Jim Meyering [Thu, 21 Jan 2010 13:39:42 +0000 (14:39 +0100)]
avoid format-related warnings

* src/conf/domain_conf.c (virDomainDeviceInfoParseXML): Use "%s".

15 years agoFix off-by-1 in SCSI drive hotplug
Daniel P. Berrange [Wed, 20 Jan 2010 14:53:30 +0000 (14:53 +0000)]
Fix off-by-1 in SCSI drive hotplug

The loop looking for the controller associated with a SCI drive had
an off by one, causing it to miss the last controller.

* src/qemu/qemu_driver.c: Fix off-by-1 in searching for SCSI
  drive hotplug

15 years agoFix leak in hotplug code in QEMU driver
Daniel P. Berrange [Mon, 18 Jan 2010 18:02:20 +0000 (18:02 +0000)]
Fix leak in hotplug code in QEMU driver

The hotplug code in QEMU was leaking memory because although the
inner device object was being moved into the main virDomainDefPtr
config object, the outer container virDomainDeviceDefPtr was not.

 * src/qemu/qemu_driver.c: Clarify code to show that the inner
   device object is owned by the main domain config upon
   successfull attach.

15 years agoAdd configuration option to turn off dynamic permissions management
Daniel P. Berrange [Wed, 13 Jan 2010 17:41:36 +0000 (17:41 +0000)]
Add configuration option to turn off dynamic permissions management

Add the ability to turn off dynamic management of file permissions
for libvirt guests.

* qemu/libvirtd_qemu.aug: Support 'dynamic_ownership' flag
* qemu/qemu.conf: Document 'dynamic_ownership' flag.
* qemu/qemu_conf.c: Load 'dynamic_ownership' flag
* qemu/test_libvirtd_qemu.aug: Test 'dynamic_ownership' flag

15 years agoFix security driver calls in hotplug cleanup paths
Daniel P. Berrange [Wed, 13 Jan 2010 17:27:19 +0000 (17:27 +0000)]
Fix security driver calls in hotplug cleanup paths

The hotplug code was not correctly invoking the security driver
in error paths. If a hotplug attempt failed, the device would
be left with VM permissions applied, rather than restored to the
original permissions. Also, a CDROM media that is ejected was
not restored to original permissions. Finally there was a bogus
call to set hostdev permissions in the hostdev unplug code

* qemu/qemu_driver.c: Fix security driver usage in hotplug/unplug

15 years agoAdd missing call to re-attach host devices if VM startup fails
Daniel P. Berrange [Wed, 13 Jan 2010 17:09:41 +0000 (17:09 +0000)]
Add missing call to re-attach host devices if VM startup fails

If there is a problem with VM startup, PCI devices may be left
assigned to pci-stub / pci-back. Adding a call to reattach
host devices in the cleanup path is required.

* qemu/qemu_driver.c: qemuDomainReAttachHostDevices() when
  VM startup fails

15 years agoSwitch QEMU driver over to use the DAC security driver
Daniel P. Berrange [Wed, 13 Jan 2010 17:06:57 +0000 (17:06 +0000)]
Switch QEMU driver over to use the DAC security driver

Remove all the QEMU driver calls for setting file ownership and
process uid/gid. Instead wire in the QEMU DAC security driver,
stacking it ontop of the primary SELinux/AppArmour driver.

* qemu/qemu_driver.c: Switch over to new DAC security driver

15 years agoIntroduce a new DAC security driver for QEMU
Daniel P. Berrange [Wed, 13 Jan 2010 16:43:29 +0000 (16:43 +0000)]
Introduce a new DAC security driver for QEMU

This new security driver is responsible for managing UID/GID changes
to the QEMU process, and any files/disks/devices assigned to it.

* qemu/qemu_conf.h: Add flag for disabling automatic file permission
  changes
* qemu/qemu_security_dac.h, qemu/qemu_security_dac.c: New DAC driver
  for QEMU guests
* Makefile.am: Add new files

15 years agoIntroduce a stacked security driver impl for QEMU
Daniel P. Berrange [Wed, 13 Jan 2010 16:26:55 +0000 (16:26 +0000)]
Introduce a stacked security driver impl for QEMU

* qemu/qemu_conf.h: Add securityPrimaryDriver and
  securitySecondaryDriver fields to 'struct qemud_driver'
* Makefile.am: Add new files
* qemu/qemu_security_stacked.c, qemu/qemu_security_stacked.h: A
  simple stacked security driver

15 years agoPull initial disk labelling out into libvirtd instead of exec hook
Daniel P. Berrange [Wed, 13 Jan 2010 16:28:31 +0000 (16:28 +0000)]
Pull initial disk labelling out into libvirtd instead of exec hook

Pulling the disk labelling code out of the exec hook, and into
libvirtd will allow it to access shared state in the daemon. It
will also make debugging & error reporting easier / more reliable.

* qemu/qemu_driver.c: Move initial disk labelling calls up into
  libvirtd. Add cleanup of disk labels upon failure

15 years agoFix leak of allocated security label
Daniel P. Berrange [Wed, 13 Jan 2010 15:30:24 +0000 (15:30 +0000)]
Fix leak of allocated security label

If a VM fails to start, we can't simply free the security label
strings, we must call the domainReleaseSecurityLabel() method
otherwise the reserved 'mcs' level will be leaked in SElinux

* src/qemu/qemu_driver.c: Invoke domainReleaseSecurityLabel()
  when domain fails to start

15 years agoRefactor setup & cleanup of security labels in security driver
Daniel P. Berrange [Mon, 11 Jan 2010 11:04:40 +0000 (11:04 +0000)]
Refactor setup & cleanup of security labels in security driver

The current security driver architecture has the following
split of logic

 * domainGenSecurityLabel

    Allocate the unique label for the domain about to be started

 * domainGetSecurityLabel

    Retrieve the current live security label for a process

 * domainSetSecurityLabel

    Apply the previously allocated label to the current process
    Setup all disk image / device labelling

 * domainRestoreSecurityLabel

    Restore the original disk image / device labelling.
    Release the unique label for the domain

The 'domainSetSecurityLabel' method is special because it runs
in the context of the child process between the fork + exec.

This is require in order to set the process label. It is not
required in order to label disks/devices though. Having the
disk labelling code run in the child process limits what it
can do.

In particularly libvirtd would like to remember the current
disk image label, and only change shared image labels for the
first VM to start. This requires use & update of global state
in the libvirtd daemon, and thus cannot run in the child
process context.

The solution is to split domainSetSecurityLabel into two parts,
one applies process label, and the other handles disk image
labelling. At the same time domainRestoreSecurityLabel is
similarly split, just so that it matches the style. Thus the
previous 4 methods are replaced by the following 6 new methods

 * domainGenSecurityLabel

    Allocate the unique label for the domain about to be started
    No actual change here.

 * domainReleaseSecurityLabel

   Release the unique label for the domain

 * domainGetSecurityProcessLabel

   Retrieve the current live security label for a process
   Merely renamed for clarity.

 * domainSetSecurityProcessLabel

   Apply the previously allocated label to the current process

 * domainRestoreSecurityAllLabel

    Restore the original disk image / device labelling.

 * domainSetSecurityAllLabel

    Setup all disk image / device labelling

The SELinux and AppArmour drivers are then updated to comply with
this new spec. Notice that the AppArmour driver was actually a
little different. It was creating its profile for the disk image
and device labels in the 'domainGenSecurityLabel' method, where as
the SELinux driver did it in 'domainSetSecurityLabel'. With the
new method split, we can have consistency, with both drivers doing
that in the domainSetSecurityAllLabel method.

NB, the AppArmour changes here haven't been compiled so may not
build.

15 years agoMake security drivers responsible for checking dynamic vs static labelling
Daniel P. Berrange [Wed, 13 Jan 2010 14:03:04 +0000 (14:03 +0000)]
Make security drivers responsible for checking dynamic vs static labelling

The QEMU driver is doing 90% of the calls to check for static vs
dynamic labelling. Except it is forgetting todo so in many places,
in particular hotplug is mistakenly assigning disk labels. Move
all this logic into the security drivers themselves, so the HV
drivers don't have to think about it.

* src/security/security_driver.h: Add virDomainObjPtr parameter
  to virSecurityDomainRestoreHostdevLabel and to
  virSecurityDomainRestoreSavedStateLabel
* src/security/security_selinux.c, src/security/security_apparmor.c:
  Add explicit checks for VIR_DOMAIN_SECLABEL_STATIC and skip all
  chcon() code in those cases
* src/qemu/qemu_driver.c: Remove all checks for VIR_DOMAIN_SECLABEL_STATIC
  or VIR_DOMAIN_SECLABEL_DYNAMIC. Add missing checks for possibly NULL
  driver entry points.

15 years agoImplement support for multi IQN
David Allan [Thu, 21 Jan 2010 11:50:52 +0000 (12:50 +0100)]
Implement support for multi IQN

Allows the initiator to use a variety of IQNs rather than just the
system IQN when creating iSCSI pools.
* docs/schemas/storagepool.rng: extends the syntax with <iqn name="..."/>
* src/conf/storage_conf.[ch]: read and stores the iqn name
* src/storage/storage_backend_iscsi.[ch]: implement the IQN selection
  when detected