File b662d0b5-qemu-raw-only-BlockPeek.patch of Package libvirt.9596
commit b662d0b52003accaea865a694c4eb35d87a3b5bc
Author: Peter Krempa <pkrempa@redhat.com>
Date: Fri May 12 16:00:27 2017 +0200
qemu: Support only raw volumes in qemuDomainBlockPeek
The API documents that it peeks into the VM disk. We can't do that
currently for non raw images so report an error.
Index: libvirt-3.3.0/src/qemu/qemu_driver.c
===================================================================
--- libvirt-3.3.0.orig/src/qemu/qemu_driver.c
+++ libvirt-3.3.0/src/qemu/qemu_driver.c
@@ -11156,6 +11156,7 @@ qemuDomainBlockPeek(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
+ virDomainDiskDefPtr disk = NULL;
virDomainObjPtr vm;
int fd = -1, ret = -1;
const char *actual;
@@ -11168,6 +11169,18 @@ qemuDomainBlockPeek(virDomainPtr dom,
if (virDomainBlockPeekEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
+ if (!(disk = virDomainDiskByName(vm->def, path, true))) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("invalid disk '%s'"), path);
+ goto cleanup;
+ }
+
+ if (disk->src->format != VIR_STORAGE_FILE_RAW) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("peeking is supported only for RAW disks"));
+ goto cleanup;
+ }
+
/* Check the path belongs to this domain. */
if (!(actual = virDomainDiskPathByName(vm->def, path))) {
virReportError(VIR_ERR_INVALID_ARG,
@@ -11194,6 +11207,8 @@ qemuDomainBlockPeek(virDomainPtr dom,
ret = 0;
cleanup:
+ if (disk)
+ virStorageFileDeinit(disk->src);
VIR_FORCE_CLOSE(fd);
virDomainObjEndAPI(&vm);
return ret;