Commit Graph

3699 Commits

Author SHA1 Message Date
Cole Robinson
045176bf35 storage: Fix deadlock when cloning across pools.
We need to unlock the first pool before looking up the second, since the
search locks every pool it checks.
2009-07-16 12:52:52 -04:00
Cole Robinson
a500d73ac0 storage: disk: Use capacity, not allocation, when creating volume.
There isn't any way to dictate allocation when creating disk volumes, so
capacity is the only relevant value.
2009-07-16 12:52:52 -04:00
Cole Robinson
bd70595c9d storage: disk: Default to 'ext2' for new volumes.
Currently, if no format is specified for a new disk volume, we pass the
invalid value "none" as the FS type to 'parted mkpart'.

There doesn't seem to be a way to have parted not format the drive, so
just default to using 'ext2' in this case: this shouldn't cause any harm,
since we are creating a new partition in the first place.
2009-07-16 12:52:52 -04:00
Cole Robinson
12a6278135 storage: disk: Fix segfault creating volume without target path
Remove unneeded target path duplication, which could carelessly dereference
NULL. Make it clear where 'key' is actually filled in.
2009-07-16 12:52:51 -04:00
Cole Robinson
a3711708f7 storage: disk: Fix parthelper '-g' option handling.
Typo was breaking 'parthelper -g', preventing disk pool definition.
2009-07-16 12:52:51 -04:00
Jim Meyering
8f84fef2eb build: submodule machinery now works also when no tag is reachable
The code in cfg.mk to detect when the git submodule was out of date
worked most of the time, but not when checked out in a certain way.
* cfg.mk: Extract submodule hash from command output and file,
and compare only that, since the format of the full line may vary.
Reported by Mike Burns, with some diagnosis by Daniel P Berrange.
2009-07-16 18:42:47 +02:00
Daniel P. Berrange
0714b2ba4c Run QEMU guests as an unprivileged user
* configure.in: Add --with-qemu-user and --with-qemu-group args
* libvirt.spec.in: use 'qemu' for user/group for Fedora >= 12
* qemud/libvirtd_qemu.arg, qemud/test_libvirtd_qemu.aug,
  src/qemu.conf: Add 'user' and 'group' args for configuration
* src/Makefile.am: Create %localstatedir/cache/libvirt/qemu
* src/qemu_conf.c, src/qemu_conf.h: Load user/group from config
* src/qemu_driver.c: Change user ID/group ID when launching QEMU
  guests. Change user/group ownership on disks/usb/pci devs.
  Put memory dumps in %localstatedir/cache/libvirt/qemu
* src/util.c, src/util.h: Add convenient APIs for converting
  username/groupname to user ID / group ID
2009-07-16 17:06:55 +01:00
Laine Stump
d4ad29be2a Implement the new virinterface functions
* src/driver.h: add new driver functions virDrvNumOfDefinedInterfaces
  and virDrvListDefinedInterfaces
* src/libvirt.c: implements the entry points, calling new driver
  functions
* qemud/remote.c qemud/remote_dispatch_args.h qemud/remote_protocol.[chx]
  qemud/remote_dispatch_prototypes.h qemud/remote_dispatch_ret.h
  qemud/remote_dispatch_table.h src/remote_internal.c: implement the
  client/server side of the RPC
2009-07-16 17:58:15 +02:00
Laine Stump
043c954e9f Public API for new virInterface functions
* include/libvirt/libvirt.h[.in]: adds signatures for the new exported
  functions virConnectNumOfDefinedInterfaces and
  virConnectListDefinedInterfaces
* src/libvirt_public.syms: export the new symbols
2009-07-16 17:49:50 +02:00
Daniel Veillard
d3c236f91c Fix configure flags in spec file
* libvirt.spec.in: we were still using deprecated configure switches
2009-07-16 17:28:41 +02:00
Daniel P. Berrange
5dd21f2a75 Rename a bunch of internal methods to clarify their meaning
This renames a lot of the methods in the remote driver client
to more accurately reflect their responsibility of IO handling
vs message handling.
2009-07-16 16:09:48 +01:00
Daniel P. Berrange
d65707a5b4 Simplify remote driver error reporting
Remove redundant error reporting functions which obscured the
filename/line number reporting. Removed code which created a
virDomain/virNetwork object, since those are silently dropped
in error reporting functions now

* src/remote_internal.c: Remove error() and errorf() in favour of
 macros, and remove server_error in favour of direct call
2009-07-16 16:09:48 +01:00
Daniel P. Berrange
9c9ed0f3f6 Refactor message sending to allow code reuse for data streams
Splits up the 'call' method moving generic IO code out into
separate method to allow it to be easily reused for sending
data streams

* src/remote_internal.c: Split 'call' into two methods, the first
  with same name serializes a set of method arguments into a
  message, the second 'remoteIO' takes a pre-serialized messages,
  sends it and awaits a reply
2009-07-16 16:09:48 +01:00
Daniel P. Berrange
7a61c13834 Refactor incoming message handling to prepare for data stream support
* src/remote_internal.c: Rename processCallRecvMsg to
  processCallDispatch, and move code specific to method replies
  into processCallDispatchReply, and rename processCallAsyncEvent
  to processCallDispatchMessage
2009-07-16 16:09:48 +01:00
Daniel P. Berrange
27944fac9c Rename 'direction' to 'type' in remote_message_header
The 'remote_message_header' struct has a mis-leadingly named
field 'direction'. It is really a reflection of the type of
message, and some types can be sent in either direction. Thus
the field is more accurately named 'type'. No function change.

* qemud/remote_protocol.x: Rename 'direction' to 'type' in
  'remote_message_header. Write better docs describing the
  message header field semantics & usage
* qemud/remote_protocol.c, qemud/remote_protocol.h: Regenerate
* qemud/remote.c, qemud/dispatch.c, src/remote_internal.c
  Update to reflect rename of 'direction' to 'type'
2009-07-16 16:09:48 +01:00
Daniel P. Berrange
caaa1b8f13 Define an API for registering incoming message dispatch filters
All incoming messages currently get routed to the generic method
remoteDispatchClientRequest() for processing. To allow incoming
data stream messages to bypass this and be routed to a specific
location, a concept of dispatch filters is introduced.

* qemud/qemud.h: Add a qemud_client_filter struct and a callback
  qemud_client_filter_func. Maintain a list of filters on every
  struct qemud_client
* qemud/qemud.c: Move remoteDecodeClientMessageHeader() out of
  qemudWorker() into qemudDispatchClientRead(). Check registered
  message filters in qemudDispatchClientRead() to decide where
  to send incoming messages for dispatch.
2009-07-16 16:09:48 +01:00
Daniel P. Berrange
47cab73499 Split out code for handling incoming method call messages
The remoteDispatchClientRequest() method is currently hardwired to
assume there is only one type of incoming message, a method call.
To allow for alternate types of incoming messags, the code that is
specific to method calls is being split into a separate method
remoteDispatchClientCall

* qemud/dispatch.c: Move method call specific code out into
  remoteDispatchClientCall. Add a helper remoteSerializeError
  for returning error messages to client
2009-07-16 16:09:47 +01:00
Daniel P. Berrange
af4dad0fa2 Change the way client event loop watches are managed
The current qemudRegisterClientEvent() code is used both for
registering the initial socket watch, and updating the already
registered watch. This causes unneccessary complexity in alot
of code which only cares about updating existing watches. The
updating of a watch cannot ever fail, nor is a reference to the
'qemud_server' object required.

This introduces a new qemudUpdateClientEvent() method for that
case, allowing the elimination of unneccessary error checking
and removal of the server back-reference in struct qemud_client.

* qemud/qemud.h: Remove 'server' field from struct qemud_client.
  Add qemudUpdateClientEvent() method. Remove 'update' param
  from qemudRegisterClientEvent method
* qemud/dispatch.c, qemud/qemud.c, qemud/remote.c: Update alot
  of code to use qemudUpdateClientEvent() instead of
  qemudRegisterClientEvent(). Move more logic from remoteRelayDomainEvent
  into remoteDispatchDomainEventSend.
2009-07-16 16:09:47 +01:00
Daniel P. Berrange
c40e14b4be Move queuing of RPC replies into dispatch code
This removes an assumption from qemudWorker() code that every
incoming message will generate a reply.

* qemud/dispatch.c: remoteDispatchClientRequest now has responsibility
  for queuing the reply message to the RPC call
* qemud/qemud.c: Do not queue the RPC call reply in qemudWorker(),
  allowing remoteDispatchClientRequest() to take care of it
2009-07-16 16:09:47 +01:00
Daniel P. Berrange
aa23d432cd Change code generator to give async event messages their own postfix
The naming convention for structs used in the RPC layer is for
incoming requests to be called XXXX_args, and the associated
outgoing reply to be called XXXX_ret.  Asynchronously emitted
messages (eg events) are re-using the XXXX_ret naming scheme.
This patch changes that such that async messages are XXXX_msg,
and stops adding entries for them in the dispatch table, avoiding
the need for a dummy no-op implementation.

* qemud/remote.c: Remove dummy remoteDispatchDomainEvent, no
  longer required. Update to replace remote_domain_event_ret
  with xdr_remote_domain_event_msg
* qemud/remote_protocol.x: Rename remote_domain_event_ret to
  remote_domain_event_msg
* qemud/remote_generate_stubs.pl: Adding handling for new
  XXX_msg structs.
* src/remote_internal.c: Rename remote_domain_event_ret to
  remote_domain_event_msg
* qemud/remote_dispatch_prototypes.h, qemud/remote_dispatch_ret.h,
  qemud/remote_dispatch_table.h, qemud/remote_protocol.h,
  qemud/remote_protocol.c: auto-regenerate
2009-07-16 16:09:47 +01:00
Daniel P. Berrange
852fa7d04a Separate code for encoding outgoing remote message headers
Introduces an API for encoding the header field for outgoing messages
allowing some duplicated code to be eliminated

* qemud/dispatch.c, qemud/dispatch.h: add remoteEncodeClientMessageHeader
  for encoding message header. Update remoteDispatchClientRequest to
  use this method.
* qemud/remote.c: Update remoteDispatchDomainEventSend to use the
  generic remoteEncodeClientMessageHeader() for encoding event
  message hedaders. Push some logic from remoteRelayDomainEvent
  down into remoteDispatchDomainEventSend.
2009-07-16 16:09:47 +01:00
Daniel P. Berrange
081c6330b1 Decode incoming request header before invoking dispatch code
Separate the decoding of incoming request header out from the
dispatch code. This will allow later code to making dispatcher
routing decisions based on the header field data.

* qemud/dispatch.c, qemud/dispatch.h: Add remoteDecodeClientMessageHeader
  API for decoding the header of a client message. Update the
  remoteDispatchClientRequest method to assume a pre-decoded
  header.
* qemud/qemud.h: Include a 'remote_message_header' field in
  'struct qemud_client_message' for pre-decoded header data
* qemud/qemud.c: Decode the incoming client message header before
  invoking remoteDispatchClientRequest
2009-07-16 16:09:47 +01:00
Daniel P. Berrange
a147ef3837 Split generic RPC message dispatch code out from remote protocol API handlers
* po/POTFILES.in: Add qemud/dispatch.c
* qemud/dispatch.c, qemud/dispatch.h: Generic code handling dispatch of
  RPC messages.
* qemud/Makefile.am: Add dispatch.c to build
* qemud/qemud.c: Include dispatch.h
* qemud/qemud.h: Remove remoteDispatchClientRequest, remoteRelayDomainEvent
  now in dispatch.h
* qemud/remote.c: Remove remoteDispatchClientRequest, remoteRelayDomainEvent
  now in dispatch.c, and dispatch_args, dispatch_ret, dispatch_fn & dispatch_data
  now in remote.h
* qemud/remote.h: Add typedefs for dispatch_args, dispatch_ret,
  dispatch_fn, dispath_data. Add remoteGetDispatchData() API
2009-07-16 16:09:41 +01:00
Paolo Bonzini
e1abc44814 Implement qemu dump capabilities
* src/qemu_driver.c (qemudDomainCoreDump): New
  (qemuDriver): Add core dump function. The behaviour is similar
  as the current Xen dump
2009-07-16 16:50:23 +02:00
Paolo Bonzini
c4951f11b7 add cd and pwd commands to virsh
* src/virsh.c: adds cd and pwd commands to virsh useful for save and
  restore commands
* docs/virsh.pod virsh.1: update the documentation
* AUTHORS: add Paolo Bonzini
2009-07-16 16:40:08 +02:00
Jim Meyering
08a2e796e8 make "make syntax-check" consistent with "git diff --check"
This makes "make syntax-check" fail when a version-controlled
file contains a trailing blank line.
* cfg.mk (sc_prohibit_trailing_blank_lines): New rule.
2009-07-16 15:06:42 +02:00
Jim Meyering
07613d2020 remove all trailing blank lines
by running this command:
git ls-files -z | xargs -0 perl -pi -0777 -e 's/\n\n+$/\n/'
This is in preparation for a more strict make syntax-check
rule that will detect trailing blank lines.
2009-07-16 15:06:42 +02:00
Daniel P. Berrange
4a7acedd3c Fix free of unitialized data upon PCI open fail 2009-07-16 13:57:44 +01:00
Daniel P. Berrange
1795bfe4a1 Fix SELinux denial during hotplug
* src/qemu_driver.c: Relabel disk images *before* running QEMU
hotplug monitor commands
2009-07-16 11:32:09 +01:00
Daniel P. Berrange
326ecb7814 Fix PCI device hotplug/unplug with newer QEMU
* src/qemu_driver.c: Try new monitor syntax for hotplug first. If
  that fails fallback to old KVM specific syntax
2009-07-16 11:32:09 +01:00
Daniel P. Berrange
2d1f2e706c Fix problem with QEMU monitor welcome prompt confusing libvirt
after a libvirtd daemon restart with active guests

* src/qemu_driver: Read and dicard pending monitor data
  before issuing new monitor commands.
2009-07-16 11:32:03 +01:00
Daniel P. Berrange
bf5343d233 Ensure spawned children have a stderr/out set to /dev/null if requested 2009-07-16 10:53:21 +01:00
Daniel P. Berrange
89c5ce4dcd Allow autostart of libvirtd to be disabled with LIBVIRT_AUTOSTART=0
* src/remote_internal.c: Disable libvirtd autostart if the
  LIBVIRT_AUTOSTART=0 env variable is set
* src/libvirt.c: Document environment variables can impact
  the virConnectOpen API
2009-07-16 10:53:16 +01:00
Daniel Veillard
788c315165 netcf XML validation and input and output tests
* tests/interfaceschematest: test all XML data against the interface
  schemas
* tests/interfacexml2xmltest.c: parse and reserialize all XML data
  and check the output is identical
* tests/Makefile.am: hook up the tests
* tests/.gitignore: add ignore test
2009-07-15 20:16:36 +02:00
Daniel Veillard
19e57fd902 Add netcf XML schemas and test data
* docs/schemas/interface.rng: schemas for the interface XML files
  directly imported from netcf-0.1.0
* tests/interfaceschemadata/*.xml: set of test files from netcf-0.1.0
  changed to use single quote instead of double quote
2009-07-15 20:16:36 +02:00
Daniel Veillard
2f5fb5e09d add support for netcf XML import and export
* src/interface_conf.c src/interface_conf.h: the import and export
  routines and the internal APIs
* src/Makefile.am: hook the new file in the makefiles
* src/libvirt_private.syms: export a few private symbols internally
* po/POTFILES.in: the new file contains translatable strings
2009-07-15 20:16:26 +02:00
Daniel P. Berrange
8c9b8431ee Ensure test:/// URIs get routed to the non-privileged libvirtd
* src/remote_internal.c: Ensure that all test:/// URIs are dealt
  with by the auto-started, per-user unprivileged libvirtd instances
2009-07-15 12:29:35 +01:00
Daniel P. Berrange
845659340e Fix error reporting for security driver over remote protocol
* qemud/remote.c: Send back the actual libvirt connection error
  rather than formatting a generic error for security driver
  methods
* src/libvirt.c: Fix virDomainGetSecurityLabel, and
  virNodeGetSecurityModel to correctly set the error on
  the virConnectPtr object, and raise a full error rather
  than warning when not supported
2009-07-15 12:27:42 +01:00
Garry Dolley
a90629aa13 Update the links for RHEL libvirt bugzillas 2009-07-15 11:46:52 +02:00
Garry Dolley
f19fdbba22 Update links to bugzilla
* docs/bugs.html[.in]: general tickets are under the 'Virtualization
  Tools' product category and Fedora specific tickets are under the
  'Fedora' product category.
2009-07-13 10:31:24 +02:00
Cole Robinson
ad664f54ff Fix docs and code disagreements for character devices.
The 'pipe' character type wasn't documented.
TCP uses a <protocol> element, not <wire>
We weren't doing strict validation for protocol and source mode values.
2009-07-10 19:29:31 -04:00
Cole Robinson
fe7cb869a8 qemu: Check driver is initialized up front, to avoid segfault.
If the qemu_driver was not initialized (possibly due to an error on driver
startup), we can segfault if attempting to connect to the URI.
2009-07-10 19:29:31 -04:00
Jim Meyering
f272378d52 build: automatically rerun ./bootstrap when needed
When "git pull" (or any other operation) brings in a new version of the
gnulib git submodule, you must rerun the autogen.sh script.  With this
change, "make" now fails and tells you to run ./autogen.sh, when needed.
* autogen.sh: Maintain a new file, .git-module-status, containing
the current submodule status.  If it doesn't exist or its content
is different from what "git submodule status" prints, then run
./bootstrap
* .gitignore: Add .git-module-status
* cfg.mk: Diagnose out of date submodule and fail.
* README-hacking: Update not to mention bootstrap.
* Makefile.am (MAINTAINERCLEANFILES): Add .git-module-status,
so that "make maintainerclean" will remove it.
2009-07-10 13:39:28 +02:00
Jim Meyering
e335b2ca90 build: make autogen.sh use autoreconf -if
* autogen.sh: Use "autoreconf -if" instead of open-coding it with
manual and unconditional invocation of each separate tool.
2009-07-10 13:39:28 +02:00
Mark McLoughlin
13709bdbf8 Use virDomainChrTypeFromString() instead of open coding
* src/domain_conf.c: replace open coded chr type parsing with
  virDomainChrTypeFromString(), retaining the existing semantics
  where unknown types are silently mapped to the "null" type and
  "pty" is used if none is specified
2009-07-10 09:33:34 +01:00
Mark McLoughlin
62455ed872 Switch to using a unix socket for the qemu monitor
We keep support for the pty based monitor so that we can re-connect
to VMs started by older versions of libvirtd.

* src/domain_conf.c: handle formatting and parsing unix monitors

* src/qemu_driver.c: add qemudOpenMonitorUnix(), remove the monitor
  pty path searching from qemudFindCharDevicePTYs(), switch
  qemudStartVMDaemon() and qemuDomainXMLToNative() to using a unix
  monitor

* tests/qemuxml2argvtest.c: switch to using a unix monitor

* tests/qemuxml2argvdata/qemuxml2argv-*.args: update test data
2009-07-09 20:04:09 +01:00
Mark McLoughlin
05d377bdd2 Add the monitor type to the domain state XML
There are no functional changes in this patch apart from adding the
monitor type to the state XML.

The patch mostly consists of switching to use virDomainChrDef every
where to describe the monitor.

* src/domain_conf.h: replace monitorpath with monitor_chr

* src/domain_conf.c: handle parsing the monitor type and initializing
  monitor chr

* src/qemu_conf.[ch]: make qemudBuildCommandLine take a
  virDomainChrDefPtr and use that to build the -monitor parameter

* src/qemu_driver.c: split pty specific and common code from
  qemudOpenMonitor, have qemudStartVMDaemon() initialize monitor_chr

* tests/qemuxml2argvtest.c: update for qemudBuildCommandLine() change
2009-07-09 20:04:07 +01:00
Mark McLoughlin
1f4ec305f0 Minor qemu monitor coding style fixes
* src/qemu_driver.c: use a consistent coding style for function
  definitions
2009-07-09 19:31:01 +01:00
Mark McLoughlin
8a52daa2d4 Don't leak vm->monitorpath on re-connect
* src/qemu_driver.c: vm->monitorpath is already initialized in the case
  of re-connect, so move the initialization for the normal startup case
  out of the common code
2009-07-09 19:31:01 +01:00
Jim Meyering
72978b9789 build: update from gnulib, for latest maint.mk
* gnulib: Update submodule to latest.
This fixes the make syntax-check failure whereby sc_po_check
would complain about cfg.mk.
2009-07-09 20:02:31 +02:00