Commit Graph

49917 Commits

Author SHA1 Message Date
Daniel Veillard
d6fa6f3e92 Remove trailing blank lines 2009-07-21 15:43:11 +02:00
Laine Stump
846f694908 Add interface object list manipulation functions
* interface_conf.c interface_conf.h: utilities function usful for
  interface driver like the test interface driver
2009-07-21 15:40:55 +02:00
Laine Stump
9734c81f3a virGetinterface matching of MAC and interface name
MAC address of a particular interface may change over time, and the
reduced virInterface object (which contains just name and mac) needs
to reflect these changes. Since we can't modify the mac address of an
existing virInterface (some other thread may currently be using it) we
just create a new virInterface, and let the old one die a dignified
death when its refct goes to 0.
* src/datatypes.c: fix the matching and lifetime of virInterface object
  accordingly
2009-07-21 15:37:20 +02:00
Laine Stump
6eeca586d4 Add an error code for conflicting mac addresses
* include/libvirt/virterror.h src/virterror.c: if a driver's
  virInterfaceLookupByMACString() function finds more than one interface
  with the desired MAC Address, this new error is raised.
2009-07-21 15:13:32 +02:00
Jun Koi
b2fd033cd5 Fix an uninitialized variable in Unix socket open
* src/qemu_driver.c: qemudOpenMonitorUnix() had an uninitialized loop
  counter
2009-07-21 11:57:54 +02:00
Daniel Veillard
7641c3c782 rpm spec cleanup and split off client only package
* libvirt.spec.in: make a client rpm with shared libs, client binaries
  and resources needed by those, and a small number of fixes and
  cleanups in the spec file.
2009-07-21 11:16:15 +02:00
Jim Meyering
4567905790 build: do not emit a trailing blank line into VC'd file, NEWS
* docs/Makefile.am ($(top_builddir)/NEWS): Adjust rule to filter
out any trailing blank lines when generating this file.
* NEWS: Regenerate, so that it contains entries for 0.6.5.
2009-07-16 23:11:55 +02:00
Daniel Veillard
86941f55d5 Remove some unused variables and cut long lines
* src/virsh.c: a bit of cleanup on previous commit
2009-07-16 22:04:24 +02:00
Laine Stump
6b56ac24df Add virsh commands for network interface management
* src/virsh.c: add a number of interface related commands:
  iface-list, iface-name, iface-mac, iface-dumpxml, iface-define,
  iface-undefine, iface-edit, iface-start and iface-destroy
2009-07-16 21:44:10 +02:00
Cole Robinson
632ed550c7 Fix gitweb link on download page. 2009-07-16 12:52:53 -04:00
Cole Robinson
3b5417687d qemu: Try multiple times to open unix monitor socket
Unlike the pty monitor (which we know exists since we scrape its path from
stdout), we have no way of knowing that the unix monitor socket should exist/
be initialized. As a result, some of my KVM guests randomly fail to start on
F10 host.

Try to open the unix socket in a 3 second timeout loop. Ignore EACCES (path
does not exist if a first time run) and ECONNREFUSED (leftover socket from
a previous run hasn't been removed yet). Fixes things for me.
2009-07-16 12:52:53 -04:00
Cole Robinson
fd06fd1442 storage: Implement CreateVolFrom for logical and disk backend.
With the previous refactoring, this is a simple process, since the global
'CreateBlockFrom' in storage_backend does all the work.
2009-07-16 12:52:52 -04:00
Cole Robinson
f23814e0cd storage: Don't try sparse detection if writing to block device.
We don't gain any space savings, so skip the detection to speed up
the cloning operation.
2009-07-16 12:52:52 -04:00
Cole Robinson
7471357081 storage: Implement 'CreateBlockFrom' helper.
Add a 'CreateBlockFrom' in the global storage_backend, which sets up the
destination block device: CopyFromFD does the rest of the cloning.
2009-07-16 12:52:52 -04:00
Cole Robinson
a256fccfe1 storage: Break out actual raw cloning to separate function.
The CreateRaw function has some 'file' only assumptions, so break the agnostic
cloning bits to a separate function.
2009-07-16 12:52:52 -04:00
Cole Robinson
16e4833492 storage: cleanup: do away with 'createFile'
Have storage building functions be definitions of
virStorageBackendBuildVolFrom: we will need to do this in the future anyways
if we ever support the flags attribute.
2009-07-16 12:52:52 -04:00
Cole Robinson
6d7d465a04 storage: Move most of the FS creation functions to common backend.
These will be used by other pool cloning implementations.
2009-07-16 12:52:52 -04:00
Cole Robinson
1b16bf4ec7 storage: Refactor FS backend 'create' function choosing.
Break out separate functions for

- Determining the supported '*-img' tool,
- The tool's associated create function,
- Desired function for cloning (CreateXMLFrom).

This will be eventually used to unify cloning across all backends.
2009-07-16 12:52:52 -04:00
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