Commit Graph

4553 Commits

Author SHA1 Message Date
Daniel P. Berrange
ea7dc33786 Make internal domain events struct definitions private
The virtual box driver was directly accesing the domain events
structs instead of using the APIs provided. To prevent this kind
of abuse, make the struct definitions private, forcing use of the
internal APIs. This requires adding one extra internal API.

* src/conf/domain_event.h, src/conf/domain_event.c: Move
  virDomainEventCallback and virDomainEvent structs into
  the source file instead of header
* src/vbox/vbox_tmpl.c: Use official APIs for dispatching domain
  events instead of accessing structs directly.
2010-03-26 13:52:09 +00:00
Daniel P. Berrange
4445723811 Introduce a new public API for domain events
The current API for domain events has a number of problems

 - Only allows for domain lifecycle change events
 - Does not allow the same callback to be registered multiple times
 - Does not allow filtering of events to a specific domain

This introduces a new more general purpose domain events API

  typedef enum {
     VIR_DOMAIN_EVENT_ID_LIFECYCLE = 0,       /* virConnectDomainEventCallback */
      ...more events later..
  }

  int virConnectDomainEventRegisterAny(virConnectPtr conn,
                                       virDomainPtr dom, /* Optional, to filter */
                                       int eventID,
                                       virConnectDomainEventGenericCallback cb,
                                       void *opaque,
                                       virFreeCallback freecb);

  int virConnectDomainEventDeregisterAny(virConnectPtr conn,
                                         int callbackID);

Since different event types can received different data in the callback,
the API is defined with a generic callback. Specific events will each
have a custom signature for their callback. Thus when registering an
event it is neccessary to cast the callback to the generic signature

eg

  int myDomainEventCallback(virConnectPtr conn,
                            virDomainPtr dom,
                            int event,
                            int detail,
                            void *opaque)
  {
    ...
  }

  virConnectDomainEventRegisterAny(conn, NULL,
                                   VIR_DOMAIN_EVENT_ID_LIFECYCLE,
                                   VIR_DOMAIN_EVENT_CALLBACK(myDomainEventCallback)
                                   NULL, NULL);

The VIR_DOMAIN_EVENT_CALLBACK() macro simply does a "bad" cast
to the generic signature

* include/libvirt/libvirt.h.in: Define new APIs for registering
  domain events
* src/driver.h: Internal driver entry points for new events APIs
* src/libvirt.c: Wire up public API to driver API for events APIs
* src/libvirt_public.syms: Export new APIs
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xen_driver.c,
  src/xenapi/xenapi_driver.c: Stub out new API entries
2010-03-26 13:52:03 +00:00
Eric Blake
271945a148 maint: update syntax-check rule to also catch test's -o operator
* cfg.mk (sc_prohibit_test_minus_a): Rename...
(sc_prohibit_test_minus_ao): ...and flag '-o', too.
2010-03-26 08:50:14 +01:00
Jim Meyering
156133597d tests: teach syntax-check that virDomainDefFree has free-like semantics
* cfg.mk (useless_free_options): Add virDomainDefFree to the list
of free-like functions.
* src/test/test_driver.c (testDomainCreateXML): Remove useless-if-
before-virDomainDefFree.
* src/conf/domain_conf.c (virDomainAssignDef): Likewise
2010-03-26 08:16:54 +01:00
Jiri Denemark
e36be6e7c7 Add entry point logging for cpu functions 2010-03-25 14:51:52 +01:00
Eric Blake
e07cf19fe5 build: don't use "test cond1 -o cond2": it's not portable
* configure.ac: Use "test cond1 || test cond2" instead.
* m4/compiler-flags.m4 (gl_COMPILER_FLAGS): Likewise.
* tests/test-lib.sh (verbose): Likewise.
2010-03-25 09:28:24 +01:00
Matthias Bolte
5edaf95599 esx: Make the conf parser compare names case insensitive in VMX mode
The keys of entries in a VMX file are case insensitive. Both scsi0:1.fileName
and scsi0:1.filename are valid. Therefore, make the conf parser compare names
case insensitive in VMX mode to accept every capitalization variation.

Also add test cases for this.
2010-03-24 21:03:37 +01:00
Matthias Bolte
f66636e3ca vbox: Fix segfault on empty device source
<source file=''/> results in def->disks[i]->src == NULL. But
vboxDomainDefineXML and vboxDomainAttachDevice didn't check
def->disks[i]->src for NULL and expected it to be a valid string.

Add checks for def->disks[i]->src != NULL to fix the segfault.
2010-03-24 21:00:53 +01:00
Philipp Hahn
1cfbfaa697 python example: poll(-0.001) does not sleep forever
The conversion from seconds to milliseconds should only be done for
actual delays >= 0, not for the magic -1 value used for infinite
timeouts.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-03-24 10:26:23 +01:00
Jim Meyering
84eb6effdd build: suppress distracting build output
* src/Makefile.am (augeas-check): New target, just to give the existing
rule a name.  At the same time, prefix the commands with $(AM_V_GEN),
to avoid unexpected build output with V=0 which is the default.
2010-03-24 09:45:24 +01:00
Jim Meyering
95c8ddd2ec maint: add syntax-check rule to prohibit use of test's -a operator
* cfg.mk (sc_prohibit_test_minus_a): New rule.
2010-03-24 09:32:43 +01:00
Jim Meyering
7998714d60 build: don't use "test cond1 -a cond2" in configure: it's not portable
* configure.ac: Use "test cond1 && test cond2" instead.
2010-03-24 09:23:46 +01:00
Jim Meyering
ca7db6cb80 tests: shell script portability and clean-up
* tests/test-lib.sh: "echo -n" is not portable.  Use printf instead.
Remove unnecessary uses of "eval-in-subshell" (subshell is sufficient).
Remove uses of tests' -a operator; it is not portable.
Instead, use "test cond && test cond2".
* tests/schematestutils.sh: Replace use of test's -a.
2010-03-24 09:23:01 +01:00
Matthias Bolte
8a7783c163 tests: Don't add extra padding if counter mod 40 is 0
This change only affects the output of tests that have an exact
multiple of 40 test cases. For example the domainschematest currently:

TEST: domainschematest
      ........................................ 40
      ........................................ 80
      ........................................ 120
      ........................................ 160
      ........................................                                         200 OK
PASS: domainschematest

It outputs additional 40 spaces on the last line.

The domainschematest output is fixed by the change in test-lib.sh. The
change in testutils.c fixes this for tests written in C. Currently no
C test has an exact multiple of 40 test cases, but I checked it and
the same problem exists there.

This patch stops that in both cases.
2010-03-24 01:07:57 +01:00
Jiri Denemark
81e99f014b Fix error reporting when parsing CPU XML strings 2010-03-23 15:40:10 +01:00
Jiri Denemark
8d8815ea2a Use common XML parsing functions 2010-03-23 15:40:10 +01:00
Jiri Denemark
26be7a0a24 Introduce XML parsing utility functions 2010-03-23 15:40:04 +01:00
Jim Meyering
c390bcfec5 virDomainDiskDefAssignAddress: return int, not void
Before, this function would blindly accept an invalid def->dst
and then abuse the idx=-1 it would get from virDiskNameToIndex,
when passing it invalid strings like "xvda:disk" and "sda1".
Now, this function returns -1 upon failure.
* src/conf/domain_conf.c (virDomainDiskDefAssignAddress): as above.
Update callers.
* src/conf/domain_conf.h: Update prototype.
* src/qemu/qemu_conf.c: Update callers.
2010-03-23 11:22:26 +01:00
Jim Meyering
67904847f0 tests: do not use the ":disk" suffix in sample xml input
* tests/xml2sexprdata/xml2sexpr-curmem.xml: Remove ":disk" suffix from
"<target dev=" value.
* tests/xml2sexprdata/xml2sexpr-pv-localtime.xml: Likewise.
* tests/xml2sexprdata/xml2sexpr-curmem.sexpr: Update expected output
to match.
* tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr: Likewise.
2010-03-23 11:22:26 +01:00
Jim Meyering
67ef701779 virDiskNameToIndex: ignore trailing digits
* src/util/util.c (virDiskNameToIndex): Accept sda1, and map it to "sda".
I.e., accept and ignore any string of trailing digits.
2010-03-23 11:22:26 +01:00
Matthias Bolte
b9a3287e80 util: Add stubs for some functions on Windows
virSetCloseExec and virExecDaemonize were missing a body on Windows.
2010-03-23 02:14:20 +01:00
Matthias Bolte
7233dc170f Add HAVE_PTHREAD_H guard for pthread_sigmask
Correctly disable pthread related code if pthread is not avialable,
in order to get it compile with MinGW on Windows.
2010-03-23 02:13:19 +01:00
Matthias Bolte
2f80b2a013 bootstrap: Enable copy-mode for MinGW builds
MSYS' ln doesn't work well in the way bootstrap uses it with relative paths.
2010-03-23 02:12:07 +01:00
Matthias Bolte
e77ee32357 util: Handle lack of (f)chmod and (f)chown on Windows
Even if gnulib can provide stubs, it won't help that much. So just
replace affected util functions (virFileOperation and virDirCreate)
with stubs on Windows. Both functions aren't used on libvirt's
client side, so this is fine for MinGW builds.
2010-03-23 02:11:21 +01:00
Matthias Bolte
17f7220891 bootstrap: Remove rsync from buildreq list
rsync is used to download .po files, but SKIP_PO=true is set and
downloading .po files is skipped.

This also fixes a problem with MinGW builds, because rsync is not
available for MinGW.
2010-03-23 02:10:14 +01:00
Matthias Bolte
0f7ba8c21c util: Make some conditional symbols unconditional
Add dummy bodies for HAVE_GETPWUID_R and HAVE_MNTENT_H dependent
functions for MinGW builds.
2010-03-23 02:09:29 +01:00
Matthias Bolte
3528d66641 Make sure virtTestCaptureProgramOutput has a body on Windows
Now the virsh tests compile at least.
2010-03-23 02:08:14 +01:00
Matthias Bolte
190aaa2627 Fix export of virConnectAuthPtrDefault for MinGW builds
Use the __declspec(dllexport/dllimport) stuff to export the symbol,
otherwise accessing virConnectAuthPtrDefault triggers a segfault.
2010-03-23 02:07:38 +01:00
Matthias Bolte
460e7b6a94 Remove interfaceRegister from libvirt_private.syms
This symbol is conditional, it would need to be exported conditional to
work properly with MinGW. So just remove it, as no other driver register
function is listed in the symbols files.
2010-03-23 02:06:07 +01:00
Matthias Bolte
6d45d5855d Export conditional state driver symbols only when they are defined
This is necessary for MinGW builds.
2010-03-23 02:05:18 +01:00
Matthias Bolte
91da9a7689 Make sure uid_t and gid_t are available 2010-03-23 02:04:03 +01:00
Matthias Bolte
041a18be17 esx: Add esxVI_LookupVirtualMachineByName
Used in esxDomainLookupByName and to be used in esxDomainDefineXML later.
2010-03-23 01:28:08 +01:00
Matthias Bolte
bba36f7fc7 esx: Fix potential memory leak in esxVI_BuildFullTraversalSpecItem
If esxVI_String_DeepCopyValue or esxVI_SelectionSpec_AppendToList fail
then selectionSpec would leak. Add a free call in the failure path to
fix the leak.
2010-03-23 01:28:08 +01:00
Matthias Bolte
055d21d254 esx: Cleanup file header comments
Replace 'method' with 'function' and get the filename's suffix right.
2010-03-23 01:28:08 +01:00
Matthias Bolte
d304352b19 esx: Generate method mappings via macros
This is actually a consequence of the reworked required parameter
checking: Unify the required parameter check into a Validate function
instead of doing it separately im the (de)serialization part.

The required parameter checking for the mapped methods parameter was
done in the (de)serialize functions before. Now it's explicitly done
in the mapped method itself.
2010-03-23 01:28:08 +01:00
Jim Fehlig
09fafa1e21 Avoid libvirtd crash when cgroups is not configured on host
Invoking virDomainSetMemory() on lxc driver results in libvirtd
segfault when cgroups has not been configured on the host.

Ensure driver->cgroup is non-null before invoking
virCgroupForDomain().  To prevent similar segfaults in the future,
ensure driver parameter to virCgroupForDomain() is non-null before
dereferencing.
2010-03-22 09:42:14 -06:00
Cole Robinson
65e97240e6 security: selinux: Fix crash when releasing non-existent label
This can be triggered by the qemuStartVMDaemon cleanup path if a
VM references a non-existent USB device (by product) in the XML.
2010-03-22 10:45:36 -04:00
Guido Günther
b7a7b33651 Don't crash without a security driver
"virsh dominfo <vm>" crashes if there's no primary security driver set
since we only intialize the secmodel.model and secmodel.doi if we have
one. Attached patch checks for securityPrimaryDriver instead of
securityDriver since the later is always set in qemudSecurityInit().

Closes: http://bugs.debian.org/574359
2010-03-22 10:43:45 +01:00
Jiri Denemark
5ee592208c Add migrate-setmaxdowntime command to virsh 2010-03-19 22:57:10 +01:00
Jiri Denemark
7f4f1dd416 Implement virDomainMigrateSetMaxDowntime in qemu driver 2010-03-19 22:47:45 +01:00
Jiri Denemark
0ab6423579 Implement virDomainMigrateSetMaxDowntime in remote driver 2010-03-19 22:45:55 +01:00
Jiri Denemark
20ffaf59dc Wire protocol and dispatcher for virDomainMigrateSetMaxDowntime 2010-03-19 22:42:25 +01:00
Jiri Denemark
68f63673da Public virDomainMigrateSetMaxDowntime API 2010-03-19 22:33:09 +01:00
Jiri Denemark
7f7849c996 Internal driver API for virDomainMigrateSetMaxDowntime 2010-03-19 22:20:42 +01:00
David Allan
3535092f3a Virsh support for vol wiping 2010-03-19 14:44:47 -04:00
David Allan
73adc0e5b7 Simplified version of volume wiping based on feedback from the list. 2010-03-19 14:43:40 -04:00
David Allan
3fdb9ba760 Implement remote bits for vol wiping 2010-03-19 14:43:02 -04:00
David Allan
d36b4e92ac Implement the public API for vol wiping 2010-03-19 14:37:51 -04:00
David Allan
b50ab42d41 Define the internal driver API for vol wiping
Also add vol wiping to ESX storage driver struct
2010-03-19 14:35:58 -04:00
David Allan
e10dc8666e Add public API for volume wiping 2010-03-19 14:31:48 -04:00