Commit Graph

428 Commits

Author SHA1 Message Date
Jim Fehlig
c0d3f608d6 libxl: support soundhw for hvm domains
The xend driver and the parsing/formating code in src/xenconfig
have long supported soundhw.  Add support in the libxl driver too.
2015-05-05 09:19:37 -06:00
Jim Fehlig
198cc1d339 libxl: provide integration with lock manager
Provide integration with libvirt's lock manager in the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-29 10:51:36 -06:00
Olaf Hering
bb5fc7214e libxl: remove duplicate check for pci subsystem type
Both attach and detach functions get called only if the type matches.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
2015-04-24 15:22:20 -06:00
Olaf Hering
f54391b447 libxl: use pci init and dispose functions
Rearrange code so that the local variable is always initialized and
disposed.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
2015-04-24 15:02:08 -06:00
Jim Fehlig
247b2c5388 libxl: initialize sdl.opengl defbool in libxlMakeVfb
Commit bf32462b missed initializing sdl.opengl.  Without the
initialization, libvirtd will be terminated by an assert from libxl:

Assertion `!libxl_defbool_is_default(db)' failed.

Reported-by: Olaf Hering <olaf@aepfle.de>
2015-04-24 14:11:26 -06:00
Olaf Hering
bf32462bd3 libxl: initialize vfb defbools in libxlMakeVfb
If the domU configu has sdl enabled libvirtd crashes:
libvirtd[5158]: libvirtd: libxl.c:343: libxl_defbool_val:
Assertion `!libxl_defbool_is_default(db)' failed.

Initialize the relevant defbool variables in libxl_device_vfb.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
2015-04-24 13:17:36 -06:00
Michal Privoznik
620ff93bd3 virDomainObjListFindByName: Return referenced object
Every domain that grabs a domain object to work over should
reference it to make sure it won't disappear meanwhile.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-24 13:22:45 +02:00
Jim Fehlig
d0baac09e6 libxl: Introduce configuration file for libxl driver
Introduce libxl.conf configuration file, adding the 'autoballoon'
setting as the first knob for controlling the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-21 14:23:40 -06:00
Cole Robinson
835cf84b7e domain: conf: Drop expectedVirtTypes
This needs to specified in way too many places for a simple validation
check. The ostype/arch/virttype validation checks later in
DomainDefParseXML should catch most of the cases that this was covering.
2015-04-20 16:43:43 -04:00
Cole Robinson
4fa6f9b413 caps: Convert to use VIR_DOMAIN_VIRT internally 2015-04-20 16:40:26 -04:00
Cole Robinson
5f7c599456 domain: Convert os.type to VIR_DOMAIN_OSTYPE enum 2015-04-20 16:40:09 -04:00
Cole Robinson
d0440e3269 caps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value
Rather than an opencoded string. This should be a no-op
2015-04-20 16:38:09 -04:00
Jim Fehlig
6dfec1efba libxl: drop virDomainObj lock when destroying a domain
A destroy operation can take considerable time on large memory
domains due to scrubbing the domain's memory.  Unlock the
virDomainObj while libxl_domain_destroy is executing.

Implement libxlDomainDestroyInternal wrapper to handle unlocking,
calling destroy, and locking.  Change all callers of
libxl_domain_destroy to use the wrapper.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-16 16:43:19 -06:00
Jim Fehlig
894d2ff759 libxl: acquire a job when destroying a domain
A job should be acquired at the beginning of a domain destroy operation,
not at the end when cleaning up the domain.  Fix two occurrences of this
late job acquisition in the libxl driver.  Doing so renders
libxlDomainCleanupJob unused, so it is removed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-16 16:43:18 -06:00
Jim Fehlig
f86ae40324 libxl: Move job acquisition in libxlDomainStart to callers
Let callers of libxlDomainStart decide when it is appropriate to
acquire a job on the associated virDomainObj.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-16 16:42:53 -06:00
Jim Fehlig
13e2c22099 libxl: support HVM direct kernel boot
Add support for HVM direct kernel boot in libxl.  Also add a
test to verify domXML <-> native conversions.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-16 16:14:51 -06:00
Jim Fehlig
d685c0f91b libxl: fix dom0 balloon logic
Recent testing on large memory systems revealed a bug in the Xen xl
tool's freemem() function.  When autoballooning is enabled, freemem()
is used to ensure enough memory is available to start a domain,
ballooning dom0 if necessary.  When ballooning large amounts of memory
from dom0, freemem() would exceed its self-imposed wait time and
return an error.  Meanwhile, dom0 continued to balloon.  Starting the
domain later, after sufficient memory was ballooned from dom0, would
succeed.  The libvirt implementation in libxlDomainFreeMem() suffers
the same bug since it is modeled after freemem().

In the end, the best place to fix the bug on the Xen side was to
slightly change the behavior of libxl_wait_for_memory_target().
Instead of failing after caller-provided wait_sec, the function now
blocks as long as dom0 memory ballooning is progressing.  It will return
failure only when more memory is needed to reach the target and wait_sec
have expired with no progress being made.  See xen.git commit fd3aa246.
There was a dicussion on how this would affect other libxl apps like
libvirt

http://lists.xen.org/archives/html/xen-devel/2015-03/msg00739.html

If libvirt containing this patch was build against a Xen containing
the old libxl_wait_for_memory_target() behavior, libxlDomainFreeMem()
will fail after 30 sec and domain creation will be terminated.
Without this patch and with old libxl_wait_for_memory_target() behavior,
libxlDomainFreeMem() does not succeed after 30 sec, but returns success
anyway.  Domain creation continues resulting in all sorts of fun stuff
like cpu soft lockups in the guest OS.  It was decided to properly fix
libxl_wait_for_memory_target(), and if anything improve the default
behavior of apps using the freemem reference impl in xl.

xl was patched to accommodate the change in libxl_wait_for_memory_target()
with xen.git commit 883b30a0.  This patch does the same in the libxl
driver.  While at it, I changed the logic to essentially match
freemem() in $xensrc/tools/libxl/xl_cmdimpl.c.  It was a bit cleaner
IMO and will make it easier to spot future, potentially interesting
divergences.
2015-04-02 09:41:03 -06:00
Konrad Rzeszutek Wilk
95003cd511 libxl: Fix memory leak if pthread_create fails.
If we fail to create the thread we leak the shutdown_info
structure.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2015-03-26 14:22:36 -06:00
Jim Fehlig
a5bf06ba34 libxl: remove per-domain libxl_ctx
Although needed in the Xen 4.1 libxl days, there is no longer any
benefit to having per-domain libxl_ctx.  On the contrary, their use
makes the code unecessarily complicated and prone to deadlocks under
load.  As suggested by the libxl maintainers, use a single libxl_ctx
as a handle to libxl instead of per-domain ctx's.

One downside to using a single libxl_ctx is there are no longer
per-domain log files for log messages emitted by libxl.  Messages
for all domains will be sent to /var/log/libvirt/libxl/libxl-driver.log.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-24 15:03:55 -06:00
Jim Fehlig
6728645a41 libxl: make libxlDomainFreeMem static
libxlDomainFreeMem() is only used in libxl_domain.c and thus should
be declared static.  While at it, change the signature to take a
libxl_ctx instead of libxlDomainObjPrivatePtr, since only the
libxl_ctx is needed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-24 15:03:54 -06:00
Jim Fehlig
1cca1d25a0 libxl: remove unnecessary libxlDomainEventsRegister
This function now only enables domain death events.  Simply call
libxl_evenable_domain_death() instead of an unnecessary wrapper.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-24 15:03:54 -06:00
Jim Fehlig
0b0a3d63bb libxl: use global libxl_ctx in event handler
Change the domain event handler code to use the driver-wide
libxl_ctx instead of the domain-specific one.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-24 15:03:54 -06:00
Jim Fehlig
109cf8d89c libxl: move event registration to driver initialization
Register a domain event handler with the driver-wide libxl_ctx
during driver initialization.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-24 15:03:54 -06:00
Jim Fehlig
331a02a701 libxl: Move setup of child processing code to driver initialization
Informing libxl how to handle its child proceses should be done once
during driver initialization, not once for each domain-specific
libxl_ctx object.  The related libxl documentation in
$xen-src/tools/libxl/libxl_event.h even mentions that "it is best to
call this at initialisation".

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-24 15:03:54 -06:00
Jim Fehlig
57db83ae3b libxl: use driver-wide ctx in fd and timer event handling
Long ago I incorrectly associated libxl fd and timer registrations
with per-domain libxl_ctx objects.  When creating a libxlDomainObjPrivate,
a libxl_ctx is allocated, and libxl_osevent_register_hooks is called
passing a pointer to the libxlDomainObjPrivate.  When an fd or timer
registration occurred, the registration callback received the
libxlDomainObjPrivate, containing the per-domain libxl_ctx.  This
libxl_ctx was then used when informing libxl about fd events or
timer expirations.

The problem with this approach is that fd and timer registrations do not
share the same lifespan as libxlDomainObjPrivate, and hence the per-domain
libxl_ctx ojects.  The result is races between per-domain libxl_ctx's being
destoryed and events firing on associated fds/timers, typically manifesting
as an assert in libxl

libxl_internal.h:2788: libxl__ctx_unlock: Assertion `!r' failed

There is no need to associate libxlDomainObjPrivate objects with libxl's
desire to use libvirt's event loop.  Instead, the driver-wide libxl_ctx can
be used for the fd and timer registrations.

This patch moves the fd and timer handling code away from the
domain-specific code in libxl_domain.c into libxl_driver.c.  While at it,
function names were changed a bit to better describe their purpose.

The unnecessary locking was also removed since the code simply provides a
wrapper over the event loop interface.  Indeed the locks may have been
causing some deadlocks when repeatedly creating/destroying muliple domains.
There have also been rumors about such deadlocks during parallel OpenStack
Tempest runs.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-24 15:03:54 -06:00
Peter Krempa
3e4230d270 conf: Add interface to parse and format memory device information
This patch adds code that parses and formats configuration for memory
devices.

A simple configuration would be:
<memory model='dimm'>
  <target>
    <size unit='KiB'>524287</size>
    <node>0</node>
  </target>
</memory>

A complete configuration of a memory device:
<memory model='dimm'>
  <source>
    <pagesize unit='KiB'>4096</pagesize>
    <nodemask>1-3</nodemask>
  </source>
  <target>
    <size unit='KiB'>524287</size>
    <node>1</node>
  </target>
</memory>

This patch preemptively forbids use of the <memory> device in individual
drivers so the users are warned right away that the device is not
supported.
2015-03-23 14:25:15 +01:00
Peter Krempa
bffb9163a1 conf: Add support for parsing and formatting max memory and slot count
Add a XML element that will allow to specify maximum supportable memory
and the count of memory slots to use with memory hotplug.

To avoid possible confusion and misuse of the new element this patch
also explicitly forbids the use of the maxMemory setting in individual
drivers's post parse callbacks. This limitation will be lifted when the
support is implemented.
2015-03-23 14:25:14 +01:00
Peter Krempa
19e85d8454 libxl: Refactor logic in domain post parse callback
With the current control flow the post parse callback returned success
right away for fully virtualized VMs. To allow adding additional checks
into the post parse callback tweak the conditions so that the function
doesn't return early except for error cases.

To clarify the original piece of code borrow the wording from the commit
message for the patch that introduced the code.
2015-03-23 14:25:14 +01:00
Jim Fehlig
2adba7d3ab libxl: use xenlight pkgconfig file if present
xen.git commit babeca32 added a pkgconfig file for libxenlight,
allowing libxl apps to determine the location of Xen binaries
such as firmware blobs, device emulator, etc.

This patch adds support for xenlight.pc in the libxl driver, falling
back to the previous configure logic if not found.  It introduces
LIBXL_FIRMWARE_DIR and LIBXL_EXECBIN_DIR to define the firmware and
libexec_bin locations.  If xenlight.pc does not exist, the defines
are set to the current hardcoded paths.  The capabilities'
<emulator> and <loader> elements are updated to use the paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-19 16:13:26 -06:00
Jim Fehlig
bd235cd873 libxl: Don't overwrite errors from xenconfig
When converting domXML from native, the libxl driver was overwriting
useful errors from the xenconfig parsing code with a useless, generic
error.  E.g. "internal error: parsing xm config failed" vs
"internal error: config value usbdevice was malformed".  Remove the
redundant (and useless) error reporting in the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-18 20:55:33 -06:00
Jim Fehlig
a7d6b94a00 libxl: fix regression introduced by commit 4ab8cd77
Commit 4ab8cd77 added a check requiring input devices to have
a bus type of VIR_DOMAIN_INPUT_BUS_USB, failing to start the
domain otherwise.  But virDomainDefParseXML adds implicit mouse
and keyboard if a graphics device is configured.  See calls to
virDomainDefMaybeAddInput.

The regression is fixed by removing the check requiring USB input
devices, and skipping non-USB input devices when populating USB
'usbdevice' in libxl_domain_build_info struct.
2015-03-16 11:49:58 -06:00
John Ferlan
4985dde0f5 Replace virDomainVcpuPinDel with virDomainPinDel
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
John Ferlan
cacf27f212 Replace virDomainVcpuPinAdd with virDomainPinAdd
Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference
2015-03-16 11:54:57 -04:00
John Ferlan
a9f528ab29 Convert virDomainPinDefPtr->vcpuid to virDomainPinDefPtr->id
Since we're not specifically a vcpu related structure anymore...
2015-03-16 11:54:57 -04:00
John Ferlan
59ba70237a Convert virDomainVcpuPinDefPtr to virDomainPinDefPtr
As pointed out by jtomko in his review of the IOThreads pinning code:

http://www.redhat.com/archives/libvir-list/2015-March/msg00495.html

there are some comments sprinkled in indicating IOThreads were using
the same structure as the VcpuPin code...

This is the first patch of a few that will change the virDomainVcpuPin*
structures and code to just virDomainPin* - starting with the data
structure naming...
2015-03-16 11:54:56 -04:00
Peter Krempa
4f9907cd11 conf: Replace access to def->mem.max_balloon with accessor functions
As there are two possible approaches to define a domain's memory size -
one used with legacy, non-NUMA VMs configured in the <memory> element
and per-node based approach on NUMA machines - the user needs to make
sure that both are specified correctly in the NUMA case.

To avoid this burden on the user I'd like to replace the NUMA case with
automatic totaling of the memory size. To achieve this I need to replace
direct access to the virDomainMemtune's 'max_balloon' field with
two separate getters depending on the desired size.

The two sizes are needed as:
1) Startup memory size doesn't include memory modules in some
hypervisors.
2) After startup these count as the usable memory size.

Note that the comments for the functions are future aware and document
state that will be present after a few later patches.
2015-03-16 14:26:51 +01:00
Marek Marczykowski-Górecki
1a01a2aa57 libxl: prevent attaching multiple netdevs with the same MAC
It will not be possible to detach such device later. Also improve
logging in such cases.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-03-13 12:00:50 -06:00
Marek Marczykowski
4ab8cd77ad libxl: add tablet/mouse input device support
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-03-13 12:00:49 -06:00
Ján Tomko
22fd3ac38f Introduce virBitmapIsBitSet
A helper that never returns an error and treats bits out of bitmap range
as false.

Use it everywhere we use ignore_value on virBitmapGetBit, or loop over
the bitmap size.
2015-03-13 15:31:33 +01:00
Jim Fehlig
3b7f589571 libxl: remove unneeded cleanup_unlock label
In the old days of a global driver lock, it was necessary to unlock
the driver after a domain restore operation.  When the global lock
was removed from the driver, some remnants were left behind in
libxlDomainRestoreFlags.  Remove this unneeded (and incorrect) code.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-05 09:05:35 -07:00
Jim Fehlig
b1d159d889 libxl: use libxl_ctx passed to libxlConsoleCallback
Instead of using the libxl_ctx in the libxlDomainObjPrivatePtr,
use the ctx passed to the callback.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-05 09:05:34 -07:00
Jim Fehlig
fc3ef44ea4 libxl: remove redundant calls to libxl_evdisable_domain_death
Domain death watch is already disabled in libxlDomainCleanup.  No
need to disable it a second and third time.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-05 09:05:34 -07:00
Marek Marczykowski
d0106d5828 libxl: support backend domain setting for disk and net devices
This implement handling of <backenddomain name=''/>  parameter introduced
in previous patch.

Works on Xen >= 4.3, because only there libxl supports setting backend
domain by name.  Specifying backend domain by ID or UUID is currently not
supported.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-02-20 14:50:24 -07:00
John Ferlan
4438646c0d libxl: Resolve Coverity CHECKED_RETURN
Periodically my Coverity scan will return a checked_return failure
for libxlDomainShutdownThread call to libxlDomainStart. Followed the
libxlAutostartDomain example in order to check the status, emit a
message, and continue on.
2015-02-14 07:31:41 -05:00
Marek Marczykowski-Górecki
98780c6be6 libxl: disable VNC and SDL until explicitly enabled
When initializing a libxl_domain_build_info struct with
libxl_domain_build_info_init(), VNC is enabled by default.  As a
result, VMs configured with no graphics still have VNC enabled.
This behavior is a regression wrt to the legacy Xen driver.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-02-11 20:24:20 -07:00
Marek Marczykowski-Górecki
8703ee58bd libxl: pass ipaddr to libxl toolstack
Do not silently ignore its value. LibXL support only one address, so
refuse multiple IPs.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-02-11 16:46:36 -07:00
Marek Marczykowski-Górecki
490be8c724 libxl: update dom->id in libxlDomainCreateWithFlags
Otherwise domainCreateWithFlags via remote returns -1 as domid.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-02-05 13:58:47 -07:00
Daniel P. Berrange
55ea7be7d9 Removing probing of secondary drivers
For stateless, client side drivers, it is never correct to
probe for secondary drivers. It is only ever appropriate to
use the secondary driver that is associated with the
hypervisor in question. As a result the ESX & HyperV drivers
have both been forced to do hacks where they register no-op
drivers for the ones they don't implement.

For stateful, server side drivers, we always just want to
use the same built-in shared driver. The exception is
virtualbox which is really a stateless driver and so wants
to use its own server side secondary drivers. To deal with
this virtualbox has to be built as 3 separate loadable
modules to allow registration to work in the right order.

This can all be simplified by introducing a new struct
recording the precise set of secondary drivers each
hypervisor driver wants

struct _virConnectDriver {
    virHypervisorDriverPtr hypervisorDriver;
    virInterfaceDriverPtr interfaceDriver;
    virNetworkDriverPtr networkDriver;
    virNodeDeviceDriverPtr nodeDeviceDriver;
    virNWFilterDriverPtr nwfilterDriver;
    virSecretDriverPtr secretDriver;
    virStorageDriverPtr storageDriver;
};

Instead of registering the hypervisor driver, we now
just register a virConnectDriver instead. This allows
us to remove all probing of secondary drivers. Once we
have chosen the primary driver, we immediately know the
correct secondary drivers to use.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-01-27 12:02:04 +00:00
Anthony PERARD
368042cf4a libxl: Set path to console on domain startup.
The path to the pty of a Xen PV console is set only in
virDomainOpenConsole. But this is done too late. A call to
virDomainGetXMLDesc done before OpenConsole will not have the path to
the pty, but a call after OpenConsole will.

e.g. of the current issue.
Starting a domain with '<console type="pty"/>'
Then:
virDomainGetXMLDesc():
  <devices>
    <console type='pty'>
      <target type='xen' port='0'/>
    </console>
  </devices>
virDomainOpenConsole()
virDomainGetXMLDesc():
  <devices>
    <console type='pty' tty='/dev/pts/30'>
      <source path='/dev/pts/30'/>
      <target type='xen' port='0'/>
    </console>
  </devices>

The patch intend to have the TTY path on the first call of GetXMLDesc.
This is done by setting up the path at domain start up instead of in
OpenConsole.

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

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
2015-01-16 15:57:10 -07:00
Daniel P. Berrange
dd69a14f90 Add support for schema validation when passing in XML
The virDomainDefineXMLFlags and virDomainCreateXML APIs both
gain new flags allowing them to be told to validate XML.
This updates all the drivers to turn on validation in the
XML parser when the flags are set
2015-01-15 16:40:27 +00:00