From patchwork Mon Jul 5 17:30:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 110271 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o65HUfb5017652 for ; Mon, 5 Jul 2010 17:30:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753056Ab0GERak (ORCPT ); Mon, 5 Jul 2010 13:30:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50680 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753010Ab0GERaj (ORCPT ); Mon, 5 Jul 2010 13:30:39 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o65HUb8o026379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Jul 2010 13:30:38 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o65HUbFv014531; Mon, 5 Jul 2010 13:30:37 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o65HUYqx002392; Mon, 5 Jul 2010 13:30:35 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: when available, use new syntax instead of -tftp, -bootp and -redir Date: Mon, 5 Jul 2010 20:30:25 +0300 Message-Id: <1278351025-13093-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 05 Jul 2010 17:30:43 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 1102f88..603576f 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -241,7 +241,8 @@ class VM: return cmd def add_net(help, vlan, mode, ifname=None, script=None, - downscript=None, netdev_id=None): + downscript=None, tftp=None, bootfile=None, hostfwd=[], + netdev_id=None): if has_option(help, "netdev"): cmd = " -netdev %s,id=%s" % (mode, netdev_id) else: @@ -250,16 +251,39 @@ class VM: if ifname: cmd += ",ifname='%s'" % ifname if script: cmd += ",script='%s'" % script cmd += ",downscript='%s'" % (downscript or "no") + elif mode == "user": + if tftp and "[,tftp=" in help: + cmd += ",tftp='%s'" % tftp + if bootfile and "[,bootfile=" in help: + cmd += ",bootfile='%s'" % bootfile + if "[,hostfwd=" in help: + for host_port, guest_port in hostfwd: + cmd += ",hostfwd=tcp::%s-:%s" % (host_port, guest_port) return cmd def add_floppy(help, filename): return " -fda '%s'" % filename def add_tftp(help, filename): - return " -tftp '%s'" % filename + # If the new syntax is supported, don't add -tftp + if "[,tftp=" in help: + return "" + else: + return " -tftp '%s'" % filename + + def add_bootp(help, filename): + # If the new syntax is supported, don't add -bootp + if "[,bootfile=" in help: + return "" + else: + return " -bootp '%s'" % filename def add_tcp_redir(help, host_port, guest_port): - return " -redir tcp:%s::%s" % (host_port, guest_port) + # If the new syntax is supported, don't add -redir + if "[,hostfwd=" in help: + return "" + else: + return " -redir tcp:%s::%s" % (host_port, guest_port) def add_vnc(help, vnc_port): return " -vnc :%d" % (vnc_port - 5900) @@ -345,6 +369,13 @@ class VM: image_params.get("image_snapshot") == "yes", image_params.get("image_boot") == "yes") + redirs = [] + for redir_name in kvm_utils.get_sub_dict_names(params, "redirs"): + redir_params = kvm_utils.get_sub_dict(params, redir_name) + guest_port = int(redir_params.get("guest_port")) + host_port = self.redirs.get(guest_port) + redirs += [(host_port, guest_port)] + vlan = 0 for nic_name in kvm_utils.get_sub_dict_names(params, "nics"): nic_params = kvm_utils.get_sub_dict(params, nic_name) @@ -357,13 +388,18 @@ class VM: # Handle the '-net tap' or '-net user' part script = nic_params.get("nic_script") downscript = nic_params.get("nic_downscript") + tftp = nic_params.get("tftp") if script: script = kvm_utils.get_path(root_dir, script) if downscript: downscript = kvm_utils.get_path(root_dir, downscript) + if tftp: + tftp = kvm_utils.get_path(root_dir, tftp) qemu_cmd += add_net(help, vlan, nic_params.get("nic_mode", "user"), nic_params.get("nic_ifname"), - script, downscript, self.netdev_id[vlan]) + script, downscript, tftp, + nic_params.get("bootp"), redirs, + self.netdev_id[vlan]) # Proceed to next NIC vlan += 1 @@ -400,6 +436,10 @@ class VM: tftp = kvm_utils.get_path(root_dir, tftp) qemu_cmd += add_tftp(help, tftp) + bootp = params.get("bootp") + if bootp: + qemu_cmd += add_bootp(help, bootp) + kernel = params.get("kernel") if kernel: kernel = kvm_utils.get_path(root_dir, kernel) @@ -414,10 +454,7 @@ class VM: initrd = kvm_utils.get_path(root_dir, initrd) qemu_cmd += add_initrd(help, initrd) - for redir_name in kvm_utils.get_sub_dict_names(params, "redirs"): - redir_params = kvm_utils.get_sub_dict(params, redir_name) - guest_port = int(redir_params.get("guest_port")) - host_port = self.redirs.get(guest_port) + for host_port, guest_port in redirs: qemu_cmd += add_tcp_redir(help, host_port, guest_port) if params.get("display") == "vnc": diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 62936d4..c2def29 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -526,7 +526,8 @@ variants: pxe_image = "vmlinuz" pxe_initrd = "initrd.img" tftp = "images/tftpboot" - extra_params += " -bootp /pxelinux.0 -boot cn" + bootp = "/pxelinux.0" + extra_params += " -boot cn" kernel_args = "ks=floppy nicdelay=60 console=ttyS0,115200 console=tty0" variants: @@ -687,7 +688,8 @@ variants: pxe_image = "linux" pxe_initrd = "initrd" tftp = "images/tftpboot" - extra_params += " -bootp /pxelinux.0 -boot cn" + bootp = "/pxelinux.0" + extra_params += " -boot cn" kernel_args = "autoyast=floppy console=ttyS0,115200 console=tty0" post_install_delay = 10 @@ -769,7 +771,8 @@ variants: unattended_install.cdrom: pxe_image = "linux" pxe_initrd = "initrd" - extra_params += " -bootp /pxelinux.0 -boot cn" + bootp = "/pxelinux.0" + extra_params += " -boot cn" kernel_args = "autoyast=floppy console=ttyS0,115200 console=tty0" post_install_delay = 10 @@ -861,7 +864,8 @@ variants: pxe_image = "vmlinuz" pxe_initrd = "initrd.img" tftp = "images/tftpboot" - extra_params += " -bootp /pxelinux.0 -boot cn" + bootp = "/pxelinux.0" + extra_params += " -boot cn" kernel_args = "ks=floppy nicdelay=60 console=ttyS0,115200 console=tty0" variants: