Commit Graph

2252 Commits

Author SHA1 Message Date
Cole Robinson
08dce95a74 test: Update vcpu runtime info in SetVcpus 2009-11-03 17:31:17 -05:00
Cole Robinson
667ce28946 test: Use privateData to track running VM vcpu state 2009-11-03 17:31:17 -05:00
Cole Robinson
4e40aee273 test: Break out wrapper for setting up started domain state.
This should be a no op for now, but we will use this function to set up
transient state in the future.
2009-11-03 17:31:16 -05:00
Cole Robinson
7624b47d1e test: Fixes for SetVcpus
- Implement DomainGetMaxVCPUs
- Use GetMaxVCPUs to validate requested CPU amount
- Deny the 'hotplug' for a running domain.
2009-11-03 17:31:16 -05:00
Cole Robinson
2f5115627b qemu: Remove compiled out localhost migration support
Pretty sure this would deadlock now that we have proper locking, so
remove the code.
2009-11-03 16:46:54 -05:00
Cole Robinson
030db0c2ec storage: conf: Fix memory leak in encryption parsing 2009-11-03 16:46:54 -05:00
Cole Robinson
4c44cdcce3 Various error reporting fixes
- Don't duplicate SystemError
- Use proper error code in domain_conf
- Fix a broken error call in qemu_conf
- Don't use VIR_ERR_ERROR in security driver (isn't a valid code in this case)
2009-11-03 16:46:54 -05:00
Cole Robinson
517761fd96 Improve error reporting for virConnectGetHostname calls
All drivers have copy + pasted inadequate error reporting which wraps
util.c:virGetHostname. Move all error reporting to this function, and improve
what we report.

Changes from v1:
  Drop the driver wrappers around virGetHostname. This means we still need
  to keep the new conn argument to virGetHostname, but I think it's worth
  it.
2009-11-03 16:46:54 -05:00
Laine Stump
af1e2ede26 Fix improper error return in virInterfaceDefParseProtoIPvX
* src/conf/interface_conf.c: the code was erronously returning -1
  in the two functions if <dhcp> is not provided
2009-11-03 21:04:56 +01:00
Laine Stump
468439854b Make monitor type (miimon/arpmon) optional in bond xml
* src/conf/interface_conf.c: lack of one of these in the live xml output
  was causing the parse in virInterfaceDefParseBond() to fail
2009-11-03 21:04:56 +01:00
Laine Stump
23eaae9aff Fix virInterfaceIpDefPtr leak during virInterfaceIpDefFree
* src/conf/interface_conf.c: forgot to free the structure itself
2009-11-03 21:04:56 +01:00
Laine Stump
3d4c1d94d7 Support for IPv6 / multiple addresses per interfaces
This patch updates the xml parsing and formatting, and the associated
virInterfaceDef data structure to support IPv6, along the way adding
support for multiple protocols per interface, and multiple IP
addresses per protocol.
* src/conf/interface_conf.[ch]: update the structures, code for parsing
  and serialization
2009-11-03 21:04:56 +01:00
Laine Stump
753c6c9c75 Support reporting live interface IP/netmask
This patch adds the flag VIR_INTERFACE_XML_INACTIVE to
virInterfaceGetXMLDesc's flags. When it is*not* set (the default), the
live interface info will be returned in the XML (in particular, the IP
address(es) and netmask(s) will be retrieved by querying the interface
directly, rather than  reporting what's in the config file). The
backend of this is in netcf's ncf_if_xml_state() function.

* configure.in libvirt.spec.in: requires netcf >= 0.1.3
* include/libvirt/libvirt.h.in: adds flag VIR_INTERFACE_XML_INACTIVE
* src/conf/interface_conf.c src/interface/netcf_driver.c src/libvirt.c:
  update the parsing and backend routines accordingly
* tools/virsh.c: change interface edit to inactive definition and
  adds the inactive flag for interface dump
2009-11-03 21:04:56 +01:00
Laine Stump
ef591ef7b9 Make startmode optional in toplevel interface definition
The minimal XML returned from ncf_if_xml_state() doesn't contain this
attribute (which makes no sense in the case of reporting current
status of the interface), and it was preventing it from passing
through the parse/format step.

* src/conf/interface_conf.[ch]: add a new virInterfaceStartMode value
  and modify loading/saving accordingly
2009-11-03 21:04:56 +01:00
Laine Stump
4728bad403 Allow NULL mac address in virGetInterface
There are places where an interface will not have a mac address, and netcf
returns this as a NULL pointer rather than a pointer to an empty string.
Rather than checking for this all over the place in libvirt, just save it
in the virInterface object as an empty string.

* src/datatypes.c: allow NULL mac in virGetInterface()
2009-11-03 16:42:53 +01:00
Daniel Veillard
112ed8f50d Fix compilation problems
introduced on commit 9231aa7d95
* src/qemu/qemu_driver.c: in qemudRemoveDomainStatus fix a reference
  to an undefined variable buf and free up an allocated string
2009-11-03 16:24:46 +01:00
Chris Lalancette
991be60403 Fix up NLS warnings.
When building with --disable-nls, I got a few messages like this:

storage/storage_backend.c: In function 'virStorageBackendCreateQemuImg':
storage/storage_backend.c:571: warning: format not a string literal and no format arguments

Fix these up.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-11-03 16:19:40 +01:00
Chris Lalancette
9231aa7d95 Remove redundant virFileDeletePID() call
qemudShutdownVMDaemon() calls qemudRemoveDomainStatus(), which
then calls virFileDeletePID().  qemudShutdownVMDaemon() then
unnecessarily calls virFileDeletePID() again.  Remove this second
usage of it, and also slightly refactor qemudRemoveDomainStatus()
to VIR_WARN appropriate error messages.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-11-03 16:19:28 +01:00
Daniel P. Berrange
979218cdd9 Fix return value in virStateInitialize impl for LXC
The LXC driver was mistakenly returning -1 for lxcStartup()
in scenarios that are not an error. This caused the libvirtd
to quit for unprivileged users. This fixes the return code
of LXC driver, and also adds a "name" field to the virStateDriver
struct and logging to make it easier to find these problems
in the future

* src/driver.h: Add a 'name' field to state driver to allow
  easy identification during failures
* src/libvirt.c: Log name of failed driver for virStateInit
  failures
* src/lxc/lxc_driver.c: Don't return a failure code for
  lxcStartup() if LXC is not available on this host, simply
  disable the driver.
* src/network/bridge_driver.c, src/node_device/node_device_devkit.c,
  src/node_device/node_device_hal.c, src/opennebula/one_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/secret/secret_driver.c, src/storage/storage_driver.c,
  src/uml/uml_driver.c, src/xen/xen_driver.c: Fill in name
  field in virStateDriver struct
2009-11-02 18:20:14 -05:00
Matthias Bolte
680c92ae7e ESX: Fix memory leak in list handling functions.
If an error occurs between the allocation of an item and appending it
to the list, the item leaks. Free such orphaned items in error cases.

* src/esx/esx_vi.c: free orphaned items in error cases
2009-11-02 22:22:13 +01:00
Matthias Bolte
b79aaf91b8 ESX: Don't automatically follow redirects.
The default transport for the VI API is HTTPS. If the server redirects
from HTTPS to HTTP the driver would silently follow that redirection.
The user assumes to communicate with the server over a secure transport
but isn't.

This patch disables automatical redirection following. The driver reports
an error if the server tries to redirect.

* src/esx/esx_vi.c: refactor the call to curl_easy_perform() into a
  function and do error handling there, disable automatical redirection
  following for curl
* src/esx/esx_vi.h: change the type of responseCode to int
2009-11-02 22:22:13 +01:00
Matthias Bolte
447ef8863c ESX: Unify naming of VI API utility and convenience functions.
Unified function naming scheme:
- 'lookup' functions query the ESX or vCenter for information
- 'get' functions return information from a local object

* src/esx/esx_driver.c, src/esx/esx_vi.[ch]: unify function naming
2009-11-02 22:22:12 +01:00
Matthias Bolte
7c7681dd90 ESX: Change disk selection for datastore detection.
In order to register a new virtual machine the ESX driver needs to upload
a VMX file to a datastore. Try to put this file beside the main VMDK file
of the virtual machine. Change the disk selection for datastore detection
to choose the first file-based harddisk instead of just the first disk.
The first disk may be a CDROM disk and ISO images are normaly not located
in the virtual machine's directory.

* src/esx/esx_driver.c: change disk selection for datastore detection
2009-11-02 22:22:12 +01:00
Matthias Bolte
b7abcf9d71 ESX: Fallback to the preliminary name if the datastore cannot be found.
This allows to use domain-xml-from-native with VMX files that reference
unavailable datastores.

* src/esx/esx_vmx.c: fallback to the preliminary name if the datastore
  cannot be found
2009-11-02 22:22:12 +01:00
Daniel P. Berrange
fc8d199188 Rename internal APis
Rename virDomainIsActive to virDomainObjIsActive, and
virInterfaceIsActive to virInterfaceObjIsActive and finally
virNetworkIsActive to virNetworkObjIsActive.

* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/conf/interface_conf.h, src/conf/network_conf.c,
  src/conf/network_conf.h, src/lxc/lxc_driver.c,
  src/network/bridge_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c: Update for
  renamed APIs.
2009-11-02 11:58:55 -05:00
Yuji NISHIDA
8001eef5d0 Set KMEMSIZE for OpenVZ domains being defined
* src/openvz/openvz_driver.c: add a new openvzDomainSetMemoryInternal()
  function, used to initialize the KMEMSIZE parameter of a container.
2009-11-02 17:39:46 +01:00
Daniel P. Berrange
46992453b9 Annotate many methods with ATTRIBUTE_RETURN_CHECK & fix problems
Nearly all of the methods in src/util/util.h have error codes that
must be checked by the caller to correct detect & report failure.
Add ATTRIBUTE_RETURN_CHECK to ensure compile time validation of
this

* daemon/libvirtd.c: Add explicit check on return value of virAsprintf
* src/conf/domain_conf.c: Add missing check on virParseMacAddr return
  value status & report error
* src/network/bridge_driver.c: Add missing OOM check on virAsprintf
  and report error
* src/qemu/qemu_conf.c: Add missing check on virParseMacAddr return
  value status & report error
* src/security/security_selinux.c: Remove call to virRandomInitialize
  that's done in libvirt.c already
* src/storage/storage_backend_logical.c: Add check & log on virRun
  return status
* src/util/util.c: Add missing checks on virAsprintf/Run status
* src/util/util.h: Annotate all methods with ATTRIBUTE_RETURN_CHECK
  if they return an error status code
* src/vbox/vbox_tmpl.c: Add missing check on virParseMacAddr
* src/xen/xm_internal.c: Add missing checks on virAsprintf
* tests/qemuargv2xmltest.c: Remove bogus call to virRandomInitialize()
2009-11-02 11:09:03 -05:00
Daniel P. Berrange
3505790b85 Allow for a driver specific private data blob in virDomainObjPtr
The virDomainObjPtr object stores state about a running domain.
This object is shared across all drivers so it is not appropriate
to include driver specific state here. This patch adds the ability
to request a blob of private data per domain object instance. The
driver must provide a allocator & deallocator for this purpose

THis patch abuses the virCapabilitiesPtr structure for storing the
allocator/deallocator callbacks, since it is already being abused
for other internal things relating to parsing. This should be moved
out into a separate object at some point.

* src/conf/capabilities.h: Add privateDataAllocFunc and
  privateDataFreeFunc fields
* src/conf/domain_conf.c: Invoke the driver allocators / deallocators
  when creating/freeing virDomainObjPtr instances.
* src/conf/domain_conf.h: Pass virCapsPtr into virDomainAssignDef
  to allow access to the driver specific allocator function
* src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c: Update for
  change in virDomainAssignDef contract
2009-11-02 11:03:10 -05:00
Matthias Bolte
530d4463ba Don't use private struct member names of in6_addr
__in6_u.__u6_addr16 is the private name for this struct member,
s6_addr16 is the public one
* src/util/network.c: dont use the private field, but the public one.
2009-11-02 15:45:05 +01:00
Matthew Booth
c3cc4f8bad More network utility functions
* src/util/network.[ch] Add functions for address->text and get/set
  port number
* src/libvirt_private.syms: add new entry points
2009-11-02 15:42:47 +01:00
Matthew Booth
9899e08b8d Fix typo in network.c function comments
* src/util/network.c: fix a few typo
2009-10-30 16:39:57 +01:00
Daniel Veillard
37bc888b28 Add symbols from new network.h module
* src/libvirt_private.syms: keep all symbols from network.h private
2009-10-30 16:36:04 +01:00
Daniel Veillard
24c8fc5dff Set of new network related utilities
* src/util/network.h src/util/network.c: utilities to parse network
  addresses, check netmask and compute ranges
2009-10-30 15:44:53 +01:00
Daniel Veillard
47fec8eac2 Remote code caught EINTR making it ininterruptable
John Levon raised the issue that remoteIOEventLoop() poll call was
reissued after EINTR was caught making it uninterruptible.
* src/remote/remote_driver.c: catch EAGAIN instead as suggested by
  Richard Jones
2009-10-30 12:08:26 +01:00
Daniel P. Berrange
a3adcce795 Convert virDomainObjListPtr to use a hash of domain objects
The current virDomainObjListPtr object stores domain objects in
an array. This means that to find a particular objects requires
O(n) time, and more critically acquiring O(n) mutex locks.

The new impl replaces the array with a virHashTable, keyed off
UUID. Finding a object based on UUID is now O(1) time, and only
requires a single mutex lock. Finding by name/id is unchanged
in complexity.

In changing this, all code which iterates over the array had
to be updated to use a hash table iterator function callback.
Several of the functions which were identically duplicating
across all drivers were pulled into domain_conf.c

* src/conf/domain_conf.h, src/conf/domain_conf.c: Change
  virDomainObjListPtr to use virHashTable. Add a initializer
  method virDomainObjListInit, and rename virDomainObjListFree
  to virDomainObjListDeinit, since its not actually freeing
  the container, only its contents. Also add some convenient
  methods virDomainObjListGetInactiveNames,
  virDomainObjListGetActiveIDs and virDomainObjListNumOfDomains
  which can be used to implement the correspondingly named
  public API entry points in drivers
* src/libvirt_private.syms: Export new methods from domain_conf.h
* src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_conf.c, src/openvz/openvz_driver.c,
  src/qemu/qemu_driver.c, src/test/test_driver.c,
  src/uml/uml_driver.c, src/vbox/vbox_tmpl.c: Update all code
  to deal with hash tables instead of arrays for domains
2009-10-28 20:05:55 +00:00
Cole Robinson
66c6cc7c5e virterror: Add a missing 'break' for VIR_ERR_INVALID_SECRET 2009-10-28 11:30:42 -04:00
Cole Robinson
33b35313a3 qemu: migrate: Don't require manual URI to specify a port
The xen driver will generate a migration port if only a hostname is passed
in the optional migrate URI, so let's do the same in qemu.
2009-10-28 11:30:41 -04:00
Cole Robinson
64f920d056 Fix p2p migration without a passed uri. 2009-10-28 11:30:41 -04:00
Cole Robinson
48a7637d9f qemu: Fix an error message in GetVcpus 2009-10-28 11:30:40 -04:00
Cole Robinson
e5edc3f03a test: Support virStorageFindPoolSources
The results are hardcoded into the test driver, no option to read from a
testfile is implemented at this time.
2009-10-28 11:30:40 -04:00
Cole Robinson
d61fff3f4b storage: Add ParseSourceString function for use with FindPoolSources.
This will simplify adding FindPoolSources support to more pool backends in
the future (as well as the test driver).
2009-10-28 11:30:40 -04:00
Cole Robinson
9bcb174473 storage: Break out function to add pool source to a SourceList.
Similar in theory to *AssignDef type functions, this duplicate functionality
will be used by an future FindPoolSources implementations.
2009-10-28 11:30:39 -04:00
Cole Robinson
fcbbb289b6 storage: Break out pool source parsing to a separate function.
We need to parse a source XML block for FindPoolSources, so this is a step
in sharing the parsing. The new storage pool XML 2 XML tests cover this area
pretty well to ensure we aren't causing regressions.
2009-10-28 11:30:39 -04:00
Chris Lalancette
0d77396605 Update the documentation for virDomainMigrateToURI
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-10-28 16:27:04 +01:00
Paolo Bonzini
936565c701 Add support for an external TFTP boot server
This patch adds an optional attribute to the <bootp> tag, that
allows to specify a TFTP server address other than the address of
the DHCP server itself.

This can be used to forward the BOOTP settings of the host down to the
guest.  This is something that configurations such as Xen's default
network achieve naturally, but must be done manually for NAT.

* docs/formatnetwork.html.in: Document new attribute.
* docs/schemas/network.rng: Add it to schema.
* src/conf/network_conf.h: Add it to struct.
* src/conf/network_conf.c: Add it to parser and pretty printer.
* src/network/bridge_driver.c: Put it in the dnsmasq command line.
* tests/networkxml2xmlin/netboot-proxy-network.xml
  tests/networkxml2xmlout/netboot-proxy-network.xml
  tests/networkxml2xmltest.c: add new tests
2009-10-28 15:57:49 +01:00
Cole Robinson
16c1c0833b test: Support virNodeDeviceCreate and virNodeDeviceDestroy 2009-10-27 10:03:51 -04:00
Dan Kenigsberg
0b74bc622c Fix some typos in comments 2009-10-27 00:02:46 +01:00
Matthias Bolte
74c81b5d93 Fix problems in the Xen inotify driver.
In xenInotifyXendDomainsDirLookup() the wrong UUID variable is used
to search in the config info list.

In xenInotifyEvent() the event is dispatched if it's NULL.

Both were introduced in bc898df2c7.
2009-10-26 23:30:19 +01:00
Matthias Bolte
dfdfc601ac Fix error message in qemudLoadDriverConfig()
* src/qemu/qemu_conf.c: change the error message to refer to
  'cgroup_controllers' instead of 'cgroup_device_acl'
2009-10-26 23:30:19 +01:00
Chris Lalancette
d27098c054 Add a new syntax-check rule for gethostname.
We should always be using virGetHostname in place of
gethostname; thus add in a new syntax-check rule to make
sure no new uses creep in.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-10-26 10:34:27 +01:00