]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agolibxl: fix double-free of libxl_domain_build_info
Jim Fehlig [Fri, 10 Oct 2014 21:39:46 +0000 (15:39 -0600)]
libxl: fix double-free of libxl_domain_build_info

On error, libxlMakeDomBuildInfo() frees the caller-provided
libxl_domain_build_info struct embedded in libxl_domain_config,
causing a segfault

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f9c13020700 (LWP 40988)]
(gdb) bt
0  0x00007f9c162f95b4 in free () from /lib64/libc.so.6
1  0x00007f9c0d0965ad in libxl_bitmap_dispose () from
   /usr/lib64/libxenlight.so.4.4
2  0x00007f9c0d0a73bf in libxl_domain_build_info_dispose ()
   from /usr/lib64/libxenlight.so.4.4
3  0x00007f9c0d0a7974 in libxl_domain_config_dispose () from
   /usr/lib64/libxenlight.so.4.4
4  0x00007f9c0d2e00c5 in libxlDomainStart (driver=0x7f9c0400e4e0,
   vm=0x7f9c0412b0d0, start_paused=false, restore_fd=-1) at
   libxl/libxl_domain.c:1323
5  0x00007f9c0d2e1d4b in libxlDomainCreateXML (conn=0x7f9c000009a0,...)
   at libxl/libxl_driver.c:660

Remove the call to libxl_domain_build_info_dispose() from
libxlMakeDomBuildInfo().  On error, callers will dispose the
libxl_domain_config object, which in turn disposes the build info.

10 years agolibxl: Support user-specified <emulator>
Jim Fehlig [Fri, 19 Sep 2014 19:03:18 +0000 (13:03 -0600)]
libxl: Support user-specified <emulator>

With the introduction of the libxlDomainGetEmulatorType function,
it is trivial to support a user-specfied <emulator> in the libxl
driver.  This patch is based loosely on David Scott's old patch
to do the same

https://www.redhat.com/archives/libvir-list/2013-April/msg02119.html
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agoSpell TIOCSCTTY right in the error message
Ján Tomko [Thu, 30 Oct 2014 16:13:00 +0000 (17:13 +0100)]
Spell TIOCSCTTY right in the error message

10 years agoReject live update of offloading options
Ján Tomko [Thu, 30 Oct 2014 12:32:00 +0000 (13:32 +0100)]
Reject live update of offloading options

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

10 years agoconf: forbid negative values in virDomainParseScaledValue
Martin Kletzander [Wed, 29 Oct 2014 16:29:40 +0000 (17:29 +0100)]
conf: forbid negative values in virDomainParseScaledValue

It makes sense for none of the callers to have negative value as an
output and, fortunately, if anyone tried defining domain with negative
memory or any other value parsed by virDomainParseScaledValue(), the
resulting value was 0.  That means we can error out during parsing as
it won't break anything.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: Fix memory leak in cmdNetworkDHCPLeases
Luyao Huang [Thu, 30 Oct 2014 02:35:14 +0000 (10:35 +0800)]
virsh: Fix memory leak in cmdNetworkDHCPLeases

After cidr_format is allocated by virAsprintf and used by vshPrintExtra
it needs to be freed.

Fix the following memory leak from valgrind:
 18 bytes in 1 blocks are definitely lost in loss record 41 of 192
    at 0x4C29BBD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x85CE36F: __vasprintf_chk (vasprintf_chk.c:80)
    by 0x4EE52D5: UnknownInlinedFun (stdio2.h:210)
    by 0x4EE52D5: virVasprintfInternal (virstring.c:459)
    by 0x4EE53CA: virAsprintfInternal (virstring.c:480)
    by 0x14FE96: cmdNetworkDHCPLeases (virsh-network.c:1378)
    by 0x13006B: vshCommandRun (virsh.c:1915)
    by 0x12A9E1: main (virsh.c:3699)

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agovirutil: fix virGetSCSIHostNumber stub return type
Roman Bogorodskiy [Wed, 29 Oct 2014 18:20:48 +0000 (21:20 +0300)]
virutil: fix virGetSCSIHostNumber stub return type

The virGetSCSIHostNumber function return type is int, however
its stubbed version returns NULL. That results in a build fail
on systems that use the stubbed version. Fix by using a proper
return type.

10 years agovirnetdev: stub virNetDev{Add,Del}Multi on FreeBSD
Roman Bogorodskiy [Wed, 29 Oct 2014 18:20:47 +0000 (21:20 +0300)]
virnetdev: stub virNetDev{Add,Del}Multi on FreeBSD

Currently, build fails on FreeBSD because its struct ifreq does not
have ifr_hwaddr member. In order to fix that, check if this member
is present, otherwise fall back to the stub version of the
virNetDev{Add,Del}Multi functions.

10 years agovirnetdev: Resolve Coverity RESOURCE_LEAK
John Ferlan [Wed, 29 Oct 2014 22:29:43 +0000 (18:29 -0400)]
virnetdev: Resolve Coverity RESOURCE_LEAK

virFileReadAll returns a chunk of memory that needs to be free'd when
done

10 years agovirnetdev: Resolve Coverity FORWARD_NULL
John Ferlan [Wed, 29 Oct 2014 22:21:17 +0000 (18:21 -0400)]
virnetdev: Resolve Coverity FORWARD_NULL

The complaint is that if cleanup is called when virFileReadAll fails,
then mcast->entries is NULL and could be dereferenced in the clear
function. After following the code some - I saw that the caller to
the function (virNetDevGetMulticastTable) will also call
virNetDevMcastListClear if this function returns -1, so this
isn't necessary, so I removed the call.

10 years agovirnetdev: Resolve Coverity DEADCODE
John Ferlan [Wed, 29 Oct 2014 20:57:58 +0000 (16:57 -0400)]
virnetdev: Resolve Coverity DEADCODE

Coverity complains that because the for loop is from 0 to 5 (max tokens)
and the impending switch/case statements used each of the #define values
that the 'default' wouldn't reachable. This patch will convert the #define's
into enum's and add the obligatory dead_error_begin marker for these type
situations.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoTeach virt-aa-helper to use TEMPLATE.qemu if the domain is kvm or kqemu
Cédric Bosdonnat [Tue, 28 Oct 2014 20:42:34 +0000 (14:42 -0600)]
Teach virt-aa-helper to use TEMPLATE.qemu if the domain is kvm or kqemu

10 years agoqemu: better error message when block job can't succeed
Eric Blake [Fri, 24 Oct 2014 20:49:13 +0000 (14:49 -0600)]
qemu: better error message when block job can't succeed

https://bugzilla.redhat.com/show_bug.cgi?id=1140981 reports that
the qemu-kvm shipped as part of RHEL 7.0 intentionally[1] cripples
block jobs by removing the 'block-stream' QMP command, while still
leaving 'block-job-cancel' as an unusable no-op.  Meanwhile, we
already had existing code that checked whether block jobs were
completely missing (such as qemu 0.15), old style (cancel is
synchronous, and all commands spelled with '_'), or new style
(cancel is asynchronous, and all commands spelled with '-'), and
used that three-way probe to give decent error messages.  At the
time that code was added, all existing qemu versions fell in one
of three buckets, and the code was using the presence of
'block-job-cancel' as the witness of which of the three buckets.
But now that RHEL qemu has shipped with intentionally crippled
'block-stream', we have a fourth bucket, which results in ugly
error messages when trying 'virsh blockpull':

 error: Requested operation is not valid: Command 'block-stream' is not found

In reality, the fourth bucket should be treated the same as the
first bucket (no block job support); we can do that by realizing
that no existing build of qemu has working block-stream while
lacking block-job-cancel, so it is easiest to change our witness
to the command that starts a job rather than ends one.  We still
act correctly regarding command spelling and whether cancel is
asynchronous.  And on crippled RHEL builds, we now get the desired:

 error: unsupported configuration: block jobs not supported with this qemu binary

[1] The intentional cripple is limited to qemu-kvm of RHEL; when using
qemu-kvm-rhev of RHEV, block job functionality is supported.  Don't ask
me to explain the "why" behind it all - I'm just dealing with fallout
from someone else's decision.

* src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC): Tweak comment.
* src/qemu/qemu_capabilities.c (virQEMUCapsCommands): Look for stream
rather than cancel when determining the flavor of block jobs supported.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agotest: Add test to verify helpers used for backing file name parsing
Peter Krempa [Wed, 29 Oct 2014 10:01:48 +0000 (11:01 +0100)]
test: Add test to verify helpers used for backing file name parsing

Add two test cases to verify that the helpers split and parse the
backing store components properly.

10 years agostorage: Fix crash when parsing backing store URI with schema
Peter Krempa [Wed, 29 Oct 2014 09:55:23 +0000 (10:55 +0100)]
storage: Fix crash when parsing backing store URI with schema

The code that parses the schema from the URI touches the "hosts[0]"
member of the storage file source structure in case the URI contains a
schema. The hosts array was not yet allocated at the point in the code
where the transport protocol was parsed and set. This lead to a crash of
libvirtd.

Fix the code by allocating the "hosts" array upfront and add a test case
to verify this scenario. (Unfortunately this requires shuffling the test
case numbers too).

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

10 years agomaint: add syntax check to prohibit static zero init
Eric Blake [Tue, 28 Oct 2014 18:22:03 +0000 (12:22 -0600)]
maint: add syntax check to prohibit static zero init

Now that all offenders have been cleaned, turn on a syntax-check
rule to prevent future offenders.

* cfg.mk (sc_prohibit_static_zero_init): New rule.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Avoid false
positive.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: avoid static zero init in drivers
Eric Blake [Tue, 28 Oct 2014 18:38:04 +0000 (12:38 -0600)]
maint: avoid static zero init in drivers

C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* src/libxl/libxl_driver.c: Fix initialization.
* src/lxc/lxc_controller.c: Likewise.
* src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
* src/phyp/phyp_driver.c: Likewise.
* src/remote/remote_driver.c: Likewise.
* src/test/test_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/vbox/vbox_XPCOMCGlue.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_driver.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: avoid static zero init in helpers
Eric Blake [Tue, 28 Oct 2014 20:17:04 +0000 (14:17 -0600)]
maint: avoid static zero init in helpers

C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* src/conf/nwfilter_conf.c: Fix initialization.
* src/cpu/cpu_x86.c: Likewise.
* src/interface/interface_backend_netcf.c: Likewise.
* src/locking/lock_daemon.c: Likewise.
* src/locking/lock_driver_lockd.c: Likewise.
* src/locking/lock_driver_sanlock.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/node_device/node_device_udev.c: Likewise.
* src/nwfilter/nwfilter_learnipaddr.c: Likewise.
* src/rpc/virnetserver.c: Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxGenSecurityLabel): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: avoid static zero init in tests
Eric Blake [Tue, 28 Oct 2014 18:38:04 +0000 (12:38 -0600)]
maint: avoid static zero init in tests

C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* tests/eventtest.c: Fix initialization.
* tests/testutils.c: Likewise.
* tests/virhostdevtest.c: Likewise.
* tests/virportallocatortest.c: Likewise.
* tests/virscsitest.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: avoid static zero init in tools
Eric Blake [Tue, 28 Oct 2014 18:38:04 +0000 (12:38 -0600)]
maint: avoid static zero init in tools

C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* tools/virsh-console.c (got_signal): Drop unused variable.
* tools/virsh-domain.c: Fix initialization.
* tools/virsh.c: Likewise.
* tools/virt-host-validate-common.c (virHostMsgWantEscape):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: avoid static zero init in core files
Eric Blake [Tue, 28 Oct 2014 18:38:04 +0000 (12:38 -0600)]
maint: avoid static zero init in core files

C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* src/libvirt.c: Fix initialization.
* src/util/viralloc.c: Likewise.
* src/util/virdbus.c: Likewise.
* src/util/virevent.c: Likewise.
* src/util/virfile.c (safezero): Likewise.
* src/util/virlog.c: Likewise.
* src/util/virnetlink.c: Likewise.
* src/util/virthread.h (VIR_ONCE_GLOBAL_INIT): Likewise.
* src/util/virprocess.c (virProcessGetStartTime): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoaudit: use bool for audit log choice
Eric Blake [Tue, 28 Oct 2014 19:07:09 +0000 (13:07 -0600)]
audit: use bool for audit log choice

We weren't ever using the value for anything other than being non-zero.

* src/util/viraudit.h (virAuditLog): Change signature.
* src/util/viraudit.c (virAuditLog): Update user.
* daemon/libvirtd.c (main): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agosrc/Makefile.am: Add forgotten backslash
Michal Privoznik [Wed, 29 Oct 2014 03:32:43 +0000 (04:32 +0100)]
src/Makefile.am: Add forgotten backslash

As I've pushed 5892944f I haven't noticed one small nitpick.
There was this backslash missing on the line 1231 in the
enumeration of libraries to be added to vbox storage driver. This
resulted in nondeterministic build which sometimes succeeded and
sometimes failed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostorage_conf: Resolve libvirtd crash matching scsi_host
John Ferlan [Tue, 30 Sep 2014 19:28:20 +0000 (15:28 -0400)]
storage_conf: Resolve libvirtd crash matching scsi_host

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

Resolve a crash in libvirtd resulting from commit id 'a4bd62ad' (1.0.6)
which added parentaddr and unique_id to allow unique identification of
a scsi_host, but assumed that all the pool entries and the incoming
definition would be similarly defined. If the existing pool uses the
'name' attribute and an incoming pool is using the parentaddr/unique_id,
then the code will attempt to compare the existing name string against
the incoming name string which doesn't exist (is NULL) and results in
a core (STREQ).

Conversely, if the existing pool used the parentaddr/unique_id and the
to be defined pool used the name, then the comparison would be against
the parentaddr, but since the incoming pool doesn't have one - that would
leave the comparison against a parentaddr of all 0's and a unique_id of 0,
which will always comparison to fail. This means someone could define the
same source adapter for two pools

In order to resolve this, adjust the code to get the 'host#' to be used
by the storage scsi backend in order to check/start the pool and make sure
the incoming definition doesn't match any of the existing pool defs.

10 years agovirutil: Introduce virGetSCSIHostNameByParentaddr
John Ferlan [Mon, 6 Oct 2014 20:18:23 +0000 (16:18 -0400)]
virutil: Introduce virGetSCSIHostNameByParentaddr

Create the function from the code in getAdapterName() in order to return
the "host#" name for the provided parentaddr values.

10 years agovirutil: Introduce virGetSCSIHostNumber
John Ferlan [Mon, 6 Oct 2014 18:18:11 +0000 (14:18 -0400)]
virutil: Introduce virGetSCSIHostNumber

Create/use virGetSCSIHostNumber to replace the static getHostNumber

Removed the "if (result &&" since result is now required to be non NULL
on input.

10 years agoqemu-attach: Assign device aliases
John Ferlan [Wed, 8 Oct 2014 22:52:26 +0000 (18:52 -0400)]
qemu-attach: Assign device aliases

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

As part of attach processing, assign the device aliases by calling
qemuAssignDeviceAliases during qemuDomainQemuAttach once all the devices
are found after the qemuParseCommandLinePid processing.

This will alleviate a symptom that caused a libvirtd crash during an
attempted device detach.

10 years agohotplug: Check for alias in net detach
John Ferlan [Wed, 8 Oct 2014 22:55:43 +0000 (18:55 -0400)]
hotplug: Check for alias in net detach

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

If the QEMU_CAPS_DEVICE is set, then ensure the host device alias has
been properly set before making the calls to detach the device

10 years agohotplug: Check for alias in chrdev detach
John Ferlan [Wed, 8 Oct 2014 22:48:48 +0000 (18:48 -0400)]
hotplug: Check for alias in chrdev detach

If the QEMU_CAPS_DEVICE is set, then ensure the chr device alias has
been properly set before making the calls to detach the device

10 years agohotplug: Check for alias in hostdev detach
John Ferlan [Wed, 8 Oct 2014 22:45:39 +0000 (18:45 -0400)]
hotplug: Check for alias in hostdev detach

If the QEMU_CAPS_DEVICE is set, then ensure the host device alias has
been properly set before making the calls to detach the device

10 years agohotplug: Check for alias in disk detach
John Ferlan [Wed, 8 Oct 2014 21:59:52 +0000 (17:59 -0400)]
hotplug: Check for alias in disk detach

If the QEMU_CAPS_DEVICE is set, then ensure the disk device alias has
been properly set in prior to making the calls to detach the device.

10 years agohotplug: Check for alias in controller detach
John Ferlan [Wed, 8 Oct 2014 21:51:19 +0000 (17:51 -0400)]
hotplug: Check for alias in controller detach

In qemuDomainDetachControllerDevice if the info.alias already exists
a call to qemuAssignDeviceControllerAlias would overwrite the existing
so avoid this possibility.

10 years agovirsh: Adjust the text in man page regarding qemu-attach
John Ferlan [Wed, 8 Oct 2014 22:54:10 +0000 (18:54 -0400)]
virsh: Adjust the text in man page regarding qemu-attach

Slight adjustment to the qemu-attach man page to note device hotplug
and hot unplug may not work and that the environment should be considered
read-only

10 years agoremote: fix jump depends on uninitialised value
Jincheng Miao [Fri, 24 Oct 2014 04:03:13 +0000 (12:03 +0800)]
remote: fix jump depends on uninitialised value

Currently remote driver only initializes partial fields of
remote_connect_get_all_domain_stats_args. But xdr_array()
will check the uninitialised field 'doms_val'.
For safty reason, memset all fields of args is better.

Fix the following error from valgrind, like:
==30515== 1 errors in context 1 of 3:
==30515== Conditional jump or move depends on uninitialised value(s)
==30515==    at 0x85E9402: xdr_array (xdr_array.c:88)
==30515==    by 0x4FD8FC9: xdr_remote_connect_get_all_domain_stats_args (remote_protocol.c:6473)
==30515==    by 0x4FE72F2: virNetMessageEncodePayload (virnetmessage.c:350)
==30515==    by 0x4FDD21C: virNetClientProgramCall (virnetclientprogram.c:326)
==30515==    by 0x4FB4D01: callFull.isra.2 (remote_driver.c:6667)
==30515==    by 0x4FCBD45: call (remote_driver.c:6689)
==30515==    by 0x4FCBD45: remoteConnectGetAllDomainStats (remote_driver.c:7793)
==30515==    by 0x4FA0E75: virConnectGetAllDomainStats (libvirt.c:21678)
==30515==    by 0x147FD1: cmdDomstats (virsh-domain-monitor.c:2148)
==30515==    by 0x13006B: vshCommandRun (virsh.c:1915)
==30515==    by 0x12A9E1: main (virsh.c:3699)

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
10 years agovbox: Remove unused things in vbox_tmpl.c
Taowei Luo [Fri, 24 Oct 2014 01:46:53 +0000 (09:46 +0800)]
vbox: Remove unused things in vbox_tmpl.c

After rewriting the whole driver, Only version specified code is
remained in vbox_tmpl.c. So, this patch removes those unused macros
header files in vbox_tmpl.c.

10 years agovbox: New storage driver
Taowei Luo [Fri, 24 Oct 2014 01:46:52 +0000 (09:46 +0800)]
vbox: New storage driver

This patch provides the new stroage driver for vbox. The work
is similar with patch 87dea4fc and the next b4022de33.

10 years agovbox: Rewrite vboxStorageVolGetPath
Taowei Luo [Fri, 24 Oct 2014 01:46:51 +0000 (09:46 +0800)]
vbox: Rewrite vboxStorageVolGetPath

10 years agovbox: Rewrite vboxStorageVolGetXMLDesc
Taowei Luo [Fri, 24 Oct 2014 01:46:50 +0000 (09:46 +0800)]
vbox: Rewrite vboxStorageVolGetXMLDesc

10 years agovbox: Rewrite vboxStorageVolGetInfo
Taowei Luo [Fri, 24 Oct 2014 01:46:49 +0000 (09:46 +0800)]
vbox: Rewrite vboxStorageVolGetInfo

10 years agovbox: Rewrite vboxStorageVolDelete
Taowei Luo [Fri, 24 Oct 2014 01:46:48 +0000 (09:46 +0800)]
vbox: Rewrite vboxStorageVolDelete

The API on IHardDiskAttachment is merged into IMediumAttachment.
So, we don't need it anymore.

10 years agovbox: Make IMediumAttachment work with vbox2.2 and 3.0
Taowei Luo [Fri, 24 Oct 2014 01:46:47 +0000 (09:46 +0800)]
vbox: Make IMediumAttachment work with vbox2.2 and 3.0

The GetMedium will always return a IHardDisk object them.
In 2.2 and 3.0, it is what GetHardDisk exactly do. In 3.1 and later,
The IMedium is same as IHardDisk.

10 years agovbox: Rewrite vboxStorageVolCreateXML
Taowei Luo [Fri, 24 Oct 2014 01:46:46 +0000 (09:46 +0800)]
vbox: Rewrite vboxStorageVolCreateXML

If the <path> in target element is not given, libvirt will put the
new volume in ~/.VirtualBox by default.

10 years agovbox: Make CreateHardDisk support all vbox versions
Taowei Luo [Fri, 24 Oct 2014 01:46:45 +0000 (09:46 +0800)]
vbox: Make CreateHardDisk support all vbox versions

The CreateHardDiskMedium only support create HardDisk for medium
type, and it only works when vbox version >= 3.1. This patch make
the function workable with all vbox versions and rename it as
CreateHardDisk.

In vbox 2.2 and 3.0 this function will create a IHardDisk object.
In vbox later than 3.0, this function will create a IMedium object.

10 years agovbox: Rewrite vboxStorageVolLookupByPath
Taowei Luo [Fri, 24 Oct 2014 01:46:44 +0000 (09:46 +0800)]
vbox: Rewrite vboxStorageVolLookupByPath

10 years agovbox: Make FindMedium support old vbox versions
Taowei Luo [Fri, 24 Oct 2014 01:46:43 +0000 (09:46 +0800)]
vbox: Make FindMedium support old vbox versions

In old version, function FindMedium in UIVirtualBox doesn't work
for vbox2.2 and 3.0. We assume it will not be used when vbox in
these versions.

But when rewriting vboxStorageVolLookupByPath, we found it was
compatibe to use FindMedium to get a IHardDisk object, even in
vbox old versions. To achieve this, first make FindMedium call
FindHardDisk when VBOX_API_VERSION < 4000000.
Then change the argument type **IMedium to **IHardDisk. (As the
rules in heriachy, we can't transfer a IHardDisk to match
IMedium in output)

In vbox 2.2 and 3.0, the caller must be aware that they will get
a IHardDisk object in return.

10 years agovbox: Rewrite vboxStorageVolLookupByKey
Taowei Luo [Fri, 24 Oct 2014 01:46:42 +0000 (09:46 +0800)]
vbox: Rewrite vboxStorageVolLookupByKey

10 years agovbox: Rewrite vboxStorageVolLookupByName
Taowei Luo [Fri, 24 Oct 2014 01:46:41 +0000 (09:46 +0800)]
vbox: Rewrite vboxStorageVolLookupByName

10 years agovbox: Rewrite vboxStoragePoolListVolumes
Taowei Luo [Fri, 24 Oct 2014 01:46:40 +0000 (09:46 +0800)]
vbox: Rewrite vboxStoragePoolListVolumes

10 years agovbox: Rewrite vboxStoragePoolNumOfVolumes
Taowei Luo [Fri, 24 Oct 2014 01:46:39 +0000 (09:46 +0800)]
vbox: Rewrite vboxStoragePoolNumOfVolumes

We use typedef IMedium IHardDisk to make IHardDisk hierachy from
IMedium (Actually it did on vbox 2.2 and 3.0's C++ API).
So when calling
    VBOX_MEDIUM_FUNC_ARG*(IHardDisk, func, args)
we can directly replace it to
    gVBoxAPI.UIMedium.func(IHardDisk, args)

When dealing with this two types, we get some rules from it's
hierachy relationship.

When using IHardDisk and IMedium as input, we can't transfer a
IMedium to IHardDisk. Like:
    gVBoxAPI.UIHardDisk.func(IHardDisk *hardDisk, args)
    Here, we can't put a *IMedium as a argument.

When using IHardDisk and IMedium as output, we can't transfer a
IHardDisk to IMedium. Like:
    gVBoxAPI.UIMachine.GetMedium(IMedium **out)
    Here, we can't put a **IHardDisk as a argument. If this case
    do happen, we either change the API to GetHardDisk or write a
    new one.

10 years agovbox: Rewrite vbox-independent functions
Taowei Luo [Fri, 24 Oct 2014 01:46:38 +0000 (09:46 +0800)]
vbox: Rewrite vbox-independent functions

This patch rewrites the following functions
    *vboxStorageOpen
    *vboxStorageClose
    *vboxConnectNumOfStoragePools
    *vboxConnectListStoragePools
    *vboxStoragePoolLookupByName

These functions do not call any vbox API, so I directly move it
from vbox_tmpl.c to vbox_storage.c

A small improvement is made on vboxConnectListStoragePools.
The if condition nnames == 1 is modified to nnames > 0. So if the
caller put more than one slot to get active storage pools, the new
function will return exactly one, while the old one would only
return 0.

10 years agovbox: move common codes to vbox_common.h
Taowei Luo [Fri, 24 Oct 2014 01:46:37 +0000 (09:46 +0800)]
vbox: move common codes to vbox_common.h

There are lots of macro declarations in vbox_common.c,
vbox_network.c, and the coming vbox_storage.c which simply the API
calling. Since they are totally the same. We shouldn't keep three
copies of that, so they are moved to vbox_common.h.

Note: The macros are quite different from those in vbox_tmpl.c,
      because they are using different API.

10 years agovbox: Remove VBOX_OBJECT_CHECK macro
Taowei Luo [Fri, 24 Oct 2014 01:46:36 +0000 (09:46 +0800)]
vbox: Remove VBOX_OBJECT_CHECK macro

We should follow the rules that CHECK macro only do checking works.
But this VBOX_OBJECT_CHECK and VBOX_OBJECT_HOST_CHECK declared some
varibles at the same time, which broke the rule. So the patch
removed this macros and dispatched it in source code.

The storage driver is still not rewriten at this point. So, I
remains the VBOX_OBJECT_CHECK macro in vbox_tmpl.c. But this will
finally be removed in patch 'vbox: Remove unused things in vbox_tmpl.c'

10 years agovbox: Fix copyright mistake
Taowei Luo [Fri, 24 Oct 2014 01:46:35 +0000 (09:46 +0800)]
vbox: Fix copyright mistake

I made a mistake on copyright in patch 7f0f415b87.

If I copied codes from one file to another, I should copy the
copyright announcement as well. So this patch makes up the
copyright which I should have added in the previous patch.

10 years agovirsh: Improve the job type reported of virsh cmd blockcommit
Shanzhi Yu [Thu, 23 Oct 2014 10:13:15 +0000 (18:13 +0800)]
virsh: Improve the job type reported of virsh cmd blockcommit

When starting an active block commit job in virsh, it will report
"Block Commit started", but for more precise message it could
report "Active Block Commit started".

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoRenamed internal __mon_yday into mon_yday to avoid conflicts
Cédric Bosdonnat [Thu, 18 Sep 2014 21:23:11 +0000 (23:23 +0200)]
Renamed internal __mon_yday into mon_yday to avoid conflicts

libc has another constant with the same name, which leads to
redefinition error when building against static libvirt

10 years agoqemu_agent: Produce more readable error messages
Michal Privoznik [Tue, 28 Oct 2014 02:41:27 +0000 (03:41 +0100)]
qemu_agent: Produce more readable error messages

Not every error message from qemu-ga has to have the 'class' field
filled out. For instance, I've seen this error message lately:

  qemuAgentCheckError:1047 : unable to execute QEMU agent command \
  {"execute":"guest-set-time"}: \
  {"error":{"desc":"Invalid parameter type, expected: integer"}}

However, this got translated into rather generic error message:

  internal error: unable to execute QEMU agent command
  'guest-set-time': unknown QEMU command error

So we've dropped better error message in favor of a generic one.
This is due to our code which expects 'class' which is not
present here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: change macvtap multicast list in response to NIC_RX_FILTER_CHANGED
Tony Krowiak [Fri, 10 Oct 2014 17:55:43 +0000 (13:55 -0400)]
qemu: change macvtap multicast list in response to NIC_RX_FILTER_CHANGED

This patch adds functionality to processNicRxFilterChangedEvent().
The old and new multicast lists are compared and the filters in
the macvtap are programmed to match the guest's filters.

Signed-off-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
10 years agoutil: Functions to update host network device's multicast filter
Tony Krowiak [Fri, 10 Oct 2014 17:55:42 +0000 (13:55 -0400)]
util: Functions to update host network device's multicast filter

This patch provides the utility functions to needed to synchronize the
changes made to a guest domain network device's multicast filter
with the corresponding macvtap device's filter on the host:

* Get/add/remove multicast MAC addresses
* Get the macvtap device's RX filter list

Signed-off-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
Signed-off-by: Laine Stump <laine@laine.org>
10 years agoqemu: forbid snapshot-delete --children-only on external snapshot
Eric Blake [Mon, 27 Oct 2014 11:37:34 +0000 (05:37 -0600)]
qemu: forbid snapshot-delete --children-only on external snapshot

https://bugzilla.redhat.com/show_bug.cgi?id=956506 documents that
given a domain where an internal snapshot parent has an external
snapshot child, we lacked a safety check when trying to use the
--children-only option to snapshot-delete:

$ virsh start dom
$ virsh snapshot-create-as dom internal
$ virsh snapshot-create-as dom external --disk-only
$ virsh snapshot-delete dom external
error: Failed to delete snapshot external
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
$ virsh snapshot-delete dom internal --children
error: Failed to delete snapshot internal
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
$ virsh snapshot-delete dom internal --children-only
Domain snapshot internal children deleted

While I'd still like to see patches that actually do proper external
snapshot deletion, we should at least fix the inconsistency in the
meantime.  With this patch:

$ virsh snapshot-delete dom internal --children-only
error: Failed to delete snapshot internal
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet

* src/qemu/qemu_driver.c (qemuDomainSnapshotDelete): Fix condition.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoutil: eliminate "use after free" in callers of virNetDevLinkDump
Laine Stump [Wed, 15 Oct 2014 22:49:01 +0000 (00:49 +0200)]
util: eliminate "use after free" in callers of virNetDevLinkDump

virNetDevLinkDump() gets a message from netlink into "resp", then
calls nlmsg_parse() to fill the table "tb" with pointers into resp. It
then returns tb to its caller, but not before freeing the buffer at
resp. That means that all the callers of virNetDevLinkDump() are
examining memory that has already been freed. This can be verified by
filling the buffer at resp with garbage prior to freeing it (or, I
suppose, just running libvirtd under valgrind) then performing some
operation that calls virNetDevLinkDump().

The code has been like this ever since virNetDevLinkDump() was written
- the original author didn't notice it, and neither did later
additional users of the function. It has only been pure luck (or maybe
a lack of heavy load, and/or maybe an allocation algorithm in malloc()
that delays re-use of just-freed memory) that has kept this from
causing errors, for example when configuring a PCI passthrough or
macvtap passthrough network interface.

The solution taken in this patch is the simplest - just return resp to
the caller along with tb, then have the caller free it after they are
finished using the data (pointers) in tb. I alternately could have
made a cleaner interface by creating a new struct that put tb and resp
together along with a vir*Free() function for it, but this function is
only used in a couple places, and I'm not sure there will be
additional new uses of virNetDevLinkDump(), so the value of adding a
new type, extra APIs, etc. is dubious.

10 years agotests: Add SELINUX_LIBS to fix viridentitytest linker bug
Julio Faracco [Fri, 24 Oct 2014 12:33:52 +0000 (10:33 -0200)]
tests: Add SELINUX_LIBS to fix viridentitytest linker bug

In a clean build system (Ubuntu 14.04), the viridentitytest failed to compile.
Even if all the SELINUX libraries and depedencies are installed. See the error
message below:

[...]
  CC       viridentitytest.o
  CCLD     viridentitytest
/usr/bin/ld: viridentitytest.o: undefined reference to symbol
                                                       'security_disable'
//lib/x86_64-linux-gnu/libselinux.so.1: error adding symbols: DSO missing
                                                           from command line
collect2: error: ld returned 1 exit status
make: *** [viridentitytest] Error 1

Simply adding the variable SELINUX_LIBS in viridentitytest rules of
Makefile.am to include SELINUX libraries into viridentitytest solved that
compilation issue.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovbox: network: make sure driver is not NULL in virRegisterNetworkDriver
Shanzhi Yu [Fri, 24 Oct 2014 09:31:43 +0000 (17:31 +0800)]
vbox: network: make sure driver is not NULL in virRegisterNetworkDriver

libvirtd will report below error if it does not make sure driver was not NULL
in virRegisterNetworkDriver

$ libvirtd
2014-10-24 09:24:36.443+0000: 28876: info : libvirt version: 1.2.10
2014-10-24 09:24:36.443+0000: 28876: error : virRegisterNetworkDriver:549 : driver in virRegisterNetworkDriver must not be NULL
2014-10-24 09:24:36.443+0000: 28876: error : virDriverLoadModule:99 : Failed module registration vboxNetworkRegister

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoAdd new driver-*.h files to DRIVER_SOURCES
Daniel P. Berrange [Fri, 24 Oct 2014 16:39:48 +0000 (17:39 +0100)]
Add new driver-*.h files to DRIVER_SOURCES

The recently added driver-*.h files were not listed in the
Makefile.am causing them to be missed when creating dists.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoFix indentation of sysinfo data
Daniel P. Berrange [Thu, 23 Oct 2014 17:35:57 +0000 (18:35 +0100)]
Fix indentation of sysinfo data

The <sysinfo> data block was indented by 2 spaces too many.
This was missed because we never had any test validating
the XML formatting.

10 years agoFix preprocessor indentation in libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 12:54:31 +0000 (13:54 +0100)]
Fix preprocessor indentation in libvirt.h.in

The cfg.mk rule for checking preprocessor indentation was
mistakenly missing the libvirt.h.in file due to bad file
extension matching rule. Fix that and the resolve the
incorrect indentation that is identified.

10 years agoMove virConnect related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virConnect related APIs out of libvirt.h.in

Create a new libvirt-host.h file to hold the public
API definitions for the virConnect type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virDomain related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virDomain related APIs out of libvirt.h.in

Create a new libvirt-domain.h file to hold the public
API definitions for the virDomain type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virEvent related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virEvent related APIs out of libvirt.h.in

Create a new libvirt-event.h file to hold the public
API definitions for the virEvent type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virStoragePool/Vol related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virStoragePool/Vol related APIs out of libvirt.h.in

Create a new libvirt-storage.h file to hold the public
API definitions for the virStorage/Vol type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virStream related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virStream related APIs out of libvirt.h.in

Create a new libvirt-stream.h file to hold the public
API definitions for the virStream type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

Note the definition of virStreamPtr is not moved, since that
must be declared early for all other libvirt APIs to be able
to reference it.

10 years agoMove virSecret related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virSecret related APIs out of libvirt.h.in

Create a new libvirt-secret.h file to hold the public
API definitions for the virSecret type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virNodeDevice related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virNodeDevice related APIs out of libvirt.h.in

Create a new libvirt-nodedev.h file to hold the public
API definitions for the virNodeDevice type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virNWFilter related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virNWFilter related APIs out of libvirt.h.in

Create a new libvirt-nwfilter.h file to hold the public
API definitions for the virNWFilter type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virInterface related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virInterface related APIs out of libvirt.h.in

Create a new libvirt-interface.h file to hold the public
API definitions for the virInterface type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virNetwork related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virNetwork related APIs out of libvirt.h.in

Create a new libvirt-network.h file to hold the public
API definitions for the virNetwork type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virDomainSnapshot related APIs out of libvirt.h.in
Daniel P. Berrange [Thu, 23 Oct 2014 10:28:16 +0000 (11:28 +0100)]
Move virDomainSnapshot related APIs out of libvirt.h.in

Create a new libvirt-domain-snapshot.h file to hold the public
API definitions for the virDomainSnapshot type. This header
file is not self-contained, so applications will not directly
include it. They will continue to #include <libvirt/libvirt.h>

10 years agoMove virConnect/virNode related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virConnect/virNode related APIs out of libvirt.c

Introduce a src/libvirt-host.c file to hold all the
methods related to the virConnect type.

10 years agoMove virDomain related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virDomain related APIs out of libvirt.c

Introduce a src/libvirt-domain.c file to hold all the
methods related to the virDomain type.

10 years agoMake virTypedParameterValidateSet non-static
Daniel P. Berrange [Fri, 24 Oct 2014 15:54:29 +0000 (16:54 +0100)]
Make virTypedParameterValidateSet non-static

The virTypedParameterValidateSet method will need to be used
from several libvirt-*.c files so must be non-static

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoMove virStorage{Pool,Vol} related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virStorage{Pool,Vol} related APIs out of libvirt.c

Introduce a src/libvirt-storage.c file to hold all the
methods related to the virStorage{Pool,Vol} types.

10 years agoMove virStream related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virStream related APIs out of libvirt.c

Introduce a src/libvirt-stream.c file to hold all the
methods related to the virStream type.

10 years agoMove virSecret related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virSecret related APIs out of libvirt.c

Introduce a src/libvirt-secret.c file to hold all the
methods related to the virSecret type.

10 years agoMove virNodeDevice related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virNodeDevice related APIs out of libvirt.c

Introduce a src/libvirt-nodedev.c file to hold all the
methods related to the virNodeDevice type.

10 years agoMove virNWFilter related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virNWFilter related APIs out of libvirt.c

Introduce a src/libvirt-nwfilter.c file to hold all the
methods related to the virNWFilter type.

10 years agoMove virInterface related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virInterface related APIs out of libvirt.c

Introduce a src/libvirt-interface.c file to hold all the
methods related to the virInterface type.

10 years agoMove virNetwork related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virNetwork related APIs out of libvirt.c

Introduce a src/libvirt-network.c file to hold all the
methods related to the virNetwork type.

10 years agoMove virDomainSnapshot related APIs out of libvirt.c
Daniel P. Berrange [Wed, 22 Oct 2014 15:29:09 +0000 (16:29 +0100)]
Move virDomainSnapshot related APIs out of libvirt.c

Introduce a src/libvirt-domain-snapshot.c file to hold all the
methods related to the virDomainSnapshot type.

10 years agohyperv: avoid query memleaks on failure
Eric Blake [Wed, 8 Oct 2014 16:23:59 +0000 (10:23 -0600)]
hyperv: avoid query memleaks on failure

The function hypervEnumAndPull consumes query on success, but leaked
it on failure.  Rather than having to change all callers (many of
them indirect callers through the generated
hypervGetMsvmComputerSystemList), it was easier to just guarantee
that the buffer is cleaned on return from the function.

* src/hyperv/hyperv_wmi.c (hypervEnumAndPull): Don't leak query on
failure.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoSplit driver.h into multiple parts
Daniel P. Berrange [Thu, 16 Oct 2014 10:01:19 +0000 (11:01 +0100)]
Split driver.h into multiple parts

With the large number of APIs in libvirt the driver.h file,
it is easy to get lost looking for things. Split each driver
into a separate header file based on the functional driver
groups.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoRename virDriver to virHypervisorDriver
Daniel P. Berrange [Thu, 16 Oct 2014 09:25:59 +0000 (10:25 +0100)]
Rename virDriver to virHypervisorDriver

To prepare for introducing a single global driver, rename the
virDriver struct to virHypervisorDriver and the registration
API to virRegisterHypervisorDriver()

10 years agoqemu: Disallow NUMA/network tuning for session mode
Erik Skultety [Wed, 1 Oct 2014 12:57:32 +0000 (14:57 +0200)]
qemu: Disallow NUMA/network tuning for session mode

Tuning NUMA or network interface parameters requires root
privileges to manage cgroups. Thus an attempt to set some of these
parameters in session mode on a running domain should be invalid
followed by an error. An example might be memory tuning which raises
an error in such case.

The following behavior in session mode will be present after applying
this patch:

  Tuning  |      SET      |   GET  |
----------|---------------|--------|
NUMA      | shut off only | always |
Memory    |     never     | never  |
Interface |     never     | always |

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

10 years agoqemu: migration: Make check for empty hook XML robust
Peter Krempa [Wed, 22 Oct 2014 09:27:36 +0000 (11:27 +0200)]
qemu: migration: Make check for empty hook XML robust

Also consider whitespace only strings returned from the hook as empty
result.

10 years agoqemu: restore: Fix restoring of VM when the restore hook returns empty XML
Peter Krempa [Wed, 22 Oct 2014 09:22:08 +0000 (11:22 +0200)]
qemu: restore: Fix restoring of VM when the restore hook returns empty XML

The documentation for the restore hook states that returning an empty
XML is equivalent with copying the input. There was a bug in the code
checking the returned string by checking the string instead of the
contents. Use the new helper to check if the string is empty.

10 years agoutil: string: Add helper to check whether string is empty
Peter Krempa [Wed, 22 Oct 2014 08:26:42 +0000 (10:26 +0200)]
util: string: Add helper to check whether string is empty

The helper checks whether a string contains only whitespace or is NULL.
This will be helpful to skip cases where a user string is optional, but
may be provided empty with the same meaning.

10 years agodoc: HACKING: Regenerate after recent change
Peter Krempa [Wed, 22 Oct 2014 15:50:08 +0000 (17:50 +0200)]
doc: HACKING: Regenerate after recent change

10 years agoAdd support for /run/initctl
Rick Harris [Wed, 22 Oct 2014 12:09:49 +0000 (13:09 +0100)]
Add support for /run/initctl

Newer versions of Debian use '/run/initctl' instead of '/dev/initctl'.
This patch updates the code to search for the FIFO from a list of
well-known locations.

10 years agodocs: fix an improper git browsable address
Chen Hanxiao [Wed, 22 Oct 2014 09:38:33 +0000 (17:38 +0800)]
docs: fix an improper git browsable address

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoFix cast errors with clang
Roman Bogorodskiy [Tue, 21 Oct 2014 14:22:36 +0000 (18:22 +0400)]
Fix cast errors with clang

Build with clang fails with:

  CC       util/libvirt_util_la-virsocketaddr.lo
util/virsocketaddr.c:904:17: error: cast from 'struct sockaddr *' to
'struct sockaddr_in *' increases required alignment from 1 to 4
[-Werror,-Wcast-align]
        inet4 = (struct sockaddr_in*) res->ai_addr;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/virsocketaddr.c:909:17: error: cast from 'struct sockaddr *' to
'struct sockaddr_in6 *' increases required alignment from 1 to 4
[-Werror,-Wcast-align]
        inet6 = (struct sockaddr_in6*) res->ai_addr;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

Fix that by replacing virSocketAddrParseInternal() call with
virSocketAddrParse() in the virSocketAddrIsNumericLocalhost() function.
virSocketAddrParse stores an address in virSocketAddr.
virSocketAddr uses a union to store an address, so it doesn't
need casting.

10 years agodocs: Mention repository locations in contributor guidelines
Martin Kletzander [Tue, 21 Oct 2014 10:20:56 +0000 (12:20 +0200)]
docs: Mention repository locations in contributor guidelines

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: unref cfg after TerminateMachine has been called
Martin Kletzander [Tue, 21 Oct 2014 09:44:13 +0000 (11:44 +0200)]
qemu: unref cfg after TerminateMachine has been called

Commit 4882618ed13b469d92fa8b2b4a158fdb17dbe9f1 added the code that
requests driver cfg, but forgot to unref it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>