diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index e726801fe1..5b8f7f8a9f 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -434,6 +434,22 @@
+
+
+ dir
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0a7eef7bc3..42820a7f96 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -90,7 +90,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST,
"block",
- "file")
+ "file",
+ "dir")
VIR_ENUM_IMPL(virDomainDiskDevice, VIR_DOMAIN_DISK_DEVICE_LAST,
"disk",
@@ -777,10 +778,22 @@ virDomainDiskDefParseXML(virConnectPtr conn,
if ((source == NULL) &&
(xmlStrEqual(cur->name, BAD_CAST "source"))) {
- if (def->type == VIR_DOMAIN_DISK_TYPE_FILE)
+ switch (def->type) {
+ case VIR_DOMAIN_DISK_TYPE_FILE:
source = virXMLPropString(cur, "file");
- else
+ break;
+ case VIR_DOMAIN_DISK_TYPE_BLOCK:
source = virXMLPropString(cur, "dev");
+ break;
+ case VIR_DOMAIN_DISK_TYPE_DIR:
+ source = virXMLPropString(cur, "dir");
+ break;
+ default:
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unexpected disk type %s"),
+ virDomainDiskTypeToString(def->type));
+ goto error;
+ }
/* People sometimes pass a bogus '' source path
when they mean to omit the source element
@@ -3951,12 +3964,25 @@ virDomainDiskDefFormat(virConnectPtr conn,
}
if (def->src) {
- if (def->type == VIR_DOMAIN_DISK_TYPE_FILE)
+ switch (def->type) {
+ case VIR_DOMAIN_DISK_TYPE_FILE:
virBufferEscapeString(buf, " \n",
def->src);
- else
+ break;
+ case VIR_DOMAIN_DISK_TYPE_BLOCK:
virBufferEscapeString(buf, " \n",
def->src);
+ break;
+ case VIR_DOMAIN_DISK_TYPE_DIR:
+ virBufferEscapeString(buf, " \n",
+ def->src);
+ break;
+ default:
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unexpected disk type %s"),
+ virDomainDiskTypeToString(def->type));
+ return -1;
+ }
}
virBufferVSprintf(buf, " \n",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1fdb4fac7e..62014639f9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -67,6 +67,7 @@ enum virDomainVirtType {
enum virDomainDiskType {
VIR_DOMAIN_DISK_TYPE_BLOCK,
VIR_DOMAIN_DISK_TYPE_FILE,
+ VIR_DOMAIN_DISK_TYPE_DIR,
VIR_DOMAIN_DISK_TYPE_LAST
};
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f26e94dd8e..5f68411f88 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1994,8 +1994,30 @@ int qemudBuildCommandLine(virConnectPtr conn,
break;
}
- virBufferVSprintf(&opt, "file=%s", disk->src ? disk->src : "");
- virBufferVSprintf(&opt, ",if=%s", bus);
+ if (disk->src) {
+ if (disk->type == VIR_DOMAIN_DISK_TYPE_DIR) {
+ /* QEMU only supports magic FAT format for now */
+ if (disk->driverType &&
+ STRNEQ(disk->driverType, "fat")) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("unsupported disk driver type for '%s'"),
+ disk->driverType);
+ goto error;
+ }
+ if (!disk->readonly) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot create virtual FAT disks in read-write mode"));
+ goto error;
+ }
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
+ virBufferVSprintf(&opt, "file=fat:floppy:%s,", disk->src);
+ else
+ virBufferVSprintf(&opt, "file=fat:%s,", disk->src);
+ } else {
+ virBufferVSprintf(&opt, "file=%s,", disk->src);
+ }
+ }
+ virBufferVSprintf(&opt, "if=%s", bus);
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
virBufferAddLit(&opt, ",media=cdrom");
virBufferVSprintf(&opt, ",index=%d", idx);
@@ -2003,6 +2025,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
virBufferAddLit(&opt, ",boot=on");
if (disk->driverType &&
+ disk->type != VIR_DOMAIN_DISK_TYPE_DIR &&
qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_FORMAT)
virBufferVSprintf(&opt, ",format=%s", disk->driverType);
if (disk->serial &&
@@ -2071,7 +2094,27 @@ int qemudBuildCommandLine(virConnectPtr conn,
}
}
- snprintf(file, PATH_MAX, "%s", disk->src);
+ if (disk->type == VIR_DOMAIN_DISK_TYPE_DIR) {
+ /* QEMU only supports magic FAT format for now */
+ if (disk->driverType &&
+ STRNEQ(disk->driverType, "fat")) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("unsupported disk driver type for '%s'"),
+ disk->driverType);
+ goto error;
+ }
+ if (!disk->readonly) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot create virtual FAT disks in read-write mode"));
+ goto error;
+ }
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
+ snprintf(file, PATH_MAX, "fat:floppy:%s", disk->src);
+ else
+ snprintf(file, PATH_MAX, "fat:%s", disk->src);
+ } else {
+ snprintf(file, PATH_MAX, "%s", disk->src);
+ }
ADD_ARG_LIT(dev);
ADD_ARG_LIT(file);
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index bd838e67a9..255ba537b5 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -687,6 +687,9 @@ SELinuxSetSecurityLabel(virConnectPtr conn,
if (secdef->imagelabel) {
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)
+ continue;
if (SELinuxSetSecurityImageLabel(conn, vm, vm->def->disks[i]) < 0)
return -1;
}
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index d61e9e699b..e370eb887a 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -5375,11 +5375,16 @@ xenDaemonFormatSxprDisk(virConnectPtr conn ATTRIBUTE_UNUSED,
} else {
if (def->type == VIR_DOMAIN_DISK_TYPE_FILE) {
virBufferVSprintf(buf, "(uname 'file:%s')", def->src);
- } else {
+ } else if (def->type == VIR_DOMAIN_DISK_TYPE_BLOCK) {
if (def->src[0] == '/')
virBufferVSprintf(buf, "(uname 'phy:%s')", def->src);
else
virBufferVSprintf(buf, "(uname 'phy:/dev/%s')", def->src);
+ } else {
+ virXendError(conn, VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported disk type %s"),
+ virDomainDiskTypeToString(def->type));
+ return -1;
}
}
}
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 2ee321f0b3..40c199682e 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -1973,9 +1973,19 @@ static int xenXMDomainConfigFormatDisk(virConnectPtr conn,
if (STREQ(disk->driverName, "tap"))
virBufferVSprintf(&buf, "%s:", disk->driverType ? disk->driverType : "aio");
} else {
- virBufferVSprintf(&buf, "%s:",
- disk->type == VIR_DOMAIN_DISK_TYPE_FILE ?
- "file" : "phy");
+ switch (disk->type) {
+ case VIR_DOMAIN_DISK_TYPE_FILE:
+ virBufferAddLit(&buf, "file:");
+ break;
+ case VIR_DOMAIN_DISK_TYPE_BLOCK:
+ virBufferAddLit(&buf, "phy:");
+ break;
+ default:
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unsupported disk type %s"),
+ virDomainDiskTypeToString(disk->type));
+ goto cleanup;
+ }
}
virBufferVSprintf(&buf, "%s", disk->src);
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args
index 1ef2602b76..1dd90d035a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args
@@ -1 +1 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0 -drive file=,if=ide,media=cdrom,index=2 -net none -serial none -parallel none -usb
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0 -drive if=ide,media=cdrom,index=2 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.args
new file mode 100644
index 0000000000..da1163b180
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -drive file=fat:/var/somefiles,if=ide,index=0,boot=on -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.xml
new file mode 100644
index 0000000000..818ca93bf8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.xml
@@ -0,0 +1,24 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-floppy-drive-fat.args b/tests/qemuxml2argvdata/qemuxml2argv-floppy-drive-fat.args
new file mode 100644
index 0000000000..4b4e3f4e86
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-floppy-drive-fat.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot a -drive file=fat:floppy:/var/somefiles,if=floppy,index=0 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-floppy-drive-fat.xml b/tests/qemuxml2argvdata/qemuxml2argv-floppy-drive-fat.xml
new file mode 100644
index 0000000000..9e32b68a57
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-floppy-drive-fat.xml
@@ -0,0 +1,24 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219200
+ 219200
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c948379946..677c5b4ccb 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -211,6 +211,10 @@ mymain(int argc, char **argv)
QEMUD_CMD_FLAG_DRIVE_BOOT);
DO_TEST("disk-drive-boot-cdrom", QEMUD_CMD_FLAG_DRIVE |
QEMUD_CMD_FLAG_DRIVE_BOOT);
+ DO_TEST("floppy-drive-fat", QEMUD_CMD_FLAG_DRIVE |
+ QEMUD_CMD_FLAG_DRIVE_BOOT | QEMUD_CMD_FLAG_DRIVE_FORMAT);
+ DO_TEST("disk-drive-fat", QEMUD_CMD_FLAG_DRIVE |
+ QEMUD_CMD_FLAG_DRIVE_BOOT | QEMUD_CMD_FLAG_DRIVE_FORMAT);
DO_TEST("disk-drive-fmt-qcow", QEMUD_CMD_FLAG_DRIVE |
QEMUD_CMD_FLAG_DRIVE_BOOT | QEMUD_CMD_FLAG_DRIVE_FORMAT);
DO_TEST("disk-drive-shared", QEMUD_CMD_FLAG_DRIVE |
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 25ef2ce235..793900c8e3 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -98,6 +98,8 @@ mymain(int argc, char **argv)
DO_TEST("disk-many");
DO_TEST("disk-xenvbd");
DO_TEST("disk-usb");
+ DO_TEST("floppy-drive-fat");
+ DO_TEST("disk-drive-fat");
DO_TEST("disk-drive-fmt-qcow");
DO_TEST("disk-drive-cache-v1-wt");
DO_TEST("disk-drive-cache-v1-wb");