[PATCH 0/2] qemu: Clarify purpose of image format settings

The current documentation of the various foo_image_format settings in qemu.conf subtly implies they are only used for specifying compression. Patch1 of this small series attempts to clarify and improve the description of the settings. It defines image format as a way to specify the desired layout of guest memory blocks on disk. Patch2 changes the name of the 'compressed' field of virQEMUSaveHeader to 'format', removing implication that format == compressed in the code. Jim Fehlig (2): qemu: conf: Improve the foo_image_format setting descriptions qemu: Rename compressed field of save image header src/qemu/qemu.conf.in | 46 +++++++++++++++++++++++++-------------- src/qemu/qemu_saveimage.c | 18 +++++++-------- src/qemu/qemu_saveimage.h | 4 ++-- 3 files changed, 41 insertions(+), 27 deletions(-) -- 2.35.3

The current description of the various foo_image_format settings can be construded to imply the setting is only used to control compression of the image. Improve the documentation to clarify that format describes the representation of guest memory blocks on disk, which includes compression among other possible layouts. Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- If something like this is agreeable, I'd remove the sentences about 'mapped' format and include those in the mapped-ram work. src/qemu/qemu.conf.in | 46 ++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 6bc2140dcb..3e221048ef 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -578,27 +578,41 @@ # "/dev/infiniband/uverbs0" -# The default format for QEMU/KVM guest save images is raw; that is, the -# memory from the domain is dumped out directly to a file. If you have -# guests with a large amount of memory, however, this can take up quite -# a bit of space. If you would like to compress the images while they -# are being saved to disk, you can also set "zstd", "lzop", "gzip", "bzip2", -# or "xz" for save_image_format. Note that this means you slow down the process -# of saving a domain in order to save disk space. +# The libvirt QEMU driver supports serveral different save image formats. +# The term "format" is used loosely to describe how the save image data is +# represented on disk. It could be a continguous stream of guest memory blocks, +# a stream of compressed memory blocks, or memory blocks mapped to fixed +# locations in the save image file. # -# save_image_format is used when you use 'virsh save' or 'virsh managedsave' -# at scheduled saving, and it is an error if the specified save_image_format -# is not valid, or the requested compression program can't be found. +# A continguous stream of guest memory blocks is the default format for QEMU/KVM +# guest save images and is termed "raw". The raw format can consume considerable +# disk space when saving large memory guests. Various compression formats are +# available for specifying a save image compressed by the named algorithm. +# Supported compression formats are "zstd", "lzop", "gzip", "bzip2", and "xz". +# The "mapped" format supports efficient direct and multithreaded I/O to the +# save image file. + +# save_image_format can be used to select the desired save format. "raw" is +# the traditional format used by libvirt and is also the default. The +# compression formats can be used to save disk space, although this typically +# results in longer save and restore times. The "mapped" format is preferred +# when doing direct and parallel I/O to the save image file, but can result +# in sparse save image files due to mapping of guest memory blocks to file +# offsets. # -# dump_image_format is used when you use 'virsh dump' at emergency -# crashdump, and if the specified dump_image_format is not valid, or -# the requested compression program can't be found, this falls -# back to "raw" compression. +# save_image_format is used with 'virsh save' or 'virsh managedsave'. It is +# an error if the specified save_image_format is not valid, or cannot be +# supported by the system. # -# snapshot_image_format specifies the compression algorithm of the memory save +# dump_image_format is analogous to save_image_format and is used with +# 'virsh dump' at emergency crashdump. If the specified dump_image_format is +# not valid or cannot be supported by the system, this falls back to the +# "raw" format. +# +# Likewise, snapshot_image_format specifies the format of the memory save # image when an external snapshot of a domain is taken. This does not apply # on disk image format. It is an error if the specified format isn't valid, -# or the requested compression program can't be found. +# or the system cannot support the requested format. # #save_image_format = "raw" #dump_image_format = "raw" -- 2.35.3

The corresponding qemu.conf setting is named save_image_format and the enum of supported format types is declared with name virQEMUSaveFormat. Let's be consistent and use 'format' instead of 'compressed' as a field name in the virQEMUSaveHeader struct. Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- src/qemu/qemu_saveimage.c | 18 +++++++++--------- src/qemu/qemu_saveimage.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 018ab5a222..ffd988bc0b 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -55,8 +55,8 @@ typedef enum { QEMU_SAVE_FORMAT_LAST } virQEMUSaveFormat; -VIR_ENUM_DECL(qemuSaveCompression); -VIR_ENUM_IMPL(qemuSaveCompression, +VIR_ENUM_DECL(qemuSaveFormat); +VIR_ENUM_IMPL(qemuSaveFormat, QEMU_SAVE_FORMAT_LAST, "raw", "gzip", @@ -72,7 +72,7 @@ qemuSaveImageBswapHeader(virQEMUSaveHeader *hdr) hdr->version = GUINT32_SWAP_LE_BE(hdr->version); hdr->data_len = GUINT32_SWAP_LE_BE(hdr->data_len); hdr->was_running = GUINT32_SWAP_LE_BE(hdr->was_running); - hdr->compressed = GUINT32_SWAP_LE_BE(hdr->compressed); + hdr->format = GUINT32_SWAP_LE_BE(hdr->format); hdr->cookieOffset = GUINT32_SWAP_LE_BE(hdr->cookieOffset); } @@ -97,7 +97,7 @@ virQEMUSaveData * virQEMUSaveDataNew(char *domXML, qemuDomainSaveCookie *cookieObj, bool running, - int compressed, + int format, virDomainXMLOption *xmlopt) { virQEMUSaveData *data = NULL; @@ -114,7 +114,7 @@ virQEMUSaveDataNew(char *domXML, memcpy(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic)); header->version = QEMU_SAVE_VERSION; header->was_running = running ? 1 : 0; - header->compressed = compressed; + header->format = format; data->xml = domXML; return data; @@ -230,7 +230,7 @@ static virCommand * qemuSaveImageGetCompressionCommand(virQEMUSaveFormat compression) { virCommand *ret = NULL; - const char *prog = qemuSaveCompressionTypeToString(compression); + const char *prog = qemuSaveFormatTypeToString(compression); if (!prog) { virReportError(VIR_ERR_OPERATION_FAILED, @@ -282,10 +282,10 @@ qemuSaveImageDecompressionStart(virQEMUSaveData *data, if (header->version != 2) return 0; - if (header->compressed == QEMU_SAVE_FORMAT_RAW) + if (header->format == QEMU_SAVE_FORMAT_RAW) return 0; - if (!(cmd = qemuSaveImageGetCompressionCommand(header->compressed))) + if (!(cmd = qemuSaveImageGetCompressionCommand(header->format))) return -1; *intermediatefd = *fd; @@ -475,7 +475,7 @@ qemuSaveImageGetCompressionProgram(const char *imageFormat, if (!imageFormat) return QEMU_SAVE_FORMAT_RAW; - if ((ret = qemuSaveCompressionTypeFromString(imageFormat)) < 0) + if ((ret = qemuSaveFormatTypeFromString(imageFormat)) < 0) goto error; if (ret == QEMU_SAVE_FORMAT_RAW) diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index e541792153..0e58dd14b6 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -38,7 +38,7 @@ struct _virQEMUSaveHeader { uint32_t version; uint32_t data_len; uint32_t was_running; - uint32_t compressed; + uint32_t format; uint32_t cookieOffset; uint32_t unused[14]; }; @@ -121,7 +121,7 @@ virQEMUSaveData * virQEMUSaveDataNew(char *domXML, qemuDomainSaveCookie *cookieObj, bool running, - int compressed, + int format, virDomainXMLOption *xmlopt); void -- 2.35.3

On 8/16/24 11:20, Jim Fehlig wrote:
The current documentation of the various foo_image_format settings in qemu.conf subtly implies they are only used for specifying compression. Patch1 of this small series attempts to clarify and improve the description of the settings. It defines image format as a way to specify the desired layout of guest memory blocks on disk.
Patch2 changes the name of the 'compressed' field of virQEMUSaveHeader to 'format', removing implication that format == compressed in the code.
This patch could have went a bit further in replacing the use of 'compressed' with 'format'. I've sent a V2 of the series https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/ROTXT... Regards, Jim
participants (1)
-
Jim Fehlig