[libvirt] [PATCH 2/3] Add ftps protocol support for cdrom disk

Aline Manera alinefm at linux.vnet.ibm.com
Mon Sep 16 17:12:52 UTC 2013


From: Aline Manera <alinefm at br.ibm.com>

The ftps protocol is another protocol supported by qemu/KVM while specifying
the cdrom ISO image.

The xml should be as following:

    <disk type='network' device='cdrom'>
      <source protocol='ftps' name='/url/path'>
        <host name='host.name' port='990'/>
      </source>
    </disk>

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 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-ftps.args      |    8 +++++
 .../qemuxml2argv-disk-cdrom-network-ftps.xml       |   37 ++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |    2 ++
 8 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 240571f..0b6cd45 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1525,6 +1525,14 @@
       <target dev='hdc' bus='ide' tray='open'/>
       <readonly/>
     </disk>
+    <disk type='network' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source protocol="ftps" name="url_path">
+        <host name="hostname" port="990"/>
+      </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 2f91f0f..2da3669 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1233,6 +1233,7 @@
         <value>http</value>
         <value>https</value>
         <value>ftp</value>
+        <value>ftps</value>
       </choice>
     </attribute>
     <optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e83292e..cff26df 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -266,7 +266,8 @@ VIR_ENUM_IMPL(virDomainDiskProtocol, VIR_DOMAIN_DISK_PROTOCOL_LAST,
               "iscsi",
               "http",
               "https",
-              "ftp")
+              "ftp",
+              "ftps")
 
 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 04aaa95..b3854a5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -545,6 +545,7 @@ enum virDomainDiskProtocol {
     VIR_DOMAIN_DISK_PROTOCOL_HTTP,
     VIR_DOMAIN_DISK_PROTOCOL_HTTPS,
     VIR_DOMAIN_DISK_PROTOCOL_FTP,
+    VIR_DOMAIN_DISK_PROTOCOL_FTPS,
 
     VIR_DOMAIN_DISK_PROTOCOL_LAST
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 883b513..1bde013 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3917,6 +3917,12 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
                                   disk->hosts->port ? disk->hosts->port : "21");
                 virBufferEscape(&opt, ',', ",", "%s,", disk->src);
                 break;
+            case VIR_DOMAIN_DISK_PROTOCOL_FTPS:
+                virBufferAsprintf(&opt, "file=ftps://%s:%s",
+                                  disk->hosts->name,
+                                  disk->hosts->port ? disk->hosts->port : "990");
+                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-ftps.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.args
new file mode 100644
index 0000000..78dbff2
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.args
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/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=ftps://host.name:990/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-ftps.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.xml
new file mode 100644
index 0000000..b4a0f52
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.xml
@@ -0,0 +1,37 @@
+<domain type='kvm'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-1.2'>hvm</type>
+    <boot dev='cdrom'/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/kvm</emulator>
+    <disk type='network' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source protocol='ftps' name='/url/path/file.iso'>
+        <host name='host.name' port='990'/>
+      </source>
+      <target dev='hdc' bus='ide'/>
+      <readonly/>
+      <alias name='ide0-1-0'/>
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a11c9a8..5daee82 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -449,6 +449,8 @@ mymain(void)
             QEMU_CAPS_DRIVE);
     DO_TEST("disk-cdrom-network-ftp", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
             QEMU_CAPS_DRIVE);
+    DO_TEST("disk-cdrom-network-ftps", 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);
-- 
1.7.10.4




More information about the libvir-list mailing list