forked from pool/libvirt
827fa7dc68
- libxl: fix VM migration on busy hosts 60b4fd90-libxl-rm-vm-finish-phase.patch, e39c66d3-libxl-fix-p2p-migration.patch, 47da84e0-libxl-fix-job-handling-migsrc.patch, 0149464a-libxl-fix-job-handling-migdst.patch, 5ea2abb3-libxl-join-mig-rcv-thread.patch bsc#1108086 - Update to libvirt 4.7.0 - Many incremental improvements and bug fixes, see http://libvirt.org/news.html - Dropped patches: 9ed59012--revert-jansson1.patch, 54f2b5e3-revert-jansson2.patch, b56950fd-revert-jansson3.patch, 6c3d66ac-revert-jansson4.patch, 8e373e6d-revert-jansson5.patch, 6f99de31-revert-jansson6.patch, f204cf51-revert-jansson7.patch, 5a58b5ed-revert-jansson8.patch, 63f6e0e9-revert-jansson9.patch, 8687eba-revert-jansson10.patch, e96e71d8-revert-jansson11.patch, d99a8959-revert-jansson12.patch, 074a7e14-revert-jansson13.patch OBS-URL: https://build.opensuse.org/request/show/636920 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=704
132 lines
4.5 KiB
Diff
132 lines
4.5 KiB
Diff
From 661298572a5499ccfafcd36d30d66d091a5be9b6 Mon Sep 17 00:00:00 2001
|
|
From: Jim Fehlig <jfehlig@suse.com>
|
|
Date: Fri, 23 Mar 2018 17:41:51 -0600
|
|
Subject: [PATCH] libxl: add support for BlockResize API
|
|
|
|
Add support in the libxl driver for the BlockResize API. Use libxl's
|
|
libxl_qemu_monitor_command API to issue the block_resize command to qemu.
|
|
|
|
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
|
|
|
Note: In its current form, this patch is not upstream material IMO. It uses
|
|
the unsupported libxl_qemu_monitor_command() API. Before it can be considered
|
|
upstream, we need an upstream solution in qemu and Xen. Bruce will work on
|
|
the qemu part. Once done we can consider how to do the Xen part. And only
|
|
after we have a supported blockresize API in Xen (libxl) can we consider
|
|
reworking this patch and submitting it to upstream libvirt.
|
|
|
|
---
|
|
src/libxl/libxl_driver.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 91 insertions(+)
|
|
|
|
Index: libvirt-4.7.0/src/libxl/libxl_driver.c
|
|
===================================================================
|
|
--- libvirt-4.7.0.orig/src/libxl/libxl_driver.c
|
|
+++ libvirt-4.7.0/src/libxl/libxl_driver.c
|
|
@@ -5119,6 +5119,97 @@ libxlDomainMemoryStats(virDomainPtr dom,
|
|
|
|
#undef LIBXL_SET_MEMSTAT
|
|
|
|
+/**
|
|
+ * Resize a block device while a guest is running. Resize to a lower size
|
|
+ * is supported, but should be used with extreme caution. Note that it
|
|
+ * only supports to resize image files, it can't resize block devices
|
|
+ * like LVM volumes.
|
|
+ */
|
|
+static int
|
|
+libxlDomainBlockResize(virDomainPtr dom,
|
|
+ const char *path,
|
|
+ unsigned long long size,
|
|
+ unsigned int flags)
|
|
+{
|
|
+ libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
+ libxlDriverConfigPtr cfg;
|
|
+ virDomainObjPtr vm;
|
|
+ int ret = -1;
|
|
+ virDomainDiskDefPtr disk = NULL;
|
|
+ char *moncmd = NULL;
|
|
+ char *monreply = NULL;
|
|
+
|
|
+ virCheckFlags(VIR_DOMAIN_BLOCK_RESIZE_BYTES, -1);
|
|
+
|
|
+ if (path[0] == '\0') {
|
|
+ virReportError(VIR_ERR_INVALID_ARG,
|
|
+ "%s", _("empty path"));
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ /* We prefer operating on bytes. */
|
|
+ if ((flags & VIR_DOMAIN_BLOCK_RESIZE_BYTES) == 0) {
|
|
+ if (size > ULLONG_MAX / 1024) {
|
|
+ virReportError(VIR_ERR_OVERFLOW,
|
|
+ _("size must be less than %llu"),
|
|
+ ULLONG_MAX / 1024);
|
|
+ return -1;
|
|
+ }
|
|
+ size *= 1024;
|
|
+ }
|
|
+
|
|
+ cfg = libxlDriverConfigGet(driver);
|
|
+ if (!(vm = libxlDomObjFromDomain(dom)))
|
|
+ goto cleanup;
|
|
+
|
|
+ if (virDomainBlockResizeEnsureACL(dom->conn, vm->def) < 0)
|
|
+ goto cleanup;
|
|
+
|
|
+ if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
|
+ goto cleanup;
|
|
+
|
|
+ if (!virDomainObjIsActive(vm)) {
|
|
+ virReportError(VIR_ERR_OPERATION_INVALID,
|
|
+ "%s", _("domain is not running"));
|
|
+ goto endjob;
|
|
+ }
|
|
+
|
|
+ if (!(disk = virDomainDiskByName(vm->def, path, false))) {
|
|
+ virReportError(VIR_ERR_INVALID_ARG,
|
|
+ _("invalid path: %s"), path);
|
|
+ goto endjob;
|
|
+ }
|
|
+
|
|
+ /* qcow2 and qed must be sized on 512 byte blocks/sectors,
|
|
+ * so adjust size if necessary to round up.
|
|
+ */
|
|
+ if (disk->src->format == VIR_STORAGE_FILE_QCOW2 ||
|
|
+ disk->src->format == VIR_STORAGE_FILE_QED)
|
|
+ size = VIR_ROUND_UP(size, 512);
|
|
+
|
|
+ if (virAsprintf(&moncmd, "block_resize %s %lluB", disk->dst, size) < 0)
|
|
+ goto endjob;
|
|
+
|
|
+ if (libxl_qemu_monitor_command(cfg->ctx, vm->def->id, moncmd, &monreply) != 0) {
|
|
+ virReportError(VIR_ERR_OPERATION_FAILED,
|
|
+ _("block_resize command failed for device '%s' on domain '%d'"),
|
|
+ disk->dst, vm->def->id);
|
|
+ goto endjob;
|
|
+ }
|
|
+
|
|
+ ret = 0;
|
|
+
|
|
+ endjob:
|
|
+ libxlDomainObjEndJob(driver, vm);
|
|
+
|
|
+ cleanup:
|
|
+ VIR_FREE(moncmd);
|
|
+ VIR_FREE(monreply);
|
|
+ virDomainObjEndAPI(&vm);
|
|
+ virObjectUnref(cfg);
|
|
+ return ret;
|
|
+}
|
|
+
|
|
static int
|
|
libxlDomainGetJobInfo(virDomainPtr dom,
|
|
virDomainJobInfoPtr info)
|
|
@@ -6497,6 +6588,7 @@ static virHypervisorDriver libxlHypervis
|
|
#endif
|
|
.nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
|
|
.nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */
|
|
+ .domainBlockResize = libxlDomainBlockResize, /* 4.2.0 */
|
|
.domainGetJobInfo = libxlDomainGetJobInfo, /* 1.3.1 */
|
|
.domainGetJobStats = libxlDomainGetJobStats, /* 1.3.1 */
|
|
.domainMemoryStats = libxlDomainMemoryStats, /* 1.3.0 */
|