]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add tftp protocol support for cdrom disk
authorAline Manera <alinefm@br.ibm.com>
Mon, 16 Sep 2013 17:12:53 +0000 (14:12 -0300)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 17 Sep 2013 13:45:02 +0000 (14:45 +0100)
qemu/KVM also supports a tftp URL while specifying the cdrom ISO image.

The xml should be as following:

    <disk type='network' device='cdrom'>
      <source protocol='tftp' name='/url/path'>
        <host name='host.name' port='69'/>
      </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-tftp.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 0b6cd455d4134f5f526b78febeecf028af9ec161..a927643c3991b1ce44b6d9ccee208af1f32b330b 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="tftp" name="url_path"&gt;
+        &lt;host name="hostname" port="69"/&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 2da36691c154cf1bb270739e487e02a6f019203b..4d333a84e176ee96b73d6f08bd679c11eecce990 100644 (file)
         <value>https</value>
         <value>ftp</value>
         <value>ftps</value>
+        <value>tftp</value>
       </choice>
     </attribute>
     <optional>
index ff3da7a7dc7871f214c0a3469ec663d203309099..05c1de4f53314110eb51d46995a3facb5df78412 100644 (file)
@@ -267,7 +267,8 @@ VIR_ENUM_IMPL(virDomainDiskProtocol, VIR_DOMAIN_DISK_PROTOCOL_LAST,
               "http",
               "https",
               "ftp",
-              "ftps")
+              "ftps",
+              "tftp")
 
 VIR_ENUM_IMPL(virDomainDiskProtocolTransport, VIR_DOMAIN_DISK_PROTO_TRANS_LAST,
               "tcp",
index ab1290b4aaa65a1fd49a093ae6cf9f98cba4c47e..9414ebff76efec6440be2d54da8318e458351d1e 100644 (file)
@@ -546,6 +546,7 @@ enum virDomainDiskProtocol {
     VIR_DOMAIN_DISK_PROTOCOL_HTTPS,
     VIR_DOMAIN_DISK_PROTOCOL_FTP,
     VIR_DOMAIN_DISK_PROTOCOL_FTPS,
+    VIR_DOMAIN_DISK_PROTOCOL_TFTP,
 
     VIR_DOMAIN_DISK_PROTOCOL_LAST
 };
index 1bde013802729217f1ecebab8b421b9eddcda7bd..4628dac73e3f3cc6e963ba4643273476b57976dc 100644 (file)
@@ -3923,6 +3923,12 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
                                   disk->hosts->port ? disk->hosts->port : "990");
                 virBufferEscape(&opt, ',', ",", "%s,", disk->src);
                 break;
+            case VIR_DOMAIN_DISK_PROTOCOL_TFTP:
+                virBufferAsprintf(&opt, "file=tftp://%s:%s",
+                                  disk->hosts->name,
+                                  disk->hosts->port ? disk->hosts->port : "69");
+                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-tftp.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.args
new file mode 100644 (file)
index 0000000..bc0cb92
--- /dev/null
@@ -0,0 +1,7 @@
+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=tftp://host.name:69/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-tftp.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.xml
new file mode 100644 (file)
index 0000000..b311237
--- /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='tftp' name='/url/path/file.iso'>
+        <host name='host.name' port='69'/>
+      </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 5daee822a9075b77f628051df9fac856a3c4832a..ec4a6e5777968b29d4b5016a3c9a31850789380c 100644 (file)
@@ -451,6 +451,8 @@ mymain(void)
             QEMU_CAPS_DRIVE);
     DO_TEST("disk-cdrom-network-ftps", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
             QEMU_CAPS_DRIVE);
+    DO_TEST("disk-cdrom-network-tftp", 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);