From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id CD0311D8A for ; Wed, 22 Nov 2017 10:37:00 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 16FAF1435; Wed, 22 Nov 2017 01:37:00 -0800 (PST) Received: from phil-VirtualBox.shanghai.arm.com (phil-virtualbox.shanghai.arm.com [10.169.38.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3353E3F318; Wed, 22 Nov 2017 01:36:59 -0800 (PST) From: Phil Yang To: dts@dpdk.org Cc: nd@arm.com, Jianbo.Liu@arm.com, Herbert.Guan@arm.com, phil.yang@arm.com Date: Wed, 22 Nov 2017 17:36:41 +0800 Message-Id: <1511343401-6459-1-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH] framework/qemu_kvm: Add machine and pflash option support X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Nov 2017 09:37:01 -0000 1. Add machine and pflash option support; 2. Set default machine type 'virt' for Aarch64; 3. Fix Aarch64 vhost vm case failure when using the default "-net nic model". since the default nic type in vm is "virtio". 4. Add opt_format, opt_if, opt_index, opt_media for disk option. Signed-off-by: Phil Yang --- conf/vhost_sample.cfg | 10 ++++++++++ framework/qemu_kvm.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/conf/vhost_sample.cfg b/conf/vhost_sample.cfg index 8bdc20e..ab71936 100644 --- a/conf/vhost_sample.cfg +++ b/conf/vhost_sample.cfg @@ -2,6 +2,9 @@ # name # name: vm0 # +# machine +# machine: [virt | ...] +# # enable_kvm # enable: [yes | no] # @@ -18,6 +21,13 @@ # # disk # file: /path/to/image/test.img +# opt_format: raw +# opt_if: virtio +# opt_index: 0 +# opt_media: disk +# +# pflash +# file: /path/to/image/pflash0.img # # char # opt_path: define the file path to vhost-net socket file diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index 79095bd..42acd69 100644 --- a/framework/qemu_kvm.py +++ b/framework/qemu_kvm.py @@ -98,12 +98,17 @@ class QEMUKvm(VirtBase): # internal variable to track whether default nic has been added self.__default_nic = False + # arch info for multi-paltform init + self.arch = self.host_session.send_expect('uname -m', '# ') + # set some default values for vm, # if there is not the values of the specified options self.set_vm_default() def set_vm_default(self): self.set_vm_name(self.vm_name) + if self.arch == 'aarch64': + self.set_vm_machine('virt') self.set_vm_enable_kvm() self.set_vm_pid_file() self.set_vm_qga() @@ -249,6 +254,25 @@ class QEMUKvm(VirtBase): enable_kvm_boot_line = '-enable-kvm' self.__add_boot_line(enable_kvm_boot_line) + def set_vm_machine(self, machine): + """ + Set VM boot option to specify the option 'machine'. + """ + index = self.find_option_index('machine') + if index: + self.params[index] = {'machine': [{'machine': '%s' % machine}]} + else: + self.params.append({'machine': [{'machine': '%s' % machine}]}) + + def add_vm_machine(self, **options): + """ + 'machine': 'virt' + """ + if 'machine' in options.keys() and \ + options['machine']: + machine_boot_line = '-machine %s' % options['machine'] + self.__add_boot_line(machine_boot_line) + def set_vm_pid_file(self): """ Set VM pidfile option for manage qemu process @@ -329,11 +353,32 @@ class QEMUKvm(VirtBase): def add_vm_disk(self, **options): """ file: /home/image/test.img + opt_format: raw + opt_if: virtio + opt_index: 0 + opt_media: disk """ + separator = ',' if 'file' in options.keys(): disk_boot_line = '-drive file=%s' % options['file'] + if 'opt_format' in options.keys(): + disk_boot_line += separator + 'format=%s' % options['opt_format'] + if 'opt_if' in options.keys(): + disk_boot_line += separator + 'if=%s' % options['opt_if'] + if 'opt_index' in options.keys(): + disk_boot_line += separator + 'index=%s' % options['opt_index'] + if 'opt_media' in options.keys(): + disk_boot_line += separator + 'media=%s' % options['opt_media'] self.__add_boot_line(disk_boot_line) + def add_vm_pflash(self, **options): + """ + file: /home/image/flash0.img + """ + if 'file' in options.keys(): + pflash_boot_line = '-pflash %s' % options['file'] + self.__add_boot_line(pflash_boot_line) + def add_vm_login(self, **options): """ user: login username of virtual machine -- 2.7.4