2006-03-20 17:49:28 +00:00
|
|
|
/*
|
2008-02-05 19:27:37 +00:00
|
|
|
* driver.h: description of the set of interfaces provided by a
|
2006-03-20 17:49:28 +00:00
|
|
|
* entry point to the virtualization engine
|
2013-05-14 23:42:12 +00:00
|
|
|
*
|
blockcopy: virDomainBlockCopy with XML destination, typed params
This commit (finally) adds the virDomainBlockCopy API, with the
intent that it will provide more power to the existing 'virsh
blockcopy' command.
'virsh blockcopy' was first added in Apr 2012 (v0.9.12), which
corresponds to the upstream qemu 1.2 timeframe. It was done as
a hack on top of the existing virDomainBlockRebase() API call,
for two reasons: 1) it was targetting a feature that landed first
in downstream RHEL qemu, but had not stabilized in upstream qemu
at the time (and indeed, 'drive-mirror' only landed upstream in
qemu 1.3 with slight differences to the first RHEL attempt,
and later gained further parameters like granularity and buf-size
that are also worth exposing), and 2) extending an existing API
allowed it to be backported without worrying about bumping .so
versions. A virDomainBlockCopy() API was proposed at that time
[1], but we decided not to accept it into libvirt until after
upstream qemu stabilized, and it ended up getting scrapped.
Whether or not RHEL should have attempted adding a new feature
without getting it upstream first is a debate that can be held
another day; but enough time has now elapsed that we are ready to
do the interface cleanly.
[1] https://www.redhat.com/archives/libvir-list/2012-April/msg00768.html
Delaying the creation of a clean API until now has also had a
benefit: we've only recently learned of a few shortcomings in the
original design: 1) it is unable to target a network destination
(such as a gluster volume) because it hard-coded the assumption
that the destination is a local file name. Because of all the
refactoring we've done to add virStorageSourcePtr, we are in a
better position to declare an API that parses XML describing a
host storage source as the copy destination, which was not
possible had we implemented virDomainBlockCopy as it had been
originally envisioned (although a network target will have to wait
until a later libvirt release compared to the API addition to
actually be implemented). 2) the design of using MiB/sec as the
bandwidth throttle is rather coarse; qemu is actually tuned to
bytes/second, and libvirt is preventing access to that level of
detail. A later patch will add flags to existing block job API
that can request bytes/second instead of back-compat MiB/s, but as
this is a new API, we can get it right to begin with.
At least I had the foresight to create 'virsh blockcopy' as a
separate command at the UI level (commit 1f06c00) rather than
leaking the underlying API overload of virDomainBlockRebase onto
shell users.
A further note on the bandwidth option: virTypedParameters
intentionally lacks unsigned long (since variable-width
interaction between mixed 32- vs. 64-bit client/server setups is
nasty), but we have to deal with the fact that we are interacting
with existing older code that mistakenly chose unsigned long
bandwidth at a point before we decided to prohibit it in all new
API. The typed parameter is therefore unsigned long long, but
the implementation (in a later patch) will have to do overflow
detection on 32-bit platforms, as well as capping the value to
match the LLONG_MAX>>20 cap of the existing MiB/s interfaces.
* include/libvirt/libvirt.h.in (virDomainBlockCopy): New API.
(virDomainBlockJobType, virConnectDomainEventBlockJobStatus):
Update related documentation.
* src/libvirt.c (virDomainBlockCopy): Implement it.
* src/libvirt_public.syms (LIBVIRT_1.2.8): Export it.
* src/driver.h (_virDriver): New driver callback.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-26 21:16:48 +00:00
|
|
|
* Copyright (C) 2006-2014 Red Hat, Inc.
|
2013-05-14 23:42:12 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2006-03-20 17:49:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_DRIVER_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_DRIVER_H__
|
2006-03-20 17:49:28 +00:00
|
|
|
|
2012-01-11 13:48:14 +00:00
|
|
|
# include <unistd.h>
|
2007-11-14 11:40:57 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
2013-12-13 16:16:50 +00:00
|
|
|
# include "libvirt_internal.h"
|
2012-02-24 18:48:55 +00:00
|
|
|
# include "viruri.h"
|
2006-06-21 12:56:19 +00:00
|
|
|
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
/* Status codes returned from driver open call. */
|
|
|
|
typedef enum {
|
|
|
|
/* Opened successfully. */
|
|
|
|
VIR_DRV_OPEN_SUCCESS = 0,
|
|
|
|
|
|
|
|
/* 'name' is not for us. */
|
|
|
|
VIR_DRV_OPEN_DECLINED = -1,
|
|
|
|
|
|
|
|
/* 'name' is for us, but there was some error. virConnectOpen will
|
|
|
|
* return an error rather than continue probing the other drivers.
|
|
|
|
*/
|
|
|
|
VIR_DRV_OPEN_ERROR = -2,
|
|
|
|
} virDrvOpenStatus;
|
|
|
|
|
2008-11-14 08:42:47 +00:00
|
|
|
|
2007-08-21 09:03:55 +00:00
|
|
|
/* Internal feature-detection macro. Don't call drv->supports_feature
|
2010-12-03 08:31:48 +00:00
|
|
|
* directly if you don't have to, because it may be NULL, use this macro
|
|
|
|
* instead.
|
2007-08-21 09:03:55 +00:00
|
|
|
*
|
2010-12-03 08:31:48 +00:00
|
|
|
* Note that this treats a possible error returned by drv->supports_feature
|
|
|
|
* the same as not supported. If you care about the error, call
|
|
|
|
* drv->supports_feature directly.
|
2007-08-21 09:03:55 +00:00
|
|
|
*
|
|
|
|
* Returns:
|
2010-12-03 08:31:48 +00:00
|
|
|
* != 0 Feature is supported.
|
2007-08-21 09:03:55 +00:00
|
|
|
* 0 Feature is not supported.
|
|
|
|
*/
|
2014-08-22 12:59:28 +00:00
|
|
|
# define VIR_DRV_SUPPORTS_FEATURE(drv, conn, feature) \
|
2013-04-22 17:26:01 +00:00
|
|
|
((drv)->connectSupportsFeature ? \
|
|
|
|
(drv)->connectSupportsFeature((conn), (feature)) > 0 : 0)
|
2007-08-21 09:03:55 +00:00
|
|
|
|
2013-04-23 09:49:27 +00:00
|
|
|
|
2014-10-16 10:01:19 +00:00
|
|
|
# define __VIR_DRIVER_H_INCLUDES___
|
2008-02-20 15:06:53 +00:00
|
|
|
|
2014-10-16 10:01:19 +00:00
|
|
|
# include "driver-hypervisor.h"
|
|
|
|
# include "driver-interface.h"
|
|
|
|
# include "driver-network.h"
|
|
|
|
# include "driver-nodedev.h"
|
|
|
|
# include "driver-nwfilter.h"
|
|
|
|
# include "driver-secret.h"
|
2015-01-19 16:56:04 +00:00
|
|
|
# include "driver-state.h"
|
2014-10-16 10:01:19 +00:00
|
|
|
# include "driver-stream.h"
|
|
|
|
# include "driver-storage.h"
|
2006-03-20 17:49:28 +00:00
|
|
|
|
2014-10-16 10:01:19 +00:00
|
|
|
# undef __VIR_DRIVER_H_INCLUDES___
|
2008-11-21 12:19:22 +00:00
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
typedef struct _virConnectDriver virConnectDriver;
|
|
|
|
typedef virConnectDriver *virConnectDriverPtr;
|
|
|
|
|
|
|
|
struct _virConnectDriver {
|
|
|
|
virHypervisorDriverPtr hypervisorDriver;
|
|
|
|
virInterfaceDriverPtr interfaceDriver;
|
|
|
|
virNetworkDriverPtr networkDriver;
|
|
|
|
virNodeDeviceDriverPtr nodeDeviceDriver;
|
|
|
|
virNWFilterDriverPtr nwfilterDriver;
|
|
|
|
virSecretDriverPtr secretDriver;
|
|
|
|
virStorageDriverPtr storageDriver;
|
|
|
|
};
|
|
|
|
|
|
|
|
int virRegisterConnectDriver(virConnectDriverPtr driver,
|
|
|
|
bool setSharedDrivers) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
int virRegisterStateDriver(virStateDriverPtr driver) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
|
|
|
|
int virSetSharedInterfaceDriver(virInterfaceDriverPtr driver) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
int virSetSharedNetworkDriver(virNetworkDriverPtr driver) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
int virSetSharedNodeDeviceDriver(virNodeDeviceDriverPtr driver) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
int virSetSharedNWFilterDriver(virNWFilterDriverPtr driver) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
int virSetSharedSecretDriver(virSecretDriverPtr driver) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
int virSetSharedStorageDriver(virStorageDriverPtr driver) ATTRIBUTE_RETURN_CHECK;
|
2014-10-16 10:01:19 +00:00
|
|
|
|
2017-01-26 13:57:41 +00:00
|
|
|
int virDriverLoadModule(const char *name,
|
|
|
|
const char *regfunc);
|
2017-01-18 15:44:20 +00:00
|
|
|
int virDriverLoadModuleFull(const char *name,
|
|
|
|
const char *regfunc,
|
|
|
|
void **handle);
|
2006-03-20 17:49:28 +00:00
|
|
|
|
|
|
|
#endif /* __VIR_DRIVER_H__ */
|