<commit_before># virtc

`virtc` is a simple command-line tool that serves to demonstrate typical usage of the `virt` API.
This is example software; unlike other projects like runc, runv, or rkt, `virt` is not a full container runtime.

## Virtc example

Here we explain how to use the pod API from __virtc__ command line.

### Prepare your environment

#### Get your kernel

_Fedora_
```
$ sudo -E dnf config-manager --add-repo http://download.opensuse.org/repositories/home:clearlinux:preview:clear-containers-2.0/Fedora_24/home:clearlinux:preview:clear-containers-2.0.repo
$ sudo dnf install linux-container 
```

_Ubuntu_
```
$ sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/clearlinux:/preview:/clear-containers-2.0/xUbuntu_16.04/ /' >> /etc/apt/sources.list.d/cc-oci-runtime.list"
$ sudo apt install linux-container
```

#### Get your image

It has to be a recent Clear Linux image to make sure it contains hyperstart binary.
You can dowload the following tested [image](https://download.clearlinux.org/releases/11130/clear/clear-11130-containers.img.xz), or any version more recent.

```
$ wget https://download.clearlinux.org/releases/11130/clear/clear-11130-containers.img.xz
$ unxz clear-11130-containers.img.xz
$ sudo cp clear-11130-containers.img /usr/share/clear-containers/clear-containers.img
```

#### Get virtc

_Download virtc_
```
$ go get github.com/containers/virtcontainers
```

_Build virtc_
```
$ cd $GOPATH/src/github.com/containers/virtcontainers
$ cd virtc && go build
```

### Run virtc

All following commands needs to be run as root. Currently, __virtc__ only starts single container pods.

_Create your container bundle_

As an example we will create a busybox bundle:

```
$ mkdir -p /tmp/bundles/busybox/
$ docker pull busybox
$ cd /tmp/bundles/busybox/
$ mkdir rootfs
$ docker export $(docker create busybox) | tar -C rootfs -xvf -
$ echo -e '#!/bin/sh\ncd "\"\n"sh"' > rootfs/.containerexec
$ echo -e 'HOME=/root\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\nTERM=xterm' > rootfs/.containerenv
```

#### Run a new pod (Create + Start)
```
./virtc pod run --bundle="/tmp/bundles/busybox/rootfs" --agent="hyperstart" --init-cmd="/bin/sh"
```
#### Create a new pod
```
./virtc pod create --bundle="/tmp/bundles/busybox/rootfs" --agent="hyperstart" --init-cmd="/bin/sh"
```
This should generate that kind of output
```
Created pod 306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```

#### Start an existing pod
```
./virtc pod start --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```

#### Stop an existing pod
```
./virtc pod stop --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```

#### Get the status of an existing pod and its containers
```
./virtc pod status --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```
This should generate the following output:
```
POD ID                                  STATE   HYPERVISOR      AGENT
306ecdcf-0a6f-4a06-a03e-86a7b868ffc8    running qemu            hyperstart

CONTAINER ID    STATE
1               ready
```

#### Delete an existing pod
```
./virtc pod delete --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```

#### List all existing pods
```
./virtc pod list
```
This should generate that kind of output
```
POD ID                                  STATE   HYPERVISOR      AGENT
306ecdcf-0a6f-4a06-a03e-86a7b868ffc8    running qemu            hyperstart
92d73f74-4514-4a0d-81df-db1cc4c59100    running qemu            hyperstart
7088148c-049b-4be7-b1be-89b3ae3c551c    ready   qemu            hyperstart
6d57654e-4804-4a91-b72d-b5fe375ed3e1    ready   qemu            hyperstart
```<commit_msg>README.md: Update readme according to recent changes<commit_after># virtc

`virtc` is a simple command-line tool that serves to demonstrate typical usage of the `virt` API.
This is example software; unlike other projects like runc, runv, or rkt, `virt` is not a full container runtime.

## Virtc example

Here we explain how to use the pod API from __virtc__ command line.

### Prepare your environment

#### Get your kernel

_Fedora_
```
$ sudo -E dnf config-manager --add-repo http://download.opensuse.org/repositories/home:clearlinux:preview:clear-containers-2.0/Fedora_24/home:clearlinux:preview:clear-containers-2.0.repo
$ sudo dnf install linux-container 
```

_Ubuntu_
```
$ sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/clearlinux:/preview:/clear-containers-2.0/xUbuntu_16.04/ /' >> /etc/apt/sources.list.d/cc-oci-runtime.list"
$ sudo apt install linux-container
```

#### Get your image

It has to be a recent Clear Linux image to make sure it contains hyperstart binary.
You can dowload the following tested [image](https://download.clearlinux.org/releases/12210/clear/clear-12210-containers.img.xz), or any version more recent.

```
$ wget https://download.clearlinux.org/releases/12210/clear/clear-12210-containers.img.xz
$ unxz clear-12210-containers.img.xz
$ sudo cp clear-12210-containers.img /usr/share/clear-containers/clear-containers.img
```

#### Get virtc

_Download virtc_
```
$ go get github.com/containers/virtcontainers
```

_Build and install pause binary_
```
$ cd $GOPATH/src/github.com/containers/virtcontainers
$ make
$ make install
```

_Go to virtc_
```
$ cd hack/virtc
```

### Run virtc

All following commands needs to be run as root. Currently, __virtc__ only starts single container pods.

_Create your container bundle_

As an example we will create a busybox bundle:

```
$ mkdir -p /tmp/bundles/busybox/
$ docker pull busybox
$ cd /tmp/bundles/busybox/
$ mkdir rootfs
$ docker export $(docker create busybox) | tar -C rootfs -xvf -
$ echo -e '#!/bin/sh\ncd "\"\n"sh"' > rootfs/.containerexec
$ echo -e 'HOME=/root\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\nTERM=xterm' > rootfs/.containerenv
```

#### Run a new pod (Create + Start)
```
./virtc pod run --agent="hyperstart" --network="CNI"
```
#### Create a new pod
```
./virtc pod create --agent="hyperstart" --network="CNI"
```
This should generate that kind of output
```
Created pod 306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```

#### Start an existing pod
```
./virtc pod start --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```

#### Stop an existing pod
```
./virtc pod stop --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```

#### Get the status of an existing pod and its containers
```
./virtc pod status --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```
This should generate the following output:
```
POD ID                                  STATE   HYPERVISOR      AGENT
306ecdcf-0a6f-4a06-a03e-86a7b868ffc8    running qemu            hyperstart

CONTAINER ID    STATE
```

#### Delete an existing pod
```
./virtc pod delete --id=306ecdcf-0a6f-4a06-a03e-86a7b868ffc8
```

#### List all existing pods
```
./virtc pod list
```
This should generate that kind of output
```
POD ID                                  STATE   HYPERVISOR      AGENT
306ecdcf-0a6f-4a06-a03e-86a7b868ffc8    running qemu            hyperstart
92d73f74-4514-4a0d-81df-db1cc4c59100    running qemu            hyperstart
7088148c-049b-4be7-b1be-89b3ae3c551c    ready   qemu            hyperstart
6d57654e-4804-4a91-b72d-b5fe375ed3e1    ready   qemu            hyperstart
```
{'fraction_non_alphanumeric': 0.1325048869030997, 'fraction_numerical': 0.06241273387321977, 'mean_word_length': 3.4490683229813666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6396666', 'n_tokens_mistral': 2924, 'n_tokens_neox': 2549, 'n_words': 647}