urlwatch-cookbook

title: urlwatch-cookbook(7)

text:
# urlwatch-cookbook(7)

## NAME
urlwatch-cookbook - Advanced topics and recipes for urlwatch

## ADDING URLS FROM THE COMMAND LINE
Quickly adding new URLs to the job list from the command line:

```
urlwatch --add url=http://example.org,name=Example
```

## USING WORD-BASED DIFFERENCES
You can also specify an external diff-style tool (a tool that takes two filenames (old, new) as parameter and returns on its standard output the difference of the files), for example to use wdiff(1) to get word-based differences instead of line-based difference, or pandiff <https://github.com/davidar/pandiff> to get markdown differences:

```
url: https://example.com/
diff_tool: wdiff
```

Note that diff_tool specifies an external command-line tool, so that tool must be installed separately (e.g. apt install wdiff on Debian or brew install wdiff on macOS). Syntax highlighting is supported for wdiff-style output, but potentially not for other diff tools.

## IGNORING WHITESPACE CHANGES
If you would like to ignore whitespace changes so that you don't receive notifications for trivial differences, you can use diff_tool for this. For example:

```
diff_tool: "diff --ignore-all-space --unified"
```

When using another external diff-like tool, make sure it returns unified output format to retain syntax highlighting.

## ONLY SHOW ADDED OR REMOVED LINES
The diff_filter feature can be used to filter the diff output text with the same tools (see Filters) used for filtering web pages.

In order to show only diff lines with added lines, use:

```
url: http://example.com/things-get-added.html
diff_filter:

  - grep: '^[@+]'
```

This will only keep diff lines starting with @ or +. Similarly, to only keep removed lines:

```
url: http://example.com/things-get-removed.html
diff_filter:

  - grep: '^[@-]'
```

More sophisticated diff filtering is possibly by combining existing filters, writing a new filter or using shellpipe to delegate the filtering/processing of the diff output to an external tool.

Read the next section if you want to disable empty notifications.

## DISABLE EMPTY NOTIFICATIONS
As an extension to the previous example, let's say you want to only get notified with all lines added, but receive no notifications at all if lines are removed.

A diff usually looks like this:

```
--- @       Fri, 04 Mar 2022 19:58:14 +0100
+++ @       Fri, 04 Mar 2022 19:58:22 +0100
@@ -1,3 +1,3 @@

 someline
-someotherlines
+someotherline

 anotherline
```

We want to filter all lines starting with "+" only, but because of the headers we also want to filter lines that start with "+++", which can be accomplished like so:

```
url: http://example.com/only-added.html
diff_filter:

  - grep: '^[+]'      # Include all lines starting with "+"

  - grepi: '^[+]{3}'  # Exclude the line starting with "+++"
```

This deals with all diff lines now, but since urlwatch reports "changed" pages even when the diff_filter returns an empty string (which might be useful in some cases), you have to explicitly opt out by using urlwatch --edit-config and setting the empty-diff option to false in the display category:

```
display:

  empty-diff: false
```

## PASS DIFF OUTPUT TO A CUSTOM SCRIPT
In some situations, it might be useful to run a script with the diff as input when changes were detected (e.g. to start an update or process something). This can be done by combining diff_filter with the shellpipe filter, which can be any custom script.

The output of the custom script will then be the diff result as reported by urlwatch, so if it outputs any status, the CHANGED notification that urlwatch does will contain the output of the custom script, not the original diff. This can even have a "normal" filter attached to only watch links (the css: a part of the filter definitions):

```
url: http://example.org/downloadlist.html
filter:

  - css: a
diff_filter:

  - shellpipe: /usr/local/bin/process_new_links.sh
```

## COMPARING WEB PAGES VISUALLY
To compare the visual contents of web pages, Nicolai has written pyvisualcompare <https://github.com/nspo/pyvisualcompare> as a frontend (with GUI) to urlwatch. The tool can be used to select a region of a web page. It then generates a configuration for urlwatch to run pyvisualcompare and generate a hash for the screen contents.

## IGNORING CONNECTION ERRORS
In some cases, it might be useful to ignore (temporary) network errors to avoid notifications being sent. While there is a display.error config option (defaulting to true) to control reporting of errors globally, to ignore network errors for specific jobs only, you can use the ignore_connection_errors key in the job list configuration file:

```
url: https://example.com/
ignore_connection_errors: true
```

Similarly, you might want to ignore some (temporary) HTTP errors on the server side:

```
url: https://example.com/
ignore_http_error_codes: 408, 429, 500, 502, 503, 504
```

or ignore all HTTP errors if you like:

```
url: https://example.com/
ignore_http_error_codes: 4xx, 5xx
```

You can also ignore incomplete reads:

```
url: "https://example.com/"
ignore_incomplete_reads: true
```

## OVERRIDING THE CONTENT ENCODING
For web pages with misconfigured HTTP headers or rare encodings, it may be useful to explicitly specify an encoding from Python’s Standard Encodings <https://docs.python.org/3/library/codecs.html#standard-encodings>.

```
url: https://example.com/
encoding: utf-8
```

## CHANGING THE DEFAULT TIMEOUT
By default, url jobs timeout after 60 seconds. If you want a different timeout period, use the timeout key to specify it in number of seconds, or set it to 0 to never timeout.

```
url: https://example.com/
timeout: 300
```

## SUPPLYING COOKIE DATA
It is possible to add cookies to HTTP requests for pages that need it, the YAML syntax for this is:

```
url: http://example.com/
cookies:

    Key: ValueForKey

    OtherKey: OtherValue
```

## COMPARING WITH SEVERAL LATEST SNAPSHOTS
If a webpage frequently changes between several known stable states, it may be desirable to have changes reported only if the webpage changes into a new unknown state. You can use compared_versions to do this.

```
url: https://example.com/
compared_versions: 3
```

In this example, changes are only reported if the webpage becomes different from the latest three distinct states. The differences are shown relative to the closest match.

## RECEIVING A REPORT EVERY TIME URLWATCH RUNS
If you are watching pages that change seldomly, but you still want to be notified daily if urlwatch still works, you can watch the output of the date command, for example:

```
name: "urlwatch watchdog"
command: "date"
```

Since the output of date changes every second, this job should produce a report every time urlwatch is run.

## USING REDIS AS A CACHE BACKEND
If you want to use Redis as a cache backend over the default SQLite3 file:

```
urlwatch --cache=redis://localhost:6379/
```

There is no migration path from the SQLite3 format, the cache will be empty the first time Redis is used.

## WATCHING CHANGES ON .ONION (TOR) PAGES
Since pages on the Tor Network <https://www.torproject.org> are not accessible via public DNS and TCP, you need to either configure a Tor client as HTTP/HTTPS proxy or use the torify(1) tool from the tor package (apt install tor on Debian, brew install tor on macOS). Setting up Tor is out of scope for this document. On a properly set up Tor installation, one can just prefix the urlwatch command with the torify wrapper to access .onion pages:

```
torify urlwatch
```

## WATCHING FACEBOOK PAGE EVENTS
If you want to be notified of new events on a public Facebook page, you can use the following job pattern, replace PAGE with the name of the page (can be found by navigating to the events page on your browser):

```
url: http://m.facebook.com/PAGE/pages/permalink/?view_type=tab_events
filter:

  - css:

      selector: div#objects_container

      exclude: 'div.x, #m_more_friends_who_like_this, img'

  - re.sub:

      pattern: '(/events/\d*)[^"]*'

      repl: '\1'

  - html2text: pyhtml2text
```

## SETTING THE CONTENT WIDTH FOR HTML2TEXT (LYNX METHOD)
When using the lynx method in the html2text filter, it uses a default width that will cause additional line breaks to be inserted.

To set the lynx output width to 400 characters, use this filter setup:

```
url: http://example.com/longlines.html
filter:

  - html2text:

      method: lynx

      width: 400
```

## CONFIGURING HOW LONG BROWSER JOBS WAIT FOR PAGES TO LOAD
For browser jobs, you can configure how long the headless browser will wait before a page is considered loaded by using the wait_until option.

It can take one of four values (see wait_until docs <https://playwright.dev/python/docs/api/class-page#page-goto-option-wait-until> of Playwright):

- load - consider operation to be finished when the load event is fired

- domcontentloaded - consider operation to be finished when the DOMContentLoaded event is fired

- networkidle - discouraged consider operation to be finished when there are no network connections for at least 500 ms. Don't use this method for testing, rely on web assertions to assess readiness instead

- commit - consider operation to be finished when network response is received and the document started loading

## TREATING NEW JOBS AS CHANGED
In some cases (e.g. when the diff_tool or diff_filter executes some external command as a side effect that should also run for the initial page state), you can set the treat_new_as_changed to true, which will make the job report as CHANGED instead of NEW the first time it is retrieved (and the diff will be reported, too).

```
url: http://example.com/initialpage.html
treat_new_as_changed: true
```

This option will also change the behavior of --test-diff-filter, and allow testing the diff filter if only a single version of the page has been retrieved.

## MONITORING THE SAME URL IN MULTIPLE JOBS
Because urlwatch uses the url/navigate (for URL/Browser jobs) and/or the command (for Shell jobs) key as unique identifier, each URL can only appear in a single job. If you want to monitor the same URL multiple times, you can append #1, #2, ... (or anything that makes them unique) to the URLs, like this:

```
name: "Looking for Thing A"
url: http://example.com/#1
filter:

  - grep: "Thing A"
---
name: "Looking for Thing B"
url: http://example.com/#2
filter:

  - grep: "Thing B"
```

## UPDATING A URL AND KEEPING PAST HISTORY
Job history is stored based on the value of the url parameter, so updating a job's URL in the configuration file urls.yaml will create a new job with no history. Retain history by using --change-location:

```
urlwatch --change-location http://example.org#old http://example.org#new
```

The command also works with Browser and Shell jobs, changing navigate and command respectively.

## RUNNING A SUBSET OF JOBS
To run one or more specific jobs instead of all known jobs, provide the job index numbers to the urlwatch command. For example, to run jobs with index 2, 4, and 7:

```
urlwatch 2 4 7
```

## SENDING HTML FORM DATA USING POST
To simulate submitting a HTML form using the POST method, you can pass the form fields in the data field of the job description:

```
name: "My POST Job"
url: http://example.com/foo
data:

  username: "foo"

  password: "bar"

  submit: "Send query"
```

By default, the request will use the HTTP POST method, and the Content-type will be set to application/x-www-form-urlencoded.

## SENDING ARBITRARY DATA USING HTTP PUT
It is possible to customize the HTTP method and Content-type header, allowing you to send arbitrary requests to the server:

```
name: "My PUT Request"
url: http://example.com/item/new
method: PUT
headers:

  Content-type: application/json
data: '{"foo": true}'
```

## SEE ALSO
urlwatch(1), urlwatch-intro(7), urlwatch-jobs(5), urlwatch-filters(5), urlwatch-config(5), urlwatch-reporters(5)

## UTF-8 SUPPORT ON WINDOWS
On Windows, the default file encoding might be locale-specific and not work correctly if files are saved using the (recommended) UTF-8 encoding.

If you are having problems loading UTF-8-encoded files on Windows, you might see an issue like the following when urlwatch parses your config files:

```
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 214: character maps to <undefined>
```

To work around this issue, Python 3.7 and newer have a new UTF-8 Mode <https://peps.python.org/pep-0540/> that can be enabled by setting the environment variable PYTHONUTF8 to 1:

```
set PYTHONUTF8=1
urlwatch
```

You can also add this environment variable to your user environment or system environment to apply the UTF-8 Mode to all Python programs on your machine.

## COPYRIGHT
2024 Thomas Perl


urlwatch-deprecated

title: urlwatch-deprecated(7)

text:
# urlwatch-deprecated(7)

## NAME
urlwatch-deprecated - Documentation of feature deprecation in urlwatch

As features are deprecated and cleaned up, they are documented here with steps to update your configuration for replacements.

## NETWORKIDLE0 AND NETWORKIDLE2 FOR WAIT_UNTIL IN BROWSER JOBS (SINCE 2.28)
Since version 2.28, execution of browser jobs uses Playwright instead of pyppetteer.

The previously-supported wait_until values of networkidle0 and networkidle2 are not supported anymore. Playwright supports the values load, domcontentloaded, networkidle (discouraged) or commit instead.

Existing settings of networkidle0 and networkidle2 will be mapped to networkidle, and a warning will be issued. To silence the warning and continue to use networkidle, specify wait_until: networkidle explicitly.

## FILTERS WITHOUT SUBFILTERS (SINCE 2.22)
In older urlwatch versions, it was possible to write custom filters that do not take a subfilter as argument.

If you have written your own filter code like this:

```
class CustomFilter(filters.FilterBase):

    """My old custom filter"""

    __kind__ = 'foo'

    def filter(self, data):

        ...
```

You have to update your filter to take an optional subfilter argument (if the filter configuration does not have a subfilter defined, the value of subfilter will be None):

```
class CustomFilter(filters.FilterBase):

    """My new custom filter"""

    __kind__ = 'foo'

    def filter(self, data, subfilter):

        ...
```

## STRING-BASED FILTER DEFINITIONS (SINCE 2.19)
With urlwatch 2.19, string-based filter lists are deprecated, because they are not as flexible as dict-based filter lists and had some problems (e.g. : and , are treated in a special way and cannot be used in subfilters easily). If you have a filter definition like this:

```
filter: css:body,html2text:re,strip
```

You can get the same results with a filter definition like this:

```
filter:

  - css:

      selector: body

  - html2text:

      method: re

  - strip
```

Since selector is the default subfilter for css, and method is the default subfilter for html2text, this can also be written as:

```
filter:

  - css: body

  - html2text: re

  - strip
```

If you just have a single filter such as:

```
filter: html2text
```

You can change this filter to dict-based using:

```
filter:

  - html2text
```

## KEYRING SETTING IN SMTP REPORTER CONFIGURATION (SINCE 2.18)
Since version 2.18, the SMTP reporter configuration now uses auth to decide if SMTP authentication should be done or not. Previously, this setting was called keyring. If you have an old configuration like this:

```
report:

  email:

    smtp:

      host: localhost

      keyring: false

      port: 25

      starttls: true

    subject: '{count} changes: {jobs}'
```

You can change the setting to this (replace keyring with auth):

```
report:

  email:

    smtp:

      host: localhost

      auth: false

      port: 25

      starttls: true

    subject: '{count} changes: {jobs}'
```

## COPYRIGHT
2024 Thomas Perl

branch: sisyphus


urlwatch-intro

title: urlwatch-intro(7)

summary: Introduction to basic urlwatch usage

text:
# urlwatch-intro(7)

## NAME
urlwatch-intro - Introduction to basic urlwatch usage

## QUICK START
1.

Run urlwatch once to migrate your old data or start fresh

2.

Use urlwatch --edit to customize jobs and filters (urls.yaml)

3.

Use urlwatch --edit-config to customize settings and reporters (urlwatch.yaml)

4.

Add urlwatch to your crontab (crontab -e) to monitor webpages periodically

The checking interval is defined by how often you run urlwatch. You can use e.g. crontab.guru <https://crontab.guru> to figure out the schedule expression for the checking interval, we recommend not more often than 30 minutes (this would be */30 * * * *). If you have never used cron before, check out the crontab command help <https://www.computerhope.com/unix/ucrontab.htm>.

On Windows, cron is not installed by default. Use the Windows Task Scheduler <https://en.wikipedia.org/wiki/Windows_Task_Scheduler> instead, or see this StackOverflow question <https://stackoverflow.com/q/132971/1047040> for alternatives.

## HOW IT WORKS
Every time you run urlwatch(1), it:

- retrieves the output of each job and filters it

- compares it with the version retrieved the previous time ("diffing")

- if it finds any differences, it invokes enabled reporters (e.g. text reporter, e-mail reporter, ...) to notify you of the changes

## JOBS AND FILTERS
Each website or shell command to be monitored constitutes a "job".

The instructions for each such job are contained in a config file in the YAML format <https://yaml.org/spec/>. If you have more than one job, you separate them with a line containing only ---.

You can edit the job and filter configuration file using:

```
urlwatch --edit
```

If you get an error, set your $EDITOR (or $VISUAL) environment variable in your shell, for example:

```
export EDITOR=/bin/nano
```

While you can edit the YAML file manually, using --edit will do sanity checks before activating the new configuration file.

### Kinds of Jobs
Each job must have exactly one of the following keys, which also defines the kind of job:

- url retrieves what is served by the web server (HTTP GET by default),

- navigate uses a headless browser to load web pages requiring JavaScript, and

- command runs a shell command.

Each job can have an optional name key to define a user-visible name for the job.

You can then use optional keys to finely control various job's parameters.

See urlwatch-jobs(5) for detailed information on job configuration.

### Filters
You may use the filter key to select one or more Filters to apply to the data after it is retrieved, for example to:

- select HTML: css, xpath, element-by-class, element-by-id, element-by-style, element-by-tag

- make HTML more readable: html2text, beautify

- make PDFs readable: pdf2text

- make JSON more readable: format-json

- make iCal more readable: ical2text

- make binary readable: hexdump

- just detect changes: sha1sum

- edit text: grep, grepi, strip, sort, striplines

These filters can be chained. As an example, after retrieving an HTML document by using the url key, you can extract a selection with the xpath filter, convert this to text with html2text, use grep to extract only lines matching a specific regular expression, and then sort them:

```
name: "Sample urlwatch job definition"
url: "https://example.dummy/"
https_proxy: "http://dummy.proxy/"
max_tries: 2
filter:

  - xpath: '//section[@role="main"]'

  - html2text:

      method: pyhtml2text

      unicode_snob: true

      body_width: 0

      inline_links: false

      ignore_links: true

      ignore_images: true

      pad_tables: false

      single_line_break: true

  - grep: "lines I care about"

  - sort:
---
```

See urlwatch-filters(5) for detailed information on filter configuration.

## REPORTERS
urlwatch can be configured to do something with its report besides (or in addition to) the default of displaying it on the console.

Reporters are configured in the global configuration file:

```
urlwatch --edit-config
```

Examples of reporters:

- email (using SMTP)

- email using mailgun

- slack

- discord

- pushbullet

- telegram

- matrix

- pushover

- stdout

- xmpp

- shell

See urlwatch-reporters(5) for reporter configuration options.

## SEE ALSO
urlwatch(1), urlwatch-jobs(5), urlwatch-filters(5), urlwatch-config(5), urlwatch-reporters(5), cron(8)

## COPYRIGHT
2024 Thomas Perl


qemu-block-drivers

package: qemu-common

title: qemu-block-drivers(7)

summary: QEMU block drivers reference

text:
# qemu-block-drivers(7)

## NAME
qemu-block-drivers - QEMU block drivers reference

## SYNOPSIS
QEMU block driver reference manual

## DESCRIPTION

### Disk image file formats
QEMU supports many image file formats that can be used with VMs as well as with any of the tools (like qemu-img). This includes the preferred formats raw and qcow2 as well as formats that are supported for compatibility with older QEMU versions or other hypervisors.

Depending on the image format, different options can be passed to qemu-img create and qemu-img convert using the -o option. This section describes each format and the options that are supported for it.

raw

Raw disk image format. This format has the advantage of being simple and easily exportable to all other emulators. If your file system supports holes (for example in ext2 or ext3 on Linux or NTFS on Windows), then only the written sectors will reserve space. Use qemu-img info to know the real size used by the image or ls -ls on Unix/Linux. Supported options:

preallocation

Preallocation mode (allowed values: off, falloc, full). falloc mode preallocates space for image by calling posix_fallocate(). full mode preallocates space for image by writing data to underlying storage. This data may or may not be zero, depending on the storage location.

qcow2

QEMU image format, the most versatile format. Use it to have smaller images (useful if your filesystem does not supports holes, for example on Windows), zlib based compression and support of multiple VM snapshots. Supported options:

compat

Determines the qcow2 version to use. compat=0.10 uses the traditional image format that can be read by any QEMU since 0.10. compat=1.1 enables image format extensions that only QEMU 1.1 and newer understand (this is the default). Amongst others, this includes zero clusters, which allow efficient copy-on-read for sparse images.

backing_file

File name of a base image (see create subcommand)

backing_fmt

Image format of the base image

encryption

This option is deprecated and equivalent to encrypt.format=aes

encrypt.format

If this is set to luks, it requests that the qcow2 payload (not qcow2 header) be encrypted using the LUKS format. The passphrase to use to unlock the LUKS key slot is given by the encrypt.key-secret parameter. LUKS encryption parameters can be tuned with the other encrypt.* parameters. If this is set to aes, the image is encrypted with 128-bit AES-CBC. The encryption key is given by the encrypt.key-secret parameter. This encryption format is considered to be flawed by modern cryptography standards, suffering from a number of design problems:

- The AES-CBC cipher is used with predictable initialization vectors based on the sector number. This makes it vulnerable to chosen plaintext attacks which can reveal the existence of encrypted data.

- The user passphrase is directly used as the encryption key. A poorly chosen or short passphrase will compromise the security of the encryption.

- In the event of the passphrase being compromised there is no way to change the passphrase to protect data in any qcow images. The files must be cloned, using a different encryption passphrase in the new file. The original file must then be securely erased using a program like shred, though even this is ineffective with many modern storage technologies.

The use of this is no longer supported in system emulators. Support only remains in the command line utilities, for the purposes of data liberation and interoperability with old versions of QEMU. The luks format should be used instead.

encrypt.key-secret

Provides the ID of a secret object that contains the passphrase (encrypt.format=luks) or encryption key (encrypt.format=aes).

encrypt.cipher-alg

Name of the cipher algorithm and key length. Currently defaults to aes-256. Only used when encrypt.format=luks.

encrypt.cipher-mode

Name of the encryption mode to use. Currently defaults to xts. Only used when encrypt.format=luks.

encrypt.ivgen-alg

Name of the initialization vector generator algorithm. Currently defaults to plain64. Only used when encrypt.format=luks.

encrypt.ivgen-hash-alg

Name of the hash algorithm to use with the initialization vector generator (if required). Defaults to sha256. Only used when encrypt.format=luks.

encrypt.hash-alg

Name of the hash algorithm to use for PBKDF algorithm Defaults to sha256. Only used when encrypt.format=luks.

encrypt.iter-time

Amount of time, in milliseconds, to use for PBKDF algorithm per key slot. Defaults to 2000. Only used when encrypt.format=luks.

cluster_size

Changes the qcow2 cluster size (must be between 512 and 2M). Smaller cluster sizes can improve the image file size whereas larger cluster sizes generally provide better performance.

preallocation

Preallocation mode (allowed values: off, metadata, falloc, full). An image with preallocated metadata is initially larger but can improve performance when the image needs to grow. falloc and full preallocations are like the same options of raw format, but sets up metadata also.

lazy_refcounts

If this option is set to on, reference count updates are postponed with the goal of avoiding metadata I/O and improving performance. This is particularly interesting with cache=writethrough which doesn't batch metadata updates. The tradeoff is that after a host crash, the reference count tables must be rebuilt, i.e. on the next open an (automatic) qemu-img check -r all is required, which may take some time. This option can only be enabled if compat=1.1 is specified.

nocow

If this option is set to on, it will turn off COW of the file. It's only valid on btrfs, no effect on other file systems. Btrfs has low performance when hosting a VM image file, even more when the guest on the VM also using btrfs as file system. Turning off COW is a way to mitigate this bad performance. Generally there are two ways to turn off COW on btrfs:

- Disable it by mounting with nodatacow, then all newly created files will be NOCOW.

- For an empty file, add the NOCOW file attribute. That's what this option does.

Note: this option is only valid to new or empty files. If there is an existing file which is COW and has data blocks already, it couldn't be changed to NOCOW by setting nocow=on. One can issue lsattr filename to check if the NOCOW flag is set or not (Capital 'C' is NOCOW flag).

qed

Old QEMU image format with support for backing files and compact image files (when your filesystem or transport medium does not support holes). When converting QED images to qcow2, you might want to consider using the lazy_refcounts=on option to get a more QED-like behaviour.

Supported options:

backing_file

File name of a base image (see create subcommand).

backing_fmt

Image file format of backing file (optional). Useful if the format cannot be autodetected because it has no header, like some vhd/vpc files.

cluster_size

Changes the cluster size (must be power-of-2 between 4K and 64K). Smaller cluster sizes can improve the image file size whereas larger cluster sizes generally provide better performance.

table_size

Changes the number of clusters per L1/L2 table (must be power-of-2 between 1 and 16). There is normally no need to change this value but this option can between used for performance benchmarking.

qcow

Old QEMU image format with support for backing files, compact image files, encryption and compression. Supported options:

backing_file

File name of a base image (see create subcommand)

encryption

This option is deprecated and equivalent to encrypt.format=aes

encrypt.format

If this is set to aes, the image is encrypted with 128-bit AES-CBC. The encryption key is given by the encrypt.key-secret parameter. This encryption format is considered to be flawed by modern cryptography standards, suffering from a number of design problems enumerated previously against the qcow2 image format. The use of this is no longer supported in system emulators. Support only remains in the command line utilities, for the purposes of data liberation and interoperability with old versions of QEMU.

Users requiring native encryption should use the qcow2 format instead with encrypt.format=luks.

encrypt.key-secret

Provides the ID of a secret object that contains the encryption key (encrypt.format=aes).

luks

LUKS v1 encryption format, compatible with Linux dm-crypt/cryptsetup Supported options:

key-secret

Provides the ID of a secret object that contains the passphrase.

cipher-alg

Name of the cipher algorithm and key length. Currently defaults to aes-256.

cipher-mode

Name of the encryption mode to use. Currently defaults to xts.

ivgen-alg

Name of the initialization vector generator algorithm. Currently defaults to plain64.

ivgen-hash-alg

Name of the hash algorithm to use with the initialization vector generator (if required). Defaults to sha256.

hash-alg

Name of the hash algorithm to use for PBKDF algorithm Defaults to sha256.

iter-time

Amount of time, in milliseconds, to use for PBKDF algorithm per key slot. Defaults to 2000.

vdi

VirtualBox 1.1 compatible image format. Supported options:

static

If this option is set to on, the image is created with metadata preallocation.

vmdk

VMware 3 and 4 compatible image format. Supported options:

backing_file

File name of a base image (see create subcommand).

compat6

Create a VMDK version 6 image (instead of version 4)

hwversion

Specify vmdk virtual hardware version. Compat6 flag cannot be enabled if hwversion is specified.

subformat

Specifies which VMDK subformat to use. Valid options are monolithicSparse (default), monolithicFlat, twoGbMaxExtentSparse, twoGbMaxExtentFlat and streamOptimized.

vpc

VirtualPC compatible image format (VHD). Supported options:

subformat

Specifies which VHD subformat to use. Valid options are dynamic (default) and fixed.

VHDX

Hyper-V compatible image format (VHDX). Supported options:

subformat

Specifies which VHDX subformat to use. Valid options are dynamic (default) and fixed.

block_state_zero

Force use of payload blocks of type 'ZERO'. Can be set to on (default) or off. When set to off, new blocks will be created as PAYLOAD_BLOCK_NOT_PRESENT, which means parsers are free to return arbitrary data for those blocks. Do not set to off when using qemu-img convert with subformat=dynamic.

block_size

Block size; min 1 MB, max 256 MB. 0 means auto-calculate based on image size.

log_size

Log size; min 1 MB.

### Read-only formats
More disk image file formats are supported in a read-only mode.

bochs

Bochs images of growing type.

cloop

Linux Compressed Loop image, useful only to reuse directly compressed CD-ROM images present for example in the Knoppix CD-ROMs.

dmg

Apple disk image.

parallels

Parallels disk image format.

### Using host drives
In addition to disk image files, QEMU can directly access host devices. We describe here the usage for QEMU version >= 0.8.3.

### Linux
On Linux, you can directly use the host device filename instead of a disk image filename provided you have enough privileges to access it. For example, use /dev/cdrom to access to the CDROM.

CD

You can specify a CDROM device even if no CDROM is loaded. QEMU has specific code to detect CDROM insertion or removal. CDROM ejection by the guest OS is supported. Currently only data CDs are supported.

Floppy

You can specify a floppy device even if no floppy is loaded. Floppy removal is currently not detected accurately (if you change floppy without doing floppy access while the floppy is not loaded, the guest OS will think that the same floppy is loaded). Use of the host's floppy device is deprecated, and support for it will be removed in a future release.

Hard disks

Hard disks can be used. Normally you must specify the whole disk (/dev/hdb instead of /dev/hdb1) so that the guest OS can see it as a partitioned disk. WARNING: unless you know what you do, it is better to only make READ-ONLY accesses to the hard disk otherwise you may corrupt your host data (use the -snapshot command line option or modify the device permissions accordingly).

Zoned block devices

Zoned block devices can be passed through to the guest if the emulated storage controller supports zoned storage. Use --blockdev host_device, node-name=drive0,filename=/dev/nullb0,cache.direct=on to pass through /dev/nullb0 as drive0.

### Windows
CD

The preferred syntax is the drive letter (e.g. d:). The alternate syntax \\.\d: is supported. /dev/cdrom is supported as an alias to the first CDROM drive. Currently there is no specific code to handle removable media, so it is better to use the change or eject monitor commands to change or eject media.

Hard disks

Hard disks can be used with the syntax: \\.\PhysicalDriveN where N is the drive number (0 is the first hard disk). WARNING: unless you know what you do, it is better to only make READ-ONLY accesses to the hard disk otherwise you may corrupt your host data (use the -snapshot command line so that the modifications are written in a temporary file).

### Mac OS X
/dev/cdrom is an alias to the first CDROM.

Currently there is no specific code to handle removable media, so it is better to use the change or eject monitor commands to change or eject media.

### Virtual FAT disk images
QEMU can automatically create a virtual FAT disk image from a directory tree. In order to use it, just type:

```
qemu-system-x86_64 linux.img -hdb fat:/my_directory
```

Then you access access to all the files in the /my_directory directory without having to copy them in a disk image or to export them via SAMBA or NFS. The default access is read-only.

Floppies can be emulated with the :floppy: option:

```
qemu-system-x86_64 linux.img -fda fat:floppy:/my_directory
```

A read/write support is available for testing (beta stage) with the :rw: option:

```
qemu-system-x86_64 linux.img -fda fat:floppy:rw:/my_directory
```

What you should never do:

- use non-ASCII filenames

- use "-snapshot" together with ":rw:"

- expect it to work when loadvm'ing

- write to the FAT directory on the host system while accessing it with the guest system

### NBD access
QEMU can access directly to block device exported using the Network Block Device protocol.

```
qemu-system-x86_64 linux.img -hdb nbd://my_nbd_server.mydomain.org:1024/
```

If the NBD server is located on the same host, you can use an unix socket instead of an inet socket:

```
qemu-system-x86_64 linux.img -hdb nbd+unix://?socket=/tmp/my_socket
```

In this case, the block device must be exported using qemu-nbd:

```
qemu-nbd --socket=/tmp/my_socket my_disk.qcow2
```

The use of qemu-nbd allows sharing of a disk between several guests:

```
qemu-nbd --socket=/tmp/my_socket --share=2 my_disk.qcow2
```

and then you can use it with two guests:

```
qemu-system-x86_64 linux1.img -hdb nbd+unix://?socket=/tmp/my_socket
qemu-system-x86_64 linux2.img -hdb nbd+unix://?socket=/tmp/my_socket
```

If the nbd-server uses named exports (supported since NBD 2.9.18, or with QEMU's own embedded NBD server), you must specify an export name in the URI:

```
qemu-system-x86_64 -cdrom nbd://localhost/debian-500-ppc-netinst
qemu-system-x86_64 -cdrom nbd://localhost/openSUSE-11.1-ppc-netinst
```

The URI syntax for NBD is supported since QEMU 1.3. An alternative syntax is also available. Here are some example of the older syntax:

```
qemu-system-x86_64 linux.img -hdb nbd:my_nbd_server.mydomain.org:1024
qemu-system-x86_64 linux2.img -hdb nbd:unix:/tmp/my_socket
qemu-system-x86_64 -cdrom nbd:localhost:10809:exportname=debian-500-ppc-netinst
```

### iSCSI LUNs
iSCSI is a popular protocol used to access SCSI devices across a computer network.

There are two different ways iSCSI devices can be used by QEMU.

The first method is to mount the iSCSI LUN on the host, and make it appear as any other ordinary SCSI device on the host and then to access this device as a /dev/sd device from QEMU. How to do this differs between host OSes.

The second method involves using the iSCSI initiator that is built into QEMU. This provides a mechanism that works the same way regardless of which host OS you are running QEMU on. This section will describe this second method of using iSCSI together with QEMU.

In QEMU, iSCSI devices are described using special iSCSI URLs. URL syntax:

```
iscsi://[<username>[%<password>]@]<host>[:<port>]/<target-iqn-name>/<lun>
```

Username and password are optional and only used if your target is set up using CHAP authentication for access control. Alternatively the username and password can also be set via environment variables to have these not show up in the process list:

```
export LIBISCSI_CHAP_USERNAME=<username>
export LIBISCSI_CHAP_PASSWORD=<password>
iscsi://<host>/<target-iqn-name>/<lun>
```

Various session related parameters can be set via special options, either in a configuration file provided via '-readconfig' or directly on the command line.

If the initiator-name is not specified qemu will use a default name of 'iqn.2008-11.org.linux-kvm[:<uuid>'] where <uuid> is the UUID of the virtual machine. If the UUID is not specified qemu will use 'iqn.2008-11.org.linux-kvm[:<name>'] where <name> is the name of the virtual machine.

Setting a specific initiator name to use when logging in to the target:

```
-iscsi initiator-name=iqn.qemu.test:my-initiator
```

Controlling which type of header digest to negotiate with the target:

```
-iscsi header-digest=CRC32C|CRC32C-NONE|NONE-CRC32C|NONE
```

These can also be set via a configuration file:

```
[iscsi]

  user = "CHAP username"

  password = "CHAP password"

  initiator-name = "iqn.qemu.test:my-initiator"

  # header digest is one of CRC32C|CRC32C-NONE|NONE-CRC32C|NONE

  header-digest = "CRC32C"
```

Setting the target name allows different options for different targets:

```
[iscsi "iqn.target.name"]

  user = "CHAP username"

  password = "CHAP password"

  initiator-name = "iqn.qemu.test:my-initiator"

  # header digest is one of CRC32C|CRC32C-NONE|NONE-CRC32C|NONE

  header-digest = "CRC32C"
```

How to use a configuration file to set iSCSI configuration options:

```
cat >iscsi.conf <<EOF
[iscsi]

  user = "me"

  password = "my password"

  initiator-name = "iqn.qemu.test:my-initiator"

  header-digest = "CRC32C"
EOF
qemu-system-x86_64 -drive file=iscsi://127.0.0.1/iqn.qemu.test/1 \

  -readconfig iscsi.conf
```

How to set up a simple iSCSI target on loopback and access it via QEMU: this example shows how to set up an iSCSI target with one CDROM and one DISK using the Linux STGT software target. This target is available on Red Hat based systems as the package 'scsi-target-utils'.

```
tgtd --iscsi portal=127.0.0.1:3260
tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.qemu.test
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 \

    -b /IMAGES/disk.img --device-type=disk
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 2 \

    -b /IMAGES/cd.iso --device-type=cd
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
qemu-system-x86_64 -iscsi initiator-name=iqn.qemu.test:my-initiator \

  -boot d -drive file=iscsi://127.0.0.1/iqn.qemu.test/1 \

  -cdrom iscsi://127.0.0.1/iqn.qemu.test/2
```

### GlusterFS disk images
GlusterFS is a user space distributed file system.

You can boot from the GlusterFS disk image with the command:

URI:

```
qemu-system-x86_64 -drive file=gluster[+TYPE]://[HOST}[:PORT]]/VOLUME/PATH

                             [?socket=...][,file.debug=9][,file.logfile=...]
```

JSON:

```
qemu-system-x86_64 'json:{"driver":"qcow2",

                         "file":{"driver":"gluster",

                                  "volume":"testvol","path":"a.img","debug":9,"logfile":"...",

                                  "server":[{"type":"tcp","host":"...","port":"..."},

                                            {"type":"unix","socket":"..."}]}}'
```

gluster is the protocol.

TYPE specifies the transport type used to connect to gluster management daemon (glusterd). Valid transport types are tcp and unix. In the URI form, if a transport type isn't specified, then tcp type is assumed.

HOST specifies the server where the volume file specification for the given volume resides. This can be either a hostname or an ipv4 address. If transport type is unix, then HOST field should not be specified. Instead socket field needs to be populated with the path to unix domain socket.

PORT is the port number on which glusterd is listening. This is optional and if not specified, it defaults to port 24007. If the transport type is unix, then PORT should not be specified.

VOLUME is the name of the gluster volume which contains the disk image.

PATH is the path to the actual disk image that resides on gluster volume.

debug is the logging level of the gluster protocol driver. Debug levels are 0-9, with 9 being the most verbose, and 0 representing no debugging output. The default level is 4. The current logging levels defined in the gluster source are 0 - None, 1 - Emergency, 2 - Alert, 3 - Critical, 4 - Error, 5 - Warning, 6 - Notice, 7 - Info, 8 - Debug, 9 - Trace

logfile is a commandline option to mention log file path which helps in logging to the specified file and also help in persisting the gfapi logs. The default is stderr.

You can create a GlusterFS disk image with the command:

```
qemu-img create gluster://HOST/VOLUME/PATH SIZE
```

Examples

```
qemu-system-x86_64 -drive file=gluster://1.2.3.4/testvol/a.img
qemu-system-x86_64 -drive file=gluster+tcp://1.2.3.4/testvol/a.img
qemu-system-x86_64 -drive file=gluster+tcp://1.2.3.4:24007/testvol/dir/a.img
qemu-system-x86_64 -drive file=gluster+tcp://[1:2:3:4:5:6:7:8]/testvol/dir/a.img
qemu-system-x86_64 -drive file=gluster+tcp://[1:2:3:4:5:6:7:8]:24007/testvol/dir/a.img
qemu-system-x86_64 -drive file=gluster+tcp://server.domain.com:24007/testvol/dir/a.img
qemu-system-x86_64 -drive file=gluster+unix:///testvol/dir/a.img?socket=/tmp/glusterd.socket
qemu-system-x86_64 -drive file=gluster://1.2.3.4/testvol/a.img,file.debug=9,file.logfile=/var/log/qemu-gluster.log
qemu-system-x86_64 'json:{"driver":"qcow2",

                         "file":{"driver":"gluster",

                                  "volume":"testvol","path":"a.img",

                                  "debug":9,"logfile":"/var/log/qemu-gluster.log",

                                  "server":[{"type":"tcp","host":"1.2.3.4","port":24007},

                                            {"type":"unix","socket":"/var/run/glusterd.socket"}]}}'
qemu-system-x86_64 -drive driver=qcow2,file.driver=gluster,file.volume=testvol,file.path=/path/a.img,

                                     file.debug=9,file.logfile=/var/log/qemu-gluster.log,

                                     file.server.0.type=tcp,file.server.0.host=1.2.3.4,file.server.0.port=24007,

                                     file.server.1.type=unix,file.server.1.socket=/var/run/glusterd.socket
```

### Secure Shell (ssh) disk images
You can access disk images located on a remote ssh server by using the ssh protocol:

```
qemu-system-x86_64 -drive file=ssh://[USER@]SERVER[:PORT]/PATH[?host_key_check=HOST_KEY_CHECK]
```

Alternative syntax using properties:

```
qemu-system-x86_64 -drive file.driver=ssh[,file.user=USER],file.host=SERVER[,file.port=PORT],file.path=PATH[,file.host_key_check=HOST_KEY_CHECK]
```

ssh is the protocol.

USER is the remote user. If not specified, then the local username is tried.

SERVER specifies the remote ssh server. Any ssh server can be used, but it must implement the sftp-server protocol. Most Unix/Linux systems should work without requiring any extra configuration.

PORT is the port number on which sshd is listening. By default the standard ssh port (22) is used.

PATH is the path to the disk image.

The optional HOST_KEY_CHECK parameter controls how the remote host's key is checked. The default is yes which means to use the local .ssh/known_hosts file. Setting this to no turns off known-hosts checking. Or you can check that the host key matches a specific fingerprint. The fingerprint can be provided in md5, sha1, or sha256 format, however, it is strongly recommended to only use sha256, since the other options are considered insecure by modern standards. The fingerprint value must be given as a hex encoded string:

```
host_key_check=sha256:04ce2ae89ff4295a6b9c4111640bdcb3297858ee55cb434d9dd88796e93aa795
```

The key string may optionally contain ":" separators between each pair of hex digits.

The $HOME/.ssh/known_hosts file contains the base64 encoded host keys. These can be converted into the format needed for QEMU using a command such as:

```
$ for key in `grep 10.33.8.112 known_hosts | awk '{print $3}'`

  do

    echo $key | base64 -d | sha256sum

  done

  6c3aa525beda9dc83eadfbd7e5ba7d976ecb59575d1633c87cd06ed2ed6e366f  -

  12214fd9ea5b408086f98ecccd9958609bd9ac7c0ea316734006bc7818b45dc8  -

  d36420137bcbd101209ef70c3b15dc07362fbe0fa53c5b135eba6e6afa82f0ce  -
```

Note that there can be multiple keys present per host, each with different key ciphers. Care is needed to pick the key fingerprint that matches the cipher QEMU will negotiate with the remote server.

Currently authentication must be done using ssh-agent. Other authentication methods may be supported in future.

Note: Many ssh servers do not support an fsync-style operation. The ssh driver cannot guarantee that disk flush requests are obeyed, and this causes a risk of disk corruption if the remote server or network goes down during writes. The driver will print a warning when fsync is not supported:

```
warning: ssh server ssh.example.com:22 does not support fsync
```

With sufficiently new versions of libssh and OpenSSH, fsync is supported.

### NVMe disk images
NVM Express (NVMe) storage controllers can be accessed directly by a userspace driver in QEMU. This bypasses the host kernel file system and block layers while retaining QEMU block layer functionalities, such as block jobs, I/O throttling, image formats, etc. Disk I/O performance is typically higher than with -drive file=/dev/sda using either thread pool or linux-aio.

The controller will be exclusively used by the QEMU process once started. To be able to share storage between multiple VMs and other applications on the host, please use the file based protocols.

Before starting QEMU, bind the host NVMe controller to the host vfio-pci driver. For example:

```
# modprobe vfio-pci
# lspci -n -s 0000:06:0d.0
06:0d.0 0401: 1102:0002 (rev 08)
# echo 0000:06:0d.0 > /sys/bus/pci/devices/0000:06:0d.0/driver/unbind
# echo 1102 0002 > /sys/bus/pci/drivers/vfio-pci/new_id
# qemu-system-x86_64 -drive file=nvme://HOST:BUS:SLOT.FUNC/NAMESPACE
```

Alternative syntax using properties:

```
qemu-system-x86_64 -drive file.driver=nvme,file.device=HOST:BUS:SLOT.FUNC,file.namespace=NAMESPACE
```

HOST:BUS:SLOT.FUNC is the NVMe controller's PCI device address on the host.

NAMESPACE is the NVMe namespace number, starting from 1.

### Disk image file locking
By default, QEMU tries to protect image files from unexpected concurrent access, as long as it's supported by the block protocol driver and host operating system. If multiple QEMU processes (including QEMU emulators and utilities) try to open the same image with conflicting accessing modes, all but the first one will get an error.

This feature is currently supported by the file protocol on Linux with the Open File Descriptor (OFD) locking API, and can be configured to fall back to POSIX locking if the POSIX host doesn't support Linux OFD locking.

To explicitly enable image locking, specify "locking=on" in the file protocol driver options. If OFD locking is not possible, a warning will be printed and the POSIX locking API will be used. In this case there is a risk that the lock will get silently lost when doing hot plugging and block jobs, due to the shortcomings of the POSIX locking API.

QEMU transparently handles lock handover during shared storage migration. For shared virtual disk images between multiple VMs, the "share-rw" device option should be used.

By default, the guest has exclusive write access to its disk image. If the guest can safely share the disk image with other writers the -device ...,share-rw=on parameter can be used. This is only safe if the guest is running software, such as a cluster file system, that coordinates disk accesses to avoid corruption.

Note that share-rw=on only declares the guest's ability to share the disk. Some QEMU features, such as image file formats, require exclusive write access to the disk image and this is unaffected by the share-rw=on option.

Alternatively, locking can be fully disabled by "locking=off" block device option. In the command line, the option is usually in the form of "file.locking=off" as the protocol driver is normally placed as a "file" child under a format driver. For example:

```
-blockdev driver=qcow2,file.filename=/path/to/image,file.locking=off,file.driver=file
```

To check if image locking is active, check the output of the "lslocks" command on host and see if there are locks held by the QEMU process on the image file. More than one byte could be locked by the QEMU instance, each byte of which reflects a particular permission that is acquired or protected by the running block driver.

### Filter drivers
QEMU supports several filter drivers, which don't store any data, but perform some additional tasks, hooking io requests.

preallocate

The preallocate filter driver is intended to be inserted between format and protocol nodes and preallocates some additional space (expanding the protocol file) when writing past the file’s end. This can be useful for file-systems with slow allocation. Supported options:

prealloc-align

On preallocation, align the file length to this value (in bytes), default 1M.

prealloc-size

How much to preallocate (in bytes), default 128M.

## SEE ALSO
The HTML documentation of QEMU for more precise information and Linux user mode emulator invocation.

## Author
Fabrice Bellard and the QEMU Project developers

## Copyright
2025, The QEMU Project Developers


qemu-cpu-models

title: qemu-cpu-models(7)

summary: QEMU CPU Models

text:
# qemu-cpu-models(7)

## NAME
qemu-cpu-models - QEMU CPU Models

## SYNOPSIS
QEMU CPU Modelling Infrastructure manual

## DESCRIPTION

### Recommendations for KVM CPU model configuration on x86 hosts
The information that follows provides recommendations for configuring CPU models on x86 hosts. The goals are to maximise performance, while protecting guest OS against various CPU hardware flaws, and optionally enabling live migration between hosts with heterogeneous CPU models.

### Two ways to configure CPU models with QEMU / KVM
1.

Host passthrough This passes the host CPU model features, model, stepping, exactly to the guest. Note that KVM may filter out some host CPU model features if they cannot be supported with virtualization. Live migration is unsafe when this mode is used as libvirt / QEMU cannot guarantee a stable CPU is exposed to the guest across hosts. This is the recommended CPU to use, provided live migration is not required.

2.

Named model QEMU comes with a number of predefined named CPU models, that typically refer to specific generations of hardware released by Intel and AMD. These allow the guest VMs to have a degree of isolation from the host CPU, allowing greater flexibility in live migrating between hosts with differing hardware. @end table

In both cases, it is possible to optionally add or remove individual CPU features, to alter what is presented to the guest by default.

Libvirt supports a third way to configure CPU models known as "Host model". This uses the QEMU "Named model" feature, automatically picking a CPU model that is similar the host CPU, and then adding extra features to approximate the host model as closely as possible. This does not guarantee the CPU family, stepping, etc will precisely match the host CPU, as they would with "Host passthrough", but gives much of the benefit of passthrough, while making live migration safe.

### ABI compatibility levels for CPU models
The x86_64 architecture has a number of ABI compatibility levels <https://gitlab.com/x86-psABIs/x86-64-ABI/> defined. Traditionally most operating systems and toolchains would only target the original baseline ABI. It is expected that in future OS and toolchains are likely to target newer ABIs. The table that follows illustrates which ABI compatibility levels can be satisfied by the QEMU CPU models. Note that the table only lists the long term stable CPU model versions (eg Haswell-v4). In addition to what is listed, there are also many CPU model aliases which resolve to a different CPU model version, depending on the machine type is in use.

### x86-64 ABI compatibility levels
Model

baseline

v2

v3

v4

486-v1

Broadwell-v1

✅

✅

✅

Broadwell-v2

✅

✅

✅

Broadwell-v3

✅

✅

✅

Broadwell-v4

✅

✅

✅

Cascadelake-Server-v1

✅

✅

✅

✅

Cascadelake-Server-v2

✅

✅

✅

✅

Cascadelake-Server-v3

✅

✅

✅

✅

Cascadelake-Server-v4

✅

✅

✅

✅

Cascadelake-Server-v5

✅

✅

✅

✅

Conroe-v1

✅

Cooperlake-v1

✅

✅

✅

✅

Cooperlake-v2

✅

✅

✅

✅

Denverton-v1

✅

✅

Denverton-v2

✅

✅

Denverton-v3

✅

✅

Dhyana-v1

✅

✅

✅

Dhyana-v2

✅

✅

✅

EPYC-Genoa-v1

✅

✅

✅

✅

EPYC-Milan-v1

✅

✅

✅

EPYC-Milan-v2

✅

✅

✅

EPYC-Rome-v1

✅

✅

✅

EPYC-Rome-v2

✅

✅

✅

EPYC-Rome-v3

✅

✅

✅

EPYC-Rome-v4

✅

✅

✅

EPYC-v1

✅

✅

✅

EPYC-v2

✅

✅

✅

EPYC-v3

✅

✅

✅

EPYC-v4

✅

✅

✅

GraniteRapids-v1

✅

✅

✅

✅

Haswell-v1

✅

✅

✅

Haswell-v2

✅

✅

✅

Haswell-v3

✅

✅

✅

Haswell-v4

✅

✅

✅

Icelake-Server-v1

✅

✅

✅

✅

Icelake-Server-v2

✅

✅

✅

✅

Icelake-Server-v3

✅

✅

✅

✅

Icelake-Server-v4

✅

✅

✅

✅

Icelake-Server-v5

✅

✅

✅

✅

Icelake-Server-v6

✅

✅

✅

✅

IvyBridge-v1

✅

✅

IvyBridge-v2

✅

✅

KnightsMill-v1

✅

✅

✅

Nehalem-v1

✅

✅

Nehalem-v2

✅

✅

Opteron_G1-v1

✅

Opteron_G2-v1

✅

Opteron_G3-v1

✅

Opteron_G4-v1

✅

✅

Opteron_G5-v1

✅

✅

Penryn-v1

✅

SandyBridge-v1

✅

✅

SandyBridge-v2

✅

✅

SapphireRapids-v1

✅

✅

✅

✅

SapphireRapids-v2

✅

✅

✅

✅

Skylake-Client-v1

✅

✅

✅

Skylake-Client-v2

✅

✅

✅

Skylake-Client-v3

✅

✅

✅

Skylake-Client-v4

✅

✅

✅

Skylake-Server-v1

✅

✅

✅

✅

Skylake-Server-v2

✅

✅

✅

✅

Skylake-Server-v3

✅

✅

✅

✅

Skylake-Server-v4

✅

✅

✅

✅

Skylake-Server-v5

✅

✅

✅

✅

Snowridge-v1

✅

✅

Snowridge-v2

✅

✅

Snowridge-v3

✅

✅

Snowridge-v4

✅

✅

Westmere-v1

✅

✅

Westmere-v2

✅

✅

athlon-v1

core2duo-v1

✅

coreduo-v1

kvm32-v1

kvm64-v1

✅

n270-v1

pentium-v1

pentium2-v1

pentium3-v1

phenom-v1

✅

qemu32-v1

qemu64-v1

✅

### Preferred CPU models for Intel x86 hosts
The following CPU models are preferred for use on Intel hosts. Administrators / applications are recommended to use the CPU model that matches the generation of the host CPUs in use. In a deployment with a mixture of host CPU models between machines, if live migration compatibility is required, use the newest CPU model that is compatible across all desired hosts.

ClearwaterForest

Intel Xeon Processor (ClearwaterForest, 2025)

SierraForest, SierraForest-v2

Intel Xeon Processor (SierraForest, 2024), SierraForest-v2 mitigates the GDS and RFDS vulnerabilities with stepping 3.

GraniteRapids, GraniteRapids-v2

Intel Xeon Processor (GraniteRapids, 2024)

Cascadelake-Server, Cascadelake-Server-noTSX

Intel Xeon Processor (Cascade Lake, 2019), with "stepping" levels 6 or 7 only. (The Cascade Lake Xeon processor with stepping 5 is vulnerable to MDS variants.)

Skylake-Server, Skylake-Server-IBRS, Skylake-Server-IBRS-noTSX

Intel Xeon Processor (Skylake, 2016)

Skylake-Client, Skylake-Client-IBRS, Skylake-Client-noTSX-IBRS}

Intel Core Processor (Skylake, 2015)

Broadwell, Broadwell-IBRS, Broadwell-noTSX, Broadwell-noTSX-IBRS

Intel Core Processor (Broadwell, 2014)

Haswell, Haswell-IBRS, Haswell-noTSX, Haswell-noTSX-IBRS

Intel Core Processor (Haswell, 2013)

IvyBridge, IvyBridge-IBR

Intel Xeon E3-12xx v2 (Ivy Bridge, 2012)

SandyBridge, SandyBridge-IBRS

Intel Xeon E312xx (Sandy Bridge, 2011)

Westmere, Westmere-IBRS

Westmere E56xx/L56xx/X56xx (Nehalem-C, 2010)

Nehalem, Nehalem-IBRS

Intel Core i7 9xx (Nehalem Class Core i7, 2008)

Penryn

Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007)

Conroe

Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006)

### Important CPU features for Intel x86 hosts
The following are important CPU features that should be used on Intel x86 hosts, when available in the host CPU. Some of them require explicit configuration to enable, as they are not included by default in some, or all, of the named CPU models listed above. In general all of these features are included if using "Host passthrough" or "Host model".

pcid

Recommended to mitigate the cost of the Meltdown (CVE-2017-5754) fix. Included by default in Haswell, Broadwell & Skylake Intel CPU models.

Should be explicitly turned on for Westmere, SandyBridge, and IvyBridge Intel CPU models. Note that some desktop/mobile Westmere CPUs cannot support this feature.

spec-ctrl

Required to enable the Spectre v2 (CVE-2017-5715) fix. Included by default in Intel CPU models with -IBRS suffix.

Must be explicitly turned on for Intel CPU models without -IBRS suffix.

Requires the host CPU microcode to support this feature before it can be used for guest CPUs.

stibp

Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some operating systems. Must be explicitly turned on for all Intel CPU models.

Requires the host CPU microcode to support this feature before it can be used for guest CPUs.

ssbd

Required to enable the CVE-2018-3639 fix. Not included by default in any Intel CPU model.

Must be explicitly turned on for all Intel CPU models.

Requires the host CPU microcode to support this feature before it can be used for guest CPUs.

pdpe1gb

Recommended to allow guest OS to use 1GB size pages. Not included by default in any Intel CPU model.

Should be explicitly turned on for all Intel CPU models.

Note that not all CPU hardware will support this feature.

md-clear

Required to confirm the MDS (CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091) fixes. Not included by default in any Intel CPU model.

Must be explicitly turned on for all Intel CPU models.

Requires the host CPU microcode to support this feature before it can be used for guest CPUs.

mds-no

Recommended to inform the guest OS that the host is not vulnerable to any of the MDS variants ([MFBDS] CVE-2018-12130, [MLPDS] CVE-2018-12127, [MSBDS] CVE-2018-12126). This is an MSR (Model-Specific Register) feature rather than a CPUID feature, therefore it will not appear in the Linux /proc/cpuinfo in the host or guest. Instead, the host kernel uses it to populate the MDS vulnerability file in sysfs.

So it should only be enabled for VMs if the host reports @code{Not affected} in the /sys/devices/system/cpu/vulnerabilities/mds file.

taa-no

Recommended to inform the guest that the host is not vulnerable to CVE-2019-11135, TSX Asynchronous Abort (TAA). This is also an MSR feature, therefore it does not show up in the Linux /proc/cpuinfo in the host or guest.

It should only be enabled for VMs if the host reports Not affected in the /sys/devices/system/cpu/vulnerabilities/tsx_async_abort file.

tsx-ctrl

Recommended to inform the guest that it can disable the Intel TSX (Transactional Synchronization Extensions) feature; or, if the processor is vulnerable, use the Intel VERW instruction (a processor-level instruction that performs checks on memory access) as a mitigation for the TAA vulnerability. (For details, refer to Intel's deep dive into MDS <https://software.intel.com/security-software-guidance/insights/deep-dive-intel-analysis-microarchitectural-data-sampling>.) Expose this to the guest OS if and only if: (a) the host has TSX enabled; and (b) the guest has rtm CPU flag enabled.

By disabling TSX, KVM-based guests can avoid paying the price of mitigating TSX-based attacks.

Note that tsx-ctrl is also an MSR feature, therefore it does not show up in the Linux /proc/cpuinfo in the host or guest.

To validate that Intel TSX is indeed disabled for the guest, there are two ways: (a) check for the absence of rtm in the guest's /proc/cpuinfo; or (b) the /sys/devices/system/cpu/vulnerabilities/tsx_async_abort file in the guest should report Mitigation: TSX disabled.

bhi-no

Recommended to inform the guest that the host is not vulnerable to CVE-2022-0001, Branch History Injection (BHI). This is also an MSR feature, therefore it does not show up in the Linux /proc/cpuinfo in the host or guest.

It should only be enabled for VMs if the host reports BHI: Not affected in the /sys/devices/system/cpu/vulnerabilities/spectre_v2 file.

gds-no

Recommended to inform the guest that the host is not vulnerable to CVE-2022-40982, Gather Data Sampling (GDS). This is also an MSR feature, therefore it does not show up in the Linux /proc/cpuinfo in the host or guest.

It should only be enabled for VMs if the host reports Not affected in the /sys/devices/system/cpu/vulnerabilities/gather_data_sampling file.

rfds-no

Recommended to inform the guest that the host is not vulnerable to CVE-2023-28746, Register File Data Sampling (RFDS). This is also an MSR feature, therefore it does not show up in the Linux /proc/cpuinfo in the host or guest.

It should only be enabled for VMs if the host reports Not affected in the /sys/devices/system/cpu/vulnerabilities/reg_file_data_sampling file.

### Preferred CPU models for AMD x86 hosts
The following CPU models are preferred for use on AMD hosts. Administrators / applications are recommended to use the CPU model that matches the generation of the host CPUs in use. In a deployment with a mixture of host CPU models between machines, if live migration compatibility is required, use the newest CPU model that is compatible across all desired hosts.

EPYC, EPYC-IBPB

AMD EPYC Processor (2017)

Opteron_G5

AMD Opteron 63xx class CPU (2012)

Opteron_G4

AMD Opteron 62xx class CPU (2011)

Opteron_G3

AMD Opteron 23xx (Gen 3 Class Opteron, 2009)

Opteron_G2

AMD Opteron 22xx (Gen 2 Class Opteron, 2006)

Opteron_G1

AMD Opteron 240 (Gen 1 Class Opteron, 2004)

### Important CPU features for AMD x86 hosts
The following are important CPU features that should be used on AMD x86 hosts, when available in the host CPU. Some of them require explicit configuration to enable, as they are not included by default in some, or all, of the named CPU models listed above. In general all of these features are included if using "Host passthrough" or "Host model".

ibpb

Required to enable the Spectre v2 (CVE-2017-5715) fix. Included by default in AMD CPU models with -IBPB suffix.

Must be explicitly turned on for AMD CPU models without -IBPB suffix.

Requires the host CPU microcode to support this feature before it can be used for guest CPUs.

stibp

Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some operating systems. Must be explicitly turned on for all AMD CPU models.

Requires the host CPU microcode to support this feature before it can be used for guest CPUs.

virt-ssbd

Required to enable the CVE-2018-3639 fix Not included by default in any AMD CPU model.

Must be explicitly turned on for all AMD CPU models.

This should be provided to guests, even if amd-ssbd is also provided, for maximum guest compatibility.

Note for some QEMU / libvirt versions, this must be force enabled when when using "Host model", because this is a virtual feature that doesn't exist in the physical host CPUs.

amd-ssbd

Required to enable the CVE-2018-3639 fix Not included by default in any AMD CPU model.

Must be explicitly turned on for all AMD CPU models.

This provides higher performance than virt-ssbd so should be exposed to guests whenever available in the host. virt-ssbd should none the less also be exposed for maximum guest compatibility as some kernels only know about virt-ssbd.

amd-no-ssb

Recommended to indicate the host is not vulnerable CVE-2018-3639 Not included by default in any AMD CPU model.

Future hardware generations of CPU will not be vulnerable to CVE-2018-3639, and thus the guest should be told not to enable its mitigations, by exposing amd-no-ssb. This is mutually exclusive with virt-ssbd and amd-ssbd.

pdpe1gb

Recommended to allow guest OS to use 1GB size pages Not included by default in any AMD CPU model.

Should be explicitly turned on for all AMD CPU models.

Note that not all CPU hardware will support this feature.

### Default x86 CPU models
The default QEMU CPU models are designed such that they can run on all hosts. If an application does not wish to do perform any host compatibility checks before launching guests, the default is guaranteed to work.

The default CPU models will, however, leave the guest OS vulnerable to various CPU hardware flaws, so their use is strongly discouraged. Applications should follow the earlier guidance to setup a better CPU configuration, with host passthrough recommended if live migration is not needed.

qemu32, qemu64

QEMU Virtual CPU version 2.5+ (32 & 64 bit variants)

qemu64 is used for x86_64 guests and qemu32 is used for i686 guests, when no -cpu argument is given to QEMU, or no <cpu> is provided in libvirt XML.

### Other non-recommended x86 CPUs
The following CPUs models are compatible with most AMD and Intel x86 hosts, but their usage is discouraged, as they expose a very limited featureset, which prevents guests having optimal performance.

kvm32, kvm64

Common KVM processor (32 & 64 bit variants). Legacy models just for historical compatibility with ancient QEMU versions.

486, athlon, phenom, coreduo, core2duo, n270, pentium, pentium2, pentium3

Various very old x86 CPU models, mostly predating the introduction of hardware assisted virtualization, that should thus not be required for running virtual machines.

### Syntax for configuring CPU models
The examples below illustrate the approach to configuring the various CPU models / features in QEMU and libvirt.

### QEMU command line
Host passthrough:

```
qemu-system-x86_64 -cpu host
```

Host passthrough with feature customization:

```
qemu-system-x86_64 -cpu host,vmx=off,...
```

Named CPU models:

```
qemu-system-x86_64 -cpu Westmere
```

Named CPU models with feature customization:

```
qemu-system-x86_64 -cpu Westmere,pcid=on,...
```

### Libvirt guest XML
Host passthrough:

```
<cpu mode='host-passthrough'/>
```

Host passthrough with feature customization:

```
<cpu mode='host-passthrough'>

    <feature name="vmx" policy="disable"/>

    ...
</cpu>
```

Host model:

```
<cpu mode='host-model'/>
```

Host model with feature customization:

```
<cpu mode='host-model'>

    <feature name="vmx" policy="disable"/>

    ...
</cpu>
```

Named model:

```
<cpu mode='custom'>

    <model name="Westmere"/>
</cpu>
```

Named model with feature customization:

```
<cpu mode='custom'>

    <model name="Westmere"/>

    <feature name="pcid" policy="require"/>

    ...
</cpu>
```

### Supported CPU model configurations on MIPS hosts
QEMU supports variety of MIPS CPU models:

### Supported CPU models for MIPS32 hosts
The following CPU models are supported for use on MIPS32 hosts. Administrators / applications are recommended to use the CPU model that matches the generation of the host CPUs in use. In a deployment with a mixture of host CPU models between machines, if live migration compatibility is required, use the newest CPU model that is compatible across all desired hosts.

mips32r6-generic

MIPS32 Processor (Release 6, 2015)

P5600

MIPS32 Processor (P5600, 2014)

M14K, M14Kc

MIPS32 Processor (M14K, 2009)

74Kf

MIPS32 Processor (74K, 2007)

34Kf

MIPS32 Processor (34K, 2006)

24Kc, 24KEc, 24Kf

MIPS32 Processor (24K, 2003)

4Kc, 4Km, 4KEcR1, 4KEmR1, 4KEc, 4KEm

MIPS32 Processor (4K, 1999)

### Supported CPU models for MIPS64 hosts
The following CPU models are supported for use on MIPS64 hosts. Administrators / applications are recommended to use the CPU model that matches the generation of the host CPUs in use. In a deployment with a mixture of host CPU models between machines, if live migration compatibility is required, use the newest CPU model that is compatible across all desired hosts.

I6400

MIPS64 Processor (Release 6, 2014)

Loongson-2E

MIPS64 Processor (Loongson 2, 2006)

Loongson-2F

MIPS64 Processor (Loongson 2, 2008)

Loongson-3A1000

MIPS64 Processor (Loongson 3, 2010)

Loongson-3A4000

MIPS64 Processor (Loongson 3, 2018)

mips64dspr2

MIPS64 Processor (Release 2, 2006)

MIPS64R2-generic, 5KEc, 5KEf

MIPS64 Processor (Release 2, 2002)

20Kc

MIPS64 Processor (20K, 2000

5Kc, 5Kf

MIPS64 Processor (5K, 1999)

VR5432

MIPS64 Processor (VR, 1998)

R4000

MIPS64 Processor (MIPS III, 1991)

### Supported CPU models for nanoMIPS hosts
The following CPU models are supported for use on nanoMIPS hosts. Administrators / applications are recommended to use the CPU model that matches the generation of the host CPUs in use. In a deployment with a mixture of host CPU models between machines, if live migration compatibility is required, use the newest CPU model that is compatible across all desired hosts.

I7200

MIPS I7200 (nanoMIPS, 2018)

### Preferred CPU models for MIPS hosts
The following CPU models are preferred for use on different MIPS hosts:

MIPS III

R4000

MIPS32R2

34Kf

MIPS64R6

I6400

nanoMIPS

I7200

## SEE ALSO
The HTML documentation of QEMU for more precise information and Linux user mode emulator invocation.

## Author
The QEMU Project developers

## Copyright
2025, The QEMU Project Developers