Commit Graph

7687 Commits

Author SHA1 Message Date
Laine Stump
07f4136993 conf: support abstracted interface info in domain interface XML
the domain XML <interface> element is updated in the following ways:

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

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

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

The virDomainActualNetDef will only be parsed/formatted if the
parse/format function is called with the
VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET flag set (which is only needed when
saving/loading a running domain's state info to the stateDir).
2011-07-21 14:46:44 -04:00
Laine Stump
524655eea2 conf: virDomainNetDef points to (rather than contains) virtPortProfile
The virtPortProfile in the domain interface struct is now a separately
allocated object *pointed to by* (rather than contained in) the main
virDomainNetDef object. This is done to make it easier to figure out
when a virtualPortProfile has/hasn't been specified in a particular
config.
2011-07-21 14:46:39 -04:00
Laine Stump
a3d95b550b conf: put virtPortProfile struct / functions in a common location
virtPortProfiles are currently only used in the domain XML, but will
soon also be used in the network XML. To prepare for that change, this
patch moves the structure definition into util/network.h and the parse
and format functions into util/network.c (I decided that this was a
better choice than macvtap.h/c for something that needed to always be
available on all platforms).
2011-07-21 14:46:33 -04:00
Laine Stump
6fe5fde292 util: define MAX
If util.h is going to have a MIN, it may as well also have MAX.
2011-07-21 14:45:20 -04:00
Michal Privoznik
7b5fc59733 destroy: Implement internal API for xenapi driver 2011-07-21 20:41:28 +02:00
Michal Privoznik
1edf5cc5b4 destroy: Implement internal API for xen driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
73838d331f destroy: Implement internal API for vmware driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
6ec7195c01 destroy: Implement internal API for vbox driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
64ce43f82c destroy: Implement internal API for uml driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
e4e69b4bb2 destroy: Implement internal API for phyp driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
ab5eb92bbd destroy: Implement internal API for openvz driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
2dd3f025a0 destroy: Implement internal API for lxc driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
ba0219a752 destroy: Implement internal API for libxl driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
3959fe300e destroy: Implement internal API for ESX driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
427eaf13e2 destroy: Implement internal API for qemu driver 2011-07-21 20:41:27 +02:00
Michal Privoznik
ca79a4fb51 destroy: Wire up the remote protocol 2011-07-21 20:41:27 +02:00
Michal Privoznik
080bc4ea02 destroy: Define new public API virDomainDestroyFlags
This introduces new API virDomainDestroyFlags to allow
domain destroying with flags, as the existing API virDomainDestroy
misses flags.

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

Calling this API with no flags set (@flags == 0) is equivalent calling
virDomainDestroy.
2011-07-21 20:38:35 +02:00
Eric Blake
b6fe647b60 save: wire up remote protocol
* src/remote/remote_driver.c (remote_driver): Add new callbacks.
* src/remote/remote_protocol.x (remote_procedure): New RPCs.
(remote_domain_save_flags_args, remote_domain_restore_flags_args):
New structs.
* src/remote_protocol-structs: Update.
2011-07-21 10:34:51 -06:00
Eric Blake
ad0b912384 save: new public API to bypass file system cache on save/restore
In order to choose whether to use O_DIRECT when saving a domain image
to a file, we need a new flag.  But virDomainSave was implemented
before our policy of all new APIs having a flag argument.  Likewise
for virDomainRestore when restoring from a file.

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

* include/libvirt/libvirt.h.in (virDomainCreateFlags)
(virDomainCoreDumpFlags): Add a flag.
(virDomainSaveFlags, virDomainRestoreFlags): New prototypes.
* src/libvirt.c (virDomainSaveFlags, virDomainRestoreFlags): New API.
* src/libvirt_public.syms: Export them.
* src/driver.h (virDrvDomainSaveFlags, virDrvDomainRestoreFlags):
New driver callbacks.
2011-07-21 10:34:51 -06:00
Eric Blake
360e5ea144 qemu: fix error message with migrate2 xml
Otherwise, an ABI mismatch gives error messages attributing the target
xml string as current, and the current domain state as the new xml.

* src/qemu/qemu_migration.c (qemuMigrationBegin): Use correct
argument order.
2011-07-21 10:34:51 -06:00
Eric Blake
8e22e08935 build: rename files.h to virfile.h
In preparation for a future patch adding new virFile APIs.

* src/util/files.h, src/util/files.c: Move...
* src/util/virfile.h, src/util/virfile.c: ...here, and rename
functions to virFile prefix.  Macro names are intentionally
left alone.
* *.c: All '#include "files.h"' uses changed.
* src/Makefile.am (UTIL_SOURCES): Reflect rename.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_close): Likewise.
* src/libvirt_private.syms: Likewise.
* docs/hacking.html.in: Likewise.
* HACKING: Regenerate.
2011-07-21 10:34:51 -06:00
Eric Blake
5d804ffae4 command: avoid leaking fds across fork
Since libvirt is multi-threaded, we should use FD_CLOEXEC as much
as possible in the parent, and only relax fds to inherited after
forking, to avoid leaking an fd created in one thread to a fork
run in another thread.  This gets us closer to that ideal, by
making virCommand automatically clear FD_CLOEXEC on fds intended
for the child, as well as avoiding a window of time with non-cloexec
pipes created for capturing output.

* src/util/command.c (virExecWithHook): Use CLOEXEC in parent.  In
child, guarantee that all fds to pass to child are inheritable.
(getDevNull): Use CLOEXEC.
(prepareStdFd): New helper function.
(virCommandRun, virCommandRequireHandshake): Use pipe2.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Simplify caller.
2011-07-21 10:34:51 -06:00
Eric Blake
4289114518 command: move all docs into .c file
We already have a precedent of function documentation in C files,
where it is closer to the implementation (witness libvirt.h vs.
libvirt.c); maintaining docs in both files risks docs going stale.

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

* src/util/command.h: Remove duplicate docs, and move unique
documentation...
* src/util/command.c: ...here.
Suggested by Matthias Bolte.
2011-07-21 10:34:51 -06:00
Matthias Bolte
fbd5465a5b rpc: Make the dispatch generator handle 'void name(void)' style procedures
The only 'void name(void)' style procedure in the protocol is 'close' that
is handled special, but also programming errors like a missing _args or
_ret suffix on the structs in the .x files can create such a situation by
accident. Making the generator aware of this avoids bogus errors from the
generator such as:

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

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

Reported by Michal Privoznik
2011-07-21 17:00:59 +02:00
Eric Blake
979b784be2 error: preserve errno when saving last error
It is common to see the sequence:

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

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

* src/util/virterror.c (virSaveLastError, virSetError): Preserve
errno.
2011-07-21 07:24:33 -06:00
Matthias Bolte
1468359f16 python: Fix makefile rule for code generation
Commit 8665f85523 changed generated.stamp to $(GENERATE).stamp,
but missed one instance in the CLEANFILES list. This can break the
build in case the generated code is deleted but the .stamp file stays
around and therefore the code isn't regenerated.
2011-07-21 14:36:34 +02:00
Daniel P. Berrange
5e7d638ca0 Fix uninitialized variable in QEMU CPU bandwidth code
* src/qemu/qemu_driver.c: Fix uninitialized variable
2011-07-21 13:28:08 +01:00
Wen Congyang
d6fa4967bc fix make syntax-check error 2011-07-21 17:42:44 +08:00
Wen Congyang
fbdea7cb92 doc: Add documentation for new cputune elements period and quota
We have added element period and quota. Document them in formatdomain.html.in.
2011-07-21 17:11:12 +08:00
Wen Congyang
67a173c54f qemu: Implement cfs_period and cfs_quota's modification
This patch implements cfs_period and cfs_quota's modification.
We can use the command 'virsh schedinfo' to query or modify cfs_period and
cfs_quota.
If you query period or quota from config file, the value 0 means it does not set
in the config file.
If you set period or quota to config file, the value 0 means that delete current
setting from config file.
If you modify period or quota while vm is running, the value 0 means that use
current value.
2011-07-21 17:11:12 +08:00
Wen Congyang
c4441fee10 qemu: Implement period and quota tunable XML configuration and parsing
This patch implements period and quota tunable XML configuration and parsing.
A quota or period of zero will be simply ignored.
2011-07-21 17:11:12 +08:00
Wen Congyang
f27f62ca69 Update XML Schema for new entries
Define the element cputune's child elements 'period' and 'quota':
<cputune>
  <period>100000</period>
  <quota>50000</quota>
</cputune>
2011-07-21 17:11:12 +08:00
Wen Congyang
fd7c172340 cgroup: Implement cpu.cfs_period_us and cpu.cfs_quota_us tuning API
This patch provides 4 APIs to get and set cpu.cfs_period_us and cpu.cfs_quota_us.
2011-07-21 17:11:12 +08:00
Wen Congyang
8e64f87306 Introduce the function virCgroupForVcpu
Introduce the function virCgroupForVcpu() to create sub directory for each vcpu.
2011-07-21 17:11:12 +08:00
Lai Jiangshan
e40725779c qemu: send-key: Implement the driver methods
qemu driver just accept xt_kbd codeset's keycode, so the lib virtkey
is used for translating keycodes from other codesets
2011-07-21 15:58:31 +08:00
Lai Jiangshan
7818b7ef85 send-key: Expose the new API in virsh
Also support string names for the linux keycode(auto detect)
* tools/virsh.c: add new command "send-key"
* tools/virsh.pod: documents the new command
2011-07-21 15:58:31 +08:00
Lai Jiangshan
0bbf87e91e util: add virtkeycode module
Add virtkey lib for usage-improvment and keycode translating.
Add 4 internal API for the aim

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

* include/libvirt/libvirt.h.in: extend virKeycodeSet enum
* src/Makefile.am: add new virtkeycode module and rule to generate
  virkeymaps.h
* src/util/virkeycode.c src/util/virkeycode.h: new module
* src/util/virkeycode-mapgen.py: python generator for virkeymaps.h
  out of keymaps.csv
* src/libvirt_private.syms: extend private symbols for new module
* .gitignore: add generated virkeymaps.h
2011-07-21 15:57:47 +08:00
Lai Jiangshan
1151f0eee8 util: Add keymaps.csv
Should keep it as the same as:
http://git.gnome.org/browse/gtk-vnc/commit/src/keymaps.csv

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

* src/Makefile.am: added to EXTRA_DIST
* src/util/keymaps.csv: new file
2011-07-21 15:02:52 +08:00
Eric Blake
a71434054c maint: fix typos on guaranteed
* src/conf/domain_event.c (virDomainEventDispatch): Fix typo.
* src/internal.h (ATTRIBUTE_FMT_PRINTF): Likewise.
* src/libvirt.c (virStreamEventUpdateCallback): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.
* src/util/virterror.c (virConnCopyLastError, virCopyLastError):
Likewise.
* src/xen/xend_internal.h (xend_wait_for_devices): Likewise.
2011-07-20 16:53:31 -06:00
Cole Robinson
e0a21dfef4 rpc: Pass through DISPLAY so ssh can launch askpass
Though we prefer users to have SSH keys setup, virt-manager users still
depend on remote SSH connections to launch a password dialog. This fixes
launch ssh-askpass

Fix suggested by danpb
2011-07-20 14:14:23 -04:00
Michal Privoznik
670c9f770b sysinfo: Don't try to run dmidecode on archs missing it
DMI table is Intel & Intel-compatible specific. Therefore other
architectures miss dmidecode command. So we always fail in searching
for that command on non-Intel architectures.
2011-07-20 17:14:24 +02:00
Guannan Ren
b14800af14 Don't try to close a NULL virNetClientPtr
* src/rpc/virnetclient.c: Skip close attempt if virNetClientPtr
  is NULL
2011-07-20 15:24:31 +01:00
Daniel P. Berrange
14800d49cb Honour key usage/purpose criticality flag
If a key purpose or usage field is marked as non-critical in the
certificate, then a data mismatch is not (ordinarily) a cause for
rejecting the connection

* src/rpc/virnettlscontext.c: Honour key usage/purpose criticality
2011-07-20 15:23:33 +01:00
Daniel P. Berrange
f53cc36fe8 Fix checking of key usage/purpose data
If key usage or purpose data is not present in the cert, the
RFC recommends that access be allowed. Also fix checking of
key usage to include requirements for client/server certs,
and fix key purpose checking to treat data as a list of bits
2011-07-20 15:19:35 +01:00
Daniel P. Berrange
3ea043254c Fix mixed up error messages when reporting TLS certificate problems
* src/rpc/virnettlscontext.c: Fix mixed up error messages
2011-07-20 15:19:35 +01:00
Michal Privoznik
4f550a129e udev: Don't try to dump DMI on non-intel archs
DMI is Intel & Intel-compatible specific. Don't try to dump information
on non-compatible architectures, which results only in error message in
logs.
2011-07-20 10:03:09 +02:00
Eric Blake
574953309f build: fix broken build
* src/libxl/libxl_driver.c (libxlDomainUndefineFlags): Use correct
enum value.
* src/remote_protocol-structs (remote_procedure): Likewise.
2011-07-19 21:40:05 -06:00
Osier Yang
83e849c197 undefine: Extend virsh undefine to support the new flag
If the domain has managed save image, and --managed-save is
not specified, then it fails with an error telling the user
that a managed save image still exists.

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

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

NOTE: Have not removing the codes checking if the domain is running
in function "cmdUndefine", it will go along with qemu driver's fix
(allow to undefine a running domain).
2011-07-20 11:12:46 +08:00
Osier Yang
39babffb73 undefine: Implement undefineFlags for all other drivers 2011-07-20 11:08:21 +08:00
Osier Yang
67d33735ec undefine: Implement internal API for libxl driver
* src/libxl/libxl_driver.c: New callback for libxl_driver,
new function libxlDomainUndefineFlags, and changes libxlDomainUndefine
as a wrapper of libxlDomainUndefineFlags.
2011-07-20 11:05:20 +08:00