Commit Graph

5366 Commits

Author SHA1 Message Date
Eric Blake
8d733f4ef1 flags: fix qemu migration regression
Commit f548480b broke migration v3 on qemu, because the driver
passed flags on through to qemu_migration even though
qemu_migration wasn't using those flags.

* src/qemu/qemu_migration.h (QEMU_MIGRATION_FLAGS): New define.
* src/qemu/qemu_driver.c: Simplify all migration callbacks.
* src/qemu/qemu_migration.c (qemuMigrationConfirm): Fix regression.
2011-07-15 12:34:00 -06:00
Eric Blake
461e0f1a2d flags: use common dumpxml flags check
The previous patches only cleaned up ATTRIBUTE_UNUSED flags cases;
auditing the drivers found other places where flags was being used
but not validated.  In particular, domainGetXMLDesc had issues with
clients accepting a different set of flags than the common
virDomainDefFormat helper function.

* src/conf/domain_conf.c (virDomainDefFormat): Add common flag check.
* src/uml/uml_driver.c (umlDomainAttachDeviceFlags)
(umlDomainDetachDeviceFlags): Reject unknown
flags.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc)
(vboxDomainAttachDeviceFlags)
(vboxDomainDetachDeviceFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainMemoryPeek): Likewise.
(qemuDomainGetXMLDesc): Document common flag handling.
* src/libxl/libxl_driver.c (libxlDomainGetXMLDesc): Likewise.
* src/lxc/lxc_driver.c (lxcDomainGetXMLDesc): Likewise.
* src/openvz/openvz_driver.c (openvzDomainGetXMLDesc): Likewise.
* src/phyp/phyp_driver.c (phypDomainGetXMLDesc): Likewise.
* src/test/test_driver.c (testDomainGetXMLDesc): Likewise.
* src/vmware/vmware_driver.c (vmwareDomainGetXMLDesc): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainGetXMLDesc): Likewise.
2011-07-15 12:22:20 -06:00
Eric Blake
37754a74bb maint: fix typos
Our XML prefers "shareable" over "sharable".

* docs/internals/locking.html.in: s/sharable/shareable/
* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockAddResource): Likewise.
2011-07-15 12:15:04 -06:00
Daniel P. Berrange
c8771867b8 Fix error message for missing TLS write function
* src/rpc/virnettlscontext.c: s/read/write/
2011-07-15 16:26:11 +01:00
Daniel P. Berrange
f2845177e2 Fix reporting of cert validation failures
If the server succesfully validates the client cert, it will send
back a single byte, under TLS. If it fails, it will close the
connection. In this case, we were just reporting the standard
I/O error. The original RPC code had a special case hack for the
GNUTLS_E_UNEXPECTED_PACKET_LENGTH error code to make us report
a more useful error message

* src/rpc/virnetclient.c: Return ENOMSG if we get
  GNUTLS_E_UNEXPECTED_PACKET_LENGTH
* src/rpc/virnettlscontext.c: Report cert failure if we
  see ENOMSG
2011-07-15 16:26:07 +01:00
Dave Allan
618b55220a Fix error code for storage operations
Many volume operations will fail if the volume in question is being
allocated.  These operations were returning VIR_ERR_INTERNAL_ERROR
when they should be returning VIR_ERR_OPERATION_INVALID.
2011-07-15 08:35:25 -06:00
Taku Izumi
c147b93739 setvcpus: extend qemuDomainSetVcpusFlags() to support current flag
This patch extends qemudDomainSetVcpusFlags() function to support
VIR_DOMAIN_AFFECT_CURRENT flag.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
2011-07-15 08:19:24 -06:00
Taku Izumi
ceb0ed5d97 setvcpus: extend virDomainSetVcpusFlags API to support current flag
This patch extends virDomainSetVcpusFlags API to support
VIR_DOMAIN_AFFECT_CURRENT flag.

Now because most APIs accept VIR_DOMAIN_AFFECT_CURRENT flags,
virDomainSetVcpusFlags API should also do.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
2011-07-15 08:19:24 -06:00
Daniel P. Berrange
cf81318cb7 Add domain events support to UML driver
* src/uml_conf.h: Add queue for dispatch of domain events
* src/uml_driver.c: Trigger domain events upon important lifecycle transitions
2011-07-15 14:13:20 +01:00
Eric Blake
a59a99f218 virnetsocket: use new API for uniform child cleanup
Rather than trying to clean up the ssh child ourselves, and risk
subtle differences from the socket creation error path, we can
just use the new APIs.

* src/rpc/virnetsocket.c (virNetSocketFree): Use new function.
2011-07-14 12:02:25 -06:00
Eric Blake
3cbf5d5f76 fdstream: avoid child process leak on error
By requesting the pid in virCommandRunAsync, fdstream was claiming
that it would manually wait for the process.  But on the failure
path, the child process was being leaked.

* src/fdstream.c (virFDStreamOpenFileInternal): Auto-reap child.
2011-07-14 12:00:13 -06:00
Eric Blake
e208c38b49 command: introduce virPidWait, virPidAbort
When using virCommandRunAsync and saving the pid for later, it
is useful to be able to reap that pid in the same way that it
would have been auto-reaped by virCommand if we had passed
NULL for the pid argument in the first place.

* src/util/command.c (virPidWait, virPidAbort): New functions,
created from...
(virCommandWait, virCommandAbort): ...bodies of these.
(includes): Drop duplicate <stdlib.h>.  Ensure that our pid_t
assumptions hold.
(virCommandRunAsync): Improve documentation.
* src/util/command.h (virPidWait, virPidAbort): New prototypes.
* src/libvirt_private.syms: Export them.
* docs/internals/command.html.in: Document them.
2011-07-14 11:56:30 -06:00
Jamie Strandboge
3d7320403b update apparmor security driver for new udev paths
In the Ubuntu development release we recently got a new udev that
moves /var/run to /run, /var/lock to /run/lock and /dev/shm to /run/shm.
This change in udev requires updating the apparmor security driver in
libvirt[1].

Attached is a patch that:
 * adjusts src/security/virt-aa-helper.c to allow both
LOCALSTATEDIR/run/libvirt/**/%s.pid and /run/libvirt/**/%s.pid. While
the profile is not as precise, LOCALSTATEDIR/run/ is typically a symlink
to /run/ anyway, so there is no additional access (remember that
apparmor resolves symlinks, which is why this is still required even
if /var/run points to /run).
 * adjusts example/apparmor/libvirt-qemu paths for /dev/shm

[1]https://launchpad.net/bugs/810270

--
Jamie Strandboge             | http://www.canonical.com
2011-07-14 11:41:48 -06:00
Matthias Bolte
2682731d24 xenapi: Improve error reporting in xenapiOpen
Use better suited error code and avoid NULL in error messsage
as *privP->session->error_description can be NULL.
2011-07-14 17:51:21 +02:00
Eric Blake
3fbc761552 build: check for virnetprotocol on-the-wire stability
Similar to the recent qemu_protocol-structs addition.

* src/virnetprotocol-structs: New file.
* src/Makefile.am (%_protocol-structs): Factor body...
(PDWTAGS): ...into new helper macro.
(virnetprotocol-structs): New rule.
(PROTOCOL_STRUCTS): Add virnetprotocol-structs.
2011-07-14 09:25:41 -06:00
Michal Privoznik
85aa40e26d storage: Avoid memory leak on metadata fetching
Getting metadata on storage allocates a memory (path) which need to
be freed after use otherwise it gets leaked. This means after use of
virStorageFileGetMetadataFromFD or virStorageFileGetMetadata one
must call virStorageFileFreeMetadata to free it. This function frees
structure internals and structure itself.
2011-07-14 16:39:42 +02:00
Jiri Denemark
c3fd09f7b7 qemu: Don't overwrite errors by closefd in error paths
When qemuMonitorCloseFileHandle is called in error path, we need to
preserve the original error since a possible further error when running
closefd monitor command is not very useful to users.
2011-07-14 16:10:17 +02:00
Jiri Denemark
5169e5ea38 qemu: Save domain status ASAP after creating qemu process
When creating new qemu process we saved domain status XML only after the
process was fully setup and running. In case libvirtd was killed before
the whole process finished, once libvirtd started again it didn't know
anything about the new process and we end up with an orphaned qemu
process. Let's save the domain status XML as soon as we know the PID so
that libvirtd can kill the process on restart.
2011-07-14 16:10:17 +02:00
Eric Blake
088473b29f build: avoid ATTRIBUTE_UNUSED in headers
The compiler might optimize based on our declaration that something
is unused.  Putting that declaration in the header risks getting
out of sync with the actual implementation, so it belongs better
only in the .c files.  We were mostly compliant, and a new syntax
check will help us in the future.

* cfg.mk (sc_avoid_attribute_unused_in_header): New syntax check.
* src/nodeinfo.h (nodeGetCPUStats, nodeGetMemoryStats): Delete
attribute already present in .c file.
* src/qemu/qemu_domain.h (qemuDomainEventFlush): Likewise.
* src/util/virterror_internal.h (virReportErrorHelper): Parameters
are actually used by .c file.
* src/xenxs/xen_sxpr.h (xenFormatSxprDisk): Adjust prototype.
* src/xenxs/xen_sxpr.c (xenFormatSxprDisk): Delete unused argument.
(xenFormatSxpr): Adjust caller.
* src/xen/xend_internal.c (xenDaemonAttachDeviceFlags)
(xenDaemonUpdateDeviceFlags): Likewise.
Suggested by Daniel Veillard.
2011-07-14 07:51:30 -06:00
Eric Blake
3349f2bb65 remote: prefer unsigned flags
* src/remote/remote_driver.c (call, remoteOpenSecondaryDriver):
Prefer unsigned flags.
2011-07-14 07:34:38 -06:00
Eric Blake
553115d3ca conf: delete unused flags arguments
For static functions not used as callbacks, there's no need to
keep an unused parameter.

* src/conf/domain_conf.c (virDomainChrDefParseTargetXML)
(virDomainTimerDefParseXML, virDomainHostdevSubsysUsbDefParseXML)
(virDomainVcpuPinDefParseXML): Drop unused parameter.
(virDomainChrDefParseXML, virDomainDefParseXML)
(virDomainHostdevDefParseXML): Update callers.
(virDomainNetDefParseXML): Mark flags used.
2011-07-14 07:34:38 -06:00
Jiri Denemark
3e75c5ec85 util: Avoid duplicating virFileOpenAsNoFork in virFileOpenAs
In 2f4d2496a8 I didn't notice that one
part of virFileOpenAs doesn't actually call to virFileOpenAsNoFork but
rather includes a copy of the code from there.
2011-07-14 11:04:16 +08:00
Eric Blake
ff98359d51 build: don't hand-roll cloexec code
No need to repeat common code.

* bootstrap.conf (gnulib_modules): Import calloc-posix.
* src/util/bridge.c (brInit): Use virSetCloseExec.
(brSetInterfaceUp): Adjust flags name.
* src/uml/uml_driver.c (umlSetCloseExec): Delete.
(umlStartVMDaemon): Use util version instead.
2011-07-13 17:44:08 -06:00
Eric Blake
e17d3e7fe7 conf: prefer unsigned flags
* src/conf/cpu_conf.h (virCPUDefFormat, virCPUDefFormatBuf):
Change flags type.
* src/conf/cpu_conf.c (virCPUDefFormat, virCPUDefFormatBuf):
Likewise.
* src/conf/storage_conf.c (_virStoragePoolOptions): Likewise.
* src/datatypes.h (_virConnect, _virStream): Likewise.
2011-07-13 17:05:10 -06:00
Eric Blake
52a12382b6 node_device: avoid implicit int
'unsigned a' and 'unsigned int a' are synonyms, but we generally
always spell out the 'int' in that case.  Fixing this will avoid
a false positive in the next syntax-check commit.

* src/conf/node_device_conf.h (pci_config_address)
(_virNodeDevCapsDef): Prefer 'unsigned int' over 'unsigned'.
2011-07-13 17:05:10 -06:00
Eric Blake
4ba3faac2c xenapi: reject unknown flags
* src/xenapi/xenapi_driver.c (xenapiOpen, xenapiDomainReboot):
Reject unknown flags.
(xenapiDomainGetXMLDesc): Likewise, and pass known flags through
to XML generation.
2011-07-13 17:01:28 -06:00
Eric Blake
8cf1b7fc86 vmware: reject unknown flags
* src/vmware/vmware_driver.c (vmwareOpen, vmwareDomainReboot)
(vmwareDomainCreateXML, vmwareDomainCreateWithFlags): Reject
unknown flags.
2011-07-13 16:54:24 -06:00
Eric Blake
8d173c47b7 vbox: reject unknown flags
* src/vbox/vbox_driver.c (vboxOpenDummy): Reject unknown flags.
* src/vbox/vbox_tmpl.c (vboxOpen, vboxDomainReboot)
(vboxNetworkOpen, vboxNetworkGetXMLDesc, vboxStorageOpen)
(vboxStorageVolCreateXML, vboxStorageVolDelete)
(vboxStorageVolGetXMLDesc, vboxDomainScreenshot): Likewise.
2011-07-13 16:40:07 -06:00
Eric Blake
2bcad36889 uml: reject unknown flags
* src/uml/uml_driver.c (umlOpen, umlDomainGetXMLDesc)
(umlDomainBlockPeek): Reject unknown flags.
2011-07-13 15:10:42 -06:00
Eric Blake
e8f03b8fb6 test: reject unknown flags
* src/test/test_driver.c (testOpen, testDomainCoreDump)
(testOpenNetwork, testNetworkGetXMLDesc, testOpenInterface)
(testInterfaceChangeBegin, testInterfaceChangeCommit)
(testInterfaceChangeRollback, testInterfaceGetXMLDesc)
(testInterfaceDefineXML, testInterfaceCreate)
(testInterfaceDestroy, testStorageOpen, testStoragePoolStart)
(testStorageFindPoolSources, testStoragePoolCreate)
(testStoragePoolDefine, testStoragePoolBuild)
(testStoragePoolDelete, testStoragePoolRefresh)
(testStoragePoolGetXMLDesc, testStorageVolumeCreateXML)
(testStorageVolumeCreateXMLFrom, testStorageVolumeDelete)
(testStorageVolumeGetXMLDesc, testDevMonOpen)
(testNodeNumOfDevices, testNodeListDevices)
(testNodeDeviceGetXMLDesc, testNodeDeviceCreateXML)
(testSecretOpen, testNWFilterOpen): Reject unknown flags.
2011-07-13 14:52:45 -06:00
Eric Blake
f548480b7f qemu: reject unknown flags
* src/qemu/qemu_driver.c (qemudOpen, qemuDomainScreenshot)
(qemuDomainXMLFromNative, qemuDomainXMLToNative)
(qemudDomainBlockPeek, qemuCPUCompare, qemuCPUBaseline): Reject
unknown flags.
* src/qemu/qemu_migration.c (qemuMigrationConfirm): Likewise.
(_qemuMigrationCookie, qemuMigrationCookieXMLParse)
(qemuMigrationCookieXMLParseStr, qemuMigrationBakeCookie)
(qemuMigrationEatCookie): Make flags unsigned.
* src/qemu/qemu_domain.h: (qemuDomainDefFormatXML)
(qemuDomainFormatXML): Prefer unsigned flags.
* src/qemu/qemu_domain.c (qemuDomainDefFormatXML)
(qemuDomainFormatXML): Likewise.
(qemuDomainOpenLogHelper, qemuDomainCreateLog): Rename variable.
2011-07-13 14:44:09 -06:00
Eric Blake
76f40fa55f phyp: reject unknown flags
* src/phyp/phyp_driver.c (phypOpen, phypDomainReboot)
(phypVIOSDriverOpen): Reject unknown flags.
2011-07-13 14:44:09 -06:00
Eric Blake
8ef4fe1425 openvz: reject unknown flags
* src/openvz/openvz_driver.c (openvzDomainReboot, openvzOpen):
Reject unknown flags.
2011-07-13 14:44:08 -06:00
Eric Blake
5037cea55e lxc: reject unknown flags
* src/lxc/lxc_driver.c (lxcOpen, lxcDomainSetMemoryParameters)
(lxcDomainGetMemoryParameters): Reject unknown flags.
* src/lxc/lxc_container.c (lxcContainerStart): Rename flags to
cflags to reflect that it is not tied to libvirt.
2011-07-13 14:42:05 -06:00
Eric Blake
9110941cfd libxl: reject unknown flags
* src/libxl/libxl_driver.c (libxlOpen, libxlDomainReboot)
(libxlDomainXMLFromNative, libxlDomainXMLToNative)
(libxlDomainCreateWithFlags): Reject unknown flags.
2011-07-13 14:22:03 -06:00
Peter Krempa
36caaddde6 qemu: build failed due to unused variables
While compiling on F15 build crashed (probably because of new GCC).
2011-07-13 11:22:28 -06:00
Eric Blake
64bd1b9dd5 storage: reject unknown flags
* src/storage/storage_backend.c (virStorageBackendCreateBlockFrom)
(virStorageBackendCreateQemuImg)
(virStorageBackendCreateQcowCreate): Reject unknown flags.
* src/storage/storage_backend_disk.c (virStorageBackendDiskBuildPool)
(virStorageBackendDiskDeleteVol): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources)
(virStorageBackendFileSystemBuild)
(virStorageBackendFileSystemDelete, createFileDir)
(virStorageBackendFileSystemVolBuildFrom)
(virStorageBackendFileSystemVolDelete): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSIFindPoolSources): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalFindPoolSources)
(virStorageBackendLogicalBuildPool)
(virStorageBackendLogicalDeletePool)
(virStorageBackendLogicalDeleteVol): Likewise.
* src/storage/storage_driver.c (storageOpen, storagePoolCreate)
(storagePoolDefine, storagePoolRefresh, storagePoolGetXMLDesc)
(storageVolumeCreateXML, storageVolumeCreateXMLFrom)
(storageVolumeGetXMLDesc): Likewise.
2011-07-13 09:04:54 -06:00
Eric Blake
ba78d2cf89 node_device: reject unknown flags
* src/node_device/node_device_driver.c (nodeNumOfDevices)
(nodeListDevices, nodeDeviceGetXMLDesc, nodeDeviceCreateXML):
Reject unknown flags.
* src/node_device/node_device_hal.c (halNodeDrvOpen): Likewise.
* src/node_device/node_device_udev.c (udevNodeDrvOpen): Likewise.
2011-07-13 09:04:54 -06:00
Eric Blake
833fe8abec util: reject unknown flags, and prefer unsigned flags
Silently ignored flags get in the way of new features that
use those flags.  Also, an upcoming syntax check will favor
unsigned flags.

* src/nodeinfo.h (nodeGetCPUStats, nodeGetMemoryStats): Drop
unused attribute.
* src/interface/netcf_driver.c (interfaceOpenInterface)
(interfaceDefineXML, interfaceCreate, interfaceDestroy): Reject
unknown flags.
* src/network/bridge_driver.c (networkOpenNetwork)
(networkGetXMLDesc): Likewise.
* src/nwfilter/nwfilter_driver.c (nwfilterOpen): Likewise.
* src/secret/secret_driver.c (secretOpen, secretDefineXML)
(secretGetXMLDesc, secretSetValue): Likewise.
* src/util/logging.c (virLogDefineFilter, virLogDefineOutput)
(virLogMessage): Likewise; also use unsigned flags.
* src/util/logging.h (virLogDefineFilter, virLogDefineOutput)
(virLogMessage): Change signature.
* src/util/command.c (virExecWithHook): Likewise.
2011-07-13 09:04:54 -06:00
Eric Blake
01ed9b56d1 libvirt-qemu: use unsigned flags
Like commit 1740c381, but for libvirt-qemu.

* src/remote/qemu_protocol.x (qemu_monitor_command_args): Adjust
type to match API.
* src/qemu_protocol-structs: Update accordingly.
2011-07-13 08:48:09 -06:00
Eric Blake
06dbfa6d21 maint: print flags in hex during debug
Continuation of commit 313ac7fd, and enforce things with a syntax
check.

Technically, virNetServerClientCalculateHandleMode is not printing
a mode_t, but rather a collection of VIR_EVENT_HANDLE_* bits;
however, these bits are < 8, so there is no different in the
output, and that was the easiest way to silence the new syntax check.

* cfg.mk (sc_flags_debug): New syntax check.
(exclude_file_name_regexp--sc_flags_debug): Add exemptions.
* src/fdstream.c (virFDStreamOpenFileInternal): Print flags in
hex, mode_t in octal.
* src/libvirt-qemu.c (virDomainQemuMonitorCommand)
(virDomainQemuAttach): Likewise.
* src/locking/lock_driver_nop.c (virLockManagerNopInit): Likewise.
* src/locking/lock_driver_sanlock.c (virLockManagerSanlockInit):
Likewise.
* src/locking/lock_manager.c: Likewise.
* src/qemu/qemu_migration.c: Likewise.
* src/qemu/qemu_monitor.c: Likewise.
* src/rpc/virnetserverclient.c
(virNetServerClientCalculateHandleMode): Print mode with %o.
2011-07-13 07:47:45 -06:00
Eric Blake
51fc56553f util: honor anchored names when searching for executables
I got bit in a debugging session on an uninstalled libvirtd; the
code tried to call out to the installed $LIBEXECDIR/libvirt_iohelper
instead of my just-built version.  So I set a breakpoint and altered
the binary name to be "./src/libvirt_iohelper", and it still failed
because I don't have "." on my PATH.

According to POSIX, execvp only searches PATH if the name does
not contain a slash.  Since we are trying to mimic that behavior,
an anchored name should be relative to the current working dir.

This tightens existing behavior, but most callers already pass
an absolute name or a name with no slashes, so it probably won't
be noticeable.

* src/util/util.c (virFindFileInPath): Anchored relative names do
not invoke a PATH search.
2011-07-13 07:30:42 -06:00
Daniel P. Berrange
83d768fab8 Ensure signal handler propagates fatal signals to default handler
When replacing the default SEGV/ABORT/BUS signal handlers you
can't rely on the process being terminated after your custom
handler runs. It is neccessary to manually restore the default
handler and then re-raise the signal

* src/rpc/virnetserver.c: Restore default handler and raise
  signal
2011-07-13 11:47:12 +01:00
Daniel P. Berrange
1a81687ad2 Remove unused virNetServerProgramErrorHander typedef
* src/rpc/virnetserverprogram.h: Remove unused typedef for
  virNetServerProgramErrorHander function callback
* daemon/remote.h: Remove decl for non-existant variables
2011-07-13 11:47:01 +01:00
Jiri Denemark
a23476f0db qemu: Fix monitor unlocking in some error paths
When monitor is entered with qemuDomainObjEnterMonitorWithDriver, the
correct method for leaving and unlocking the monitor is
qemuDomainObjExitMonitorWithDriver.
2011-07-13 01:53:32 +02:00
Jiri Denemark
307656b48a qemu: Consolidate qemuMigrationPrepare{Direct,Tunnel}
Most of the code in these two functions is supposed to be identical but
currently it isn't (which is natural since the code is duplicated).
Let's move common parts of these functions into qemuMigrationPrepareAny.

This also fixes qemuMigrationPrepareTunnel which didn't store received
lockState in the domain object.
2011-07-13 01:53:32 +02:00
Jiri Denemark
5b2d0bbc4c qemu: Add support for job phase
Asynchronous jobs may take long time to finish and may consist of
several phases which we need to now about to help with recovery/rollback
after libvirtd restarts.
2011-07-13 01:53:32 +02:00
Jiri Denemark
e6704af1fc qemu: Recover from interrupted jobs
Detect and react on situations when libvirtd was restarted or killed
when a job was active.
2011-07-13 01:53:32 +02:00
Jiri Denemark
ff340a84b8 qemu: Save job type in domain status XML
If libvirtd is restarted when a job is running, the new libvirtd process
needs to know about that to be able to recover and rollback the
operation.
2011-07-13 01:53:32 +02:00
Jiri Denemark
361842881e qemu: Allow all query commands to be run during long jobs
Query commands are safe to be called during long running jobs (such as
migration). This patch makes them all work without the need to
special-case every single one of them.

The patch introduces new job.asyncCond condition and associated
job.asyncJob which are dedicated to asynchronous (from qemu monitor
point of view) jobs that can take arbitrarily long time to finish while
qemu monitor is still usable for other commands.

The existing job.active (and job.cond condition) is used all other
synchronous jobs (including the commands run during async job).

Locking schema is changed to use these two conditions. While asyncJob is
active, only allowed set of synchronous jobs is allowed (the set can be
different according to a particular asyncJob) so any method that
communicates to qemu monitor needs to check if it is allowed to be
executed during current asyncJob (if any). Once the check passes, the
method needs to normally acquire job.cond to ensure no other command is
running. Since domain object lock is released during that time, asyncJob
could have been started in the meantime so the method needs to recheck
the first condition. Then, normal jobs set job.active and asynchronous
jobs set job.asyncJob and optionally change the list of allowed job
groups.

Since asynchronous jobs only set job.asyncJob, other allowed commands
can still be run when domain object is unlocked (when communicating to
remote libvirtd or sleeping). To protect its own internal synchronous
commands, the asynchronous job needs to start a special nested job
before entering qemu monitor. The nested job doesn't check asyncJob, it
only acquires job.cond and sets job.active to block other jobs.
2011-07-13 01:53:21 +02:00
Jiri Denemark
24f717ac22 qemu: Consolidate {Enter,Exit}Monitor{,WithDriver}
EnterMonitor and ExitMonitor methods are very similar to their
*WithDriver variants; consolidate them into EnterMonitorInternal and
ExitMonitorInternal to avoid (mainly future) code duplication.
2011-07-12 21:17:28 +02:00
Jiri Denemark
cec1d280ad qemu: Consolidate BeginJob{,WithDriver} into a single method
This avoids code duplication and also avoids relying on good luck that
ignore_value(virDomainObjUnref(obj)) doesn't set errno.
2011-07-12 21:17:28 +02:00
Jiri Denemark
90a422f071 qemu: Separate job related data into a new object 2011-07-12 21:17:28 +02:00
Daniel P. Berrange
65d68f62f1 Add missing cleanup for transient guests in UML driver
The UML inotify handler would kill off guests when certain
conditions arise, but it forgot to remove transient guests
from the list of domains

* src/uml/uml_driver.c: Cleanup transient guests
2011-07-12 17:05:30 +01:00
Daniel P. Berrange
f0c7103db5 Add auditing to the UML driver
* src/uml/uml_driver.c: Add audit hooks
2011-07-12 17:05:30 +01:00
Daniel P. Berrange
7d612c3059 Add auditing to the LXC driver
* src/lxc/lxc_driver.c: Add auditing hooks
2011-07-12 17:05:30 +01:00
Daniel P. Berrange
839f47b57f Add virtualization type in audit messages
Since a host can run several different virtualization types at
the same time, audit messages should allow domains to be identified.
Add a 'virt={qemu,kvm,uml,lxc,...}' key to domain audit messages

* src/conf/domain_audit.c: Identify virt type of guest
2011-07-12 17:05:30 +01:00
Daniel P. Berrange
e6e90c8d70 Add auditing of filesystems
When passing through filesystems from the host to a guest, the
host filesystem passed must be audited

* src/conf/domain_audit.{c,h}: Add virDomainAuditFS
2011-07-12 17:05:30 +01:00
Daniel P. Berrange
b43070ebfc Move qemu_audit.h helpers into shared code
The LXC and UML drivers can both make use of auditing. Move
the qemu_audit.{c,h} files to src/conf/domain_audit.{c,h}

* src/conf/domain_audit.c: Rename from src/qemu/qemu_audit.c
* src/conf/domain_audit.h: Rename from src/qemu/qemu_audit.h
* src/Makefile.am: Remove qemu_audit.{c,h}, add domain_audit.{c,h}
* src/qemu/qemu_audit.h, src/qemu/qemu_cgroup.c,
  src/qemu/qemu_command.c, src/qemu/qemu_driver.c,
  src/qemu/qemu_hotplug.c, src/qemu/qemu_migration.c,
  src/qemu/qemu_process.c: Update for changed audit API names
2011-07-12 17:05:25 +01:00
Matthias Bolte
38ea116eba esx: Initialize all instances of esxVMX_Data to zero
To avoid using or freeing uninitialized memory or pointers.
2011-07-12 17:08:36 +02:00
Matthias Bolte
b253452942 rpc: Fix compile error due to potentially unused parameter
connectDBus is only used if HAVE_DBUS is set. Therefore mark
it as potentially unused.
2011-07-12 17:06:16 +02:00
Jim Fehlig
b8adfcc60c Fix build when using polkit0
V2: Remove policy kit references from virNetServer and use DBus APIs
    directly, if available.
2011-07-12 08:44:55 -06:00
Daniel P. Berrange
109efd7941 Implement code to attach to external QEMU instances.
Given a PID, the QEMU driver reads /proc/$PID/cmdline and
/proc/$PID/environ to get the configuration. This is fed
into the ARGV->XML convertor to build an XML configuration
for the process.

/proc/$PID/exe is resolved to identify the full command
binary path

After checking for name/uuid uniqueness, an attempt is
made to connect to the monitor socket. If successful
then 'info status' and 'info kvm' are issued to determine
whether the CPUs are running and if KVM is enabled.

* src/qemu/qemu_driver.c: Implement virDomainQemuAttach
* src/qemu/qemu_process.h, src/qemu/qemu_process.c: Add
  qemuProcessAttach to connect to the monitor of an
  existing QEMU process
2011-07-12 15:39:04 +01:00
Daniel P. Berrange
7760eaa050 Add monitor API for checking whether KVM is enabled
When attaching to an external QEMU process, it is neccessary
to check if the process is using KVM or not. This can be done
using a monitor command

* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
  API for checking if KVM is enabled
2011-07-12 15:39:04 +01:00
Daniel P. Berrange
80a4ee4695 Add a method for extracting QEMU argv from /proc
To enable attaching to externally launched QEMU, we need
to be able to reverse engineer a guest XML config based
on the argv for a PID in /proc

* src/qemu/qemu_command.c, src/qemu/qemu_command.h: Add
  qemuParseCommandLinePid which extracts QEMU config from
  argv in /proc, given a PID number
2011-07-12 15:39:04 +01:00
Daniel P. Berrange
ebbae359ff Change extract pidfile & monitor config from QEMU command line
When converting QEMU argv into a virDomainDefPtr, also extract
the pidfile, monitor character device config and the monitor
mode.

* src/qemu/qemu_command.c, src/qemu/qemu_command.h: Extract
  pidfile & monitor config from QEMU argv
* src/qemu/qemu_driver.c, tests/qemuargv2xmltest.c: Add extra
  params when calling qemuParseCommandLineString
2011-07-12 15:39:04 +01:00
Daniel P. Berrange
accfe952eb Keep pidfile path in qemuDomainObjPrivate struct
Avoid re-formatting the pidfile path everytime we need it. Create
it once when starting the guest, and preserve it until the guest
is shutdown.

* src/libvirt_private.syms, src/util/util.c,
  src/util/util.h: Add virFileReadPidPath
* src/qemu/qemu_domain.h: Add pidfile field
* src/qemu/qemu_process.c: Store pidfile path in qemuDomainObjPrivate
2011-07-12 15:39:03 +01:00
Daniel P. Berrange
4403646001 Define remote wire protocol & impls for virDomainQemuAttach
This tweaks the RPC generator to cope with some naming
conventions used for the QEMU specific APIs

* daemon/remote.c: Server side dispatcher
* src/remote/remote_driver.c: Client side dispatcher
* src/remote/qemu_protocol.x: Wire protocol definition
* src/rpc/gendispatch.pl: Use '$structprefix' in method
  names, fix QEMU flags and fix dispatcher method names
2011-07-12 15:39:03 +01:00
Daniel P. Berrange
639f841346 Define a QEMU specific API to attach to a running QEMU process
Introduce a new API in libvirt-qemu.so

 virDomainPtr virDomainQemuAttach(virConnectPtr domain,
                                  unsigned long long pid,
                                  unsigned int flags);

This allows libvirtd to attach to an existing, externally
launched QEMU process. This is useful for QEMU developers who
prefer to launch QEMU themselves for debugging/devel reasons,
but still want the benefit of libvirt based tools like
virt-top, virt-viewer, etc

* include/libvirt/libvirt-qemu.h: Define virDomainQemuAttach
* src/driver.h, src/libvirt-qemu.c, src/libvirt_qemu.syms:
  Driver glue for virDomainQemuAttach
2011-07-12 15:39:03 +01:00
Alex Jia
9c5b190017 qemu: update configuration file
* src/qemu/qemu.conf: Add blkio controller into qemu.conf.
2011-07-12 07:24:43 -06:00
Eric Blake
f532bfa297 qemu: avoid fd leak on core dump failure
* src/qemu/qemu_driver.c (doCoreDump): Guarantee fd is closed.
2011-07-12 07:24:43 -06:00
Eric Blake
2ceb35e1cd maint: rename virtaudit to match file contents
* src/util/virtaudit.[ch]: Rename...
* src/util/viraudit.[ch]: ...to match virAudit* API.
* src/Makefile.am (UTIL_SOURCES): Reflect rename.
* daemon/libvirtd.c: Likewise.
* po/POTFILES.in: Likewise.
* src/libvirt_private.syms: Likewise.
* src/qemu/qemu_audit.c: Likewise.
2011-07-12 07:24:43 -06:00
Oskari Saarenmaa
9a0e6a8fae remote/ssh: support for no_verify.
Set StrictHostKeyChecking=no to auto-accept new ssh host keys if the
no_verify extra parameter was specified.  This won't disable host key
checking for already known hosts.  Includes a test and documentation.
2011-07-12 15:09:05 +02:00
Michal Privoznik
d50bb45b1a domain_conf: Free temporary variable
* src/conf/domain_conf.c: caller must free returned value of
  virXPathString in useserial
2011-07-12 17:25:36 +08:00
Osier Yang
6ddb83efcc esx: Fix a potential crash
Initialize ptr data.datastorePathWithoutFileName as NULL, otherwise
it might cause crash when trying to free it in cleanup.
2011-07-12 17:23:35 +08:00
Eric Blake
62dee6fa48 build: also check qemu_protocol for on-the-wire stability
Since we are going to add some libvirt-qemu.so entry points in
0.9.4, we might as well start checking for RPC stability, just
as for libvirt.so.

* src/Makefile.am (PROTOCOL_STRUCTS): New variable.
(remote_protocol-structs): Rename...
(%_protocol-structs): ...and make more generic.
* src/qemu_protocol-structs: New file.
2011-07-11 17:48:32 -06:00
Eric Blake
df94811f71 build: avoid requiring -lm
log2() is heavy when ffs() can do the same thing.  But ffs()
requires gnulib support for mingw.

This patch solves this linker error on Fedora 14.

/usr/bin/ld: libvirt_lxc-domain_conf.o: undefined reference to symbol 'log2@@GLIBC_2.2.5'
/usr/bin/ld: note: 'log2@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line
/lib64/libm.so.6: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

* .gnulib: Update to latest, for ffs.
* bootstrap.conf (gnulib_modules): Import ffs.
* src/conf/domain_conf.c (virDomainDefParseXML): Use ffs instead
of log2.
Reported by Dave Allan.
2011-07-11 17:32:11 -06:00
Matthias Bolte
aa14709a47 Add domain type checking
The drivers were accepting domain configs without checking if those
were actually meant for them. For example the LXC driver happily
accepts configs with type QEMU.

Add a check for the expected domain types to the virDomainDefParse*
functions.
2011-07-11 19:38:51 +02:00
Alex Jia
7518ad753f remote: Fix memory leak
Detected in valgrind run:

==9184== 1 bytes in 1 blocks are definitely lost in loss record 1 of 19
==9184==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184==    by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184==    by 0x4CF97C9: xdr_remote_domain_get_security_label_ret (remote_protocol.c:1696)
==9184==    by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184==    by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184==    by 0x4CE3887: call (remote_driver.c:3933)
==9184==    by 0x4CF71C6: remoteDomainGetSecurityLabel (remote_driver.c:1580)
==9184==    by 0x4CCA480: virDomainGetSecurityLabel (libvirt.c:7340)
==9184==    by 0x41993A: cmdDominfo (virsh.c:2414)
==9184==    by 0x411E92: vshCommandRun (virsh.c:12730)
==9184==    by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== 2 bytes in 1 blocks are definitely lost in loss record 2 of 19
==9184==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184==    by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184==    by 0x4CF974F: xdr_remote_node_get_security_model_ret (remote_protocol.c:1713)
==9184==    by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184==    by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184==    by 0x4CE3887: call (remote_driver.c:3933)
==9184==    by 0x4CF6F96: remoteNodeGetSecurityModel (remote_driver.c:1648)
==9184==    by 0x4CBF799: virNodeGetSecurityModel (libvirt.c:7382)
==9184==    by 0x4197D7: cmdDominfo (virsh.c:2394)
==9184==    by 0x411E92: vshCommandRun (virsh.c:12730)
==9184==    by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== 8 bytes in 1 blocks are definitely lost in loss record 3 of 19
==9184==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184==    by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184==    by 0x4CF9729: xdr_remote_node_get_security_model_ret (remote_protocol.c:1710)
==9184==    by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184==    by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184==    by 0x4CE3887: call (remote_driver.c:3933)
==9184==    by 0x4CF6F96: remoteNodeGetSecurityModel (remote_driver.c:1648)
==9184==    by 0x4CBF799: virNodeGetSecurityModel (libvirt.c:7382)
==9184==    by 0x4197D7: cmdDominfo (virsh.c:2394)
==9184==    by 0x411E92: vshCommandRun (virsh.c:12730)
==9184==    by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== LEAK SUMMARY:
==9184==    definitely lost: 11 bytes in 3 blocks

* src/remote/remote_driver.c: Avoid leak on remoteDomainGetSecurityLabel
  and remoteNodeGetSecurityModel.
2011-07-11 09:50:07 -06:00
Jim Fehlig
eb3143154e Do not drop kernel cmdline for xen pv domains
Kernel cmdline args can be passed to xen pv domains even when a
bootloader is specified.  The current config-to-sxpr mapping
ignores cmdline when bootloader is present.

Since the xend sub-driver is used with many xen toolstack versions,
this patch takes conservative approach of adding an else block to
existing !def->os.bootloader, and only appends sxpr if def->os.cmdline
is non-NULL.

V2: Fix existing testcase broken by this patch and add new testcases
2011-07-11 09:11:15 -06:00
Wen Congyang
8a8b45b889 kill vm if saving config failed in v3 protocol
If virDomainSaveConfig() failed, we will return NULL to source,
and the vm is still available to restart during confirm() step in
v3 protocol. So we should kill it off in qemuMigrationFinish().

In v2 protocol, we should not set vm to NULL, because we hold
a reference of vm and should unrefernce it.
2011-07-11 20:53:35 +08:00
Wen Congyang
586765fb65 RPC: fix argument's name 2011-07-11 20:53:29 +08:00
Michal Privoznik
874e65aa15 bios: Add support for SGA
This patch creates new <bios> element which, at this time has only the
attribute useserial='yes|no'. This attribute allow users to use
Serial Graphics Adapter and see BIOS messages from the very first moment
domain boots up. Therefore, users can choose boot medium, set PXE, etc.
2011-07-11 11:47:14 +02:00
Matthias Bolte
1428029738 vbox: Fix logic in storage driver open function
If the main driver is the vbox driver, then the open function
has to return an error if the private data is invalid.
2011-07-09 15:52:14 +02:00
Matthias Bolte
6ca8d68d70 rpc: Fix whitespace problem in generated code
Add missing line break and fix indention level.

Reported by Cole Robinson.
2011-07-09 00:10:04 +02:00
Federico Simoncelli
de2aa6cfc7 sanlock: avoid lockspace setup when auto_disk_lease is off
When auto_disk_lease is off we should avoid the automatic lockspace
creation.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
2011-07-08 14:49:10 -06:00
Michael Santos
b0b85c454c qemu: clean up OOM checks 2011-07-08 09:39:23 -06:00
Daniel P. Berrange
3cfdc57b85 Fix sending of reply to final RPC message
The dispatch for the CLOSE RPC call was invoking the method
virNetServerClientClose(). This caused the client connection
to be immediately terminated. This meant the reply to the
final RPC message was never sent. Prior to the RPC rewrite
we merely flagged the connection for closing, and actually
closed it when the next RPC call dispatch had completed.

* daemon/remote.c: Flag connection for a delayed close
* daemon/stream.c: Update to use new API for closing
  failed connection
* src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h:
  Add support for a delayed connection close. Rename the
  virNetServerClientMarkClose method to virNetServerClientImmediateClose
  to clarify its semantics
2011-07-08 16:19:57 +01:00
Daniel P. Berrange
afe8839f01 Fix leak of remote driver if final 'CLOSE' RPC call fails
When closing a remote connection we issue a (fairly pointless)
'CLOSE' RPC call to the daemon. If this fails we skip all the
cleanup of private data, but the virConnectPtr object still
gets released as normal. This causes a memory leak. Since the
CLOSE RPC call is pretty pointless, just carry on freeing the
remote driver if it fails.

* src/remote/remote_driver.c: Ignore failure to issue CLOSE
  RPC call
2011-07-08 16:19:57 +01:00
Daniel P. Berrange
2c85644b0b Fix release of outgoing stream confirmation/abort message
When sending back the final OK or ERROR message on completion
of a stream, we were not decrementing the 'nrequests' tracker
on the client. With the default requests limit of '5', this
meant once a client had created 5 streams, they are unable to
process any further RPC calls.  There was also a bug when
handling an error from decoding a message length header, which
meant a client connection would not immediately be closed.

* src/rpc/virnetserverclient.c: Fix release of request after
  stream completion & mark client for close on error
2011-07-08 16:19:57 +01:00
Daniel P. Berrange
927dfcf693 Fix leak of 'msg' object in client stream code
In one exit path we forgot to free the virNetMessage object causing
a large memory leak for streams which send a lot of data. Some other
paths were calling VIR_FREE directly instead of virNetMessageFree
although this was (currently) harmless.

* src/rpc/virnetclientstream.c: Fix leak of msg object
* src/rpc/virnetclientprogram.c: Call virNetMessageFree instead
  of VIR_FREE
2011-07-08 16:19:57 +01:00
Daniel P. Berrange
c2ddd53614 Fix mistaken order of server cert/key parameters in constructor
The virNetTLSContextNew was being passed key/cert parameters in
the wrong order. This wasn't immediately visible because if
virNetTLSContextNewPath was used, a second bug reversed the order
of those parameters again.

Only if the paths were manually specified in /etc/libvirt/libvirtd.conf
did the bug appear

* src/rpc/virnettlscontext.c: Fix order of params passed to
  virNetTLSContextNew
2011-07-08 16:19:57 +01:00
Michal Privoznik
30c43afd73 graphics: add support for action_if_connected in qemu
This option accepts 3 values:
-keep, to keep current client connected (Spice+VNC)
-disconnect, to disconnect client (Spice)
-fail, to fail setting password if there is a client connected (Spice)
2011-07-08 17:00:43 +02:00
Jiri Denemark
2f4d2496a8 util: Don't try to fchown files opened as non-root
When virFileOpenAs is called with VIR_FILE_OPEN_AS_UID flag and uid/gid
different from root/root while libvirtd is running as root, we fork a
new child, change its effective UID/GID to uid/gid and run
virFileOpenAsNoFork. It doesn't make any sense to fchown() the opened
file in this case since we already know that uid/gid can access the file
when open succeeds and one of the following situations may happen:

- the file is already owned by uid/gid and we skip fchown even before
  this patch
- the file is owned by uid but not gid because it was created in a
  directory with SETGID set, in which case it is desirable not to change
  the group
- the file may be owned by a completely different user and/or group
  because it was created on a root-squashed or even all-squashed NFS
  filesystem, in which case fchown would most likely fail anyway
2011-07-08 16:43:55 +02:00
Michal Privoznik
724819a10a qemu: Don't chown files on NFS share if dynamic_ownership is off
When dynamic ownership is disabled we don't want to chown any files,
not just local.
2011-07-08 10:05:59 +02:00
John Williams
a1092070d4 microblaze: Add architecture support
Add libvirt support for MicroBlaze architecture as a QEMU target.  Based on mips/mipsel pattern.

Signed-off-by: John Williams <john.williams@petalogix.com>
2011-07-07 17:49:21 -06:00
Eric Blake
17da0669e0 util: drop unused safezero argument
No caller was using the flags argument, and this function is internal
only, so we might as well skip it.

* src/util/util.h (safezero): Update signature.
* src/util/util.c (safezero): Update function.
* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockSetupLockspace)
(virLockManagerSanlockCreateLease): Update all callers.
* src/storage/storage_backend.c (createRawFile): Likewise.
2011-07-07 14:15:38 -06:00
Eric Blake
7931639b7a conf: prefer unsigned int for flags
* src/conf/domain_conf.c (virDomainGraphicsDefParseXML)
(virDomainDeviceInfoFormat, virDomainDeviceInfoParseXML)
(virDomainDiskDefParseXML, virDomainControllerDefParseXML)
(virDomainFSDefParseXML, virDomainNetDefParseXML)
(virDomainChrDefParseTargetXML, virDomainChrDefParseXML)
(virDomainSmartcardDefParseXML, virDomainInputDefParseXML)
(virDomainTimerDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainMemballoonDefParseXML)
(virDomainVideoDefParseXML)
(virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevDefParseXML, virSecurityLabelDefParseXML)
(virDomainVcpuPinDefParseXML, virDomainDefParseXML)
(virDomainDefParse, virDomainDiskDefFormat)
(virDomainControllerDefFormat, virDomainFSDefFormat)
(virDomainNetDefFormat, virDomainChrSourceDefFormat)
(virDomainChrDefFormat, virDomainSmartcardDefFormat)
(virDomainSoundDefFormat, virDomainMemballoonDefFormat)
(virDomainWatchdogDefFormat, virDomainVideoDefFormat)
(virDomainInputDefFormat, virDomainGraphicsDefFormat)
(virDomainHostdevDefFormat, virDomainObjFormat): Switch signature.
(virDomainObjTaint, virDomainSaveStatus): Use unsigned flags.
2011-07-07 14:15:38 -06:00
Eric Blake
1740c38116 drivers: prefer unsigned int for flags
Now that the public APIs always use unsigned flags, the internal
driver callbacks might as well do likewise.

* src/driver.h (vrDrvOpen, virDrvDomainCoreDump)
(virDrvDomainGetXMLDesc, virDrvNetworkGetXMLDesc)
(virDrvNWFilterGetXMLDesc): Update type.
* src/remote/remote_protocol.x (remote_open_args)
(remote_domain_core_dump_args, remote_domain_get_xml_desc_args)
(remote_network_get_xml_desc_args)
(remote_nwfilter_get_xml_desc_args): Likewise.
* src/test/test_driver.c: Update clients.
* src/remote/remote_driver.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* src/xen/xen_hypervisor.h: Likewise.
* src/xen/xen_driver.c: Likewise.
* src/xen/xend_internal.c: Likewise.
* src/xen/xend_internal.h: Likewise.
* src/xen/xm_internal.c: Likewise.
* src/xen/xm_internal.h: Likewise.
* src/xen/xs_internal.c: Likewise.
* src/xen/xs_internal.h: Likewise.
* src/xen/xen_inotify.c: Likewise.
* src/xen/xen_inotify.h: Likewise.
* src/phyp/phyp_driver.c: Likewise.
* src/openvz/openvz_driver.c: Likewise.
* src/vmware/vmware_driver.c: Likewise.
* src/vbox/vbox_driver.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xenapi/xenapi_driver.c: Likewise.
* src/esx/esx_driver.c: Likewise.
* src/esx/esx_interface_driver.c: Likewise.
* src/esx/esx_network_driver.c: Likewise.
* src/esx/esx_storage_driver.c: Likewise.
* src/esx/esx_device_monitor.c: Likewise.
* src/esx/esx_secret_driver.c: Likewise.
* src/esx/esx_nwfilter_driver.c: Likewise.
* src/interface/netcf_driver.c: Likewise.
* src/nwfilter/nwfilter_driver.c: Likewise.
* src/libxl/libxl_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/secret/secret_driver.c: Likewise.
* src/storage/storage_driver.c: Likewise.
* src/node_device/node_device_hal.c: Likewise.
* src/node_device/node_device_udev.c: Likewise.
* src/remote_protocol-structs: Likewise.
2011-07-07 14:15:37 -06:00
Eric Blake
18d561c7a4 public API: prefer unsigned int for flags
Most APIs use 'unsigned int flags'; but a few stragglers were using
a signed value.  In particular, the vir*GetXMLDesc APIs were
split-brain, with inconsistent choice of types.  Although it is
an API break to use 'int' instead of 'unsigned int', it is ABI
compatible (pre-compiled apps will have no difference in behavior),
and generally apps can be recompiled without any issue (only rare
apps that compiled with extremely high warning levels, or which
pass libvirt API around as typed function pointers, would have to
make any code changes to deal with the change).

The migrate APIs use 'unsigned long flags', which can't be changed,
due to ABI constraints.

This patch intentionally touches only the public API, to prove the
claim that most existing code (including driver callbacks and virsh)
still compiles just fine in spite of the type change.

* include/libvirt/libvirt.h.in (virConnectOpenAuth)
(virDomainCoreDump, virDomainGetXMLDesc, virNetworkGetXMLDesc)
(virNWFilterGetXMLDesc): Use unsigned int for flags.
(virDomainHasCurrentSnapshot): Use consistent spelling.
* src/libvirt.c (virConnectOpenAuth, virDomainCoreDump)
(virDomainGetXMLDesc, virNetworkGetXMLDesc)
(virNWFilterGetXMLDesc, do_open): Update accordingly.
2011-07-07 14:15:32 -06:00