I am trying to use a qcow image with libvirt where the backing 'file' is
a qemu-nbd server. Unfortunately the security code assumes that
backingStore is always a real file so something like 'nbd:0:3333' is
rejected because a file with that name cannot be accessed. A simple
patch like the following works around the problem -- are there any
suggestions on how to do this properly? Note that I am not worried
about directly using nbd images. That would require a new disk type
with XML markup, etc. I only want it to be permitted as a backingStore.
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index 6f48b10..7c0ea9a 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -292,6 +292,13 @@ qcowXGetBackingStore(char **res,
return BACKING_STORE_INVALID;
if (size + 1 == 0)
return BACKING_STORE_INVALID;
+
+ /* Short-circuit nbd backing files */
+ if (size >= 4 && STRPREFIX((const char *)(buf + offset),
"nbd:")) {
+ return BACKING_STORE_OK;
+ }
+
if (VIR_ALLOC_N(*res, size + 1) < 0) {
virReportOOMError();
return BACKING_STORE_ERROR;
--
Thanks,
Adam