]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoIntroduce generic RPC client objects
Daniel P. Berrange [Wed, 1 Dec 2010 16:35:50 +0000 (16:35 +0000)]
Introduce generic RPC client objects

To facilitate creation of new clients using XDR RPC services,
pull alot of the remote driver code into a set of reusable
objects.

 - virNetClient: Encapsulates a socket connection to a
   remote RPC server. Handles all the network I/O for
   reading/writing RPC messages. Delegates RPC encoding
   and decoding to the registered programs

 - virNetClientProgram: Handles processing and dispatch
   of RPC messages for a single RPC (program,version).
   A program can register to receive async events
   from a client

 - virNetClientStream: Handles generic I/O stream
   integration to RPC layer

Each new client program now merely needs to define the list of
RPC procedures & events it wants and their handlers. It does
not need to deal with any of the network I/O functionality at
all.

13 years agoIntroduce generic RPC module for advertising via MDNS
Daniel P. Berrange [Wed, 2 Mar 2011 17:11:42 +0000 (17:11 +0000)]
Introduce generic RPC module for advertising via MDNS

Allow RPC servers to advertise themselves using MDNS,
via Avahi

* src/rpc/virnetserver.c, src/rpc/virnetserver.h: Allow
  registration of MDNS services via avahi
* src/rpc/virnetserverservice.c, src/rpc/virnetserverservice.h: Add
  API to fetch the listen port number
* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Add API to
  fetch the local port number
* src/rpc/virnetservermdns.c, src/rpc/virnetservermdns.h: Represent
  an MDNS advertisement

13 years agoIntroduce generic RPC server objects
Daniel P. Berrange [Wed, 1 Dec 2010 16:36:40 +0000 (16:36 +0000)]
Introduce generic RPC server objects

To facilitate creation of new daemons providing XDR RPC services,
pull a lot of the libvirtd daemon code into a set of reusable
objects.

 * virNetServer: A server contains one or more services which
   accept incoming clients. It maintains the list of active
   clients. It has a list of RPC programs which can be used
   by clients. When clients produce a complete RPC message,
   the server passes this onto the corresponding program for
   handling, and queues any response back with the client.

 * virNetServerClient: Encapsulates a single client connection.
   All I/O for the client is handled, reading & writing RPC
   messages.

 * virNetServerProgram: Handles processing and dispatch of
   RPC method calls for a single RPC (program,version).
   Multiple programs can be registered with the server.

 * virNetServerService: Encapsulates socket(s) listening for
   new connections. Each service listens on a single host/port,
   but may have multiple sockets if on a dual IPv4/6 host.

Each new daemon now merely has to define the list of RPC procedures
& their handlers. It does not need to deal with any network related
functionality at all.

13 years agoIntegrate TLS/SASL directly into the socket APIs
Daniel P. Berrange [Fri, 10 Dec 2010 12:22:03 +0000 (12:22 +0000)]
Integrate TLS/SASL directly into the socket APIs

This extends the basic virNetSocket APIs to allow them to have
a handle to the TLS/SASL session objects, once established.
This ensures that any data reads/writes are automagically
passed through the TLS/SASL encryption layers if required.

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Wire up
  SASL/TLS encryption

13 years agoGeneric module for handling SASL authentication & encryption
Daniel P. Berrange [Fri, 10 Dec 2010 12:21:18 +0000 (12:21 +0000)]
Generic module for handling SASL authentication & encryption

This provides two modules for handling SASL

 * virNetSASLContext provides the process-wide state, currently
   just a whitelist of usernames on the server and a one time
   library init call

 * virNetTLSSession provides the per-connection state, ie the
   SASL session itself. This also include APIs for providing
   data encryption/decryption once the session is established

* src/Makefile.am: Add to libvirt-net-rpc.la
* src/rpc/virnetsaslcontext.c, src/rpc/virnetsaslcontext.h: Generic
  SASL handling code

13 years agoGeneric module for handling TLS encryption and x509 certs
Daniel P. Berrange [Tue, 23 Nov 2010 20:17:41 +0000 (20:17 +0000)]
Generic module for handling TLS encryption and x509 certs

This provides two modules for handling TLS

 * virNetTLSContext provides the process-wide state, in particular
   all the x509 credentials, DH params and x509 whitelists
 * virNetTLSSession provides the per-connection state, ie the
   TLS session itself.

The virNetTLSContext provides APIs for validating a TLS session's
x509 credentials. The virNetTLSSession includes APIs for performing
the initial TLS handshake and sending/recving encrypted data

* src/Makefile.am: Add to libvirt-net-rpc.la
* src/rpc/virnettlscontext.c, src/rpc/virnettlscontext.h: Generic
  TLS handling code

13 years agoIntroduce a generic object for using network sockets
Daniel P. Berrange [Mon, 6 Dec 2010 17:03:35 +0000 (17:03 +0000)]
Introduce a generic object for using network sockets

Introduces a simple wrapper around the raw POSIX sockets APIs
and name resolution APIs. Allows for easy creation of client
and server sockets with correct usage of name resolution APIs
for protocol agnostic socket setup.

It can listen for UNIX and TCP stream sockets.

It can connect to UNIX, TCP streams directly, or indirectly
to UNIX sockets via an SSH tunnel or external command

* src/Makefile.am: Add to libvirt-net-rpc.la
* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Generic
  sockets APIs
* tests/Makefile.am: Add socket test
* tests/virnetsockettest.c: New test case
* tests/testutils.c: Avoid overriding LIBVIRT_DEBUG settings
* tests/ssh.c: Dumb helper program for SSH tunnelling tests

13 years agoProvide a simple object for encoding/decoding RPC messages
Daniel P. Berrange [Mon, 6 Dec 2010 17:03:22 +0000 (17:03 +0000)]
Provide a simple object for encoding/decoding RPC messages

This provides a new struct that contains a buffer for the RPC
message header+payload, as well as a decoded copy of the message
header. There is an API for applying a XDR encoding & decoding
of the message headers and payloads. There are also APIs for
maintaining a simple FIFO queue of message instances.

Expected usage scenarios are:

To send a message

   msg = virNetMessageNew()

   ...fill in msg->header fields..
   virNetMessageEncodeHeader(msg)
   ...loook at msg->header fields to determine payload filter
   virNetMessageEncodePayload(msg, xdrfilter, data)
   ...send msg->bufferLength worth of data from buffer

To receive a message

   msg = virNetMessageNew()
   ...read VIR_NET_MESSAGE_LEN_MAX of data into buffer
   virNetMessageDecodeLength(msg)
   ...read msg->bufferLength-msg->bufferOffset of data into buffer
   virNetMessageDecodeHeader(msg)
   ...look at msg->header fields to determine payload filter
   virNetMessageDecodePayload(msg, xdrfilter, data)
   ...run payload processor

* src/Makefile.am: Add to libvirt-net-rpc.la
* src/rpc/virnetmessage.c, src/rpc/virnetmessage.h: Internal
  message handling API.
* testutils.c, testutils.h: Helper for printing binary differences
* virnetmessagetest.c: Validate all XDR encoding/decoding

13 years agoDefines the basics of a generic RPC protocol in XDR
Daniel P. Berrange [Mon, 6 Dec 2010 17:03:10 +0000 (17:03 +0000)]
Defines the basics of a generic RPC protocol in XDR

This patch defines the basics of a generic RPC protocol in XDR.
This is wire ABI compatible with the original remote_protocol.x.
It takes everything except for the RPC calls / events from that
protocol

 - The basic header virNetMessageHeader (aka remote_message_header)
 - The error object virNetMessageError  (aka remote_error)
 - Two dummy objects virNetMessageDomain & virNetMessageNetwork
   sadly needed to keep virNetMessageError ABI compatible with
   the old remote_error

The RPC protocol supports method calls, async events and
bidirectional data streams as before

* src/Makefile.am: Add rules for generating RPC code from
  protocol & define a new libvirt-net-rpc.la helper library
* src/rpc/virnetprotocol.x: New generic RPC protocol

13 years agobuild: avoid python 2.4 build failure
Eric Blake [Fri, 24 Jun 2011 04:09:00 +0000 (22:09 -0600)]
build: avoid python 2.4 build failure

On RHEL 5, I got:

/usr/bin/python ./generator.py /usr/bin/python
  File "./generator.py", line 427
    "virStreamFree", # Needed in custom virStream __del__, but free shouldn't
                   ^
SyntaxError: invalid syntax

* python/generator.py (function_skip_python_impl): Use same syntax
as other skip lists.

13 years agobuild: avoid compiler failure
Eric Blake [Fri, 24 Jun 2011 03:57:58 +0000 (21:57 -0600)]
build: avoid compiler failure

GCC complained about a C99 for-loop declaration outside of C99 mode
when compiling on RHEL 5.

* src/qemu/qemu_driver.c (qemudDomainPinVcpuFlags): Avoid C99 for
loop, since gcc 4.1.2 hates it.

13 years agodocumenting the 802.1Qbh parameters of a 'direct' interface
David S. Wang [Thu, 23 Jun 2011 16:35:30 +0000 (09:35 -0700)]
documenting the 802.1Qbh parameters of a 'direct' interface

This patch adds documentation about the 802.1Qbh related parameters
of the virtualport element for 'direct' interfaces.

Signed-off-by: David S. Wang <dwang2@cisco.com>
Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: Vasanthy Kolluri <vkolluri@cisco.com>
13 years agobuild: update to latest gnulib
Eric Blake [Wed, 22 Jun 2011 14:47:11 +0000 (08:47 -0600)]
build: update to latest gnulib

Gnulib has been busy, with 397 commits; it's easier to update now
even without any known libvirt issue to be fixed, rather than
having to analyze an even larger changeset later on.

* .gnulib: Update to latest, for lots of changes.
* bootstrap: Synchronize to upstream.

13 years agobuild: fix compilation on systems missing libnl and new includes
Stefan Berger [Thu, 23 Jun 2011 15:54:11 +0000 (11:54 -0400)]
build: fix compilation on systems missing libnl and new includes

This patch fixes the compilation of netlink.c and interface.c on those
systems missing either libnl or that have an older linux/if_link.h
include file not supporting macvtap or VF_PORTS.

WITH_MACVTAP is '1' if newer include files were detected, '0' otherwise.

IFLA_PORT_MAX is defined in linux/if_link.h if yet more functionality is
supported.

13 years agoconfigure: Make libnl optional unless macvtap is required
Matthias Bolte [Thu, 23 Jun 2011 15:51:00 +0000 (11:51 -0400)]
configure: Make libnl optional unless macvtap is required

If macvtap is required then libnl has to be available, otherwise
libnl is optional.

13 years agopython: Generate virStreamFree but don't expose in bindings
Cole Robinson [Tue, 21 Jun 2011 00:06:49 +0000 (20:06 -0400)]
python: Generate virStreamFree but don't expose in bindings

Turns out I was right in removing this the first time :) This is
needed in our custom __del__ function, but the C code wasn't
being generated. Add new infrastructure to do what we want

13 years agomaint: avoid future setgid problems
Eric Blake [Wed, 22 Jun 2011 22:18:01 +0000 (16:18 -0600)]
maint: avoid future setgid problems

* cfg.mk (sc_prohibit_setuid)
(exclude_file_name_regexp--sc_prohibit_setuid): New rule.
(VC_LIST_ALWAYS_EXCLUDE_REGEX): Always exempt po files.
(exclude_file_name_regexp--sc_prohibit_asprintf): Simplify.
(exclude_file_name_regexp--sc_prohibit_can_not): Drop.
(exclude_file_name_regexp--sc_prohibit_doubled_word): Likewise.

13 years agodocs: Make virConnectClose comply to apibuild.py expectations
Matthias Bolte [Wed, 22 Jun 2011 22:38:58 +0000 (00:38 +0200)]
docs: Make virConnectClose comply to apibuild.py expectations

apibuild.py expects a sentence that starts with "Returns"
describing the return value of a function.

13 years agoutil: Fix memory leak in virJSONParserHandleStartMap
Osier Yang [Thu, 23 Jun 2011 10:16:31 +0000 (18:16 +0800)]
util: Fix memory leak in virJSONParserHandleStartMap

13 years agoqemu: Fix memory leak in qemuProcessWaitForMonitor
Osier Yang [Thu, 23 Jun 2011 10:15:25 +0000 (18:15 +0800)]
qemu: Fix memory leak in qemuProcessWaitForMonitor

Move "VIR_FREE(buf) into label "closelog", so that "buf" could be
freed before returning.

13 years agoqemu: Only check for NUMA availability if required
Jiri Denemark [Tue, 21 Jun 2011 16:37:10 +0000 (18:37 +0200)]
qemu: Only check for NUMA availability if required

We only care about NUMA availability if NUMA configuration is requested
in domain XML.

13 years agostorage: fix volDelete return when volume still being allocated
Matthew Booth [Thu, 23 Jun 2011 03:28:29 +0000 (11:28 +0800)]
storage: fix volDelete return when volume still being allocated

volDelete used to return VIR_ERR_INTERNAL_ERROR when attempting to
delete a volume which was still being allocated. It should return
VIR_ERR_OPERATION_INVALID.

* src/storage/storage_driver.c: Fix return of volDelete.

13 years agoutil: avoid PATH_MAX-sized array
Eric Blake [Wed, 22 Jun 2011 20:52:32 +0000 (14:52 -0600)]
util: avoid PATH_MAX-sized array

See previous patch for why this is good...

* src/util/pci.c (struct _pciDevice, pciGetDevice, pciFreeDevice):
Manage path dynamically.  Report snprintf overflow.
* src/util/hostusb.c (struct _usbDevice, usbGetDevice)
(usbFreeDevice): Likewise.

13 years agoxen: avoid PATH_MAX-sized array
Eric Blake [Wed, 22 Jun 2011 20:31:45 +0000 (14:31 -0600)]
xen: avoid PATH_MAX-sized array

See previous patch for why this is good...

* src/xen/xen_driver.h (xenXMConfCache): Manage filename
dynamically.
* src/xen/xm_internal.c (xenXMConfigCacheAddFile)
(xenXMConfigFree, xenXMDomainDefineXML): Likewise.

13 years agotests: avoid PATH_MAX-sized array
Eric Blake [Wed, 22 Jun 2011 20:03:30 +0000 (14:03 -0600)]
tests: avoid PATH_MAX-sized array

See previous patch for why this is good...

* src/test/test_driver.c (struct _testConn, testOpenFromFile)
(testClose): Manage path dynamically.

13 years agovirStorageVol: avoid PATH_MAX-sized array
Eric Blake [Wed, 22 Jun 2011 19:51:32 +0000 (13:51 -0600)]
virStorageVol: avoid PATH_MAX-sized array

POSIX allows implementations where PATH_MAX is undefined, leading
to compilation error.  Not to mention that even if it is defined,
it is often wasteful in relation to the amount of data being stored.

All clients of vol->key were audited, and found not to care about
whether key is static or dynamic, except for these offenders:

* src/datatypes.h (struct _virStorageVol): Manage key dynamically.
* src/datatypes.c (virReleaseStorageVol): Free key.
(virGetStorageVol): Copy key.

13 years agomaint: add omitted copyright header
Eric Blake [Wed, 22 Jun 2011 21:42:51 +0000 (15:42 -0600)]
maint: add omitted copyright header

Bug introduced in commit 6a597883.

* src/util/netlink.h: Add boilerplate.

13 years agodocs: fix docs to match behavior of virConnectClose
Eric Blake [Wed, 22 Jun 2011 16:17:04 +0000 (10:17 -0600)]
docs: fix docs to match behavior of virConnectClose

* src/libvirt.c (virConnectClose): Mention reference count return.
Reported by Michal Novotny, analyzed by Matthias Bolte.

13 years agocleanup: make several interface functions commonly available
Stefan Berger [Wed, 22 Jun 2011 18:28:57 +0000 (14:28 -0400)]
cleanup: make several interface functions commonly available

In a second cleanup step this patch makes several interface functions from macvtap.c commonly available by moving them into interface.c and prefixing their names with 'iface'. Those functions taking Linux-specific structures as parameters are only visible on Linux.

ifaceRestoreMacAddress returns the return code from the ifaceSetMacAddr call and display an error message if setting the MAC address did not work. The caller is unchanged and still ignores the return code (which is ok).

13 years agocleanup: make nlComm commonly available
Stefan Berger [Wed, 22 Jun 2011 18:17:36 +0000 (14:17 -0400)]
cleanup: make nlComm commonly available

In a first cleanup step, make nlComm from macvtap.c commonly available
for other code to use. Since nlComm uses Linux-specific structures as
parameters it's prototype is only visible on Linux.

13 years agomaint: remove syntax-check exception
Eric Blake [Wed, 22 Jun 2011 16:40:24 +0000 (10:40 -0600)]
maint: remove syntax-check exception

We weren't using the @FOO@ notation for a Makefile substitution,
but instead for a sed rule, so using [@]FOO@ instead avoids the
need to exempt this syntax check.

* cfg.mk (_makefile_at_at_check_exceptions): Delete.
* tools/Makefile.am (virt-xml-validate, virt-pki-validate): Avoid
tripping syntax-check.
Reported by Daniel P. Berrange.

13 years agoFix use-after-free in handling domain taint flags
Daniel P. Berrange [Wed, 22 Jun 2011 16:33:10 +0000 (17:33 +0100)]
Fix use-after-free in handling domain taint flags

* src/conf/domain_conf.c: Fix use after free

13 years agoRemove macvtap dependency on domain configuration
Daniel P. Berrange [Mon, 20 Jun 2011 16:08:41 +0000 (17:08 +0100)]
Remove macvtap dependency on domain configuration

Files under src/util must not depend on src/conf
Solve the macvtap problem by moving the definition
of macvtap modes from domain_conf.h into macvtap.h

* src/util/macvtap.c, src/util/macvtap.h: Add enum
  for macvtap modes
* src/conf/domain_conf.c, src/conf/domain_conf.h: Remove
  enum for macvtap modes

13 years agoutil: Correct the error prompt string
Osier Yang [Wed, 22 Jun 2011 11:33:24 +0000 (19:33 +0800)]
util: Correct the error prompt string

virCommandProcessIO: It's reading from stdout or stderr of child,
but not writing.

13 years agoqemu: Fix one memory leak
Osier Yang [Wed, 22 Jun 2011 11:32:04 +0000 (19:32 +0800)]
qemu: Fix one memory leak

* src/qemu/qemu_domain.c: (qemuDomainAppendLog)

  Free "message" in "cleanup".

13 years agoFix to python API extractor and API doc generation
Daniel Veillard [Mon, 20 Jun 2011 03:25:34 +0000 (11:25 +0800)]
Fix to python API extractor and API doc generation

This fixes a number of issues most of them raised by Eric Blake on the
generated documentation output:
   - parsing of "long long int" and similar
   - add parsing of unions within a struct
   - remove spurious " * " fron comments on structure fields and enums
   - fix concatenation of base type and name in arrays
   - extend XSLT to cope with union in structs

* docs/apibuild.py: fix and extend API extraction tool
* docs/newapi.xsl: extend the stylesheets to cope with union in
  public structures

13 years agoqemu: domain I/O asynchronous handling
Michal Privoznik [Mon, 20 Jun 2011 08:26:47 +0000 (10:26 +0200)]
qemu: domain I/O asynchronous handling

For virtio disks and interfaces, qemu allows users to enable or disable
ioeventfd feature. This means, qemu can execute domain code, while
another thread waits for I/O event. Basically, in some cases it is win,
in some loss. This feature is available via 'ioeventfd' attribute in disk
and interface <driver> element. It accepts 'on' and 'off'. Leaving this
attribute out defaults to hypervisor decision.

13 years agobuild: require newer netcf when it is available
Eric Blake [Mon, 20 Jun 2011 15:41:49 +0000 (09:41 -0600)]
build: require newer netcf when it is available

When building rpms for newer Fedora or RHEL, take advantage of the
newer netcf packaging to guarantee interface snapshot support.

* libvirt.spec.in (BuildRequires): Bump minimum version on
platforms that support netcf 0.1.8.

13 years agovirsh: avoid bogus description
Eric Blake [Mon, 20 Jun 2011 20:25:08 +0000 (14:25 -0600)]
virsh: avoid bogus description

https://bugzilla.redhat.com/show_bug.cgi?id=682121

Gettext reserves the empty string for internal use, and it must
not be passed through _().  We were violating this for commands
that (for whatever reason) used "" for their description.

* tools/virsh.c (vshCmddefHelp): Don't translate empty string.
Reported by Tatsuo Kawasaki.

13 years agoset and restore MAC address of a NIC when using PASSTHROUGH mode
Dirk Herrendoerfer [Tue, 21 Jun 2011 15:49:40 +0000 (11:49 -0400)]
set and restore MAC address of a NIC when using PASSTHROUGH mode

The following patch addresses the problem that when a PASSTHROUGH
mode DIRECT NIC connection is made the MAC address of the NIC is
not automatically set and reset to the configured VM MAC and
back again.

The attached patch fixes this problem by setting and resetting the MAC
while remembering the previous setting while the VM is running.
This also works if libvirtd is restarted while the VM is running.

the patch passes make syntax-check

13 years agopython: Mark event callback wrappers as private
Cole Robinson [Thu, 16 Jun 2011 00:14:45 +0000 (20:14 -0400)]
python: Mark event callback wrappers as private

These functions aren't intended to be called directly by users, so mark
them as private.

While we're at it, remove unneeded exception handling, and break some
long lines.

13 years agopython: events: Fix C->Python handle callback prototype
Cole Robinson [Thu, 16 Jun 2011 00:02:27 +0000 (20:02 -0400)]
python: events: Fix C->Python handle callback prototype

If registering our own event loop implementation written in python,
any handles or timeouts callbacks registered by libvirt C code must
be wrapped in a python function. There is some argument trickery that
makes this all work, by wrapping the user passed opaque value in
a tuple, along with the callback function.

Problem is, the current setup requires the user's event loop to know
about this trickery, rather than just treating the opaque value
as truly opaque.

Fix this in a backwards compatible manner, and adjust the example
python event loop to do things the proper way.

13 years agopython: Add bindings for virEvent*Handle/Timeout
Cole Robinson [Wed, 15 Jun 2011 23:35:44 +0000 (19:35 -0400)]
python: Add bindings for virEvent*Handle/Timeout

13 years agoevents: Correct virEventAddTimeout docs
Cole Robinson [Wed, 15 Jun 2011 23:35:19 +0000 (19:35 -0400)]
events: Correct virEventAddTimeout docs

13 years agoPromote virEvent*Handle/Timeout to public API
Cole Robinson [Wed, 15 Jun 2011 21:54:30 +0000 (17:54 -0400)]
Promote virEvent*Handle/Timeout to public API

Since we virEventRegisterDefaultImpl is now a public API, callers need
a way to invoke the default registered Handle and Timeout functions. We
already have general functions for these internally, so promote
them to the public API.

v2:
    Actually add APIs to libvirt.h

13 years agopython: Implement virStreamSend/RecvAll helpers
Cole Robinson [Wed, 15 Jun 2011 20:54:16 +0000 (16:54 -0400)]
python: Implement virStreamSend/RecvAll helpers

Pure python implementation. The handler callbacks have been altered
a bit compared to the C API: RecvAll doesn't pass length of the data read
since that can be trivially obtained from python string objects, and SendAll
requires the handler to return the string data to send rather than
store the data in a string pointer.

13 years agopython: Implement virStreamSend/Recv
Cole Robinson [Tue, 14 Jun 2011 20:07:43 +0000 (16:07 -0400)]
python: Implement virStreamSend/Recv

The return values for the python version are different that the C version
of virStreamSend: on success we return a string, an error raises an exception,
and if the stream would block we return int(-2). We need to do this
since strings aren't passed by reference in python.

13 years agoconf: Make full use of goto label
Osier Yang [Tue, 21 Jun 2011 08:20:15 +0000 (16:20 +0800)]
conf: Make full use of goto label

* virDomainDefParse: There is a goto label "no_memory", which
reports OOM error, and then fallthrough label "error". This
patch changes things like following:

    virReportOOMError();
    goto error;

into:

    goto no_memory;

13 years agoconf: Fix one memory leak
Osier Yang [Tue, 21 Jun 2011 08:03:59 +0000 (16:03 +0800)]
conf: Fix one memory leak

Free def->numatune.memory.nodemask in virDomainDefFree.

13 years agopython: Implement bindings for virStreamEventAddCallback
Cole Robinson [Tue, 14 Jun 2011 17:49:22 +0000 (13:49 -0400)]
python: Implement bindings for virStreamEventAddCallback

v2:
    Don't generate virStreamFree

13 years agopython: generator: Don't print warning if nothing to warn about
Cole Robinson [Wed, 15 Jun 2011 21:57:37 +0000 (17:57 -0400)]
python: generator: Don't print warning if nothing to warn about

13 years agopython: libvirt-override: use simpler debug
Cole Robinson [Tue, 14 Jun 2011 16:59:44 +0000 (12:59 -0400)]
python: libvirt-override: use simpler debug

In a couple instances we have to mark a debug variable as ATTRIBUTE_UNUSED
to avoid warnings.

v2:
    Use #if 0 to comment out debug define

13 years agovirsh: enhance snapshot-create-as
Eric Blake [Wed, 15 Jun 2011 22:24:40 +0000 (16:24 -0600)]
virsh: enhance snapshot-create-as

Similar to pool-create-as.

* tools/virsh.c (cmdSnapshotCreateAs): Add --print-xml.
* tools/virsh.pod: Document it.

13 years agovirsh: add snapshot-create-as command
Eric Blake [Wed, 15 Jun 2011 22:19:13 +0000 (16:19 -0600)]
virsh: add snapshot-create-as command

Producing an xml file just for name and description fields is
overkill; this makes life easier from virsh.

* tools/virsh.c (cmdSnapshotCreateAs): New command.
(snapshotCmds): Install it.
* tools/virsh.pod: Document it.

13 years agovirsh: clarify snapshot vs. save
Eric Blake [Wed, 15 Jun 2011 20:24:53 +0000 (14:24 -0600)]
virsh: clarify snapshot vs. save

* tools/virsh.c (info_snapshot_create, info_save): Clarify
description.
* tools/virsh.pod (save): Likewise.

13 years agoFix compile warnings in virsh vcpupin
Daniel P. Berrange [Mon, 20 Jun 2011 13:28:14 +0000 (14:28 +0100)]
Fix compile warnings in virsh vcpupin

The 'char *cur' variable was being assigned from a
'const char *' string, thus discarding constness.
As well as causing a compile warning, it masked a
piece of code which attempts to assign to the
previously const string.

* tools/virsh.c: Fix const-ness of 'cur' variable in vcpupin

13 years agoremote generator: Allow to annotate arrays with typecasts
Matthias Bolte [Thu, 16 Jun 2011 09:30:23 +0000 (11:30 +0200)]
remote generator: Allow to annotate arrays with typecasts

Removes special case code from the generator and handle additional
methods.

The generated version of remoteDispatchDomainPinVcpu(Flags) has no
length check, but this check was useless anyway as it was applied to
data that was already deserialized from its XDR form.

13 years agoremote: Handle functions that return optional strings
Matthias Bolte [Wed, 15 Jun 2011 18:03:45 +0000 (20:03 +0200)]
remote: Handle functions that return optional strings

13 years agoremote: Generate virDomainGetBlockPullInfo
Matthias Bolte [Wed, 15 Jun 2011 17:52:09 +0000 (19:52 +0200)]
remote: Generate virDomainGetBlockPullInfo

It was already generatable but skipped.

13 years agovcpupin: add vcpupin resetting feature to qemu driver
Taku Izumi [Fri, 10 Jun 2011 06:41:18 +0000 (15:41 +0900)]
vcpupin: add vcpupin resetting feature to qemu driver

Pinning to all physical cpus means resetting, hence it is preferable to
delete vcpupin setting of XML.

This patch changes qemu driver to delete vcpupin setting by invoking
virDomainVcpupinDel API when pinning the specified virtual cpu to
all host physical cpus.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agovcpupin: add virDomainVcpupinDel function
Taku Izumi [Fri, 10 Jun 2011 06:40:36 +0000 (15:40 +0900)]
vcpupin: add virDomainVcpupinDel function

This patch add the private API (virDomainVcpupinDel).
This API can delete the vcpupin setting of a specified virtual cpu.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agovcpupin: add reset option to virsh vcpupin command
Taku Izumi [Fri, 10 Jun 2011 06:39:38 +0000 (15:39 +0900)]
vcpupin: add reset option to virsh vcpupin command

When resetting vcpupin setting, we have to specify all host physical
cpus as a cpulist parameter of virsh vcpupin command. It's a little
tedious.

This patch changes to allow to receive the special keyword 'r' as a cpulist
parameter of virsh vcpupin command when resetting vcpupin setting.

If you set the following:

 # virsh vcpupin VM 0 r

the vcpu0 will be pinned to all physical cpus.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agovcpupin: improve vcpupin definition of virsh vcpupin
Taku Izumi [Fri, 10 Jun 2011 06:38:55 +0000 (15:38 +0900)]
vcpupin: improve vcpupin definition of virsh vcpupin

When using vcpupin command, we have to speficy comma-separated list as cpulist,
but this is tedious in case the number of phsycal cpus is large.
This patch improves this by introducing special markup "-" and "^" which are
similar to XML schema of "cpuset" attribute.

The example:

 # virsh vcpupin Guest 0 0-15,^8

 is identical to

 # virsh vcpupin Guest 0 0,1,2,3,4,5,6,7,9,10,11,12,13,14,15

NOTE: The expression is sequentially evaluated, so "0-15,^8" is not identical
to "^8,0-15".

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agoFix preprocessor indentation in nodeinfo.c
Matthias Bolte [Mon, 20 Jun 2011 08:39:09 +0000 (10:39 +0200)]
Fix preprocessor indentation in nodeinfo.c

13 years agoMove XenAPI driver to correct spec file section
Matthias Bolte [Thu, 16 Jun 2011 11:46:38 +0000 (13:46 +0200)]
Move XenAPI driver to correct spec file section

The XenAPI driver works like the ESX and PHyp driver by using its
own HTTPS based remote protocol.

13 years agonumatune: Add tests for numatune XML
Osier Yang [Mon, 20 Jun 2011 07:17:43 +0000 (15:17 +0800)]
numatune: Add tests for numatune XML

Only add tests for qemuxmlargvtest.c, as there is no qemu command line
for numatune XML, just want to make sure the XML could be validated
well.

13 years agonumatune: Support NUMA memory tuning in qemu driver
Osier Yang [Mon, 20 Jun 2011 07:16:16 +0000 (15:16 +0800)]
numatune: Support NUMA memory tuning in qemu driver

Implemented as setting NUMA policy between fork and exec as a hook,
using libnuma. Only support memory tuning on domain process currently.

For the nodemask out of range, will report soft warning instead of
hard error in libvirt layer. (Kernel will be silent as long as one
of set bit in the nodemask is valid on the host. E.g. For a host
has two NUMA nodes, kernel will be silent for nodemask "01010101").
So, soft warning is the only thing libvirt can do, as one might want
to specify the numa policy prior to a node that doesn't exist yet,
however, it may come as hotplug soon.

13 years agonumatune: Support persistent XML for numatune
Osier Yang [Mon, 20 Jun 2011 07:15:44 +0000 (15:15 +0800)]
numatune: Support persistent XML for numatune

* src/conf/domain_conf.h: Introduce one new struct for representing
NUMA tuning related stuffs.

* src/conf/domain_conf.c: Parse and format numatune XML.

13 years agonumatune: Add doc for new numatune XML
Osier Yang [Mon, 20 Jun 2011 07:15:05 +0000 (15:15 +0800)]
numatune: Add doc for new numatune XML

13 years agonumatune: Define XML schema
Osier Yang [Mon, 20 Jun 2011 07:13:25 +0000 (15:13 +0800)]
numatune: Define XML schema

Example XML:

<numatune>
  <memory mode="strict" nodeset="0-10,^4"/>
</numatune>

Please enter the commit message for your changes. Lines starting

13 years agoUpdate qemuDomainSetBlkioParameters to use flags
Hu Tao [Tue, 7 Jun 2011 06:03:09 +0000 (14:03 +0800)]
Update qemuDomainSetBlkioParameters to use flags

13 years agoupdate qemuDomainGetBlkioParameters to use flags
Hu Tao [Tue, 7 Jun 2011 06:03:08 +0000 (14:03 +0800)]
update qemuDomainGetBlkioParameters to use flags

13 years agoAdd new parameters for blkiotune
Hu Tao [Tue, 7 Jun 2011 06:03:07 +0000 (14:03 +0800)]
Add new parameters for blkiotune

Add --config, --live and --current for command blkiotune

13 years agobuild: fix building error when building without libvirtd
Wen Congyang [Mon, 20 Jun 2011 02:48:07 +0000 (10:48 +0800)]
build: fix building error when building without libvirtd

When building libvirt without libvirtd, we will receive the following error
message:

make[3]: Entering directory `/home/wency/rpmbuild/BUILD/libvirt-0.9.2/tools'
  CC     virsh-virsh.o
  CC     virsh-console.o
  GEN    virt-xml-validate
  GEN    virt-pki-validate
  CCLD   virsh
./src/.libs/libvirt.so: undefined reference to `numa_available'
./src/.libs/libvirt.so: undefined reference to `numa_max_node'
collect2: ld returned 1 exit status

The reason is that: we check numactl only when building qemu driver, and qemu
driver will not be built when bulding without libvirtd. So with_numactl's
value is check and we will not link libnuma.so.

In the other function, we call numa_available() and numa_max_node() only
when HAVE_NUMACTL is 1. We should do the same check in the function nodeGetMemoryStats().

13 years agoapparmor: implement AppArmorSetFDLabel()
Jamie Strandboge [Mon, 20 Jun 2011 03:53:24 +0000 (11:53 +0800)]
apparmor: implement AppArmorSetFDLabel()

During a savevm operation, libvirt will now use fd migration if qemu
supports it. When the AppArmor driver is enabled, AppArmorSetFDLabel()
is used but since this function simply returns '0', the dynamic AppArmor
profile is not updated and AppArmor blocks access to the save file. This
patch implements AppArmorSetFDLabel() to get the pathname of the file by
resolving the fd symlink in /proc, and then gives that pathname to
reload_profile(), which fixes 'virsh save' when AppArmor is enabled.

Reference: https://launchpad.net/bugs/795800

13 years agoAdd missing checks for NULL in domain lock manager
Daniel P. Berrange [Tue, 14 Jun 2011 08:05:54 +0000 (09:05 +0100)]
Add missing checks for NULL in domain lock manager

The domain lock manager forgot to include a bunch of checks
for NULL which could occur on OOM

* src/locking/domain_lock.c: Add checks for NULL

13 years agoFix errno return in safezero()
Daniel P. Berrange [Tue, 14 Jun 2011 08:07:39 +0000 (09:07 +0100)]
Fix errno return in safezero()

Most of the safezero() implementations return -1 on error,
setting errno. The safezero() impl using posix_fallocate()
though returned a positive errno value on error (due to
the unusual API contract of posix_fallocate() compared to
most syscall APIs).

* src/util/util.c: Ensure safezero() returns -1 and sets
  errno on error.
* src/storage/storage_backend.c: Change safezero != 0 to
  < 0 for detecting errors

13 years agoAdd missing error reporting when loading mac filter config for QEMU
Daniel P. Berrange [Tue, 14 Jun 2011 08:11:31 +0000 (09:11 +0100)]
Add missing error reporting when loading mac filter config for QEMU

If the 'mac_filter' configuration parameter is enabled, and there
is a failure to enable filtering, no error is reported back to
the caller. Also fix some bogus whitespace indentation for
hugetlbfs_mount

* src/qemu/qemu_conf.c: Add missing error reporting

13 years agovirsh: Add support for virDomainGetControlInfo
Jiri Denemark [Tue, 31 May 2011 16:21:58 +0000 (18:21 +0200)]
virsh: Add support for virDomainGetControlInfo

13 years agoqemu: Implement virDomainGetControlInfo
Jiri Denemark [Tue, 31 May 2011 16:34:20 +0000 (18:34 +0200)]
qemu: Implement virDomainGetControlInfo

13 years agoWire protocol and remote driver for virDomainGetControlInfo
Jiri Denemark [Tue, 31 May 2011 15:37:00 +0000 (17:37 +0200)]
Wire protocol and remote driver for virDomainGetControlInfo

13 years agoIntroduce virDomainGetControlInfo API
Jiri Denemark [Tue, 24 May 2011 08:28:50 +0000 (11:28 +0300)]
Introduce virDomainGetControlInfo API

The API can be used to query current state of an interface to VMM used
to control a domain. In QEMU world this translates into monitor
connection.

13 years agoFix documentation of virStreamRecv
Matthias Bolte [Wed, 15 Jun 2011 16:38:26 +0000 (18:38 +0200)]
Fix documentation of virStreamRecv

virStreamRecv is for reading.

Also add some missing punctuation to virStreamSend's documentation.

13 years agosendkey: use consistent API convention
Eric Blake [Wed, 15 Jun 2011 16:33:59 +0000 (10:33 -0600)]
sendkey: use consistent API convention

Even though rpc uses 'unsigned int' for the _len parameter that
passes the length of item<length>, the public libvirt APIs all
use 'int' and filter out lengths < 0, except for virDomainSendKey.

* include/libvirt/libvirt.h.in (virDomainSendKey): All other APIs
use int for array length.
* src/libvirt.c (virDomainSendKey): Adjust.
* src/driver.h (virDrvDomainSendKey): Likewise.
* daemon/remote_generator.pl: Likewise.

13 years agobuild: export correct function names
Eric Blake [Wed, 15 Jun 2011 17:23:51 +0000 (11:23 -0600)]
build: export correct function names

Detected by autobuild.sh, when targetting mingw.
Introduced in commit 98bfdff.

* src/libvirt_private.syms: Fix typos.

13 years agobuild: avoid compiler warning on non-Linux
Eric Blake [Wed, 15 Jun 2011 17:21:28 +0000 (11:21 -0600)]
build: avoid compiler warning on non-Linux

Detected by autobuild.sh when cross-building for mingw.
Introduced in commits ce76e85 and af35cec.

* src/nodeinfo.c (nodeGetCPUStats, nodeGetMemoryStats): Mark
parameters as potentially unused.

13 years agoremote generator: Handle struct returning functions better (part 2)
Matthias Bolte [Wed, 15 Jun 2011 15:34:19 +0000 (17:34 +0200)]
remote generator: Handle struct returning functions better (part 2)

Commit 64000eabedf2 is part 1, that only covered the daemon side by
accident. Part 2 covers the client side too.

13 years agoFix apibuild.py warnings about missing comment headers
Matthias Bolte [Wed, 15 Jun 2011 10:32:19 +0000 (12:32 +0200)]
Fix apibuild.py warnings about missing comment headers

Also improve wording of some comments.

13 years agoremote generator: Handle struct returning functions better
Matthias Bolte [Wed, 15 Jun 2011 13:38:31 +0000 (15:38 +0200)]
remote generator: Handle struct returning functions better

The position of the struct parameter in the function signature
differs. Instead of hardcoding the handling for this add an annotation
to the .x file to define the position.

13 years agosupport for Xen HVM Viridian (Hyper-V) enlightenment interface
Daniel Gollub [Wed, 15 Jun 2011 13:27:43 +0000 (15:27 +0200)]
support for Xen HVM Viridian (Hyper-V) enlightenment interface

Introduce libvirt support for Xen HVM Viridian (Hyper-V) enlightenment
interface guest feature.

 src/conf/domain_conf.c     |    3 ++-
 src/conf/domain_conf.h     |    1 +
 src/xen/xen_hypervisor.c   |   11 +++++++++++
 src/xenapi/xenapi_driver.c |    2 ++
 src/xenapi/xenapi_utils.c  |    2 ++
 src/xenxs/xen_sxpr.c       |    4 ++++
 src/xenxs/xen_xm.c         |   12 +++++++++++-
 7 files changed, 33 insertions(+), 2 deletions(-)

13 years agovirsh: reduce complexity in argv iteration
Eric Blake [Tue, 14 Jun 2011 17:26:20 +0000 (11:26 -0600)]
virsh: reduce complexity in argv iteration

This reduces things from O(n^2) to O(n).

* tools/virsh.c (vshCommandOptArgv): Change signature.
(cmdEcho): Update caller.
Based on a patch by Lai Jiangshan.

13 years agoAdd support for network filter code in LXC driver
Daniel P. Berrange [Tue, 7 Jun 2011 13:29:08 +0000 (14:29 +0100)]
Add support for network filter code in LXC driver

The LXC driver networking uses veth device pairs. These can
be easily hooked into the network filtering code.

* src/lxc/lxc_driver.c: Add calls to setup/teardown nwfilter

13 years agoFix allocation of veth's to not skip an index
Daniel P. Berrange [Tue, 7 Jun 2011 13:26:48 +0000 (14:26 +0100)]
Fix allocation of veth's to not skip an index

The algorithm for autoassigning vethXXX devices, was always
skipping over the starting dev index when finding a free
name for the guest device. This should only be done if the host
device was autoallocated.

* src/lxc/veth.c: Don't skip over veth indexes

13 years agoqemu: Translate boot config into bootindex if possible
Jiri Denemark [Thu, 26 May 2011 14:15:01 +0000 (17:15 +0300)]
qemu: Translate boot config into bootindex if possible

Prefer bootindex=N option for -device over the old way -boot ORDER
possibly accompanied with boot=on option for -drive. This gives us full
control over which device will actually be used for booting guest OS.
Moreover, if qemu doesn't support boot=on, this is the only way to boot
of certain disks in some configurations (such as virtio disks when used
together IDE disks) without transforming domain XML to use per device
boot elements.

13 years agoAsynchronous event for BlockPull completion
Adam Litke [Tue, 14 Jun 2011 14:36:53 +0000 (09:36 -0500)]
Asynchronous event for BlockPull completion

When an operation started by virDomainBlockPullAll completes (either with
success or with failure), raise an event to indicate the final status.  This
allows an API user to avoid polling on virDomainBlockPullInfo if they would
prefer to use the event mechanism.

* daemon/remote.c: Dispatch events to client
* include/libvirt/libvirt.h.in: Define event ID and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle the new event
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for block_stream completion and emit a libvirt block pull event
* src/remote/remote_driver.c: Receive and dispatch events to application
* src/remote/remote_protocol.x: Wire protocol definition for the event
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for BLOCK_STREAM_COMPLETED event
  from QEMU monitor

Signed-off-by: Adam Litke <agl@us.ibm.com>
13 years agoEnable virDomainBlockPull in the python API.
Adam Litke [Tue, 14 Jun 2011 14:36:52 +0000 (09:36 -0500)]
Enable virDomainBlockPull in the python API.

virDomainBlockPullAll and virDomainBlockPullAbort are handled automatically.
virDomainBlockPull and virDomainBlockPullInfo require manual overrides since
they return a custom type.

* python/generator.py: reenable bindings for this entry point
* python/libvirt-override-api.xml python/libvirt-override.c:
  manual overrides

Signed-off-by: Adam Litke <agl@us.ibm.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoEnable the virDomainBlockPull API in virsh
Adam Litke [Tue, 14 Jun 2011 14:36:51 +0000 (09:36 -0500)]
Enable the virDomainBlockPull API in virsh

Define two new virsh commands:
 * blockpull: Perform block pull operations (incremental plus start
              and stop continuous streams)
 * blockpullinfo: Retrieve progress info for continuous block pull

Share print_job_progress() with the migration code.

* tools/virsh.c: implement the new commands

Signed-off-by: Adam Litke <agl@us.ibm.com>
13 years agoImplement virDomainBlockPull for the qemu driver
Adam Litke [Tue, 14 Jun 2011 14:36:50 +0000 (09:36 -0500)]
Implement virDomainBlockPull for the qemu driver

The virDomainBlockPull* family of commands are enabled by the
'block_stream' and 'info block_stream' qemu monitor commands.

* src/qemu/qemu_driver.c src/qemu/qemu_monitor_text.[ch]: implement disk
  streaming by using the stream and info stream text monitor commands
* src/qemu/qemu_monitor_json.[ch]: implement commands using the qmp monitor

Signed-off-by: Adam Litke <agl@us.ibm.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
13 years agoAdd virDomainBlockPull support to the remote driver
Adam Litke [Tue, 14 Jun 2011 14:36:49 +0000 (09:36 -0500)]
Add virDomainBlockPull support to the remote driver

The generator can handle DomainBlockPullAll and DomainBlockPullAbort.
DomainBlockPull and DomainBlockPullInfo must be written by hand.

* src/remote/remote_protocol.x: provide defines for the new entry points
* src/remote/remote_driver.c daemon/remote.c: implement the client and
  server side
* src/remote_protocol-structs: structure definitions for protocol verification

Signed-off-by: Adam Litke <agl@us.ibm.com>
13 years agovirDomainBlockPull: Implement the main entry points
Adam Litke [Tue, 14 Jun 2011 14:36:48 +0000 (09:36 -0500)]
virDomainBlockPull: Implement the main entry points

* src/libvirt.c: implement the main entry points

Signed-off-by: Adam Litke <agl@us.ibm.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>