Commit Graph

7326 Commits

Author SHA1 Message Date
Eric Blake
60bfd5b565 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.
2011-06-22 17:13:58 -06:00
Eric Blake
565c975f9b 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.
2011-06-22 17:13:58 -06:00
Eric Blake
ca8b4cec6d 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.
2011-06-22 17:13:58 -06:00
Eric Blake
aa286e537d 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.
2011-06-22 17:13:58 -06:00
Eric Blake
26dc216ae8 maint: add omitted copyright header
Bug introduced in commit 6a597883.

* src/util/netlink.h: Add boilerplate.
2011-06-22 15:42:51 -06:00
Eric Blake
dbcd8c5967 docs: fix docs to match behavior of virConnectClose
* src/libvirt.c (virConnectClose): Mention reference count return.
Reported by Michal Novotny, analyzed by Matthias Bolte.
2011-06-22 13:25:56 -06:00
Stefan Berger
df3d8c362d 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).
2011-06-22 14:28:57 -04:00
Stefan Berger
6a5978833a 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.
2011-06-22 14:17:36 -04:00
Eric Blake
50a6a1267a 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.
2011-06-22 10:45:21 -06:00
Daniel P. Berrange
abb82f53ed Fix use-after-free in handling domain taint flags
* src/conf/domain_conf.c: Fix use after free
2011-06-22 17:39:45 +01:00
Daniel P. Berrange
caf808c790 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
2011-06-22 17:39:06 +01:00
Osier Yang
73b9246df9 util: Correct the error prompt string
virCommandProcessIO: It's reading from stdout or stderr of child,
but not writing.
2011-06-22 19:33:24 +08:00
Osier Yang
20d5e9db82 qemu: Fix one memory leak
* src/qemu/qemu_domain.c: (qemuDomainAppendLog)

  Free "message" in "cleanup".
2011-06-22 19:32:04 +08:00
Daniel Veillard
d42ea21aec 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
2011-06-22 15:50:08 +08:00
Michal Privoznik
017abcbb1a 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.
2011-06-22 09:26:24 +02:00
Eric Blake
1486099cca 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.
2011-06-21 14:27:32 -06:00
Eric Blake
491858bf3c 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.
2011-06-21 11:46:09 -06:00
Dirk Herrendoerfer
cbd8227ee0 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
2011-06-21 11:49:40 -04:00
Cole Robinson
7268cb9274 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.
2011-06-21 10:08:48 -04:00
Cole Robinson
f2fb235b1d 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.
2011-06-21 10:08:48 -04:00
Cole Robinson
d0e3f3d6a6 python: Add bindings for virEvent*Handle/Timeout 2011-06-21 10:08:47 -04:00
Cole Robinson
27e47955a0 events: Correct virEventAddTimeout docs 2011-06-21 10:08:47 -04:00
Cole Robinson
6094ad7bd7 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
2011-06-21 10:08:47 -04:00
Cole Robinson
3b04871e80 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.
2011-06-21 10:08:47 -04:00
Cole Robinson
ca55dc598c 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.
2011-06-21 10:08:47 -04:00
Osier Yang
a22dbe0d66 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;
2011-06-21 16:20:15 +08:00
Osier Yang
9a2ac25a63 conf: Fix one memory leak
Free def->numatune.memory.nodemask in virDomainDefFree.
2011-06-21 16:03:59 +08:00
Cole Robinson
b1ede4cf9c python: Implement bindings for virStreamEventAddCallback
v2:
    Don't generate virStreamFree
2011-06-20 14:11:55 -04:00
Cole Robinson
eb3151b411 python: generator: Don't print warning if nothing to warn about 2011-06-20 14:10:45 -04:00
Cole Robinson
e8c8fc144d 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
2011-06-20 14:10:26 -04:00
Eric Blake
9256ad84fc virsh: enhance snapshot-create-as
Similar to pool-create-as.

* tools/virsh.c (cmdSnapshotCreateAs): Add --print-xml.
* tools/virsh.pod: Document it.
2011-06-20 10:44:08 -06:00
Eric Blake
1546dcf866 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.
2011-06-20 10:44:06 -06:00
Eric Blake
ea71d82816 virsh: clarify snapshot vs. save
* tools/virsh.c (info_snapshot_create, info_save): Clarify
description.
* tools/virsh.pod (save): Likewise.
2011-06-20 10:05:27 -06:00
Daniel P. Berrange
b325768064 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
2011-06-20 14:50:27 +01:00
Matthias Bolte
272ead559c 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.
2011-06-20 11:23:34 +02:00
Matthias Bolte
ac77cbaeae remote: Handle functions that return optional strings 2011-06-20 11:23:34 +02:00
Matthias Bolte
6be35f5fef remote: Generate virDomainGetBlockPullInfo
It was already generatable but skipped.
2011-06-20 11:23:34 +02:00
Taku Izumi
7ea9778c8a 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>
2011-06-20 18:14:54 +08:00
Taku Izumi
3711c0b051 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>
2011-06-20 18:14:54 +08:00
Taku Izumi
c4a8ca71b1 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>
2011-06-20 18:14:54 +08:00
Taku Izumi
2903534a30 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>
2011-06-20 18:14:54 +08:00
Matthias Bolte
d967a8bfa4 Fix preprocessor indentation in nodeinfo.c 2011-06-20 10:39:09 +02:00
Matthias Bolte
7e3205cd10 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.
2011-06-20 10:23:55 +02:00
Osier Yang
b369114de6 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.
2011-06-20 15:17:43 +08:00
Osier Yang
a6f5c9b600 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.
2011-06-20 15:16:16 +08:00
Osier Yang
d7edaf5d8c 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.
2011-06-20 15:15:44 +08:00
Osier Yang
e6ea48c325 numatune: Add doc for new numatune XML 2011-06-20 15:15:05 +08:00
Osier Yang
e68b9ab0b8 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
2011-06-20 15:13:25 +08:00
Hu Tao
8485e5a256 Update qemuDomainSetBlkioParameters to use flags 2011-06-20 15:52:11 +08:00
Hu Tao
100c39ca03 update qemuDomainGetBlkioParameters to use flags 2011-06-20 15:52:11 +08:00