From patchwork Mon Sep 7 15:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 306036 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8801C43461 for ; Mon, 7 Sep 2020 15:05:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D00FA2078E for ; Mon, 7 Sep 2020 15:05:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iDQQjP0O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D00FA2078E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFIiA-0005pd-Mx for qemu-devel@archiver.kernel.org; Mon, 07 Sep 2020 11:05:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFIhE-0004ip-Qd for qemu-devel@nongnu.org; Mon, 07 Sep 2020 11:04:40 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:29993 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kFIh8-0003gk-UK for qemu-devel@nongnu.org; Mon, 07 Sep 2020 11:04:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599491073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RGxYMEBRAK2fh8GrPevjIyG85PcFEeZDWBDUvEghzec=; b=iDQQjP0OAmnM+ZzNBic3ZqjUZqdNDM7Qigs/HDygFXbTmdRrypIoLr7m+KeZNPyUE/i1n6 7JXaKndo0LhRZlZ/eaicdrv956+T32dPPAJf8tJgLW/LodyjyF1dyYkImvmT0gGwGvFt9m bvAD/j0OunyrMnYok5hVIR7MT8cdypY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-96-yTCmQVhCMa2EU-i5eMM0EQ-1; Mon, 07 Sep 2020 11:04:27 -0400 X-MC-Unique: yTCmQVhCMa2EU-i5eMM0EQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D270801A9D; Mon, 7 Sep 2020 15:04:26 +0000 (UTC) Received: from localhost (ovpn-112-153.ams2.redhat.com [10.36.112.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 921C97C452; Mon, 7 Sep 2020 15:04:22 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [qemu-web PATCH] Add QEMU storage overview blog post Date: Mon, 7 Sep 2020 16:04:21 +0100 Message-Id: <20200907150421.8106-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/07 03:05:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Thomas Huth , qemu-block@nongnu.org, afrosi@redhat.com, mreitz@redhat.com, Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" I want to kick of a series of posts about storage. The first post covers high-level concepts, features, and utilities in QEMU. Later posts will discuss configuration details, architecture, and performance. Signed-off-by: Stefan Hajnoczi --- _posts/2020-09-07-qemu-storage-overview.md | 122 +++++++ screenshots/2020-09-07-block-device-io.svg | 366 +++++++++++++++++++++ screenshots/2020-09-07-lifecycle.svg | 328 ++++++++++++++++++ 3 files changed, 816 insertions(+) create mode 100644 _posts/2020-09-07-qemu-storage-overview.md create mode 100644 screenshots/2020-09-07-block-device-io.svg create mode 100644 screenshots/2020-09-07-lifecycle.svg diff --git a/_posts/2020-09-07-qemu-storage-overview.md b/_posts/2020-09-07-qemu-storage-overview.md new file mode 100644 index 0000000..79f60c4 --- /dev/null +++ b/_posts/2020-09-07-qemu-storage-overview.md @@ -0,0 +1,122 @@ +--- +layout: post +title: "An Overview of QEMU Storage Features" +date: 2020-09-07 07:00:00 +0000 +categories: [storage] +--- +This article introduces QEMU storage concepts including disk images, emulated +storage controllers, block jobs, the qemu-img utility, and qemu-storage-daemon. +If you are new to QEMU or want an overview of storage functionality in QEMU +then this article explains how things fit together. + +## Storage technologies +Persistently storing data and retrieving it later is the job of storage devices +such as hard disks, solid state drives (SSDs), USB flash drives, network +attached storage, and many others. Technologies vary in their storage capacity +(disk size), access speed, price, and other factors but most of them follow the +same block device model. + +![Block device I/O](/screenshots/2020-09-07-block-device-io.svg) + +Block devices are accessed in storage units called blocks. It is not possible +to access individual bytes, instead an entire block must be transferred. Block +sizes vary between devices with 512 bytes and 4KB block sizes being the most +common. + +As an emulator and virtualizer of computer systems, QEMU naturally has to offer +block device functionality. QEMU is capable of emulating hard disks, solid +state drives (SSDs), USB flash drives, SD cards, and more. + +## Storage for virtual machines +There is more to storage than just persisting data on behalf of a virtual +machine. The lifecycle of a disk image includes several operations that are +briefly covered below. + +![Block device I/O](/screenshots/2020-09-07-lifecycle.svg) + +Virtual machines consist of device configuration (how much RAM, which +graphics card, etc) and the contents of their disks. Transferring virtual +machines either to migrate them between hosts or to distribute them to users is +an important workflow that QEMU and its utilities support. + +Much like ISO files are used to distribute operating system installer images, +QEMU supports disk image file formats that are more convenient for transferring +disk images than the raw contents of a disk. In fact, disk image file formats +offer many other features such as the ability to import/export disks from other +hypervisors, snapshots, and instantiating new disk images from a backing file. + +Finally, managing disk images also involves the ability to take backups and +restore them should it be necessary to roll back after the current disk +contents have been lost or corrupted. + +## Emulated storage controllers + +The virtual machine accesses block devices through storage controllers. These +are the devices that the guest talks to in order to read or write blocks. Some +storage controllers facilitate access to multiple block devices, such as a SCSI +Host Bus Adapter that provides access to many SCSI disks. + +Storage controllers vary in their features, performance, and guest operating +system support. They expose a storage interface such as virtio-blk, NVMe, or +SCSI. Virtual machines program storage controller registers to transfer data +between memory buffers in RAM and block devices. Modern storage controllers +support multiple request queues so that I/O can processed in parallel at high +rates. + +The most common storage controllers in QEMU are virtio-blk, virtio-scsi, AHCI +(SATA), IDE for legacy systems, and SD Card controllers on embedded or smaller +boards. + +## Disk image file formats + +Disk image file formats handle the layout of blocks within a host file or +device. The simplest format is the raw format where each block is located at +its Logical Block Address (LBA) in the host file. This simple scheme does not +offer much in the way of features. + +QEMU's native disk image format is QCOW2 and it offers a number of features: +* Compactness - the host file grows as blocks are written so a sparse disk image can be much smaller than the virtual disk size. +* Backing files - disk images can be based on a parent image so that a master image can be shared by virtual machines. +* Snapshots - the state of the disk image can be saved and later reverted. +* Compression - block compression reduces the image size. +* Encryption - the disk image can be encrypted to protect data at rest. +* Dirty bitmaps - backup applications can track changed blocks so that efficient incremental backups are possible. + +A number of other disk image file formats are available for importing/exporting +disk images for use with other software including VMware and Hyper-V. + +## Block jobs + +Block jobs are background operations that manipulate disk images: +* Commit - merging backing files to shorten a backing file chain. +* Backup - copying out a point-in-time snapshot of a disk. +* Mirror - copying an image to a new destination while the virtual machine can still write to it. +* Stream - populating a disk image from its backing file. +* Create - creating new disk image files. + +These background operations are powerful tools for building storage migration +and backup workflows. + +Some operations like mirror and stream can take a long time because they copy +large amounts of data. Block jobs support throttling to limit the performance +impact on virtual machines. + +## qemu-img and qemu-storage-daemon + +The [qemu-img utility](https://www.qemu.org/docs/master/interop/qemu-img.html) manipulates disk images. It can create, resize, snapshot, +repair, and inspect disk images. It has both human-friendly and JSON output +formats, making it suitable for manual use as well as scripting. + +qemu-storage-daemon exposes QEMU's storage functionality in a server process +without running a virtual machine. It can export disk images over the Network +Block Device (NBD) protocol as well as run block jobs and other storage +commands. This makes qemu-storage-daemon useful for applications that want to +automate disk image manipulation. + +## Conclusion + +QEMU presents block devices to virtual machines via emulated storage +controllers. On the host side the disk image file format, block jobs, and +qemu-img/qemu-storage-daemon utilities provide functionality for working with +disk images. Future blog posts will dive deeper into some of these areas and +describe best practices for configuring storage. diff --git a/screenshots/2020-09-07-block-device-io.svg b/screenshots/2020-09-07-block-device-io.svg new file mode 100644 index 0000000..b1effcc --- /dev/null +++ b/screenshots/2020-09-07-block-device-io.svg @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + This is a test + 0 1 2 3 4 5 + Logical Block Address + Write + Read + Block Device I/O + + diff --git a/screenshots/2020-09-07-lifecycle.svg b/screenshots/2020-09-07-lifecycle.svg new file mode 100644 index 0000000..1c10668 --- /dev/null +++ b/screenshots/2020-09-07-lifecycle.svg @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + Import + Export + Backup + Restore + Migrate + Create + + + + + DiskImage + +