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