]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agosave: support --xml to virsh save/restore
Eric Blake [Tue, 19 Jul 2011 20:24:29 +0000 (14:24 -0600)]
save: support --xml to virsh save/restore

Also, migrate was missing documentation for the --xml option
added in commit ec5301cb.

* tools/virsh.c (cmdSave, cmdRestore): Add xml argument.
* tools/virsh.pod (save, restore, migrate): Document it.

13 years agosave: add --bypass-cache flag to virsh save/restore operations
Eric Blake [Sat, 9 Jul 2011 03:09:16 +0000 (21:09 -0600)]
save: add --bypass-cache flag to virsh save/restore operations

Wire up the new flag to several virsh commands.  Also, the
'dump' command had undocumented flags.

* tools/virsh.c (cmdSave, cmdManagedSave, cmdDump, cmdStart)
(cmdRestore): Add new flag.
* tools/virsh.pod (save, managedsave, dump, start, restore):
Document flags.

13 years agosave: wire up trivial save/restore flags implementations
Eric Blake [Sat, 9 Jul 2011 02:55:29 +0000 (20:55 -0600)]
save: wire up trivial save/restore flags implementations

For all hypervisors that support save and restore, the new API
now performs the same functions as the old.

VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save).  A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.

* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.

13 years agoerror: add new error type for reflecting partial API support
Eric Blake [Thu, 21 Jul 2011 18:13:59 +0000 (12:13 -0600)]
error: add new error type for reflecting partial API support

VIR_ERR_INVALID_ARG implies that an argument cannot possibly
be correct, given the current state of the API.
VIR_ERR_CONFIG_UNSUPPORTED implies that a configuration is
wrong, but arguments aren't configuration.
VIR_ERR_NO_SUPPORT implies that a function is completely
unimplemented.

But in the case of a function that is partially implemented,
yet the full power of the API is not available for that
driver, none of the above messages make sense.  Hence a new
error message, implying that the argument is known to comply
with the current state of the API, and that while the driver
supports aspects of the function, it does not support that
particular use of the argument.

A good use case for this is a driver that supports
virDomainSaveFlags, but not the dxml argument of that API.

It might be feasible to also use this new error for all functions
that check flags, and which accept fewer flags than what is possible
in the public API.  But doing so would get complicated, since
neither libvirt.c nor the remote driver may do flag filtering,
and every other driver would have to do a two-part check, first
using virCheckFlags on all public flags (which gives
VIR_ERR_INVALID_ARG for an impossible flag), followed by a
particular mask check for VIR_ERR_ARGUMENT_UNSUPPORTED (for a
possible public flag but unsupported by this driver).

* include/libvirt/virterror.h (VIR_ERR_ARGUMENT_UNSUPPORTED): New
error.
* src/util/virterror.c (virErrorMsg): Give it a message.
Suggested by Daniel P. Berrange.

13 years agobuild: fix bugs with destroyFlags patches
Eric Blake [Thu, 21 Jul 2011 19:41:15 +0000 (13:41 -0600)]
build: fix bugs with destroyFlags patches

Build failure on xenapi_driver from compiler warnings (flags was unused).

Build failure on xen (incorrect number of arguments).  And in fixing
that, I obeyed the comments of struct xenUnifiedDriver that state
that we want to minimize the number of callback functions in that
struct, not add to it.

* src/xen/xen_driver.c (xenUnifiedDomainDestroyFlags): Use correct
arguments.
(xenUnifiedDomainDestroy): Simplify.
* src/xen/xen_driver.h (xenUnifiedDriver): Remove unused callback.
* src/xen/xen_hypervisor.c (xenHypervisorDestroyDomain): Likewise.
* src/xen/xend_internal.c (xenDaemonDomainDestroy): Likewise.
* src/xen/xend_internal.h (xenDaemonDomainDestroyFlags): Likewise.
* src/xen/xm_internal.c (xenXMDriver): Likewise.
* src/xen/xs_internal.c (xenStoreDriver): Likewise.
* src/xen/xen_inotify.c (xenInotifyDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainDestroyFlags): Reject
unknown flags.

13 years agoremote: Fix forgotten comma
Michal Privoznik [Thu, 21 Jul 2011 19:06:08 +0000 (21:06 +0200)]
remote: Fix forgotten comma

during conflict resolving

13 years agonetwork: internal API functions to manage assignment of physdev to guest
Laine Stump [Mon, 4 Jul 2011 06:27:12 +0000 (02:27 -0400)]
network: internal API functions to manage assignment of physdev to guest

The network driver needs to assign physical devices for use by modes
that use macvtap, keeping track of which physical devices are in use
(and how many instances, when the devices can be shared). Three calls
are added:

networkAllocateActualDevice - finds a physical device for use by the
domain, and sets up the virDomainActualNetDef accordingly.

networkNotifyActualDevice - assumes that the domain was already
running, but libvirtd was restarted, and needs to be notified by each
already-running domain about what interfaces they are using.

networkReleaseActualDevice - decrements the usage count of the
allocated physical device, and frees the virDomainActualNetDef to
avoid later accidentally using the device.

bridge_driver.[hc] - the new APIs. When WITH_NETWORK is false, these
functions are all #defined to be "0" in the .h file (effectively
becoming a NOP) to prevent link errors.

qemu_(command|driver|hotplug|process).c - add calls to the above APIs
    in the appropriate places.

tests/Makefile.am - we need to include libvirt_driver_network.la
    whenever libvirt_driver_qemu.la is linked, to avoid unreferenced
    symbols (in functions that are never called by the test
    programs...)

13 years agoqemu: use virDomainNetGetActual*() in qemuDomainXMLToNative
Laine Stump [Wed, 20 Jul 2011 04:06:45 +0000 (00:06 -0400)]
qemu: use virDomainNetGetActual*() in qemuDomainXMLToNative

This is the one function outside of domain_conf.c that plays around
with (even modifying) the internals of the virDomainNetDef, and thus
can't be fixed up simply by replacing direct accesses to the fields of
the struct with the GetActual*() access functions.

In this case, we need to check if the defined type is "network", and
if it is *then* check the actual type; if the actual type is "bridge",
then we can at least put the bridgename in a place where it can be
used; otherwise (if type isn't "bridge"), we behave exactly as we used
to - just null out *everything*.

13 years agoqemu: use virDomainNetGetActual*() functions where appropriate
Laine Stump [Mon, 4 Jul 2011 01:57:45 +0000 (21:57 -0400)]
qemu: use virDomainNetGetActual*() functions where appropriate

The qemu driver accesses fields in the virDomainNetDef directly, but
with the advent of the virDomainActualNetDef, some pieces of
information may be found in a different place (the ActualNetDef) if
the network connection is of type='network' and that network is of
forward type='bridge|private|vepa|passthrough'. The previous patch
added functions to mask this difference from callers - they hide the
decision making process and just pick the value from the proper place.

This patch uses those functions in the qemu driver as a first step in
making qemu work with the new network types. At this point, the
virDomainActualNetDef is guaranteed always NULL, so the GetActualX()
function will return exactly what the def->X that's being replaced
would have returned (ie bisecting is not compromised).

There is one place (in qemu_driver.c) where the internal details of
the NetDef are directly manipulated by the code, so the GetActual
functions cannot be used there without extra additional code; that
file will be treated in a separate patch.

13 years agonetwork: separate Start/Shutdown functions for new network types
Laine Stump [Thu, 30 Jun 2011 21:05:07 +0000 (17:05 -0400)]
network: separate Start/Shutdown functions for new network types

Previously all networks were composed of bridge devices created and
managed by libvirt, and the same operations needed to be done for all
of them when they were started and stopped (create and start the
bridge device, configure its MAC address and IP address, add iptables
rules). The new network types are (for now at least) managed outside
of libvirt, and the network object is used only to contain information
about the network, which is then used as each individual guest
connects itself.

This means that when starting/stopping one of these new networks, we
really want to do nothing, aside from marking the network as
active/inactive.

This has been setup as toplevel Start/Shutdown functions that do the
small bit of common stuff, then have a switch statement to execute
network type-specific start/shutdown code, then do a bit more common
code. The type-specific functions called for the new host bridge and
macvtap based types are currently empty.

In the future these functions may actually do something, and we will
surely add more functions that are similarly patterned. Once
everything has settled, we can make a table of "sub-driver" function
pointers for each network type, and store a pointer to that table in
the network object, then we can replace the switch statements with
calls to functions in the table.

The final step in this will be to add a new table (and corresponding
new functions) for new network types as they are added.

13 years agoconf: support abstracted interface info in network XML
Laine Stump [Wed, 20 Jul 2011 03:01:09 +0000 (23:01 -0400)]
conf: support abstracted interface info in network XML

The network XML is updated in the following ways:

1) The <forward> element can now contain a list of forward interfaces:

     <forward .... >
       <interface dev='eth10'/>
       <interface dev='eth11'/>
       <interface dev='eth12'/>
       <interface dev='eth13'/>
     </forward>

   The first of these takes the place of the dev attribute that is
   normally in <forward> - when defining a network you can specify
   either one, and on output both will be present. If you specify
   both on input, they must match.

2) In addition to forward modes of 'nat' and 'route', these new modes
   are supported:

     private, passthrough, vepa - when this network is referenced by a
     domain's interface, it will have the same effect as if the
     interface had been defined as type='direct', e.g.:

        <interface type='direct'>
          <source mode='${mode}' dev='${dev}>
          ...
        </interface>

     where ${mode} is one of the three new modes, and ${dev} is an interface
     selected from the list given in <forward>.

     bridge - if a <forward> dev (or multiple devs) is defined, and
     forward mode is 'bridge' this is just like the modes 'private',
     'passthrough', and 'vepa' above. If there is no forward dev
     specified but a bridge name is given (e.g. "<bridge
     name='br0'/>"), then guest interfaces using this network will use
     libvirt's "host bridge" mode, equivalent to this:

       <interface type='bridge'>
          <source bridge='${bridge-name}'/>
          ...
       </interface>

3) A network can have multiple <portgroup> elements, which may be
   selected by the guest interface definition (by adding
   "portgroup='${name}'" in the <source> element along with the
   network name). Currently a portgroup can only contain a
   virtportprofile, but the intent is that other configuration items
   may be put there int the future (e.g. bandwidth config). When
   building a guest's interface, if the <interface> XML itself has no
   virtportprofile, and if the requested network has a portgroup with
   a name matching the name given in the <interface> (or if one of the
   network's portgroups is marked with the "default='yes'" attribute),
   the virtportprofile from that portgroup will be used by the
   interface.

4) A network can have a virtportprofile defined at the top level,
   which will be used by a guest interface when connecting in one of
   the 'direct' modes if the guest interface XML itself hasn't
   specified any virtportprofile, and if there are also no matching
   portgroups on the network.

13 years agoconf: support abstracted interface info in domain interface XML
Laine Stump [Sun, 26 Jun 2011 08:09:00 +0000 (04:09 -0400)]
conf: support abstracted interface info in domain interface XML

the domain XML <interface> element is updated in the following ways:

1) <virtualportprofile> can be specified when source type='network'
(previously it was only valid for source type='direct')

2) A new attribute "portgroup" has been added to the <source>
element. When source type='network' (the only time portgroup is
recognized), extra configuration information will be taken from the
<portgroup> element of the given name in the network definition.

3) Each virDomainNetDef now also potentially has a
virDomainActualNetDef which is a private object (never
exported/imported via the public API, and not defined in the RNG) that
is used to maintain information about the physical device that was
actually used for a NetDef of type VIR_DOMAIN_NET_TYPE_NETWORK.

The virDomainActualNetDef will only be parsed/formatted if the
parse/format function is called with the
VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET flag set (which is only needed when
saving/loading a running domain's state info to the stateDir).

13 years agoconf: virDomainNetDef points to (rather than contains) virtPortProfile
Laine Stump [Mon, 18 Jul 2011 22:44:38 +0000 (18:44 -0400)]
conf: virDomainNetDef points to (rather than contains) virtPortProfile

The virtPortProfile in the domain interface struct is now a separately
allocated object *pointed to by* (rather than contained in) the main
virDomainNetDef object. This is done to make it easier to figure out
when a virtualPortProfile has/hasn't been specified in a particular
config.

13 years agoconf: put virtPortProfile struct / functions in a common location
Laine Stump [Wed, 29 Jun 2011 04:38:10 +0000 (00:38 -0400)]
conf: put virtPortProfile struct / functions in a common location

virtPortProfiles are currently only used in the domain XML, but will
soon also be used in the network XML. To prepare for that change, this
patch moves the structure definition into util/network.h and the parse
and format functions into util/network.c (I decided that this was a
better choice than macvtap.h/c for something that needed to always be
available on all platforms).

13 years agoutil: define MAX
Laine Stump [Wed, 20 Jul 2011 02:08:15 +0000 (22:08 -0400)]
util: define MAX

If util.h is going to have a MIN, it may as well also have MAX.

13 years agodestroy: Implement internal API for xenapi driver
Michal Privoznik [Thu, 21 Jul 2011 08:28:19 +0000 (10:28 +0200)]
destroy: Implement internal API for xenapi driver

13 years agodestroy: Implement internal API for xen driver
Michal Privoznik [Thu, 21 Jul 2011 08:19:59 +0000 (10:19 +0200)]
destroy: Implement internal API for xen driver

13 years agodestroy: Implement internal API for vmware driver
Michal Privoznik [Thu, 21 Jul 2011 08:01:44 +0000 (10:01 +0200)]
destroy: Implement internal API for vmware driver

13 years agodestroy: Implement internal API for vbox driver
Michal Privoznik [Thu, 21 Jul 2011 07:59:16 +0000 (09:59 +0200)]
destroy: Implement internal API for vbox driver

13 years agodestroy: Implement internal API for uml driver
Michal Privoznik [Thu, 21 Jul 2011 07:54:28 +0000 (09:54 +0200)]
destroy: Implement internal API for uml driver

13 years agodestroy: Implement internal API for phyp driver
Michal Privoznik [Thu, 21 Jul 2011 07:51:51 +0000 (09:51 +0200)]
destroy: Implement internal API for phyp driver

13 years agodestroy: Implement internal API for openvz driver
Michal Privoznik [Thu, 21 Jul 2011 07:49:02 +0000 (09:49 +0200)]
destroy: Implement internal API for openvz driver

13 years agodestroy: Implement internal API for lxc driver
Michal Privoznik [Wed, 20 Jul 2011 16:51:26 +0000 (18:51 +0200)]
destroy: Implement internal API for lxc driver

13 years agodestroy: Implement internal API for libxl driver
Michal Privoznik [Wed, 20 Jul 2011 16:47:46 +0000 (18:47 +0200)]
destroy: Implement internal API for libxl driver

13 years agodestroy: Implement internal API for ESX driver
Michal Privoznik [Wed, 20 Jul 2011 16:45:21 +0000 (18:45 +0200)]
destroy: Implement internal API for ESX driver

13 years agodestroy: Implement internal API for qemu driver
Michal Privoznik [Wed, 20 Jul 2011 16:41:24 +0000 (18:41 +0200)]
destroy: Implement internal API for qemu driver

13 years agodestroy: Wire up the remote protocol
Michal Privoznik [Wed, 20 Jul 2011 16:33:23 +0000 (18:33 +0200)]
destroy: Wire up the remote protocol

13 years agodestroy: Define new public API virDomainDestroyFlags
Michal Privoznik [Wed, 20 Jul 2011 15:02:48 +0000 (17:02 +0200)]
destroy: Define new public API virDomainDestroyFlags

This introduces new API virDomainDestroyFlags to allow
domain destroying with flags, as the existing API virDomainDestroy
misses flags.

The set of flags is defined in virDomainDestroyFlagsValues enum,
which is currently commented, because it is empty.

Calling this API with no flags set (@flags == 0) is equivalent calling
virDomainDestroy.

13 years agosave: wire up remote protocol
Eric Blake [Sat, 9 Jul 2011 02:35:16 +0000 (20:35 -0600)]
save: wire up remote protocol

* src/remote/remote_driver.c (remote_driver): Add new callbacks.
* src/remote/remote_protocol.x (remote_procedure): New RPCs.
(remote_domain_save_flags_args, remote_domain_restore_flags_args):
New structs.
* src/remote_protocol-structs: Update.

13 years agosave: new public API to bypass file system cache on save/restore
Eric Blake [Wed, 6 Jul 2011 18:10:11 +0000 (12:10 -0600)]
save: new public API to bypass file system cache on save/restore

In order to choose whether to use O_DIRECT when saving a domain image
to a file, we need a new flag.  But virDomainSave was implemented
before our policy of all new APIs having a flag argument.  Likewise
for virDomainRestore when restoring from a file.

The new flag name is chosen as CACHE_BYPASS so as not to preclude
a future solution that uses posix_fadvise once the Linux kernel has
a smarter implementation of that interface.

* include/libvirt/libvirt.h.in (virDomainCreateFlags)
(virDomainCoreDumpFlags): Add a flag.
(virDomainSaveFlags, virDomainRestoreFlags): New prototypes.
* src/libvirt.c (virDomainSaveFlags, virDomainRestoreFlags): New API.
* src/libvirt_public.syms: Export them.
* src/driver.h (virDrvDomainSaveFlags, virDrvDomainRestoreFlags):
New driver callbacks.

13 years agoqemu: fix error message with migrate2 xml
Eric Blake [Tue, 19 Jul 2011 22:40:32 +0000 (16:40 -0600)]
qemu: fix error message with migrate2 xml

Otherwise, an ABI mismatch gives error messages attributing the target
xml string as current, and the current domain state as the new xml.

* src/qemu/qemu_migration.c (qemuMigrationBegin): Use correct
argument order.

13 years agobuild: rename files.h to virfile.h
Eric Blake [Tue, 19 Jul 2011 18:32:58 +0000 (12:32 -0600)]
build: rename files.h to virfile.h

In preparation for a future patch adding new virFile APIs.

* src/util/files.h, src/util/files.c: Move...
* src/util/virfile.h, src/util/virfile.c: ...here, and rename
functions to virFile prefix.  Macro names are intentionally
left alone.
* *.c: All '#include "files.h"' uses changed.
* src/Makefile.am (UTIL_SOURCES): Reflect rename.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_close): Likewise.
* src/libvirt_private.syms: Likewise.
* docs/hacking.html.in: Likewise.
* HACKING: Regenerate.

13 years agocommand: avoid leaking fds across fork
Eric Blake [Tue, 12 Jul 2011 20:56:03 +0000 (14:56 -0600)]
command: avoid leaking fds across fork

Since libvirt is multi-threaded, we should use FD_CLOEXEC as much
as possible in the parent, and only relax fds to inherited after
forking, to avoid leaking an fd created in one thread to a fork
run in another thread.  This gets us closer to that ideal, by
making virCommand automatically clear FD_CLOEXEC on fds intended
for the child, as well as avoiding a window of time with non-cloexec
pipes created for capturing output.

* src/util/command.c (virExecWithHook): Use CLOEXEC in parent.  In
child, guarantee that all fds to pass to child are inheritable.
(getDevNull): Use CLOEXEC.
(prepareStdFd): New helper function.
(virCommandRun, virCommandRequireHandshake): Use pipe2.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Simplify caller.

13 years agocommand: move all docs into .c file
Eric Blake [Thu, 14 Jul 2011 19:47:25 +0000 (13:47 -0600)]
command: move all docs into .c file

We already have a precedent of function documentation in C files,
where it is closer to the implementation (witness libvirt.h vs.
libvirt.c); maintaining docs in both files risks docs going stale.

While I was at it, I used consistent doxygen style on all comments.

* src/util/command.h: Remove duplicate docs, and move unique
documentation...
* src/util/command.c: ...here.
Suggested by Matthias Bolte.

13 years agorpc: Make the dispatch generator handle 'void name(void)' style procedures
Matthias Bolte [Tue, 19 Jul 2011 12:16:47 +0000 (14:16 +0200)]
rpc: Make the dispatch generator handle 'void name(void)' style procedures

The only 'void name(void)' style procedure in the protocol is 'close' that
is handled special, but also programming errors like a missing _args or
_ret suffix on the structs in the .x files can create such a situation by
accident. Making the generator aware of this avoids bogus errors from the
generator such as:

  Use of uninitialized value in exists at ./rpc/gendispatch.pl line 967.

Also this allows to get rid of the -c option and the special case code for
the 'close' procedure, as the generator handles it now correctly.

Reported by Michal Privoznik

13 years agoerror: preserve errno when saving last error
Eric Blake [Wed, 20 Jul 2011 23:07:59 +0000 (17:07 -0600)]
error: preserve errno when saving last error

It is common to see the sequence:

virErrorPtr save_err = virSaveLastError();
// do cleanup
virSetError(save_err);
virFreeError(save_err);

on cleanup paths.  But for functions where it is desirable to
return the errno that caused failure, this sequence can clobber
that errno.  virFreeError was already safe; this makes the other
two functions in the sequence safe as well, assuming all goes
well (on OOM, errno will be clobbered, but then again, save_err
won't reflect the real error that happened, so you are no longer
preserving the real situation - that's life with OOM).

* src/util/virterror.c (virSaveLastError, virSetError): Preserve
errno.

13 years agopython: Fix makefile rule for code generation
Matthias Bolte [Thu, 21 Jul 2011 11:45:42 +0000 (13:45 +0200)]
python: Fix makefile rule for code generation

Commit 8665f85523f0451c changed generated.stamp to $(GENERATE).stamp,
but missed one instance in the CLEANFILES list. This can break the
build in case the generated code is deleted but the .stamp file stays
around and therefore the code isn't regenerated.

13 years agoFix uninitialized variable in QEMU CPU bandwidth code
Daniel P. Berrange [Thu, 21 Jul 2011 12:06:33 +0000 (13:06 +0100)]
Fix uninitialized variable in QEMU CPU bandwidth code

* src/qemu/qemu_driver.c: Fix uninitialized variable

13 years agofix make syntax-check error
Wen Congyang [Thu, 21 Jul 2011 09:32:57 +0000 (17:32 +0800)]
fix make syntax-check error

13 years agodoc: Add documentation for new cputune elements period and quota
Wen Congyang [Thu, 21 Jul 2011 08:36:39 +0000 (16:36 +0800)]
doc: Add documentation for new cputune elements period and quota

We have added element period and quota. Document them in formatdomain.html.in.

13 years agoqemu: Implement cfs_period and cfs_quota's modification
Wen Congyang [Thu, 21 Jul 2011 08:04:25 +0000 (16:04 +0800)]
qemu: Implement cfs_period and cfs_quota's modification

This patch implements cfs_period and cfs_quota's modification.
We can use the command 'virsh schedinfo' to query or modify cfs_period and
cfs_quota.
If you query period or quota from config file, the value 0 means it does not set
in the config file.
If you set period or quota to config file, the value 0 means that delete current
setting from config file.
If you modify period or quota while vm is running, the value 0 means that use
current value.

13 years agoqemu: Implement period and quota tunable XML configuration and parsing
Wen Congyang [Thu, 21 Jul 2011 02:10:31 +0000 (10:10 +0800)]
qemu: Implement period and quota tunable XML configuration and parsing

This patch implements period and quota tunable XML configuration and parsing.
A quota or period of zero will be simply ignored.

13 years agoUpdate XML Schema for new entries
Wen Congyang [Thu, 21 Jul 2011 02:09:46 +0000 (10:09 +0800)]
Update XML Schema for new entries

Define the element cputune's child elements 'period' and 'quota':
<cputune>
  <period>100000</period>
  <quota>50000</quota>
</cputune>

13 years agocgroup: Implement cpu.cfs_period_us and cpu.cfs_quota_us tuning API
Wen Congyang [Thu, 21 Jul 2011 07:21:05 +0000 (15:21 +0800)]
cgroup: Implement cpu.cfs_period_us and cpu.cfs_quota_us tuning API

This patch provides 4 APIs to get and set cpu.cfs_period_us and cpu.cfs_quota_us.

13 years agoIntroduce the function virCgroupForVcpu
Wen Congyang [Thu, 21 Jul 2011 07:12:55 +0000 (15:12 +0800)]
Introduce the function virCgroupForVcpu

Introduce the function virCgroupForVcpu() to create sub directory for each vcpu.

13 years agoqemu: send-key: Implement the driver methods
Lai Jiangshan [Thu, 21 Jul 2011 07:55:56 +0000 (15:55 +0800)]
qemu: send-key: Implement the driver methods

qemu driver just accept xt_kbd codeset's keycode, so the lib virtkey
is used for translating keycodes from other codesets

13 years agosend-key: Expose the new API in virsh
Lai Jiangshan [Thu, 21 Jul 2011 07:49:10 +0000 (15:49 +0800)]
send-key: Expose the new API in virsh

Also support string names for the linux keycode(auto detect)
* tools/virsh.c: add new command "send-key"
* tools/virsh.pod: documents the new command

13 years agoutil: add virtkeycode module
Lai Jiangshan [Thu, 21 Jul 2011 07:32:34 +0000 (15:32 +0800)]
util: add virtkeycode module

Add virtkey lib for usage-improvment and keycode translating.
Add 4 internal API for the aim

const char *virKeycodeSetTypeToString(int codeset);
int virKeycodeSetTypeFromString(const char *name);
int virKeycodeValueFromString(virKeycodeSet codeset, const char *keyname);
int virKeycodeValueTranslate(virKeycodeSet from_codeset,
                             virKeycodeSet to_offset,
                             int key_value);

* include/libvirt/libvirt.h.in: extend virKeycodeSet enum
* src/Makefile.am: add new virtkeycode module and rule to generate
  virkeymaps.h
* src/util/virkeycode.c src/util/virkeycode.h: new module
* src/util/virkeycode-mapgen.py: python generator for virkeymaps.h
  out of keymaps.csv
* src/libvirt_private.syms: extend private symbols for new module
* .gitignore: add generated virkeymaps.h

13 years agoutil: Add keymaps.csv
Lai Jiangshan [Thu, 21 Jul 2011 07:02:52 +0000 (15:02 +0800)]
util: Add keymaps.csv

Should keep it as the same as:
http://git.gnome.org/browse/gtk-vnc/commit/src/keymaps.csv

All master  keymaps are defined in a CSV file. THis covers
Linux keycodes, OSX keycodes, AT set1, 2 & 3, XT keycodes,
the XT encoding used by the Linux KBD driver, USB keycodes,
Win32 keycodes, the XT encoding used by Xorg on Cygwin,
the XT encoding used by Xorg on Linux with kbd driver.

* src/Makefile.am: added to EXTRA_DIST
* src/util/keymaps.csv: new file

13 years agomaint: fix typos on guaranteed
Eric Blake [Wed, 20 Jul 2011 22:53:31 +0000 (16:53 -0600)]
maint: fix typos on guaranteed

* src/conf/domain_event.c (virDomainEventDispatch): Fix typo.
* src/internal.h (ATTRIBUTE_FMT_PRINTF): Likewise.
* src/libvirt.c (virStreamEventUpdateCallback): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.
* src/util/virterror.c (virConnCopyLastError, virCopyLastError):
Likewise.
* src/xen/xend_internal.h (xend_wait_for_devices): Likewise.

13 years agorpc: Pass through DISPLAY so ssh can launch askpass
Cole Robinson [Wed, 20 Jul 2011 18:11:43 +0000 (14:11 -0400)]
rpc: Pass through DISPLAY so ssh can launch askpass

Though we prefer users to have SSH keys setup, virt-manager users still
depend on remote SSH connections to launch a password dialog. This fixes
launch ssh-askpass

Fix suggested by danpb

13 years agosysinfo: Don't try to run dmidecode on archs missing it
Michal Privoznik [Wed, 20 Jul 2011 15:03:17 +0000 (17:03 +0200)]
sysinfo: Don't try to run dmidecode on archs missing it

DMI table is Intel & Intel-compatible specific. Therefore other
architectures miss dmidecode command. So we always fail in searching
for that command on non-Intel architectures.

13 years agoDon't try to close a NULL virNetClientPtr
Guannan Ren [Wed, 20 Jul 2011 14:20:18 +0000 (15:20 +0100)]
Don't try to close a NULL virNetClientPtr

* src/rpc/virnetclient.c: Skip close attempt if virNetClientPtr
  is NULL

13 years agoHonour key usage/purpose criticality flag
Daniel P. Berrange [Wed, 20 Jul 2011 13:08:39 +0000 (14:08 +0100)]
Honour key usage/purpose criticality flag

If a key purpose or usage field is marked as non-critical in the
certificate, then a data mismatch is not (ordinarily) a cause for
rejecting the connection

* src/rpc/virnettlscontext.c: Honour key usage/purpose criticality

13 years agoFix checking of key usage/purpose data
Daniel P. Berrange [Wed, 20 Jul 2011 12:54:32 +0000 (13:54 +0100)]
Fix checking of key usage/purpose data

If key usage or purpose data is not present in the cert, the
RFC recommends that access be allowed. Also fix checking of
key usage to include requirements for client/server certs,
and fix key purpose checking to treat data as a list of bits

13 years agoFix mixed up error messages when reporting TLS certificate problems
Daniel P. Berrange [Wed, 20 Jul 2011 12:46:08 +0000 (13:46 +0100)]
Fix mixed up error messages when reporting TLS certificate problems

* src/rpc/virnettlscontext.c: Fix mixed up error messages

13 years agoudev: Don't try to dump DMI on non-intel archs
Michal Privoznik [Tue, 19 Jul 2011 14:48:49 +0000 (16:48 +0200)]
udev: Don't try to dump DMI on non-intel archs

DMI is Intel & Intel-compatible specific. Don't try to dump information
on non-compatible architectures, which results only in error message in
logs.

13 years agobuild: fix broken build
Eric Blake [Wed, 20 Jul 2011 03:33:51 +0000 (21:33 -0600)]
build: fix broken build

* src/libxl/libxl_driver.c (libxlDomainUndefineFlags): Use correct
enum value.
* src/remote_protocol-structs (remote_procedure): Likewise.

13 years agoundefine: Extend virsh undefine to support the new flag
Osier Yang [Wed, 20 Jul 2011 03:12:46 +0000 (11:12 +0800)]
undefine: Extend virsh undefine to support the new flag

If the domain has managed save image, and --managed-save is
not specified, then it fails with an error telling the user
that a managed save image still exists.

If the domain has managed save image, and --managed-save is
specified, it invokes virDomainUndefineFlags. If
virDomainUndefineFlags fails, then it tries to remove the managed
save image using virDomainManagedSaveRemove first, with
invoking virDomainUndefine following. (For compatibility between
new virsh with this patch and older libvirt without this patch).

Similarly if the domain has no managed save image. See the codes for
detail.

NOTE: Have not removing the codes checking if the domain is running
in function "cmdUndefine", it will go along with qemu driver's fix
(allow to undefine a running domain).

13 years agoundefine: Implement undefineFlags for all other drivers
Osier Yang [Wed, 20 Jul 2011 03:08:21 +0000 (11:08 +0800)]
undefine: Implement undefineFlags for all other drivers

13 years agoundefine: Implement internal API for libxl driver
Osier Yang [Wed, 20 Jul 2011 03:05:20 +0000 (11:05 +0800)]
undefine: Implement internal API for libxl driver

* src/libxl/libxl_driver.c: New callback for libxl_driver,
new function libxlDomainUndefineFlags, and changes libxlDomainUndefine
as a wrapper of libxlDomainUndefineFlags.

13 years agoundefine: Implement internal API for qemu driver
Osier Yang [Wed, 20 Jul 2011 03:04:15 +0000 (11:04 +0800)]
undefine: Implement internal API for qemu driver

* src/qemu/qemu_driver.c: New call back for qemu_driver,
New function qemudDomainUndefineFlags, and changes on
qemudDomainUndefine.

13 years agoundefine: Wire up the remote protocol
Osier Yang [Wed, 20 Jul 2011 03:01:45 +0000 (11:01 +0800)]
undefine: Wire up the remote protocol

13 years agoundefine: Define the new API
Osier Yang [Wed, 20 Jul 2011 02:59:54 +0000 (10:59 +0800)]
undefine: Define the new API

This introduces a new API virDomainUndefineFlags to control the
domain undefine process, as the existing API virDomainUndefine
doesn't support flags.

Currently only flag VIR_DOMAIN_UNDEFINE_MANAGED_SAVE is supported.
If the domain has a managed save image, including
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE in @flags will also remove that
file, and omitting the flag will cause undefine process to fail.

This patch also changes the behavior of virDomainUndefine, if the
domain has a managed save image, the undefine will be refused.

13 years agomaint: fix spelling of Red Hat
Eric Blake [Tue, 19 Jul 2011 18:17:22 +0000 (12:17 -0600)]
maint: fix spelling of Red Hat

* cfg.mk (sc_copyright_format): Add to rule.
* src/util/files.h: Fix offenders.
* src/util/files.c: Likewise.

13 years agoAdd sanity checking of basic constraints, key purpose & key usage
Daniel P. Berrange [Fri, 15 Jul 2011 11:55:23 +0000 (12:55 +0100)]
Add sanity checking of basic constraints, key purpose & key usage

Gnutls requires that certificates have basic constraints present
to be used as a CA certificate. OpenSSL doesn't add this data
by default, so add a sanity check to catch this situation. Also
validate that the key usage and key purpose constraints contain
correct data

* src/rpc/virnettlscontext.c: Add sanity checking of certificate
  constraints

13 years agoAdd some basic sanity checking of certificates before use
Daniel P. Berrange [Thu, 14 Jul 2011 16:52:03 +0000 (17:52 +0100)]
Add some basic sanity checking of certificates before use

If the libvirt daemon or libvirt client is configured with bogus
certificates, it is very unhelpful to only find out about this
when a TLS connection is actually attempted. Not least because
the error messages you get back for failures are incredibly
obscure.

This adds some basic sanity checking of certificates at the
time the virNetTLSContext object is created. This is at libvirt
startup, or when creating a virNetClient instance.

This checks that the certificate expiry/start dates are valid
and that the certificate is actually signed by the CA that is
loaded.

* src/rpc/virnettlscontext.c: Add certificate sanity checks

13 years agoFix reporting of errors for p2p migration
Daniel P. Berrange [Tue, 19 Jul 2011 14:51:08 +0000 (10:51 -0400)]
Fix reporting of errors for p2p migration

Starting/ending jobs when closing the connection may reset any
error which was reported earlier in p2p migration. We must
save the original error before doing so. This means we can also
just call virConnectClose as normal, instead of virUnrefConnect

* src/qemu/qemu_migration.c: Preserve errors in p2p migration

13 years agoAdd an explicit virNetClientClose method
Daniel P. Berrange [Tue, 19 Jul 2011 13:13:32 +0000 (14:13 +0100)]
Add an explicit virNetClientClose method

Since the I/O callback registered against virNetSocket will
hold a reference on the virNetClient, we can't rely on the
virNetClientFree to be able to close the network connection.
The last reference will only go away when the event callback
fires (likely due to EOF from the server).

This is sub-optimal and can potentially cause a leak of the
virNetClient object if the server were to not explicitly
close the socket itself

* src/remote/remote_driver.c: Explicitly close the client
  object when disconnecting
* src/rpc/virnetclient.c, src/rpc/virnetclient.h: Add a
  virNetClientClose method

13 years agoUse a virFreeCallback on virNetSocket to ensure safe release
Daniel P. Berrange [Tue, 19 Jul 2011 13:11:33 +0000 (14:11 +0100)]
Use a virFreeCallback on virNetSocket to ensure safe release

When unregistering an I/O callback from a virNetSocket object,
there is still a chance that an event may come in on the callback.
In this case it is possible that the virNetSocket might have been
freed already. Make use of a virFreeCallback when registering
the I/O callbacks and hold a reference for the entire time the
callback is set.

* src/rpc/virnetsocket.c: Register a free function for the
  file handle watch
* src/rpc/virnetsocket.h, src/rpc/virnetserverservice.c,
  src/rpc/virnetserverclient.c, src/rpc/virnetclient.c: Add
  a free function for the socket I/O watches

13 years agoAdd mutex locking and reference counting to virNetSocket
Daniel P. Berrange [Tue, 19 Jul 2011 13:00:24 +0000 (14:00 +0100)]
Add mutex locking and reference counting to virNetSocket

Remove the need for a virNetSocket object to be protected by
locks from the object using it, by introducing its own native
locking and reference counting

* src/rpc/virnetsocket.c: Add locking & reference counting

13 years agoAdd some debugging for virNetClient reference counting
Daniel P. Berrange [Tue, 19 Jul 2011 13:14:59 +0000 (14:14 +0100)]
Add some debugging for virNetClient reference counting

* src/rpc/virnetclient.c: Add debugging of ref counts

13 years agobuild: detect doc generation failure
Eric Blake [Tue, 19 Jul 2011 13:34:34 +0000 (07:34 -0600)]
build: detect doc generation failure

Commit 8665f85 introduced a slight regression in doc generation,
since make only quits a rule on the first failed command ending
with a newline rather than a semicolon.

* docs/Makefile.am (html/index.html): Don't use xmllint unless
xsltproc succeeded.
* .gitignore: Ignore recently updated stamp file name.

13 years agoutil: avoid fds leak when virEventPollAddHandle fail
Alex Jia [Tue, 19 Jul 2011 11:15:18 +0000 (19:15 +0800)]
util: avoid fds leak when virEventPollAddHandle fail

* src/util/event_poll.c: avoid file descriptors leak when
  virEventPollAddHandle fail on virEventPollInit function.

13 years agoRevert "virsh: make migrate --tunnelled imply --p2p"
Eric Blake [Tue, 19 Jul 2011 13:14:43 +0000 (07:14 -0600)]
Revert "virsh: make migrate --tunnelled imply --p2p"

This reverts commit 40143fb697c3cb042197632c0286e7dadf40afd4.

The patch prevents future compatibility if migration ever learns
how to do tunnelled without p2p.

13 years agoUnregister event callback if a fatal error occurs during dispatch
Daniel P. Berrange [Fri, 15 Jul 2011 10:19:40 +0000 (11:19 +0100)]
Unregister event callback if a fatal error occurs during dispatch

If we get an I/O error in the async event callback for an RPC
client, we might not have consumed all pending data off the
wire. This could result in the callback being immediately
invoked again. At which point the same I/O might occur. And
we're invoked again. And again...And again...

Unregistering the async event callback if an error occurs is
a good safety net. The real error will be seen when the next
RPC method is invoked

* src/rpc/virnetclient.c: Unregister event callback on error

13 years agoQuieten build & ensure API build scripts exit with non-zero status
Daniel P. Berrange [Thu, 12 May 2011 10:19:42 +0000 (11:19 +0100)]
Quieten build & ensure API build scripts exit with non-zero status

The current API build scripts will continue and exit with a zero
status even if they find problems. This has been the cause of many
build problems, or hidden build errors, in the past. Change the
scripts so they always exit with a non-zero status for any problems
they do not understand. Also turn off all debug output by default
so they respect $(AM_V_GEN)

* docs/Makefile.am: Use $(AM_V_GEN) for API/HTML scripts
* docs/apibuild.py, python/generator.py: Exit with non-zero status
  if problems are found. Also be silent, not outputting any debug
  messages.
* src/Makefile.am: Use $(AM_V_GEN) for ESX generator
* python/Makefile.am: Tweak rule

13 years agotests: Fix virshtest failure after dominfo changed
Osier Yang [Tue, 19 Jul 2011 12:48:15 +0000 (20:48 +0800)]
tests: Fix virshtest failure after dominfo changed

Caused by the new changed "dominfo" command.

13 years agovirsh: Extend virsh dominfo to display if managed save image exists
Osier Yang [Tue, 19 Jul 2011 06:24:57 +0000 (14:24 +0800)]
virsh: Extend virsh dominfo to display if managed save image exists

* tools/virsh.c: new column "Managed save" for "cmdDominfo".
* tools/virsh.pod: Update document of "managedsave" to tell one can
  use "dominfo" to query whether a domain has any managed save image.

13 years agodoc: Correct documents for iface commands
Osier Yang [Tue, 19 Jul 2011 03:19:25 +0000 (11:19 +0800)]
doc: Correct documents for iface commands

The problems:
    * Duplicate documents for "iface-name"
    * Lacks of document for "iface-mac"
    * Inconsistent option names with virsh help strings.

13 years agovirsh: make migrate --tunnelled imply --p2p
Eric Blake [Mon, 18 Jul 2011 19:10:29 +0000 (13:10 -0600)]
virsh: make migrate --tunnelled imply --p2p

We can make the virsh migrate UI friendlier by supplying the
missing bit automatically instead of erroring out when requesting
--tunnelled without --p2p.

* tools/virsh.c (doMigrate): Make --p2p optional when using
--tunnelled.
* tools/virsh.pod (migrate): Tweak wording accordingly.

13 years agolibvirt: do not mix internal flags into public API
Eric Blake [Wed, 13 Jul 2011 21:31:56 +0000 (15:31 -0600)]
libvirt: do not mix internal flags into public API

There were two API in driver.c that were silently masking flags
bits prior to calling out to the drivers, and several others
that were explicitly masking flags bits.  This is not
forward-compatible - if we ever have that many flags in the
future, then talking to an old server that masks out the
flags would be indistinguishable from talking to a new server
that can honor the flag.  In general, libvirt.c should forward
_all_ flags on to drivers, and only the drivers should reject
unknown flags.

In the case of virDrvSecretGetValue, the solution is to separate
the internal driver callback function to have two parameters
instead of one, with only one parameter affected by the public
API.  In the case of virDomainGetXMLDesc, it turns out that
no one was ever mixing VIR_DOMAIN_XML_INTERNAL_STATUS with
the dumpxml path in the first place; that internal flag was
only used in saving and restoring state files, which happened
to be in functions internal to a single file, so there is no
mixing of the internal flag with a public flags argument.
Additionally, virDomainMemoryStats passed a flags argument
over RPC, but not to the driver.

* src/driver.h (VIR_DOMAIN_XML_FLAGS_MASK)
(VIR_SECRET_GET_VALUE_FLAGS_MASK): Delete.
(virDrvSecretGetValue): Separate out internal flags.
(virDrvDomainMemoryStats): Provide missing flags argument.
* src/driver.c (verify): Drop unused check.
* src/conf/domain_conf.h (virDomainObjParseFile): Delete
declaration.
(virDomainXMLInternalFlags): Move...
* src/conf/domain_conf.c: ...here.  Delete redundant include.
(virDomainObjParseFile): Make static.
* src/libvirt.c (virDomainGetXMLDesc, virSecretGetValue): Update
clients.
(virDomainMemoryPeek, virInterfaceGetXMLDesc)
(virDomainMemoryStats, virDomainBlockPeek, virNetworkGetXMLDesc)
(virStoragePoolGetXMLDesc, virStorageVolGetXMLDesc)
(virNodeNumOfDevices, virNodeListDevices, virNWFilterGetXMLDesc):
Don't mask unknown flags.
* src/interface/netcf_driver.c (interfaceGetXMLDesc): Reject
unknown flags.
* src/secret/secret_driver.c (secretGetValue): Update clients.
* src/remote/remote_driver.c (remoteSecretGetValue)
(remoteDomainMemoryStats): Likewise.
* src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainMemoryStats): Likewise.
* daemon/remote.c (remoteDispatchDomainMemoryStats): Likewise.

13 years agovirsh: avoid double free of domain
Alex Jia [Sun, 17 Jul 2011 15:29:07 +0000 (23:29 +0800)]
virsh: avoid double free of domain

* tools/virsh.c: avoid double free of domain, when weight value of blkiotune
  less than 0, codes will free domain and jump to cleanup section, however,
  cleanup will free domain again.

Detected in valgrind run:

==21297== ERROR SUMMARY: 20 errors from 20 contexts (suppressed: 69 from 8)
==21297==
==21297== 1 errors in context 1 of 20:
==21297== Invalid read of size 4
==21297==    at 0x40E209B: virDomainFree (libvirt.c:2096)
==21297==    by 0x8065274: cmdBlkiotune (virsh.c:3695)
==21297==    by 0x8054CC1: vshCommandRun (virsh.c:13135)
==21297==    by 0x806B967: main (virsh.c:14487)
==21297==  Address 0x446ad48 is 0 bytes inside a block of size 36 free'd
==21297==    at 0x4005B0A: free (vg_replace_malloc.c:325)
==21297==    by 0x406814D: virFree (memory.c:310)
==21297==    by 0x40D6635: virReleaseDomain (datatypes.c:243)
==21297==    by 0x40D6C5E: virUnrefDomain (datatypes.c:280)
==21297==    by 0x40E20B9: virDomainFree (libvirt.c:2101)
==21297==    by 0x8065297: cmdBlkiotune (virsh.c:3613)
==21297==    by 0x8054CC1: vshCommandRun (virsh.c:13135)
==21297==    by 0x806B967: main (virsh.c:14487)
==21297==
==21297==
==21297== 1 errors in context 2 of 20:
==21297== Invalid read of size 4
==21297==    at 0x40E1FE6: virDomainFree (libvirt.c:2092)
==21297==    by 0x8065274: cmdBlkiotune (virsh.c:3695)
==21297==    by 0x8054CC1: vshCommandRun (virsh.c:13135)
==21297==    by 0x806B967: main (virsh.c:14487)
==21297==  Address 0x446ad48 is 0 bytes inside a block of size 36 free'd
==21297==    at 0x4005B0A: free (vg_replace_malloc.c:325)
==21297==    by 0x406814D: virFree (memory.c:310)
==21297==    by 0x40D6635: virReleaseDomain (datatypes.c:243)
==21297==    by 0x40D6C5E: virUnrefDomain (datatypes.c:280)
==21297==    by 0x40E20B9: virDomainFree (libvirt.c:2101)
==21297==    by 0x8065297: cmdBlkiotune (virsh.c:3613)
==21297==    by 0x8054CC1: vshCommandRun (virsh.c:13135)
==21297==    by 0x806B967: main (virsh.c:14487)

* how to reproduce?
  % valgrind -v --leak-check=full virsh blkiotune guestname --weight -1

13 years agodocs: improve virsh man page synopses
Eric Blake [Thu, 14 Jul 2011 17:36:21 +0000 (11:36 -0600)]
docs: improve virsh man page synopses

"optional" is not a very good meta-syntactic construct in our man
page.  I scrubbed this, and additionally improved some documentation
on mutually exclusive options.  For example,

[[--live] [--config] | [--current]]

implies a set of optional flags, where within the set you can have
either --current or a choice of 0, 1, or both --live and --config.

* tools/virsh.pod: Use "[name]" rather than "optional name" for
optional arguments.

13 years agobuild: Fix protocol-structs check in VPATH build
Jiri Denemark [Mon, 18 Jul 2011 08:25:02 +0000 (10:25 +0200)]
build: Fix protocol-structs check in VPATH build

$@ already included $(srcdir)

13 years agoFix now dead cleanup of VMs on libvirtd restart
Daniel P. Berrange [Fri, 15 Jul 2011 14:33:15 +0000 (15:33 +0100)]
Fix now dead cleanup of VMs on libvirtd restart

When libvirtd restarts it will attempt to reconnect to existing
LXC containers. If it loads a XML state file for the container
the container will appear running. If we fail to read the PID
file, or fail to connect to the LXC monitor, we should be killing
off the guest, but if the VMs cgroup does not exist any more,
cleanup will get skipped. Reading the PID file is also pointless
since the PID is in the XML statefile

In lxcReconnectVM we do not need to read the PID file. If part
of the reconnect process fails we need to run the VM terminate
code as a safety net.

In lxcVMTerminate, if we can't obtain the VM cgroup, we know
the process has died, but we must still run lxcVMCleanup to
clear out the virDomainObjPtr live state

* src/lxc/lxc_driver.c: Fix cleanup of dead VMs on restart

13 years agodocs: Fix spice documentation typo
Michal Privoznik [Mon, 18 Jul 2011 09:28:54 +0000 (11:28 +0200)]
docs: Fix spice documentation typo

We missed ending tag for paragraph element

13 years agorpc: Fix typos in rpc generator scripts
Osier Yang [Sun, 17 Jul 2011 04:41:39 +0000 (12:41 +0800)]
rpc: Fix typos in rpc generator scripts

These typos are introduced by file renaming in commit b17b4afaf.

src/remote/qemu_protocol.x \
src/remote/remote_protocol.x \
src/rpc/gendispatch.pl:
    s/remote_generator/gendispatch/

src/rpc/genprotocol.pl:
    s/remote\/remote_protocol/remote_protocol/

13 years agoqemu: Fix a regression of attaching device
Osier Yang [Sat, 16 Jul 2011 03:24:49 +0000 (11:24 +0800)]
qemu: Fix a regression of attaching device

The regression is introduced by Commit da1eba6b, the new
codes with this commit doesn't reset "ret" to "-1" when
it fails on parsing the device XML (live device attachment)

This patch changes the codes to reset the "ret" and "-1",
and also changes the codes so that it don't modify "ret"
for condition checking.

How to reproduce:

% cat test.xml
<disk type='oops' device='disk'>
  <driver name='qemu' type='raw'/>
  <source file='/var/lib/libvirt/images/test.img'/>
  <target dev='vda' bus='virtio'/>
</disk>

% virsh attach-device $domain test.xml
Device attached successfully

The device attachment failed actually with error "unknown disk type 'oops'",
however, it reports success.

13 years agobuild: also track RPC on-wire enum values
Eric Blake [Thu, 14 Jul 2011 16:18:40 +0000 (10:18 -0600)]
build: also track RPC on-wire enum values

As long as we guarantee RPC struct layout stability, we might as
well also guarantee RPC enum value constancy.

* src/Makefile.am (r1, r2, PDWTAGS): Adjust rule to pick up named
and anonymous enums.
* src/remote_protocol-structs: Add enum values.
* src/qemu_protocol-structs: Likewise.
* src/virnetprotocol-structs: Likewise.

13 years agodocs: document dxml argument to migrate2
Eric Blake [Thu, 14 Jul 2011 17:09:03 +0000 (11:09 -0600)]
docs: document dxml argument to migrate2

Commit 135554166 introduced a nice feature without documenting it.

* src/libvirt.c (virDomainMigrate2): Add paragraph.

13 years agobuild: add syntax check for proper flags use
Eric Blake [Thu, 7 Jul 2011 17:57:43 +0000 (11:57 -0600)]
build: add syntax check for proper flags use

Enforce the recent flags cleanups - we want to use 'unsigned int flags'
in any of our APIs (except where backwards compatibility is important,
in the public migration APIs), and that all flags are checked for
validity (except when there are stub functions that completely
ignore the flags argument).

There are a few minor tweaks done here to avoid false positives:
signed arguments passed to open() are renamed oflags, and flags
arguments that are legitimately ignored are renamed flags_unused.

* cfg.mk (sc_flags_usage): New rule.
(exclude_file_name_regexp--sc_flags_usage): And a few exemptions.
(sc_flags_debug): Tweak wording.
* src/util/iohelper.c (runIO, main): Rename variable.
* src/util/util.c (virSetInherit): Likewise.
* src/fdstream.h (virFDStreamOpenFile, virFDStreamCreateFile):
Likewise.
* src/fdstream.c (virFDStreamOpenFileInternal)
(virFDStreamOpenFile, virFDStreamCreateFile): Likewise.
* src/util/command.c (virExecWithHook) [WIN32]: Likewise.
* src/util/util.c (virFileOpenAs, virDirCreate) [WIN32]: Likewise.
* src/locking/lock_manager.c (virLockManagerPluginNew)
[!HAVE_DLFCN_H]: Likewise.
* src/locking/lock_driver_nop.c (virLockManagerNopNew)
(virLockManagerNopAddResource, virLockManagerNopAcquire)
(virLockManagerNopRelease, virLockManagerNopInquire): Likewise.

13 years agoxen: reject unknown flags
Eric Blake [Wed, 6 Jul 2011 23:15:33 +0000 (17:15 -0600)]
xen: reject unknown flags

Also fix a logic bug in xenXMDomain{Attach,Detach}DeviceFlags,
where (flags & VIR_DOMAIN_DEVICE_MODIFY_CURRENT) is always false.

* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare, xenDaemonDomainSetVcpusFlags,
xenDaemonDomainGetVcpusFlags, xenDaemonAttachDeviceFlags,
xenDaemonDetachDeviceFlags): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState, xenXMDomainSetVcpusFlags)
(xenXMDomainGetVcpusFlags): Reject unknown flags.
(xenXMDomainAttachDeviceFlags, xenXMDomainDetachDeviceFlags):
Likewise, and avoid always-false conditional.
* src/xen/xen_driver.h (XEN_MIGRATION_FLAGS): New define.

13 years agoesx: reject unknown flags
Eric Blake [Wed, 6 Jul 2011 22:14:33 +0000 (16:14 -0600)]
esx: reject unknown flags

Silently ignored flags get in the way of new features that
use those flags.

Regarding ESX migration flags - right now, ESX silently enforces
VIR_MIGRATE_PERSIST_DEST, VIR_MIGRATE_UNDEFINE_SOURCE, and
VIR_MIGRATE_LIVE, even if those flags were not supplied; it ignored
other flags.  This patch does not change the implied bits (it permits
but does not require them), but enforces only the supported bits.
If further cleanup is needed to be more particular about migration
flags, that should be a separate patch.

* src/esx/esx_device_monitor.c (esxDeviceOpen): Reject unknown
flags.
* src/esx/esx_driver.c (esxOpen, esxDomainReboot)
(esxDomainXMLFromNative, esxDomainXMLToNative)
(esxDomainMigratePrepare, esxDomainMigratePerform)
(esxDomainMigrateFinish): Likewise.
* src/esx/esx_interface_driver.c (esxInterfaceOpen): Likewise.
* src/esx/esx_network_driver.c (esxNetworkOpen): Likewise.
* src/esx/esx_nwfilter_driver.c (esxNWFilterOpen): Likewise.
* src/esx/esx_secret_driver.c (esxSecretOpen): Likewise.
* src/esx/esx_storage_driver.c (esxStorageOpen): Likewise.

13 years agovirsh: improve option handling
Eric Blake [Fri, 15 Jul 2011 17:23:17 +0000 (11:23 -0600)]
virsh: improve option handling

The documentation for vshCommandOptString claims that it returns
-1 on a missing required argument, but in reality, that error
message was unreachable (it was buried inside an if clause that
is true only if the argument was present).  The code was so hairy
that I decided a rewrite would make it easier to understand,
and actually return the error values we want.

Meanwhile, our construction guarantees that all vshCmdOpt have
a non-null def member, so there are some redundant checks that
can be trimmed.

* tools/virsh.c (vshCommandOpt): Alter signature.
(vshCommandOptInt, vshCommandOptUInt, vshCommandOptUL)
(vshCommandOptString, vshCommandOptLongLong)
(vshCommandOptULongLong, vshCommandOptBool): Adjust all callers.
(vshCommandOptArgv): Remove dead condition.

13 years agoflags: fix domain_conf migration regression
Eric Blake [Fri, 15 Jul 2011 19:03:20 +0000 (13:03 -0600)]
flags: fix domain_conf migration regression

Commit 461e0f1a broke migration, because there was a code path
that tried to enable an internal flag while still going through
the public function.  Split the internal flag into a separate
callback, and validate that flags do not overlap.

* src/conf/domain_conf.c (virDomainDefFormat): Split...
(virDomainDefFormatInternal): ...to separate the flag check.
(virDomainObjFormat): Adjust caller.

13 years agowebsite: Point main page links to libvirt driver pages
Dave Allan [Fri, 15 Jul 2011 18:33:17 +0000 (14:33 -0400)]
website: Point main page links to libvirt driver pages

The "libvirt supports:" section on the main page of libvirt.org
contains a list of hypervisors with links that point to the sites of
the underlying virt technologies.  The entry for KVM points to
http://www.linux-kvm.org/, for example.  People coming to libvirt.org
for the first time are likely to know about those sites, and they're
probably interested in how libvirt manages those technologies.  This
patch points those links to the libvirt driver pages instead.  It also
consolidates KVM and QEMU as there is only one libvirt driver page for
them.  Finally, it adds a line about networking support.

v2: incorporate Eric's feedback adding project links to driver pages.

website: Add project links to KVM/QEMU driver page
website: Add project links to Xen driver page
website: Add project links to LXC driver page
website: Add project links to OpenVZ driver page
website: Add project links to UML driver page
website: Add project links to Virtualbox driver page
website: Add project links to ESX driver page
website: Add project links to VMware driver page

13 years agoflags: fix qemu migration regression
Eric Blake [Thu, 14 Jul 2011 21:46:49 +0000 (15:46 -0600)]
flags: fix qemu migration regression

Commit f548480b broke migration v3 on qemu, because the driver
passed flags on through to qemu_migration even though
qemu_migration wasn't using those flags.

* src/qemu/qemu_migration.h (QEMU_MIGRATION_FLAGS): New define.
* src/qemu/qemu_driver.c: Simplify all migration callbacks.
* src/qemu/qemu_migration.c (qemuMigrationConfirm): Fix regression.

13 years agoflags: use common dumpxml flags check
Eric Blake [Wed, 13 Jul 2011 22:24:38 +0000 (16:24 -0600)]
flags: use common dumpxml flags check

The previous patches only cleaned up ATTRIBUTE_UNUSED flags cases;
auditing the drivers found other places where flags was being used
but not validated.  In particular, domainGetXMLDesc had issues with
clients accepting a different set of flags than the common
virDomainDefFormat helper function.

* src/conf/domain_conf.c (virDomainDefFormat): Add common flag check.
* src/uml/uml_driver.c (umlDomainAttachDeviceFlags)
(umlDomainDetachDeviceFlags): Reject unknown
flags.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc)
(vboxDomainAttachDeviceFlags)
(vboxDomainDetachDeviceFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainMemoryPeek): Likewise.
(qemuDomainGetXMLDesc): Document common flag handling.
* src/libxl/libxl_driver.c (libxlDomainGetXMLDesc): Likewise.
* src/lxc/lxc_driver.c (lxcDomainGetXMLDesc): Likewise.
* src/openvz/openvz_driver.c (openvzDomainGetXMLDesc): Likewise.
* src/phyp/phyp_driver.c (phypDomainGetXMLDesc): Likewise.
* src/test/test_driver.c (testDomainGetXMLDesc): Likewise.
* src/vmware/vmware_driver.c (vmwareDomainGetXMLDesc): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainGetXMLDesc): Likewise.

13 years agomaint: fix typos
Eric Blake [Fri, 15 Jul 2011 18:08:59 +0000 (12:08 -0600)]
maint: fix typos

Our XML prefers "shareable" over "sharable".

* docs/internals/locking.html.in: s/sharable/shareable/
* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockAddResource): Likewise.