- 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)
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
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
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
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>
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.
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()
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
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
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.
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
If no matching device was found (cap == NULL) then no strdup() call
was made and *wwnn and *wwpn are untouched. Checking them for NULL
in this situation may result in reporting an false-positive OOM error
because *wwnn and *wwpn may be initialized to NULL by the caller.
Only check *wwnn and *wwpn for NULL if a matching device was found
(cap != NULL) and thus strdup() was called.
* src/conf/node_device_conf.c: only report an OOM error if there
really is one
* src/conf/storage_conf.c src/conf/storage_conf.h: extend the enums
and values
* docs/schemas/storagepool.rng: add to the list of storage pool type
formats
When specifying bridge delay via network XML define, we were looking for
the 'delay' attribute, but would dump the value as 'forwardDelay'. Have
the output match the expected input (and schema).
If one has e.g.
<guest>
<os_type>hvm</os_type>
<arch name='x86_64'>
<wordsize>64</wordsize>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<machine>pc-0.11</machine>
<machine canonical='pc-0.11'>pc</machine>
<machine>pc-0.10</machine>
<machine>isapc</machine>
<domain type='qemu'>
</domain>
<domain type='kvm'>
<emulator>/usr/bin/kvm</emulator>
<machine>pc</machine>
<machine>isapc</machine>
</domain>
</arch>
</guest>
and start a guest with:
<domain type='kvm'>
...
<os>
<type arch='x86_64'>hvm</type>
...
</os>
</domain>
then the default machine type should be 'pc' and not 'pc-0.11'
Issue was reported by Anton Protopopov.
* src/capabilities.[ch]: pass the domain type to
virCapabilitiesDefaultGuestArch() and use it to look up the default
machine type from a specific guest domain if needed.
* src/conf/domain_conf.c, src/xen/xm_internal.c: update
* tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.xml: update
the domain type to 'kvm' and remove the machine type to check
that the default gets looked up correctly
Add virNodeDeviceParseFile, and make virNodeDeviceParseNode non-static. These
will be used by the test driver.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
* src/conf/domain_conf.c: a simple typo in an XML domain file could lead
to a crash, because we called STRPREFIX() on the looked up value without
checking it was non-null.
* src/conf/domain_conf.c: when declaring a <interface type="bridge">
tag, <source> needs a "bridge" attribute, but the parser complains
about a missing "dev" attribute.
* docs/schemas/domain.rng: allow one <description> tag in the top level
of the <domain> to store user information as text
* src/conf/domain_conf.c src/conf/domain_conf.h: extend the structure
to store this text, grab it at parse time and save it back when
present after <uuid>
Rename virStorageVolFormatFileSystem to virStorageFileFormat and
move to src/util/storage_file.[ch]
* src/Makefile.am: add src/util/storage_file.[ch]
* src/conf/storage_conf.[ch]: move enum from here ...
* src/util/storage_file.[ch]: .. to here
* src/libvirt_private.syms: update To/FromString exports
* src/storage/storage_backend.c, src/storage/storage_backend_fs.c,
src/vbox/vbox_tmpl.c: update for above changes
* src/conf/interface_conf.c: This was causing subsequent calls to
virXPathxxx() to fail, since ctxt->node was left pointing at the
dhcp node, rather than the protocol node.
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.
* 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
* 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