[PATCH v2] qemu: add port check for host when disk type is network

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For network type disk, host port is not checked when start a guest,
so the error may be unclear when with invalid port. If pass -1 to port
the error will be
error: Failed to start domain rh6-i
error: An error occurred, but the cause is unknown
So make a check to make sure the port range from 0 to 65536

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1163553
Signed-off-by: Shanzhi Yu <shyu@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f674ba9..66082e1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3016,6 +3016,18 @@ qemuBuildNetworkDriveURI(int protocol,
         case VIR_STORAGE_NET_PROTOCOL_FTPS:
         case VIR_STORAGE_NET_PROTOCOL_TFTP:
         case VIR_STORAGE_NET_PROTOCOL_ISCSI:
+            if (VIR_ALLOC(uri) < 0)
+                goto cleanup;
+
+            if (qemuNetworkDriveGetPort(protocol, hosts->port) < 0 ||
+                qemuNetworkDriveGetPort(protocol, hosts->port) > 65536) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("port should be in range 0 to 65536 for '%s' host"),
+                               virStorageNetProtocolTypeToString(protocol));
+
+                goto cleanup;
+            }
+
         case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
             if (nhosts != 1) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]