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
|
|
|
};
|
|
|
|
|
|
|
|
virHashTablePtr
|
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
|
|
|
|
2017-03-16 11:30:16 +00:00
|
|
|
virHashTablePtr
|
|
|
|
qemuBlockGetNodeData(virJSONValuePtr data);
|
|
|
|
|
2017-11-14 14:34:46 +00:00
|
|
|
bool
|
|
|
|
qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src);
|
|
|
|
|
2017-07-07 15:37:42 +00:00
|
|
|
virJSONValuePtr
|
2018-03-22 15:42:47 +00:00
|
|
|
qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
|
2018-09-04 16:52:02 +00:00
|
|
|
bool legacy,
|
2018-09-04 17:29:10 +00:00
|
|
|
bool onlytarget,
|
|
|
|
bool autoreadonly);
|
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;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
virJSONValuePtr authsecretProps;
|
|
|
|
char *authsecretAlias;
|
|
|
|
|
|
|
|
virJSONValuePtr encryptsecretProps;
|
|
|
|
char *encryptsecretAlias;
|
2018-06-01 10:11:06 +00:00
|
|
|
|
|
|
|
virJSONValuePtr tlsProps;
|
|
|
|
char *tlsAlias;
|
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);
|
|
|
|
|
|
|
|
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 *
|
|
|
|
qemuBlockGetBackingStoreString(virStorageSourcePtr src)
|
|
|
|
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
|
2019-10-10 13:02:00 +00:00
|
|
|
qemuBlockStorageSourceCreateDetectSize(virHashTablePtr 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
|
|
|
|
qemuBlockNamedNodeDataGetBitmapByName(virHashTablePtr blockNamedNodeData,
|
|
|
|
virStorageSourcePtr src,
|
|
|
|
const char *bitmap);
|