Commit Graph

9265 Commits

Author SHA1 Message Date
Philipp Hahn
184fc07fda xen_xs: name xendConfigVersion magic numbers
libvirt supports 4 different versions of the user-land XenD daemon. When
queried the daemon just returns its generation number, which is hard to
match to the version of the Xen tools.

Replace the magic generation numbers by named enum definitions to
improve code readability.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2012-02-01 16:28:17 -07:00
Alex Jia
be9fb5affc network: Avoid memory leaks on networkBuildDnsmasqArgv
Detected by valgrind. Leaks introduced in commit 973af236.

* src/network/bridge_driver.c: fix memory leaks on failure and successful path.

* How to reproduce?
% make -C tests check TESTS=networkxml2argvtest
% cd tests && valgrind -v --leak-check=full ./networkxml2argvtest

* Actual result:

==2226== 3 bytes in 1 blocks are definitely lost in loss record 1 of 24
==2226==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226==    by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226==    by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226==    by 0x41E0B7: virAsprintf (util.c:1695)
==2226==    by 0x41A2D9: networkBuildDhcpDaemonCommandLine (bridge_driver.c:545)
==2226==    by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226==    by 0x4156A1: virtTestRun (testutils.c:141)
==2226==    by 0x414332: mymain (networkxml2argvtest.c:123)
==2226==    by 0x414D97: virtTestMain (testutils.c:696)
==2226==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== 3 bytes in 1 blocks are definitely lost in loss record 2 of 24
==2226==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226==    by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226==    by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226==    by 0x41E0B7: virAsprintf (util.c:1695)
==2226==    by 0x41A307: networkBuildDhcpDaemonCommandLine (bridge_driver.c:551)
==2226==    by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226==    by 0x4156A1: virtTestRun (testutils.c:141)
==2226==    by 0x414332: mymain (networkxml2argvtest.c:123)
==2226==    by 0x414D97: virtTestMain (testutils.c:696)
==2226==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== 5 bytes in 1 blocks are definitely lost in loss record 4 of 24
==2226==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226==    by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226==    by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226==    by 0x41E0B7: virAsprintf (util.c:1695)
==2226==    by 0x41A2AB: networkBuildDhcpDaemonCommandLine (bridge_driver.c:539)
==2226==    by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226==    by 0x4156A1: virtTestRun (testutils.c:141)
==2226==    by 0x414332: mymain (networkxml2argvtest.c:123)
==2226==    by 0x414D97: virtTestMain (testutils.c:696)
==2226==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== LEAK SUMMARY:
==2226==    definitely lost: 11 bytes in 3 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2012-02-01 16:16:59 -07:00
Eric Blake
9f902a2ed5 block rebase: initial qemu implementation
This is a trivial implementation, which works with the current
released qemu 1.0 with backports of preliminary block pull but
no partial rebase.  Future patches will update the monitor handling
to support an optional parameter for partial rebase; but as qemu
1.1 is unreleased, it can be in later patches, designed to be
backported on top of the supported API.

* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Add parameter,
and adjust callers.  Drop redundant check.
(qemuDomainBlockPull): Move guts...
(qemuDomainBlockRebase): ...to new function.
2012-02-01 15:31:44 -07:00
Eric Blake
8ee8fd6555 block rebase: wire up remote protocol
Nice and simple.

* src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_BLOCK_REBASE):
New RPC.
* src/remote/remote_driver.c (remote_driver): Wire it up.
* src/remote_protocol-structs: Regenerate.
2012-02-01 15:27:39 -07:00
Eric Blake
99fd69c3de block rebase: add new API virDomainBlockRebase
Qemu is adding the ability to do a partial rebase.  That is, given:

base <- intermediate <- current

virDomainBlockPull will produce:

current

but qemu now has the ability to leave base in the chain, to produce:

base <- current

Note that current qemu can only do a forward merge, and only with
the current image as the destination, which is fully described by
this API without flags.  But in the future, it may be possible to
enhance this API for additional scenarios by using flags:

Merging the current image back into a previous image (that is,
undoing a live snapshot), could be done by passing base as the
destination and flags with a bit requesting a backward merge.

Merging any other part of the image chain, whether forwards (the
backing image contents are pulled into the newer file) or backwards
(the deltas recorded in the newer file are merged back into the
backing file), could also be done by passing a new flag that says
that base should be treated as an XML snippet rather than an
absolute path name, where the XML could then supply the additional
instructions of which part of the image chain is being merged into
any other part.

* include/libvirt/libvirt.h.in (virDomainBlockRebase): New
declaration.
* src/libvirt.c (virDomainBlockRebase): Implement it.
* src/libvirt_public.syms (LIBVIRT_0.9.10): Export it.
* src/driver.h (virDrvDomainBlockRebase): New driver callback.
* src/rpc/gendispatch.pl (long_legacy): Add exemption.
* docs/apibuild.py (long_legacy_functions): Likewise.
2012-02-01 15:21:56 -07:00
Peter Krempa
21d13ddc5d qemu: Add support for virDomainGetMetadata and virDomainSetMetadata
This patch adds support for the new api into the qemu driver to support
modification and retrieval of domain description and title. This patch
does not add support for modifying the <metadata> element.
2012-02-01 15:19:28 -07:00
Peter Krempa
fad5cd2108 virsh: Add support for modifying domain description and titles
This patch adds a new command "desc" to show and modify titles and
description for the domains using the new API.

This patch also adds a new flag for the "list" command to show titles in
the domain list, to allow easy identification of VMs by storing a short
description.

Example:
virsh # list --title
 Id Name                 State      Title
 -----------------------------------------------
   0 Domain-0             running    Mailserver 1
   2 fedora               paused
2012-02-01 15:12:53 -07:00
Peter Krempa
c471e55e10 API: Add api to set and get domain metadata
This patch adds API to modify domain metadata for running and stopped
domains. The api supports changing description, title as well as the
newly added <metadata> element. The API has support for storing data in
the metadata element using xml namespaces.

* include/libvirt/libvirt.h.in
* src/libvirt_public.syms
        - add function headers
        - add enum to select metadata to operate on
        - export functions
* src/libvirt.c
        - add public api implementation
* src/driver.h
        - add driver support
* src/remote/remote_driver.c
* src/remote/remote_protocol.x
        - wire up the remote protocol
* include/libvirt/virterror.h
* src/util/virterror.c
        - add a new error message note that metadata for domain are
        missing
2012-02-01 15:01:38 -07:00
Peter Krempa
b79ba8382e xml: Add element <title> to allow short description of domains
This patch adds a new element <title> to the domain XML. This attribute
can hold a short title defined by the user to ease the identification of
domains. The title may not contain newlines and should be reasonably short.

 *docs/formatdomain.html.in
 *docs/schemas/domaincommon.rng
        - add schema grammar for the new element and documentation
  *src/conf/domain_conf.c
  *src/conf/domain_conf.h
        - add field to hold the new attribute
        - add code to parse and create XML with the new attribute
2012-02-01 14:41:13 -07:00
Laine Stump
26e9fdc0bc build: add missing virStorageFileResize to libvirt_private.syms
This was forgotten when the function was originally written (not
noticed because it wasn't used at the time). It's required for
proper compilation with modules enabled after applying the recent
virStorageVolResize patches.
2012-02-01 16:14:46 -05:00
Laine Stump
f594cddaf2 build: add missing virCommandAddCap to libvirt_private.syms
This was forgotten when the function was initially written (not
noticed because it wasn't used at the time). It's required for proper
compilation with modules enabled after applying the recent rawio
patches.
2012-02-01 16:14:46 -05:00
Jiri Denemark
1d7086c2ed qemu: Silent bogus warning about unitialized variable
GCC complaints about uninitialized use of len, which however is only
used when errors != NULL and in that case len is always initialized.
It's trivial to silence this by always initializing len.
2012-02-01 16:13:25 +01:00
Michal Privoznik
d7320e799f daemon: Allow overriding NOFILES ulimit for the daemon as well
One of my latest patches (d8db0f9690) created support for setting
the limit for the maximum of opened files by qemu user. However,
since libvirtd keeps one FD opened per domain (well, for qemu at least)
it will likely hit this limit on huge scenarios.
2012-02-01 16:04:30 +01:00
Jiri Denemark
7bceae0fa6 python: Add binding for virDomainGetDiskErrors 2012-02-01 10:59:27 +01:00
Jiri Denemark
e08d2a9ad8 virsh: Implement domblkerror command
This command lists all disk devices with errors
2012-02-01 10:56:45 +01:00
Jiri Denemark
e17e3ed6aa qemu: Implement virDomainGetDiskErrors 2012-02-01 10:54:15 +01:00
Jiri Denemark
342fc56f58 Remote protocol for virDomainGetDiskErrors 2012-02-01 10:50:58 +01:00
Jiri Denemark
02af3e13b2 virDomainGetDiskErrors public API
We already provide ways to detect when a domain has been paused as a
result of I/O error, but there was no way of getting the exact error or
even the device that experienced it.  This new API may be used for both.
2012-02-01 10:42:16 +01:00
Alex Jia
a89bb7d75a python: correct a copy-paste error
* python/libvirt-override-virStream.py: fix a copy-paste error in sendAll().

Signed-off-by: Alex Jia <ajia@redhat.com>
2012-02-01 10:26:57 +01:00
Michal Privoznik
7b0a740542 command: Fix ATTRIBUTE_UNUSED on virSetCapabilities
If we are building not on a WIN32 architecture and without HAVE_CAPNG
virSetCapabilities has unused argument and virClearCapabilities
is unused as well.
2012-02-01 10:02:30 +01:00
Michal Privoznik
50e9b38930 qemu: Clenup qemuDomainSetInterfaceParameters
which contained some useless lines, copied code, NULL
dereference.
2012-02-01 08:56:54 +01:00
Michal Privoznik
bb311b3458 qemu: Don't jump to endjob if no job was even started
In qemuDomainShutdownFlags if we try to use guest agent,
which has error or is not configured, we jump go endjob
label even if we haven't started any job yet. This may
lead to the daemon crash:
1) virsh shutdown --mode agent on a domain without agent configured
2) wait until domain quits
3) virsh edit
2012-02-01 08:42:47 +01:00
Taku Izumi
53e23e99a9 qemu: fix my typo at commit 74e034964c
Fix my typo at
  commit 74e034964c

"disk->rawio == -1" indicates that this value is not
specified. So in case of this, domain must not
be tainted.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
2012-01-31 20:21:06 -07:00
Alex Jia
bfdbae0694 simplify block of codes
Using new function 'virTypedParameterArrayClear' to simplify block of codes.

* daemon/remote.c, src/remote/remote_driver.c: simplify codes.

Signed-off-by: Alex Jia <ajia@redhat.com>
2012-02-01 10:57:56 +08:00
Eric Blake
c3c2cc6534 build: fix text regression
Commit 8a09ee410 tickles a bug in libxml2-2.7.6 on RHEL 6.2,
where libxml2 treats the pattern [^\n] as excluding literal
backslash and n, instead of the intended newline, thus failing
to validate any domain name containing 'n'.

* docs/schemas/domaincommon.rng: Use literal newline instead.
2012-01-31 16:53:46 -07:00
Laine Stump
b303465d2f docs: fill out rawio description
The original doc entry for rawio didn't mention the values it could
have, the default, or the fact that setting it to "yes" for one disk
effectively set it to "yes" for all disks in the domain.
2012-01-31 14:57:14 -05:00
Taku Izumi
74e034964c qemu: make qemu processes to retain rawio capability
This patch revises qemuProcessStart() function for qemu
processes to retain CAP_SYS_RAWIO if needed.
And in case of that, add taint flag to domain.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
2012-01-31 13:36:38 -05:00
Taku Izumi
c2e146bfb0 util: extend virExecWithHook()
This patch extends virExecWithHook() to receive
capability information.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
2012-01-31 13:36:33 -05:00
Taku Izumi
53bd0cebd3 util: add functions to keep capabilities
This patch introduces virSetCapabilities() function and implements
virCommandAllowCap() function.

Existing virClearCapabilities() is function to clear all capabilities.
Instead virSetCapabilities() is function to set arbitrary capabilities.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
2012-01-31 13:36:28 -05:00
Taku Izumi
397e6a705b conf: add rawio attribute to disk element of domain XML
This patch adds a new attribute "rawio" to the "disk" element
 of domain XML. Valid values of "rawio" attribute are "yes"
 and "no".
 rawio='yes' indicates the disk is desirous of CAP_SYS_RAWIO.

 If you specify the following XML:

 <disk type='block' device='lun' rawio='yes'>
  ...
 </disk>

 the domain will be granted CAP_SYS_RAWIO.
 (of course, the domain have to be executed with root privilege)

NOTE:
   - "rawio" attribute is only valid when device='lun'
   - At the moment, any other disks you won't use rawio can use rawio.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
2012-01-31 13:36:23 -05:00
Zeeshan Ali (Khattak)
e545dd4ffe Implement virStorageVolResize() for FS backend
Currently only VIR_STORAGE_VOL_RESIZE_DELTA flag is supported.
2012-01-31 11:58:11 -05:00
Eric Blake
055bbf45e4 resize: slightly alter signature
Our existing virDomainBlockResize takes an unsigned long long
argument; if that command is later taught a DELTA and SHRINK flag,
we cannot change its type without breaking API (but at least such
a change would be ABI compatible).  Meanwhile, the only time a
negative size makes sense is if both DELTA and SHRINK are used
together, but if we keep the argument unsigned, applications can
pass the positive delta amount by which they would like to shrink
the system, and have the flags imply the negative value.  So,
since this API has not yet been released, and in the interest of
consistency with existing API, we swap virStorageVolResize to
always pass an unsigned value.

* include/libvirt/libvirt.h.in (virStorageVolResize): Use unsigned
argument.
* src/libvirt.c (virStorageVolResize): Likewise.
* src/driver.h (virDrvStorageVolUpload): Adjust clients.
* src/remote/remote_protocol.x (remote_storage_vol_resize_args):
Likewise.
* src/remote_protocol-structs: Regenerate.
Suggested by Daniel P. Berrange.
2012-01-31 11:58:06 -05:00
Philipp Hahn
098a987b98 XenXs: Update documentation
Fix several references to now renamed functions and parameters when the
functions were moved from src/xen/ to src/xenxs/.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2012-01-30 13:13:23 -07:00
Laine Stump
3801831cdf qemu: add "romfile" support to specify device boot ROM
This patch addresses: https://bugzilla.redhat.com/show_bug.cgi?id=781562

Along with the "rombar" option that controls whether or not a boot rom
is made visible to the guest, qemu also has a "romfile" option that
allows specifying a binary file to present as the ROM BIOS of any
emulated or passthrough PCI device. This patch adds support for
specifying romfile to both passthrough PCI devices, and emulated
network devices that attach to the guest's PCI bus (just about
everything other than ne2k_isa).

One example of the usefulness of this option is described in the
bugzilla report: 82576 sriov network adapters don't provide a ROM BIOS
for the cards virtual functions (VF), but an image of such a ROM is
available, and with this ROM visible to the guest, it can PXE boot.

In libvirt's xml, the new option is configured like this:

   <hostdev>
     ...
     <rom file='/etc/fake/boot.bin'/>
     ...
   </hostdev

(similarly for <interface>).
2012-01-30 12:30:35 -05:00
Laine Stump
3284ac046f qemu: (and conf) support rombar for network devices
When support for the rombar option was added, it was only added for
PCI passthrough devices, configured with <hostdev>. The same option is
available for any network device that is attached to the guest's PCI
bus. This patch allows setting rombar for any PCI network device type.

After adding cases to test this to qemuxml2argv-hostdev-pci-rombar.*,
I decided to rename those files (to qemuxml2argv-pci-rom.*) to more
accurately reflect the additional tests, and also noticed that up to
now we've only been performing a domainschematest for that case, so I
added the "pci-rom" test to both qemuxml2argv and qemuxml2xml (and in
the process found some bugs whose fixes I squashed into previous
commits of this series).
2012-01-30 12:25:32 -05:00
Laine Stump
c01ba1a48f conf: relocate rombar and boot order parse/format
Since these two items are now in the virDomainDeviceInfo struct, it
makes sense to parse/format them in the functions written to
parse/format that structure. Not all types of devices allow them, so
two internal flags are added to indicate when it is appropriate to do
so.

I was lucky - only one test case needed to be re-ordered!
2012-01-30 12:25:25 -05:00
Laine Stump
159f4d0b30 conf: put all guest-related HostdevDef data in one object
To help consolidate the commonality between virDomainHostdevDef and
virDomainNetDef into as few members as possible (and because I
think it makes sense), this patch moves the rombar and bootIndex
members into the "info" member that is common to both (and to all the
other structs that use them).

It's a bit problematic that this gives rombar and bootIndex to many
device types that don't use them, but this is already the case for the
master and mastertype members of virDomainDeviceInfo, and is properly
commented as such in the definition.

Note that this opens the door to supporting rombar for other devices
that are attached to the guest PCI bus - virtio-blk-pci,
virtio-net-pci, various other network adapters - which which have that
capability in qemu, but previously had no support in libvirt.
2012-01-30 12:25:20 -05:00
Laine Stump
aaa6210f81 conf: remove duplicate call to VIR_FREE(info->alias)
There is another identical call 4 lines up in the same function.
2012-01-30 11:38:39 -05:00
Hendrik Schwartke
484a0bab39 qemu: Fix segfault in qemuMonitorTextGetBlockInfo
If some error occurs then the cleanup code calls VIR_FREE(info)
without ensuring that info is initialized.
2012-01-30 13:48:34 +01:00
Cole Robinson
efb0839c1d xen: Don't add <console> to xml for dom0
It just doesn't really make sense and confuses virt-manager
2012-01-30 07:17:36 -05:00
Daniel P. Berrange
e97c3109af Add virt-host-validate.1 to Mingw32 RPM spec file list 2012-01-30 12:03:30 +00:00
KAMEZAWA Hiroyuki
c6ec021b3c remote handler for virDomainGetCPUStats()
Unlike other users of virTypedParameter with RPC, this interface
can return zero-filled entries because the interface assumes
2 dimensional array. We compress these entries out from the
server when generating the over-the-wire contents, then reconstitute
them in the client.

Signed-off-by: Eric Blake <eblake@redhat.com>
2012-01-28 11:09:31 -07:00
Eric Blake
5c6651fea2 docs: reorder public header
The bottom of the public header is reserved for deprecated APIs;
it's nicer to arrange things in logical groups.

* include/libvirt/libvirt.h.in (virConnectSetKeepAlive)
(virDomainGetCPUStats): Float earlier in the file.
2012-01-28 07:37:55 -07:00
Eric Blake
f0b22ebea4 docs: tweak recent suspend API additions
* src/libvirt.c (virDomainPMSuspendForDuration): Clarify usage.
2012-01-28 07:29:10 -07:00
KAMEZAWA Hiroyuki
e1eea7470b Add new public API virDomainGetCPUStats()
add new API virDomainGetCPUStats() for getting cpu accounting information
per real cpus which is used by a domain.  The API is designed to allow
future extensions for additional statistics.

based on ideas by Lai Jiangshan and Eric Blake.

* src/libvirt_public.syms: add API for LIBVIRT_0.9.10
* src/libvirt.c: define virDomainGetCPUStats()
* include/libvirt/libvirt.h.in: add virDomainGetCPUStats() header
* src/driver.h: add driver API
* python/generator.py: add python API (as not implemented)

Signed-off-by: Eric Blake <eblake@redhat.com>
2012-01-28 07:18:27 -07:00
Michal Privoznik
7c741763db virsh: Expose new virDomainPMSuspendForDuration API
under new command "dompmsuspend"
2012-01-28 10:20:46 +01:00
Michal Privoznik
8f8b080263 Introduce virDomainPMSuspendForDuration API
This API allows a domain to be put into one of S# ACPI states.
Currently, S3 and S4 are supported. These states are shared
with virNodeSuspendForDuration.
However, for now we don't support any duration other than zero.
The same apply for flags.
2012-01-28 10:20:46 +01:00
Zeeshan Ali (Khattak)
835817806e resize: implement remote protocol for virStorageVolResize()
Autogeneration saves the day.

Signed-off-by: Eric Blake <eblake@redhat.com>
2012-01-27 19:56:21 -07:00
Zeeshan Ali (Khattak)
6714fd04d2 resize: add virStorageVolResize() API
Add a new function to allow changing of capacity of storage volumes.
Plan out several flags, even if not all of them will be implemented
up front.

Expose the new command via 'virsh vol-resize'.

Signed-off-by: Eric Blake <eblake@redhat.com>
2012-01-27 19:56:18 -07:00
Eric Blake
b2e13f9c44 tests: fix reversed comparisons
Otherwise, a failed test gives misleading output.

* tests/commandtest.c (test13, test14, test16): Pass arguments in
correct order.
2012-01-27 16:35:14 -07:00