Commit Graph

7972 Commits

Author SHA1 Message Date
Daniel P. Berrange
2d533a465a Fix command test wrt gnutls initialize & fix debugging
The VIR_TEST_DEBUG and VIR_TEST_VERBOSE env vars did not work
because we replaced 'environ' with 'newenv'. Simply calling
virTestGetDebug/Verbose() before replacing the 'environ' ensures
we have processed the env variables.

The gnutls initialization code opens /dev/urandom and keeps that
FD around for later use. We have code which kills off FDs 3-5
to avoid interfereing with our test case. Move the virInitialize
call before this point, so it kills off the gnutls /dev/urandom
FD which is irrelevant for testing purposes

* tests/commandtest.c: Fix test debugging & make it robust against
  opened FDs
2011-08-25 12:05:54 +01:00
Michal Privoznik
eaddec976e daemon: Move TLS initialization to virInitialize
My previous patch 74c7567133
introduced a regression by removing TLS initialization from client.
2011-08-25 10:22:03 +02:00
Laine Stump
b1643dc15c util: only fchown newly created files in virFileOpenAs
virFileOpenAs takes desired uid:gid as arguments, and not only uses
them for a fork/setuid/setgid when retrying failed open operations,
but additionally always forces the opened file to be owned by the
given uid:gid.

One example of the problems this causes is that, when restoring a
domain from a file that is owned by the qemu user, opening the file
chowns it to root. if dynamic_ownership=1 this is coincidentally
expected, but if dynamic_ownership=0, no existing file should ever
have its ownership changed.

This patch adds an extra check before calling fchown() - it only does
it if O_CREAT was passed to virFileOpenAs() in the openflags.
2011-08-24 15:32:00 -04:00
Shradha Shah
7ae740fcb1 qemu: fix off-by-one in pci slot reservation
Signed-off-by: Steve Hodgson <shodgson@solarflare.com>
2011-08-24 10:49:02 -06:00
Steve Hodgson
3468bdafaf maint: attribute second author of previous patch
Signed-off-by: Eric Blake <eblake@redhat.com>
2011-08-24 10:48:20 -06:00
Shradha Shah
c0f025b8ba pci: fix pciDeviceListSteal on multiple devices
pciDeviceListSteal(pcidevs, dev) removes dev from pcidevs reducing
the length of pcidevs, so moving onto what was the next dev is wrong.

Instead callers should pop entry 0 repeatedly until pcidevs is empty.

Signed-off-by: Steve Hodgson <shodgson@solarflare.com>
Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2011-08-24 10:31:29 -06:00
Eric Blake
ba0c219902 libvirt: log all flags parameters
I was testing a virsh patch, and wanted to see if I had passed the
flags I thought.  But with LIBVIRT_DEBUG in the environment, I just
saw:

14:24:52.359: 15022: debug : virDomainSnapshotNum:15586 : dom=0xc9c180, (VM: name=rhel_6-64, uuid=48f8e8e7-e14f-0e14-02f0-ce71997bdcab),

including a trailing space.  This fixes the issues.

* src/libvirt.c: Log flag parameters, even if currently unused.
(VIR_DOMAIN_DEBUG_0): Drop trailing comma in log.
(VIR_DOMAIN_DEBUG_1): Split guts into...
(VIR_DOMAIN_DEBUG_2): ...new macro.
2011-08-24 08:34:49 -06:00
Eric Blake
131540277e virsh: add list --managed-save
Knowing whether 'virsh start' will resume a saved image or do
a fresh boot is useful enough to expose via 'virsh list'.

Also, translate the state column.

* tools/virsh.c (cmdList): add --managed-save flag
* tools/virsh.pod (list): Document it.
Based on a suggestion by Miklos Vajna.
2011-08-24 08:34:49 -06:00
Matthias Bolte
6aa57af3e4 esx: Use $(PYTHON) instead of the shebang to run the generator 2011-08-24 10:45:03 +02:00
Osier Yang
10b100240f qemu: Report error if qemu monitor command not found for BlockJob
* src/qemu/qemu_monitor_json.c: Handle error "CommandNotFound" and
  report the error.

* src/qemu/qemu_monitor_text.c: If a sub info command is not found,
  it prints the output of "help info", for other commands,
  "unknown command" is printed.

Without this patch, libvirt always report:

  An error occurred, but the cause is unknown

This patch was adapted from a patch by Osier Yang <jyang@redhat.com> to
break out detection of unrecognized text monitor commands into a separate
function.

Signed-off-by: Adam Litke <agl@us.ibm.com>
2011-08-24 14:39:42 +08:00
Matthias Bolte
678cd0f04b esx: Refactor a repeated string in the generator 2011-08-23 23:15:21 +02:00
Eric Blake
3a52b864dd maint: fix comment typos
* src/qemu/qemu_driver.c (qemuDomainSaveInternal): Fix typo.
* src/conf/domain_event.c (virDomainEventDispatchMatchCallback):
Likewise.
* daemon/libvirtd.c (daemonRunStateInit): Likewise.
* src/lxc/lxc_container.c (lxcContainerChildMountSort): Likewise.
* src/util/virterror.c (virCopyError, virRaiseErrorFull): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprSound): Likewise.
2011-08-23 11:31:28 -06:00
Osier Yang
fb6d616523 virsh: Substitute goto label out with cleanup
Introduced by 241cbc13a, pushed under urgent rule.
2011-08-23 22:22:51 +08:00
Osier Yang
241cbc13ac virsh: Do not try to free domain if it is NULL
Without these patch, there will be error like below if domain
is NULL.

error: invalid domain pointer in virDomainFree

Which is useless.
2011-08-23 21:42:22 +08:00
Osier Yang
0756e5ad92 xen: Cleanup improper VIR_ERR_NO_SUPPORT use 2011-08-23 16:53:15 +08:00
Osier Yang
172214bd30 test: Cleanup improper VIR_ERR_NO_SUPPORT use 2011-08-23 16:32:06 +08:00
Osier Yang
0376f4a69b storage: Cleanup improper VIR_ERR_NO_SUPPORT use 2011-08-23 16:31:03 +08:00
Osier Yang
d4b53ef6cf remote: Cleanup improper VIR_ERR_NO_SUPPORT use 2011-08-23 16:26:26 +08:00
Osier Yang
4340b3ba40 qemu: Cleanup improper VIR_ERR_NO_SUPPORT use
* src/qemu/qemu_command.c: s/VIR_ERR_NO_SUPPORT/VIR_ERR_CONFIG_UNSUPPORTED/

* src/qemu/qemu_driver.c: s/VIR_ERR_NO_SUPPORT/VIR_ERR_OPERATION_INVALID/

* src/qemu/qemu_process.c: s/VIR_ERR_NO_SUPPORT/VIR_ERR_OPERATION_INVALID/
2011-08-23 16:23:10 +08:00
Osier Yang
5e495c8bd8 nodeinfo: Cleanup improper VIR_ERR_NO_SUPPORT use 2011-08-23 16:20:35 +08:00
Osier Yang
6ac47762bb lxc: Cleanup improper VIR_ERR_NO_SUPPORT use
s/VIR_ERR_NO_SUPPORT/VIR_ERR_OPERATION_INVALID/

Special case is changes on lxcDomainInterfaceStats, if it's not
implemented on the platform, prints error like:

    lxcError(VIR_ERR_OPERATION_INVALID, "%s",
             _("interface stats not implemented on this platform"));

As the function is supported by driver actually, error like
VIR_ERR_NO_SUPPORT is confused.
2011-08-23 16:17:10 +08:00
Osier Yang
49218c59b2 conf: Cleanup improper use of VIR_ERR_NO_SUPPORT in node_device_conf 2011-08-23 15:04:00 +08:00
Osier Yang
825d91cd31 qemu: Substitute VIR_ERR_NO_SUPPORT with VIR_ERR_OPERATION_INVALID
* src/qemu/qemu_monitor_text.c: Error like "this function is not
supported by the connection driver" is confused obviously.
2011-08-23 14:59:16 +08:00
Osier Yang
dba7086fc3 virsh: Print error if specified bandwidth is invalid for blockjob
It's strange that the command fails but without any error if one
specifies as not a number.
2011-08-23 14:55:23 +08:00
KAMEZAWA Hiroyuki
9f5afc732c send-key: fix scan keycode map
Now, bad key-code in send-key can cause segmentation fault in libvirt.
(example)
 % virsh send-key --codeset win32 12
   error: End of file while reading data: Input/output error

This is caused by overrun at scanning keycode array.

Fix it.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
2011-08-22 07:24:15 -06:00
Eric Blake
6611d9ebcc build: work around older systemtap header
Systemtap 1.2 <sys/sdt.h> tried to expand STAP_PROBE3 into an
initialization:
  volatile __typeof__(arg) foo = arg;
but that fails if arg was declared as 'char arg[100]'.
Rather than make all callers to PROBE deal with the stupidity
of <sys/sdt.h>, we instead make PROBE cast away the problem.
Some of this preprocessor abuse copies ideas in src/libvirt.c.

* daemon/libvirtd.h (PROBE): Add casts to all arguments, using...
(VIR_ADD_CASTS, VIR_ADD_CAST, VIR_ADD_CAST2, VIR_ADD_CAST3)
(VIR_ADD_CAST_EXPAND, VIR_ADD_CAST_PASTE, VIR_COUNT_ARGS)
(VIR_ARG5, PROBE_EXPAND): New macros.
Reported by Wen Congyang.
2011-08-22 06:57:16 -06:00
Eric Blake
baac9c37d7 virsh: properly interleave shared stdout and stderr
Without this patch, invoking 'virsh >file 2>&1' results in
error messages appearing before normal output, even if they
occurred later in time than the normal output (since stderr
is unbuffered, but stdout waits until a full buffer).

* tools/virsh.c (print_job_progress, vshError): Flush between
stream transitions.
* tests/undefine: Test it.
2011-08-19 09:22:22 -06:00
Eric Blake
d89dd42d51 maint: simplify lots of libxml2 clients
Repetitive patterns should be factored.  The sign of a good
factorization is a change that kills 5x more lines than it adds :)

* src/conf/domain_conf.c (virDomainDeviceDefParse)
(virDomainSnapshotDefParseString): Use new convenience macros.
* src/conf/storage_conf.c (virStoragePoolDefParseSourceString):
Likewise.
* src/cpu/cpu.c (cpuCompareXML, cpuBaselineXML): Likewise.
* src/esx/esx_vi.c (esxVI_Context_Execute): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationCookieXMLParseStr):
Likewise.
* src/security/virt-aa-helper.c (caps_mockup): Likewise.
* src/test/test_driver.c (testOpenFromFile): Likewise.
* tests/cputest.c (cpuTestLoadXML, cpuTestLoadMultiXML):
Likewise.
* tools/virsh.c (cmdFreecell, makeCloneXML, cmdVNCDisplay)
(cmdTTYConsole, cmdDetachInterface, cmdDetachDisk)
(cmdSnapshotCreate, cmdSnapshotCreateAs, cmdSnapshotCurrent)
(cmdSnapshotList, cmdSnapshotParent): Likewise.
2011-08-19 09:13:55 -06:00
Eric Blake
751304e367 xml: add another convenience function
Often, we want to use XPath functions on the just-parsed document;
fold this into the parser function for convenience.

* src/util/xml.h (virXMLParseHelper): Add argument.
(virXMLParseStrHelper, virXMLParseFileHelper): Delete.
(virXMLParseCtxt, virXMLParseStringCtxt, virXMLParseFileCtxt): New
macros.
* src/libvirt_private.syms (xml.h): Remove deleted functions.
* src/util/xml.c (virXMLParseHelper): Add argument.
(virXMLParseStrHelper, virXMLParseFileHelper): Delete.
2011-08-19 09:13:54 -06:00
Eric Blake
e472fe25c7 maint: treat more libxml2 functions as free-like
* cfg.mk (useless_free_options): Add xmlFreeDoc, xmlBufferFree.
* src/esx/esx_vi.c (ESX_VI__TEMPLATE__FREE): Fix offenders.
* tools/virsh.c (cmdFreecell, cmdVNCDisplay, cmdTTYConsole)
(cmdDetachInterface, cmdDetachDisk, cmdSnapshotCreate)
(cmdSnapshotCreateAs, cmdSnapshotList, cmdSnapshotParent):
Likewise.
2011-08-19 09:13:54 -06:00
Eric Blake
5f98c43707 test: rewrite test to match change in behavior
Test failure exposed in commit 7d3390f.

* tests/undefine: Fix to match updated test driver semantics.
2011-08-19 09:06:47 -06:00
Eric Blake
04682e694c build: fix typo in recent test patch
* src/test/test_driver.c (testDomainUndefineFlags): Use right
variable name.
2011-08-19 08:20:33 -06:00
Eric Blake
ecc2735480 Revert "xen: Allow to undefine a running domain (xm_internal)"
ACK was given too soon.  According to the code, the xm driver is
only used for inactive domains, and has no notion of an active
domain, thus, it cannot support undefine of a running domain.
The real fix for xen needs to be in the unified driver and/or
the xend level.

This reverts commit 49186deda6.
2011-08-19 08:19:34 -06:00
Osier Yang
49186deda6 xen: Allow to undefine a running domain (xm_internal) 2011-08-19 21:53:39 +08:00
Osier Yang
b9736d5b21 vmware: Allow to undefine a running domain 2011-08-19 21:52:12 +08:00
Osier Yang
b3b4aba5d4 uml: Allow to undefine a running domain 2011-08-19 21:51:42 +08:00
Osier Yang
7d3390f802 test: Allow to undefine a running domain 2011-08-19 21:50:49 +08:00
Osier Yang
aaa93ab6fa qemu: Allow to undefine a running domain 2011-08-19 21:49:37 +08:00
Osier Yang
ea92a34d1d openvz: Allow to undefine a running domain 2011-08-19 21:48:47 +08:00
Osier Yang
b375fc01e2 lxc: Allow to undefine a running domain 2011-08-19 21:47:33 +08:00
Osier Yang
0f407570b4 libxl: Allow to undefine a running domain.
Undefining a running domain will convert it to trasient, but keep
the domain still running.
2011-08-19 21:46:22 +08:00
Osier Yang
4ffa7530a4 qemu: Get memory balloon info correctly for text monitor
* src/qemu/qemu_monitor_text.c: BALLOON_PREFIX was defined as
"balloon: actual=", which cause "actual=" is stripped early before
the real parsing. This patch changes BALLOON_PREFIX into "balloon: ",
and modifies related functions, also renames
"qemuMonitorParseExtraBalloonInfo" to "qemuMonitorParseBalloonInfo",
as after the changing, it parses all the info returned by "info balloon".
2011-08-19 21:34:59 +08:00
Eric Blake
b14df8bec0 build: fix compilation on mingw64
* .gnulib: Update to latest, for getcwd fixes.
* bootstrap: Resync to gnulib.
2011-08-19 07:20:10 -06:00
Michal Privoznik
b32f8b1989 storage: Flush host cache after write
Although we are flushing cache after some critical writes (e.g.
volume creation), after some others we do not (e.g. volume cloning).
This patch fix this issue. That is for volume cloning, writing
header of logical volume, and storage wipe.
2011-08-19 11:10:31 +02:00
Michal Privoznik
74c7567133 daemon: initialize GnuTLS
When spice_tls is set but listen_tls is not, we don't initialize
GnuTLS library. So any later gnutls call (e.g. during migration,
where we initialize a certificate) will access uninitialized GnuTLS
internal structs and throws an error.

Although, we might now initialize GnuTLS twice, it is safe according
to the documentation:

    This function can be called many times,
    but will only do something the first time.

This patch creates 2 functions: virNetTLSInit and virNetTLSDeinit
with respect to written above.
2011-08-19 10:58:51 +02:00
Taku Izumi
4dec4d414f schedinfo: add missing documentation
This patch adds the missing documentation about the scheduler parameter
"vcpu_period" and "vcpu_quota".
2011-08-19 16:53:22 +08:00
Eric Blake
322d1cfc78 maint: ignore generated file
I did 'git add .' while in the middle of 'make syntax-check', and
it picked up a temporary file that should not be committed.

* .gitignore: Ignore sc_* from syntax check.
2011-08-18 17:34:56 -06:00
Eric Blake
310b09ec27 build: fix virnetsocket on mingw
Regression introduced in commit 5d30db0.

* src/rpc/virnetsocket.c (virNetSocketNewListenUNIX) [WIN32]: Use
correct signature.
2011-08-17 11:52:38 -06:00
Eric Blake
c811de8fb7 build: fix virpidfile on mingw
Regression introduced in commit b7e5ca4.

Mingw lacks kill(), but we were only using it for a sanity check;
so we can go with one less check.

Also, on OOM error, this function should outright fail rather than
claim that the pid file was successfully read.

* src/util/virpidfile.c (virPidFileReadPathIfAlive): Skip kill
call where unsupported, and report error on OOM.
2011-08-17 11:51:24 -06:00
Daniel P. Berrange
984840a2c2 Ensure async packets never get marked for sync replies
If a client had initiated a stream abort, it will have a call
waiting for a reply in the queue. If more data continues to
arrive on the stream, the abort command could mistakenly get
signalled as complete. Remove the code from async data processing
that looked for waiting calls. Add a sanity check to ensure no
async call can ever be marked as needing a reply

* src/rpc/virnetclient.c: Ensure async data packets can't
  trigger a reply
2011-08-17 09:44:12 -07:00