Commit Graph

3109 Commits

Author SHA1 Message Date
Daniel P. Berrange
5486abfe4e Fix API doc extractor to stop munging comment formatting
The python method help docs are copied across from the C
funtion comments, but in the process all line breaks and
indentation was being lost. This made the resulting text
and code examples completely unreadable. Both the API
doc extractor and the python generator were destroying
whitespace & this fixes them to preserve it exactly.

* docs/apibuild.py: Preserve all whitespace when extracting
  function comments. Print function comment inside a <![CDATA[
  section to fully preserve all whitespace. Look for the
  word 'returns' to describe return values, instead of 'return'
  to avoid getting confused with code examples including the
  C 'return' statement.
* python/generator.py: Preserve all whitespace when printing
  function help docs
* src/libvirt.c: Change any return parameter indicated by
  'return' to be 'returns', to avoid confusing the API extractor
* docs/libvirt-api.xml: Re-build for fixed descriptions
2009-09-28 14:08:25 +01:00
Mark McLoughlin
d104362d90 Fix cdub's surname spelling 2009-09-24 14:50:51 +01:00
Daniel Veillard
fe4bb32cba Added Matthias Bolte as commiter 2009-09-24 15:32:16 +02:00
Charles Duffy
ce37c3a109 Fix secret_driver compile warning, bug.
Set def to NULL in secretLoad(), otherwise we can access a
random pointer on error.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-24 12:58:53 +02:00
Charles Duffy
580ad29288 Fix unitialized variable in qemudDomainDetachHostPciDevice()
* src/qemu/qemu_driver.c: initialize detach var
2009-09-24 09:02:56 +01:00
Mark McLoughlin
6bfffce916 Fix a typo in virNetHasValidPciAddr() too
* src/conf/domain_conf.h: check domain/bus/slot, not domain/domain/slot
2009-09-24 08:55:55 +01:00
Jiri Denemark
3620e3cdcf Fix a typo in virDiskHasValidPciAddr()
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2009-09-24 08:55:14 +01:00
Matthias Bolte
b167672c74 ESX: Check if a datastore is accessible first
An inaccessible datastore has no valid URL property so don't
access its URI property.

* src/esx/esx_vi.c: esxVI_LookupDatastoreByName(): check if datastore is
  accessible before accessing its URL property
* src/esx/esx_vmx.c: update to changed datastore properties
2009-09-23 15:08:25 +02:00
Matthias Bolte
23b2497292 ESX remove phantom mode
* src/esx/esx_driver.c: remove phantom mode
2009-09-23 15:00:54 +02:00
Matthias Bolte
8ce9f2b161 ESX replace esxUtil_EqualSuffix() with virFileHasSuffix()
* src/esx/esx_util.[ch]: remove esxUtil_EqualSuffix()
* src/esx/esx_driver.c, src/esx/esx_vmx.c: replace esxUtil_EqualSuffix()
  with virFileHasSuffix()
2009-09-23 15:00:54 +02:00
Matthias Bolte
49faa15e4f ESX add esxDomainDefineXML()
A given domain XML gets converted to a VMX config, uploaded to the host
and registered as new virtual machine.

* src/esx/esx_driver.c: refactor datastore related path parsing into
  esxUtil_ParseDatastoreRelatedPath()
* src/esx/esx_util.[ch]: add esxUtil_ParseDatastoreRelatedPath()
* src/esx/esx_vi.[ch]: add esxVI_Context_UploadFile(), add datastores to
  the traversal in esxVI_BuildFullTraversalSpecList(), add
  esxVI_LookupDatastoreByName()
* src/esx/esx_vi_methods.[ch]: add esxVI_RegisterVM_Task()
* src/esx/esx_vi_types.c: make some error message more verbose
* src/esx/esx_vmx.[ch]: add esxVMX_AbsolutePathToDatastoreRelatedPath()
  to convert a path into a datastore related path, add esxVMX_ParseFileName()
  to convert from VMX path format to domain XML path format, extend the other
  parsing function to be datastore aware, add esxVMX_FormatFileName() to
  convert from domain XML path format to VMX path format, fix VMX ethernet
  entry formating
* tests/esxutilstest.c: add test for esxUtil_ParseDatastoreRelatedPath()
* tests/vmx2xmldata/*: update domain XML files to use datastore related paths
* tests/xml2vmxdata/*: update domain XML files to use datastore related paths,
  update VMX files to use absolute paths
2009-09-23 15:00:54 +02:00
Matthias Bolte
c3aa1f8bdb ESX add esxVI_Occurence enum to for occurences
Add esxVI_Occurence enum to describe expected occurence of items
* src/esx/esx_driver.c: update the use of esxVI_LookupVirtualMachineByUuid()
* src/esx/esx_vi.c: add an esxVI_Occurence parameter to
  esxVI_LookupVirtualMachineByUuid() and take care if esxVI_FindByUuid()
  can't find anything for a given uuid
* src/esx/esx_vi.h: add esxVI_Occurence enum
* src/esx/esx_vi_methods.c: expect null or more items to be returned
  from esxVI_FindByUuid()
2009-09-23 15:00:54 +02:00
Matthias Bolte
0d4d04e550 ESX Whitespace cleanup 2009-09-23 15:00:54 +02:00
Matthias Bolte
15b0c4ffdb ESX add x86_64 detection based on the CPUID
* src/esx/esx_driver.c: add esxSupportsLongMode() and update esxCapsInit()
* src/esx/esx_vi.[ch]: Add AnyType handling for lists
* src/esx/esx_vi_types.c: bind VI type HostCpuIdInfo
2009-09-23 15:00:54 +02:00
Matthias Bolte
af4c893eb7 ESX add tests for the VMX to/from domain XML mapping
* tests/.gitignore: ignore new test binaries
* tests/Makefile.am: add new tests
* tests/esxutilstest.c: test esxVMX_IndexToDiskName()
* tests/vmx2xmldata/*: config files for the VMX to domain XML test
* tests/vmx2xmltest.c: test the VMX to domain XML mapping
* tests/xml2vmxdata/*: config files for the domain XML to VMX test
* tests/xml2vmxtest.c: test the domain XML to VMX mapping
2009-09-23 15:00:54 +02:00
Matthias Bolte
a1c4d7d765 ESX Add esxDomainXMLToNative()
Extend and cleanup the VMX to domain XML mapping. Add the domain XML to
VMX mapping functions.

* src/esx/esx_driver.c: add esxDomainXMLToNative()
* src/esx/esx_vmx.[ch]: add esxVMX_SCSIDiskNameToControllerAndID(),
  esxVMX_IDEDiskNameToControllerAndID(), esxVMX_FloppyDiskNameToController(),
  esxVMX_GatherSCSIControllers(), add basic handling for the VMX guestOS entry
  to distinguish between i686 and x86_64, make SCSI virtualDev VMX entry
  optional as it should be, map the VMX networkName entry to the domain XML
  interface bridge name, add basic mapping for serial devices in pipe mode,
  add several esxVMX_Format*() functions
2009-09-23 15:00:54 +02:00
Matthias Bolte
6f9d8bdbcb ESX Set challenge for auth callback to hostname
This enables the auth callback to automatically distinguish between
requests for ESX host and vCenter credentials.

* src/esx/esx_util.[ch]: set challenge for auth callback to hostname
2009-09-23 15:00:54 +02:00
Matthias Bolte
ecd93b7541 ESX Add esxNodeGetFreeMemory()
* src/esx/esx_driver.c: add esxNodeGetFreeMemory(), cache IP address
* src/esx/esx_vi.[ch]: refactor resource pool query into esxVI_GetResourcePool()
* src/esx/esx_vi_types.[ch]: bind VI type ResourcePoolResourceUsage
2009-09-23 15:00:54 +02:00
Chris Lalancette
b92587bc56 Fix up "make syntax-check" after the tree restructuring.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-23 14:58:13 +02:00
Paolo Bonzini
738ee810b4 network: add 'bootp' and 'tftp' config
Currently, libvirtd will start a dnsmasq process for the virtual
network, but (aside from killing the dnsmasq process and replacing it),
there's no way to define tftp boot options.

This change introduces the appropriate tags to the dhcp configuration:

 <network>
   <name>default</name>
   <bridge name="virbr%d" />
   <forward/>
   <ip address="192.168.122.1" netmask="255.255.255.0">
     <tftp root="/var/lib/tftproot" />
     <dhcp>
       <range start="192.168.122.2" end="192.168.122.254" />
       <bootp file="pxeboot.img"/>
     </dhcp>
   </ip>
 </network>

When the attributes are present, these are passed to the
arguments to dnsmasq:

 dnsmasq [...] --enable-tftp --tftp-root /srv/tftp --dhcp-boot pxeboot.img
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
                      from <tftp />                     from <bootp />

At present, only local tftp servers are supported (ie, dnsmasq runs as
the tftp server), but we could improve this in future by adding a
server= attribute.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

2009-09-21  Paolo Bonzini  <pbonzini@redhat.com>
            Jeremy Kerr  <jk@ozlabs.org>

	* docs/formatnetwork.html.in: Document new tags.
	* docs/formatnetwork.html: Regenerate.
	* docs/schemas/network.rng: Update.
	* src/network_conf.c (virNetworkDefFree): Free new fields.
	(virNetworkDHCPRangeDefParseXML): Parse <bootp>.
	(virNetworkIPParseXML): New, parsing <dhcp> and <tftp>.
	(virNetworkDefParseXML): Use virNetworkIPParseXML instead of
	virNetworkDHCPRangeDefParseXML.
	(virNetworkDefFormat): Pretty print new fields.
	* src/network_conf.h (struct _virNetworkDef): Add netboot fields.
	* src/network_driver.c (networkBuildDnsmasqArgv): Add
	TFTP and BOOTP arguments.

	* tests/Makefile.am (EXTRA_DIST): Add networkschemadata.
	* tests/networkschematest: Look in networkschemadata.
	* tests/networkschemadata/netboot-network.xml: New.
2009-09-23 09:47:10 +02:00
Chris Lalancette
03d777f345 Introduce virStrncpy.
Add the virStrncpy function, which takes a dst string, source string,
the number of bytes to copy and the number of bytes available in the
dest string.  If the source string is too large to fit into the
destination string, including the \0 byte, then no data is copied and
the function returns NULL.  Otherwise, this function copies n bytes
from source into dst, including the \0, and returns a pointer to the
dst string.  This function is intended to replace all unsafe uses
of strncpy in the code base, since strncpy does *not* guarantee that
the buffer terminates with a \0.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-22 20:10:00 +02:00
Daniel P. Berrange
b81a7ece97 Fix handling of Xen(ner) detection
Latest upstream QEMU can be built with Xen support, which introduces
a -xen-domid argument. This was  mistakenly detected as -domid due
to old Xenner support. Adapt to cope with both syntax. Also only
set domid if the virt type is xen, or the guest type is xen

* src/qemu_conf.c, src/qemu_conf.h: Detect new -xen-domid flag in
  preference to -domid.
* tests/qemuxml2argvdata/qemuxml2argv-bootloader.args,
  tests/qemuxml2argvdata/qemuxml2argv-input-xen.args: Add missing
  -domid param
* tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args: Remove bogus
  -boot param.
* tests/qemuxml2argvtest.c: Add missing QEMUD_CMD_FLAG_DOMID params
2009-09-22 16:13:33 +01:00
Daniel P. Berrange
12c542a421 Ignore auto-generated header file
* include/libvirt/.gitignore: Ignore libvirt.h
2009-09-22 16:12:51 +01:00
Matthias Bolte
6ed7374c5a Fix xen driver refcounting.
The commit cb51aa48a7 "Fix up connection
reference counting." changed the driver closing and virConnectPtr
unref-logic in virConnectClose().

Before this commit virConnectClose() closed all drivers of the given
virConnectPtr and virUnrefConnect()'ed it afterwards. After this
commit the driver-closing is done in virUnrefConnect() if and only if
the ref-count of the virConnectPtr dropped to zero.

This change in execution order leads to a virConnectPtr leak, at least
for connections to Xen.

The relevant call sequences:

virConnectOpen() -> xenUnifiedOpen() ...

... xenInotifyOpen() -> virConnectRef(conn)

... xenStoreOpen() -> xenStoreAddWatch() -> conn->refs++

virConnectClose() -> xenUnifiedClose() ...

... xenInotifyClose() -> virUnrefConnect(conn)

... xenStoreClose() -> xenStoreRemoveWatch() -> virUnrefConnect(conn)

Before the commit this additional virConnectRef/virUnrefConnect calls
where no problem, because virConnectClose() closed the drivers
explicitly and the additional refs added by the Xen subdrivers were
removed properly. After the commit this additional refs result in a
virConnectPtr leak (including a leak of the hypercall file handle;
that's how I noticed this problem), because now the drivers are only
close if and only if the ref-count drops to zero, but this cannot
happen anymore, because the additional refs from the Xen subdrivers
would only be removed if the drivers get closed, but that doesn't
happen because the ref-count cannot drop to zero.

The fix for this problem is simple: remove the
virConnectRef/virUnrefConnect calls from the Xen subdrivers (see
attached patch). Maybe someone could explain why the Xen Inotify and
Xen Store driver do this extra ref-counting, but none of the other Xen
subdrivers. It seems unnecessary to me and can be removed without
problems.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-22 15:12:48 +02:00
Dan Kenigsberg
27a1f781bc Fix a number of small typos 2009-09-22 12:55:39 +02:00
Ryota Ozaki
c8c9ef2757 lxc: suspend/resume support
* src/conf/domain_conf.c: Don't assume all virDomainObjPtr have
  a non-NULL monitor_chr field in virDomainObjFormat.
* src/lxc/lxc_driver.c: Implement suspend/resume driver APis
* src/util/cgroup.c, src/util/cgroup.h: Support the 'freezer'
  cgroup controller
* src/libvirt_private.syms: Export virCgroupSetFreezerState
  and virCgroupGetFreezerState
2009-09-22 11:30:06 +01:00
Yuji NISHIDA
0c85095e46 OpenVZ Fix a restriction about domain names
* src/openvz/openvz_driver.c: try to autogenerate a non-conflicting
  id for the domain and use the name field as the name not as id.
2009-09-22 12:19:09 +02:00
Florian Vichot
24e0171b86 add doc for graphic and video elements
* docs/formatdomain.html.in: explain the new syntax of the video and
  graphic elements in the domain XML
2009-09-22 10:32:14 +02:00
Charles Duffy
faa8bf1079 prevent attempt to call cat -c during virDomainSave to raw
This was prevent virDomainSave from working properly by default,
which is a bad thing.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-22 08:56:39 +02:00
Chris Lalancette
58df0daa7f Fix up 'neccessary -> necessary' in a comment.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-21 18:16:12 +02:00
Chris Lalancette
9ca731f66c Don't do virSetConnError when virDrvSupportsFeature is successful.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-21 18:16:00 +02:00
Chris Lalancette
3514c8c375 Fix a double-free in qemudRunLoop()
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-21 18:15:51 +02:00
Chris Lalancette
5d2df4100d Fix up comments for domainXML{To,From}Native.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-21 18:15:41 +02:00
Chris Lalancette
aabafbea1d Simple fix of a comment in qemuStringToArgvEnv.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-21 18:15:31 +02:00
Chris Lalancette
38b3514832 Remove an unnecessary variable from remoteIOReadMessage().
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-21 18:15:13 +02:00
Daniel P. Berrange
b1e32305bd Remove auto-generated header file from repo
* include/libvirt/libvirt.h: Delete auto-generated file
2009-09-21 15:44:06 +01:00
Daniel P. Berrange
cf5fa06c8d Tweak specfile to fix RHEL6 rules & ESX/PHYP enablement
* libvirt.spec.in: ESX/PHYP drivers do not require libvirtd.
  RHEL-6 should include LXC on all arches
2009-09-21 15:24:08 +01:00
Daniel P. Berrange
13f59ad733 Move example XML files into examples/xml
* docs/storage/: Move to examples/xml/storage/
* docs/test*.xml: Move to examples/xml/test/
* docs/Makefile.am: Remove example XML files from dist
* Makefile.am: Add examples/xml to EXTRA_DIST
* tests/virshtest.c: Update for moved test XML
* libvirt.spec.in: Include example XML files as docs
* tests/int-overflow: UPdate for moved XML
2009-09-21 14:41:48 +01:00
Daniel P. Berrange
bde4589189 Remove all generated docs from source control
* docs/*.html, docs/devhelp/*.html, docs/html/*.html: Delete
* docs/.gitignore, docs/devhelp/.gitignore, docs/html/.gitignore:
  Ignore generated docs files
* docs/Makefile.am: Rebuild all HTML docs for 'all' target
  and include them in EXTRA_DIST and CLEANFILES
* docs/devhelp/Makefile.am: Include HTML in CLEANFILES
2009-09-21 14:41:47 +01:00
Daniel P. Berrange
b553b50acb Fix missing data file in qemuhelpdata
* tests/Makefile.am: Add missing data file to extra dist
2009-09-21 14:41:47 +01:00
Daniel P. Berrange
7ad5c00ed9 Misc syntax-check fixes 2009-09-21 14:41:47 +01:00
Daniel P. Berrange
634736a781 Move remote protocol definition into src/remote/
When making changes to the remote protocol, src/ is always built
first, so rpcgen should live there, to avoid having to run make
in the 'daemon/' directory before building src/

* src/Makefile.am: Add rules for rpcgen, and drop -I../daemon from
  remote client build
* daemon/Makefile.am: Add -I../src/remote/ to libvirtd build
  and remove rpcgen rules
* daemon/libvirtd.c: Adapt include of remote_driver.h taking
  into account new -I flag
* daemon/remote_protocol.c, daemon/remote_protocol.h,
  daemon/remote_protocol.x: Move to src/remote/
* daemon/rpcgen_fix.pl: Move to src/remote/rpcgen_fix.pl
2009-09-21 14:41:47 +01:00
Daniel P. Berrange
b1be11c727 Add a README file to src/ explaining the directory structure
* src/README: New file
2009-09-21 14:41:47 +01:00
Daniel P. Berrange
1355e0552e Move all shared utility files to src/util/
* src/bridge.c, src/bridge.h, src/buf.c, src/buf.h, src/cgroup.c,
  src/cgroup.h, src/conf.c, src/conf.h, src/event.c, src/event.h,
  src/hash.c, src/hash.h, src/hostusb.c, src/hostusb.h,
  src/iptables.c, src/iptables.h, src/logging.c, src/logging.h,
  src/memory.c, src/memory.h, src/pci.c, src/pci.h, src/qparams.c,
  src/qparams.h, src/stats_linux.c, src/stats_linux.h,
  src/threads-pthread.c, src/threads-pthread.h, src/threads-win32.c,
  src/threads-win32.h, src/threads.c, src/threads.h, src/util.c,
  src/util.h, src/uuid.c, src/uuid.h, src/virterror.c,
  src/virterror_internal.h, src/xml.c, src/xml.h: Move all files
  into src/util/
* daemon/Makefile.am: Add -Isrc/util/ to build flags
* src/Makefile.am: Add -Isrc/util/ to build flags and update for
  moved files
* src/libvirt_private.syms: Export cgroup APIs since they're now
  in util rather than linking directly to drivers
* src/xen/xs_internal.c: Disable bogus virEventRemoveHandle call
  when built under PROXY
* proxy/Makefile.am: Update for changed file locations. Remove
  bogus build of event.c
* tools/Makefile.am, tests/Makefile.am: Add -Isrc/util/ to build flags
2009-09-21 14:41:47 +01:00
Daniel P. Berrange
e0a48c99e4 Move all XML configuration handling to src/conf/
* src/capabilities.c, src/capabilities.h, src/domain_conf.c,
  src/domain_conf.h, src/domain_event.c, src/domain_event.h,
  src/interface_conf.c, src/interface_conf.h,
  src/network_conf.c, src/network_conf.h, src/node_device_conf.c,
  src/node_device_conf.h, src/secret_conf.c, src/secret_conf.h,
  src/storage_conf.c, src/storage_conf.h, src/storage_encryption_conf.c,
  src/storage_encryption_conf.h: Move to src/conf/
* src/Makefile.am: Add -Isrc/conf to the individual build targets
  which need to use XML config APIs. Remove LIBXML_CFLAGS, LIBSSH2_CFLAGS
  and SELINUX_CFLAGS from global INCLUDES and only have them in build
  targets which actually need them.  Create a libvirt_conf.la
  convenience library for all config parsers
* src/hostusb.h: Remove bogus include of domain_conf.h
* tests/Makefile.am: Add -Isrc/conf. Remove bogus -I$builddir/src
  since it never has any generated header files
* daemon/Makefile.am: Add -Isrc/conf
* proxy/Makefile.am: Add -Isrc/conf and cope with renamed files
* src/hash.c: Remove bogus include of libxml/threads.h
2009-09-21 14:41:46 +01:00
Daniel P. Berrange
3decd4f9f1 Make pki_check.sh into an installed & supported tool
* docs/pki_check.sh: Move to tool/virt-pki-validate.in and add
  in POD man page documentation
* tools/.gitignore: Ignore generated virt-pki-validate file
* tools/Makefile.am: Install & build virt-pki-validate and
  virt-pki-validate.1
* docs/remote.html, docs/remote.html.in: Refer to new tool
  name virt-pki-validate
* libvirt.spec.in, mingw32-libvirt.spec.in: Add virt-pki-validate
  and virt-pki-validate.1 to files list
2009-09-21 14:41:46 +01:00
Daniel P. Berrange
f991a00653 Re-arrange python generator to make it clear what's auto-generated
* README: New file describing what each file is used for
* livvirt-override.c, libvirt-override.py, libvirt-override-api.xml,
  libvirt-override-virConnect.py: Manually written code overriding
  the generator
* typewrappers.c, typewrappers.h: Data type wrappers
* generator.py: Automatically pre-prend contents of libvirt-override.py
  to generated libvirt.py. Output into libvirt.py directly instead of
  libvirtclass.py. Don't generate libvirtclass.txt at all. Write C
  files into libvirt.c/.h directly
* Makefile.am: Remove rule for creating libvirt.py from libvirt-override.py
  and libvirtclass.py, since generator.py does it directly
2009-09-21 14:41:46 +01:00
Daniel P. Berrange
81c28325aa Remove obsolete files
* docs/Goals, RENAMES, mylibtool: Removed
2009-09-21 14:41:46 +01:00
Daniel P. Berrange
cebeba7bd7 Move docs/examples into examples/
* Makefile.am: Add examples/dominfo examples/domsuspend examples/python
  as SUBDIRS
* configure.in: Update AC_OUTPUT for new/old Makefiles
* docs/Makefile.am: Remove examples from SUBDIRS
* docs/examples/info1.c: Move to examples/dominfo/info1.c
* docs/examples/suspend.c: Move to examples/domsuspend/suspend.c
* docs/examples: Remove all remaining files
* docs/examples/python: Moved to examples/python/
* examples/dominfo/Makefile.am, examples/domsuspend/Makefile.am: New
  build files
* libvirt.spec.in: Update to take account of moved examples
2009-09-21 14:41:46 +01:00
Daniel P. Berrange
d6d528ca25 Remove unused images from docs/ directory
* 16favicon.png, Libxml2-Logo-90x34.gif, libvirHeader.png,
  libvirLogo.png, windows-cygwin-1.png, windows-cygwin-2.png,
  windows-cygwin-3.png: Remove unreferenced files
* Makefile.am: Remove deleted files from EXTRA_DIST
2009-09-21 14:41:45 +01:00