Commit Graph

11054 Commits

Author SHA1 Message Date
Osier Yang
331934b296 qemu: Add caps to indentify if setting wwn is supported by qemu
This assumes ide-drive.wwn, ide-hd.wwn, ide-cd.wwn were supported
at the same time, similar for scsi-disk.wwn, scsi-hd.wwn, and
scsi-cd.wwn. So only two new caps (QEMU_CAPS_IDE_DRIVE_WWN,
and QEMU_CAPS_SCSI_DISK_WWN) are introduced.
2012-09-18 14:42:39 +08:00
Osier Yang
facc1c0057 conf: Parse and format disk <wwn>
Validates the wwn while parsing, error out if it's malformed.

* src/util/util.h: Declare virValidateWWN
* src/util/util.c: Implement virValidateWWN
* src/libvirt_private.syms: Export virValidateWWN.
* src/conf/domain_conf.h: New member 'wwn' for disk def.
* src/conf/domain_conf.c: Parse and format disk <wwn>
2012-09-18 14:42:33 +08:00
Osier Yang
dbb7df1f81 schema: Add schema for disk <wwn>
* docs/formatdomain.html.in: Add document.
* docs/schemas/nodedev.rng: Move definition of "wwn" to ...
* docs/schemas/basictypes.rng: ...Here
* docs/schemas/domaincommon.rng: Add schema for disk <wwn>
2012-09-18 14:42:29 +08:00
Eric Blake
85edb0c8bb blockjob: add blockcommit support to rpc
Relatively straightforward.  Our decision to make block job
speed a long keeps haunting us on new API.

* src/remote/remote_protocol.x (remote_domain_block_commit_args):
New struct.
* src/remote/remote_driver.c (remote_driver): Enable it.
* src/remote_protocol-structs: Regenerate.
* src/rpc/gendispatch.pl (long_legacy): Exempt another bandwidth.
2012-09-17 21:46:41 -06:00
Eric Blake
ed23b10660 blockjob: add virsh blockcommit
The new command 'virsh blockcommit $dom $disk' requests the start
of an asynchronous commit operation across the entire chain of
$disk.  Further arguments can fine-tune which portion of the
chain is committed.  Existing 'virsh blockjob' commands can then
track the status, change the bandwidth, or abort the commit job.

With a bit more on the command line, 'virsh blockcommit $dom $disk
--wait --verbose' can be used for blocking behavior, with visual
feedback on the overall status, and can be canceled with Ctrl-C.

The overall design, including the wait loop logic, borrows heavily
from the existing blockpull command.

* tools/virsh-domain.c (cmdBlockCommit): New function.
* tools/virsh.pod (blockcommit): Document it.
2012-09-17 21:44:49 -06:00
Eric Blake
ef1e024df8 blockjob: add virDomainBlockCommit
A block commit moves data in the opposite direction of block pull.
Block pull reduces the chain length by dropping backing files after
data has been pulled into the top overlay, and is always safe; block
commit reduces the chain length by dropping overlays after data has
been committed into the backing file, and any files that depended
on base but not on top are invalidated at any point where they have
unallocated data that is now pointing to changed contents in base.
Both directions are useful, however: a qcow2 layer that is more than
50% allocated will typically be faster with a pull operation, while
a qcow2 layer with less than 50% allocation will be faster as a
commit operation.  Committing across multiple layers can be more
efficient than repeatedly committing one layer at a time, but
requires extra support from the hypervisor.

This API matches Jeff Cody's proposed qemu command 'block-commit':
https://lists.gnu.org/archive/html/qemu-devel/2012-09/msg02226.html

Jeff's command is still in the works for qemu 1.3, and may gain
further enhancements, such as the ability to control on-error
handling (it will be comparable to the error handling Paolo is
adding to 'drive-mirror', so a similar solution will be needed
when I finally propose virDomainBlockCopy with more functionality
than the basics supported by virDomainBlockRebase).  However, even
without qemu support, this API will be useful for _offline_ block
commits, by wrapping qemu-img calls and turning them into a block
job, so this API is worth committing now.

For some examples of how this will be implemented, all starting
with the chain: base <- snap1 <- snap2 <- active

+ These are equivalent:
 virDomainBlockCommit(dom, disk, NULL, NULL, 0, 0)
 virDomainBlockCommit(dom, disk, NULL, "active", 0, 0)
 virDomainBlockCommit(dom, disk, "base", NULL, 0, 0)
 virDomainBlockCommit(dom, disk, "base", "active", 0, 0)
but cannot be implemented for online qemu with round 1 of
Jeff's patches; and for offline images, it would require
three back-to-back qemu-img invocations unless qemu-img
is patched to allow more efficient multi-layer commits;
the end result would be 'base' as the active disk with
contents from all three other files, where 'snap1' and
'snap2' are invalid right away, and 'active' is invalid
once any further changes to 'base' are made.

+ These are equivalent:
 virDomainBlockCommit(dom, disk, "snap2", NULL, 0, 0)
 virDomainBlockCommit(dom, disk, NULL, NULL, 0, _SHALLOW)
they cannot be implemented for online qemu, but for offline,
it is a matter of 'qemu-img commit active', so that 'snap2'
is now the active disk with contents formerly in 'active'.

+ Similarly:
 virDomainBlockCommit(dom, disk, "snap2", NULL, 0, _DELETE)
for an offline domain will merge 'active' into 'snap2', then
delete 'active' to avoid leaving a potentially invalid file
around.

+ This version:
 virDomainBlockCommit(dom, disk, NULL, "snap2", 0, _SHALLOW)
can be implemented online with 'block-commit' passing a base of
snap1 and a top of snap2; and can be implemented offline by
'qemu-img commit snap2' followed by 'qemu-img rebase -u
-b snap1 active'

* include/libvirt/libvirt.h.in (virDomainBlockCommit): New API.
* src/libvirt.c (virDomainBlockCommit): Implement it.
* src/libvirt_public.syms (LIBVIRT_0.10.2): Export it.
* src/driver.h (virDrvDomainBlockCommit): New driver callback.
* docs/apibuild.py (CParser.parseSignature): Add exception.
2012-09-17 21:28:08 -06:00
Eric Blake
d239085e95 qemu: drop unused arguments for dump-guest-memory
Upstream qemu has raised a concern about whether dumping guest
memory by reading guest paging tables is a security hole:
https://lists.gnu.org/archive/html/qemu-devel/2012-09/msg02607.html

While auditing libvirt to see if we would be impacted, I noticed
that we had some dead code.  It is simpler to nuke the dead code
and limit our monitor code to just the subset we make use of.

* src/qemu/qemu_monitor.h (QEMU_MONITOR_DUMP): Drop poorly named
and mostly-unused enum.
* src/qemu/qemu_monitor.c (qemuMonitorDumpToFd): Drop arguments.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONDump): Likewise.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONDump): Likewise.
* src/qemu/qemu_driver.c (qemuDumpToFd): Update caller.
2012-09-17 20:44:29 -06:00
Osier Yang
22acfdc7fc build: Fix build failure on non-linux platform 2012-09-18 09:42:23 +08:00
Laine Stump
16d9a3df94 conf: avoid freeing network object with undestroyed mutex
virNetworkAssignDef was allocating a new network object, initing and
grabbing its lock, then potentially freeing it without unlocking or
destroying the lock. In practice 1) this will probably never happen,
and 2) even if it did, the lock implementation used on most (all?)
platforms doesn't actually hold any resources for an initialized or
held lock, but it still bothered me, so I moved the realloc that could
lead to this bad situation earlier in the function, and now the mutex
isn't inited or locked until we are assured of complete success.
2012-09-17 20:24:06 -04:00
Laine Stump
764bd8537a conf: separate functions to parse DHCPHostDef and DHCPRangeDef
These two objects were previously always parsed as a part of an IpDef,
but we will now need to be able to parse them on their own for
virNetworkUpdate(). Split the parsing functions out, with no
functional changes.
2012-09-17 20:24:06 -04:00
Hu Tao
afe869819f remove virDomainCpuSetFormat and virDomainCpuSetParse
virBitmap is recommanded to store cpuset info, and
virBitmapFormat/virBitmapParse can do the format/parse
jobs.
2012-09-17 14:59:37 -04:00
Laine Stump
58d372d441 xen: eliminate remaining uses of virDomainCpuSetParse
The final patch in Hu Tao's series to enhance virBitmap actually
removes virDomainCpuSetParse and virDomainCpuSetFormat as "no longer
used", and the rest of the series hadn't taken care of two uses of
virDomainCpuSetParse in the xen code.

This patch replaces those with appropriate virBitmap functions. It
should be pushed prior to the patch removing virDomainCpuSetParse.
2012-09-17 14:59:37 -04:00
Hu Tao
fe2a0b027b use virBitmap to store nodeinfo. 2012-09-17 14:59:37 -04:00
Hu Tao
f4b2dcf550 use virBitmap to store cells' cpumask info. 2012-09-17 14:59:37 -04:00
Hu Tao
ee7d23ba4b use virBitmap to store cpumask info. 2012-09-17 14:59:37 -04:00
Hu Tao
75b198b3e7 use virBitmap to store numa nodemask info. 2012-09-17 14:59:37 -04:00
Hu Tao
f1a43a8e41 use virBitmap to store cpu affinity info 2012-09-17 14:59:37 -04:00
Hu Tao
f970d8481e use virBitmap to store cpupin info 2012-09-17 14:59:36 -04:00
Hu Tao
0fc89098a6 New functions for virBitmap
In many places we store bitmap info in a chunk of data
(pointed to by a char *), and have redundant codes to
set/unset bits. This patch extends virBitmap, and convert
those codes to use virBitmap in subsequent patches.
2012-09-17 14:59:36 -04:00
Hu Tao
0831a5bade bitmap: new member variable and function renaming
Add a new member variable map_len to store map len of bitmap.
and rename size to max_bit accordingly.

rename virBitmapAlloc to virBitmapNew.
2012-09-17 14:59:36 -04:00
Peter Krempa
60b0284f24 virsh: Clarify behavior of domain list filtering.
Some combinations of filtering flags produce no result. This patch tries
to clarify this.
2012-09-17 16:35:24 +02:00
Osier Yang
4ed43d62f1 Build: Fix typos which cause build failure
Pushed under build-breaker rules.
2012-09-17 14:39:43 +08:00
Osier Yang
4c4c80df3f node_memory: Expose the APIs to Python bindings
* python/libvirt-override-api.xml: (Add document to describe
  the APIs).
* python/libvirt-override.c: (Implement the API wrappers manually)
2012-09-17 13:55:46 +08:00
Osier Yang
0e96fa5489 node_memory: Expose the APIs to virsh
New command node-memory-tune to get/set the node memory parameters,
only two parameters are allowed to set (pages_to_scan, and sleep_millisecs,
see documents in this patch for more details).

Example of node-memory-tune's output:

Shared memory:
	pages_to_scan   100
	sleep_millisecs 20
	pages_shared    0
	pages_sharing   0
	pages_unshared  0
	pages_volatile  0
	full_scans      0
2012-09-17 13:55:35 +08:00
Osier Yang
8268a24548 node_memory: Support get/set memory parameters for drivers
Including QEMU, LXC, UML, XEN drivers.
2012-09-17 13:55:22 +08:00
Osier Yang
aaa8ab3e01 node_memory: Implement the internal APIs
Only implemented for linux platform.

* src/nodeinfo.h: (Declare node{Get,Set}MemoryParameters)
* src/nodeinfo.c: (Implement node{Get,Set}MemoryParameters)
* src/libvirt_private.syms: (Export those two new internal APIs to
  private symbols)
2012-09-17 13:55:12 +08:00
Osier Yang
00792722fd node_memory: Wire up the RPC protocol
* src/rpc/gendispatch.pl: (virNodeSetMemoryParameters is the
  the special one which needs a connection object as the first
  argument, improve the generator to support it).
* daemon/remote.c: (Implement the server side handler for
  virDomainGetMemoryParameters)
* src/remote/remote_driver.c: (Implement the client side handler
  for virDomainGetMemoryParameters)
* src/remote/remote_protocol.x: (New RPC procedures for the two
  new APIs and structs to represent the args and ret for it)
* src/remote_protocol-structs: Likewise
2012-09-17 13:54:57 +08:00
Osier Yang
12ad7435de node_memory: Define the APIs to get/set memory parameters
* include/libvirt/libvirt.h.in: (Add macros for the param fields,
  declare the APIs).
* src/driver.h: (New methods for the driver struct)
* src/libvirt.c: (Implement the public APIs)
* src/libvirt_public.syms: (Export the public symbols)
2012-09-17 13:49:44 +08:00
Osier Yang
d15d092cda list: Use virConnectListAllSecrets in virsh
This introduces four new options for secret-list, to filter the
returned secrets by whether it's ephemeral or not, and/or by
whether it's private or not.

* tools/virsh-secret.c: (New helper vshSecretSorter,
  vshSecretListFree, and vshCollectSecretList; Use the new
  API for secret-list; error out if flags are specified,
  because there is no way to filter the results when using
  old APIs (no APIs to get the properties (ephemeral, private)
  of a secret yet).

* tools/virsh.pod: Document the 4 new options.
2012-09-17 13:23:19 +08:00
Osier Yang
473ee27e6a list: Expose virConnectListAllSecrets to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py: Implementation for listAllSecrets.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-17 13:18:51 +08:00
Osier Yang
288f9b13ee list: Implement listAllSecrets
Simply returns the object list. Supports to filter the secrets
by its storage location, and whether it's private or not.

src/secret/secret_driver.c: Implement listAllSecrets
2012-09-17 13:18:12 +08:00
Osier Yang
867374079d list: Implement RPC calls for virConnectListAllSecrets
The RPC generator doesn't support returning list of object yet, this patch
does the work manually.

  * daemon/remote.c:
    Implement the server side handler remoteDispatchConnectListAllSecrets.

  * src/remote/remote_driver.c:
    Add remote driver handler remoteConnectListAllSecrets.

  * src/remote/remote_protocol.x:
    New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_SECRETS and
    structs to represent the args and ret for it.

  * src/remote_protocol-structs: Likewise.
2012-09-17 13:17:14 +08:00
Osier Yang
7a236982fe list: Define new API virConnectListAllSecrets
This is to list the secret objects. Supports to filter the secrets
by its storage location, and whether it's private or not.

include/libvirt/libvirt.h.in: Declare enum virConnectListAllSecretFlags
                              and virConnectListAllSecrets.
python/generator.py: Skip auto-generating
src/driver.h: (virDrvConnectListAllSecrets)
src/libvirt.c: Implement the public API
src/libvirt_public.syms: Export the symbol to public
2012-09-17 13:08:39 +08:00
Osier Yang
9b096843cb list: Use virConnectListAllNWFilters in virsh
tools/virsh-nwfilter.c:
  * vshNWFilterSorter to sort network filters by name

  * vshNWFilterListFree to free the network filter objects list.

  * vshNWFilterListCollect to collect the network filter objects, trying
    to use new API first, fall back to older APIs if it's not supported.
2012-09-17 12:38:44 +08:00
Osier Yang
f4c1efaa9a list: Expose virConnectListAllNWFilters to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py:
  * Implementation for listAllNWFilters.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-17 12:37:03 +08:00
Osier Yang
1483d79ce9 list: Implement listAllNWFilters
Simply returns the object list. No filtering.

src/nwfilter/nwfilter_driver.c: Implement listAllNWFilters
2012-09-17 12:36:51 +08:00
Osier Yang
3f47ff8bb5 list: Implement RPC calls for virConnectListAllNWFilters
The RPC generator doesn't support returning list of object yet, this patch
do the work manually.

  * daemon/remote.c:
    Implemente the server side handler remoteDispatchConnectListAllNWFilters.

  * src/remote/remote_driver.c:
    Add remote driver handler remoteConnectListAllNWFilters.

  * src/remote/remote_protocol.x:
    New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS and
    structs to represent the args and ret for it.

  * src/remote_protocol-structs: Likewise.
2012-09-17 12:36:29 +08:00
Osier Yang
6498f76e31 list: Define new API virConnectListAllNWFilters
This is to list the network filter objects. No flags are supported

include/libvirt/libvirt.h.in: Declare enum virConnectListAllNWFilterFlags
                              and virConnectListAllNWFilters.
python/generator.py: Skip auto-generating
src/driver.h: (virDrvConnectListAllNWFilters)
src/libvirt.c: Implement the public API
src/libvirt_public.syms: Export the symbol to public
2012-09-17 12:35:15 +08:00
Osier Yang
aa20e97578 list: Use virConnectListAllNodeDevices in virsh
tools/virsh-nodedev.c:
  * vshNodeDeviceSorter to sort node devices by name

  * vshNodeDeviceListFree to free the node device objects list.

  * vshNodeDeviceListCollect to collect the node device objects, trying
    to use new API first, fall back to older APIs if it's not supported.

  * Change option --cap to accept multiple capability types.

tools/virsh.pod
  * Update document for --cap
2012-09-17 11:32:53 +08:00
Osier Yang
f5fb059a78 virsh: Don't motify the const string
This improve helper vshStringToArray to accept const string as
argument instead. To not convert the const string when using
vshStringToArray, and thus avoid motifying it.
2012-09-17 11:29:31 +08:00
Osier Yang
a3676b6cb6 list: Expose virConnectListAllNodeDevices to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py:
  * Implementation for listAllNodeDevices.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-17 10:41:03 +08:00
Osier Yang
c68cd62adb list: Implement listAllNodeDevices
This simply implements listAllNodeDevices using helper virNodeDeviceList

src/node_device/node_device_driver.h:
  * Declare nodeListAllNodeDevices.

src/node_device/node_device_driver.c:
  * Implement nodeListAllNodeDevices.

src/node_device/node_device_hal.c:
  * Hook listAllNodeDevices to nodeListAllNodeDevices.

src/node_device/node_device_udev.c
  * Hook listAllNodeDevices to nodeListAllNodeDevices.
2012-09-17 10:40:31 +08:00
Osier Yang
324bf8bfdc list: Add helpers for listing node devices
src/conf/node_device_conf.h:
  * New macro VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP
  * Declare virNodeDeviceList

src/conf/node_device_conf.c:
  * New helpers virNodeDeviceCapMatch, virNodeDeviceMatch.
    virNodeDeviceCapMatch looks up the list of all the caps the device
    support, to see if the device support the cap type.
  * Implement virNodeDeviceList

src/libvirt_private.syms:
  * Export virNodeDeviceList
  * Export virNodeDevCapTypeFromString
2012-09-17 10:38:18 +08:00
Osier Yang
4230b6c102 list: Implement RPC calls for virConnectListAllNodeDevices
The RPC generator doesn't support returning list of object yet, this patch
does the work manually.

  * daemon/remote.c:
    Implemente the server side handler remoteDispatchConnectListAllNodeDevices.

  * src/remote/remote_driver.c:
    Add remote driver handler remoteConnectListAllNodeDevices.

  * src/remote/remote_protocol.x:
    New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES and
2012-09-17 10:36:14 +08:00
Osier Yang
c6a3be5dff list: Define new API virConnectListAllNodeDevices
This is to list the node device objects, supports to filter the results
by capability types.

include/libvirt/libvirt.h.in: Declare enum virConnectListAllNodeDeviceFlags
                              and virConnectListAllNodeDevices.
python/generator.py: Skip auto-generating
src/driver.h: (virDrvConnectListAllNodeDevices)
src/libvirt.c: Implement the public API
src/libvirt_public.syms: Export the symbol to public
2012-09-17 10:30:04 +08:00
Dwight Engen
14dd70cca2 build: fix missing include
virNWFilterSnoopAdjustPoll() uses a struct pollfd but poll.h is never included
nwfilter/nwfilter_dhcpsnoop.c:1297: error: 'struct pollfd' declared inside parameter list
2012-09-14 16:55:58 -06:00
Daniel P. Berrange
637a1124ae Add missing 'goto error' in QEMU command line building
If reporting case of a binary not supporting KVM or kQEMU, libvirt
forgot to jump to the error branch for cleanup
2012-09-14 17:15:43 +01:00
Daniel P. Berrange
731c911ceb Fix initialization of virCommandPtr when creating QEMU argv
If the qemuBuildCommandLine method raised an error before the
virCommandPtr instance was created, the local var would not
be initialized, resulting in a possible SEGV in the error
cleanup branch. Also add some debugging of the method params
2012-09-14 17:15:37 +01:00
Daniel P. Berrange
a55a610b30 Fix 3 broken test cases which were mistakenly raising errors
Several test cases were mistakenly raising errors due to the
QEMU_CAPS_KVM flag being missed.
2012-09-14 17:15:31 +01:00
Ján Tomko
b4418464e1 qemu: fix uninitialized variable in qemuParseCommandLine
Newly added if branch for kvm_pv_eoi did not set the ret variable.
2012-09-14 21:15:16 +08:00