Commit Graph

226 Commits

Author SHA1 Message Date
Matthias Bolte
681ff75e88 esx: Add read-only storage volume access
This allows to list existing volumes and to retrieve information
about them.
2010-08-26 23:19:55 +02:00
Matthias Bolte
8c48743b97 esx: Improve object-by-type lookup performance
Instead of using one big traversal spec for lookup use a set of
more fine grained traversal specs that are selected based on the
actual needs of the lookup.

This gives up to 20% speedup for certain operations like domain
listing due to less HTTP(S) traffic.
2010-08-24 11:06:06 +02:00
Matthias Bolte
92af69abad esx: Use MD5 sum of mount path as storage pool UUID
With the previous storage pool UUID source not all storage pools
had a proper UUID, especially GSX storage pools. The mount path
is unique per host and cannot change during the lifetime of the
datastore. Therefore, it's MD5 sum can be used as UUID.

Use gnulib's crypto/md5 module to generate the MD5 sum.
2010-08-21 01:30:08 +02:00
Matthias Bolte
a8cc67a44b esx: Make sure dumpxml outputs proper ID for active domains 2010-08-21 00:03:27 +02:00
Matthias Bolte
f688faceac esx: Fix memory leak when looking up an non-existing domain by name
In case an optional object cannot be found the lookup function is
left early and the cleanup code is not executed.

This pattern occurs in some other functions too.
2010-08-17 23:04:36 +02:00
Matthias Bolte
7c0cbe0279 esx: Explicitly disable unused floppy devices
floppy0.present defaults to true. Therefore, it needs to be
explicitly set to false when the XML config doesn't specify the
corresponding floppy device.

Also update tests accordingly.
2010-08-14 20:16:14 +02:00
Matthias Bolte
145d6cb05c esx: Improve VMX file name parsing and formatting
For parsing try to match by datastore mount path first, if that
fails fallback to /vmfs/volumes/<datastore>/<path> parsing. This
also fixes problems with GSX on Windows. Because GSX on Windows
doesn't use /vmfs/volumes/ style file names.

For formatting use the datastore mount path too, instead of using
/vmfs/volumes/<datastore>/<path> as fixed format.
2010-08-12 01:16:16 +02:00
Matthias Bolte
3de8245560 esx: Split VMX code into a general and an ESX specific part
Introduce esxVMX_Context containing functions pointers to
glue both parts together in a generic way.

Move the ESX specific part to esx_driver.c.

This is a step towards making the VMX code reusable in a
potential VMware Workstation and VMware Player driver.
2010-08-11 16:17:50 +02:00
Matthias Bolte
14954fb8cb esx: Set storage pool target path to host.mountInfo.path
Now all storage pool types expose the target path.
2010-08-02 22:25:15 +02:00
Matthias Bolte
5254546bba esx: Make storage pool lookup by name and UUID more robust
Don't rely on summary.url anymore, because its value is different
between an esx:// and vpx:// connection. Use host.mountInfo.path
instead.

Don't fallback to lookup by UUID (actually lookup by absolute path)
in esxVI_LookupDatastoreByName when lookup by name fails. Add a
seperate function for this: esxVI_LookupDatastoreByAbsolutePath
2010-08-02 22:25:15 +02:00
Matthias Bolte
e4938ce2f1 esx: Restrict vpx:// to handle a single host in a vCenter
Now a vpx:// connection has an explicitly specified host. This
allows to enabled several functions for a vpx:// connection
again, like host UUID, hostname, general node info, max vCPU
count, free memory, migration and defining new domains.

Lookup datacenter, compute resource, resource pool and host
system once and cache them. This simplifies the rest of the
code and reduces overall HTTP(S) traffic a bit.

esx:// and vpx:// can be mixed freely for a migration.

Ensure that migration source and destination refer to the
same vCenter. Also directly encode the resource pool and
host system object IDs into the migration URI in the prepare
function. Then directly build managed object references in
the perform function instead of re-looking up already known
information.
2010-08-02 22:25:15 +02:00
Matthias Bolte
9f85668bd7 esx: Map some managed object types
Datacenter, ComputeResource and HostSystem will be used for
simplified handling and caching.
2010-08-02 22:25:15 +02:00
Matthias Bolte
ac041072f8 esx: Parse the path of the URI
The path will be used to specify the datacenter, compute resource
and host system to be used with a vpx:// connection.
2010-08-02 22:25:15 +02:00
Matthias Bolte
e670d39417 Update ID after stopping a domain 2010-07-30 22:49:26 +02:00
Matthias Bolte
6139b27477 esx: Update ID after starting a domain 2010-07-30 17:14:02 +02:00
Matthias Bolte
5cff36e39a esx: Fix freeing of heterogeneous lists
Always call the free function of the base type. The base type
function then dynamically dispatches the call to the free function
for the actual type.
2010-07-30 14:42:57 +02:00
Matthias Bolte
c38e2f7a39 esx: Switch from name to number checks in the subdrivers 2010-07-30 14:42:57 +02:00
Matthias Bolte
25e34b703a esx: Improve blocked task detection and fix race condition
esxVI_WaitForTaskCompletion can take a UUID to lookup the
corresponding domain and check if the current task for it
is blocked by a question. It calls another function to do
this: esxVI_LookupAndHandleVirtualMachineQuestion looks up
the VirtualMachine and checks for a question. If there is
a question it calls esxVI_HandleVirtualMachineQuestion to
handle it.

If there was no question or it has been answered the call
to esxVI_LookupAndHandleVirtualMachineQuestion returns 0.
If any error occurred during the lookup and answering
process -1 is returned. The problem with this is, that -1
is also returned when there was no error but the question
could not be answered. So esxVI_WaitForTaskCompletion cannot
distinguish between this two situations and reports that a
question is blocking the task even when there was actually
another problem.

This inherent problem didn't surface until vSphere 4.1 when
you try to define a new domain. The driver tries to lookup
the domain that is just in the process of being registered.
There seems to be some kind of race condition and the driver
manages to issue a lookup command before the ESX server was
able to register the domain. This used to work before.

Due to the return value problem described above the driver
reported a false error message in that case.

To solve this esxVI_WaitForTaskCompletion now takes an
additional occurrence parameter that describes whether or
not to expect the domain to be existent. Also add a new
parameter to esxVI_LookupAndHandleVirtualMachineQuestion
that allows to distinguish if the call returned -1 because
of an actual error or because the question could not be
answered.
2010-07-30 14:42:57 +02:00
Eric Blake
2c216d95e8 esx: silence spurious compiler warning
* src/esx/esx_vi_types.c (_DESERIALIZE_NUMBER)
(ESX_VI__TEMPLATE__DESERIALIZE_NUMBER): Add range check to shut up
gcc 4.5.0 regarding long long.
2010-07-29 14:36:43 -06:00
Cole Robinson
50147933a5 domain conf: Rename character prop targetType -> deviceType
There is actually a difference between the character device type (serial,
parallel, channel, ...) and the target type (virtio, guestfwd). Currently
they are awkwardly conflated.

Start to pull them apart by renaming targetType -> deviceType. This is
an entirely mechanical change.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2010-07-28 16:47:57 -04:00
Matthias Bolte
d3864c3782 esx: Support vSphere 4.1
Also accept version > 4.1, but output a warning.
2010-07-24 21:22:54 +02:00
Matthias Bolte
3827f7f087 esx: Add vpx:// scheme to allow direct connection to a vCenter
Add a pointer to the primary context of a connection and use it in all
driver functions that don't dependent on the context type. This includes
almost all functions that deal with a virDomianPtr. Therefore, using
a vpx:// connection allows you to perform all the usual domain related
actions like start, destroy, suspend, resume, dumpxml etc.

Some functions that require an explicitly specified ESX server don't work
yet. This includes the host UUID, the hostname, the general node info, the
max vCPU count and the free memory. Also not working yet are migration and
defining new domains.
2010-07-24 20:46:05 +02:00
Matthias Bolte
1b38e92b7a esx: Don't ignore the vcenter query parameter
Since 070f61002f the vcenter query
parameter has been ignored, because the refactoring to use
esxUtil_ParseQuery was incomplete. This effectively broke migration,
because the vcenter query parameter is essential for a migration.
2010-07-24 17:31:05 +02:00
Matthias Bolte
cf8cf8a59f esx: Add autodetection for the SCSI controller model
This works for file-backed SCSI disk device with a datastore
related source path.
2010-07-24 17:31:04 +02:00
Matthias Bolte
afb85c5889 esx: Allow 'vmpvscsi' as SCSI controller model 2010-07-24 17:31:04 +02:00
Chris Lalancette
21adf03c2d Qemu Monitor API entry point.
Add the library entry point for the new virDomainQemuMonitorCommand()
entry point.  Because this is not part of the "normal" libvirt API,
it gets its own header file, library file, and will eventually
get its own over-the-wire protocol later in the series.

Changes since v1:
 - Go back to using the virDriver table for qemuDomainMonitorCommand, due to
   linking issues
 - Added versioning information to the libvirt-qemu.so

Changes since v2:
 - None

Changes since v3:
 - Add LGPL header to libvirt-qemu.c
 - Make virLibConnError and virLibDomainError macros instead of function calls

Changes since v4:
 - Move exported symbols to libvirt_qemu.syms

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:14 -04:00
Matthias Bolte
8aa08ea873 esx: Make esxVI_*_Deserialize dynamically dispatched
This will be used to deserialize the response from a call
to esxVI_SearchDatastore_Task properly.
2010-07-13 18:44:14 +02:00
Matthias Bolte
e214bcf37c esx: Use bool instead of int where appropriated 2010-06-24 14:56:04 +02:00
Matthias Bolte
d72d92565b esx: Add support for the controller element
Also don't abuse the disk driver name to specify the SCSI controller
model anymore:

  <driver name='buslogic'/>

Use the newly added model attribute of the controller element for this:

  <controller type='scsi' index='0' model='buslogic'/>

The disk driver name approach is deprecated now, but still works for
backward compatibility reasons.

Update the documentation and tests accordingly.

Fix usage of the words controller and id in the VMX handling code. Use
controller, bus and unit properly.
2010-06-24 14:56:04 +02:00
Matthias Bolte
f8f29b1fc2 Add wide SCSI bus disk address generation support
The domain XML parsing code autogenerates disk address and
controller elements when they are not explicitly specified.
The code assumes a narrow SCSI bus (7 units per bus). ESX
uses a wide SCSI bus (16 units per bus).

This is a step towards controller support for the ESX driver.
2010-06-24 14:56:04 +02:00
Matthias Bolte
b0f414c67b esx: Accept 'disk' as harddisk device type in .vmx files 2010-06-16 23:06:12 +02:00
Eric Blake
de3aadaa71 drivers: add virDomainCreateWithFlags if virDomainCreate exists
* src/esx/esx_driver.c (esxDomainCreate): Move guts...
(esxDomainCreateWithFlags): ...to new function.
(esxDriver): Trivially support the new API.
* src/lxc/lxc_driver.c (lxcDomainStart, lxcDomainStartWithFlags)
(lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDomainStart)
(oneDomainStartWithFlags, oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDomainCreate)
(openvzDomainCreateWithFlags, openvzDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainStart)
(qemudDomainStartWithFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testDomainCreate)
(testDomainCreateWithFlags, testDriver): Likewise.
* src/uml/uml_driver.c (umlDomainStart, umlDomainStartWithFlags)
(umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainCreate)
(vboxDomainCreateWithFlags, Driver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainCreate)
(xenUnifiedDomainCreateWithFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainCreate)
(xenapiDomainCreateWithFlags, xenapiDriver): Likewise.
2010-06-15 09:37:11 -06:00
Eric Blake
460ca88b98 libvirt: introduce domainCreateWithFlags API
Persistent domain creation needs the same features as transient
domains, but virDomainCreate lacks the flags argument present in
virDomainCreateXML.  virDomainCreateFlags is already claimed as
a public enum, so we have to break convention and expose
virDomainCreateWithFlags.

* include/libvirt/libvirt.h.in (virDomainCreateWithFlags): Add.
* src/driver.h (virDrvDomainCreateWithFlags): Internal API.
* src/libvirt.c (virDomainCreateWithFlags): Glue public API to
driver API.
* src/libvirt_public.syms (LIBVIRT_0.8.2): Expose public API.
* src/esx/esx_driver.c (esxDriver): Add stub for driver.
* src/lxc/lxc_driver.c (lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/test/test_driver.c (testDriver): Likewise.
* src/uml/uml_driver.c (umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (Driver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.
2010-06-15 07:32:41 -06:00
Matthias Bolte
46c14d2045 esx: Add proxy query parameter
Allow to specify a proxy to be used by libcurl.
2010-06-09 12:55:02 +02:00
Matthias Bolte
070f61002f esx: Refactor esxUtil_ParseQuery's parameter handling
Pass a struct containing the parameters instead of passing each
one individually. This make future extensions a bit simpler.
2010-06-09 11:29:09 +02:00
Matthias Bolte
041aac8648 esx: Simplify goto usage
Eliminate almost all backward jumps by replacing this common pattern:

int
some_random_function(void)
{
    int result = 0;
    ...

  cleanup:
    <unconditional cleanup code>
    return result;

  failure:
    <cleanup code in case of an error>
    result = -1;
    goto cleanup
}

with this simpler pattern:

int
some_random_function(void)
{
    int result = -1;
    ...
    result = 0;

  cleanup:
    if (result < 0) {
        <cleanup code in case of an error>
    }

    <unconditional cleanup code>
    return result;
}

Add a bool success variable in functions that don't have a int result
that can be used for the new pattern.

Also remove some unnecessary memsets in error paths.
2010-05-27 01:32:25 +02:00
Matthias Bolte
b4cead5949 esx: Expose host UUID in the capabilities XML
Parse the BIOS UUID. This information may not be available, in that
case no host UUID is exposed in the capabilities XML.
2010-05-27 00:03:57 +02:00
Matthias Bolte
ddb4ae0ca9 esx: Add read-only storage pool access
Allows listing existing pools and requesting information about them.

Alter the esxVI_ProductVersion enum in a way that allows to check for
product type by masking.
2010-05-26 12:01:27 +02:00
Jim Meyering
82a3c81d8c maint: VIR_ERROR/VIR_ERROR0: mark up the remaining ones manually
Handle concatenated strings manually.
2010-05-20 21:36:25 +02:00
Jim Meyering
8d63d82e5c maint: mark translatable string args of VIR_ERROR0
Run this:
  git grep -l 'VIR_ERROR0\s*("'|xargs perl -pi -e \
    's/(VIR_ERROR0)\s*\((".*?")\)/$1(_($2))/'
2010-05-20 21:36:25 +02:00
Matthias Bolte
894baa0af8 esx: Make esxVI_*_CastFromAnyType dynamically dispatched
This will be used in the ESX storage driver in order to handle
the DatastoreInfo type and inheriting types properly.
2010-05-20 00:00:34 +02:00
Matthias Bolte
90fce23f24 esx: Allow esxVI_X_DynamicCast to be called successfully on X objects
This semantic will be used in the ESX storage driver.
2010-05-20 00:00:31 +02:00
Eric Blake
e8a1a730fe build: update gnulib
* .gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Import netdb.
* src/esx/esx_util.c (AI_ADDRCONFIG): Rely on gnulib.
* src/remote/remote_driver.c (AI_ADDRCONFIG): Likewise.
* tools/virsh.c (WEXITSTATUS, O_SYNC): Likewise.
2010-05-11 10:03:48 -06:00
Daniel P. Berrange
46bad5121f Internal driver API infrastructure for virDomainGetBlockInfo
This defines the internal driver API and stubs out each driver

* src/driver.h: Define virDrvDomainGetBlockInfo signature
* src/libvirt.c, src/libvirt_public.syms: Glue public API to drivers
* 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/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 driver
2010-04-29 17:20:24 +01:00
Eric Blake
84bc7ac06b build: fix preprocessor indentation
* src/esx/esx_vi.h: Placate cppi.
2010-04-21 10:05:01 -06:00
Chris Wong
b1fab0c21c esx: Don't treat an empty root snapshot list as error
An empty root snapshot list was considered as error condition. Creating a
new snapshot would fail if the domain didn't have snapshots yet, because
the snapshot-create function tries to lookup the list of existing snapshots
in order to verify that the snapshot name is unique. This fails if the
domain doesn't have snapshots yet.

Removing the NULL check from esxVI_LookupRootSnapshotTreeList fixes this.
2010-04-21 11:47:15 +02:00
Matthias Bolte
3f52921d43 esx: Gather some XML generation macros in esx_vi.h 2010-04-21 00:44:24 +02:00
Matthias Bolte
7a056d0648 esx: Fix FindByIp response handling
FindByIp may return nothing if there is no host or virtual machine
with the given IP address. Handle that case properly.
2010-04-21 00:44:18 +02:00
Matthias Bolte
1d8099f4b6 esx: Fix virtualHW.version generation
The supported virtualHW.version doesn't depend on the API version,
but on the product version.
2010-04-21 00:37:46 +02:00
Matthias Bolte
c6375aa796 esx: Add support for the VMXNET 2 (Enhanced) NIC model
Add a test case and document it.
2010-04-20 20:58:24 +02:00
Jiri Denemark
7a2c6222a9 Use virCheckFlags for APIs added in 0.8.0 2010-04-16 14:05:50 +02:00
Matthias Bolte
3a7f2fc3b2 esx: Replace scanf with STRSKIP and strtok_r
This also fixes a portability problem with the %a format modifier.
%a is not portable and made esxDomainDumpXML fail at runtime in
MinGW builds.
2010-04-15 19:52:38 +02:00
Matthias Bolte
77408cc0e1 esx: Add nwfilter driver stub
This stops libvirt trying to connect to a non-existing libvirtd on the
ESX server in order to find a nwfilter driver.
2010-04-15 19:52:38 +02:00
Eric Blake
cffe619bdf build: fix recent 'make syntax-check' failure
* src/esx/esx_vi_methods.h: Placate cppi.
2010-04-14 11:23:09 -06:00
Matthias Bolte
71057b1c58 esx: Extend esx_vi_generator.py to cover methods too
Generate almost all SOAP method mapping code.

Update the driver code to use the complete paramater list of some methods
that had parameters skipped before.

Improve the ESX_VI__METHOD marco to do automatic output deserialization
based on output occurrence. Also incorporate automatic _this binding and
output pointer check.
2010-04-14 12:01:33 +02:00
Jim Meyering
dc8dd7f8db esxVMX_GatherSCSIControllers: avoid NULL dereference
* src/esx/esx_vmx.c (esxVMX_GatherSCSIControllers): Do not dereference
a NULL disk->driverName.  We already detect this condition in another
case.  Check for it here, too.
2010-04-14 11:59:18 +02:00
Matthias Bolte
1aaa909116 esx: Add domain snapshot support
Fix invalid code generating in esx_vi_generator.py regarding deep copy
types that contain enum properties.

Add strptime and timegm to bootstrap.conf. Both are used to convert a
xsd:dateTime to calendar time.

Add a testcase of the xsd:dateTime conversion.
2010-04-08 21:54:43 +02:00
Matthias Bolte
4acab37f56 esx: Allow 'lsisas1068' as SCSI controller type
Extend tests to cover all SCSI controller types and document the
new type.

The lsisas1068 SCSI controller type was added in ESX 4.0. The VMX
parser reports an error when this controller type is present. This
makes virsh dumpxml fail for every domain that uses this controller
type.

This patch fixes this and adds lsisas1068 to the list of accepted
SCSI controller types.

Reported by Jonathan Kelley.
2010-04-08 12:05:51 +02:00
Matthias Bolte
fba503c368 esx: Report an error for invalid arguments in esxList(Defined)Domains 2010-04-08 11:58:33 +02:00
Matthias Bolte
028db0bf5d esx: Mark error messages for translation
Also define ESX_ERROR and ESX_VI_ERROR in a central place, instead of
defining them in each source file.

Add ESX_ERROR and ESX_VI_ERROR to the msg_gen_function list in cfg.mk.

Update po/POTFILES.in accordingly.
2010-04-06 19:24:24 +02:00
Chris Lalancette
2f992d4be4 Snapshot API framework.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:24:34 -04:00
Daniel Veillard
15c647a91e Add managed save API entry points
virDomainManagedSave() is to be run on a running domain. Once the call
complete, as in virDomainSave() the domain is stopped upon completion,
but there is no restore counterpart as any order to start the domain
from the API would load the state from the managed file, similary if
the domain is autostarted when libvirtd starts.
Once a domain has restarted his managed save image is destroyed,
basically managed save image can only exist for a stopped domain,
for a running domain that would be by definition outdated data.

* include/libvirt/libvirt.h.in src/libvirt.c src/libvirt_public.syms:
  adds the new entry points virDomainManagedSave(),
  virDomainHasManagedSaveImage() and virDomainManagedSaveRemove()
* src/driver.h 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/vbox/vbox_tmpl.c
  src/remote/remote_driver.c src/test/test_driver.c src/uml/uml_driver.c
  src/xen/xen_driver.c: add corresponding new internal drivers entry
  points
2010-04-04 11:07:48 +02:00
Matthias Bolte
56bac4a221 Refactor major.minor.micro version parsing into a function
virParseVersionString uses virStrToLong_ui instead of sscanf.

This also fixes a bug in the UML driver, that always returned 0
as version number.

Introduce STRSKIP to check if a string has a certain prefix and
to skip this prefix.
2010-04-01 12:53:41 +02:00
Eric Blake
9d6614df86 maint: remove redundant tests after virStrToLong
virStrToLong* guarantees (via strtol) that the end pointer will be set
to the point at which parsing stopped (even on failure, this point is
the start of the input string).

* src/esx/esx_driver.c (esxGetVersion): Remove pointless
conditional.
* src/qemu/qemu_conf.c (qemuParseCommandLinePCI)
(qemuParseCommandLineUSB, qemuParseCommandLineSmp): Likewise.
* src/qemu/qemu_monitor_text.c
(qemuMonitorTextGetMigrationStatus): Likewise.
2010-03-31 08:58:46 -06:00
Jim Meyering
3cda0eb487 maint: fix cpp indentation syntax-check failure
* src/esx/esx_vi_types.h: Filter through cppi.
2010-03-31 16:32:38 +02:00
Matthias Bolte
63c0c9a77f esx: Remove redundant semicolons 2010-03-31 13:36:54 +02:00
Matthias Bolte
50723581b0 esx: Generate most SOAP mapping and improve inheritance handling
The Python script generates the mappings based on the type descriptions
in the esx_vi_generator.input file.

This also improves the inheritance handling and allows to get rid of the
ugly, inflexible, and error prone _base/_super approach. Now every struct
that represents a SOAP type contains a _type member, that allows to
recreate C++-like dynamic dispatch for "method" calls in C.
2010-03-31 13:36:54 +02:00
Daniel P. Berrange
46a2ea3689 Introduce a new virDomainUpdateDeviceFlags public API
The current virDomainAttachDevice API can be (ab)used to change
the media of an existing CDROM/Floppy device. Going forward there
will be more devices that can be configured on the fly and overloading
virDomainAttachDevice for this is not too pleasant. This patch adds
a new virDomainUpdateDeviceFlags() explicitly just for modifying
existing devices.

* include/libvirt/libvirt.h.in: Add virDomainUpdateDeviceFlags
* src/driver.h: Internal API for virDomainUpdateDeviceFlags
* src/libvirt.c, src/libvirt_public.syms: Glue public API to
  driver API
* 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: Add
  stubs for new driver entry point
2010-03-26 14:13:28 +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
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
Jiri Denemark
7f7849c996 Internal driver API for virDomainMigrateSetMaxDowntime 2010-03-19 22:20:42 +01: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
Matthias Bolte
3cdc4cb613 esx: Move username and password helper functions to authhelper.c 2010-03-16 20:15:32 +01:00
Eric Blake
36d8e7d8d7 build: consistently indent preprocessor directives
* global: patch created by running:
for f in $(git ls-files '*.[ch]') ; do
    cppi $f > $f.t && mv $f.t $f
done
2010-03-09 19:22:28 +01:00
Eric Blake
2e56fb2bcc build: consistently use C99 varargs macros
Prior to this patch, there was an inconsistent mix between GNU and C99.

For consistency, and potential portability to other compilers, stick
with the C99 vararg macro syntax.

* src/conf/cpu_conf.c (virCPUReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/conf/domain_conf.c (virDomainReportError): Likewise.
* src/conf/domain_event.c (eventReportError): Likewise.
* src/conf/interface_conf.c (virInterfaceReportError): Likewise.
* src/conf/network_conf.c (virNetworkReportError): Likewise.
* src/conf/node_device_conf.h (virNodeDeviceReportError): Likewise.
* src/conf/secret_conf.h (virSecretReportError): Likewise.
* src/conf/storage_conf.h (virStorageReportError): Likewise.
* src/esx/esx_device_monitor.c (ESX_ERROR): Use C99 rather than
  GNU vararg macro syntax.
* src/esx/esx_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_interface_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_network_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_secret_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_storage_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_util.c (ESX_ERROR): Likewise.
* src/esx/esx_vi.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vi_methods.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vi_types.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vmx.c (ESX_ERROR): Likewise.
* src/util/hostusb.c (usbReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/util/json.c (virJSONError): Likewise.
* src/util/macvtap.c (ReportError): Likewise.
* src/util/pci.c (pciReportError): Likewise.
* src/util/stats_linux.c (virStatsError): Likewise.
* src/util/util.c (virUtilError): Likewise.
* src/util/xml.c (virXMLError): Likewise.
* src/xen/proxy_internal.c (virProxyError): Use C99 rather than
  GNU vararg macro syntax.
* src/xen/sexpr.c (virSexprError): Likewise.
* src/xen/xen_driver.c (xenUnifiedError): Likewise.
* src/xen/xen_hypervisor.c (virXenError): Likewise.
* src/xen/xen_inotify.c (virXenInotifyError): Likewise.
* src/xen/xend_internal.c (virXendError): Likewise.
* src/xen/xm_internal.c (xenXMError): Likewise.
* src/xen/xs_internal.c (virXenStoreError): Likewise.
* src/cpu/cpu.h (virCPUReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/datatypes.c (virLibConnError): Likewise.
* src/interface/netcf_driver.c (interfaceReportError): Likewise.
* src/libvirt.c (virLibStreamError): Likewise.
* src/lxc/lxc_conf.h (lxcError): Likewise.
* src/network/bridge_driver.c (networkReportError): Likewise.
* src/nodeinfo.c (nodeReportError): Likewise.
* src/opennebula/one_conf.h (oneError): Likewise.
* src/openvz/openvz_conf.h (openvzError): Likewise.
* src/phyp/phyp_driver.c (PHYP_ERROR): Likewise.
* src/qemu/qemu_conf.h (qemuReportError): Likewise.
* src/remote/remote_driver.c (errorf): Likewise.
* src/security/security_driver.h (virSecurityReportError): Likewise.
* src/test/test_driver.c (testError): Likewise.
* src/uml/uml_conf.h (umlReportError): Likewise.
* src/vbox/vbox_driver.c (vboxError): Likewise.
* src/vbox/vbox_tmpl.c (vboxError): Likewise.
2010-03-08 13:32:27 +01:00
Eric Blake
a8464c516b esx: don't ignore failure on close
Another warning caught by coverity.  Continue to perform best-effort
closing and resource release, but warn the caller about the failure.

* src/esx/esx_driver.c (esxClose): Return an error on failure to close.
2010-03-03 11:22:46 +01:00
Daniel P. Berrange
0d8aa35f60 Wire up internal entry points for virDomainAbortJob API
This provides the internal glue for the driver API

* src/driver.h: Internal API contract
* src/libvirt.c, src/libvirt_public.syms: Connect public API
  to driver API
* 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: Stub out entry points
2010-03-02 16:23:31 +00:00
Daniel P. Berrange
92bd859a29 Stub out internal driver entry points for job processing
The internal glue layer for the new pubic API

* src/driver.h: Define internal driver API contract
* src/libvirt.c, src/libvirt_public.syms: Wire up public
  API to internal driver API
* 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: Stub new entry point
2010-03-02 16:22:31 +00:00
Jiri Denemark
53c05341d4 Internal driver API for virConnectBaselineCPU 2010-02-12 14:23:53 +01:00
Daniel P. Berrange
65842bf669 Remove virConnectPtr from all domain XML parsing/formatting APIs 2010-02-10 11:49:23 +00:00
Matthias Bolte
d5c6183def Remove conn parameter from virXPath* functions
It was used for error reporting only.
2010-02-09 01:04:54 +01:00
Matthias Bolte
8ce5e2c1ab Remove conn parameter from virReportOOMError 2010-02-09 01:04:54 +01:00
Jim Fehlig
ed9c14a7ef domain{Attach,Detach}DeviceFlags handler for drivers
Implementation of domain{Attach,Detach}DeviceFlags handlers
in the drivers.
2010-02-08 10:49:43 -07:00
Matthias Bolte
af25361762 esx: Remove unnecessary casts 2010-02-04 19:09:28 +01:00
Matthias Bolte
a6b00cbb16 esx: Cleanup preprocessing structure in esxVI_EnsureSession 2010-02-04 19:09:28 +01:00
Matthias Bolte
ef088ed962 esx: Output error details from libcurl 2010-01-26 21:23:18 +01:00
Matthias Bolte
854111f97e esx: Stop passing around virConnectPtr for error reporting 2010-01-26 01:19:23 +01:00
Jim Meyering
61defb6bcc esx_vi_types.c: include required headers
* src/esx/esx_vi_types.c: Include <stdint.h>.
2010-01-18 09:50:08 +01:00
Matthias Bolte
c2c4d51b2f esx: Add VNC support
* src/conf/domain_conf.c: add defaults for the video device
* src/esx/esx_vmx.[ch]: add VNC support to the VMX handling
* tests/vmx2xmltest.c, tests/xml2vmxtest.c: add tests for the VNC support
2010-01-18 01:44:20 +01:00
Matthias Bolte
58fe995e50 esx: Make the domain part of the hostname optional
Before the driver assumed that there is always a domain part. That's
not true. Now the domain part is handled as optional.
2010-01-18 01:21:37 +01:00
Matthias Bolte
d6c40aaec8 esx: Add stubs for secondary driver types
This stops libvirt from probing for a libvirtd on the ESX server and
sets the base for the implementation of the secondary drivers.
2010-01-18 01:15:11 +01:00
Matthias Bolte
7003390791 esx: Dump the raw response in case of an SOAP fault
Currently only the faultcode and faultstring are deserialized, the
detail part is ignored. The implementation of many new SOAP types
would be necessary to deserialize the detail part correctly. As an
intermediate solution the raw response is dumped to the debug log.
2010-01-08 19:28:14 +01:00
Matthias Bolte
75b7f400f9 esx: Warn if the ESX server is in maintenance mode 2010-01-08 19:28:09 +01:00
Matthias Bolte
96ceb12443 esx: Fix 'vpx' MAC address range and allow arbitrary MAC addresses
The MAC addresses with 00:50:56 prefix are split into several ranges:

  00:50:56:00:00:00 - 00:50:56:3f:ff:ff  'static' range (manually assigned)
  00:50:56:80:00:00 - 00:50:56:bf:ff:ff  'vpx' range (assigned by a VI Client)

Erroneously the 'vpx' range was assumed to be larger and to occupy the
remaining addresses of the 00:50:56 prefix that are not part of the 'static'
range.

00:50:56 was used as prefix for generated MAC addresses, this is not possible
anymore, because there are gaps in the allowed ranges. Therefore, change the
prefix to 00:0c:29 which is the prefix for auto generated MAC addresses anyway.

Allow arbitrary MAC addresses to be used and set the checkMACAddress VMX option
to false in case the MAC address doesn't fall into any predefined range.

* docs/drvesx.html.in: update website accordingly
* src/esx/esx_driver.c: set the auto generation prefix to 00:0c:29
* src/esx/esx_vmx.c: fix MAC address range handling and allow arbitrary MAC
  addresses
* tests/vmx2xml*, tests/xml2vmx*: add some basic MAC address range tests
2010-01-07 01:38:19 +01:00
Matthias Bolte
79f9419652 esx: Fix deserialization for VI API calls CancelTask and UnregisterVM 2010-01-07 01:38:19 +01:00
Matthias Bolte
d9734072ff esx: Fix and improve the libcurl debug callback
The data passed to the callback is not guaranteed to be zero terminated,
take care of that by coping the data and adding a zero terminator.

Also dump the data for other types than CURLINFO_TEXT.

Set CURLOPT_VERBOSE to 1 so the debug callback is called when enabled.
2010-01-07 01:38:19 +01:00
Matthias Bolte
b0367e86ee esx: Don't warn about an empty URI path 2010-01-07 01:38:19 +01:00