From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 986E92A5E for ; Tue, 2 Jan 2018 03:21:34 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jan 2018 18:21:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,494,1508828400"; d="scan'208";a="18258773" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 01 Jan 2018 18:21:32 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 1 Jan 2018 18:21:32 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 1 Jan 2018 18:21:31 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Tue, 2 Jan 2018 10:21:30 +0800 From: "Liu, Yong" To: Herbert Guan , "dts@dpdk.org" CC: Phil Yang , Jianbo Liu , nd , "Mo, YufengX" Thread-Topic: [dts] [PATCH] framework: enable AArch64 and add more options for libvirt Thread-Index: AQHTbYx31U2LqjVfPEiJwC3tO0OwQqNPA/7Q//+wOwCAEU68MA== Date: Tue, 2 Jan 2018 02:21:29 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62F3C6CF@SHSMSX103.ccr.corp.intel.com> References: <1512452777-3982-1-git-send-email-herbert.guan@arm.com> <86228AFD5BCD8E4EBFD2B90117B5E81E62F3804E@SHSMSX103.ccr.corp.intel.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmE0YzA0ZmMtNThmYy00NjExLTgxY2QtZmE1NzUxOTNmODkwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiIwWXVVZHYwTmxzQUx3VzJ2THVmOGF3YkpmWUJ6SEpGOUdad295Y3VLV2JoUnkxbDNwM3lsZmpMclRtKzh4aVlOIn0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH] framework: enable AArch64 and add more options for libvirt 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: Tue, 02 Jan 2018 02:21:35 -0000 Herber, Sorry for late response, I was on vacation last week. For my previous comme= nts, I just want to separated arch specified stuffs.=20 Some common things like disk/graphic should be done in independent function= s like add_vm_disk.=20 You can change the previous functions, I think below is the specified thing= s for x86_64. def set_vm_default_x86(self): os =3D ET.SubElement(self.domain, 'os') type =3D ET.SubElement( os, 'type', {'arch': 'x86_64', 'machine': 'pc-i440fx-1.6'}) type.text =3D 'hvm' features =3D ET.SubElement(self.domain, 'features') ET.SubElement(features, 'acpi') ET.SubElement(features, 'apic') ET.SubElement(features, 'pae') ET.SubElement(self.domain, 'cpu', {'mode': 'host-passthrough'}) Thanks, Marvin > -----Original Message----- > From: Herbert Guan [mailto:Herbert.Guan@arm.com] > Sent: Friday, December 22, 2017 5:53 PM > To: Liu, Yong ; dts@dpdk.org > Cc: Phil Yang ; Jianbo Liu ; nd > > Subject: RE: [dts] [PATCH] framework: enable AArch64 and add more options > for libvirt >=20 > Marvin, >=20 > > -----Original Message----- > > From: Liu, Yong [mailto:yong.liu@intel.com] > > Sent: Friday, December 22, 2017 16:10 > > To: Herbert Guan ; dts@dpdk.org > > Cc: Phil Yang ; Jianbo Liu > > Subject: RE: [dts] [PATCH] framework: enable AArch64 and add more > options > > for libvirt > > > > Herbert, thanks for your patch. I'm not very clear about what is must > for > > AArch64 support and what is for enabling your environment. > > Please separate them in different functions. >=20 > To make it more clear, are you requesting to split this patch into smalle= r > ones (maybe around 6 patches)? >=20 > > > > Thanks, > > Marvin > > > > > -----Original Message----- > > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Herbert Guan > > > Sent: Tuesday, December 05, 2017 1:46 PM > > > To: dts@dpdk.org > > > Cc: phil.yang@arm.com; jianbo.liu@arm.com; Herbert Guan > > > > > > Subject: [dts] [PATCH] framework: enable AArch64 and add more options > > > for libvirt > > > > > > 1) Add the libvirt support on AArch64 platforms > > > 2) Add 'loader' and 'nvram' option support in 'os' section > > > 3) Add 'opt_bus', 'opt_dev' and 'opt_controller' option support in > > > 'disk' section. Change 'type' to 'opt_format' to get aligined > > > with option naming in qemu_kvm. > > > 4) Add serial 'serial_option' option support for serial console > > > 5) Add domain parsing in __parse_pci() > > > 6) Function add_vm_device() supports both VF (new) and PF devices now > > > > > > Signed-off-by: Herbert Guan > > > --- > > > conf/vm_power_manager.cfg | 4 +- > > > framework/qemu_libvirt.py | 152 > > > ++++++++++++++++++++++++++++++++++++++--- > > > ----- > > > 2 files changed, 128 insertions(+), 28 deletions(-) mode change > > > 100644 =3D> 100755 conf/vm_power_manager.cfg mode change 100644 =3D> > > > 100755 framework/qemu_libvirt.py > > > > > > diff --git a/conf/vm_power_manager.cfg b/conf/vm_power_manager.cfg > > old > > > mode 100644 new mode 100755 index 9c8f87a..7d5d9b6 > > > --- a/conf/vm_power_manager.cfg > > > +++ b/conf/vm_power_manager.cfg > > > @@ -7,7 +7,7 @@ > > > # size: 4096 > > > # disk > > > # file: absolute path to disk image > > > -# type: disk image format > > > +# opt_format: [ raw | qcow2 | ... ] #disk image format > > > # login > > > # user: user name to login into VM > > > # password: passwork to login into VM > > > @@ -25,7 +25,7 @@ cpu =3D > > > mem =3D > > > size=3D4096; > > > disk =3D > > > - file=3D/storage/vm-image/vm0.img,type=3Draw; > > > + file=3D/storage/vm-image/vm0.img,opt_format=3Draw; > > > login =3D > > > user=3Droot,password=3Dtester; > > > [vm1] > > > diff --git a/framework/qemu_libvirt.py b/framework/qemu_libvirt.py ol= d > > > mode 100644 new mode 100755 index ed8e0e6..18dcd8b > > > --- a/framework/qemu_libvirt.py > > > +++ b/framework/qemu_libvirt.py > > > @@ -57,6 +57,7 @@ class LibvirtKvm(VirtBase): > > > > > > # disk and pci device default index > > > self.diskindex =3D 'a' > > > + self.controllerindex =3D 0 > > > self.pciindex =3D 10 > > > > > > # configure root element > > > @@ -82,7 +83,12 @@ class LibvirtKvm(VirtBase): > > > > > > # set some default values for vm, > > > # if there is not the values of the specified options > > > - self.set_vm_default() > > > + arch =3D self.host_session.send_expect('uname -m', '# ') > > > + set_default_func =3D getattr(self, 'set_vm_default_' + arch) > > > + if callable(set_default_func): > > > + set_default_func() > > > + else: > > > + self.set_vm_default() > > > > I'm not sure how much is the difference between x86 and AArch64 platfor= m. > > Look like somethings are common for example graphic and control > interface. > > Could we separate arch related setting in separated function and keep > those > > common in another function? > > >=20 > How about this: call into common function set_vm_default() first, and the= n > call arch specific function set_vm_default_'x86_64/aarch64/...'()? >=20 > > > > > > def get_qemu_emulator(self): > > > """ > > > @@ -98,6 +104,13 @@ class LibvirtKvm(VirtBase): > > > """ > > > check and setup host virtual ability > > > """ > > > + arch =3D self.host_session.send_expect('uname -m', '# ') > > > + if arch =3D=3D 'aarch64': > > > + out =3D self.host_session.send_expect('service libvirtd > > > + status', > > > "# ") > > > + if 'active (running)' not in out: > > > + return False > > > + return True > > > + > > > > Herbert, libvirt status has been checked in function has_virtual_abilit= y > when > > initialize LibvirtKvm object. > > Why do this check again? > > >=20 > This is not double check but just modifying the logic of > "has_virtual_ability ". It defines the specific checking logic for arm > platforms. And if it's not 'aarch64' platform, will go with the original > logic. >=20 > > > out =3D self.host_session.send_expect('cat /proc/cpuinfo | g= rep > > > flags', > > > '# ') > > > rgx =3D re.search(' vmx ', out) @@ -201,6 +214,47 @@ class > > > LibvirtKvm(VirtBase): > > > ',name=3Dorg.qemu.guest_agent.0'}) > > > self.qga_sock_path =3D '/tmp/%s_qga0.sock' % self.vm_name > > > > > > + def add_vm_os(self, **options): > > > + os =3D self.domain.find('os') > > > + if 'loader' in options.keys(): > > > + loader =3D ET.SubElement( > > > + os, 'loader', {'readonly': 'yes', 'type': 'pflash'}) > > > + loader.text =3D options['loader'] > > > + if 'nvram' in options.keys(): > > > + nvram =3D ET.SubElement(os, 'nvram') > > > + nvram.text =3D options['nvram'] > > > + > > > > Where this function is called? >=20 > It's called by load_local_config() in virt_base.py. There'll be an entry > added in case config file, such as: > os =3D >=20 > loader=3D/usr/share/AAVMF/AAVMF_CODE.fd,nvram=3D/var/lib/libvirt/qemu/nvr= am/vm > 0_VARS.fd; >=20 > > > > > + > > > + def set_vm_default_aarch64(self): > > > + os =3D ET.SubElement(self.domain, 'os') > > > + type =3D ET.SubElement( > > > + os, 'type', {'arch': 'aarch64', 'machine': 'virt'}) > > > + type.text =3D 'hvm' > > > + ET.SubElement(os, 'boot', {'dev': 'hd'}) > > > + > > > + features =3D ET.SubElement(self.domain, 'features') > > > + ET.SubElement(features, 'acpi')=09 > > > + ET.SubElement(features, 'gic', {'version': '3'}) > > > + > > > + ET.SubElement(self.domain, 'cpu', > > > + {'mode': 'host-passthrough', 'check': 'none'}) > > > + > > > + # qemu-kvm for emulator > > > + device =3D ET.SubElement(self.domain, 'devices') > > > + ET.SubElement(device, 'emulator').text =3D self.qemu_emulato= r > > > + > > > + # graphic device > > > + #ET.SubElement(device, 'graphics', { > > > + # 'type': 'vnc', 'port': '-1', 'autoport': > 'yes'}) > > > + # qemu guest agent > > > + self.add_vm_qga(None) > > > + > > > + # add default control interface > > > + if not self.__default_nic: > > > + def_nic =3D {'type': 'nic', 'opt_hostfwd': ''} > > > + self.add_vm_net(**def_nic) > > > + self.__default_nic =3D True > > > + > > > def set_vm_default(self): > > > os =3D ET.SubElement(self.domain, 'os') > > > type =3D ET.SubElement( > > > @@ -273,17 +327,44 @@ class LibvirtKvm(VirtBase): > > > return False > > > > > > ET.SubElement(disk, 'source', {'file': options['file']}) > > > - if 'type' not in options: > > > + if 'opt_format' not in options: > > > disk_type =3D 'raw' > > > else: > > > - disk_type =3D options['type'] > > > + disk_type =3D options['opt_format'] > > > > > > ET.SubElement(disk, 'driver', {'name': 'qemu', 'type': > > > disk_type}) > > > > > > + if 'opt_bus' not in options: > > > + bus =3D 'virtio' > > > + else: > > > + bus =3D options['opt_bus'] > > > + if 'opt_dev' not in options: > > > + dev =3D 'vd%c' % self.diskindex > > > + self.diskindex =3D chr(ord(self.diskindex) + 1) > > > + else: > > > + dev =3D options['opt_dev'] > > > ET.SubElement( > > > - disk, 'target', {'dev': 'vd%c' % self.diskindex, 'bus': > > > 'virtio'}) > > > + disk, 'target', {'dev': dev, 'bus': bus}) > > > + > > > + if 'opt_controller' in options: > > > + controller =3D ET.SubElement(devices, 'controller', > > > + {'type': bus, > > > + 'index': hex(self.controllerindex)[2:], > > > + 'model': options['opt_controller']}) > > > + self.controllerindex +=3D 1 > > > + ET.SubElement(controller, 'address', > > > + {'type': 'pci', 'domain': '0x0000', 'bus': > > > hex(self.pciindex), > > > + 'slot': '0x00', 'function': '0x00'}) > > > + self.pciindex +=3D 1 > > > > > > - self.diskindex =3D chr(ord(self.diskindex) + 1) > > > + def add_vm_serial_port(self, **options): > > > + if 'enable' in options.keys(): > > > + if options['enable'].lower() =3D=3D 'yes': > > > + devices =3D self.domain.find('devices') > > > + serial =3D ET.SubElement(devices, 'serial', {'type': > 'pty'}) > > > + ET.SubElement(serial, 'target', {'port': '0'}) > > > + console =3D ET.SubElement(devices, 'console', {'type= ': > > > 'pty'}) > > > + ET.SubElement(console, 'target', {'type': 'serial', > > > 'port': '0'}) > > > > > > > In qemu kvm module, we are using unix domain socket for serial device. > Can > > you align to this? > > Please let device type should be configurable, we plan to add more type= s > > later. >=20 > OK, I'll add the unix socket support and make type configurable in the ne= w > version. >=20 > > > > > def add_vm_login(self, **options): > > > """ > > > @@ -305,14 +386,23 @@ class LibvirtKvm(VirtBase): > > > def __parse_pci(self, pci_address): > > > pci_regex =3D r"([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2})" + \ > > > ".([0-9a-fA-F]{1,2})" > > > + pci_regex_domain =3D r"([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,2})= :" > + \ > > > + "([0-9a-fA-F]{1,2}).([0-9a-fA-F]{1,2})" > > > m =3D re.match(pci_regex, pci_address) > > > - if m is None: > > > - return None > > > - bus =3D m.group(1) > > > - slot =3D m.group(2) > > > - func =3D m.group(3) > > > - > > > - return (bus, slot, func) > > > + if m is not None: > > > + bus =3D m.group(1) > > > + slot =3D m.group(2) > > > + func =3D m.group(3) > > > + dom =3D '0' > > > + return (bus, slot, func, dom) > > > + m =3D re.match(pci_regex_domain, pci_address) > > > + if m is not None: > > > + bus =3D m.group(2) > > > + slot =3D m.group(3) > > > + func =3D m.group(4) > > > + dom =3D m.group(1) > > > + return (bus, slot, func, dom) > > > + return None > > > > > > def add_vm_device(self, **options): > > > """ > > > @@ -325,35 +415,45 @@ class LibvirtKvm(VirtBase): > > > 'mode': 'subsystem', 'type': 'pci= ', > > > 'managed': 'yes'}) > > > > > > - if 'pf_idx' not in options.keys(): > > > - print utils.RED("Missing device index for device > option!!!") > > > - return False > > > - > > > - pf =3D int(options['pf_idx']) > > > - if pf > len(self.host_dut.ports_info): > > > - print utils.RED("PF device index over size!!!") > > > + if 'pf_idx' in options.keys(): > > > + pf =3D int(options['pf_idx']) > > > + if pf > len(self.host_dut.ports_info): > > > + print utils.RED("PF device index over size!!!") > > > + return False > > > > Previous check sentence is incorrect:) Should be "if pf >=3D > > len(self.host_dut.ports_info):". > > Most of suites are just using option "opt_host" to specify the pci > address of > > device. So I'm planning to remove pf_idx option, what's your idea for > that? > > > Fully agree switching to "opt_host" to specify the PCI address. This can > match the function name "add_vm_device" better, not limited to pf/vf NIC > devices. 'vf_idx' was added just because it only support pf before, but > this is quite complex and not aligned with vf_xx suites. I can make such > change if decided to go. Could you confirm that? >=20 > > > + pci_addr =3D self.host_dut.ports_info[pf]['pci'] > > > + elif 'vf_idx' in options.keys(): > > > + vf =3D int(options['vf_idx']) > > > + if vf > len(self.host_dut.ports_info): > > > + print utils.RED("VF device index over size!!!") > > > + return False > > > + if 'vf_id' in options.keys(): > > > + vf_id =3D int(options['vf_id']) > > > + else: > > > + vf_id =3D 0 > > > + pci_addr =3D > > > self.host_dut.ports_info[vf]['sriov_vfs_pci'][vf_id] > > > + else: > > > + print utils.RED("Missing pf/vf device index for device > > > option!!!") > > > return False > > > > > > - pci_addr =3D self.host_dut.ports_info[pf]['pci'] > > > > > > pci =3D self.__parse_pci(pci_addr) > > > if pci is None: > > > return False > > > - bus, slot, func =3D pci > > > + bus, slot, func, dom =3D pci > > > > > > source =3D ET.SubElement(hostdevice, 'source') > > > ET.SubElement(source, 'address', { > > > - 'domain': '0x0', 'bus': '0x%s' % bus, > > > + 'domain': '0x%s' % dom, 'bus': '0x%s' % bus, > > > 'slot': '0x%s' % slot, > > > 'function': '0x%s' % func}) > > > if 'guestpci' in options.keys(): > > > pci =3D self.__parse_pci(options['guestpci']) > > > if pci is None: > > > return False > > > - bus, slot, func =3D pci > > > + bus, slot, func, dom =3D pci > > > ET.SubElement(hostdevice, 'address', { > > > - 'type': 'pci', 'domain': '0x0', 'bus': > '0x%s' % > > > bus, > > > - 'slot': '0x%s' % slot, 'function': '0x%s' = % > > > func}) > > > + 'type': 'pci', 'domain': '0x%s' % dom, 'bus': > > > + '0x%s' % > > > bus, > > > + 'slot': '0x%s' % slot, 'function': '0x%s' % func}) > > > # save host and guest pci address mapping > > > pci_map =3D {} > > > pci_map['hostpci'] =3D pci_addr @@ -397,7 +497,7 @@ clas= s > > > LibvirtKvm(VirtBase): > > > pci =3D self.__parse_pci(options['opt_addr']) > > > if pci is None: > > > return False > > > - bus, slot, func =3D pci > > > + bus, slot, func, dom =3D pci > > > ET.SubElement(qemu, 'qemu:arg', > > > {'value': 'nic,model=3De1000,addr=3D0x%s' = % > slot}) > > > else: > > > -- > > > 1.8.3.1 >=20 > Thanks, > Herbert