<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://sathnaga86.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://sathnaga86.com/" rel="alternate" type="text/html" /><updated>2024-10-07T05:29:07+00:00</updated><id>https://sathnaga86.com/feed.xml</id><title type="html">Linux, Cloud, DevOps and Beyond - A Deep Dive into Testing!</title><subtitle>Blog that would concentrate on software testing techniques and tools for Linux, KVM, Cloud areas and DevOps.</subtitle><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><entry><title type="html">Booting Powerpc Guest From Virtio Fs</title><link href="https://sathnaga86.com/2020/05/12/booting-powerpc-guest-from-virtio-fs.html" rel="alternate" type="text/html" title="Booting Powerpc Guest From Virtio Fs" /><published>2020-05-12T00:00:00+00:00</published><updated>2020-05-12T00:00:00+00:00</updated><id>https://sathnaga86.com/2020/05/12/booting-powerpc-guest-from-virtio-fs</id><content type="html" xml:base="https://sathnaga86.com/2020/05/12/booting-powerpc-guest-from-virtio-fs.html"><![CDATA[<h1 id="how-to-boot-a-powerpc-kvm-guest-from-virtio-fs">How to boot a PowerPC KVM guest from virtio-fs</h1>

<h2 id="introduction">Introduction:</h2>
<p>Virtio-fs is a shared file system that lets virtual machines access a directory tree on the host. Unlike existing approaches, it is designed to offer local file system semantics and performance.
Virtio-fs was started at Red Hat and is being developed in the Linux, QEMU, FUSE, and Kata Containers communities that are affected by code changes. More details on virtio-fs can be found <a href="https://virtio-fs.gitlab.io/">here</a>.</p>

<p><em>This blog gives a step by step guide on how to setup an PowerPC KVM Environment to boot a KVM guest from virtio-fs as rootfs.</em></p>

<h2 id="environment-used">Environment used:</h2>

<ul>
  <li>HW: <a href="https://openpowerfoundation.org/?resource_lib=wistron-corp-p93d2-2p-mihawk">MiHawk 2U2S Power9</a></li>
  <li>Host OS: Fedora 31</li>
  <li>Kernel: 5.7.0-rc5-g752f08972</li>
</ul>

<h2 id="steps">Steps:</h2>

<h3 id="1-create-a-working-directory-on-host">1. Create a working directory on host.</h3>

<ul>
  <li><code class="language-plaintext highlighter-rouge">mkdir -p /home/virtio-fs</code></li>
  <li><code class="language-plaintext highlighter-rouge">cd /home/virtio-fs</code>
    <blockquote>
      <p>For rest of the blog this folder is referred as $PWD</p>
    </blockquote>
  </li>
</ul>

<hr />

<h3 id="2-needs-a-guest-kernel-that-supports-virtio-fs-as-bootdisk-lets-build-one">2. Needs a Guest kernel that supports virtio-fs as bootdisk, let’s build one.</h3>

<p><em>Get kernel:</em></p>
<ul>
  <li>
    <p><code class="language-plaintext highlighter-rouge">git clone https://github.com/sathnaga/linux -b virtio-fs</code></p>

    <blockquote>
      <p>Mainline kernel has support for virtio-fs already, my above branch has
two additional patches to get rootfs feature and kernel configs
to enable it for my defconfig used below:</p>

      <ul>
        <li>
          <p>Patch from https://patchwork.kernel.org/patch/11134865/mbox to get virtio-fs as rootfs support.</p>
        </li>
        <li>
          <p>Patch to enable virtio fs kernel configs to support on guest kernel.</p>
        </li>
      </ul>
    </blockquote>
  </li>
</ul>

<p><em>Compile kernel:</em></p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">cd linux</code></li>
  <li><code class="language-plaintext highlighter-rouge">make ppc64le_guest_defconfig</code></li>
  <li><code class="language-plaintext highlighter-rouge">make -j 120 -s</code></li>
  <li><code class="language-plaintext highlighter-rouge">cd ..</code></li>
</ul>

<p>Now we have guest kernel at <strong>$PWD/linux/vmlinux</strong></p>

<hr />

<h3 id="3-needs-a-qemu-that-supports-virtio-fs-lets-build-one">3. Needs a qemu that supports virtio-fs, let’s build one.</h3>

<p><em>Get Qemu:</em></p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">git clone https://github.com/qemu/qemu.git</code>
    <blockquote>
      <p>this blog used code from master branch commit: <a href="https://github.com/qemu/qemu/commit/debe78ce14bf8f8940c2bdf3ef387505e9e035a9">debe78ce14bf8f8940c2bdf3ef387505e9e035a9</a></p>
    </blockquote>
  </li>
</ul>

<p><em>Compile Qemu:</em></p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">cd qemu</code></li>
  <li><code class="language-plaintext highlighter-rouge">./configure --target-list=ppc64-softmmu --enable-debug --disable-werrormake</code></li>
  <li><code class="language-plaintext highlighter-rouge">make -j 120 -s</code></li>
  <li><code class="language-plaintext highlighter-rouge">cd ..</code></li>
</ul>

<p>Now we have qemu binary at <strong>$PWD/qemu/ppc64-softmmu/qemu-system-ppc64</strong></p>

<hr />

<h3 id="4-needs-a-virtiofs-daemon-lets-build-one">4. Needs a virtiofs daemon, let’s build one.</h3>

<ul>
  <li><code class="language-plaintext highlighter-rouge">cd qemu</code></li>
  <li><code class="language-plaintext highlighter-rouge">make -j 8 virtiofsd</code></li>
  <li><code class="language-plaintext highlighter-rouge">cd ..</code></li>
</ul>

<p>Now we have virtio fs daemon binary at <strong>$PWD/qemu/virtiofsd</strong></p>

<hr />

<h3 id="5-lets-build-a-fedora-root-file-system-based-on-f32">5. Let’s build a Fedora root file system based on F32:</h3>
<ul>
  <li><code class="language-plaintext highlighter-rouge">mkdir $PWD/virtio-fs-root</code></li>
  <li>
    <p><code class="language-plaintext highlighter-rouge">dnf --installroot=$PWD/virtio-fs-root --releasever=32 install system-release vim-minimal systemd passwd dnf rootfiles pciutils</code></p>

    <blockquote>
      <p>Select yes to install packages.</p>

      <p>Incase to install additional packages, use below commandline,</p>

      <p>dnf –installroot=$PWD/virtio-fs-root –releasever=32 install “packages to install”</p>
    </blockquote>
  </li>
  <li>
    <p><code class="language-plaintext highlighter-rouge">openssl passwd -1 123456</code></p>

    <p><code class="language-plaintext highlighter-rouge">$1$sWUb0J.r$cyjCLYRfstQ0xEHVZ45UZ/</code></p>

    <blockquote>
      <p>let’s create a passwd for guest root file system, in above command <code class="language-plaintext highlighter-rouge">123456</code> is our guest password and output generated is md5 password of same, change the password as per your need and use the generated one in shadow file.</p>
    </blockquote>
  </li>
  <li>Edit password field of $PWD/virtio-fs-root/etc/shadow with above md5sum password.
    <blockquote>
      <p>Before edit:</p>

      <p>$ <code class="language-plaintext highlighter-rouge">head -1 $PWD/virtio-fs-root/etc/shadow</code></p>

      <p>root:*:18292:0:99999:7:::</p>

      <p>After edit:</p>

      <p>$ <code class="language-plaintext highlighter-rouge">head -1 $PWD/virtio-fs-root/etc/shadow</code>
root:$1$sWUb0J.r$cyjCLYRfstQ0xEHVZ45UZ/:18292:0:99999:7:::</p>
    </blockquote>
  </li>
  <li><code class="language-plaintext highlighter-rouge">mknod $PWD/virtio-fs-root/dev/hvc0 c 1 2</code>
    <blockquote>
      <p>This creates serial device for guest console</p>
    </blockquote>
  </li>
  <li><code class="language-plaintext highlighter-rouge">cp $PWD/virtio-fs-root/usr/lib/systemd/system/serial-getty@.service  $PWD/virtio-fs-root/etc/systemd/system/getty.target.wants/serial-getty@hvc0.service</code></li>
  <li><code class="language-plaintext highlighter-rouge">cd $PWD/virtio-fs-root/etc/systemd/system/getty.target.wants/</code></li>
  <li><code class="language-plaintext highlighter-rouge">ln -s serial-getty@hvc0.service getty@hvc0.service</code></li>
  <li>Edit getty@hvc0.service with below changes
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  ...
  [Unit]
  ....
  ConditionPathExists=/dev/hvc0
  ....
  [Install]
  WantedBy=getty.target
  DefaultInstance=hvc0
</code></pre></div>    </div>
    <blockquote>
      <p>this is needed to get the guest serial console working fine.</p>
    </blockquote>
  </li>
  <li><code class="language-plaintext highlighter-rouge">cd /home/virtio-fs</code></li>
</ul>

<hr />

<h3 id="6-lets-boot-powerpc-kvm-guest-using-qemu-cmdline-with-virtio-fs">6. Let’s Boot PowerPC KVM guest using qemu cmdline with virtio-fs.</h3>

<ul>
  <li><code class="language-plaintext highlighter-rouge">$PWD/qemu/virtiofsd -o --socket-path=/tmp/vhostqemu -o source=$PWD/virtio-fs-root -o cache=none &amp;</code>
    <blockquote>
      <p>this command starts the virtio fs daemon in background</p>
    </blockquote>
  </li>
  <li>Run below qemu command to start a KVM guest
    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$PWD</span>/qemu/ppc64-softmmu/qemu-system-ppc64 <span class="se">\</span>
      <span class="nt">-m</span> 4096 <span class="nt">-object</span> memory-backend-file,id<span class="o">=</span>mem,size<span class="o">=</span>4G,mem-path<span class="o">=</span>/dev/shm,share<span class="o">=</span>on <span class="nt">-numa</span> node,memdev<span class="o">=</span>mem <span class="se">\</span>
      <span class="nt">-smp</span> 4 <span class="nt">-enable-kvm</span> <span class="nt">-serial</span> mon:stdio <span class="nt">-vga</span> none <span class="nt">-nographic</span> <span class="se">\</span>
      <span class="nt">-kernel</span> <span class="nv">$PWD</span>/linux/vmlinux <span class="se">\</span>
      <span class="nt">-append</span> <span class="s2">"rootfstype=virtiofs root=myfs rw"</span> <span class="se">\</span>
      <span class="nt">-chardev</span> socket,id<span class="o">=</span>char0,path<span class="o">=</span>/tmp/vhostqemu <span class="se">\</span>
      <span class="nt">-device</span> vhost-user-fs-pci,queue-size<span class="o">=</span>1024,chardev<span class="o">=</span>char0,tag<span class="o">=</span>myfs
</code></pre></div>    </div>
  </li>
</ul>

<blockquote>
  <p>Login using the password created in previous steps, this blog used <code class="language-plaintext highlighter-rouge">123456</code> as guest root password, let’s use
that to login, below are command outputs inside kvm guest.</p>
</blockquote>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>localhost login:
localhost login: root
Password:
Last login: Tue May 12 14:30:59 on hvc0
<span class="o">[</span>   16.610692] <span class="nb">id</span> <span class="o">(</span>134<span class="o">)</span> used greatest stack depth: 10736 bytes left
<span class="o">[</span>root@localhost ~]#
<span class="c"># lscpu</span>
Architecture:                    ppc64le
Byte Order:                      Little Endian
CPU<span class="o">(</span>s<span class="o">)</span>:                          4
On-line CPU<span class="o">(</span>s<span class="o">)</span> list:             0-3
Thread<span class="o">(</span>s<span class="o">)</span> per core:              1
Core<span class="o">(</span>s<span class="o">)</span> per socket:              1
Socket<span class="o">(</span>s<span class="o">)</span>:                       4
NUMA node<span class="o">(</span>s<span class="o">)</span>:                    1
Model:                           2.3 <span class="o">(</span>pvr 004e 1203<span class="o">)</span>
Model name:                      POWER9 <span class="o">(</span>architected<span class="o">)</span>, altivec supported
Hypervisor vendor:               KVM
Virtualization <span class="nb">type</span>:             para
L1d cache:                       128 KiB
L1i cache:                       128 KiB
NUMA node0 CPU<span class="o">(</span>s<span class="o">)</span>:               0-3
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Mitigation<span class="p">;</span> RFI Flush, L1D private per thread
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Mitigation<span class="p">;</span> RFI Flush, L1D private per thread
Vulnerability Spec store bypass: Mitigation<span class="p">;</span> Kernel entry/exit barrier <span class="o">(</span>eieio<span class="o">)</span>
Vulnerability Spectre v1:        Mitigation<span class="p">;</span> __user pointer sanitization, ori31
                                 speculation barrier enabled
Vulnerability Spectre v2:        Mitigation<span class="p">;</span> Software count cache flush, Softwar
                                 e <span class="nb">link </span>stack flush
Vulnerability Tsx async abort:   Not affected

<span class="o">[</span>root@localhost ~]# <span class="nb">cat</span> /etc/os-release
<span class="nv">NAME</span><span class="o">=</span>Fedora
<span class="nv">VERSION</span><span class="o">=</span><span class="s2">"32 (Thirty Two)"</span>
<span class="nv">ID</span><span class="o">=</span>fedora
<span class="nv">VERSION_ID</span><span class="o">=</span>32
<span class="nv">VERSION_CODENAME</span><span class="o">=</span><span class="s2">""</span>
<span class="nv">PLATFORM_ID</span><span class="o">=</span><span class="s2">"platform:f32"</span>
<span class="nv">PRETTY_NAME</span><span class="o">=</span><span class="s2">"Fedora 32 (Thirty Two)"</span>
<span class="nv">ANSI_COLOR</span><span class="o">=</span><span class="s2">"0;34"</span>
<span class="nv">LOGO</span><span class="o">=</span>fedora-logo-icon
<span class="nv">CPE_NAME</span><span class="o">=</span><span class="s2">"cpe:/o:fedoraproject:fedora:32"</span>
<span class="nv">HOME_URL</span><span class="o">=</span><span class="s2">"https://fedoraproject.org/"</span>
<span class="nv">DOCUMENTATION_URL</span><span class="o">=</span><span class="s2">"https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/"</span>
<span class="nv">SUPPORT_URL</span><span class="o">=</span><span class="s2">"https://fedoraproject.org/wiki/Communicating_and_getting_help"</span>
<span class="nv">BUG_REPORT_URL</span><span class="o">=</span><span class="s2">"https://bugzilla.redhat.com/"</span>
<span class="nv">REDHAT_BUGZILLA_PRODUCT</span><span class="o">=</span><span class="s2">"Fedora"</span>
<span class="nv">REDHAT_BUGZILLA_PRODUCT_VERSION</span><span class="o">=</span>32
<span class="nv">REDHAT_SUPPORT_PRODUCT</span><span class="o">=</span><span class="s2">"Fedora"</span>
<span class="nv">REDHAT_SUPPORT_PRODUCT_VERSION</span><span class="o">=</span>32
<span class="nv">PRIVACY_POLICY_URL</span><span class="o">=</span><span class="s2">"https://fedoraproject.org/wiki/Legal:PrivacyPolicy"</span>
<span class="o">[</span>root@localhost ~]# <span class="nb">uname</span> <span class="nt">-a</span>
Linux localhost 5.7.0-rc5-g7aa8a99a5-dirty <span class="c">#5 SMP Tue May 12 07:33:17 EDT 2020 ppc64le ppc64le ppc64le GNU/Linux</span>
<span class="o">[</span>root@localhost ~]# lspci
00:00.0 Mass storage controller: Red Hat, Inc. Device 105a <span class="o">(</span>rev 01<span class="o">)</span>
</code></pre></div></div>

<blockquote>
  <p><em><strong>Now We have PowerPC KVM guest booted with virtio-fs as bootdisk.</strong></em></p>
</blockquote>

<p>This blog is written based on below reference documents on virtio-fs and my additional steps that are needed for setup on PowerPC environment.</p>
<ul>
  <li><a href="https://virtio-fs.gitlab.io/howto-qemu.html">https://virtio-fs.gitlab.io/howto-qemu.html</a></li>
  <li><a href="https://virtio-fs.gitlab.io/howto-qemu.html">https://virtio-fs.gitlab.io/howto-boot.html</a></li>
</ul>

<p>Thanks for reading, Hope this blog helps you in someways :-)</p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><summary type="html"><![CDATA[How to boot a PowerPC KVM guest from virtio-fs]]></summary></entry><entry><title type="html">Guide To Run Test On Power9 From Laptop Using Simulator</title><link href="https://sathnaga86.com/2019/11/19/guide-to-run-test-on-power9-from-laptop-using-simulator.html" rel="alternate" type="text/html" title="Guide To Run Test On Power9 From Laptop Using Simulator" /><published>2019-11-19T00:00:00+00:00</published><updated>2019-11-19T00:00:00+00:00</updated><id>https://sathnaga86.com/2019/11/19/guide-to-run-test-on-power9-from-laptop-using-simulator</id><content type="html" xml:base="https://sathnaga86.com/2019/11/19/guide-to-run-test-on-power9-from-laptop-using-simulator.html"><![CDATA[<h1 id="guide-to-run-commandstests-on-a-ibm-power9-using-systemsimmambo-from-your-laptop-using-op-test-and-buildroot">Guide to run commands/tests on a IBM Power9 using systemsim(mambo) from your Laptop using op-test and buildroot</h1>

<h2 id="env-used">Env Used:</h2>

<ul>
  <li>Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz</li>
  <li>Fedora 31(5.3.7-301.fc31.x86_64)</li>
</ul>

<h2 id="pre-requisite">Pre-requisite:</h2>
<p>Install packages needed for cross compilation</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>For Ubuntu env:
    apt-get install gcc-powerpc64le-linux-gnu gcc valgrind \
    expect libssl-dev device-tree-compiler make \
    xz-utils
For Fedora env:
    dnf install gcc-powerpc64le-linux-gnu \
    binutils-powerpc64-linux-gnu gcc make diffutils findutils \
    expect valgrind-devel dtc openssl-devel xz
</code></pre></div></div>

<h2 id="how-to">How to:</h2>

<ol>
  <li>
    <p>Clone <a href="https://github.com/open-power/skiboot#building">skiboot</a>, Cross compile  and get <code class="language-plaintext highlighter-rouge">skiboot.lid</code>.</p>
  </li>
  <li>Clone linux <a href="https://github.com/torvalds/linux">kernel</a>, Cross compile  and get <code class="language-plaintext highlighter-rouge">vmlinux</code>.
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make ppc64le_defconfig
 ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j `nproc`
</code></pre></div>    </div>
  </li>
  <li>
    <p>Clone <a href="https://github.com/open-power/buildroot">buildroot</a>, Compile and get rootfs image.</p>

    <ul>
      <li>run ‘make menuconfig’.</li>
      <li>
        <p>Choose</p>

        <p>Target options  —&gt;
       Target Architecture (PowerPC64 (little endian))
       Target Architecture Variant (power8)</p>

        <p>Filesystem images  —&gt;
      cpio the root filesystem (for use as an initial RAM filesystem)`</p>

        <p>and other packages you would need.</p>
      </li>
      <li>run <code class="language-plaintext highlighter-rouge">make</code>.</li>
      <li>Find root filesystem in output/images(<code class="language-plaintext highlighter-rouge">rootfs.cpio</code>).</li>
    </ul>
  </li>
  <li>
    <p>Install systemsim(mambo) <a href="ftp://public.dhe.ibm.com/software/server/powerfuncsim/p9/packages">rpm</a> for power9 and check for systemsim(mambo) binary for power9 under <code class="language-plaintext highlighter-rouge">/opt/ibm/systemsim-p9/run/p9/</code>.</p>
  </li>
  <li>Create op-test config to run <a href="https://github.com/open-power/op-test/pull/545/commits/bbc9ffc90e12557db0a4a08433d4831e422bd57c">OpTestMamboBuildRoot</a> test, same test can modified to run different commands inside power9 host systemsim.
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> $cat mambo_p9.cfg
 [op-test]
 bmc_type=mambo
 mambo_binary=/opt/ibm/systemsim-p9/run/p9/power9;5dc2cbf4
 flash_skiboot=/home/satheesh/github/skiboot/skiboot.lid
 flash_kernel=/home/satheesh/github/linux/vmlinux
 flash_initramfs=/home/satheesh/github/buildroot/output/rootfs.cpio
 host_user=root
 host_password=
</code></pre></div>    </div>
  </li>
  <li>Run <a href="https://github.com/open-power/op-test/pull/545/commits/bbc9ffc90e12557db0a4a08433d4831e422bd57c">OpTestMamboBuildRoot</a> test, which executes <code class="language-plaintext highlighter-rouge">cat /proc/interrupts</code> and <code class="language-plaintext highlighter-rouge">cat /proc/cpuinfo</code> inside a power9 host systemsim(mambo) env as shown below.
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
 $./op-test -c mambo_p9.cfg --run testcases.OpTestMamboBuildRoot.OpTestMamboBuildRoot

 ...
 ...
 runTest (testcases.OpTestMamboBuildRoot.OpTestMamboBuildRoot) ... Using initial run script skiboot.tcl
 No network support selected^M
 INFO: 0: (0): !!!!!! Simulator now in TURBO mode !!!!!!
 [    0.000170223,5] OPAL v6.5-86-g1c282887 starting...^M
 [    0.000176398,7] initial console log level: memory 7, driver 5^M
 [    0.000181940,6] CPU: P9 generation processor (max 4 threads/core)^M
 [    0.000187332,7] CPU: Boot CPU PIR is 0x0000 PVR is 0x004e1200^M
 [    0.000194047,7] OPAL table: 0x30113630 .. 0x30113ba0, branch table: 0x30002000^M
 [    0.000202048,7] Assigning physical memory map table for nimbus^M
 [    0.000208137,7] FDT: Parsing fdt @0x1f00000^M
 [    0.001023665,5] Enabling Mambo console^M
 [    0.001027953,5] CHIP: Detected Mambo simulator^M
 [    0.001096322,5] CHIP: Chip ID 0000 type: P9N DD2.30^M
 [    0.001346958,5] PLAT: Detected Mambo platform^M
 [    0.001558571,5] CPU: All 1 processors called in...^M
 [    0.001600800,3] SBE: Master chip ID not found.^M
 [    0.001767201,3] NVRAM: Partition at offset 0x0 has incorrect 0 length^M
 [    0.001773195,3] NVRAM: Re-initializing (size: 0x00040000)^M
 [    0.001935098,5] STB: secure boot not supported^M
 [    0.001943298,5] STB: trusted boot not supported^M
 [    0.002078002,4] FLASH: Can't load resource id:0. No system flash found^M
 [    0.002095952,4] FLASH: Can't load resource id:1. No system flash found^M

 ...
 ...
 [console-expect]#lsprop /sys/firmware/devicetree/base/ibm,firmware-versions
 lsprop /sys/firmware/devicetree/base/ibm,firmware-versions
 -sh: lsprop: not found^M^M
 [console-expect]#
 date
 which whoami &amp;&amp; whoami

 [console-expect]#date
 which whoami &amp;&amp; whoami
 Tue Nov 19 07:03:56 UTC 2019^M^M
 [console-expect]#/usr/bin/whoami^M^M
 root^M^M
 [console-expect]#echo $?
 echo $?
 0^M^M
 [console-expect]#stty -echo
 stty -echo
 [console-expect]#echo $?
 echo $?
 0^M^M
 [console-expect]#uname -a
 uname -a
 Linux buildroot 5.3.0-rc7 #1 SMP Wed Sep 4 14:34:53 IST 2019 ppc64le GNU/Linux^M^M
 [console-expect]#echo $?
 echo $?
 0^M^M
 [console-expect]#cat /proc/cpuinfo
 cat /proc/cpuinfo
 processor	: 0^M^M
 cpu		: POWER9, altivec supported^M^M
 clock		: 512.000000MHz^M^M
 revision	: 2.0 (pvr 004e 1200)^M^M
 ^M^M
 timebase	: 512000000^M^M
 platform	: PowerNV^M^M
 model		: Mambo,Simulated-System^M^M
 machine		: PowerNV Mambo,Simulated-System^M^M
 firmware	: OPAL^M^M
 MMU		: Radix^M^M
 [console-expect]#echo $?
 echo $?
 0^M^M
 [console-expect]#cat /proc/interrupts
 cat /proc/interrupts
            CPU0       ^M^M
  16:          0      XICS   2 Edge      IPI^M^M
  17:          0  OPAL EVT  11 Level     opal-msg^M^M
  18:         21  OPAL EVT   4 Edge      hvc_console^M^M
 LOC:      33666   Local timer interrupts for timer event device^M^M
 BCT:          0   Broadcast timer interrupts for timer event device^M^M
 LOC:          0   Local timer interrupts for others^M^M
 SPU:          0   Spurious interrupts^M^M
 PMI:          0   Performance monitoring interrupts^M^M
 MCE:          0   Machine check exceptions^M^M
 HMI:          0   Hypervisor Maintenance Interrupts^M^M
 NMI:          0   System Reset interrupts^M^M
 WDG:          7   Watchdog soft-NMI interrupts^M^M
 DBL:          0   Doorbell interrupts^M^M
 [console-expect]#echo $?
 echo $?
 0^M^M
 ok

 ----------------------------------------------------------------------
 Ran 1 test in 28.541s

 OK
</code></pre></div>    </div>
  </li>
</ol>

<p><em>Thanks for Reading…, Hope this blog helps you in someways :-)</em></p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><summary type="html"><![CDATA[Guide to run commands/tests on a IBM Power9 using systemsim(mambo) from your Laptop using op-test and buildroot]]></summary></entry><entry><title type="html">Long Haul And Multi Config Kvm Tests Using Avocado Vt</title><link href="https://sathnaga86.com/2019/06/20/long-haul-and-multi-config-KVM-tests-using-avocado-VT.html" rel="alternate" type="text/html" title="Long Haul And Multi Config Kvm Tests Using Avocado Vt" /><published>2019-06-20T00:00:00+00:00</published><updated>2019-06-20T00:00:00+00:00</updated><id>https://sathnaga86.com/2019/06/20/long-haul-and-multi-config-KVM-tests-using-avocado-VT</id><content type="html" xml:base="https://sathnaga86.com/2019/06/20/long-haul-and-multi-config-KVM-tests-using-avocado-VT.html"><![CDATA[<h1 id="long-haul-and-multi-configuration-kvm-guests-testing-using-avocado-vt">Long Haul and multi configuration KVM guests testing using Avocado-VT</h1>

<p>With reducing time to market, it becomes crucial we attempt the long haul and
stress tests mimicking the real world scenarios, and it is difficult to do it manually with less time in hand.
So, here comes the proven KVM test suite Avocado-VT, where we have implemented
recently a lot of capabilities which will allow any one to run not only longevity
tests but also in parallel multiple Guest VM with different configurations.</p>

<p>My previous <a href="https://sathnaga86.com/">blog</a> explain how to configure and use Avocado-VT KVM test suites.</p>

<p>Here let us see how to run some of long haul and multi configuration tests:</p>

<p><em><strong>Scenario 1</strong>: User wants to check whether guest withstand huge number of
reboot requests, lets take some really huge number, 5000.</em></p>

<p>Solution: Here comes the simple avocado command line allow us to accomplish it,</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>avocado run io-github-autotest-qemu.reboot \
--vt-type libvirt \
--vt-guest-os JeOS.27.ppc64le \
--job-results-dir /home/sath \
--vt-extra-params qemu_binary=/home/sath/qemu/ppc64-softmmu/qemu-system-ppc64 \
emulator_path=//home/sath/qemu/ppc64-softmmu/qemu-system-ppc64 \
mem=81920 smp=256 vcpu_maxcpus=256 \
take_regular_screendumps=no backup_image_before_testing=no \
libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd \
use_os_variant=no restore_image_after_testing=no \
vga=none display=nographic \
kernel=/home/sath/linux/vmlinux kernel_args='root=/dev/sda2 rw console=tty0 console=ttyS0,115200 init=/sbin/init initcall_debug selinux=0' \
virtinstall_qemu_cmdline=' -M pseries,ic-mode=xive' \
initrd='' \
use_serial_login=yes \
kill_vm=yes kill_vm_libvirt=yes env_cleanup=yes create_vm_libvirt=yes \
test_timeout=1440000 \
reboot_count=5000

JOB ID     : 73013bc0a7102829a87786bb6ba3efd35e816cc0
JOB LOG    : /home/sath/job-2019-05-18T08.17-73013bc/job.log
 (1/1) io-github-autotest-qemu.reboot: PASS (201977.56 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 201979.43 s
JOB HTML   : /home/sath/job-2019-05-18T08.17-73013bc/results.html
</code></pre></div></div>
<p>Explain on this test w.r.t command line parameters:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>This test reboots a KVM guest booted with given upstream kernel and qemu parameters
in libvirt environment for user defined iterations, in this case `reboot_count=5000`
times on given upstream qemu.
</code></pre></div></div>

<p>Above test ran for almost <strong>56 hours, i.e more than 2 days</strong>, Avocado-VT framework is
stable enough to facilitate such environment and tests.</p>

<p><em><strong>Scenario 2</strong>: User wants to check similar events say reboot
(it can be any vm events like cpu hotplug, vcpu pining, suspend/resume or all together)
in parallel for multiple guest with different configurations, like different machine types, cpu, memory setting etc.</em></p>

<p>Solution: Another simple avocado command line allow us to accomplish it,</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>avocado run multivm_cpustress.custom_host_events.custom_vm_events \
--vt-type libvirt \
--vt-guest-os JeOS.27.ppc64le \
--job-results-dir /home/sath \
--vt-extra-params qemu_binary=/home/sath/qemu/ppc64-softmmu/qemu-system-ppc64 \
emulator_path=/home/sath/qemu/ppc64-softmmu/qemu-system-ppc64 \
mem=81920 \
smp=512 \
take_regular_screendumps=no backup_image_before_testing=no \
libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd \
use_os_variant=no \
restore_image_after_testing=no \
vga=none \
display=nographic \
kernel=/home/sath/linux/vmlinux \
kernel_args='root=/dev/sda2 rw console=tty0 console=ttyS0,115200 init=/sbin/init initcall_debug selinux=0' \
virtinstall_qemu_cmdline_vm1=' -M pseries,ic-mode=dual' \
virtinstall_qemu_cmdline_vm2=' -M pseries,ic-mode=xive' \
virtinstall_qemu_cmdline_vm3=' -M pseries,ic-mode=xics' \
virtinstall_qemu_cmdline_vm4=' -M pseries,ic-mode=dual,max-cpu-compat=power8' \
virtinstall_qemu_cmdline_vm5=' -M pseries,ic-mode=dual,kernel-irqchip=off' \
virtinstall_qemu_cmdline_vm6=' -M pseries,ic-mode=xive,kernel-irqchip=off' \
virtinstall_qemu_cmdline_vm7=' -M pseries,ic-mode=xics,kernel-irqchip=off' \
virtinstall_qemu_cmdline_vm8=' -M pseries,ic-mode=dual,max-cpu-compat=power8,kernel-irqchip=off' \
initrd='' \
use_serial_login=yes \
kill_vm=yes kill_vm_libvirt=yes env_cleanup=yes create_vm_libvirt=yes \
vcpu_maxcpus=512 \
test_timeout=1440000 \
vms='vm1 vm2 vm3 vm4 vm5 vm6 vm7 vm8' \
stress_events='reboot' \
stress_itrs=10 \
vcpu_cores_vm1=128 vcpu_threads_vm1=4 \
vcpu_cores_vm2=256 vcpu_threads_vm2=2 \
vcpu_cores_vm3=64 vcpu_threads_vm3=8 \
vcpu_cores_vm4=512 vcpu_threads_vm4=1 \
vcpu_cores_vm5=128 vcpu_threads_vm5=4 \
vcpu_cores_vm6=256 vcpu_threads_vm6=2 \
vcpu_cores_vm7=64 vcpu_threads_vm7=8 \
vcpu_cores_vm8=512 vcpu_threads_vm8=1 \
guest_stress=no

JOB ID     : dcf3a14bae9d4007735a49a250114a6361dcea9f
JOB LOG    : /home/sath/job-2019-06-20T04.52-dcf3a14/job.log
 (1/1) type_specific.io-github-autotest-libvirt.multivm_cpustress.custom_host_events.custom_vm_events:  PASS (1214.78 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 1216.73 s
JOB HTML   : /home/sath/job-2019-06-20T04.52-dcf3a14/results.html
</code></pre></div></div>
<p>Explain on this test w.r.t command line parameters:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>This test reboots 8 KVM guests booted with given upstream kernel,each with
different interrupt controller and different cpu topology in parallel
for given user iterations, `stress_itrs=10` on given upstream qemu.
</code></pre></div></div>

<p>If you are interested in KVM Testing, there are much more possibilities you can explore
with <a href="https://github.com/avocado-framework/avocado-vt">Avocado-VT</a> and reach us through <a href="https://www.redhat.com/mailman/listinfo/avocado-devel">mailing list</a> for any suggestions or queries.</p>

<p>Hope this blog helps you in someways :-)</p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><summary type="html"><![CDATA[Long Haul and multi configuration KVM guests testing using Avocado-VT]]></summary></entry><entry><title type="html">Run Syzkaller Using Avocado And Op Test</title><link href="https://sathnaga86.com/2019/03/19/run-syzkaller-using-avocado-and-op-test.html" rel="alternate" type="text/html" title="Run Syzkaller Using Avocado And Op Test" /><published>2019-03-19T00:00:00+00:00</published><updated>2019-03-19T00:00:00+00:00</updated><id>https://sathnaga86.com/2019/03/19/run-syzkaller-using-avocado-and-op-test</id><content type="html" xml:base="https://sathnaga86.com/2019/03/19/run-syzkaller-using-avocado-and-op-test.html"><![CDATA[<h1 id="this-blog-explains-how-avocado-and-op-test-helps-us-to-setup-and-run-syzkaller-on-power-platform">This blog explains how avocado and op-test helps us to setup and run syzkaller on Power Platform</h1>

<h2 id="what-is-syzkaller">What is syzkaller:</h2>
<p><a href="https://github.com/google/syzkaller">syzkaller</a> is an unsupervised, coverage-guided kernel fuzzer</p>

<h2 id="avocado-test-enables-support">Avocado test enables support:</h2>

<p><strong>Testcase:</strong> <a href="https://github.com/autotest/tp-qemu/commit/db186f3b38717bf299e48c0cd6110d9396aed375">syzkaller.power</a></p>

<p><strong><em>What the testcase do:</em></strong></p>

<ol>
  <li>Install/Setup syzkaller in host.</li>
  <li>Setup Guest passwordless ssh from host.</li>
  <li>Prepare and compile Guest kernel.</li>
  <li>Prepare syzkaller config with user given qemu params and guest params.</li>
  <li>Start sykaller with above config and run for specified time(test_timeout).</li>
  <li>Fails out the test in case of host issues.</li>
</ol>

<p><strong><em>syzkaller specific testcase config parameters:</em></strong></p>

<p>Below syzkaller specific test parameters with default values as given here,
which can be modified in avocado command line to match as per our needs using
<code class="language-plaintext highlighter-rouge">--vt-extra-params</code> as other params as mentioned in below avocado command line.
More details on the syzkaller config params can be found under <a href="https://github.com/google/syzkaller/blob/master/docs/configuration.md">here</a></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>syz_qemu_args = "-enable-kvm -M pseries -net nic,model=virtio"
syz_kernel_repo = "https://github.com/linuxppc/linux.git"
syz_kernel_branch = "merge"
syz_kernel_config = "ppc64le_guest_defconfig"
syz_target = "linux/ppc64le"
syz_cmd_params = "-debug -v 10"
syz_http = "0.0.0.0:56741"
syz_count = 1
syz_procs = 4
</code></pre></div></div>

<h2 id="how-to-use">How to use:</h2>

<p><strong><em>ENV Used for this blog:</em></strong></p>

<ul>
  <li>Host : IBM Power8 runs Fedora 28 with kernel 5.0.0</li>
  <li>Guest: Fedora 27 with kernel 5.1.0-rc1-g3770244b0</li>
  <li>Qemu: 3.1.50 (v3.1.0-3117-ga9d1cc9f56-dirty)</li>
</ul>

<p>Below is the sample avocado command line that runs above mentioned syzkaller test</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># avocado run syzkaller --vt-type libvirt --vt-extra-params create_vm_libvirt=yes kill_vm_libvirt=yes env_cleanup=yes mem=20480 smp=2 take_regular_screendumps=no test_timeout=4000 backup_image_before_testing=no libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd use_os_variant=no restore_image_after_testing=no vga=none display=nographic --vt-guest-os JeOS.27.ppc64le
JOB ID     : 78a8a2399ad98bd0e8999f365eff1539009e9351
JOB LOG    : /home/sath/avocado-fvt-wrapper/results/job-2019-03-18T11.58-78a8a23/job.log
 (1/1) powerkvm-qemu.syzkaller.power: PASS (1830.90 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 1837.14 s
</code></pre></div></div>

<h3 id="running-syzkaller-testcase-through-op-test">Running syzkaller testcase through op-test:</h3>

<p>There are lot of chances we might hit host crash itself, so let’s run above Avocado test
using <a href="https://sathnaga86.com/2018/11/11/run-host-tests-using-op-test-framework.html">op-test-framework</a>,
so that we can capture host console and debug logs during host crash situations.</p>

<p><strong><em>op-test configuration file:</em></strong></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$cat host_tests.conf
[op-test]
bmc_type=BMC
bmc_ip=x.x.x.x
bmc_username=ADMIN
bmc_password=ADMIN
bmc_usernameipmi=ADMIN
bmc_passwordipmi=ADMIN
host_ip=x.x.x.x
host_user=root
host_password=passw0rd
host_cmd_timeout=5000
host_cmd_file=./tests.conf
host_cmd_resultpath=/home/syzkaller/latest
machine_state=OS
</code></pre></div></div>

<p><strong><em>test configuration file:</em></strong></p>

<p>This expects avocado-vt,avocado is installed already in the system under test, if not please refer this blog to get it installed, <a href="https://sathnaga86.com/2018/05/17/testing-kvm-through-libvirt-environment.html">How to install avocado-vt</a></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$cat tests.conf
avocado run syzkaller --vt-type libvirt --vt-extra-params create_vm_libvirt=yes kill_vm_libvirt=yes env_cleanup=yes mem=20480 smp=2 take_regular_screendumps=no backup_image_before_testing=no libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd use_os_variant=no test_timeout=4000 restore_image_after_testing=no vga=none display=nographic --vt-guest-os JeOS.27.ppc64le --job-results-dir /home/syzkaller --job-timeout 4100
</code></pre></div></div>

<p>Let’s run now syzkaller test using op-test framework with above mentioned configuration files.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./op-test -c host_tests.conf --run testcases.RunHostTest.RunHostTest
...
...
...
[console-expect]#avocado run syzkaller --vt-type libvirt --vt-extra-params create_vm_libvirt=yes kill_vm_libvirt=yes env_cleanup=yes mem=20480 smp=2 take_regular_screendumps=no backup_image_before_testing=no libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd use_os_variant=no test_timeout=4000 restore_image_after_testing=no vga=none display=nographic --vt-guest-os JeOS.27.ppc64le --job-results-dir /home/syzkaller --job-timeout 4100
avocado run syzkaller --vt-type libvirt --vt-extra-params create_vm_libvirt=yes kill_vm_libvirt=yes env_cleanup=yes mem=20480 smp=2 take_regular_screendumps=no backup_image_befno test_timeout=4000 restore_image_after_testing=no vga=none display=nographic --vt-guest-os JeOS.27.ppc64le --job-results-dir /home/syzkaller --job-timeout 4100
JOB ID     : b9c81856ceddded5b6a90832c35afe5400091a17
JOB LOG    : /home/syzkaller/job-2019-03-19T03.10-b9c8185/job.log
 (1/1) powerkvm-qemu.syzkaller.power: PASS (3998.13 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 4004.33 s
JOB HTML   : /home/syzkaller/job-2019-03-19T03.10-b9c8185/results.html
[console-expect]#echo $?
echo $?
0
[console-expect]#OK (4030.016s)

----------------------------------------------------------------------
Ran 1 test in 4030.016s

OK
</code></pre></div></div>

<p><em>Hope this blog help you in someway, Thanks for reading…</em></p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><summary type="html"><![CDATA[This blog explains how avocado and op-test helps us to setup and run syzkaller on Power Platform]]></summary></entry><entry><title type="html">Improve Test Scenarios Using Qemu Code Coverage</title><link href="https://sathnaga86.com/2019/01/03/improve-test-scenarios-using-qemu-code-coverage.html" rel="alternate" type="text/html" title="Improve Test Scenarios Using Qemu Code Coverage" /><published>2019-01-03T00:00:00+00:00</published><updated>2019-01-03T00:00:00+00:00</updated><id>https://sathnaga86.com/2019/01/03/improve-test-scenarios-using-qemu-code-coverage</id><content type="html" xml:base="https://sathnaga86.com/2019/01/03/improve-test-scenarios-using-qemu-code-coverage.html"><![CDATA[<p><em>Blog on how to measure qemu Code Coverage using avocado-vt framework and use it to improve test scenarios.</em></p>

<h2 id="what-is-code-coverage-measurement">What is Code Coverage measurement:</h2>
<p>Code coverage is measurement of how many lines of source code blocks/branches
are executed during automated test runs and it can be done by instrumenting
the source prior using certain tools like <a href="https://en.wikipedia.org/wiki/Gcov">gcov</a>
and coverage report can be generated using tools like <a href="https://gcovr.com/">gcovr</a></p>

<h2 id="how-to-measure-qemu-code-coverage-and-view-reports-for-test-improvements">How to measure qemu code coverage and view reports for test improvements:</h2>

<h3 id="pre-requisite">Pre-requisite:</h3>
<p>Linux box installed with Avocado framework, you can do referring my previous blogs on how to
<a href="https://sathnaga86.com/2018/05/17/testing-kvm-on-power-using-avocado-test.html">Install avocado</a> and <a href="https://sathnaga86.com/2018/05/17/testing-kvm-through-libvirt-environment.html">Running libvirt test using avocado</a></p>

<p><em>Environment Used:</em></p>
<blockquote>
  <p>Hardware: IBM Power8 Box, Operating system: Fedora29 with kernel 4.20, Qemu: 3.1.50 (v3.0.0-2419-g0e09a75401-dirty), Libvirt: 5.0.0</p>
</blockquote>

<h3 id="how-to-prepare-qemu-source-for-code-coverage-measurement">How to prepare qemu source for Code coverage measurement:</h3>

<p><em>Let’s run below qemu build test to compile qemu binary with code coverage instrumentation(gcov) enabled</em></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># wget https://raw.githubusercontent.com/sathnaga/avocado-vt/kvmci/kvmci/ppc/qemu_build.cfg -O qemu_build.cfg
# avocado run --vt-config qemu_build.cfg --vt-extra-params git_repo_qemu_configure_options="--target-list=ppc64-softmmu --enable-debug --enable-gcov"
</code></pre></div></div>

<blockquote>
  <p><em>Now we have qemu source code/binary instrumented with gcov, lets run a kvm test and measure code covered by the test.</em></p>
</blockquote>

<blockquote>
  <p><em>We need the following patch to be merged in avocado-vt to avail the support,
<a href="https://patch-diff.githubusercontent.com/raw/avocado-framework/avocado-vt/pull/1873.patch">Avocado-vt patch to enable qemu code coverage support</a></em></p>
</blockquote>

<blockquote>
  <p><em>For now you can use my <a href="https://github.com/sathnaga/avocado-vt/tree/kvmci">kvmci</a> branch for avocado-vt Or directly use above patch in your avocado-vt repository using <code class="language-plaintext highlighter-rouge">git am &lt;downloaded patch&gt;</code>.</em></p>
</blockquote>

<h3 id="how-to-run-kvm-tests-to-get-code-coverage">How to run kvm tests to get code coverage:</h3>

<p><em>Let’s run below vcpu hotplug kvm test to measure code coverage with below params enabled</em></p>

<ul>
  <li><strong>gcov_qemu=yes</strong> -&gt; <em>To enable gcov code coverage.</em></li>
  <li><strong>gcov_qemu_reset=yes</strong> -&gt; <em>Whether or not to erase coverage report generated by previous test.</em></li>
  <li><strong>gcov_qemu_compress=yes</strong> -&gt; <em>Whether to compress the coverage report, coz with –html-details the coverage report folder can cross few hundreds of MBs.</em></li>
  <li><strong>gcov_qemu_collect_cmd_opts=”–exclude-directories=capstone –html –html-details”</strong> -&gt; <em>Additional options for code coverage report generation tool(gcovr).</em></li>
  <li><strong>qemu_binary,emulator_path=/usr/share/avocado-plugins-vt/build/qemu/ppc64-softmmu/qemu-system-ppc64</strong> -&gt; <em>qemu binary path where previous qemu_build test compiled qemu binary.</em></li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># avocado run libvirt_vcpu_plug_unplug.positive_test.vcpu_set.guest.vm_operate.no_operation --vt-type libvirt --vt-extra-params qemu_binary=/usr/share/avocado-plugins-vt/build/qemu/ppc64-softmmu/qemu-system-ppc64 emulator_path=/usr/share/avocado-plugins-vt/build/qemu/ppc64-softmmu/qemu-system-ppc64 create_vm_libvirt=yes kill_vm_libvirt=yes env_cleanup=yes mem=20480 smp=2 take_regular_screendumps=no backup_image_before_testing=no libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd use_os_variant=no restore_image_after_testing=no vga=none display=nographic kernel=/home/kvmci/linux/vmlinux kernel_args='root=/dev/sda2 rw console=tty0 console=ttyS0,115200 init=/sbin/init initcall_debug selinux=0' gcov_qemu=yes gcov_qemu_reset=yes  gcov_qemu_compress=yes gcov_qemu_collect_cmd_opts="--exclude-directories=capstone --html --html-details" --vt-guest-os JeOS.27.ppc64le --job-results-dir /home/kvmci/
JOB ID     : f196562eb13d65f892b4dd8c941f32d526496dc5
JOB LOG    : /home/kvmci/job-2018-12-18T07.24-f196562/job.log
(1/1) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.guest.vm_operate.no_operation: PASS (169.21 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 173.94 s
JOB HTML   : /home/kvmci/job-2018-12-18T07.24-f196562/results.html

# ls -l /home/kvmci/job-2018-12-18T07.24-f196562/test-results/1-type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.guest.vm_operate.no_operation/
total 11236
drwxr-xr-x 2 root root     4096 Dec 18 07:24 data
-rw-r--r-- 1 root root    38423 Dec 18 07:27 debug.log
-rw-r--r-- 1 root root 11067644 Dec 18 07:27 gcov_qemu.tar.gz
-rw-r--r-- 1 root root    18544 Dec 18 07:27 ip-sniffer.log
...
...

2018-12-18 07:25:46,307 process          L0596 INFO | Running 'rpm -q gcovr'
2018-12-18 07:25:46,325 process          L0428 DEBUG| [stdout] gcovr-4.1-2.fc28.noarch
2018-12-18 07:25:46,326 process          L0684 INFO | Command 'rpm -q gcovr' finished with 0 after 0.0127010345459s
2018-12-18 07:25:46,343 process          L0596 INFO | Running 'gcovr -j 10 -o /home/kvmci/job-2018-12-18T07.24-f196562/test-results/1-type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.guest.vm_operate.no_operation/gcov_qemu/gcov.html -s --exclude-directories=capstone --html --html-details .'
2018-12-18 07:27:08,552 process          L0428 DEBUG| [stderr] (WARNING) GCOV produced the following errors processing /usr/share/avocado-plugins-vt/build/qemu/migration/colo-comm.gcno:
2018-12-18 07:27:08,552 process          L0428 DEBUG| [stdout] lines: 12.2% (35112 out of 288554)
</code></pre></div></div>

<p>Above <code class="language-plaintext highlighter-rouge">gcov_qemu.tar.gz</code> contains detailed html code coverage reports and can be extracted and viewed in browser, sample report looks like below</p>

<p>Overall Coverage report:
<img src="https://github.com/sathnaga/sathnaga.github.io/raw/master/resources/gcov_report.png" alt="" /></p>

<p>Individual files line and branch coverage:
<img src="https://github.com/sathnaga/sathnaga.github.io/raw/master/resources/gcov_file_coverage.png" alt="" /></p>

<h2 id="conclusion">Conclusion:</h2>

<p>Now we should be able to check what part of code gets exercised while running our individual <a href="https://en.wikipedia.org/wiki/Black-box_testing">blackbox</a> <a href="https://sathnaga86.com/2018/05/17/testing-kvm-on-power-using-avocado-test.html">avocado tests</a>, using the same we can improve test scenarios to address missing part of code.</p>

<p><em>Thanks for reading, hope this helps you in someways….</em></p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><summary type="html"><![CDATA[Blog on how to measure qemu Code Coverage using avocado-vt framework and use it to improve test scenarios.]]></summary></entry><entry><title type="html">Devops Per Patch Kvmci</title><link href="https://sathnaga86.com/2018/11/29/devops-per-patch-kvmci.html" rel="alternate" type="text/html" title="Devops Per Patch Kvmci" /><published>2018-11-29T00:00:00+00:00</published><updated>2018-11-29T00:00:00+00:00</updated><id>https://sathnaga86.com/2018/11/29/devops-per-patch-kvmci</id><content type="html" xml:base="https://sathnaga86.com/2018/11/29/devops-per-patch-kvmci.html"><![CDATA[<h1 id="per-patch-kvm-ci-using-open-source-recipes">Per-patch KVM CI using open source recipes</h1>

<h3 id="used-recipes"><strong>Used recipes:</strong></h3>

<p><a href="https://github.com/ruscur/snowpatch">snowpatch</a> - Used to listen on upstream patches from given mailing list and trigger the jenkins job.</p>

<p><a href="https://jenkins.io/doc/book/pipeline/">Jenkins</a> - Used to orchestrate the CI workflow using pipeline.</p>

<p><a href="https://github.com/open-power/op-test-framework">op-test-framework</a> - Framework used to install upstream kernel and run tests.</p>

<p><a href="https://github.com/avocado-framework">Avocado framework</a> - Framework used to run OS, KVM tests.</p>

<p>Hardware used: IBM Power8 box</p>

<h3 id="workflow"><strong>WorkFlow:</strong></h3>

<ol>
  <li>
    <p>snowpatch is configured to listen on a <a href="https://patchwork.ozlabs.org/project/linuxppc-dev/list/">powerpc kernel</a> mailing list and it does
create a local branch with the new patch series on the mailing list and triggers
the given jenkins job with the repository and branch details.</p>

    <p><code class="language-plaintext highlighter-rouge">sample snowpatch output screenshot</code>
 <img src="https://github.com/sathnaga/sathnaga.github.io/raw/master/resources/snowpatchlistenonpatch.png" alt="" /></p>
  </li>
  <li>
    <p>Jenkins pipeline as shown is configured to run below workflow</p>

    <ul>
      <li>
        <p><em>Clone op-test-framework</em></p>
      </li>
      <li>
        <p><a href="https://sathnaga86.com/2018/11/08/upstream-kernel-install-using-op-test-framework.html"><em>Build and install upstream kernel on OpenPOWER box</em></a> - built with <code class="language-plaintext highlighter-rouge">ppc64le_defconfig</code></p>
      </li>
      <li>
        <p><em>Build upstream guest kernel</em> - built with <a href="http://patchwork.ozlabs.org/patch/994647/"><code class="language-plaintext highlighter-rouge">ppc64le_guest_defconfig</code></a></p>
      </li>
      <li>
        <p><a href="https://sathnaga86.com/2018/05/17/testing-kvm-through-libvirt-environment.html"><em>Install Avocado test framework</em></a></p>
      </li>
      <li>
        <p><em>Build upstream qemu</em></p>
      </li>
      <li>
        <p><em>Build upstream libvirt</em></p>
      </li>
      <li>
        <p><a href="https://sathnaga86.com/2018/11/11/run-host-tests-using-op-test-framework.html"><em>Run KVM Tests with Upstream Host Kernel, guest kernel, qemu and libvirt</em></a></p>
      </li>
    </ul>

    <p><img src="https://github.com/sathnaga/sathnaga.github.io/raw/master/resources/kvmcipipeline.png" alt="" /></p>
  </li>
  <li>
    <p>Notify Slack on completion</p>

    <p><img src="https://github.com/sathnaga/sathnaga.github.io/raw/master/resources/kvmcislacknotification.png" alt="" /></p>
  </li>
</ol>

<h4 id="results-can-be-viewed-in-jenkins">Results can be viewed in Jenkins</h4>

<p><img src="https://github.com/sathnaga/sathnaga.github.io/raw/master/resources/kvmcipipelineresult.png" alt="" /></p>

<p><img src="https://github.com/sathnaga/sathnaga.github.io/raw/master/resources/kvmcipipelinekvmtestsresult.png" alt="" /></p>

<p><em>Thanks for reading, Hope this helps you in someways…</em></p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><summary type="html"><![CDATA[Per-patch KVM CI using open source recipes]]></summary></entry><entry><title type="html">Run Host Tests Using Op Test Framework</title><link href="https://sathnaga86.com/2018/11/11/run-host-tests-using-op-test-framework.html" rel="alternate" type="text/html" title="Run Host Tests Using Op Test Framework" /><published>2018-11-11T00:00:00+00:00</published><updated>2018-11-11T00:00:00+00:00</updated><id>https://sathnaga86.com/2018/11/11/run-host-tests-using-op-test-framework</id><content type="html" xml:base="https://sathnaga86.com/2018/11/11/run-host-tests-using-op-test-framework.html"><![CDATA[<h1 id="run-any-host-tests-on-ibm-openpower-boxes-using-op-test-framework">Run any host tests on IBM OpenPower boxes using op-test-framework.</h1>

<h2 id="introduction-to-op-test-framework">Introduction to op-test-framework:</h2>
<p><a href="https://github.com/open-power/op-test-framework">op-test-framework</a> is a python unittest based test suite for validating IBM OpenPower boxes, which comprises many tests including booting host with multiple configurations etc.</p>

<h2 id="test-enables-the-support">Test enables the support:</h2>
<p><a href="https://github.com/open-power/op-test-framework/blob/master/testcases/RunHostTest.py">RunHostTest.py</a></p>

<h2 id="why-to-run-other-framework-tests-through-op-test-framework">Why to run other framework tests through op-test-framework:</h2>
<p>op-test-framework has it own benefits like</p>
<ol>
  <li><em>Enable console support for IBM Power boxes</em></li>
  <li><em>Automatic Runtime failure detection like host crash</em></li>
  <li><em>Power cycle support</em></li>
  <li><em>pre-written libraries for various IPMI commands</em></li>
</ol>

<p>But we might already have testcases reside in other frameworks,like <a href="https://sathnaga.github.io/2018/05/17/testing-kvm-on-power-using-avocado-test.html">Avocado</a>.
and shortcomings of those framework would be, environment will get lost,
when a testcase crashes the host and most of similar tests are designed to run within host.</p>

<p>So instead of rewriting whole test in op-test-framework to enjoy its features.
 We can just run tests from those frameworks through op-test-framework.</p>

<h2 id="how-to-use-it">How to use it:</h2>

<p><strong>We can use it two ways:</strong></p>
<ul>
  <li>run a single command in host(SUT) using option (–host-cmd)</li>
  <li>run multiple commands in host(SUT) by supplying a file as input where each line is considered as a command and it detects <code class="language-plaintext highlighter-rouge">reboot</code> as a special line and takes care of host power cycle.(–host-cmd-file)</li>
</ul>

<p><strong>Sample configuration file:</strong></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$cat host_tests.conf
[op-test]
bmc_type=BMC
bmc_ip=x.x.x.x
bmc_username=ADMIN
bmc_password=ADMIN
bmc_usernameipmi=ADMIN
bmc_passwordipmi=ADMIN
host_ip=x.x.x.x
host_user=root
host_password=passw0rd
host_cmd_timeout=36000
host_cmd_file=./tests.conf
host_cmd_resultpath=/home/kvmci/latest
machine_state=OS
</code></pre></div></div>

<p><strong>Explanation to above op-test config file:</strong></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>host and bmc credentials which is common for most of the tests and
host_cmd_timeout - timeout for each command in the file(just given maximum timeout).
host_cmd_file - file path, relative to op-test-framework base directory.
host_cmd_resultpath - folder path inside the host(SUT) to copy back the results.
</code></pre></div></div>

<p><strong>An example host_cmd_file:</strong></p>
<ul>
  <li>compiles upstream guest kernel, boots and runs a KVM guest vcpuhotplug test.
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$cat tests.conf
[ -d /home/kvmci/ ] || mkdir -p /home/kvmci
echo "KVMCI: Building Upstream guest kernel..."
[ -d /home/kvmci/linux ] || (cd /home/kvmci &amp;&amp; git clone --depth 1 https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git -b merge)
cd /home/kvmci/linux
make ppc64le_guest_defconfig
make -j 240
avocado run libvirt_vcpu_plug_unplug.positive_test.vcpu_set.guest.vm_operate.no_operation --vt-type libvirt --vt-extra-params create_vm_libvirt=yes kill_vm_libvirt=yes env_cleanup=yes mem=20480 smp=2 take_regular_screendumps=no backup_image_before_testing=no libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd use_os_variant=no restore_image_after_testing=no vga=none display=nographic kernel=/home/kvmci/linux/vmlinux kernel_args='root=/dev/sda2 rw console=tty0 console=ttyS0,115200 init=/sbin/init initcall_debug selinux=0' --vt-guest-os JeOS.27.ppc64le --job-results-dir /home/kvmci/
</code></pre></div>    </div>
  </li>
</ul>

<h2 id="lets-run">Let’s run:</h2>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$git clone https://github.com/open-power/op-test-framework
$cd op-test-framework
$./op-test --run testcases.RunHostTest.RunHostTest -c ./host_tests.conf

...
...

[console-expect]#avocado run libvirt_vcpu_plug_unplug.positive_test.vcpu_set.guest.vm_operate.no_operation --vt-type libvirt --vt-extra-params create_vm_libvirt=yes kill_vm_libvirt=yes env_cleanup=yes mem=20480 smp=2 take_regular_screendumps=no backup_image_before_testing=no libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd use_os_variant=no restore_image_after_testing=no vga=none display=nographic kernel=/home/kvmci/linux/vmlinux kernel_args='root=/dev/sda2 rw console=tty0 console=ttyS0,115200 init=/sbin/init initcall_debug selinux=0' --vt-guest-os JeOS.27.ppc64le --job-results-dir /home/kvmci/
&lt;nel=/home/kvmci/linux/vmlinux kernel_args='root=/dev/sda2 rw console=tty0 console=ttyS0,115200 init=/sbin/init initcall_debug selinux=0' --vt-guest-os JeOS.27.ppc64le --job-results-dir /home/kvmci/
JOB ID     : b291eb36bb522ff6a3c4d8db1b9124368e20e2bc
JOB LOG    : /home/kvmci/job-2018-11-09T00.19-b291eb3/job.log
 (1/1) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.guest.vm_operate.no_operation:  PASS (75.76 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 78.36 s
JOB HTML   : /home/kvmci/job-2018-11-09T00.19-b291eb3/results.html
[console-expect]#echo $?
echo $?
0
OK (113.264s)

----------------------------------------------------------------------
Ran 1 test in 113.265s

OK

Generating XML reports...
</code></pre></div></div>

<p>References:</p>

<p><a href="http://patchwork.ozlabs.org/patch/994647/">Guest kernel config</a></p>

<p><a href="https://sathnaga.github.io/2018/05/17/testing-kvm-through-libvirt-environment.html">Avocado KVM Tests</a></p>

<p><em>Hope this helps you :-), let’s break the boxes with tests…</em></p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><summary type="html"><![CDATA[Run any host tests on IBM OpenPower boxes using op-test-framework.]]></summary></entry><entry><title type="html">Upstream Kernel Install Using Op Test Framework</title><link href="https://sathnaga86.com/2018/11/08/upstream-kernel-install-using-op-test-framework.html" rel="alternate" type="text/html" title="Upstream Kernel Install Using Op Test Framework" /><published>2018-11-08T00:00:00+00:00</published><updated>2018-11-08T00:00:00+00:00</updated><id>https://sathnaga86.com/2018/11/08/upstream-kernel-install-using-op-test-framework</id><content type="html" xml:base="https://sathnaga86.com/2018/11/08/upstream-kernel-install-using-op-test-framework.html"><![CDATA[<h1 id="installboot-upstream-kernel-on-ibm-openpower-boxes-using-op-test-framework">Install/boot Upstream Kernel on IBM OpenPower boxes using op-test-framework.</h1>

<h2 id="introduction-to-op-test-framework">Introduction to op-test-framework:</h2>
<p><a href="https://github.com/open-power/op-test-framework">op-test-framework</a> is a python unit-test based test suite for validating IBM OpenPower boxes, which comprises many tests including booting host with multiple configurations etc.</p>

<h2 id="test-enables-the-support">Test enables the support:</h2>
<p><a href="https://github.com/open-power/op-test-framework/blob/master/testcases/InstallUpstreamKernel.py">InstallUpstreamKernel.py</a></p>

<h2 id="what-does-this-test-do">What does this test do:</h2>
<p>This test takes input of upstream(any) kernel git repository, branch and optionally a patch to be applied on top of the given git repository and it builds, installs and boots that kernel into given IBM OpenPower box and makes it ready for further tests on it.</p>

<h2 id="how-to-use-it">How to use it:</h2>
<p>Lets see how to build, install and boot upstream kernel on IBM Power Host.</p>

<hr />

<p><strong>Clone op-test framework repository in any of the remote system(not the SUT):</strong></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$git clone https://github.com/open-power/op-test-framework
$cd op-test-framework
</code></pre></div></div>

<hr />

<p><strong>Create a machine.conf to match the host(SUT) that you want to install upstream kernel like below</strong></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[op-test]
bmc_type=BMC
bmc_ip=x.x.x.x
bmc_username=ADMIN
bmc_password=ADMIN
bmc_usernameipmi=ADMIN
bmc_passwordipmi=ADMIN
host_ip=x.x.x.x
host_user=root
host_password=passw0rd
host_cmd_timeout=36000
git_repo=https://github.com/linuxppc/linux.git
git_branch=merge
git_repoconfigpath=https://raw.githubusercontent.com/sathnaga/avocado-vt/kvmci/kvmci/ppc/config_kvmppc
git_patch=958675.mbox
git_home=/home/kvmci
machine_state=OS
</code></pre></div></div>

<blockquote>
  <p>Explanation of config file:</p>
</blockquote>

<ul>
  <li>git_repo - Upstream kernel repository to be used.</li>
  <li>git_branch(optional) - Branch of upstream kernel repository to be used, by default <code class="language-plaintext highlighter-rouge">master</code>.</li>
  <li>git_repoconfigpath(optional) - Kernel configuration can be supplied as url or local file path, by default <code class="language-plaintext highlighter-rouge">ppc64le_defconfig</code> will be used.</li>
  <li>git_patch(optional) - Any incremental patch to be applied on top of above kernel repository, which can be supplied as
url or local file path.</li>
  <li>git_home(optional) - Base path for kernel repository clone in SUT, by default <code class="language-plaintext highlighter-rouge">/home/ci</code> will be used.</li>
</ul>

<hr />

<p><strong>Running Upstream Kernel Install test…</strong></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$./op-test -c machine.conf --run testcases.InstallUpstreamKernel.InstallUpstreamKernel


...

...

[console-expect]#2018-11-08 17:57:10,997:op-test.testcases.InstallUpstreamKernel:runTest:INFO:Installed upstream kernel version: 4.20.0-rc1-g16a0961d6

...

[console-expect]#echo $?
echo $?
0
[console-expect]#OK (836.924s)
----------------------------------------------------------------------
Ran 1 test in 836.924s

OK
</code></pre></div></div>

<hr />

<p>Now your server has the upstream kernel installed and ready to test :-) …</p>

<p>Hope this helps, Thanks for reading…</p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><summary type="html"><![CDATA[Install/boot Upstream Kernel on IBM OpenPower boxes using op-test-framework.]]></summary></entry><entry><title type="html">How to setup Continuous integration test for qemu, libvirt and guest kernel development using Avocado Test Framework</title><link href="https://sathnaga86.com/2018/05/24/devops-libvirt-qemu-kernel-ci-for-kvm.html" rel="alternate" type="text/html" title="How to setup Continuous integration test for qemu, libvirt and guest kernel development using Avocado Test Framework" /><published>2018-05-24T00:00:00+00:00</published><updated>2018-05-24T00:00:00+00:00</updated><id>https://sathnaga86.com/2018/05/24/devops-libvirt-qemu-kernel-ci-for-kvm</id><content type="html" xml:base="https://sathnaga86.com/2018/05/24/devops-libvirt-qemu-kernel-ci-for-kvm.html"><![CDATA[<p><em>Refer my previous blogs for introductions of avocado test framework.</em></p>

<p><strong><em>Below are Commits which enabled support:</em></strong></p>

<ul>
  <li><a href="https://github.com/avocado-framework/avocado-vt/commit/74fbe0cf2e832afafdff728333a838be897466fd">74fbe0cf</a> Added support Libvirt package build test.</li>
  <li><a href="https://github.com/avocado-framework/avocado-vt/commit/a95d2972abda166b1f27c246248b384787ff5963">a95d2972</a> Add qemu binary entry for powerpc.</li>
  <li><a href="https://github.com/avocado-framework/avocado-vt/commit/8aaceb14a538d519a4036591d00a9433163ff9cd">8aaceb14</a> Minor fixes for custom boot params.</li>
  <li><a href="https://github.com/avocado-framework/avocado-vt/commit/09d46e331ae20b96dc882330fbb82ef6536af98e">09d46e3</a> Added virt-install kernel and initrd params support.</li>
  <li><a href="https://github.com/autotest/tp-libvirt/commit/ab328a91d19a14e22a0073d1e4442dbdd89168e8">ab328a91</a> Add libvirt build test config.</li>
</ul>

<blockquote>
  <p><strong>Host Environment:  <code class="language-plaintext highlighter-rouge">IBM Power8 runs Linux/Fedora28</code></strong>.</p>
</blockquote>

<h2 id="steps-to-setup-ci-on-kvm-ibm-power-host">Steps to setup CI on KVM IBM Power Host:</h2>

<ol>
  <li>Installing packages needed for qemu and libvirt building:
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # yum groupinstall "Development tools"
 # yum install pixman-devel libtool rpcgen  libnl3-devel libxml2-devel mingw64-portablexdr libtirpc-devel yajl-devel device-mapper-devel libpciaccess-devel rpm-build audit-libs-devel augeas xfsprogs-devel avahi-devel bash-completion cyrus-sasl-devel dbus-devel fuse-devel glusterfs-api-devel glusterfs-devel gnutls-devel libacl-devel libattr-devel libblkid-devel libcap-ng-devel libcurl-devel libpcap-devel librados2-devel librbd1-devel libssh-devel libssh2-devel libtasn1-devel libwsman-devel ncurses-devel netcf-devel numactl-devel parted-devel readline-devel sanlock-devel scrub systemtap-sdt-devel wireshark-devel jansson-devel libiscsi-devel
</code></pre></div>    </div>
  </li>
</ol>

<blockquote>
  <p><em>Refer my previous blogs for installing avocado framework, lets skip that and jump to test runs.</em></p>
</blockquote>

<ol>
  <li>
    <p>Building upstream qemu:</p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # wget https://raw.githubusercontent.com/sathnaga/avocado-vt/kvmci/kvmci/ppc/qemu_build.cfg -O /home/kvmci/qemu_build.cfg
 # avocado run --vt-config /home/kvmci/qemu_build.cfg
 JOB ID     : ebf827140b57cd2e183b29b372d9e4c81f3e2931
 JOB LOG    : /home/sath/avocado-fvt-wrapper/results/job-2018-05-22T02.37-ebf8271/job.log
 (1/1) build: PASS (22.61 s)
 RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 33.63 s
 JOB HTML   : /home/sath/avocado-fvt-wrapper/results/job-2018-05-22T02.37-ebf8271/results.html
</code></pre></div>    </div>

    <blockquote>
      <p>The above test will clone build the upstream/given qemu gitrepo in qemu_build.cfg
 which can be modified as per need and softlink qemu-binary in this path <code class="language-plaintext highlighter-rouge">/usr/share/avocado-plugins-vt/bin/qemu</code>.</p>
    </blockquote>
  </li>
  <li>
    <p>Building upstream libvirt…</p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # wget https://raw.githubusercontent.com/sathnaga/avocado-vt/kvmci/kvmci/ppc/libvirt_build.cfg -O /home/kvmci/libvirt_build.cfg
 # avocado run --vt-config /home/kvmci/libvirt_build.cfg
 JOB ID     : a198d64a434efc67751612bcac27e214267826dc
 JOB LOG    : /home/sath/avocado-fvt-wrapper/results/job-2018-05-21T13.04-a198d64/job.log
 (1/1) build: PASS (517.98 s)
 RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 746.36 s
 JOB HTML   : /home/sath/avocado-fvt-wrapper/results/job-2018-05-21T13.04-a198d64/results.html
</code></pre></div>    </div>

    <blockquote>
      <p>The above test will clone build the  upstream/given libvirt gitrepo in libvirt_build.cfg
 which can be modified as per need and install/replace the system libvirt binary and
 start the libvirtd service.</p>
    </blockquote>
  </li>
  <li>
    <p>Building upstream Guest VM kernel…</p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # [ -d /home/linux ] || (mkdir -p /home/ &amp;&amp; cd /home/ &amp;&amp; git clone https://github.com/torvalds/linux.git)
 # cd /home/linux
 # make ppc64le_guest_defconfig
 # make -j 240 -s
</code></pre></div>    </div>

    <blockquote>
      <p>The above steps as shown will compile the upstream kernel,
 the config used here is tweaked to accommodate the modules in built in vmlinux
 as we do not depend on initramfs for booting the guest and this is tested working with 4.17 kernel.</p>
    </blockquote>

    <p><code class="language-plaintext highlighter-rouge"># setenforce 0</code>  –&gt; as libvirt will fail to boot custom qemu path due to selinux</p>
  </li>
  <li>
    <p>Running kvm test with upstream qemu, upstream libvirt and upstream guest kernel…</p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # avocado run guestpin.with_emualorpin.sequential.positive.with_cpu_hotplug --vt-type libvirt --vt-extra-params emulator_path=/usr/share/avocado-plugins-vt/bin/qemu create_vm_libvirt=yes kill_vm_libvirt=yes env_cleanup=yes smp=2 backup_image_before_testing=no libvirt_controller=virtio-scsi scsi_hba=virtio-scsi-pci drive_format=scsi-hd use_os_variant=no restore_image_after_testing=no vga=none display=nographic kernel=/home/linux/vmlinux kernel_args='root=/dev/sda2 rw console=tty0 console=ttyS0,115200 init=/sbin/init  initcall_debug' take_regular_screendumps=no --vt-guest-os JeOS.27.ppc64le
 JOB ID     : 569dd1a8acf99002ce4c3ae5d1702b6f28b40428
 JOB LOG    : /home/sath/avocado-fvt-wrapper/results/job-2018-05-23T11.56-569dd1a/job.log
  (1/1) type_specific.io-github-autotest-libvirt.guestpin.with_emualorpin.sequential.positive.with_cpu_hotplug: PASS (108.52 s)
 RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 119.89 s
 JOB HTML   : /home/sath/avocado-fvt-wrapper/results/job-2018-05-23T11.56-569dd1a/results.html
</code></pre></div>    </div>

    <blockquote>
      <p>The above test uses the artifact(binaries) that got generated as outcome of the previous steps
 and runs a sample KVM test with upstream qemu, libvirt and guest kernel.</p>
    </blockquote>
  </li>
</ol>

<h4 id="pre-configured-script">Pre-configured script:</h4>
<p>I have written a shell script which does above described steps except dependency package installation,
this can be executed on a IBM PowerKVM host and get the KVM CI working!!!</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># wget https://raw.githubusercontent.com/sathnaga/avocado-vt/kvmci/kvmci/ppc/kvmci_hostcmd.sh
#./kvmci_hostcmd.sh
KVMCI: Building Upstream Kernel...
KVMCI: Installing avocado...
KVMCI: Installing avocado-vt...
KVMCI: Bootstrapping avocado-vt...
KVMCI: Building Upstream Qemu...
JOB ID     : 7effbff2eb661a4979c58e7891158fd183cd5f95
JOB LOG    : /root/avocado/job-results/job-2018-05-24T06.15-7effbff/job.log
 (1/1) build: PASS (22.50 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 32.53 s
JOB HTML   : /root/avocado/job-results/job-2018-05-24T06.15-7effbff/results.html
KVMCI: Building Upstream Libvirt...
JOB ID     : 5992e90c9a1ebf4ebd8b53758c986bd2df4fb30b
JOB LOG    : /root/avocado/job-results/job-2018-05-24T06.15-5992e90/job.log
 (1/1) build: PASS (515.30 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 747.75 s
JOB HTML   : /root/avocado/job-results/job-2018-05-24T06.15-5992e90/results.html
KVMCI: Running tests with Upstream qemu, libvirt, guest kernel...
JOB ID     : 3c21388a07c43c0bc6efdc18ca869c12f8ec4efd
JOB LOG    : /root/avocado/job-results/job-2018-05-24T06.28-3c21388/job.log
 (1/1) type_specific.io-github-autotest-libvirt.guestpin.with_emualorpin.sequential.positive.with_cpu_hotplug: PASS (108.77 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 125.67 s
JOB HTML   : /root/avocado/job-results/job-2018-05-24T06.28-3c21388/results.html
</code></pre></div></div>

<p><em>Hope this blog help you in someway, Thanks for reading…</em></p>

<script src="https://utteranc.es/client.js" repo="sathnaga/sathnaga.github.io" issue-term="url" theme="github-light" crossorigin="anonymous" async="">
</script>]]></content><author><name>Satheesh Rajendran</name><email>sathnaga86@gmail.com</email></author><category term="devops" /><category term="CI" /><category term="testing" /><category term="avocado-framework" /><category term="KVM" /><category term="qemu" /><category term="libvirt" /><summary type="html"><![CDATA[This blog explains how to setup Continuous integration test for qemu, libvirt and guest kernel development using Avocado Test Framework using my patches.]]></summary></entry><entry><title type="html">Deploy OS on OpenPower boxes using op-test-framework</title><link href="https://sathnaga86.com/2018/05/22/deploy-os-on-openpower-boxes-using-op.html" rel="alternate" type="text/html" title="Deploy OS on OpenPower boxes using op-test-framework" /><published>2018-05-22T11:29:00+00:00</published><updated>2018-05-22T11:29:00+00:00</updated><id>https://sathnaga86.com/2018/05/22/deploy-os-on-openpower-boxes-using-op</id><content type="html" xml:base="https://sathnaga86.com/2018/05/22/deploy-os-on-openpower-boxes-using-op.html"><![CDATA[<div dir="ltr" style="text-align: left;" trbidi="on"><h4 style="text-align: left;"><i><br />This blog explains about my patches to the op-test-framework to improve/enable OS deployment on OpenPower boxes.</i></h4><br /><h4 style="text-align: left;"><u><b>Introduction:</b></u></h4><a href="https://github.com/open-power/op-test-framework" target="_blank">op-test-framework</a> is a python unittest based test suite for validating OpenPower boxes,<br />which comprises many tests including booting host with multiple configurations etc.<br /><br /><h4 style="text-align: left;"><b><u>Patches that enabled the support:</u></b></h4><a href="https://github.com/open-power/op-test-framework" target="_blank">op-test-framework</a>:<span style="color: blue;"> *</span><br />4edece0 Add support for HostOS Installation<br />1b581fb Add support for RHEL OS installation<br />c2a96d4 Add install library and update Ubuntu install test<br />830a43c Add commandline params needed for OS deploy<br />403d141 Fallback to alternate method to determine ip for boxes with older nc utility<br /><span style="color: blue; font-size: x-small;"><i>* Merged in upstream</i></span><br /><h4 style="text-align: left;"><b><u><br /></u></b></h4><h4 style="text-align: left;"><b><u>Steps to deploy OS:</u></b></h4>Lets see how to deploy Fedora28 on IBM Power Host.<br /><br />$git clone&nbsp;https://github.com/open-power/op-test-framework<br />$cd op-test-framework<br /><br /><i><span style="color: blue;">create a machine.conf to match the host that you want to deploy like below</span></i><br /><br />[op-test]<br />bmc_type=OpenBMC<br />bmc_ip=x.x.x.x<br />bmc_username=ADMIN<br />bmc_password=ADMIN<br />bmc_usernameipmi=ADMIN<br />bmc_passwordipmi=ADMIN<br />host_ip=x.x.x.x<br />host_user=root<br />host_password=passw0rd<br />host_gateway=x.x.x.x<br />host_dns=x.x.x.x<br />host_mac=98:be:94:06:de:95 <span style="font-size: x-small;"><i>--&gt;change as per your host</i></span><br />host_submask=255.255.255.0&nbsp;<span style="font-size: x-small;"><i> --&gt;change as per your host</i></span><br />host_scratch_disk=/dev/disk/by-id/scsi-35000c50098a05d6f&nbsp; <span style="font-size: x-small;"><i>--&gt;change as per your host</i></span><br />os_repo=https://dl.fedoraproject.org/pub/fedora-secondary/releases/28/Server/ppc64le/os/<br /><br /><span style="color: blue; font-size: x-small;"><i>Running OS deploy test....</i></span><br />$./op-test -c machine.conf --run testcases.InstallRhel.InstallRhel<br /><span style="font-size: xx-small;">....</span><br /><span style="font-size: xx-small;">....</span><br /><span style="font-size: xx-small;">^[[32m[&nbsp; &nbsp;39.218896] ^[[0m^[[33mtg3 0005:09:00.0 net0^[[0m: EEE is disabled</span><br /><span style="font-size: xx-small;">^[[32m[&nbsp; &nbsp;39.218976] ^[[0m^[[33mIPv6^[[0m: ADDRCONF(NETDEV_CHANGE): net0: link becomes ready</span><br /><span style="font-size: xx-small;">[console-pexpect]#echo $?</span><br /><span style="font-size: xx-small;">0</span><br /><span style="font-size: xx-small;">/home/jenkins_data/sath/op-test-framework/test-reports/Kernel_dmesg_log_Thu_May_17_11:20:20_2018.log</span><br /><span style="font-size: xx-small;">OK (939.294s)</span><br /><span style="font-size: xx-small;"><br /></span><span style="font-size: xx-small;">----------------------------------------------------------------------</span><br /><span style="font-size: xx-small;">Ran 1 test in 939.294s</span><br /><span style="font-size: xx-small;"><br /></span><span style="font-size: xx-small;">OK</span><br /><span style="font-size: xx-small;"><br /></span><span style="font-size: xx-small;">Generating XML reports...</span><br /><span style="font-size: xx-small;">Output written to: /home/jenkins_data/sath/op-test-framework/test-reports/*20180517110439*</span><br /><div><br /><i>Now you have<span style="color: blue;"> IBM Power</span>&nbsp;system with Fedora28 installed!!</i></div><br /><a name='more'></a><br /><br />P:S:-<i> osimages/rhel/rhel.ks has the template for kickstart file, you can tune based on the packages that you want to install, for installing fedora make sure java is removed as it does not available in fedora repository.</i><br /><br /><br /><br /><div><i><span style="color: blue;"><br class="Apple-interchange-newline" />Hope this helps you in someways!!!!</span></i></div><div><i><span style="color: blue;">Thanks for taking time in reading this blog......</span></i></div><br /></div>]]></content><author><name>Satheesh</name></author><category term="op-test-framework" /><category term="deploy" /><category term="fedora" /><category term="ibm" /><category term="power" /><category term="DevOps" /><category term="openpower" /><category term="OS" /><summary type="html"><![CDATA[This blog explains about my patches to the op-test-framework to improve/enable OS deployment on OpenPower boxes.Introduction:op-test-framework is a python unittest based test suite for validating OpenPower boxes,which comprises many tests including booting host with multiple configurations etc.Patches that enabled the support:op-test-framework: *4edece0 Add support for HostOS Installation1b581fb Add support for RHEL OS installationc2a96d4 Add install library and update Ubuntu install test830a43c Add commandline params needed for OS deploy403d141 Fallback to alternate method to determine ip for boxes with older nc utility* Merged in upstreamSteps to deploy OS:Lets see how to deploy Fedora28 on IBM Power Host.$git clone&nbsp;https://github.com/open-power/op-test-framework$cd op-test-frameworkcreate a machine.conf to match the host that you want to deploy like below[op-test]bmc_type=OpenBMCbmc_ip=x.x.x.xbmc_username=ADMINbmc_password=ADMINbmc_usernameipmi=ADMINbmc_passwordipmi=ADMINhost_ip=x.x.x.xhost_user=roothost_password=passw0rdhost_gateway=x.x.x.xhost_dns=x.x.x.xhost_mac=98:be:94:06:de:95 --&gt;change as per your hosthost_submask=255.255.255.0&nbsp; --&gt;change as per your hosthost_scratch_disk=/dev/disk/by-id/scsi-35000c50098a05d6f&nbsp; --&gt;change as per your hostos_repo=https://dl.fedoraproject.org/pub/fedora-secondary/releases/28/Server/ppc64le/os/Running OS deploy test....$./op-test -c machine.conf --run testcases.InstallRhel.InstallRhel........^[[32m[&nbsp; &nbsp;39.218896] ^[[0m^[[33mtg3 0005:09:00.0 net0^[[0m: EEE is disabled^[[32m[&nbsp; &nbsp;39.218976] ^[[0m^[[33mIPv6^[[0m: ADDRCONF(NETDEV_CHANGE): net0: link becomes ready[console-pexpect]#echo $?0/home/jenkins_data/sath/op-test-framework/test-reports/Kernel_dmesg_log_Thu_May_17_11:20:20_2018.logOK (939.294s)----------------------------------------------------------------------Ran 1 test in 939.294sOKGenerating XML reports...Output written to: /home/jenkins_data/sath/op-test-framework/test-reports/*20180517110439*Now you have IBM Power&nbsp;system with Fedora28 installed!!P:S:- osimages/rhel/rhel.ks has the template for kickstart file, you can tune based on the packages that you want to install, for installing fedora make sure java is removed as it does not available in fedora repository.Hope this helps you in someways!!!!Thanks for taking time in reading this blog......]]></summary></entry></feed>