2017-03-13 11:46:18 +00:00
|
|
|
/*
|
|
|
|
* qemu_block.h: helper functions for QEMU block subsystem
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:37 +00:00
|
|
|
#pragma once
|
2017-03-13 11:46:18 +00:00
|
|
|
|
2019-06-18 16:12:37 +00:00
|
|
|
#include "internal.h"
|
2017-03-13 11:46:18 +00:00
|
|
|
|
2019-06-18 16:12:37 +00:00
|
|
|
#include "qemu_conf.h"
|
|
|
|
#include "qemu_domain.h"
|
2017-03-13 11:46:18 +00:00
|
|
|
|
2019-06-18 16:12:37 +00:00
|
|
|
#include "virhash.h"
|
|
|
|
#include "virjson.h"
|
|
|
|
#include "viruri.h"
|
2017-03-13 11:46:18 +00:00
|
|
|
|
|
|
|
typedef struct qemuBlockNodeNameBackingChainData qemuBlockNodeNameBackingChainData;
|
|
|
|
struct qemuBlockNodeNameBackingChainData {
|
|
|
|
char *qemufilename; /* name of the image from qemu */
|
|
|
|
char *nodeformat; /* node name of the format layer */
|
|
|
|
char *nodestorage; /* node name of the storage backing the format node */
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockNodeNameBackingChainData *backing;
|
2017-07-25 17:10:27 +00:00
|
|
|
|
|
|
|
/* for testing purposes */
|
|
|
|
char *drvformat;
|
|
|
|
char *drvstorage;
|
2017-03-13 11:46:18 +00:00
|
|
|
};
|
|
|
|
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockNodeNameGetBackingChain(virJSONValue *namednodesdata,
|
|
|
|
virJSONValue *blockstats);
|
2017-03-13 11:46:18 +00:00
|
|
|
|
2017-03-15 12:03:21 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockNodeNamesDetect(virQEMUDriver *driver,
|
|
|
|
virDomainObj *vm,
|
2017-04-07 11:06:24 +00:00
|
|
|
qemuDomainAsyncJob asyncJob);
|
2017-03-15 12:03:21 +00:00
|
|
|
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockGetNodeData(virJSONValue *data);
|
2017-03-16 11:30:16 +00:00
|
|
|
|
2017-11-14 14:34:46 +00:00
|
|
|
bool
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSource *src);
|
2017-11-14 14:34:46 +00:00
|
|
|
|
2020-06-19 14:28:12 +00:00
|
|
|
typedef enum {
|
|
|
|
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY = 1 << 0,
|
|
|
|
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY = 1 << 1,
|
|
|
|
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY = 1 << 2,
|
2020-06-19 14:37:43 +00:00
|
|
|
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP = 1 << 3,
|
2020-06-19 14:28:12 +00:00
|
|
|
} qemuBlockStorageSourceBackendPropsFlags;
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *
|
|
|
|
qemuBlockStorageSourceGetBackendProps(virStorageSource *src,
|
2020-06-19 14:28:12 +00:00
|
|
|
unsigned int flags);
|
2017-07-07 14:29:01 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virURI *
|
|
|
|
qemuBlockStorageSourceGetURI(virStorageSource *src);
|
2017-07-13 13:38:50 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *
|
|
|
|
qemuBlockStorageSourceGetBlockdevProps(virStorageSource *src,
|
|
|
|
virStorageSource *backingStore);
|
2017-10-23 10:26:10 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *
|
|
|
|
qemuBlockStorageGetCopyOnReadProps(virDomainDiskDef *disk);
|
2018-02-23 11:59:13 +00:00
|
|
|
|
|
|
|
typedef struct qemuBlockStorageSourceAttachData qemuBlockStorageSourceAttachData;
|
|
|
|
struct qemuBlockStorageSourceAttachData {
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *prmgrProps;
|
2018-06-01 13:56:47 +00:00
|
|
|
char *prmgrAlias;
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *storageProps;
|
2018-02-23 11:59:13 +00:00
|
|
|
const char *storageNodeName;
|
|
|
|
bool storageAttached;
|
2020-02-10 13:37:14 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *storageSliceProps;
|
2020-02-10 13:37:14 +00:00
|
|
|
const char *storageSliceNodeName;
|
|
|
|
bool storageSliceAttached;
|
2018-02-23 11:59:13 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *formatProps;
|
2018-02-23 11:59:13 +00:00
|
|
|
const char *formatNodeName;
|
|
|
|
bool formatAttached;
|
2018-05-16 11:39:22 +00:00
|
|
|
|
|
|
|
char *driveCmd;
|
|
|
|
char *driveAlias;
|
|
|
|
bool driveAdded;
|
2018-05-17 08:32:32 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainChrSourceDef *chardevDef;
|
2021-02-01 11:00:35 +00:00
|
|
|
char *chardevAlias;
|
|
|
|
char *chardevCmd;
|
|
|
|
bool chardevAdded;
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *authsecretProps;
|
2018-05-17 08:32:32 +00:00
|
|
|
char *authsecretAlias;
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *encryptsecretProps;
|
2018-05-17 08:32:32 +00:00
|
|
|
char *encryptsecretAlias;
|
2018-06-01 10:11:06 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *httpcookiesecretProps;
|
2020-03-09 08:14:07 +00:00
|
|
|
char *httpcookiesecretAlias;
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *tlsProps;
|
2018-06-01 10:11:06 +00:00
|
|
|
char *tlsAlias;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *tlsKeySecretProps;
|
2020-06-29 13:11:00 +00:00
|
|
|
char *tlsKeySecretAlias;
|
2018-02-23 11:59:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachData *data);
|
2018-02-23 11:59:13 +00:00
|
|
|
|
2019-10-15 12:47:50 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuBlockStorageSourceAttachData,
|
2019-04-04 08:46:21 +00:00
|
|
|
qemuBlockStorageSourceAttachDataFree);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceAttachData *
|
|
|
|
qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSource *src,
|
|
|
|
virStorageSource *backingStore,
|
2018-09-04 17:29:10 +00:00
|
|
|
bool autoreadonly);
|
2018-02-23 11:59:13 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceAttachData *
|
|
|
|
qemuBlockStorageSourceDetachPrepare(virStorageSource *src,
|
2018-10-10 13:30:24 +00:00
|
|
|
char *driveAlias);
|
|
|
|
|
2018-02-23 11:59:13 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceAttachApply(qemuMonitor *mon,
|
|
|
|
qemuBlockStorageSourceAttachData *data);
|
2018-02-23 11:59:13 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceAttachRollback(qemuMonitor *mon,
|
|
|
|
qemuBlockStorageSourceAttachData *data);
|
2018-02-23 11:59:13 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceDetachOneBlockdev(virQEMUDriver *driver,
|
|
|
|
virDomainObj *vm,
|
2018-02-23 11:59:13 +00:00
|
|
|
qemuDomainAsyncJob asyncJob,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *src);
|
2018-02-23 11:59:13 +00:00
|
|
|
|
2019-04-04 14:50:49 +00:00
|
|
|
struct _qemuBlockStorageSourceChainData {
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceAttachData **srcdata;
|
2019-04-04 14:50:49 +00:00
|
|
|
size_t nsrcdata;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _qemuBlockStorageSourceChainData qemuBlockStorageSourceChainData;
|
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceChainDataFree(qemuBlockStorageSourceChainData *data);
|
2019-04-04 14:50:49 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceChainData *
|
|
|
|
qemuBlockStorageSourceChainDetachPrepareBlockdev(virStorageSource *src);
|
|
|
|
qemuBlockStorageSourceChainData *
|
|
|
|
qemuBlockStorageSourceChainDetachPrepareDrive(virStorageSource *src,
|
2019-04-04 14:50:49 +00:00
|
|
|
char *driveAlias);
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceChainData *
|
2021-02-01 11:00:35 +00:00
|
|
|
qemuBlockStorageSourceChainDetachPrepareChardev(char *chardevAlias);
|
2019-04-04 14:50:49 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceChainAttach(qemuMonitor *mon,
|
|
|
|
qemuBlockStorageSourceChainData *data);
|
2019-04-04 14:50:49 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceChainDetach(qemuMonitor *mon,
|
|
|
|
qemuBlockStorageSourceChainData *data);
|
2019-04-04 14:50:49 +00:00
|
|
|
|
|
|
|
|
2019-10-15 12:47:50 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuBlockStorageSourceChainData,
|
2019-04-04 14:50:49 +00:00
|
|
|
qemuBlockStorageSourceChainDataFree);
|
|
|
|
|
2018-07-03 12:13:29 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockSnapshotAddLegacy(virJSONValue *actions,
|
|
|
|
virDomainDiskDef *disk,
|
|
|
|
virStorageSource *newsrc,
|
2018-07-03 12:13:29 +00:00
|
|
|
bool reuse);
|
2018-09-03 18:08:07 +00:00
|
|
|
|
2018-09-07 09:33:54 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockSnapshotAddBlockdev(virJSONValue *actions,
|
|
|
|
virDomainDiskDef *disk,
|
|
|
|
virStorageSource *newsrc);
|
2018-09-07 09:33:54 +00:00
|
|
|
|
2019-07-22 15:36:05 +00:00
|
|
|
char *
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockGetBackingStoreString(virStorageSource *src,
|
2020-03-23 10:48:10 +00:00
|
|
|
bool pretty)
|
2019-07-22 15:36:05 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
|
2018-09-03 18:08:07 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceCreateGetFormatProps(virStorageSource *src,
|
|
|
|
virStorageSource *backing,
|
|
|
|
virJSONValue **props)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) G_GNUC_WARN_UNUSED_RESULT;
|
2018-09-06 07:09:55 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceCreateGetStorageProps(virStorageSource *src,
|
|
|
|
virJSONValue **props)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
|
2019-06-10 16:13:09 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceCreate(virDomainObj *vm,
|
|
|
|
virStorageSource *src,
|
|
|
|
virStorageSource *backingStore,
|
|
|
|
virStorageSource *chain,
|
|
|
|
qemuBlockStorageSourceAttachData *data,
|
2019-06-10 16:13:09 +00:00
|
|
|
qemuDomainAsyncJob asyncJob);
|
|
|
|
|
|
|
|
int
|
2020-10-22 17:04:18 +00:00
|
|
|
qemuBlockStorageSourceCreateDetectSize(GHashTable *blockNamedNodeData,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *src,
|
|
|
|
virStorageSource *templ);
|
2019-11-19 07:43:58 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockRemoveImageMetadata(virQEMUDriver *driver,
|
|
|
|
virDomainObj *vm,
|
2019-11-19 07:43:58 +00:00
|
|
|
const char *diskTarget,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *src);
|
2019-12-05 14:57:30 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockNamedNodeDataBitmap *
|
2020-10-22 17:04:18 +00:00
|
|
|
qemuBlockNamedNodeDataGetBitmapByName(GHashTable *blockNamedNodeData,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *src,
|
2019-12-05 14:57:30 +00:00
|
|
|
const char *bitmap);
|
2020-01-21 14:10:27 +00:00
|
|
|
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockGetNamedNodeData(virDomainObj *vm,
|
2020-01-21 14:10:27 +00:00
|
|
|
qemuDomainAsyncJob asyncJob);
|
2020-01-29 11:08:50 +00:00
|
|
|
|
2020-06-01 10:05:49 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockGetBitmapMergeActions(virStorageSource *topsrc,
|
|
|
|
virStorageSource *basesrc,
|
|
|
|
virStorageSource *target,
|
2020-06-01 10:05:49 +00:00
|
|
|
const char *bitmapname,
|
|
|
|
const char *dstbitmapname,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *writebitmapsrc,
|
|
|
|
virJSONValue **actions,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *blockNamedNodeData);
|
2020-06-01 10:05:49 +00:00
|
|
|
|
2020-01-29 11:08:50 +00:00
|
|
|
bool
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockBitmapChainIsValid(virStorageSource *src,
|
2020-01-29 11:08:50 +00:00
|
|
|
const char *bitmapname,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *blockNamedNodeData);
|
2020-01-29 11:16:12 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockBitmapsHandleBlockcopy(virStorageSource *src,
|
|
|
|
virStorageSource *mirror,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *blockNamedNodeData,
|
2020-01-29 11:16:12 +00:00
|
|
|
bool shallow,
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue **actions);
|
2020-02-13 08:24:36 +00:00
|
|
|
|
2020-03-02 13:40:18 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockBitmapsHandleCommitFinish(virStorageSource *topsrc,
|
|
|
|
virStorageSource *basesrc,
|
2020-04-17 07:51:40 +00:00
|
|
|
bool active,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *blockNamedNodeData,
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue **actions);
|
2020-03-02 13:40:18 +00:00
|
|
|
|
2020-02-13 08:24:36 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockReopenReadWrite(virDomainObj *vm,
|
|
|
|
virStorageSource *src,
|
2020-02-13 08:24:36 +00:00
|
|
|
qemuDomainAsyncJob asyncJob);
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockReopenReadOnly(virDomainObj *vm,
|
|
|
|
virStorageSource *src,
|
2020-02-13 08:24:36 +00:00
|
|
|
qemuDomainAsyncJob asyncJob);
|
2020-03-19 15:43:49 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src);
|
2020-03-23 15:31:19 +00:00
|
|
|
|
|
|
|
char *
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStorageSourceGetCookieString(virStorageSource *src);
|
2020-03-30 09:18:32 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockUpdateRelativeBacking(virDomainObj *vm,
|
|
|
|
virStorageSource *src,
|
|
|
|
virStorageSource *topsrc);
|
2020-10-14 09:12:19 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *
|
2020-10-14 09:33:06 +00:00
|
|
|
qemuBlockExportGetNBDProps(const char *nodename,
|
|
|
|
const char *exportname,
|
|
|
|
bool writable,
|
2020-10-26 12:06:17 +00:00
|
|
|
const char **bitmaps);
|
2020-10-14 09:33:06 +00:00
|
|
|
|
|
|
|
|
2020-10-14 09:12:19 +00:00
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockExportAddNBD(virDomainObj *vm,
|
2020-10-14 09:12:19 +00:00
|
|
|
const char *drivealias,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *src,
|
2020-10-14 09:12:19 +00:00
|
|
|
const char *exportname,
|
|
|
|
bool writable,
|
|
|
|
const char *bitmap);
|