]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
9 years agoconf: Revert some code to resolve issues for hostdev hotplug
Boris Fiuczynski [Mon, 30 Nov 2015 11:05:59 +0000 (12:05 +0100)]
conf: Revert some code to resolve issues for hostdev hotplug

This patch reverts parts of commits 0d8b24f6b and 0785966d dealing with
the addition of a controller during virDomainHostdevAssignAddress. This
caused a regression for the hostdev hotplug path which assumes the
qemuDomainFindOrCreateSCSIDiskController will add the new controller
during qemuDomainAttachHostSCSIDevice to both the running domain and
the domain def controller list when the controller doesn't yet exist
(whether due to no SCSI controllers existing or the addition of a new
controller because existing ones are full).

Since commit id 0d8b24f6 will call virDomainHostdevAssignAddress during
virDomainDeviceDefPostParseInternal which is called either during domain
definition post processing (via an iterator during virDomainDefPostParse)
or directly from virDomainDeviceDefParse during hotplug, the change
broke the "side effect" of being able to add both a hostdev and controller
to the running domain.

The regression would only be seen if the running domain didn't have a
SCSI controller already defined or if the existing SCSI controller was
"full" of devices and a new controller needed to be created.

This patch will also add some extra comments to the code to avoid a
similar future change.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
9 years agovirsh: remove custom error for cpulist from cmdIOThreadPin
Ján Tomko [Thu, 3 Dec 2015 12:44:43 +0000 (13:44 +0100)]
virsh: remove custom error for cpulist from cmdIOThreadPin

Instead of the custom error:
error: iothreadpin: invalid cpulist.

use vshCommandOptStringReq and let it report a more specific error:
error: Failed to get option 'cpulist': Option argument is empty

9 years agovirsh: report errors for empty strings
Ján Tomko [Thu, 3 Dec 2015 12:42:35 +0000 (13:42 +0100)]
virsh: report errors for empty strings

Several callers were using vshCommandOptString without setting an error.
Use vshCommandOptStringReq which sets the error.

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

9 years agobridge: check for invalid MAC in networkGetDHCPLeases
Ján Tomko [Thu, 3 Dec 2015 08:47:23 +0000 (09:47 +0100)]
bridge: check for invalid MAC in networkGetDHCPLeases

Instead of comparing garbage strings against real MAC addresses,
introduce an error mesage for unparsable ones:

$ virsh net-dhcp-leases default  --mac t12
error: Failed to get leases info for default
error: invalid MAC address: t12

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

9 years agolibxl: implement virDomainInterfaceStats
Joao Martins [Mon, 23 Nov 2015 18:57:00 +0000 (18:57 +0000)]
libxl: implement virDomainInterfaceStats

Introduce support for domainInterfaceStats API call for querying
network interface statistics. Consequently it also enables the
use of `virsh domifstat <dom> <interface name>` command plus
seeing the interfaces names instead of "-" when doing
`virsh domiflist <dom>`.

After successful guest creation we fill the network
interfaces names based on domain, device id and append suffix
if it's emulated in the following form: vif<domid>.<devid>[-emu].
We extract the network interfaces info from the libxl_domain_config
object in libxlDomainCreateIfaceNames() to generate ifname. On domain
cleanup we also clear ifname, in case it was set by libvirt (i.e.
being prefixed with "vif"). We also skip these two steps in case the name
of the interface was manually inserted by the adminstrator.

For getting the interface statistics we resort to virNetInterfaceStats
and let libvirt handle the platform specific nits. Note that the latter
is not yet supported in FreeBSD.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agonetwork: selectively disable -Wcast-align in virNetDevParseDadStatus
Ian Campbell [Thu, 26 Nov 2015 15:10:12 +0000 (15:10 +0000)]
network: selectively disable -Wcast-align in virNetDevParseDadStatus

Commit 0f7436ca54c9 "network: wait for DAD to finish for bridge IPv6 addresses"
results in:

 CC     util/libvirt_util_la-virnetdevmacvlan.lo
util/virnetdev.c: In function 'virNetDevParseDadStatus':
util/virnetdev.c:1319:188: error: cast increases required alignment of target type [-Werror=cast-align]
util/virnetdev.c:1332:41: error: cast increases required alignment of target type [-Werror=cast-align]
util/virnetdev.c:1334:92: error: cast increases required alignment of target type [-Werror=cast-align]
cc1: all warnings being treated as errors

on at least ARM platforms.

The three macros involved (NLMSG_NEXT, IFA_RTA and RTA_NEXT) all appear to
correctly take care of alignment, therefore suppress Wcast-align around their
uses.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Maxim Perevedentsev <mperevedentsev@virtuozzo.com>
Cc: Laine Stump <laine@laine.org>
Cc: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Jim Fehlig <jfehlig@suse.com>
9 years agolog_manager: Include configmake.h last
Michal Privoznik [Tue, 1 Dec 2015 15:43:56 +0000 (16:43 +0100)]
log_manager: Include configmake.h last

The problem is that in some mingw header DATADIR is used but
gnulib defines it too. This leads to the following compile error:

  CC       locking/libvirt_driver_la-lock_manager.lo
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/objbase.h:66:0,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/ole2.h:17,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/wtypes.h:12,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/winscard.h:10,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/windows.h:97,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h:23,
                 from ../gnulib/lib/unistd.h:48,
                 from ../../src/util/virutil.h:29,
                 from ../../src/logging/log_manager.c:30:
/usr/i686-w64-mingw32/sys-root/mingw/include/objidl.h:12275:2: error: expected identifier or '(' before string constant
 } DATADIR;
  ^
Makefile:7888: recipe for target 'logging/libvirt_driver_la-log_manager.lo' failed

The fix is to include configmake.h at the end of includes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agotests: Run virnetdaemontest iff WITH_YAJL
Michal Privoznik [Tue, 1 Dec 2015 10:54:08 +0000 (11:54 +0100)]
tests: Run virnetdaemontest iff WITH_YAJL

The test itself and daemon require a JSON parsing library. If not
present, skip the test.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoadmin: Distribute libvirt-admin.conf
Martin Kletzander [Tue, 1 Dec 2015 10:36:37 +0000 (11:36 +0100)]
admin: Distribute libvirt-admin.conf

Commit 48cd3dfa668e5033b02dd029c2e6de558a3c4583 introduced configuration
file for libvirt-admin but forgot to distribute it.  Also the change
made to libvirt.conf in commit dbecb87f94e8f1591e3c471b34ae48a7203c9cb3
should've been removed thanks to introduction of separate config file.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Rename virAdmConnect to virAdmDaemon
Martin Kletzander [Wed, 25 Nov 2015 15:59:30 +0000 (16:59 +0100)]
admin: Rename virAdmConnect to virAdmDaemon

virAdmConnect was named after virConnect, but after some discussions,
most of the APIs called will be working with remote daemon and starting
them virAdmDaemon will make more sense.  Only possibly controversal name
is CloseCallback (de)registration, and connecting to the daemon (which
will still be Open/Close), but even this makes sense if one thinks about
the daemon being opened and closed, e.g. as file, etc.

This way all the APIs working with the daemon will start with
virAdmDaemon prefix, they will accept virAdmDaemonPtr as first parameter
and that will better suit with other namings as well (virDomain*,
virAdmServer*, etc.).

Because in virt-admin, the connection name does not refer to a struct
that would have a connect in its name, also adjust 'connname' in
clients.  And because it is not used anywhere in the vsh code, move it
from there into each client.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agospec: Temporarily disable new admin-related files
Martin Kletzander [Tue, 1 Dec 2015 10:07:59 +0000 (11:07 +0100)]
spec: Temporarily disable new admin-related files

The virt-admin binary and its man page should not yet be distributed,
but we need libvirt-common.h.  RPM build fails without specifying these.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Include admin_remote.c in the dist package
Martin Kletzander [Tue, 1 Dec 2015 07:58:02 +0000 (08:58 +0100)]
admin: Include admin_remote.c in the dist package

Otherwise all builds from the package will fail.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu_agent: fix deadlock in qemuProcessHandleAgentEOF
Wang Yufei [Sat, 26 Sep 2015 12:18:03 +0000 (20:18 +0800)]
qemu_agent: fix deadlock in qemuProcessHandleAgentEOF

If VM A is shutdown a by qemu agent at appoximately the same time
an agent EOF of VM A happened, there's a chance that deadlock may occur:

qemuProcessHandleAgentEOF in main thread
A)  priv->agent = NULL; //A happened before B

    //deadlock when we get agent lock which's held by worker thread
    qemuAgentClose(agent);

qemuDomainObjExitAgent called by qemuDomainShutdownFlags in worker thread
B)  hasRefs = virObjectUnref(priv->agent); // priv->agent is NULL,
                                           // return false
    if (hasRefs)
        virObjectUnlock(priv->agent); //agent lock will not be released here

In order to resolve, during EOF close the agent first, then set priv->agent
to NULL to fix the deadlock.

This essentially reverts commit id '1020a504'. It's also of note that commit
id '362d0477' notes a possible/rare deadlock similar to what was seen in
the monitor in commit id '25f582e3'. However, it seems interceding changes
including commit id 'd960d06f' should remove the deadlock issue.

With this change, if EOF is called:

    Get VM lock
    Check if !priv->agent || priv->beingDestroyed, then unlock VM
    Call qemuAgentClose
    Unlock VM

When qemuAgentClose is called
    Get Agent lock
    If Agent->fd open, close it
    Unlock Agent
    Unref Agent

qemuDomainObjEnterAgent
    Enter with VM lock
    Get Agent lock
    Increase Agent refcnt
    Unlock VM

After running agent command, calling qemuDomainObjExitAgent
    Enter with Agent lock
    Unref Agent
    If not last reference, unlock Agent
    Get VM lock

If we were in the middle of an EnterAgent, call Agent command, and
ExitAgent sequence and the EOF code is triggered, then the EOF code
can get the VM lock, make it's checks against !priv->agent ||
priv->beingDestroyed, and call qemuAgentClose. The CloseAgent
would wait to get agent lock. The other thread then will eventually
call ExitAgent, release the Agent lock and unref the Agent. Once
ExitAgent releases the Agent lock, AgentClose will get the Agent
Agent lock, close the fd, unlock the agent, and unref the agent.
The final unref would cause deletion of the agent.

Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Reviewed-by: Ren Guannan <renguannan@huawei.com>
9 years agobuild: Create needed folders without dependency tracking
Martin Kletzander [Mon, 30 Nov 2015 09:52:43 +0000 (10:52 +0100)]
build: Create needed folders without dependency tracking

The parameter --disable-dependency-tracking is supposed to speed up
one-time build due to the fact that it disables some dependency
extractors that, apparently, take longer time to execute.  That is a
problem for code that is generated into builddir (especially some
specific subdirectory) because the directory it should be installed to
does not exists in VPATH and without the dependency tracking is not
created.  Generating such file hence fails with -ENOENT.  In order to
keep generating files into builddir instead of srcdir, we must create
the directory ourselves.  This should finally fix the problem that is
being fixed multiple times since its introduction in commit a9fe62037214
and let us continue with cleaning those parts of Makefiles that depend
on generating files into the srcdir rather than builddir as it should
be.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoinclude: Install libvirt-common.h
Martin Kletzander [Mon, 30 Nov 2015 14:37:19 +0000 (15:37 +0100)]
include: Install libvirt-common.h

Otherwise nobody will be able to include libvirt.h.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Avoid variable named 'truncate' shadowing global declaration
Martin Kletzander [Mon, 30 Nov 2015 14:30:33 +0000 (15:30 +0100)]
util: Avoid variable named 'truncate' shadowing global declaration

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agotools: fix output of list with state-shutoff
Wei Jiangang [Mon, 30 Nov 2015 10:08:40 +0000 (18:08 +0800)]
tools: fix output of list with state-shutoff

Due to the default of flags is VIR_CONNECT_LIST_DOMAINS_ACTIVE,
It doesn't show the domains that have been shutdown when we use
'virsh list' with only --state-shutoff.

Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
9 years agoconf: Split virDomainObjList into a separate file
Michal Privoznik [Fri, 17 Jul 2015 09:11:23 +0000 (11:11 +0200)]
conf: Split virDomainObjList into a separate file

Our domain_conf.* files are big enough. Not only they contain XML
parsing code, but they served as a storage of all functions whose
name is virDomain prefixed. This is just wrong as it gathers not
related functions (and modules) into one big file which is then
harder to maintain. Split virDomainObjList module into a separate
file called virdomainobjlist.[ch].

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: build command line for virtio-input-host device
Ján Tomko [Fri, 20 Nov 2015 07:57:16 +0000 (08:57 +0100)]
qemu: build command line for virtio-input-host device

<input type='passthrough' bus='virtio'>
  <source evdev='/dev/input/event1234'/>
</input>

results in:

-device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234

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

9 years agoqemu: add passed-through input devs to cgroup ACL
Ján Tomko [Thu, 19 Nov 2015 13:32:22 +0000 (14:32 +0100)]
qemu: add passed-through input devs to cgroup ACL

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

9 years agosecurity: label the evdev for input device passthrough
Ján Tomko [Fri, 20 Nov 2015 07:25:41 +0000 (08:25 +0100)]
security: label the evdev for input device passthrough

Add functions for setting and restoring the label of input devices
to DAC and SELinux drivers.

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

9 years agoconf: add XML for input device passthrough
Ján Tomko [Mon, 16 Nov 2015 08:36:12 +0000 (09:36 +0100)]
conf: add XML for input device passthrough

Add xml for the new virtio-input-host-pci device:
<input type='passthrough' bus='virtio'>
  <source evdev='/dev/input/event1234'/>
</input>

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

9 years agoqemu: add capability for virtio-input-host-device
Ján Tomko [Fri, 13 Nov 2015 14:41:20 +0000 (15:41 +0100)]
qemu: add capability for virtio-input-host-device

Add QEMU_CAPS_VIRTIO_INPUT_HOST for both
virtio-input-host-device and virtio-input-host-pci.

9 years agoqemu: build command line for virtio input devices
Ján Tomko [Fri, 13 Nov 2015 10:38:07 +0000 (11:38 +0100)]
qemu: build command line for virtio input devices

Add support for these qemu devices:
virtio-mouse-{pci,device}
virtio-keyboard-{pci,device}
virtio-tablet-{pci,device}

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

9 years agoconf: parse and format virtio input bus in domain XML
Ján Tomko [Fri, 13 Nov 2015 10:37:12 +0000 (11:37 +0100)]
conf: parse and format virtio input bus in domain XML

To be used by the family of virtio input devices:

<input type='mouse' bus='virtio'/>
<input type='tablet' bus='virtio'/>
<input type='keyboard' bus='virtio'/>

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

9 years agoqemu: add capabilities for virtio input devices
Ján Tomko [Fri, 13 Nov 2015 10:26:37 +0000 (11:26 +0100)]
qemu: add capabilities for virtio input devices

Add capabilities for virtio-keyboard, virtio-mouse
and virtio-tablet devices:

name "virtio-keyboard-device", bus virtio-bus
name "virtio-keyboard-pci", bus PCI
name "virtio-mouse-device", bus virtio-bus
name "virtio-mouse-pci", bus PCI
name "virtio-tablet-device", bus virtio-bus
name "virtio-tablet-pci", bus PCI

Map both -device and -pci versions of the device to one capability.

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

9 years agovirlogd: fix crash if log file exists and it's larger the maxlen
Pavel Hrdina [Sat, 28 Nov 2015 08:03:40 +0000 (09:03 +0100)]
virlogd: fix crash if log file exists and it's larger the maxlen

If for some reason there is an existing log file, that is larger then
max length of log file, we need to rollover that file immediately.
Trying to figure out how much data we could write will resolve in
overflow of unsigned variable 'towrite' and this leads to segfault.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovirt-admin: Provide a man page for virt-admin
Erik Skultety [Mon, 12 Oct 2015 14:35:14 +0000 (16:35 +0200)]
virt-admin: Provide a man page for virt-admin

9 years agoadmin: Introduce virAdmConnectGetLibVersion
Erik Skultety [Mon, 5 Oct 2015 15:17:51 +0000 (17:17 +0200)]
admin: Introduce virAdmConnectGetLibVersion

Introduce a new API to get libvirt version. It is worth noting, that
libvirt-admin and libvirt share the same version number. Unfortunately,
our existing API isn't generic enough to be used with virAdmConnectPtr
as well. Also this patch wires up this API to the virt-admin client
as a generic cmdVersion command.

9 years agoadmin: Add support for connection close callbacks
Erik Skultety [Mon, 12 Oct 2015 15:10:57 +0000 (17:10 +0200)]
admin: Add support for connection close callbacks

As we need a client disconnect handler, we also need a mechanism to register
such handlers for a client. This patch introduced both the close callbacks and
also the client vshAdmCatchDisconnect handler to be registered with it. By
registering the handler we still need to make sure the client can react to
daemon's events like disconnect or keepalive, so asynchronous I/O event polling
is necessary to be enabled too.

9 years agoadmin: Add support for URI aliases
Erik Skultety [Fri, 30 Oct 2015 11:11:52 +0000 (12:11 +0100)]
admin: Add support for URI aliases

Now that we introduced URI support in libvirt-admin, we should also support URI
aliases during connection establishment phase. After applying this patch,
virAdmConnectOpen will also support VIR_CONNECT_NO_ALIASES flag.

9 years agolivirt: Move URI alias matching to util
Erik Skultety [Fri, 6 Nov 2015 09:44:53 +0000 (10:44 +0100)]
livirt: Move URI alias matching to util

As we need to provide support for URI aliases in libvirt-admin as well, URI
alias matching needs to be internally visible. Since
virConnectOpenResolveURIAlias does have a compatible signature, it could be
easily reused by libvirt-admin. This patch moves URI alias matching to util,
renaming it accordingly.

9 years agoadmin: Add URI support and introduce virAdmGetDefaultURI
Erik Skultety [Mon, 12 Oct 2015 14:07:52 +0000 (16:07 +0200)]
admin: Add URI support and introduce virAdmGetDefaultURI

Since virt-admin should be able to connect to various admin servers
on hosted different daemons, we need to provide URI support to
libvirt-admin.

9 years agoadmin: Do not generate remoteAdminConnect{Open,Close}
Erik Skultety [Mon, 12 Oct 2015 15:08:29 +0000 (17:08 +0200)]
admin: Do not generate remoteAdminConnect{Open,Close}

As we plan to add more and more logic to remote connecting methods,
these cannot be generated from admin_protocol.x anymore. Instead,
this patch implements these to methods explicitly.

9 years agoadmin: Move remote admin API version to a separate module
Erik Skultety [Thu, 15 Oct 2015 12:48:58 +0000 (14:48 +0200)]
admin: Move remote admin API version to a separate module

By moving the remote version into a separate module, we gain a slightly
better maintainability in the long run than just by leaving it in one
place with the existing libvirt-admin library which can start getting
pretty messy later on.

9 years agoadmin: Introduce virAdmConnectIsAlive
Erik Skultety [Wed, 14 Oct 2015 13:10:02 +0000 (15:10 +0200)]
admin: Introduce virAdmConnectIsAlive

Since most of our APIs rely on an acive functional connection to a daemon and
we have such a mechanism in libvirt already, there's need to have such a way in
libvirt-admin as well. By introducing a new public API, this patch provides
support to check for an active connection.

9 years agovirt-admin: Introduce first working skeleton
Erik Skultety [Mon, 12 Oct 2015 15:07:21 +0000 (17:07 +0200)]
virt-admin: Introduce first working skeleton

This patch introduces virt-admin client which is based on virsh client,
but had to reimplement several methods to meet virt-admin specific needs
or remove unnecessary virsh specific logic.

9 years agoadmin: introduce virAdmGetVersion
Erik Skultety [Thu, 26 Nov 2015 14:08:36 +0000 (15:08 +0100)]
admin: introduce virAdmGetVersion

Unfortunately, client side version retrieval API virGetVersion uses
one-time initialization (due to the fact we might not have initialized the
library by calling connect prior to this) which is not completely compatible
with admin initialization. This API is rather simplistic and reimplementing
it for admin might be the preferred method of reusing it. Note that even though
the method will be reimplemented, the version number is still the same for both
the libvirt and libvirt-admin library.

9 years agolibvirt: Move config getters to util
Erik Skultety [Mon, 12 Oct 2015 14:09:53 +0000 (16:09 +0200)]
libvirt: Move config getters to util

virConnectGetConfig and virConnectGetConfigPath were static libvirt
methods, merely because there hasn't been any need for having them
internally exported yet. Since libvirt-admin also needs to reference
its config file, 'xGetConfig' should be exported.
Besides moving, this patch also renames the methods accordingly,
as they are libvirt config specific.

9 years agoadmin: Introduce libvirt-admin.conf
Erik Skultety [Thu, 12 Nov 2015 14:30:43 +0000 (15:30 +0100)]
admin: Introduce libvirt-admin.conf

Since libvirt-admin is a separate library, it should also have a separate
config file. Available settings are currently the same as for libvirt.conf.

9 years agolibvirt: introduce libvirt/libvirt-common.h.in
Erik Skultety [Thu, 26 Nov 2015 14:02:49 +0000 (15:02 +0100)]
libvirt: introduce libvirt/libvirt-common.h.in

As it turned out, we need to share some enums and declarations between
libvirt.h and libvirt-admin.h, but since our policy forbids direct includes of
libvirt*.h, there has to be some header exempt from this rule. This patch moves
the relevant part of code from libvirt.h.in to libvirt-common.h.in. Moreover,
since there is no need to have libvirt.h generated anymore, introduce a new
header libvirt.h which was previosly ignored from git and make the common
header ignored and generated instead.

9 years agoqemu: add virtio-gpu virgl support
Marc-André Lureau [Wed, 25 Nov 2015 08:42:33 +0000 (09:42 +0100)]
qemu: add virtio-gpu virgl support

Check if virtio-gpu provides virgl option, and add qemu command line
formatter.

It is enabled with the existing accel3d attribute:
<model type='virtio' heads='1'>
 <acceleration accel3d='yes'/>
</model>

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: add virtio video device
Marc-André Lureau [Wed, 25 Nov 2015 08:42:32 +0000 (09:42 +0100)]
qemu: add virtio video device

qemu 2.5 provides virtio video device.  It can be used with -device
virtio-vga for primary devices, or -device virtio-gpu for non-vga
devices. However, only the primary device (VGA) is supported with this
patch.

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

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodomain: replace bool accel{2d, 3d} with a tristate
Marc-André Lureau [Wed, 25 Nov 2015 08:42:31 +0000 (09:42 +0100)]
domain: replace bool accel{2d, 3d} with a tristate

Allowing to have the extra undefined/default state.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoReplace support{2d,3d} with accel{2d,3d}
Marc-André Lureau [Wed, 25 Nov 2015 08:42:30 +0000 (09:42 +0100)]
Replace support{2d,3d} with accel{2d,3d}

Following the domain XML naming

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
9 years agosystemd: Escape only needed characters for machined
Martin Kletzander [Fri, 27 Nov 2015 13:24:38 +0000 (14:24 +0100)]
systemd: Escape only needed characters for machined

Machine name escaping follows the same rules as serice name escape,
except that '.' and '-' must not be escaped in machine names, due
to a bug in systemd-machined.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirtlogd: Fix build without DBus
Martin Kletzander [Fri, 27 Nov 2015 13:00:39 +0000 (14:00 +0100)]
virtlogd: Fix build without DBus

The rule for virrotatingfiletest was defined in DBUS-only block even
though the test does not use DBus at all.  Also DBUS_CFLAGS and
DBUS_LIBS are removed from the rules.  The original error was:

/usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/../../../../lib64/Scrt1.o: In
function `_start':
(.text+0x20): undefined reference to `main'

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agologging: remove reference to non-existent augeas files
Daniel P. Berrange [Fri, 27 Nov 2015 14:24:25 +0000 (14:24 +0000)]
logging: remove reference to non-existent augeas files

The libvirt_logd.aug and test_libvirt_logd.aug.in files
have never existed so shouldn't be in EXTRA_DIST. It was
a copy+paste mistake when closing virtlogd from virtlockd

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: avoid variables called 'daemon' due to function clash
Daniel P. Berrange [Fri, 27 Nov 2015 09:26:46 +0000 (09:26 +0000)]
logging: avoid variables called 'daemon' due to function clash

With some versions of GLibC / GCC, a variable called 'daemon'
will result in a warning about clashing with the function also
named 'daemon'. Rename it to 'dmn' to avoid the clash.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agovirtlogd: use %llu to print 64bit types
Guido Günther [Thu, 26 Nov 2015 17:00:09 +0000 (18:00 +0100)]
virtlogd: use %llu to print 64bit types

Otherwise we fail on 32bit with:

CC     logging/virtlogd-log_daemon_dispatch.o
logging/log_daemon_dispatch.c: In function 'virLogManagerProtocolDispatchDomainReadLogFile':
logging/log_daemon_dispatch.c:120:9: error: format '%zu' expects argument of type 'size_t', but argument 7 has type 'uint64_t' [-Werror=format]

9 years agovirtlockd: fix misc memory leaks and other bugs
Daniel P. Berrange [Tue, 24 Nov 2015 13:16:23 +0000 (13:16 +0000)]
virtlockd: fix misc memory leaks and other bugs

Fix memory leaks, failure to restore umask and missing man
page docs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: inhibit virtlogd shutdown while log files are open
Daniel P. Berrange [Tue, 24 Nov 2015 11:47:41 +0000 (11:47 +0000)]
logging: inhibit virtlogd shutdown while log files are open

The virtlogd daemon is launched with a 30 second timeout for
unprivileged users. Unfortunately the timeout is only inhibited
while RPC clients are connected, and they only connect for a
short while to open the log file descriptor. We need to hold
an inhibition for as long as the log file descriptor itself
is open.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: add support for sending QEMU stdout/stderr to virtlogd
Daniel P. Berrange [Tue, 3 Nov 2015 11:13:25 +0000 (11:13 +0000)]
qemu: add support for sending QEMU stdout/stderr to virtlogd

Currently the QEMU stdout/stderr streams are written directly to
a regular file (eg /var/log/libvirt/qemu/$GUEST.log). While those
can be rotated by logrotate (using copytruncate option) this is
not very efficient. It also leaves open a window of opportunity
for a compromised/broken QEMU to DOS the host filesystem by
writing lots of text to stdout/stderr.

This makes it possible to connect the stdout/stderr file handles
to a pipe that is provided by virtlogd. The virtlogd daemon will
read from this pipe and write data to the log file, performing
file rotation whenever a pre-determined size limit is reached.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: convert monitor to use qemuDomainLogContextPtr indirectly
Daniel P. Berrange [Thu, 12 Nov 2015 13:54:04 +0000 (13:54 +0000)]
qemu: convert monitor to use qemuDomainLogContextPtr indirectly

Currently the QEMU monitor is given an FD to the logfile. This
won't work in the future with virtlogd, so it needs to use the
qemuDomainLogContextPtr instead, but it shouldn't directly
access that object either. So define a callback that the
monitor can use for reporting errors from the log file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: convert process stop/attach to use qemuDomainLogContextPtr
Daniel P. Berrange [Thu, 12 Nov 2015 13:21:47 +0000 (13:21 +0000)]
qemu: convert process stop/attach to use qemuDomainLogContextPtr

When the qemuProcessAttach/Stop methods write a marker into
the log file, they can use qemuDomainLogContextWrite to
write a formatted message.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: convert qemuLogOperation to take a qemuDomainLogContextPtr
Daniel P. Berrange [Thu, 12 Nov 2015 13:02:46 +0000 (13:02 +0000)]
qemu: convert qemuLogOperation to take a qemuDomainLogContextPtr

Instead of writing directly to a log file descriptor, change
qemuLogOperation to use qemuDomainLogContextWrite().

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: change qemuDomainTaint APIs to accept qemuDomainLogContextPtr
Daniel P. Berrange [Thu, 12 Nov 2015 12:56:30 +0000 (12:56 +0000)]
qemu: change qemuDomainTaint APIs to accept qemuDomainLogContextPtr

The qemuDomainTaint APIs currently expect to be passed a log file
descriptor. Change them to instead use a qemuDomainLogContextPtr
to hide the implementation details.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: convert log file creation to use qemuDomainLogContextPtr
Daniel P. Berrange [Thu, 12 Nov 2015 14:28:36 +0000 (14:28 +0000)]
qemu: convert log file creation to use qemuDomainLogContextPtr

Convert the places which create/open log files to use the new
qemuDomainLogContextPtr object instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: introduce a qemuDomainLogContext object
Daniel P. Berrange [Thu, 12 Nov 2015 12:43:29 +0000 (12:43 +0000)]
qemu: introduce a qemuDomainLogContext object

Introduce a qemuDomainLogContext object to encapsulate
handling of I/O to/from the domain log file. This will
hide details of the log file implementation from the
rest of the driver, making it easier to introduce
support for virtlogd later.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: unify code for reporting errors from QEMU log files
Daniel P. Berrange [Thu, 12 Nov 2015 11:01:07 +0000 (11:01 +0000)]
qemu: unify code for reporting errors from QEMU log files

There are two pretty similar functions qemuProcessReadLog and
qemuProcessReadChildErrors. Both read from the QEMU log file
and try to strip out libvirt messages. The latter then reports
an error, while the former lets the callers report an error.

Re-write qemuProcessReadLog so that it uses a single read
into a dynamically allocated buffer. Then introduce a new
qemuProcessReportLogError that calls qemuProcessReadLog
and reports an error.

Convert all callers to use qemuProcessReportLogError.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: remove writing to QEMU log file for rename operation
Daniel P. Berrange [Wed, 11 Nov 2015 16:06:07 +0000 (16:06 +0000)]
qemu: remove writing to QEMU log file for rename operation

The rename operation only works on inactive virtual machines,
but it none the less writes to the log file used by the QEMU
processes. This log file is not intended to provide a general
purpose audit trail of operations performed on VMs. The audit
subsystem has recording of important operations. If we want
to extend that to cover all significant public APIs that is
a valid thing to consider, but we shouldn't arbitrarily log
specific APIs into the QEMU log file in the meantime.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: add client for virtlogd daemon
Daniel P. Berrange [Tue, 3 Nov 2015 11:09:25 +0000 (11:09 +0000)]
logging: add client for virtlogd daemon

Add the virLogManager API which allows for communication with
the virtlogd daemon to RPC program. This provides the client
side API to open log files for guest domains.

The virtlogd daemon is setup to auto-spawn on first use when
running unprivileged. For privileged usage, systemd socket
activation is used instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: introduce log handling protocol
Daniel P. Berrange [Tue, 3 Nov 2015 11:01:21 +0000 (11:01 +0000)]
logging: introduce log handling protocol

Define a new RPC protocol for the virtlogd daemon that provides
for handling of logs. The initial RPC method defined allows a
client to obtain a file handle to use for writing to a log
file for a guest domain. The file handle passed back will not
actually refer to the log file, but rather an anonymous pipe.
The virtlogd daemon will forward I/O between them, ensuring
file rotation happens when required.

Initially the log setup is hardcoded to cap log files at
128 KB, and keep 3 backups when rolling over, which gives
a max usage of 512 KB per guest.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoImport stripped down virtlockd code as basis of virtlogd
Daniel P. Berrange [Mon, 9 Feb 2015 16:35:05 +0000 (16:35 +0000)]
Import stripped down virtlockd code as basis of virtlogd

Copy the virtlockd codebase across to form the initial virlogd
code. Simple search & replace of s/lock/log/ and gut the remote
protocol & dispatcher. This gives us a daemon that starts up
and listens for connections, but does nothing with them.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoutil: add APIs for reading/writing from/to rotating files
Daniel P. Berrange [Fri, 6 Nov 2015 14:25:48 +0000 (14:25 +0000)]
util: add APIs for reading/writing from/to rotating files

Add virRotatingFileReader and virRotatingFileWriter objects
which allow reading & writing from/to files with automation
rotation to N backup files when a size limit is reached. This
is useful for guest logging when a guaranteed finite size
limit is required. Use of external tools like logrotate is
inadequate since it leaves the possibility for guest to DOS
the host in between invokations of logrotate.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agosystemd: Escape machine name for machined
Martin Kletzander [Tue, 24 Nov 2015 14:56:12 +0000 (15:56 +0100)]
systemd: Escape machine name for machined

According to the documentation, CreateMachine accepts only 7bit ASCII
characters in the machinename parameter, so let's make sure we can start
machines with unicode names with systemd.  We already have a function
for that, we just forgot to use it.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirsh: Try to keep printed XML pretty with change-media
Martin Kletzander [Fri, 6 Nov 2015 14:11:36 +0000 (15:11 +0100)]
virsh: Try to keep printed XML pretty with change-media

When adding a new media with change-media and --print-xml, let's try
making it more readable and nice.

Before:
<disk type="file" device="cdrom">
...
      <target dev="hdb" bus="ide"/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    <source file="/tmp/a.iso"/></disk>

After:
<disk type="file" device="cdrom">
...
      <source file="/tmp/a.iso"/>
      <target dev="hdb" bus="ide"/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    </disk>

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoschema: use a better regex for listen addresses
Ján Tomko [Thu, 26 Nov 2015 09:39:54 +0000 (10:39 +0100)]
schema: use a better regex for listen addresses

A domain with '::' as the listen address fails to validate.

Reuse the 'ipAddr' and 'dnsName' regexes from basictypes instead
of reinventing them.

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

9 years agoEnhance documentation of virDomainDetachDevice
Jiri Denemark [Wed, 25 Nov 2015 15:39:17 +0000 (16:39 +0100)]
Enhance documentation of virDomainDetachDevice

Link it to virDomainDetachDeviceFlags.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Use qemuProcessLaunch in migration Prepare phase
Jiri Denemark [Tue, 10 Nov 2015 12:43:04 +0000 (13:43 +0100)]
qemu: Use qemuProcessLaunch in migration Prepare phase

Using qemuProcess{Init,Launch,FinishStartup} allows us to run
pre-migration commands on destination before asking QEMU to wait for
incoming migration data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Skip starting NBD servers for offline migration
Jiri Denemark [Tue, 10 Nov 2015 11:56:29 +0000 (12:56 +0100)]
qemu: Skip starting NBD servers for offline migration

NBD storage migration will not work with offline migration anyway and we
already checked that the user did not ask for it. Thus it doesn't make
sense to keep the code after 'done' label where we jump in case of
offline migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Kill QEMU process if Prepare phase fails
Jiri Denemark [Tue, 10 Nov 2015 11:41:01 +0000 (12:41 +0100)]
qemu: Kill QEMU process if Prepare phase fails

Some failure paths in qemuMigrationPrepareAny forgot to kill the just
started QEMU process. This patch fixes this by combining 'stop' and
'endjob' label into a new label 'stopjob'. This name was chosen to avoid
confusion with the most common semantics of 'endjob'. Normally, 'endjob'
is always called at the end of an API to stop the job we entered at the
beginning. In qemuMigrationPrepareAny we only want to stop the job in
failure path; on success we need to carry the job over to the Finish
phase.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate incoming URI generation from qemuMigrationPrepareAny
Jiri Denemark [Thu, 5 Nov 2015 14:21:02 +0000 (15:21 +0100)]
qemu: Separate incoming URI generation from qemuMigrationPrepareAny

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessFinishStartup
Jiri Denemark [Tue, 10 Nov 2015 12:29:40 +0000 (13:29 +0100)]
qemu: Introduce qemuProcessFinishStartup

Finishes starting a new domain launched by qemuProcessLaunch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessLaunch
Jiri Denemark [Tue, 10 Nov 2015 15:58:41 +0000 (16:58 +0100)]
qemu: Introduce qemuProcessLaunch

Once qemuProcessInit was called, qemuProcessLaunch will launch a new
QEMU process with stopped virtual CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessInit
Jiri Denemark [Tue, 10 Nov 2015 15:58:12 +0000 (16:58 +0100)]
qemu: Introduce qemuProcessInit

qemuProcessStart is going to be split in three parts: qemuProcessInit,
qemuProcessLaunch, and qemuProcessFinish so that migration Prepare phase
can insert additional code in the process. qemuProcessStart will be a
small wrapper for all other callers.

qemuProcessInit prepares the domain up to the point when priv->qemuCaps
is initialized.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoconf: reject multiple panic devices of same model
Dmitry Andreev [Tue, 24 Nov 2015 12:26:38 +0000 (15:26 +0300)]
conf: reject multiple panic devices of same model

Only one panic device per model is allowed.

9 years agoAllow multiple panic devices
Dmitry Andreev [Tue, 24 Nov 2015 12:26:36 +0000 (15:26 +0300)]
Allow multiple panic devices

'model' attribute was added to a panic device but only one panic
device is allowed. This patch changes panic device presence
from 'optional' to 'zeroOrMore'.

9 years agoqemu: add support for hv_crash feature as a panic device
Dmitry Andreev [Tue, 24 Nov 2015 12:26:33 +0000 (15:26 +0300)]
qemu: add support for hv_crash feature as a panic device

Panic device type used depends on 'model' attribute.

If no model is specified then device type depends on hypervisor
and guest arch. 'pseries' model is used for pSeries guest and
'isa' model is used in other cases.

XML:
<devices>
  <panic model='hyperv'/>
</devices>

QEMU command line:
qemu -cpu <cpu_model>,hv_crash

9 years agotests: add tests for the new panic device attribute - 'model'
Dmitry Andreev [Tue, 24 Nov 2015 12:26:32 +0000 (15:26 +0300)]
tests: add tests for the new panic device attribute - 'model'

9 years agoconf: add 'model' attribute for panic device with values isa, pseries, hyperv
Dmitry Andreev [Tue, 24 Nov 2015 12:26:31 +0000 (15:26 +0300)]
conf: add 'model' attribute for panic device with values isa, pseries, hyperv

Libvirt already has two types of panic devices - pvpanic and pSeries firmware.
This patch introduces the 'model' attribute and a new type of panic device.

'isa' model is for ISA pvpanic device.
'pseries' model is a default value for pSeries guests.
'hyperv' model is the new type. It's used for Hyper-V crash.

Schema and docs are updated for the new attribute.

9 years agoconf: refactor code for checking ABI stability of panic device
Dmitry Andreev [Tue, 24 Nov 2015 12:26:30 +0000 (15:26 +0300)]
conf: refactor code for checking ABI stability of panic device

9 years agoapparmor: add missing qemu binaries
Guido Günther [Tue, 24 Nov 2015 15:04:18 +0000 (16:04 +0100)]
apparmor: add missing qemu binaries

This adds the qemu binaries as of 1.2.4 in Debian. It also removes a
duplicate sparc64 entry.

9 years agonodedev: report maxCount for virtual_functions capability
Laine Stump [Mon, 23 Nov 2015 19:19:13 +0000 (14:19 -0500)]
nodedev: report maxCount for virtual_functions capability

A PCI device may have the capability to setup virtual functions (VFs)
but have them currently all disabled. Prior to this patch, if that was
the case the the node device XML for the device wouldn't report any
virtual_functions capability.

With this patch, if a file called "sriov_totalvfs" is found in the
device's sysfs directory, its contents will be interpreted as a
decimal number, and that value will be reported as "maxCount" in a
capability element of the device's XML, e.g.:

   <capability type='virtual_functions' maxCount='7'/>

This will be reported regardless of whether or not any VFs are
currently enabled for the device.

NB: sriov_numvfs (the number of VFs currently active) is also
available in sysfs, but that value is implied by the number of items
in the list that is inside the capability element, so there is no
reason to explicitly provide it as an attribute.

sriov_totalvfs and sriov_numvfs are available in kernels at least as far
back as the 2.6.32 that is in RHEL6.7, but in the case that they
simply aren't there, libvirt will behave as it did prior to this patch
- no maxCount will be displayed, and the virtual_functions capability
will be absent from the device's XML when 0 VFs are enabled.

9 years agoconf: support reporting maxCount attribute for virtual_functions cap
Laine Stump [Mon, 23 Nov 2015 19:50:31 +0000 (14:50 -0500)]
conf: support reporting maxCount attribute for virtual_functions cap

Report the maximum possible number of VFs for an SRIOV PF, like this:

   <capability type='virtual_functions' maxCount='7'>
      ...
   </capability>

I've just discovered that the virtual_functions and physical_functions
capabilities are not supported in the virNodeDeviceParse functions,
only in virNodeDeviceFormat (I suppose because they are only reported,
not set from XML). This should probably be remedied, but is less
immediately useful than the current patch.

9 years agoqemu: monitor: Explain logic of qemuMonitorGetCPUInfo
Peter Krempa [Thu, 29 Oct 2015 13:30:23 +0000 (14:30 +0100)]
qemu: monitor: Explain logic of qemuMonitorGetCPUInfo

The return value has non-obvious semantics. Document it.

9 years agoPost-release version bump to 1.3.0
Pavel Hrdina [Tue, 24 Nov 2015 11:48:50 +0000 (12:48 +0100)]
Post-release version bump to 1.3.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoconf: Drop useless check when parsing cpu scheduler info
Peter Krempa [Mon, 19 Oct 2015 12:36:14 +0000 (14:36 +0200)]
conf: Drop useless check when parsing cpu scheduler info

The checked predicate is a deduction from the following checks:

1) maximum cpu id is checked for every parsed <vcpusched> element
2) the resulting bitmaps are checked for overlaps
3) there has to be at least one cpu per <vcpusched>

From the above checks we can indeed deduce that if we have one
<vcpusched> element per CPU we will have at most 'maxvcpus' of them.

Drop the explicit check since it's redundant.

9 years agoqemu: pass the asyncJob to qemuProcessStartCPUs
Ján Tomko [Tue, 24 Nov 2015 12:14:29 +0000 (13:14 +0100)]
qemu: pass the asyncJob to qemuProcessStartCPUs

Now that new domains are started inside a QEMU_ASYNC_JOB_START job,
we need to pass it down to qemuProcessStartCPUs too.

This removes the warning:
qemuDomainObjEnterMonitorInternal:1750 : This thread seems to be the
async job owner; entering monitor without asking for a nested job is
dangerous

Introduced by commit 04c721f, before that this code path was only
executed with QEMU_ASYNC_JOB_NONE.

(This code is not executed on migration, because qemuMigrationPrepareAny
 sets the VIR_QEMU_PROCESS_START_PAUSED flag.)

9 years agoxenapi: Refactor extraction of vcpu count
Peter Krempa [Fri, 16 Oct 2015 13:38:48 +0000 (15:38 +0200)]
xenapi: Refactor extraction of vcpu count

To simplify further refactors change the way the vcpu count is extracted
to use a temp variable rather than juggling with def->maxvcpus.

9 years agophyp: Refactor extraction of vcpu count
Peter Krempa [Fri, 16 Oct 2015 13:38:48 +0000 (15:38 +0200)]
phyp: Refactor extraction of vcpu count

To simplify further refactors change the way the vcpu count is extracted
to use a temp variable rather than juggling with def.maxvcpus.

9 years agoopenvz: Refactor extraction of vcpu count
Peter Krempa [Fri, 16 Oct 2015 13:38:48 +0000 (15:38 +0200)]
openvz: Refactor extraction of vcpu count

To simplify further refactors change the way the vcpu count is extracted
to use a temp variable rather than juggling with def->maxvcpus.

9 years agohyperv: Allocate 'def' via virDomainDefNew
Peter Krempa [Mon, 19 Oct 2015 17:06:55 +0000 (19:06 +0200)]
hyperv: Allocate 'def' via virDomainDefNew

Use the helper that is necessary to fill out some values rather than
allocating it directly.

9 years agodocument virCommandRunRegex function
Christian Loehle [Mon, 23 Nov 2015 14:06:37 +0000 (15:06 +0100)]
document virCommandRunRegex function

Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoqemuSetupChrSourceCgroup: rename dev to source
Ján Tomko [Thu, 19 Nov 2015 15:26:56 +0000 (16:26 +0100)]
qemuSetupChrSourceCgroup: rename dev to source

We do not have a pointer to the device here, just its source.

9 years agoSimplify qemuSetupChrSourceCgroup and its callers
Ján Tomko [Thu, 19 Nov 2015 13:25:44 +0000 (14:25 +0100)]
Simplify qemuSetupChrSourceCgroup and its callers

The domain definition is not needed in any of these functions.
Only pass it to qemuSetupChardevCgroup, which is used as a callback
for virDomainChrDefForeach.

Use the right type for passing virDomainObjPtr instead of
void* where possible.

9 years agorename qemuSetupHostdevCGroup to qemuSetupHostdevCgroup
Ján Tomko [Thu, 19 Nov 2015 13:35:46 +0000 (14:35 +0100)]
rename qemuSetupHostdevCGroup to qemuSetupHostdevCgroup

Change CGroup to Cgroup to match other functions in the file.

9 years agoqemu: handle more machines with a single builtin IDE controller
Guido Günther [Sat, 21 Nov 2015 18:58:56 +0000 (19:58 +0100)]
qemu: handle more machines with a single builtin IDE controller

like I440FX by moving the condition into qemuDomainMachineHasBuiltinIDE
and adding more machines.

Reference: http://bugs.debian.org/805189

9 years agostorage: Change virStorageBackendVolOpen to use virFileOpenAs
John Ferlan [Tue, 17 Nov 2015 15:13:43 +0000 (10:13 -0500)]
storage: Change virStorageBackendVolOpen to use virFileOpenAs

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

Rather than using just open on the path, allow for the possibility that
the path to be opened resides on an NFS root-squash target and was created
under a different uid/gid.

Without using virFileOpenAs an attempt to get the volume size data may fail
if the current user doesn't have permissions to read the volume, such as
would be the case if mode wasn't supplied in the volume XML and the default
VIR_STORAGE_DEFAULT_VOL_PERM_MODE (e.g. 0600) was used. Under this scenario
the owner/group is not root:root, thus this path run under root would fail
to open/read the volume.

NB: The virFileOpenAs code using OPEN_FORK will only work when the failure
is not EACESS/EPERM and the path resolves to a shared file system.

9 years agostorage: Really fix setting mode for backend exec in NFS root-squash env
John Ferlan [Tue, 17 Nov 2015 13:49:19 +0000 (08:49 -0500)]
storage: Really fix setting mode for backend exec in NFS root-squash env

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

Although commit id '77346f27' resolves part of the problem regarding creating
a qemu-img image in an NFS root-squash environment, it really didn't fix the
entire problem. Unfortunately it only masked the problem. It seems qemu-img
must open/create the image using 0644, which if used by target.perms would
result in the chmod not being called since the mode desired and set match.

Although qemu-img could conceivably ignore the mode when creating, libvirt
has more knowledge of the environment and can make the adjustment to the
mode far more easily by using virFileOpenAs with VIR_FILE_OPEN_FORCE_MODE.
If that's successful, then we know on return the file will have the right
owner and mode, so we can declare success