Commit Graph

5755 Commits

Author SHA1 Message Date
Osier Yang
8eb236c5f7 virsh: Remove redundant commands in group domain
"echo" is already in group "virsh", "freecell" and "hostname" are
already in group "host", so remove them from group "domain"

* tools/virsh.c
2010-12-07 08:23:09 -07:00
Dan Kenigsberg
e37ff2004a Fix funny off-by-one error in clock-variable
Humans consider January as month #1, while gmtime_r(3) calls it month #0.

While fixing it, render qemu's rtc parameter with leading zeros, as is more
commonplace.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=660194
2010-12-06 11:14:42 -07:00
Laurent Léonard
68e5e4672a syntax error "Bad fd number" when stopping libvirt-guests
When libvirt-guests is being stopped, I get the following message:
$Running guests on default URI: test-vm
$Suspending guests on default URI...
$Suspending test-vm: /etc/init.d/libvirt-guests: 340: Syntax error: Bad fd
number
2010-12-06 11:01:36 -07:00
Eric Blake
e4bc372e1b threads: add virThreadID for debugging use
* src/util/threads.h (virThreadID): New prototype.
* src/util/threads-pthread.c (virThreadID): New function.
* src/util/threads-win32.c (virThreadID): Likewise.
* src/libvirt_private.syms (threads.h): Export it.
* daemon/event.c (virEventInterruptLocked): Use it to avoid
warning on BSD systems.
2010-12-06 09:50:20 -07:00
Osier Yang
85ccf42cd0 util: Fix bug which will cause libvirtd crash
"virCommandRun": if "cmd->outbuf" or "cmd->errbuf" is NULL,
libvirtd will be crashed when trying to start a qemu domain
(which invokes "virCommandRun"), it caused by we try to use
"*cmd->outbuf" and "*cmd->errbuf" regardless of cmd->outbuf
or cmd->errbuf is NULL.

* src/util/command.c (virCommandRun)
2010-12-06 09:34:54 -07:00
Jiri Denemark
58d0f4d737 tests: Don't ignore return value of getcwd() 2010-12-06 10:12:01 +01:00
Jiri Denemark
5f5c6a1b90 build: Fix internal docs generation in VPATH builds 2010-12-06 10:11:44 +01:00
Jiri Denemark
584c13f356 qemu: Fix a possible deadlock in p2p migration
Two more calls to remote libvirtd have to be surrounded by
qemuDomainObjEnterRemoteWithDriver() and
qemuDomainObjExitRemoteWithDriver() to prevent possible deadlock between
two communicating libvirt daemons.

See commit f0c8e1cb37 for further details.
2010-12-06 10:09:50 +01:00
Jiri Denemark
4186f92935 Change return value of VIR_DRV_SUPPORTS_FEATURE to bool
virDrvSupportsFeature API is allowed to return -1 on error while all but
one uses of VIR_DRV_SUPPORTS_FEATURE only check for (non)zero return
value. Let's make this macro return zero on error, which is what
everyone expects anyway.
2010-12-06 10:09:00 +01:00
Matthias Bolte
ccf2d0847b qemu: Don't try to set input FD to -1 2010-12-05 00:45:43 +01:00
Matthias Bolte
45ef4d5e8a Implement virVMOperationType{To|From}String independent from WITH_MACVTAP
As this symbols are exported independent from WITH_MACVTAP.
2010-12-03 18:06:42 +01:00
Eric Blake
c6506ff8e9 build: avoid shadowing devname() on BSD systems
* tools/virsh.c (cmdRunConsole, cmdConsole): Rename problematic
symbol.
Reported by Justin Clift.
2010-12-03 08:26:40 -07:00
Osier Yang
2636f50842 virsh: Remove redundant optional option for cmdHelp
Remove the optional option "group", as cmdHelp should accepts
only one option ("virsh help" supports both command and command
group now, and user rarely uses the options, so it doesn't matter
much for it being longer, :-)

* tools/virsh.c
2010-12-03 08:22:17 -07:00
Jean-Baptiste Rouault
966a1bfe22 Create file in virFileWriteStr() if it doesn't exist
This patch adds a mode_t parameter to virFileWriteStr().
If mode is different from 0, virFileWriteStr() will try
to create the file if it doesn't exist.

* src/util/util.h (virFileWriteStr): Alter signature.
* src/util/util.c (virFileWriteStr): Allow file creation.
* src/network/bridge_driver.c (networkEnableIpForwarding)
(networkDisableIPV6): Adjust clients.
* src/node_device/node_device_driver.c
(nodeDeviceVportCreateDelete): Likewise.
* src/util/cgroup.c (virCgroupSetValueStr): Likewise.
* src/util/pci.c (pciBindDeviceToStub, pciUnBindDeviceFromStub):
Likewise.
2010-12-03 08:08:22 -07:00
Justin Clift
4fa617e6eb man pages: update the description for the virsh help command
Now includes information on keyword usage, and provides examples.
2010-12-03 17:54:16 +11:00
Osier Yang
30277bb54c virsh: move two commands from domain group to storage pool group
* tools/virsh.c (find-storage-pool-sources-as and find-storage-pool-sources
should't be in command group "Domain Management", move them to group
"Storage Pool".
2010-12-02 16:09:19 -07:00
Daniel P. Berrange
70256860ec Remove bogus includes 2010-12-02 16:00:47 -07:00
Daniel P. Berrange
98c379b3c5 uml: convert to virCommand
* src/uml/uml_conf.c (umlBuildCommandLineChr)
(umlBuildCommandLine): Rewrite with virCommand.
* src/uml/uml_conf.h (umlBuildCommandLine): Update signature.
* src/uml/uml_driver.c (umlStartVMDaemon): Adjust caller.
2010-12-02 16:00:47 -07:00
Eric Blake
6a7e7c4f62 qemu: convert to virCommand
* src/qemu/qemu_conf.c (qemudExtractVersionInfo): Check for file
before executing it here, rather than in callers.
(qemudBuildCommandLine): Rewrite with virCommand.
* src/qemu/qemu_conf.h (qemudBuildCommandLine): Update signature.
* src/qemu/qemu_driver.c (qemuAssignPCIAddresses)
(qemudStartVMDaemon, qemuDomainXMLToNative): Adjust callers.
2010-12-02 16:00:47 -07:00
Daniel P. Berrange
3709a386c9 Port hooks and iptables code to new command execution APIs
This proof of concept shows how two existing uses of virExec
and virRun can be ported to the new virCommand APIs, and how
much simpler the code becomes
2010-12-02 16:00:47 -07:00
Daniel P. Berrange
a317c50a04 virCommand: docs for usage of new command APIs
* docs/internals/command.html.in: New file.
* docs/Makefile.am: Build new docs.
* docs/subsite.xsl: New glue file.
* docs/internals.html.in, docs/sitemap.html.in: Update glue.
2010-12-02 16:00:47 -07:00
Daniel P. Berrange
f16ad06fb2 Introduce new APIs for spawning processes
This introduces a new set of APIs in src/util/command.h
to use for invoking commands. This is intended to replace
all current usage of virRun and virExec variants, with a
more flexible and less error prone API.

* src/util/command.c: New file.
* src/util/command.h: New header.
* src/Makefile.am (UTIL_SOURCES): Build it.
* src/libvirt_private.syms: Export symbols internally.
* tests/commandtest.c: New test.
* tests/Makefile.am (check_PROGRAMS): Run it.
* tests/commandhelper.c: Auxiliary program.
* tests/commanddata/test2.log - test15.log: New expected outputs.
* cfg.mk (useless_free_options): Add virCommandFree.
(msg_gen_function): Add virCommandError.
* po/POTFILES.in: New translation.
* .x-sc_avoid_write: Add exemption.
* tests/.gitignore: Ignore new built file.
2010-12-02 16:00:44 -07:00
Eric Blake
fce3baee26 util: add virVasprintf
* src/util/util.h (virVasprintf): New declaration.
* src/util/util.c (virVasprintf): New function.
(virAsprintf): Use it.
* src/util/virtaudit.c (virAuditSend): Likewise.
* src/libvirt_private.syms: Export it.
* cfg.mk (sc_prohibit_asprintf): Also prohibit vasprintf.
* .x-sc_prohibit_asprintf: Add exemption.
2010-12-02 11:23:15 -07:00
Eric Blake
dbab6bb5cf util: fix saferead type
* src/util/util.c (saferead): Fix return type.
(safewrite): Fix indentation.
2010-12-02 11:23:15 -07:00
Daniel P. Berrange
19240c3c00 Tweak daemon event debug to include errno
* daemon/event.c: Include errno in debug info upon poll() failure
2010-12-02 12:16:30 +00:00
Daniel P. Berrange
c846bc9eb8 Fix memory leak in logging setup
The logging setup requires const char * strings, but the
virLogSetFromEnv() strdup's the env variables, thus causing
a memory leak

* src/util/logging.c: Avoid strdup'ing env variables
2010-12-02 12:16:24 +00:00
Jiri Denemark
6fda7ea537 tests: Add tests for CPU selection in qemu driver 2010-12-02 11:13:09 +01:00
Jiri Denemark
9237e9558a tests: Support for faking emulator in qemuxml2argv
This patch allows for using custom scripts instead of /usr/bin/qemu
emulator in domain XML. To do so, one would specify relative path to the
custom script in <emulator/>. The path needs to be relative to
qemuxml2argvdata directory and it will be transparently made absolute in
runtime. The expected command line needs to contain the exact relative
path as was used in domain XML.

The problem is RelaxNG schema for domain XML only allows for absolute
path within <emulator/>. To workaround it, an extra '/' must be added at
the beginning of the path. That is, instead of "./qemu.sh" or
"../emulator/qemu.sh" one would use "/./qemu.sh" or
"/../emulator/qemu.sh". The extra slash is removed before further
processing. I don't like this workaround, it's very ugly but it's the
best option I was able to come up with. Relaxing domain XML schema is
not an option IMO.
2010-12-02 11:13:05 +01:00
Jiri Denemark
a7283d849c schemas: Fix cpu element schema
Both vendor and topology elements are optional.
2010-12-02 11:02:57 +01:00
Osier Yang
84f7b286c2 virsh: Remove using phy as default disk driver in cmdAttachDisk
* tools/virsh.c (virsh shouldn't use 'phy' as the disk driver if
user doesn't specify "--driver", it causes bugs, as not all of
hypervisor driver supports 'phy', and actually hypervisor should
known the correct default disk driver and subdriver, so remove it)
2010-12-01 19:01:06 -07:00
Eric Blake
3ea59d6acb maint: update .gitignore
* .gitignore: Ignore recent built file, sort.
2010-12-01 18:46:35 -07:00
Guido Günther
fab5a25c03 OpenVZ: drop fd leackage
Drop unused (and unclosed) errfd and close outfd on exit. Otherwise
polling the running domains with virt-manager let's us quickly run out
of fds.
2010-12-01 19:38:01 +01:00
Osier Yang
401979a454 qemu: Use macro for max and min vnc port instead of number
* src/qemu/qemu_driver.c (though MACROS QEMU_VNC_PORT_MAX, and
QEMU_VNC_PORT_MIN are defined at the beginning, numbers (65535, 5900)
are still used, replace them)
2010-12-01 10:28:23 -07:00
Osier Yang
ead3c43456 qemu: Fix typo in qemuTeardownDiskPathDeny
typo in error message, it should be by copy-a-paste
from "qemuSetupDiskPathAllow".

* src/qemu/qemu_driver.c (qemuTeardownDiskPathDeny)
2010-12-01 18:04:56 +01:00
Eric Blake
428ea3a626 qemu: plug memory leak
* src/qemu/qemu_driver.c (qemudShutdown): Free all strings and the
ebtables structure.
* src/libvirt_private.syms (ebtablesContextFree): Export missing
symbol.
* src/util/ebtables.c (ebtablesContextFree): Allow early exit.
2010-12-01 10:00:10 -07:00
Eric Blake
6d0df64821 libvirtd: avoid memory leak on shutdown
* daemon/libvirtd.c (qemudRunLoop): Free any remaining client data.
2010-12-01 10:00:09 -07:00
Daniel P. Berrange
9c65609247 Fix flaw in thread creation APIs
The arguments passed to the thread function must be allocated on
the heap, rather than the stack, since it is possible for the
spawning thread to continue before the new thread runs at all.
In such a case, it is possible that the area of stack where the
thread args were stored is overwritten.

* src/util/threads-pthread.c, src/util/threads-win32.c: Allocate
  thread arguments on the heap
2010-12-01 16:50:05 +00:00
Osier Yang
33e38e7710 virsh: update help for "virsh help help"
As virsh help supports both command and command group now,
update "cmdHelp" to print consite help, (this patch is
increment of "7829052757953023b0826e0293ffe18ed4ab89e9").

And also remove redundant empty line in "vshUsage".

* tools/virsh.c
2010-12-01 09:13:11 -07:00
Matthias Bolte
474b1c1487 Fix undefined symbol errors when macvtap support is disabled
Use macvtap specific functions depending on WITH_MACVTAP.

Use #if instead of #ifdef to check for WITH_MACVTAP, because
WITH_MACVTAP is always defined with value 0 or 1.

Also export virVMOperationType{To|From}String unconditional,
because they are used unconditional in the domain config code.
2010-12-01 17:08:08 +01:00
Jean-Baptiste Rouault
45147ca37f Fix warning when macvtap support is disabled 2010-12-01 15:00:58 +01:00
Justin Clift
270b0b5f2e virsh: remove a badly placed line break in virsh -h output
The output was previously:

    -c | --connect <uri>    hypervisor connection URI
    -r | --readonly         connect readonly
    -d | --debug <num>      debug level [0-5]
    -h | --help             this help
    -q | --quiet            quiet mode
    -t | --timing           print timing information
    -l | --log <file>       output logging to file
    -v | --version[=short]  program version

    -V | --version=long     version and full options

(note the blank line between the --version types)

This patch removes the extra blank line.
2010-12-02 00:28:10 +11:00
Jiri Denemark
598b9fe4af tests: Add unit tests for internal CPU APIs 2010-12-01 14:12:54 +01:00
Jiri Denemark
72bce49dcc cpu: Add support for overriding path to CPU map XML file 2010-12-01 14:12:54 +01:00
Hu Tao
1b6f13bb70 Fall back to QEMUD_SAVE_FORMAT_RAW if compression method fails.
When dumping a domain, it's reasonable to save dump-file in raw format
if dump format is misconfigured or the corresponding compress program
is not available rather then fail dumping.
2010-11-30 14:22:53 -07:00
Osier Yang
7829052757 virsh: Categorize commands into groups for virsh help
Change the virsh help out. The new output of "virsh help" and
"virsh --help" will be like:

 Secret (help keyword 'secret'):
    secret-define                  define or modify a secret from an XML file
    secret-dumpxml                 secret attributes in XML
    secret-set-value               set a secret value
    secret-get-value               Output a secret value
    secret-undefine                undefine a secret
    secret-list                    list secrets

 Snapshot (help keyword 'snapshot'):
    snapshot-create                Create a snapshot
    snapshot-current               Get the current snapshot
    snapshot-delete                Delete a domain snapshot
    snapshot-dumpxml               Dump XML for a domain snapshot
    snapshot-list                  List snapshots for a domain
    snapshot-revert                Revert a domain to a snapshot

Also support output help information of specified command group, e.g.

% ./tools/virsh help "Network Filter"
 Network Filter (help keyword 'filter'):
    nwfilter-define                define or update a network filter from an XML file
    nwfilter-undefine              undefine a network filter
    nwfilter-dumpxml               network filter information in XML
    nwfilter-list                  list network filters
    nwfilter-edit                  edit XML configuration for a network filter

Each group has a help keyword, e.g.

% ./tools/virsh help filter
 Network Filter (help keyword 'filter'):
    nwfilter-define                define or update a network filter from an XML file
    nwfilter-undefine              undefine a network filter
    nwfilter-dumpxml               network filter information in XML
    nwfilter-list                  list network filters
    nwfilter-edit                  edit XML configuration for a network filter

* tools/virsh.c:
  - introduce new struct "vshCmdGrp" and macros to define the groups.
  - split previous array "commands" into small arrays which are orgnized
    by group
  - changed some functions, e.g. "vshCmdDefSearch"
  - Added new functions, e.g. "vshCmdGrpSearch"
  - commands of each group are in "alphabetical order" now.
  - command groups are in "alphabetical order" now.
  - the commands are categorized with reference of
    http://wiki.libvirt.org/page/VirshHelpV2 (by Justin)
  - the modifications doesn't affect tests

* TODO:
  - doc
2010-11-30 13:35:32 -07:00
Eric Blake
dd70168a5b maint: allow 'make syntax-check' to run again
* cfg.mk (VC_LIST_ALWAYS_EXCLUDE_REGEX): Permanently exempt
docs/news.html.in from all future syntax checks.
2010-11-30 13:33:52 -07:00
Daniel Veillard
a33db6cbfb Release of libvirt 0.8.6
- configure.ac libvirt.spec.in: bump version, add a missing systemtap
  build requirement
- docs/news.html.in: add informations about the release
- po/*: updated Polish and Dutch localizations, and regenerated
- tests/qemuxml2argvtest.c: Fix build problem
2010-11-30 20:42:46 +01:00
Stefan Berger
c2b38277b3 802.1Qbg: use pre-associate state at beginning of inc. migr
This patch introduces the usage of the pre-associate state of the IEEE 802.1Qbg standard on incoming VM migration on the target host. It is in response to bugzilla entry 632750.

https://bugzilla.redhat.com/show_bug.cgi?id=632750

For being able to differentiate the exact reason as to why a macvtap device is being created, either due to a VM creation or an incoming VM migration, I needed to pass that reason as a parameter from wherever qemudStartVMDaemon is being called in order to determine whether to send an ASSOCIATE (VM creation) or a PRE-ASSOCIATE (incoming VM migration) towards lldpad.

I am also fixing a problem with the virsh domainxml-to-native call on the way.

Gerhard successfully tested the patch with a recent blade network 802.1Qbg-compliant switch.

The patch should not have any side-effects on the 802.1Qbh support in libvirt, but Roopa (cc'ed) may want to verify this.
2010-11-30 12:50:54 -05:00
Guido Günther
d7e2b2b4eb Ignore files generated by "make tags" 2010-11-30 17:20:18 +01:00
Guido Günther
2d626c7d08 OpenVZ: Fix some overwritten error codes
Don't overwrite errors during domain creation/definition to ease
tracking down problems.
2010-11-30 17:20:16 +01:00