Commit Graph

58 Commits

Author SHA1 Message Date
Matthias Bolte
e123e1ee6b Fix return value semantic of virFileMakePath
Some callers expected virFileMakePath to set errno, some expected
it to return an errno value. Unify this to return 0 on success and
-1 on error. Set errno to report detailed error information.

Also optimize virFileMakePath if stat fails with an errno different
from ENOENT.
2011-07-06 09:27:06 +02:00
Eric Blake
28e45afc3f build: rename Vcpupin to VcpuPin
We already have a public virDomainPinVcpu, which implies that
Pin and Vcpu are treated as separate words.  Unreleased commit
e261987c introduced virDomainGetVcpupinInfo as the first public
API that used Vcpupin, although we had prior internal uses of
that spelling.  For consistency, change the spelling to be two
words everywhere, regardless of whether pin comes first or last.

* daemon/remote.c: Treat vcpu and pin as separate words.
* include/libvirt/libvirt.h.in: Likewise.
* src/conf/domain_conf.c: Likewise.
* src/conf/domain_conf.h: Likewise.
* src/driver.h: Likewise.
* src/libvirt.c: Likewise.
* src/libvirt_private.syms: Likewise.
* src/libvirt_public.syms: Likewise.
* src/libxl/libxl_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/remote/remote_driver.c: Likewise.
* src/xen/xend_internal.c: Likewise.
* tools/virsh.c: Likewise.
* src/remote/remote_protocol.x: Likewise.
* src/remote_protocol-structs: Likewise.
Suggested by Matthias Bolte.
2011-06-27 09:55:11 -06:00
Cole Robinson
6094ad7bd7 Promote virEvent*Handle/Timeout to public API
Since we virEventRegisterDefaultImpl is now a public API, callers need
a way to invoke the default registered Handle and Timeout functions. We
already have general functions for these internally, so promote
them to the public API.

v2:
    Actually add APIs to libvirt.h
2011-06-21 10:08:47 -04:00
Osier Yang
ebf6b11ac1 Use VIR_USE_CPU instead of new wheel 2011-06-07 16:51:51 +08:00
Jim Fehlig
9a76e737fc Fix minor issues in libxenlight managed save
There were a few minor issues in commit 5b6c961e
- leak managed save path
- leak managed save fd
- functions that open an fd should also close it
2011-06-02 15:41:13 -06:00
Daniel Veillard
4cc4aee680 libxl : fix the version for the managed save APIs 2011-06-02 20:39:40 +08:00
Markus Groß
5b6c961ef2 libxl: adds managed save and restore support
Based on the equivalent qemu driver code

* src/libxl/libxl_driver.c: refactor the Start save and restore
  routines of the driver and adds the new entry points for
  managed saves handling
2011-06-02 20:24:30 +08:00
Markus Groß
47370d5a0b libxl: get maximum memory of running domain
* src/libxl/libxl_driver.c: fix the libxlDomainGetInfo to return the
  maximum memory for running domain
2011-06-02 20:16:32 +08:00
Markus Groß
bf7f798314 Support maximum and current memory flags in libxl driver
Add support to set the maximum memory of the domain.
Also add support to change the memory of the current
state of the domain, which translates to a running
domain or the config of the domain.

Based on the code from the qemu driver.
2011-05-30 23:29:08 -06:00
Markus Groß
db0274c9d7 Add domainSave/Restore to libxl driver
v3:
* initialize xml pointer to avoid segfault
* throw error message if domain is paused as
  libxenlight itself will pause it

v2:
* header is now padded and has a version field
* the correct restore function from libxl is used
* only create the restore event once in libxlVmStart
2011-05-30 23:29:05 -06:00
Markus Groß
e69b192102 Add domainCoreDump to libxl driver
v2:
* incorporated Jim Fehlig's review
2011-05-30 23:26:56 -06:00
Markus Groß
648b521e0d Populate domid field of devices for libxenlight
This patch fixes the population of the
libxenlight data structures. Now the devices
should be removed correctly from the xenstore
if they are detached.
2011-05-30 18:11:42 -06:00
Eric Blake
bb6cb66fde sched: provide new API shims for remaining drivers
Well, the remaining drivers that already had the get/set
scheduler parameter functionality to begin with.

For now, this blindly treats VIR_DOMAIN_SCHEDINFO_CURRENT as
the only supported operation for these 5 domains; it will
take domain-specific patches if more specific behavior is
preferred.

* src/esx/esx_driver.c (esxDomainGetSchedulerParameters)
(esxDomainSetSchedulerParameters): Move guts...
(esxDomainGetSchedulerParametersFlags)
(esxDomainSetSchedulerParametersFlags): ...to new functions.
* src/libxl/libxl_driver.c (libxlDomainGetSchedulerParameters)
(libxlDomainSetSchedulerParameters)
(libxlDomainGetSchedulerParametersFlags)
(libxlDomainSetSchedulerParametersFlags): Likewise.
* src/lxc/lxc_driver.c (lxcGetSchedulerParameters)
(lxcSetSchedulerParameters, lxcGetSchedulerParametersFlags)
(lxcSetSchedulerParametersFlags): Likewise.
* src/test/test_driver.c (testDomainGetSchedulerParams)
(testDomainSetSchedulerParams, testDomainGetSchedulerParamsFlags)
(testDomainSetSchedulerParamsFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainGetSchedulerParameters)
(xenUnifiedDomainSetSchedulerParameters)
(xenUnifiedDomainGetSchedulerParametersFlags)
(xenUnifiedDomainSetSchedulerParametersFlags): Likewise.
2011-05-29 18:51:33 +08:00
Eric Blake
163e5f04ef maint: prefer newer API names internally
Rather mechanical in nature.

* src/driver.h: Use newer virTypedParameter API names.
* src/libvirt.c: Likewise.
* daemon/remote.c: Likewise.
* src/esx/esx_driver.c: Likewise.
* src/libxl/libxl_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/remote/remote_driver.c: Likewise.
* src/test/test_driver.c: Likewise.
* src/xen/xen_driver.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* src/xen/xen_hypervisor.h: Likewise.
* src/xen/xend_internal.c: Likewise.
* tools/virsh.c: Likewise.
2011-05-29 18:26:31 +08:00
Markus Groß
fffea7fed7 Add disk attach/detach support to libxl driver
Based on the device attach/detach code from the QEMU driver,
but using the new functions to create the structures associated.
* src/libxl/libxl_driver.c: implements domainAttachDevice,
  domainAttachDeviceFlags, domainDetachDevice, domainDetachDeviceFlags
  and domainUpdateDeviceFlags
2011-05-26 23:27:06 +08:00
Markus Groß
685753a360 Fix libxl vm def handling on domU cleanup
* src/libxl/libxl_driver.c: in libxlVmCleanup, free up the
  newDef definition if present overwise it would be leaked.
2011-05-26 23:16:31 +08:00
Markus Groß
f59b71ac57 Refactored libxl datastructure instantiation
Create 3 new function refactored from previous list ones and
exports them internally to the driver

* src/libxl/libxl_conf.c src/libxl/libxl_conf.h: create libxlMakeDisk,
  libxlMakeNic libxlMakeVfb out of the exsting static List functions
  and exports them
2011-05-26 23:09:01 +08:00
Jim Fehlig
492e493a1e Fix initialization of current vcpus in libxl driver
The cur_vcpus member of struct libxl_domain_build_info was incorrectly
initialized to the number of vcpus, when it should have been interpreted
as a bitmap, where bit X corresponds to online/offline status of vcpuX.

To complicate matters, cur_vcpus is an int, so only 32 vcpus can be
set online.  Add a check to ensure vcpus does not exceed this limit.

V2: Eric Blake noted a compilation pitfal when '1 << 32' on an int.
    Account for vcpus == 32.
2011-05-24 14:13:04 -06:00
Eric Blake
7647422a8c build: silence clang false positive
Clang couldn't quite see that the same condition of
(flags & VIR_DOMAIN_MEM_CONFIG) is used twice, such that
the second block is guaranteed that def was assigned in
the first block.

* src/libxl/libxl_driver.c (libxlDomainSetMemoryFlags): Add a hint
for clang.
2011-05-18 12:47:46 -06:00
Matthias Bolte
d870ec367d Clarify that virDomainSetSchedulerParameters(Flags) can take subsets
Add invalid argument checks for params and nparams to the public API
and remove them from the drivers (e.g. xend).

Add subset handling to libxl and test drivers.
2011-05-18 18:20:47 +02:00
Matthias Bolte
e430c0d0c6 Clarify the semantic of virDomainGetSchedulerParameters arguments
params and nparams are essential and cannot be NULL. Check this in
libvirt.c and remove redundant checks from the drivers (e.g. xend).

Instead of enforcing that nparams must point to exact same value as
returned by virDomainGetSchedulerType relax this to a lower bound
check. This is what some drivers (e.g. xen hypervisor and esx)
already did. Other drivers (e.g. xend) didn't check nparams at all
and assumed that there is enough space in params.

Unify the behavior in all drivers to a lower bound check and update
nparams to the number of valid values in params on success.
2011-05-18 18:20:47 +02:00
Matthias Bolte
7b2f20b10b Clarify semantic of nparams argument of virDomainGetSchedulerType
Some drivers assumed it can be NULL (e.g. qemu and lxc) and check it
before assigning to it, other drivers assumed it must be non-NULL
(e.g. test and esx) and just assigned to it.

Unify this to nparams being optional and document it.
2011-05-18 18:20:47 +02:00
Daniel P. Berrange
9b1ae97fdc Add many version number annotations to drivers
Add many version number annotations to the internal driver
tables, to allow hvsupport.html to display more accurate
information
2011-05-16 14:20:48 +01:00
Daniel P. Berrange
879d409e9e Convert all driver struct intializers to C99 style
Change all the driver struct initializers to use the
C99 style, leaving out unused fields. This will make
it possible to add new APIs without changing every
driver. eg change:

    qemudDomainResume, /* domainResume */
    qemudDomainShutdown, /* domainShutdown */
    NULL, /* domainReboot */
    qemudDomainDestroy, /* domainDestroy */

to

    .domainResume = qemudDomainResume,
    .domainShutdown = qemudDomainShutdown,
    .domainDestroy = qemudDomainDestroy,

And get rid of any existing C99 style initializersr which
set NULL, eg change

     .listPools          = vboxStorageListPools,
     .numOfDefinedPools  = NULL,
     .listDefinedPools   = NULL,
     .findPoolSources    = NULL,
     .poolLookupByName   = vboxStoragePoolLookupByName,

to

     .listPools          = vboxStorageListPools,
     .poolLookupByName   = vboxStoragePoolLookupByName,
2011-05-16 14:20:43 +01:00
Daniel P. Berrange
360df0199e Tweak driver naming for consistency with public API
Fix some driver names:

  s/virDrvCPUCompare/virDrvCompareCPU/
  s/virDrvCPUBaseline/virDrvBaselineCPU/
  s/virDrvQemuDomainMonitorCommand/virDrvDomainQemuMonitorCommand/
  s/virDrvSecretNumOfSecrets/virDrvNumOfSecrets/
  s/virDrvSecretListSecrets/virDrvListSecrets/

And some driver struct field names:

  s/getFreeMemory/nodeGetFreeMemory/
2011-05-16 14:20:35 +01:00
Jiri Denemark
b046c55d40 Implement domain state reason
Only in drivers which use virDomainObj, drivers that query hypervisor
for domain status need to be updated separately in case their hypervisor
supports this functionality.

The reason is also saved into domain state XML so if a domain is not
running (i.e., no state XML exists) the reason will be lost by libvirtd
restart. I think this is an acceptable limitation.
2011-05-16 13:36:08 +02:00
Jiri Denemark
26d94012f6 Implement basic virDomainGetState in all drivers
Reason is currently always set to 0 (i.e., *_UNKNOWN).
2011-05-16 11:33:53 +02:00
Jiri Denemark
6feb1341e5 Internal driver API for virDomainGetState 2011-05-16 10:04:18 +02:00
Eric Blake
a9bb4f65ec libxl: fix typos in previous patch
* src/libxl/libxl_driver.c (libxlDomainEventFlush, libxlShutdown)
(libxlStartup): Fix typos.
2011-05-13 11:31:05 -06:00
Cole Robinson
7405aebe01 libxl: Convert to virDomainEventState 2011-05-13 10:48:32 -04:00
Michal Privoznik
3c38664339 screenshot: Defining the internal API
* src/driver.h: Stub code for new API
* src/esx/esx_driver.c, src/libxl/libxl_driver.c,
  src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
  src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
  rc/remote/remote_driver.c, rc/test/test_driver.c,
  src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/vmware/vmware_driver.c, src/xen/xen_driver.c,
  src/xen/xen_driver.h, src/xen/xen_hypervisor.c,
  src/xen/xen_inotify.c, src/xen/xend_internal.c,
  src/xen/xm_internal.c, src/xen/xs_internal.c,
  src/xenapi/xenapi_driver.c: Add dummy entries in driver
  table for new APIs
2011-05-13 12:35:58 +02:00
Lai Jiangshan
b65f37a4a1 libvirt,logging: cleanup VIR_XXX0()
These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.

How do these coversions works? The magic is using the gcc extension of ##.
When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to
avoid compile error.

example: origin				after CPP
	high_level_api("%d", a_int)	low_level_api("%d", a_int)
	high_level_api("a  string")	low_level_api("a  string")

About 400 conversions.

8 special conversions:
VIR_XXXX0("") -> VIR_XXXX("msg") (avoid empty format) 2 conversions
VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions
VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal)
  (for security) 6 conversions

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2011-05-11 12:41:14 -06:00
Eric Blake
4c6ae9ae36 build: remove some dead assignments
No syntactic effect; this merely silences some clang warnings.

* src/libxl/libxl_driver.c (libxlDomainSetVcpusFlags): Drop
redundant ret=0 statement.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextDriveDel):
Likewise.
2011-05-11 10:43:13 -06:00
Paolo Bonzini
761a742a8d libxl: support enabling the HPET
libxl accepts hpet configuration in its domain info struct.  Parse the
domain definition's <clock> element in order to set the value.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Apologies from Eric Blake, for mistakenly committing the broken
intermediate version.
2011-05-10 16:38:30 -06:00
Paolo Bonzini
0fd3fac537 libxl: support enabling the HPET
libxl accepts hpet configuration in its domain info struct.  Parse the
domain definition's <clock> element in order to set the value.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-05-10 16:28:09 -06:00
Matthias Bolte
9817604afc Rename internal DumpXML functions to GetXMLDesc
This matches the public API and helps to get rid of some special
case code in the remote generator.

Rename driver API functions and XDR protocol structs.

No functional change included outside of the remote generator.
2011-05-10 20:32:41 +02:00
Lai Jiangshan
b19bd85e15 inject-nmi: Defining the internal API 2011-05-10 11:40:51 -06:00
Markus Groß
0d9936f622 Balloon dom0 in libxl driver
Creating a domU on a freshly booted dom0 does not work,
because the libxl driver does not allocate memory for the domU.
After creating a domain with xl libvirt is able to create domains too.
This patch reserves enough memory for the domU first.
2011-05-06 11:20:33 -06:00
Eric Blake
710f8811f5 libxl: avoid compiler warning
Detected by gcc:

libxl/libxl_driver.c: In function 'libxlDomainDestroy':
libxl/libxl_drier.c:1351:30: error: variable 'priv' set but not used [-Werror=unused-but-set-variable]

* src/libxl/libxl_driver.c (libxlDomainDestroy): Delete unused
variable.
2011-05-04 09:21:05 -06:00
Markus Groß
68c5b6fb2b Add cputune support to libxl driver
Here is a new version of this patch:
https://www.redhat.com/archives/libvir-list/2011-April/msg00337.html

v2:
  - store the cputune info for the whole runtime of the domain
  - remove cputune info when domain is destroyed

The nodeGetInfo code had to be moved into a helper
function to reuse it without a virConnectPtr.
2011-04-18 12:13:11 -06:00
Matthias Bolte
60d769a13a Remove virConnectPtr from virRaiseErrorFull
And from all related macros and functions.
2011-04-17 07:22:23 +02:00
Markus Groß
a7a4414b75 Add domainSet/GetSchedulerParameters to libxl driver
Libxenlight currently only supports the credit scheduler.
Therefore setting or getting a parameter of other
schedulers raise an error (for now).
2011-04-07 10:23:19 -06:00
Markus Groß
bf7f62519a Add domainIsUpdated to libxl driver 2011-04-06 15:31:04 -06:00
Eric Blake
3eb869a04b libxl: avoid compiler warning
cc1: warnings being treated as errors
libxl/libxl_driver.c: In function 'libxlDomainSetVcpusFlags':
libxl/libxl_driver.c:1570:14: error: cast from function call of type 'double' to non-matching type 'unsigned int' [-Wbad-function-cast]
libxl/libxl_driver.c:1578:15: error: cast from function call of type 'double' to non-matching type 'unsigned int' [-Wbad-function-cast]

This was the only use of floor() and ceil(), and floating-point
is overkill for power-of-two manipulations.

* src/libxl/libxl_driver.c (libxlDomainSetVcpusFlags): Avoid -lm
for trivial computations.
2011-04-05 11:09:12 -06:00
Markus Groß
fb92307f0d Add autostart support to libxl driver
The domainSetAutostart function is nearly identical to the one from qemu.
2011-04-04 17:28:37 -06:00
Daniel Veillard
03ede2f69d Fix libxl driver startup
When you happen to have a libvirtd binary compiled with the
libxenlight driver (say you have installed xen-4.1 libraries)
but not running a xen enabled system, then libvirtd fails to start.

The cause is that libxlStartup() returns -1 when failing to initialize
the library, and this propagates to virStateInitialize() which consider
this a failure. We should only exit libxlStartup with an error code
if something like an allocation error occurs, not if the driver failed
to initialize.

* src/libxl/libxl_driver.c: fix libxlStartup() to not return -1
  when failing to initialize the libxenlight library
2011-04-01 19:30:53 +08:00
Markus Groß
6ebcb0c777 Add domainSuspend/Resume to libxl driver
* src/libxl/libxl_driver.c: implements libxlDomainSuspend and
  libxlDomainResume
2011-03-29 20:57:02 +08:00
Markus Groß
f367a1dfce Add domainGetOSType to libxl driver
* src/libxl/libxl_driver.c: implements libxlDomainGetOSType
2011-03-29 20:57:02 +08:00
Markus Groß
d53bca4868 Add domainGetSchedulerType to libxl driver
* src/libxl/libxl_driver.c: implements libxlDomainGetSchedulerType
2011-03-29 20:57:02 +08:00
Markus Groß
0244977180 Implements domainXMLTo/FromNative in libxl driver
* src/Makefile.am src/libvirt_private.syms configure.ac: share and
  reuse the sexpr routines from sexpr.h of the old xen driver
* src/libxl/libxl_driver.c: implements libxlDomainXMLFromNative and
  libxlDomainXMLToNative
2011-03-29 20:57:02 +08:00