]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add ftp protocol support for cdrom disk
authorAline Manera <alinefm@br.ibm.com>
Thu, 22 Aug 2013 19:03:08 +0000 (16:03 -0300)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 27 Aug 2013 12:50:24 +0000 (14:50 +0200)
The ftp protocol is already recognized by qemu/KVM so add this support to
libvirt as well.
The xml should be as following:

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

Signed-off-by: Aline Manera <alinefm@br.ibm.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 7df6042501a09e6b8bf54a1ae3b4b3d72af19437..7f057ec87dc050b2207f7144d4a09c946b3ac291 100644 (file)
       &lt;target dev='hdc' bus='ide' tray='open'/&gt;
       &lt;readonly/&gt;
     &lt;/disk&gt;
+    &lt;disk type='network' device='cdrom'&gt;
+      &lt;driver name='qemu' type='raw'/&gt;
+      &lt;source protocol="ftp" name="url_path"&gt;
+        &lt;host name="hostname" port="21"/&gt;
+      &lt;/source&gt;
+      &lt;target dev='hdc' bus='ide' tray='open'/&gt;
+      &lt;readonly/&gt;
+    &lt;/disk&gt;
     &lt;disk type='block' device='lun'&gt;
       &lt;driver name='qemu' type='raw'/&gt;
       &lt;source dev='/dev/sda'/&gt;
index 29ebd37c531e41624a7823ca4d2e6a3604bc169e..3df61f696abfba66b617fb183f2169aef8aeccd0 100644 (file)
         <value>gluster</value>
         <value>iscsi</value>
         <value>http</value>
+        <value>ftp</value>
       </choice>
     </attribute>
     <optional>
index 8a345e8e63f08193861ca71bf2cecb2e0e94ff53..ffd7ac75f70b8333176d373043bac89ba3ad637b 100644 (file)
@@ -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",
index 77fa00cb0fa954b376c3eb1aae83fe865895473f..6cb2d85b7171e98f4e1c67f4e0a01438b6474f9f 100644 (file)
@@ -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
 };
index f2a9a9720b6ff042496435c9d5432c8a90769f69..d8e5b471d418b06b87a19f8bafe1c764758a519a 100644 (file)
@@ -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 (file)
index 0000000..4fae2b0
--- /dev/null
@@ -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 (file)
index 0000000..660dedf
--- /dev/null
@@ -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='ftp' name='/url/path/file.iso'>
+        <host name='host.name' port='21'/>
+      </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>
index 79e144f4633ac86fd08bd10de97002ae746b0674..fda5a0a678b48fdd2816b734491e335fee5e93d4 100644 (file)
@@ -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);