From 796513d7cc01984fa7faebeb6dfb3541edeb09c6 Mon Sep 17 00:00:00 2001 From: Aline Manera Date: Thu, 22 Aug 2013 16:03:08 -0300 Subject: [PATCH] Add ftp protocol support for cdrom disk The ftp protocol is already recognized by qemu/KVM so add this support to libvirt as well. The xml should be as following: Signed-off-by: Aline Manera --- docs/formatdomain.html.in | 8 ++++ docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 3 +- src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 6 +++ .../qemuxml2argv-disk-cdrom-network-ftp.args | 6 +++ .../qemuxml2argv-disk-cdrom-network-ftp.xml | 37 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 + 8 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 7df6042501..7f057ec87d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1509,6 +1509,14 @@ <target dev='hdc' bus='ide' tray='open'/> <readonly/> </disk> + <disk type='network' device='cdrom'> + <driver name='qemu' type='raw'/> + <source protocol="ftp" name="url_path"> + <host name="hostname" port="21"/> + </source> + <target dev='hdc' bus='ide' tray='open'/> + <readonly/> + </disk> <disk type='block' device='lun'> <driver name='qemu' type='raw'/> <source dev='/dev/sda'/> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 29ebd37c53..3df61f696a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1212,6 +1212,7 @@ gluster iscsi http + ftp diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8a345e8e63..ffd7ac75f7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -262,7 +262,8 @@ VIR_ENUM_IMPL(virDomainDiskProtocol, VIR_DOMAIN_DISK_PROTOCOL_LAST, "sheepdog", "gluster", "iscsi", - "http") + "http", + "ftp") VIR_ENUM_IMPL(virDomainDiskProtocolTransport, VIR_DOMAIN_DISK_PROTO_TRANS_LAST, "tcp", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 77fa00cb0f..6cb2d85b71 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -541,6 +541,7 @@ enum virDomainDiskProtocol { VIR_DOMAIN_DISK_PROTOCOL_GLUSTER, VIR_DOMAIN_DISK_PROTOCOL_ISCSI, VIR_DOMAIN_DISK_PROTOCOL_HTTP, + VIR_DOMAIN_DISK_PROTOCOL_FTP, VIR_DOMAIN_DISK_PROTOCOL_LAST }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f2a9a9720b..d8e5b471d4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3833,6 +3833,12 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED, disk->hosts->port ? disk->hosts->port : "80"); virBufferEscape(&opt, ',', ",", "%s,", disk->src); break; + case VIR_DOMAIN_DISK_PROTOCOL_FTP: + virBufferAsprintf(&opt, "file=ftp://%s:%s", + disk->hosts->name, + disk->hosts->port ? disk->hosts->port : "21"); + virBufferEscape(&opt, ',', ",", "%s,", disk->src); + break; } } else if (disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME) { if (qemuBuildVolumeString(conn, disk, &opt) < 0) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args new file mode 100644 index 0000000000..4fae2b08da --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args @@ -0,0 +1,6 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/kvm -S \ +-M pc-1.2 -m 1024 -smp 1 -nographic -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -boot d -usb \ +-drive file=ftp://host.name:21/url/path/file.iso,if=none,media=cdrom,id=drive-ide0-1-0 \ +-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml new file mode 100644 index 0000000000..660dedf921 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml @@ -0,0 +1,37 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/bin/kvm + + + + + + + + +
+ + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 79e144f463..fda5a0a678 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -445,6 +445,8 @@ mymain(void) DO_TEST("disk-cdrom", NONE); DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE); + DO_TEST("disk-cdrom-network-ftp", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, + QEMU_CAPS_DRIVE); DO_TEST("disk-cdrom-empty", QEMU_CAPS_DRIVE); DO_TEST("disk-cdrom-tray", QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_TX_ALG);