提交 0304fa2f 编写于 作者: P Peter Krempa

qemu: Allow using qemuDomainStorageSourceAccessModify on singe images

Add a new flag QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN to select whether
to work on single image or full chain.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 6d4136da
...@@ -9214,6 +9214,8 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk, ...@@ -9214,6 +9214,8 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
typedef enum { typedef enum {
/* revoke access to the image instead of allowing it */ /* revoke access to the image instead of allowing it */
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE = 1 << 0, QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE = 1 << 0,
/* operate on full backing chain rather than single image */
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN = 1 << 1,
} qemuDomainStorageSourceAccessFlags; } qemuDomainStorageSourceAccessFlags;
...@@ -9239,6 +9241,8 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver, ...@@ -9239,6 +9241,8 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
const char *srcstr = NULLSTR(src->path); const char *srcstr = NULLSTR(src->path);
int ret = -1; int ret = -1;
virErrorPtr orig_err = NULL; virErrorPtr orig_err = NULL;
bool chain = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
int rc;
/* just tear down the disk access */ /* just tear down the disk access */
if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE) { if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE) {
...@@ -9253,20 +9257,30 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver, ...@@ -9253,20 +9257,30 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
if (qemuDomainNamespaceSetupDisk(vm, src) < 0) if (qemuDomainNamespaceSetupDisk(vm, src) < 0)
goto rollback_lock; goto rollback_lock;
if (qemuSecuritySetImageLabel(driver, vm, src, true) < 0) if (qemuSecuritySetImageLabel(driver, vm, src, chain) < 0)
goto rollback_namespace; goto rollback_namespace;
if (qemuSetupImageChainCgroup(vm, src) < 0) if (chain)
rc = qemuSetupImageChainCgroup(vm, src);
else
rc = qemuSetupImageCgroup(vm, src);
if (rc < 0)
goto rollback_label; goto rollback_label;
ret = 0; ret = 0;
goto cleanup; goto cleanup;
rollback_cgroup: rollback_cgroup:
if (qemuTeardownImageChainCgroup(vm, src) < 0) if (chain)
rc = qemuTeardownImageChainCgroup(vm, src);
else
rc = qemuTeardownImageCgroup(vm, src);
if (rc < 0)
VIR_WARN("Unable to tear down cgroup access on %s", srcstr); VIR_WARN("Unable to tear down cgroup access on %s", srcstr);
rollback_label: rollback_label:
if (qemuSecurityRestoreImageLabel(driver, vm, src, true) < 0) if (qemuSecurityRestoreImageLabel(driver, vm, src, chain) < 0)
VIR_WARN("Unable to restore security label on %s", srcstr); VIR_WARN("Unable to restore security label on %s", srcstr);
rollback_namespace: rollback_namespace:
...@@ -9289,7 +9303,7 @@ qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver, ...@@ -9289,7 +9303,7 @@ qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virStorageSourcePtr src) virStorageSourcePtr src)
{ {
qemuDomainStorageSourceAccessFlags flags = 0; qemuDomainStorageSourceAccessFlags flags = QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
return qemuDomainStorageSourceAccessModify(driver, vm, src, flags); return qemuDomainStorageSourceAccessModify(driver, vm, src, flags);
} }
...@@ -9300,7 +9314,8 @@ qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver, ...@@ -9300,7 +9314,8 @@ qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virStorageSourcePtr src) virStorageSourcePtr src)
{ {
qemuDomainStorageSourceAccessFlags flags = QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE; qemuDomainStorageSourceAccessFlags flags = QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE |
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
return qemuDomainStorageSourceAccessModify(driver, vm, src, flags); return qemuDomainStorageSourceAccessModify(driver, vm, src, flags);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册