Libvirt currently makes the assumption that disk devices are always accessible 
as files on the local system. However, certain types of virtual storage on qemu 
(e.g, NBD) may not be. This patch defines a new "virtual" disk device which is 
treated similarly to existing disk types, but which is exempted from at least 
one code path (qemuSecurityDACSetSecurityAllLabel) which assumes the disk to be 
accessible as a file.

With this patch in place, a QEMU virtual disk can be declared as:

    <disk type='virtual' device='disk'>
      <driver name='qemu' type='nbd' />
      <source path='nbd:nbdhost:1234' />
      <target dev='vda' bus='virtio' />
    </disk>

I haven't tested this with any drivers besides QEMU, so there might be some 
adjustments needed for those as well. Having the infrastructure in place to 
create these devices makes it easier to add them in the future, though.

---

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 64b5cf3..b753734 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -103,7 +103,8 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, 
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
 VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST,
               "block",
               "file",
-              "dir")
+              "dir",
+              "virtual")
 
 VIR_ENUM_IMPL(virDomainDiskDevice, VIR_DOMAIN_DISK_DEVICE_LAST,
               "disk",
@@ -1434,6 +1435,9 @@ virDomainDiskDefParseXML(xmlNodePtr node,
                 case VIR_DOMAIN_DISK_TYPE_DIR:
                     source = virXMLPropString(cur, "dir");
                     break;
+                case VIR_DOMAIN_DISK_TYPE_VIRTUAL:
+                    source = virXMLPropString(cur, "path");
+                    break;
                 default:
                     virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                          _("unexpected disk type %s"),
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f83de83..9bb5073 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -119,6 +119,7 @@ enum virDomainDiskType {
     VIR_DOMAIN_DISK_TYPE_BLOCK,
     VIR_DOMAIN_DISK_TYPE_FILE,
     VIR_DOMAIN_DISK_TYPE_DIR,
+    VIR_DOMAIN_DISK_TYPE_VIRTUAL,
 
     VIR_DOMAIN_DISK_TYPE_LAST
 };
diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c
index ffc9b8d..69c7bf1 100644
--- a/src/qemu/qemu_security_dac.c
+++ b/src/qemu/qemu_security_dac.c
@@ -374,7 +374,7 @@ qemuSecurityDACSetSecurityAllLabel(virDomainObjPtr vm, 
const char *stdin_path AT
 
     for (i = 0 ; i < vm->def->ndisks ; i++) {
         /* XXX fixme - we need to recursively label the entriy tree :-( */
-        if (vm->def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_DIR)
+        if (vm->def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_DIR || 
vm->def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_VIRTUAL)
             continue;
         if (qemuSecurityDACSetSecurityImageLabel(vm, vm->def->disks[i]) < 0)
             return -1;



--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to