1 # Copyright 2016 Intel Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 """Automation of QEMU hypervisor for launching virtio-net enabled guests.
19 from vnfs.qemu.qemu import IVnfQemu
20 from conf import settings as S
21 from tools import tasks
23 class QemuVirtioNet(IVnfQemu):
25 Control an instance of QEMU with virtio-net guest communication.
30 Initialisation function.
32 super(QemuVirtioNet, self).__init__()
33 self._logger = logging.getLogger(__name__)
35 # insert vanilla ovs specific modules
36 tasks.run_task(['sudo', 'modprobe', 'vhost_net'], self._logger,
37 'Loading vhost_net module...', True)
39 # calculate indexes of guest devices (e.g. charx, dpdkvhostuserx)
44 self._cmd += ['-netdev',
45 'type=tap,id=' + self._net1 +
46 ',script=no,downscript=no,' +
47 'ifname=tap' + if1 + ',vhost=on',
49 'virtio-net-pci,mac=' +
50 S.getValue('GUEST_NET1_MAC')[self._number] +
51 ',netdev=' + self._net1 + ',csum=off,gso=off,' +
52 'guest_tso4=off,guest_tso6=off,guest_ecn=off',
54 'type=tap,id=' + self._net2 +
55 ',script=no,downscript=no,' +
56 'ifname=tap' + if2 + ',vhost=on',
58 'virtio-net-pci,mac=' +
59 S.getValue('GUEST_NET2_MAC')[self._number] +
60 ',netdev=' + self._net2 + ',csum=off,gso=off,' +
61 'guest_tso4=off,guest_tso6=off,guest_ecn=off',