]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agoqemu: Record names of domain which uses the shared disk in hash table
Osier Yang [Wed, 20 Feb 2013 07:43:55 +0000 (15:43 +0800)]
qemu: Record names of domain which uses the shared disk in hash table

The hash entry is changed from "ref" to {ref, @domains}. With this, the
caller can simply call qemuRemoveSharedDisk, without afraid of removing
the entry belongs to other domains. qemuProcessStart will obviously
benifit from it on error codepath (which calls qemuProcessStop to do
the cleanup).

12 years agoqemu: Merge qemuCheckSharedDisk into qemuAddSharedDisk
Osier Yang [Tue, 19 Feb 2013 12:27:41 +0000 (20:27 +0800)]
qemu: Merge qemuCheckSharedDisk into qemuAddSharedDisk

Based on moving various checking into qemuAddSharedDisk, this
avoids the caller using it in wrong ways. Also this adds two
new checking for qemuCheckSharedDisk (disk device not 'lun'
and kernel doesn't support unpriv_sgio simply returns 0).

12 years agoqemu: Add checking in helpers for sgio setting
Osier Yang [Tue, 19 Feb 2013 12:27:40 +0000 (20:27 +0800)]
qemu: Add checking in helpers for sgio setting

This moves the various checking into the helpers, to avoid the
callers missing the checking.

12 years agomaint: enforce private symbol section sorting
Eric Blake [Wed, 20 Feb 2013 00:59:20 +0000 (17:59 -0700)]
maint: enforce private symbol section sorting

Automating a sorting check is the only way to ensure we don't
regress.  Suggested by Dan Berrange.

* src/check-symsorting.pl (check_sorting): Add a parameter,
validate that groups are in order, and that files exist.
* src/Makefile.am (check-symsorting): Adjust caller.
* src/libvirt_private.syms: Fix typo.
* src/libvirt_linux.syms: Fix file name.
* src/libvirt_vmx.syms: Likewise.
* src/libvirt_xenxs.syms: Likewise.
* src/libvirt_sasl.syms: Likewise.
* src/libvirt_libssh2.syms: Likewise.
* src/libvirt_esx.syms: Mention file name.
* src/libvirt_openvz.syms: Likewise.

12 years agoqemu: Do not ignore mandatory features in migration cookie
Jiri Denemark [Wed, 20 Feb 2013 09:30:38 +0000 (10:30 +0100)]
qemu: Do not ignore mandatory features in migration cookie

Due to "feature"/"features" nasty typo, any features marked as mandatory
by one side of a migration are silently considered optional by the other
side. The following is the code that formats mandatory features in
migration cookie:

    for (i = 0 ; i < QEMU_MIGRATION_COOKIE_FLAG_LAST ; i++) {
        if (mig->flagsMandatory & (1 << i))
            virBufferAsprintf(buf, "  <feature name='%s'/>\n",
                              qemuMigrationCookieFlagTypeToString(i));
    }

12 years agoqemu: switch PCI address alocation to use virDevicePCIAddress
Ján Tomko [Fri, 15 Feb 2013 06:48:49 +0000 (07:48 +0100)]
qemu: switch PCI address alocation to use virDevicePCIAddress

Some functions were using virDomainDeviceInfo where virDevicePCIAddress
would suffice. Some were only using integers for slots and functions,
assuming the bus numbers are always 0.

Switch from virDomainDeviceInfoPtr to virDevicePCIAddressPtr:
qemuPCIAddressAsString
qemuDomainPCIAddressCheckSlot
qemuDomainPCIAddressReserveAddr
qemuDomainPCIAddressReleaseAddr

Switch from int slot to virDevicePCIAddressPtr:
qemuDomainPCIAddressReserveSlot
qemuDomainPCIAddressReleaseSlot
qemuDomainPCIAddressGetNextSlot

Deleted functions (they would take the same parameters
as ReserveAddr/ReleaseAddr do now.)
qemuDomainPCIAddressReserveFunction
qemuDomainPCIAddressReleaseFunction

12 years agovirsh: distinguish errors between missing argument and wrong option
Guannan Ren [Tue, 19 Feb 2013 08:50:59 +0000 (16:50 +0800)]
virsh: distinguish errors between missing argument and wrong option

Specifying ':' to suppress the error messages printed by getopt().
Then, distinguish the two types of errors.

Before:
 # virsh -c
   virsh: option requires an argument -- 'c'
   error: unsupported option '-?'. See --help.

After:
 # virsh -c
   error: option '-c' requires an argument

 # virsh -x
   error: unsupported option '-x'. See --help.

12 years agomaint: sort private syms to reflect recent header renames
Eric Blake [Sat, 16 Feb 2013 03:34:42 +0000 (20:34 -0700)]
maint: sort private syms to reflect recent header renames

Purely mechanical (roughly, s/\n/~/; s/~~/\n/; sort by line;
s/~/\n/)

* src/libvirt_private.syms: Sort sections by header file name.

12 years agomaint: fix header file owners of private symbols
Eric Blake [Sat, 16 Feb 2013 03:25:09 +0000 (20:25 -0700)]
maint: fix header file owners of private symbols

Recent renames were not reflected into the comments of
libvirt_private.syms; furthermore, since we mix private headers from
several directories into this file, knowing where the file lives
can be helpful.

* src/libvirt_private.sym: Reflect recent names.

12 years agonet: use structs for address and port ranges
Natanael Copa [Tue, 19 Feb 2013 10:44:16 +0000 (11:44 +0100)]
net: use structs for address and port ranges

We pass over the address/port start/end values many times so we put
them in structs.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Laine Stump <laine@laine.org>
12 years agonet: add support for specifying port range for forward mode nat
Natanael Copa [Tue, 19 Feb 2013 10:44:15 +0000 (11:44 +0100)]
net: add support for specifying port range for forward mode nat

Let users set the port range to be used for forward mode NAT:

...
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
...

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Laine Stump <laine@laine.org>
12 years agonet: support set public ip range for forward mode nat
Natanael Copa [Tue, 19 Feb 2013 10:44:14 +0000 (11:44 +0100)]
net: support set public ip range for forward mode nat

Support setting which public ip to use for NAT via attribute
address in subelement <nat> in <forward>:

...
  <forward mode='nat'>
      <address start='1.2.3.4' end='1.2.3.10'/>
  </forward>
...

This will construct an iptables line using:

  '-j SNAT --to-source <start>-<end>'

instead of:

  '-j MASQUERADE'

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Laine Stump <laine@laine.org>
12 years agoqemu: Use atomic ops for driver->nactive
Jiri Denemark [Tue, 19 Feb 2013 13:57:46 +0000 (14:57 +0100)]
qemu: Use atomic ops for driver->nactive

12 years agorpc: Avoid deadlock when closing client connection
Jiri Denemark [Mon, 18 Feb 2013 14:10:04 +0000 (15:10 +0100)]
rpc: Avoid deadlock when closing client connection

We need to drop the server lock before calling virObjectUnlock(client)
since in case we had the last reference to the client, its dispose
callback would be called and that could possibly try to lock the server
and cause a deadlock. This is exactly what happens when there is only
one QEMU domain running and it is marked to be autodestroyed when the
connection dies. This results in qemuProcessAutoDestroy ->
qemuProcessStop -> virNetServerRemoveShutdownInhibition call sequence,
where the last function locks the server.

12 years agoAvoid resetting errors in virTypedParamsFree
Jiri Denemark [Mon, 18 Feb 2013 14:07:48 +0000 (15:07 +0100)]
Avoid resetting errors in virTypedParamsFree

The function does not report any errors so there should be no need too
reset an existing error first. Moreover, virTypedParamsFree is mostly
called in cleanup phase where it has the potential to reset any useful
reported earlier.

12 years agovirsh: Always print capacity unit
Jiri Denemark [Thu, 14 Feb 2013 13:45:48 +0000 (14:45 +0100)]
virsh: Always print capacity unit

It doesn't make sense to print the unit (B) only with Ki, Mi, ...
prefixes. Even those poor bytes under 1 KiB are still bytes :-)

12 years agobuild: force correct gcc syntax for attribute_nonnull
Eric Blake [Mon, 18 Feb 2013 20:34:58 +0000 (13:34 -0700)]
build: force correct gcc syntax for attribute_nonnull

Gcc lets you do:

int ATTRIBUTE_NONNULL(1) foo(void *param);
int foo(void *param) ATTRIBUTE_NONNULL(1);
int ATTRIBUTE_NONNULL(1) foo(void *param) { ... }

but chokes on:

int foo(void *param) ATTRIBUTE_NONNULL(1) { ... }

However, since commit eefb881, we have intentionally been disabling
ATTRIBUTE_NONNULL because of lame gcc handling of the attribute (that
is, gcc doesn't do decent warning reporting, then compiles code that
mysteriously fails if you break the contract of the attribute, which
is surprisingly easy to do), leaving it on only for Coverity (which
does a much better job of improved static analysis when the attribute
is present).

But completely eliding the macro makes it too easy to write code that
uses the fourth syntax option, if you aren't using Coverity.  So this
patch forces us to avoid syntax errors, even when not using the
attribute under gcc.  It also documents WHY we disable the warning
under gcc, rather than forcing you to find the commit log.

* src/internal.h (ATTRIBUTE_NONNULL): Expand to empty attribute,
rather than nothing, when on gcc.

12 years agoqemu: pass "-1" as uid/gid for unprivileged qemu
Guido Günther [Sun, 17 Feb 2013 17:33:08 +0000 (18:33 +0100)]
qemu: pass "-1" as uid/gid for unprivileged qemu

so we don't try to change uid/git to 0 when probing capabilities.

12 years agoAdd capabilities bit for -no-kvm-pit-reinjection
Doug Goldstein [Mon, 18 Feb 2013 05:46:29 +0000 (23:46 -0600)]
Add capabilities bit for -no-kvm-pit-reinjection

The conversion to qemuCaps dropped the ability with qemu{,-kvm} 1.2 and
newer to set the lost tick policy for the PIT. While the
-no-kvm-pit-reinjection option is depreacated, it is still supported at
least through 1.4, it is better to not lose the functionality.

12 years agointerface: fix udev backend use after free
Doug Goldstein [Mon, 18 Feb 2013 04:26:38 +0000 (22:26 -0600)]
interface: fix udev backend use after free

udevIfaceListAllInterface() used the udev_device after it had its ref
count decremented which results in a use after free issue.

12 years agoAdd autogenerated lxc_protocol.[ch] to gitignore
Doug Goldstein [Mon, 18 Feb 2013 05:04:17 +0000 (23:04 -0600)]
Add autogenerated lxc_protocol.[ch] to gitignore

/src/lxc/lxc_protocol.[ch] is autogenerated so add it to .gitignore

12 years agosecurity: Remove unnecessary checks for mgr == NULL
John Ferlan [Wed, 13 Feb 2013 13:11:39 +0000 (08:11 -0500)]
security: Remove unnecessary checks for mgr == NULL

Coverity found the DACGenLabel was checking for mgr == NULL after a
possible dereference; however, in order to get into the function the
virSecurityManagerGenLabel would have already dereferenced sec_managers[i]
so the check was unnecessary. Same check is made in SELinuxGenSecurityLabel.

12 years agovirsh: Resolve possible NULL dereference
John Ferlan [Wed, 13 Feb 2013 12:49:29 +0000 (07:49 -0500)]
virsh: Resolve possible NULL dereference

Coverity found that commit '41b5e845' had a possible NULL dereference on
arg->data processing

12 years agovircommand: Remove unnecessary sa_assert
John Ferlan [Fri, 15 Feb 2013 14:31:24 +0000 (09:31 -0500)]
vircommand: Remove unnecessary sa_assert

Changes from commit '3178df9a' removed the need for the sa_assert(infd).

12 years agocommandtest: Resolve some coverity resource leaks
John Ferlan [Mon, 14 Jan 2013 15:35:45 +0000 (10:35 -0500)]
commandtest: Resolve some coverity resource leaks

12 years agodrivermodule: Ignore coverity warning about leaked_storage
John Ferlan [Mon, 14 Jan 2013 15:35:08 +0000 (10:35 -0500)]
drivermodule: Ignore coverity warning about leaked_storage

12 years agoFix libvirt upgrade path when nwfilter is used
Stefan Berger [Sat, 16 Feb 2013 02:33:37 +0000 (21:33 -0500)]
Fix libvirt upgrade path when nwfilter is used

Between revision 65fb9d49 and before this patch, an upgrade of libvirt while
VMs are running and instantiating iptables filtering rules due to nwfilter
rules, may leave stray iptables rules behind when shutting VMs down.
Left-over iptables rules may look like this:

Chain FP-vnet0 (1 references)
target     prot opt source               destination
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp spt:122
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

[...]

Chain libvirt-out (1 references)
target     prot opt source               destination
FO-vnet0   all  --  0.0.0.0/0            0.0.0.0/0           [goto]  PHYSDEV match --physdev-out vnet0

The reason is that the recent nwfilter code only removed filtering rules in
the libvirt-out chain that contain the --physdev-is-bridged parameter.
Older rules didn't match and were not removed.

Note that the user-defined chain FO-vnet0 could not be removed due to the
reference from the rule in libvirt-out.

Often the work around may be done through

service iptables restart
kill -SIGHUP $(pidof libvirtd)

This patch now also removes older libvirt versions' iptables rules.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agostorage: test backing chain traversal
Eric Blake [Wed, 13 Feb 2013 18:04:05 +0000 (11:04 -0700)]
storage: test backing chain traversal

Testing our backing chain handling will make it much easier to
ensure that we avoid issues in the future.  If only I had written
this test before I first caused several regressions...

* tests/virstoragetest.c: New test.
* tests/Makefile.am (test_programs): Build it.
* .gitignore: Ignore new files.

12 years agostorage: don't follow backing chain symlinks too eagerly
Eric Blake [Wed, 6 Feb 2013 22:48:15 +0000 (15:48 -0700)]
storage: don't follow backing chain symlinks too eagerly

If you have a qcow2 file /path1/to/file pointed to by symlink
/path2/symlink, and pass qemu /path2/symlink, then qemu treats
a relative backing file in the qcow2 metadata as being relative
to /path2, not /path1/to.  Yes, this means that it is possible
to create a qcow2 file where the choice of WHICH directory and
symlink you access its contents from will then determine WHICH
backing file (if any) you actually find; the results can be
rather screwy, but we have to match what qemu does.

Libvirt and qemu default to creating absolute backing file
names, so most users don't hit this.  But at least VDSM uses
symlinks and relative backing names alongside the
--reuse-external flags to libvirt snapshot operations, with the
result that libvirt was failing to follow the intended chain of
backing files, and then backing files were not granted the
necessary sVirt permissions to be opened by qemu.

See https://bugzilla.redhat.com/show_bug.cgi?id=903248 for
more gory details.  This fixes a regression introduced in
commit 8250783.

I tested this patch by creating the following chain:

ls /home/eblake/Downloads/Fedora.iso # raw file for base
cd /var/lib/libvirt/images
qemu-img create -f qcow2 \
  -obacking_file=/home/eblake/Downloads/Fedora.iso,backing_fmt=raw one
mkdir sub
cd sub
ln -s ../one onelink
qemu-img create -f qcow2 \
  -obacking_file=../sub/onelink,backing_fmt=qcow2 two
mv two ..
ln -s ../two twolink
qemu-img create -f qcow2 \
  -obacking_file=../sub/twolink,backing_fmt=qcow2 three
mv three ..
ln -s ../three threelink

then pointing my domain at /var/lib/libvirt/images/sub/threelink.
Prior to this patch, I got complaints about missing backing
files; afterwards, I was able to verify that the backing chain
(and hence DAC and SELinux relabels) of the entire chain worked.

* src/util/virstoragefile.h (_virStorageFileMetadata): Add
directory member.
* src/util/virstoragefile.c (absolutePathFromBaseFile): Drop,
replaced by...
(virFindBackingFile): ...better function.
(virStorageFileGetMetadataInternal): Add an argument.
(virStorageFileGetMetadataFromFD, virStorageFileChainLookup)
(virStorageFileGetMetadata): Update callers.

12 years agostorage: refactor metadata lookup
Eric Blake [Wed, 6 Feb 2013 23:33:45 +0000 (16:33 -0700)]
storage: refactor metadata lookup

Prior to this patch, we had the callchains:
external users
  \-> virStorageFileGetMetadataFromFD
      \-> virStorageFileGetMetadataFromBuf
virStorageFileGetMetadataRecurse
  \-> virStorageFileGetMetadataFromFD
      \-> virStorageFileGetMetadataFromBuf

However, a future patch wants to add an additional parameter to
the bottom of the chain, for use by virStorageFileGetMetadataRecurse,
without affecting existing external callers.  Since there is only a
single caller of the internal function, we can repurpose it to fit
our needs, with this patch giving us:

external users
  \-> virStorageFileGetMetadataFromFD
      \-> virStorageFileGetMetadataInternal
virStorageFileGetMetadataRecurse /
  \-> virStorageFileGetMetadataInternal

* src/util/virstoragefile.c (virStorageFileGetMetadataFromFD):
Move most of the guts...
(virStorageFileGetMetadataFromBuf): ...here, and rename...
(virStorageFileGetMetadataInternal): ...to this.
(virStorageFileGetMetadataRecurse): Use internal helper.

12 years agostorage: prepare for refactoring
Eric Blake [Sat, 9 Feb 2013 13:41:01 +0000 (06:41 -0700)]
storage: prepare for refactoring

virStorageFileGetMetadataFromFD is the only caller of
virStorageFileGetMetadataFromBuf; and it doesn't care about the
difference between a return of 0 (total success) or 1
(metadata was inconsistent, but pointer was populated as best
as possible); only about a return of -1 (could not read metadata
or out of memory).  Changing the return type, and normalizing
the variable names used, will make merging the functions easier
in the next commit.

* src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf):
Change return value, and rename some variables.
(virStorageFileGetMetadataFromFD): Rename some variables.

12 years agostorage: rearrange functions
Eric Blake [Wed, 6 Feb 2013 23:54:08 +0000 (16:54 -0700)]
storage: rearrange functions

No semantic change; done so the next patch doesn't need a forward
declaration of a static function.

* src/util/virstoragefile.c (virStorageFileProbeFormatFromBuf):
Hoist earlier.

12 years agobuild: more mingw fixes
Eric Blake [Fri, 15 Feb 2013 22:39:33 +0000 (15:39 -0700)]
build: more mingw fixes

More mingw build failures:

  CCLD     libvirt-lxc.la
/usr/lib64/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld: cannot find libvirt_lxc.def: No such file or directory

  CC       virportallocatortest-virportallocatortest.o
../../tests/virportallocatortest.c: In function 'main':
../../tests/virportallocatortest.c:195:1: error: implicit declaration of function 'setenv' [-Werror=implicit-function-declaration]

* src/Makefile.am (GENERATED_SYM_FILES): Also generate
libvirt_lxc.def.
* bootstrap.conf (gnulib_modules): Import setenv.

12 years agobuild: fix mingw build
Eric Blake [Fri, 15 Feb 2013 22:01:44 +0000 (15:01 -0700)]
build: fix mingw build

Commits 2025356 and ba72cb12 introduced typos.

* src/util/virpci.c (virPCIIsVirtualFunction) [!__linux__]: Fix
function name.
* src/util/virutil.c (virGetDeviceID): Fix attribute spelling.

12 years agobuild: fix vircommand build on mingw
Eric Blake [Fri, 15 Feb 2013 20:13:47 +0000 (13:13 -0700)]
build: fix vircommand build on mingw

  CC       libvirt_util_la-vircommand.lo
../../src/util/vircommand.c:2358:1: error: 'virCommandHandshakeChild' defined but not used [-Werror=unused-function]

The function is only implemented inside #ifndef WIN32.

* src/util/vircommand.c (virCommandHandshakeChild): Hoist earlier,
so that win32 build doesn't hit an unused forward declaration.

12 years agoregex: gnulib guarantees that we have regex support
Eric Blake [Mon, 11 Feb 2013 22:12:16 +0000 (15:12 -0700)]
regex: gnulib guarantees that we have regex support

No need to use HAVE_REGEX_H - our use of gnulib guarantees that
the header exists and works, regardless of platform.  Similarly,
we can unconditionally assume a compiling <sys/wait.h> (although
the mingw version of this header is not full-featured).

* src/storage/storage_backend.c: Drop useless conditional.
* tests/testutils.c: Likewise.

12 years agovbox: Don't overwrite errors returned by virDomainDeviceDefParse
Jiri Denemark [Thu, 14 Feb 2013 08:05:36 +0000 (09:05 +0100)]
vbox: Don't overwrite errors returned by virDomainDeviceDefParse

12 years agoutil: maintain caps when running command with uid != 0
Laine Stump [Thu, 7 Feb 2013 16:45:27 +0000 (11:45 -0500)]
util: maintain caps when running command with uid != 0

virCommand was previously calling virSetUIDGID() to change the uid and
gid of the child process, then separately calling
virSetCapabilities(). This did not work if the desired uid was != 0,
since a setuid to anything other than 0 normally clears all
capabilities bits.

The solution is to use the new virSetUIDGIDWithCaps(), sending it the
uid, gid, and capabilities bits. This will get the new process setup
properly.

Since the static functions virSetCapabilities() and
virClearCapabilities are no longer called, they have been removed.

NOTE: When combined with "filecap $path-to-qemu sys_rawio", this patch
will make CAP_SYS_RAWIO (which is required for passthrough of generic
scsi commands to a guest - see commits e8daeeb177db08397e6a7, and
74e0349) be retained by qemu when necessary. Apparently that
capability has been broken for non-root qemu ever since it was
originally added.

12 years agoutil: virSetUIDGIDWithCaps - change uid while keeping caps
Laine Stump [Tue, 5 Feb 2013 15:30:32 +0000 (10:30 -0500)]
util: virSetUIDGIDWithCaps - change uid while keeping caps

Normally when a process' uid is changed to non-0, all the capabilities
bits are cleared, even those explicitly set with calls to
capng_update()/capng_apply() made immediately before setuid. And
*after* the process' uid has been changed, it no longer has the
necessary privileges to add capabilities back to the process.

In order to set a non-0 uid while still maintaining any capabilities
bits, it is necessary to either call capng_change_id() (which
unfortunately doesn't currently call initgroups to setup auxiliary
group membership), or to perform the small amount of calisthenics
contained in the new utility function virSetUIDGIDWithCaps().

Another very important difference between the capabilities
setting/clearing in virSetUIDGIDWithCaps() and virCommand's
virSetCapabilities() (which it will replace in the next patch) is that
the new function properly clears the capabilities bounding set, so it
will not be possible for a child process to set any new
capabilities.

A short description of what is done by virSetUIDGIDWithCaps():

1) clear all capabilities then set all those desired by the caller (in
capBits) plus CAP_SETGID, CAP_SETUID, and CAP_SETPCAP (which is needed
to change the capabilities bounding set).

2) call prctl(), telling it that we want to maintain current
capabilities across an upcoming setuid().

3) switch to the new uid/gid

4) again call prctl(), telling it we will no longer want capabilities
maintained if this process does another setuid().

5) clear the capabilities that we added to allow us to
setuid/setgid/change the bounding set (unless they were also requested
by the caller via the virCommand API).

Because the modification/maintaining of capabilities is intermingled
with setting the uid, this is necessarily done in a single function,
rather than having two independent functions.

Note that, due to the way that effective capabilities are computed (at
time of execve) for a process that has uid != 0, the *file*
capabilities of the binary being executed must also have the desired
capabilities bit(s) set (see "man 7 capabilities"). This can be done
with the "filecap" command. (e.g. "filecap /usr/bin/qemu-kvm sys_rawio").

12 years agoutil: drop capabilities immediately after changing uid/gid of child
Laine Stump [Fri, 1 Feb 2013 21:26:25 +0000 (16:26 -0500)]
util: drop capabilities immediately after changing uid/gid of child

This is an interim measure to make sure everything still works in this
order. The next step will be to perform capabilities drop and
setuid/gid as a single operation (which is the only way to keep any
capabilities when switching to a non-root uid).

12 years agoqemu: let virCommand set child process security labels/uid/gid
Laine Stump [Fri, 1 Feb 2013 20:20:22 +0000 (15:20 -0500)]
qemu: let virCommand set child process security labels/uid/gid

The qemu driver had been calling virSecurityManagerSetProcessLabel()
from a "pre-exec hook" function that is run after the child is forked,
but before exec'ing qemu. This is problematic because the uid and gid
of the child are set by the security driver, but capabilities are
dropped by virCommand - such separation doesn't work; the two
operations must be done together or the capabilities do not transfer
properly to the child process.

This patch switches to using virSecurityManagerSetChildProcessLabel(),
which is called prior to virCommandRun() (rather than being called
*during* virCommandrun() by the hook function), and doesn't set the
UID/GID/security label directly, but instead merely informs virCommand
what it should set them all to when the time is appropriate.

This lets virCommand choose to do the uid/gid and caps dropping all at
the same time if it wants (it does *want* to, but isn't doing so yet;
that's for an upcoming patch).

12 years agosecurity: add new virSecurityManagerSetChildProcessLabel API
Laine Stump [Fri, 1 Feb 2013 20:02:03 +0000 (15:02 -0500)]
security: add new virSecurityManagerSetChildProcessLabel API

The existing virSecurityManagerSetProcessLabel() API is designed so
that it must be called after forking the child process, but before
exec'ing the child. Due to the way the virCommand API works, that
means it needs to be put in a "hook" function that virCommand is told
to call out to at that time.

Setting the child process label is a basic enough need when executing
any process that virCommand should have a method of doing that. But
virCommand must be told what label to set, and only the security
driver knows the answer to that question.

The new virSecurityManagerSet*Child*ProcessLabel() API is the way to
transfer the knowledge about what label to set from the security
driver to the virCommand object. It is given a virCommandPtr, and each
security driver calls the appropriate virCommand* API to tell
virCommand what to do between fork and exec.

1) in the case of the DAC security driver, it calls
virCommandSetUID/GID() to set a uid and gid that must be set for the
child process.

2) for the SELinux security driver, it calls
virCommandSetSELinuxLabel() to save a copy of the char* that will be
sent to setexeccon_raw() *after forking the child process*.

3) for the AppArmor security drivers, it calls
virCommandSetAppArmorProfile() to save a copy of the char* that will
be sent to aa_change_profile() *after forking the child process*.

With this new API in place, we will be able to remove
virSecurityManagerSetProcessLabel() from any virCommand pre-exec
hooks.

(Unfortunately, the LXC driver uses clone() rather than virCommand, so
it can't take advantage of this new security driver API, meaning that
we need to keep around the older virSecurityManagerSetProcessLabel(),
at least for now.)

12 years agoutil: add security label setting to virCommand
Laine Stump [Fri, 1 Feb 2013 19:32:37 +0000 (14:32 -0500)]
util: add security label setting to virCommand

virCommand gets two new APIs: virCommandSetSELinuxLabel() and
virCommandSetAppArmorProfile(), which both save a copy of a
null-terminated string in the virCommand. During virCommandRun, if the
string is non-NULL and we've been compiled with AppArmor and/or
SELinux security driver support, the appropriate security library
function is called for the child process, using the string that was
previously set. In the case of SELinux, setexeccon_raw() is called,
and for AppArmor, aa_change_profile() is called.

This functionality has been added so that users of virCommand can use
the upcoming virSecurityManagerSetChildProcessLabel() prior to running
a child process, rather than needing to setup a hook function to be
called (and in turn call virSecurityManagerSetProcessLabel()) *during*
the setup of the child process.

12 years agobuild: define SECDRIVER_LIBS in Makefile.am
Laine Stump [Fri, 1 Feb 2013 19:22:26 +0000 (14:22 -0500)]
build: define SECDRIVER_LIBS in Makefile.am

This makes it simpler to include the necessary system security driver
libraries for a particular system. For this patch, several existing
conditional sections from the Makfile were replaced; I'll later be
adding SECDRIVER_LIBS to libvirt_util_la_LIBADD, because vircommand.c
will be calling a function from $securitylib.

12 years agoqemu: replace exec hook with virCommandSetUID/GID in storage_backend
Laine Stump [Thu, 31 Jan 2013 03:26:16 +0000 (22:26 -0500)]
qemu: replace exec hook with virCommandSetUID/GID in storage_backend

12 years agoqemu: replace exec hook with virCommandSetUID/GID in qemuCaps*
Laine Stump [Wed, 30 Jan 2013 20:07:03 +0000 (15:07 -0500)]
qemu: replace exec hook with virCommandSetUID/GID in qemuCaps*

Setting the uid/gid of the child process was the only thing done by
the hook function in this case, and that can now be done more simply
with virCommandSetUID/GID.

12 years agoutil: make virSetUIDGID a NOP only when uid or gid is -1
Laine Stump [Thu, 31 Jan 2013 18:18:45 +0000 (13:18 -0500)]
util: make virSetUIDGID a NOP only when uid or gid is -1

Rather than treating uid:gid of 0:0 as a NOP, we blindly pass that
through to the lower layers. However, we *do* check for a requested
value of "-1" to mean "don't change this setting". setregid() and
setreuid() already interpret -1 as a NOP, so this is just an
optimization, but we are also calling getpwuid_r and initgroups, and
it's unclear what the former would do with a uid of -1.

12 years agoutil: add virCommandSetUID and virCommandSetGID
Laine Stump [Wed, 30 Jan 2013 19:47:56 +0000 (14:47 -0500)]
util: add virCommandSetUID and virCommandSetGID

If a uid and/or gid is specified for a command, it will be set just
after the user-supplied post-fork "hook" function is called.

The intent is that this can replace user hook functions that set
uid/gid. This moves the setting of uid/gid and dropping of
capabilities closer to each other, which is important since the two
should really be done at the same time (libcapng provides a single
function that does both, which we will be unable to use, but want to
mimic as closely as possible).

12 years agoutil: refactor virCommandHook into virExec and virCommandHandshakeChild
Laine Stump [Wed, 30 Jan 2013 03:04:49 +0000 (22:04 -0500)]
util: refactor virCommandHook into virExec and virCommandHandshakeChild

12 years agoutil: eliminate extra args from virExec
Laine Stump [Tue, 29 Jan 2013 18:47:18 +0000 (13:47 -0500)]
util: eliminate extra args from virExec

All args except "cmd" in the call to virExec are now redundant, since
they can all be found in cmd, so remove the args and reference the
data directly in cmd. One exception to this is that "infd" was being
modified within virExec, and modifying the original in cmd caused make
check failures, so cmd->infd is copied to a local, and the local is
used during virExec().

12 years agoutil: eliminate generic hook from virExecWithHook
Laine Stump [Tue, 29 Jan 2013 18:30:53 +0000 (13:30 -0500)]
util: eliminate generic hook from virExecWithHook

virExecWithHook is only called from one place, so it always has the
same "hook" function (virHookCommand), and the data sent to that
function is always a virCommandPtr, so eliminate the function and
generic data from the arglist, and replace it with "virCommandPtr
cmd". The call to (hook)(data) is replaced with
"virHookCommand(cmd)". Finally, virExecWithHook is renamed to virExec.

Indentation has been updated only for code that will remain after the
next patch, which will remove all other args to virExec (since they
are now redundant, as they're all members of virCommandPtr).

12 years agoRemove qemuDriverLock from almost everywhere
Daniel P. Berrange [Wed, 6 Feb 2013 18:17:20 +0000 (18:17 +0000)]
Remove qemuDriverLock from almost everywhere

With the majority of fields in the virQEMUDriverPtr struct
now immutable or self-locking, there is no need for practically
any methods to be using the QEMU driver lock. Only a handful
of helper APIs in qemu_conf.c now need it

12 years agovirCommand: Don't misuse the eventloop for async IO
Michal Privoznik [Fri, 8 Feb 2013 14:17:44 +0000 (15:17 +0100)]
virCommand: Don't misuse the eventloop for async IO

Currently, if a command wants to do asynchronous IO, a callback
is registered in the libvirtd eventloop to handle writes and
reads. However, there's a race in virCommandWait. The eventloop
may already be executing the callback, while virCommandWait is
mangling internal state of virCommand. To deal with it, we need
to either introduce locking or spawn a separate thread where we
poll() on stdio from child. The former, however, requires to
unlock all mutexes held, as the event loop may execute other
callbacks which tries to lock one of the mutexes, deadlock and
thus never wake us up. So it's safer to spawn a separate thread.

12 years agovirsh-volume.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-volume.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-snapshot.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-snapshot.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-secret.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-secret.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-pool.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-pool.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-nwfilter.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-nwfilter.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-nodedev.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-nodedev.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-network.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-network.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-interface.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-interface.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-host.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-host.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-domain.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-domain.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh-domain-monitor.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh-domain-monitor.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh.c: Switch to c99 initialization of vshCmdInfo
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh.c: Switch to c99 initialization of vshCmdInfo

12 years agovirsh: Switch to c99 initialization of vshCmdDef
Michal Privoznik [Thu, 7 Feb 2013 15:25:10 +0000 (16:25 +0100)]
virsh: Switch to c99 initialization of vshCmdDef

12 years agoxen: clean up the mess with cpumap
Eric Blake [Tue, 12 Feb 2013 00:02:00 +0000 (17:02 -0700)]
xen: clean up the mess with cpumap

Commit 8b55992f added some Coverity comments to silence what was
a real bug in the code.  Since then, we've had a miserable run
of trying to fix the underlying problem (commits c059cde and
ba5193c), and still have a problem on 32-bit machines.

This fixes the problem for once and for all, by realizing that
on older xen, cpumap_t is identical to uint64_t, and using the
new virendian.h to do the transformation from the API (documented
to be little-endian) to the host structure.

* src/xen/xen_hypervisor.c (virXen_setvcpumap): Do the conversion
correctly.  Finally.

12 years agoutil: use new virendian.h macros
Eric Blake [Thu, 7 Feb 2013 01:57:13 +0000 (18:57 -0700)]
util: use new virendian.h macros

This makes code easier to read, by avoiding lines longer than
80 columns and removing the repetition from the callers.

* src/util/virstoragefile.c (qedGetHeaderUL, qedGetHeaderULL):
Delete in favor of more generic macros.
(qcow2GetBackingStoreFormat, qcowXGetBackingStore)
(qedGetBackingStore, virStorageFileMatchesVersion)
(virStorageFileGetMetadataInternal): Use new macros.
* src/cpu/cpu_x86.c (x86VendorLoad): Likewise.

12 years agoutil: add virendian.h macros
Eric Blake [Fri, 8 Feb 2013 23:44:21 +0000 (16:44 -0700)]
util: add virendian.h macros

We have several cases where we need to read endian-dependent
data regardless of host endianness; rather than open-coding
these call sites, it will be nicer to funnel things through
a macro.

The virendian.h file can be expanded to add writer functions,
and/or 16-bit access patterns, if needed.  Also, if we need
to turn things into a function to avoid multiple evaluations
of buf, that can be done later.  But for now, a macro worked.

* src/util/virendian.h: New file.
* src/Makefile.am (UTIL_SOURCES): Ship it.
* tests/virendiantest.c: New test.
* tests/Makefile.am (test_programs, virendiantest_SOURCES): Run
the test.
* .gitignore: Ignore built file.

12 years agoRelease VM lock before acquiring virDomainObjListPtr lock
Daniel P. Berrange [Mon, 11 Feb 2013 16:45:50 +0000 (16:45 +0000)]
Release VM lock before acquiring virDomainObjListPtr lock

When removing a VM from the virDomainObjListPtr, we must not
be holding the VM lock while acquiring the list lock. Re-order
code to ensure that we can release the VM lock early.

12 years agoFix potential deadlock across fork() in QEMU driver
Daniel P. Berrange [Mon, 11 Feb 2013 16:08:42 +0000 (16:08 +0000)]
Fix potential deadlock across fork() in QEMU driver

The hook scripts used by virCommand must be careful wrt
accessing any mutexes that may have been held by other
threads in the parent process. With the recent refactoring
there are 2 potential flaws lurking, which will become real
deadlock bugs once the global QEMU driver lock is removed.

Remove use of the QEMU driver lock from the hook function
by passing in the 'virQEMUDriverConfigPtr' instance directly.

Add functions to the virSecurityManager to be invoked before
and after fork, to ensure the mutex is held by the current
thread. This allows it to be safely used in the hook script
in the child process.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agobuild: fix compilation of selinux on RHEL 5
Eric Blake [Tue, 12 Feb 2013 00:12:25 +0000 (17:12 -0700)]
build: fix compilation of selinux on RHEL 5

On RHEL 5, I got:

security/security_selinux.c: In function 'getContext':
security/security_selinux.c:971: warning: unused parameter 'mgr' [-Wunused-parameter]

* src/security/security_selinux.c (getContext): Mark potentially
unused parameter.

12 years agoS390: domain_conf support for CCW
Viktor Mihajlovski [Fri, 8 Feb 2013 17:32:21 +0000 (18:32 +0100)]
S390: domain_conf support for CCW

Add necessary handling code for the new s390 CCW address type to
virDomainDeviceInfo. Further, introduce  memory management, XML
parsing, output formatting and range validation for the new
virDomainDeviceCCWAddress type.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoS390: Documentation for CCW address type
Viktor Mihajlovski [Fri, 8 Feb 2013 17:32:20 +0000 (18:32 +0100)]
S390: Documentation for CCW address type

The native bus for s390 I/O is called CCW (channel command word).
As QEMU has added basic support for the CCW bus, i.e. the
ability to assign CCW devnos (bus addresses) to devices.
Domains with the new machine type s390-ccw-virtio can use the
CCW bus. Currently QEMU will only allow to define virtio
devices on the CCW bus.
Here we add the new machine type and the new device address to the
schema definition and add a new paragraph to the domain XML
documentation.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agobuild: fix VPATH testsuite
Eric Blake [Mon, 11 Feb 2013 22:47:16 +0000 (15:47 -0700)]
build: fix VPATH testsuite

'make check' has been failing on VPATH builds since commit
907a39e7.  The tests already had magic for munging path names,
but were munging to the wrong location, thus working only on
an in-tree build.

* tests/securityselinuxlabeltest.c (testSELinuxMungePath): Munge
to correct path.

12 years agodocs: fix 1.0.2 release date
Eric Blake [Mon, 11 Feb 2013 22:19:04 +0000 (15:19 -0700)]
docs: fix 1.0.2 release date

* docs/news.html.in: Use correct release year.

12 years agobuild: fix make check of remote_protocol-structs
Laine Stump [Mon, 11 Feb 2013 20:33:03 +0000 (15:33 -0500)]
build: fix make check of remote_protocol-structs

Broken by incorrect formatting / spelling of remote_nonnull in commit
39758e7567b766f1df3948ea671d6ccb93daf7a9

12 years agoCheck if classes are derived from object
Guido Günther [Mon, 11 Feb 2013 16:10:38 +0000 (17:10 +0100)]
Check if classes are derived from object

This makes sure we don't regress to old style classes

12 years agohypervisor: Restore pm initialization
John Ferlan [Mon, 11 Feb 2013 16:03:23 +0000 (11:03 -0500)]
hypervisor: Restore pm initialization

Adjustment for 'c059cdeaf' due to older compiler complaint about pm
not being initialized even though the j&7 == 0 does the trick.

12 years agovirsh: Use virNodeDeviceLookupSCSIHostByWWN
Osier Yang [Mon, 4 Feb 2013 14:16:44 +0000 (22:16 +0800)]
virsh: Use virNodeDeviceLookupSCSIHostByWWN

Only nodedev-destroy and nodedev-dumpxml can benifit from the
new API, other commands like nodedev-detach only works for
PCI devices, WWN makes no sense for them.

12 years agonodedev: Implement virNodeDeviceLookupSCSIHostByWWN
Osier Yang [Mon, 4 Feb 2013 13:03:11 +0000 (21:03 +0800)]
nodedev: Implement virNodeDeviceLookupSCSIHostByWWN

This just simply changes nodeDeviceLookupByWWN to be not static,
and its name into nodeDeviceLookupSCSIHostByWWN. And use that for
udev and HAL backends.

12 years agoremote: Wire up the remote protocol
Osier Yang [Mon, 4 Feb 2013 13:03:10 +0000 (21:03 +0800)]
remote: Wire up the remote protocol

Like virNodeDeviceCreateXML, virNodeDeviceLookupSCSIHostByWWN
has to be treated specially when generating the RPC codes. Also
new rules are added in fixup_name to keep the name SCSIHostByWWN.

12 years agoIntroduce API virNodeDeviceLookupSCSIHostByWWN
Osier Yang [Mon, 4 Feb 2013 13:03:09 +0000 (21:03 +0800)]
Introduce API virNodeDeviceLookupSCSIHostByWWN

Since the name (like scsi_host10) is not stable for vHBA, (it can
be changed either after recreating or system rebooting), current
API virNodeDeviceLookupByName is not nice to use for management app
in this case. (E.g. one wants to destroy the vHBA whose name has
been changed after system rebooting, he has to find out current
name first).

Later patches will support the persistent vHBA via storage pool,
with which one can identify the vHBA stably by the wwnn && wwpn
pair.

So this new API comes.

12 years agoRemove re-entrant API call in SELinux/AppArmor security managers
Daniel P. Berrange [Mon, 11 Feb 2013 14:22:56 +0000 (14:22 +0000)]
Remove re-entrant API call in SELinux/AppArmor security managers

The security manager drivers are not allowed to call back
out to top level security manager APIs, since that results
in recursive mutex acquisition and thus deadlock. Remove
calls to virSecurityManagerGetModel from SELinux / AppArmor
drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agohypervisor: Revisit Coverity issues regarding cpumap
John Ferlan [Wed, 30 Jan 2013 18:09:13 +0000 (13:09 -0500)]
hypervisor: Revisit Coverity issues regarding cpumap

Turns out the issue regarding ptr_arith and sign_exension weren't false
positives. When shifting an 'unsigned char' as a target, it gets promoted
to an 'int'; however, that 'int' cannot be shifted 32 bits which was how
the algorithm was written. For the ptr_arith rather than index into the
cpumap, change the to address as necessary and assign directly.

12 years agohypervisor: Remove redundant validity checks, clean up function headers
John Ferlan [Tue, 29 Jan 2013 15:38:44 +0000 (10:38 -0500)]
hypervisor: Remove redundant validity checks, clean up function headers

Arguments for driver entry points are checked in libvirt.c, so no need to
check again. Make function entry points consistent. Don't type caste the
privateData.

12 years agoxend: Fix a memory leak found by Coverity
John Ferlan [Tue, 29 Jan 2013 14:54:16 +0000 (09:54 -0500)]
xend: Fix a memory leak found by Coverity

Commit id '87b4c10c' moved the VIR_ALLOC_N, but didn't check if 'cpuset'
had been allocated on failure.

12 years agoxend: Remove redundant validity checks, clean up function headers
John Ferlan [Tue, 29 Jan 2013 14:53:13 +0000 (09:53 -0500)]
xend: Remove redundant validity checks, clean up function headers

Arguments for driver entry points are checked in libvirt.c, so no need to
check again. Make function entry points consistent. Don't type caste the
privateData.

12 years agoxm: Remove redundant validity checks, clean up function headers
John Ferlan [Tue, 29 Jan 2013 14:24:42 +0000 (09:24 -0500)]
xm: Remove redundant validity checks, clean up function headers

Arguments for driver entry points are checked in libvirt.c, so no need to
check again. Make function entry points consistent. Don't type caste the
privateData.

12 years agoinotify: Clean up some function headers
John Ferlan [Tue, 29 Jan 2013 14:22:46 +0000 (09:22 -0500)]
inotify: Clean up some function headers

12 years agoxs: Remove redundant validity checks, clean up function headers
John Ferlan [Mon, 28 Jan 2013 22:22:28 +0000 (17:22 -0500)]
xs:  Remove redundant validity checks, clean up function headers

Arguments for driver entry points are checked in libvirt.c, so no need to
check again. Make function entry points consistent.

12 years agovirsh-snapshot: Reject --no-metadata together with --print-xml
Peter Krempa [Mon, 11 Feb 2013 13:06:08 +0000 (14:06 +0100)]
virsh-snapshot: Reject --no-metadata together with --print-xml

Manual for "virsh snapshot-create-as" states that --no-metadata and
--print-xml are incompatible. Honor this detail in the code.

12 years agovirsh-snapshot: Refactor some details in virsh snapshot-create-as
Peter Krempa [Mon, 11 Feb 2013 13:00:36 +0000 (14:00 +0100)]
virsh-snapshot: Refactor some details in virsh snapshot-create-as

This patch simplifies the creation of XML, some error paths and adds
correct approach to check for virBuffer errors.

12 years agoPass virQEMUDriverPtr into APIs managed shared disk list
Daniel P. Berrange [Wed, 6 Feb 2013 14:18:34 +0000 (14:18 +0000)]
Pass virQEMUDriverPtr into APIs managed shared disk list

Currently the APIs for managing the shared disk list take
a virHashTablePtr as the primary argument. This is bad
because it requires the caller to deal with locking of
the QEMU driver. Switch the APIs to take the full
virQEMUDriverPtr instance

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSerialize execution of security manager APIs
Daniel P. Berrange [Wed, 6 Feb 2013 12:40:41 +0000 (12:40 +0000)]
Serialize execution of security manager APIs

Add locking to virSecurityManagerXXX APIs, so that use of the
security drivers is internally serialized. This avoids the need
to rely on the global driver locks to achieve serialization

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoTurn virSecurityManager into a virObjectLockable
Daniel P. Berrange [Tue, 5 Feb 2013 17:54:55 +0000 (17:54 +0000)]
Turn virSecurityManager into a virObjectLockable

To enable locking to be introduced to the security manager
objects later, turn virSecurityManager into a virObjectLockable
class

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agosheepdog: skip refresh on creation failure
Harry Wei [Fri, 8 Feb 2013 06:48:43 +0000 (14:48 +0800)]
sheepdog: skip refresh on creation failure

Don't try to refresh Sheepdog volume if creating volume fails.

Signed-off-by: Harry Wei <harryxiyou@gmail.com>
12 years agoutil: refactor iptables command construction into multiple steps
Natanael Copa [Mon, 4 Feb 2013 09:45:23 +0000 (10:45 +0100)]
util: refactor iptables command construction into multiple steps

Instead of creating an iptables command in one shot, do it in steps
so we can add conditional options like physdev and protocol.

This removes code duplication while keeping existing behaviour.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoqemu: support vhost-net for generic ethernet devices
Laine Stump [Fri, 8 Feb 2013 17:19:09 +0000 (12:19 -0500)]
qemu: support vhost-net for generic ethernet devices

From qemu's point of view these are still just tap devices, so there's
no reason they shouldn't work with vhost-net; as a matter of fact,
Raja Sivaramakrishnan <srajag00@yahoo.com> verified on libvir-list
that at least the qemu_command.c part of this patch works:

  https://www.redhat.com/archives/libvir-list/2012-December/msg01314.html

(the hotplug case is extrapolation on my part).

12 years agonetwork_conf.c: Free xmlDoc after use
Michal Privoznik [Fri, 8 Feb 2013 14:25:03 +0000 (15:25 +0100)]
network_conf.c: Free xmlDoc after use

The virNetworkObjUpdateParseFile() function was not freeing the xml
variable, leaving us with a memory leak.