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;
|
|
|
|
typedef qemuBlockNodeNameBackingChainData *qemuBlockNodeNameBackingChainDataPtr;
|
|
|
|
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 */
|
|
|
|
|
2017-07-26 07:36:21 +00:00
|
|
|
qemuBlockNodeNameBackingChainDataPtr 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 *
|
2017-07-26 07:36:21 +00:00
|
|
|
qemuBlockNodeNameGetBackingChain(virJSONValuePtr namednodesdata,
|
|
|
|
virJSONValuePtr blockstats);
|
2017-03-13 11:46:18 +00:00
|
|
|
|
2017-03-15 12:03:21 +00:00
|
|
|
int
|
|
|
|
qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
|
2017-04-07 11:06:24 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
qemuDomainAsyncJob asyncJob);
|
2017-03-15 12:03:21 +00:00
|
|
|
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *
|
2017-03-16 11:30:16 +00:00
|
|
|
qemuBlockGetNodeData(virJSONValuePtr data);
|
|
|
|
|
2017-11-14 14:34:46 +00:00
|
|
|
bool
|
|
|
|
qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src);
|
|
|
|
|
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;
|
|
|
|
|
2017-07-07 15:37:42 +00:00
|
|
|
virJSONValuePtr
|
2018-03-22 15:42:47 +00:00
|
|
|
qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
|
2020-06-19 14:28:12 +00:00
|
|
|
unsigned int flags);
|
2017-07-07 14:29:01 +00:00
|
|
|
|
2017-07-13 13:38:50 +00:00
|
|
|
virURIPtr
|
|
|
|
qemuBlockStorageSourceGetURI(virStorageSourcePtr src);
|
|
|
|
|
2017-10-23 10:26:10 +00:00
|
|
|
virJSONValuePtr
|
2019-09-03 11:27:52 +00:00
|
|
|
qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src,
|
|
|
|
virStorageSourcePtr backingStore);
|
2017-10-23 10:26:10 +00:00
|
|
|
|
2018-06-11 11:25:20 +00:00
|
|
|
virJSONValuePtr
|
|
|
|
qemuBlockStorageGetCopyOnReadProps(virDomainDiskDefPtr disk);
|
2018-02-23 11:59:13 +00:00
|
|
|
|
|
|
|
typedef struct qemuBlockStorageSourceAttachData qemuBlockStorageSourceAttachData;
|
|
|
|
typedef qemuBlockStorageSourceAttachData *qemuBlockStorageSourceAttachDataPtr;
|
|
|
|
struct qemuBlockStorageSourceAttachData {
|
2018-06-01 13:56:47 +00:00
|
|
|
virJSONValuePtr prmgrProps;
|
|
|
|
char *prmgrAlias;
|
|
|
|
|
2018-02-23 11:59:13 +00:00
|
|
|
virJSONValuePtr storageProps;
|
|
|
|
const char *storageNodeName;
|
|
|
|
bool storageAttached;
|
2020-02-10 13:37:14 +00:00
|
|
|
|
|
|
|
virJSONValuePtr storageSliceProps;
|
|
|
|
const char *storageSliceNodeName;
|
|
|
|
bool storageSliceAttached;
|
2018-02-23 11:59:13 +00:00
|
|
|
|
|
|
|
virJSONValuePtr formatProps;
|
|
|
|
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-02-01 11:00:35 +00:00
|
|
|
virDomainChrSourceDefPtr chardevDef;
|
|
|
|
char *chardevAlias;
|
|
|
|
char *chardevCmd;
|
|
|
|
bool chardevAdded;
|
|
|
|
|
2018-05-17 08:32:32 +00:00
|
|
|
virJSONValuePtr authsecretProps;
|
|
|
|
char *authsecretAlias;
|
|
|
|
|
|
|
|
virJSONValuePtr encryptsecretProps;
|
|
|
|
char *encryptsecretAlias;
|
2018-06-01 10:11:06 +00:00
|
|
|
|
2020-03-09 08:14:07 +00:00
|
|
|
virJSONValuePtr httpcookiesecretProps;
|
|
|
|
char *httpcookiesecretAlias;
|
|
|
|
|
2018-06-01 10:11:06 +00:00
|
|
|
virJSONValuePtr tlsProps;
|
|
|
|
char *tlsAlias;
|
2020-06-29 13:11:00 +00:00
|
|
|
virJSONValuePtr tlsKeySecretProps;
|
|
|
|
char *tlsKeySecretAlias;
|
2018-02-23 11:59:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachDataPtr data);
|
|
|
|
|
2019-10-15 12:47:50 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuBlockStorageSourceAttachData,
|
2019-04-04 08:46:21 +00:00
|
|
|
qemuBlockStorageSourceAttachDataFree);
|
|
|
|
|
2018-02-23 11:59:13 +00:00
|
|
|
qemuBlockStorageSourceAttachDataPtr
|
2018-09-04 17:29:10 +00:00
|
|
|
qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src,
|
2019-09-03 11:58:34 +00:00
|
|
|
virStorageSourcePtr backingStore,
|
2018-09-04 17:29:10 +00:00
|
|
|
bool autoreadonly);
|
2018-02-23 11:59:13 +00:00
|
|
|
|
2018-10-10 13:30:24 +00:00
|
|
|
qemuBlockStorageSourceAttachDataPtr
|
|
|
|
qemuBlockStorageSourceDetachPrepare(virStorageSourcePtr src,
|
|
|
|
char *driveAlias);
|
|
|
|
|
2018-02-23 11:59:13 +00:00
|
|
|
int
|
|
|
|
qemuBlockStorageSourceAttachApply(qemuMonitorPtr mon,
|
|
|
|
qemuBlockStorageSourceAttachDataPtr data);
|
|
|
|
|
|
|
|
void
|
|
|
|
qemuBlockStorageSourceAttachRollback(qemuMonitorPtr mon,
|
|
|
|
qemuBlockStorageSourceAttachDataPtr data);
|
|
|
|
|
|
|
|
int
|
|
|
|
qemuBlockStorageSourceDetachOneBlockdev(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
qemuDomainAsyncJob asyncJob,
|
|
|
|
virStorageSourcePtr src);
|
|
|
|
|
2019-04-04 14:50:49 +00:00
|
|
|
struct _qemuBlockStorageSourceChainData {
|
|
|
|
qemuBlockStorageSourceAttachDataPtr *srcdata;
|
|
|
|
size_t nsrcdata;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _qemuBlockStorageSourceChainData qemuBlockStorageSourceChainData;
|
|
|
|
typedef qemuBlockStorageSourceChainData *qemuBlockStorageSourceChainDataPtr;
|
|
|
|
|
|
|
|
void
|
|
|
|
qemuBlockStorageSourceChainDataFree(qemuBlockStorageSourceChainDataPtr data);
|
|
|
|
|
|
|
|
qemuBlockStorageSourceChainDataPtr
|
|
|
|
qemuBlockStorageSourceChainDetachPrepareBlockdev(virStorageSourcePtr src);
|
|
|
|
qemuBlockStorageSourceChainDataPtr
|
|
|
|
qemuBlockStorageSourceChainDetachPrepareDrive(virStorageSourcePtr src,
|
|
|
|
char *driveAlias);
|
2021-02-01 11:00:35 +00:00
|
|
|
qemuBlockStorageSourceChainDataPtr
|
|
|
|
qemuBlockStorageSourceChainDetachPrepareChardev(char *chardevAlias);
|
2019-04-04 14:50:49 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
qemuBlockStorageSourceChainAttach(qemuMonitorPtr mon,
|
|
|
|
qemuBlockStorageSourceChainDataPtr data);
|
|
|
|
|
|
|
|
void
|
|
|
|
qemuBlockStorageSourceChainDetach(qemuMonitorPtr mon,
|
|
|
|
qemuBlockStorageSourceChainDataPtr data);
|
|
|
|
|
|
|
|
|
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
|
|
|
|
qemuBlockSnapshotAddLegacy(virJSONValuePtr actions,
|
|
|
|
virDomainDiskDefPtr disk,
|
|
|
|
virStorageSourcePtr newsrc,
|
|
|
|
bool reuse);
|
2018-09-03 18:08:07 +00:00
|
|
|
|
2018-09-07 09:33:54 +00:00
|
|
|
int
|
|
|
|
qemuBlockSnapshotAddBlockdev(virJSONValuePtr actions,
|
|
|
|
virDomainDiskDefPtr disk,
|
|
|
|
virStorageSourcePtr newsrc);
|
|
|
|
|
2019-07-22 15:36:05 +00:00
|
|
|
char *
|
2020-03-23 10:48:10 +00:00
|
|
|
qemuBlockGetBackingStoreString(virStorageSourcePtr src,
|
|
|
|
bool pretty)
|
2019-07-22 15:36:05 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
|
2018-09-03 18:08:07 +00:00
|
|
|
int
|
|
|
|
qemuBlockStorageSourceCreateGetFormatProps(virStorageSourcePtr src,
|
|
|
|
virStorageSourcePtr backing,
|
|
|
|
virJSONValuePtr *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
|
|
|
|
qemuBlockStorageSourceCreateGetStorageProps(virStorageSourcePtr src,
|
|
|
|
virJSONValuePtr *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
|
|
|
|
qemuBlockStorageSourceCreate(virDomainObjPtr vm,
|
|
|
|
virStorageSourcePtr src,
|
|
|
|
virStorageSourcePtr backingStore,
|
|
|
|
virStorageSourcePtr chain,
|
|
|
|
qemuBlockStorageSourceAttachDataPtr data,
|
|
|
|
qemuDomainAsyncJob asyncJob);
|
|
|
|
|
|
|
|
int
|
2020-10-22 17:04:18 +00:00
|
|
|
qemuBlockStorageSourceCreateDetectSize(GHashTable *blockNamedNodeData,
|
2019-06-10 16:13:09 +00:00
|
|
|
virStorageSourcePtr src,
|
2019-10-10 13:02:00 +00:00
|
|
|
virStorageSourcePtr templ);
|
2019-11-19 07:43:58 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
qemuBlockRemoveImageMetadata(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
const char *diskTarget,
|
|
|
|
virStorageSourcePtr src);
|
2019-12-05 14:57:30 +00:00
|
|
|
|
|
|
|
qemuBlockNamedNodeDataBitmapPtr
|
2020-10-22 17:04:18 +00:00
|
|
|
qemuBlockNamedNodeDataGetBitmapByName(GHashTable *blockNamedNodeData,
|
2019-12-05 14:57:30 +00:00
|
|
|
virStorageSourcePtr src,
|
|
|
|
const char *bitmap);
|
2020-01-21 14:10:27 +00:00
|
|
|
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *
|
2020-01-21 14:10:27 +00:00
|
|
|
qemuBlockGetNamedNodeData(virDomainObjPtr vm,
|
|
|
|
qemuDomainAsyncJob asyncJob);
|
2020-01-29 11:08:50 +00:00
|
|
|
|
2020-06-01 10:05:49 +00:00
|
|
|
int
|
|
|
|
qemuBlockGetBitmapMergeActions(virStorageSourcePtr topsrc,
|
|
|
|
virStorageSourcePtr basesrc,
|
|
|
|
virStorageSourcePtr target,
|
|
|
|
const char *bitmapname,
|
|
|
|
const char *dstbitmapname,
|
|
|
|
virStorageSourcePtr writebitmapsrc,
|
|
|
|
virJSONValuePtr *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
|
|
|
|
qemuBlockBitmapChainIsValid(virStorageSourcePtr src,
|
|
|
|
const char *bitmapname,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *blockNamedNodeData);
|
2020-01-29 11:16:12 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
qemuBlockBitmapsHandleBlockcopy(virStorageSourcePtr src,
|
|
|
|
virStorageSourcePtr mirror,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *blockNamedNodeData,
|
2020-01-29 11:16:12 +00:00
|
|
|
bool shallow,
|
|
|
|
virJSONValuePtr *actions);
|
2020-02-13 08:24:36 +00:00
|
|
|
|
2020-03-02 13:40:18 +00:00
|
|
|
int
|
|
|
|
qemuBlockBitmapsHandleCommitFinish(virStorageSourcePtr topsrc,
|
|
|
|
virStorageSourcePtr basesrc,
|
2020-04-17 07:51:40 +00:00
|
|
|
bool active,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *blockNamedNodeData,
|
2020-04-17 07:51:40 +00:00
|
|
|
virJSONValuePtr *actions);
|
2020-03-02 13:40:18 +00:00
|
|
|
|
2020-02-13 08:24:36 +00:00
|
|
|
int
|
|
|
|
qemuBlockReopenReadWrite(virDomainObjPtr vm,
|
|
|
|
virStorageSourcePtr src,
|
|
|
|
qemuDomainAsyncJob asyncJob);
|
|
|
|
int
|
|
|
|
qemuBlockReopenReadOnly(virDomainObjPtr vm,
|
|
|
|
virStorageSourcePtr src,
|
|
|
|
qemuDomainAsyncJob asyncJob);
|
2020-03-19 15:43:49 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src);
|
2020-03-23 15:31:19 +00:00
|
|
|
|
|
|
|
char *
|
|
|
|
qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src);
|
2020-03-30 09:18:32 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
qemuBlockUpdateRelativeBacking(virDomainObjPtr vm,
|
|
|
|
virStorageSourcePtr src,
|
|
|
|
virStorageSourcePtr topsrc);
|
2020-10-14 09:12:19 +00:00
|
|
|
|
2020-10-14 09:33:06 +00:00
|
|
|
virJSONValuePtr
|
|
|
|
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
|
|
|
|
qemuBlockExportAddNBD(virDomainObjPtr vm,
|
|
|
|
const char *drivealias,
|
|
|
|
virStorageSourcePtr src,
|
|
|
|
const char *exportname,
|
|
|
|
bool writable,
|
|
|
|
const char *bitmap);
|