/**
* qemuBlockStorageSourceGetBackendProps:
* @src: disk source
- * @legacy: use legacy formatting of attributes (for -drive / old qemus)
- * @onlytarget: omit any data which does not identify the image itself
- * @autoreadonly: use the auto-read-only feature of qemu
+ * @flags: bitwise-or of qemuBlockStorageSourceBackendPropsFlags
+ *
+ * Flags:
+ * QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY:
+ * use legacy formatting of attributes (for -drive / old qemus)
+ * QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY:
+ * omit any data which does not identify the image itself
+ * QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY:
+ * use the auto-read-only feature of qemu
*
* Creates a JSON object describing the underlying storage or protocol of a
* storage source. Returns NULL on error and reports an appropriate error message.
*/
virJSONValuePtr
qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
- bool legacy,
- bool onlytarget,
- bool autoreadonly)
+ unsigned int flags)
{
int actualType = virStorageSourceGetActualType(src);
g_autoptr(virJSONValue) fileprops = NULL;
const char *driver = NULL;
virTristateBool aro = VIR_TRISTATE_BOOL_ABSENT;
virTristateBool ro = VIR_TRISTATE_BOOL_ABSENT;
+ bool onlytarget = flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY;
+ bool legacy = flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY;
- if (autoreadonly) {
+ if (flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY) {
aro = VIR_TRISTATE_BOOL_YES;
} else {
if (src->readonly)
bool autoreadonly)
{
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
+ unsigned int backendpropsflags = 0;
+
+ if (autoreadonly)
+ backendpropsflags |= QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY;
if (VIR_ALLOC(data) < 0)
return NULL;
if (!(data->formatProps = qemuBlockStorageSourceGetBlockdevProps(src,
backingStore)) ||
- !(data->storageProps = qemuBlockStorageSourceGetBackendProps(src, false,
- false,
- autoreadonly)))
+ !(data->storageProps = qemuBlockStorageSourceGetBackendProps(src,
+ backendpropsflags)))
return NULL;
data->storageNodeName = src->nodestorage;
}
/* use json: pseudo protocol otherwise */
- if (!(backingProps = qemuBlockStorageSourceGetBackendProps(src, false, true, false)))
+ if (!(backingProps = qemuBlockStorageSourceGetBackendProps(src,
+ QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY)))
return NULL;
props = backingProps;
bool
qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src);
+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,
+} qemuBlockStorageSourceBackendPropsFlags;
+
virJSONValuePtr
qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
- bool legacy,
- bool onlytarget,
- bool autoreadonly);
+ unsigned int flags);
virURIPtr
qemuBlockStorageSourceGetURI(virStorageSourcePtr src);
g_autoptr(virJSONValue) props = NULL;
virJSONValuePtr ret;
- if (!(props = qemuBlockStorageSourceGetBackendProps(src, true, false, false)))
+ if (!(props = qemuBlockStorageSourceGetBackendProps(src,
+ QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY)))
return NULL;
if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0)
g_autoptr(virStorageSource) xmlsrc = NULL;
g_autoptr(virStorageSource) jsonsrc = NULL;
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
+ unsigned int backendpropsflags = 0;
+
+ if (data->legacy)
+ backendpropsflags |= QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY;
if (!(xmlsrc = virStorageSourceNew()))
return -1;
}
if (!(backendprops = qemuBlockStorageSourceGetBackendProps(xmlsrc,
- data->legacy,
- false,
- false))) {
+ backendpropsflags))) {
fprintf(stderr, "failed to format disk source json\n");
return -1;
}
return -1;
}
- if (!(jsonsrcout = qemuBlockStorageSourceGetBackendProps(src, false, false, true))) {
+ if (!(jsonsrcout = qemuBlockStorageSourceGetBackendProps(src,
+ QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY))) {
fprintf(stderr, "failed to format disk source json\n");
return -1;
}
for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
g_autofree char *backingstore = NULL;
+ unsigned int backendpropsflagsnormal = QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY;
+ unsigned int backendpropsflagstarget = QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY |
+ QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY;
if (testQemuDiskXMLToJSONFakeSecrets(n) < 0)
return -1;
qemuDomainPrepareDiskSourceData(disk, n);
if (!(formatProps = qemuBlockStorageSourceGetBlockdevProps(n, n->backingStore)) ||
- !(storageSrcOnlyProps = qemuBlockStorageSourceGetBackendProps(n, false, true, true)) ||
- !(storageProps = qemuBlockStorageSourceGetBackendProps(n, false, false, true)) ||
+ !(storageSrcOnlyProps = qemuBlockStorageSourceGetBackendProps(n, backendpropsflagstarget)) ||
+ !(storageProps = qemuBlockStorageSourceGetBackendProps(n, backendpropsflagsnormal)) ||
!(backingstore = qemuBlockGetBackingStoreString(n, true))) {
if (!data->fail) {
VIR_TEST_VERBOSE("failed to generate qemu blockdev props");