From 1ea77165a00baeb2f6c4aaff5619fa7bcf883e5536a8e1ed1f62af739fc1aa83 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Thu, 22 Mar 2018 00:33:49 +0000 Subject: [PATCH] Accepting request 589839 from home:jfehlig:branches:Virtualization - libxl: don't hardcode scheduler weight 83edaf44-libxl-dont-hardcode-sched-weight.patch bsc#1086377 - libxl: fixes and improvements in migration APIs 64370c4b-libxl-MigrateBegin.patch, 99486799-libxl-MigrateConfirm.patch, f5eacf2a-libxl-MigratePerform.patch, 4e6fcdb6-libxl-libxlDomObjFromDomain-cleanup.patch, fe51dbda-libxl-use-FindByRef.patch, 60b3fcd9-libxl-MigratePrepare.patch, 3c89868c-libxl-lock-after-ListRemove.patch, 13e81fc6-libxl-EndJob-on-error.patch, 594b8b99-libxl-DefineXMLFlags-API-pattern.patch, c66e344e-libxl-dont-deref-NULL.patch bsc#1080957 OBS-URL: https://build.opensuse.org/request/show/589839 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=681 --- 13e81fc6-libxl-EndJob-on-error.patch | 25 ++ 3c89868c-libxl-lock-after-ListRemove.patch | 132 +++++++++ ...-libxl-libxlDomObjFromDomain-cleanup.patch | 269 ++++++++++++++++++ ...b99-libxl-DefineXMLFlags-API-pattern.patch | 43 +++ 60b3fcd9-libxl-MigratePrepare.patch | 74 +++++ 64370c4b-libxl-MigrateBegin.patch | 82 ++++++ ...f44-libxl-dont-hardcode-sched-weight.patch | 265 +++++++++++++++++ 99486799-libxl-MigrateConfirm.patch | 75 +++++ c66e344e-libxl-dont-deref-NULL.patch | 30 ++ f5eacf2a-libxl-MigratePerform.patch | 27 ++ fe51dbda-libxl-use-FindByRef.patch | 60 ++++ libvirt.changes | 23 ++ libvirt.spec | 22 ++ libxl-dom-reset.patch | 4 +- libxl-set-cach-mode.patch | 4 +- libxl-set-migration-constraints.patch | 6 +- libxl-support-block-script.patch | 8 +- 17 files changed, 1138 insertions(+), 11 deletions(-) create mode 100644 13e81fc6-libxl-EndJob-on-error.patch create mode 100644 3c89868c-libxl-lock-after-ListRemove.patch create mode 100644 4e6fcdb6-libxl-libxlDomObjFromDomain-cleanup.patch create mode 100644 594b8b99-libxl-DefineXMLFlags-API-pattern.patch create mode 100644 60b3fcd9-libxl-MigratePrepare.patch create mode 100644 64370c4b-libxl-MigrateBegin.patch create mode 100644 83edaf44-libxl-dont-hardcode-sched-weight.patch create mode 100644 99486799-libxl-MigrateConfirm.patch create mode 100644 c66e344e-libxl-dont-deref-NULL.patch create mode 100644 f5eacf2a-libxl-MigratePerform.patch create mode 100644 fe51dbda-libxl-use-FindByRef.patch diff --git a/13e81fc6-libxl-EndJob-on-error.patch b/13e81fc6-libxl-EndJob-on-error.patch new file mode 100644 index 0000000..2907cef --- /dev/null +++ b/13e81fc6-libxl-EndJob-on-error.patch @@ -0,0 +1,25 @@ +commit 13e81fc6fad03aa6b6ecf4230f44b2ea55078229 +Author: Jim Fehlig +Date: Fri Mar 16 15:22:45 2018 -0600 + + libxl: call EndJob in error case + + If starting the domain fails in libxlDomainCreateXML, we mistakenly + jumped to cleanup without calling libxlDomainObjEndJob. Remove the + jump to 'cleanup'. + + Signed-off-by: Jim Fehlig + Reviewed-by: John Ferlan + +Index: libvirt-4.1.0/src/libxl/libxl_driver.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_driver.c ++++ libvirt-4.1.0/src/libxl/libxl_driver.c +@@ -1066,7 +1066,6 @@ libxlDomainCreateXML(virConnectPtr conn, + if (!vm->persistent) { + virDomainObjListRemove(driver->domains, vm); + virObjectLock(vm); +- goto cleanup; + } + goto endjob; + } diff --git a/3c89868c-libxl-lock-after-ListRemove.patch b/3c89868c-libxl-lock-after-ListRemove.patch new file mode 100644 index 0000000..3a2a72e --- /dev/null +++ b/3c89868c-libxl-lock-after-ListRemove.patch @@ -0,0 +1,132 @@ +commit 3c89868c5fef3d0cfbc40d0185447d13a6242620 +Author: Jim Fehlig +Date: Fri Mar 16 15:15:07 2018 -0600 + + libxl: lock virDomainObj after ListRemove + + Most libxl driver API use the pattern of lock and add a ref to + virDomainObj, perform API, then decrement ref and unlock in + virDomainEndAPI. In some cases the API may call + virDomainObjListRemove, which unlocks the virDomainObj. Relock + the object in such cases so EndAPI is called with a locked object. + + Signed-off-by: Jim Fehlig + Reviewed-by: John Ferlan + +Index: libvirt-4.1.0/src/libxl/libxl_driver.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_driver.c ++++ libvirt-4.1.0/src/libxl/libxl_driver.c +@@ -1056,7 +1056,7 @@ libxlDomainCreateXML(virConnectPtr conn, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { + if (!vm->persistent) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + goto cleanup; + } +@@ -1065,7 +1065,7 @@ libxlDomainCreateXML(virConnectPtr conn, + (flags & VIR_DOMAIN_START_PAUSED) != 0) < 0) { + if (!vm->persistent) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + goto cleanup; + } + goto endjob; +@@ -1417,8 +1417,10 @@ libxlDomainDestroyFlags(virDomainPtr dom + VIR_DOMAIN_EVENT_STOPPED_DESTROYED); + + libxlDomainCleanup(driver, vm); +- if (!vm->persistent) ++ if (!vm->persistent) { + virDomainObjListRemove(driver->domains, vm); ++ virObjectLock(vm); ++ } + + ret = 0; + +@@ -1822,7 +1824,7 @@ libxlDomainSaveFlags(virDomainPtr dom, c + cleanup: + if (remove_dom && vm) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + virDomainObjEndAPI(&vm); + return ret; +@@ -1877,7 +1879,7 @@ libxlDomainRestoreFlags(virConnectPtr co + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { + if (!vm->persistent) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + goto cleanup; + } +@@ -1885,8 +1887,10 @@ libxlDomainRestoreFlags(virConnectPtr co + ret = libxlDomainStartRestore(driver, vm, + (flags & VIR_DOMAIN_SAVE_PAUSED) != 0, + fd, hdr.version); +- if (ret < 0 && !vm->persistent) ++ if (ret < 0 && !vm->persistent) { + virDomainObjListRemove(driver->domains, vm); ++ virObjectLock(vm); ++ } + + libxlDomainObjEndJob(driver, vm); + +@@ -1995,7 +1999,7 @@ libxlDomainCoreDump(virDomainPtr dom, co + cleanup: + if (remove_dom && vm) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + virDomainObjEndAPI(&vm); + if (event) +@@ -2056,7 +2060,7 @@ libxlDomainManagedSave(virDomainPtr dom, + cleanup: + if (remove_dom && vm) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + virDomainObjEndAPI(&vm); + VIR_FREE(name); +@@ -2880,7 +2884,7 @@ libxlDomainUndefineFlags(virDomainPtr do + vm->persistent = 0; + } else { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + + ret = 0; +Index: libvirt-4.1.0/src/libxl/libxl_migration.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_migration.c ++++ libvirt-4.1.0/src/libxl/libxl_migration.c +@@ -299,7 +299,7 @@ libxlDoMigrateReceive(void *opaque) + cleanup: + if (remove_dom) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + virDomainObjEndAPI(&vm); + } +@@ -1336,8 +1336,11 @@ libxlDomainMigrationFinish(virConnectPtr + VIR_DOMAIN_SHUTOFF_FAILED); + event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_FAILED); +- if (!vm->persistent) ++ if (!vm->persistent) { + virDomainObjListRemove(driver->domains, vm); ++ /* Caller passed a locked vm and expects the same on return */ ++ virObjectLock(vm); ++ } + } + + if (event) diff --git a/4e6fcdb6-libxl-libxlDomObjFromDomain-cleanup.patch b/4e6fcdb6-libxl-libxlDomObjFromDomain-cleanup.patch new file mode 100644 index 0000000..8dd2576 --- /dev/null +++ b/4e6fcdb6-libxl-libxlDomObjFromDomain-cleanup.patch @@ -0,0 +1,269 @@ +commit 4e6fcdb6fa838d57a278dacd21bc6932edabec67 +Author: John Ferlan +Date: Fri Mar 9 11:47:59 2018 -0500 + + libxl: Properly cleanup after libxlDomObjFromDomain + + Commit id '9ac945078' altered libxlDomObjFromDomain to return + a locked *and* ref counted object for some specific purposes; + however, it neglected to alter all the consumers of the helper + to use virDomainObjEndAPI thus leaving many objects with extra + ref counts. + + Signed-off-by: John Ferlan + Reviewed-by: Jim Fehlig + +Index: libvirt-4.1.0/src/libxl/libxl_driver.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_driver.c ++++ libvirt-4.1.0/src/libxl/libxl_driver.c +@@ -1322,8 +1322,7 @@ libxlDomainShutdownFlags(virDomainPtr do + } + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -1373,8 +1372,7 @@ libxlDomainReboot(virDomainPtr dom, unsi + } + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -1459,8 +1457,7 @@ libxlDomainGetOSType(virDomainPtr dom) + goto cleanup; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return type; + } + +@@ -1479,8 +1476,7 @@ libxlDomainGetMaxMemory(virDomainPtr dom + ret = virDomainDefGetMemoryTotal(vm->def); + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -1658,8 +1654,7 @@ libxlDomainGetInfo(virDomainPtr dom, vir + ret = 0; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -1685,8 +1680,7 @@ libxlDomainGetState(virDomainPtr dom, + ret = 0; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -2110,8 +2104,7 @@ libxlDomainHasManagedSaveImage(virDomain + ret = vm->hasManagedSave; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -2140,8 +2133,7 @@ libxlDomainManagedSaveRemove(virDomainPt + + cleanup: + VIR_FREE(name); +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -2352,8 +2344,7 @@ libxlDomainGetVcpusFlags(virDomainPtr do + ret = virDomainDefGetVcpus(def); + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -2484,8 +2475,7 @@ libxlDomainGetVcpuPinInfo(virDomainPtr d + libxl_get_max_cpus(cfg->ctx), NULL); + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -2548,8 +2538,7 @@ libxlDomainGetVcpus(virDomainPtr dom, vi + ret = maxinfo; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -2580,8 +2569,7 @@ libxlDomainGetXMLDesc(virDomainPtr dom, + virDomainDefFormatConvertXMLFlags(flags)); + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -2901,8 +2889,7 @@ libxlDomainUndefineFlags(virDomainPtr do + + cleanup: + VIR_FREE(name); +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + if (event) + libxlDomainEventQueue(driver, event); + virObjectUnref(cfg); +@@ -4261,8 +4248,7 @@ libxlDomainUpdateDeviceFlags(virDomainPt + cleanup: + virDomainDefFree(vmdef); + virDomainDeviceDefFree(dev); +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -4394,8 +4380,7 @@ libxlDomainGetAutostart(virDomainPtr dom + ret = 0; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -4521,8 +4506,7 @@ libxlDomainGetSchedulerType(virDomainPtr + ignore_value(VIR_STRDUP(ret, name)); + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -4587,8 +4571,7 @@ libxlDomainGetSchedulerParametersFlags(v + ret = 0; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -4750,8 +4733,7 @@ libxlDomainOpenConsole(virDomainPtr dom, + } + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -4886,8 +4868,7 @@ libxlDomainGetNumaParameters(virDomainPt + VIR_FREE(nodeset); + virBitmapFree(nodes); + libxl_bitmap_dispose(&nodemap); +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } +@@ -4908,8 +4889,7 @@ libxlDomainIsActive(virDomainPtr dom) + ret = virDomainObjIsActive(obj); + + cleanup: +- if (obj) +- virObjectUnlock(obj); ++ virDomainObjEndAPI(&obj); + return ret; + } + +@@ -4928,8 +4908,7 @@ libxlDomainIsPersistent(virDomainPtr dom + ret = obj->persistent; + + cleanup: +- if (obj) +- virObjectUnlock(obj); ++ virDomainObjEndAPI(&obj); + return ret; + } + +@@ -4948,8 +4927,7 @@ libxlDomainIsUpdated(virDomainPtr dom) + ret = vm->updated; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -5107,8 +5085,7 @@ libxlDomainGetCPUStats(virDomainPtr dom, + start_cpu, ncpus); + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -5211,8 +5188,7 @@ libxlDomainGetJobInfo(virDomainPtr dom, + ret = 0; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -5263,8 +5239,7 @@ libxlDomainGetJobStats(virDomainPtr dom, + ret = 0; + + cleanup: +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + return ret; + } + diff --git a/594b8b99-libxl-DefineXMLFlags-API-pattern.patch b/594b8b99-libxl-DefineXMLFlags-API-pattern.patch new file mode 100644 index 0000000..b2db48f --- /dev/null +++ b/594b8b99-libxl-DefineXMLFlags-API-pattern.patch @@ -0,0 +1,43 @@ +commit 594b8b996c83724d6b1c73641daf277307afe5f7 +Author: Jim Fehlig +Date: Fri Mar 16 15:29:48 2018 -0600 + + libxl: convert DefineXMLFlags to use begin/end API pattern + + Similar to other uses of virDomainObjListAdd, on success add a ref to the + virDomainObj so that virDomainObjEndAPI can be called as usual. + + Signed-off-by: Jim Fehlig + Reviewed-by: John Ferlan + +Index: libvirt-4.1.0/src/libxl/libxl_driver.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_driver.c ++++ libvirt-4.1.0/src/libxl/libxl_driver.c +@@ -2794,6 +2794,7 @@ libxlDomainDefineXMLFlags(virConnectPtr + &oldDef))) + goto cleanup; + ++ virObjectRef(vm); + def = NULL; + vm->persistent = 1; + +@@ -2801,7 +2802,7 @@ libxlDomainDefineXMLFlags(virConnectPtr + cfg->caps, + vm->newDef ? vm->newDef : vm->def) < 0) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + goto cleanup; + } + +@@ -2815,8 +2816,7 @@ libxlDomainDefineXMLFlags(virConnectPtr + cleanup: + virDomainDefFree(def); + virDomainDefFree(oldDef); +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + if (event) + libxlDomainEventQueue(driver, event); + virObjectUnref(cfg); diff --git a/60b3fcd9-libxl-MigratePrepare.patch b/60b3fcd9-libxl-MigratePrepare.patch new file mode 100644 index 0000000..b91171c --- /dev/null +++ b/60b3fcd9-libxl-MigratePrepare.patch @@ -0,0 +1,74 @@ +commit 60b3fcd90cbd83e5721484d72414dfee1706dab8 +Author: Jim Fehlig +Date: Tue Mar 13 10:48:28 2018 -0600 + + libxl: MigratePrepare: use standard begin and end API pattern + + libxlDomainMigrationPrepare adds the incoming domain def to the list + of domains via virDomainObjListAdd, but never adds its own ref to the + returned virDomainObj as other callers of virDomainObjListAdd do. + libxlDomainMigrationPrepareTunnel3 suffers the same discrepancy. + + Change both to add a ref to the virDomainObj after a successful + virDomainObjListAdd, similar to other callers. This ensures a consistent + pattern throughout the drivers and allows using the virDomainObjEndAPI + function for cleanup. + + Signed-off-by: Jim Fehlig + Reviewed-by: John Ferlan + +Index: libvirt-4.1.0/src/libxl/libxl_migration.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_migration.c ++++ libvirt-4.1.0/src/libxl/libxl_migration.c +@@ -583,6 +583,7 @@ libxlDomainMigrationPrepareTunnel3(virCo + NULL))) + goto error; + ++ virObjectRef(vm); + *def = NULL; + priv = vm->privateData; + +@@ -635,13 +636,11 @@ libxlDomainMigrationPrepareTunnel3(virCo + /* Remove virDomainObj from domain list */ + if (vm) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + + done: +- if (vm) +- virObjectUnlock(vm); +- ++ virDomainObjEndAPI(&vm); + return ret; + } + +@@ -683,6 +682,7 @@ libxlDomainMigrationPrepare(virConnectPt + NULL))) + goto error; + ++ virObjectRef(vm); + *def = NULL; + priv = vm->privateData; + +@@ -810,7 +810,7 @@ libxlDomainMigrationPrepare(virConnectPt + /* Remove virDomainObj from domain list */ + if (vm) { + virDomainObjListRemove(driver->domains, vm); +- vm = NULL; ++ virObjectLock(vm); + } + + done: +@@ -820,8 +820,7 @@ libxlDomainMigrationPrepare(virConnectPt + VIR_FREE(hostname); + else + virURIFree(uri); +- if (vm) +- virObjectUnlock(vm); ++ virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; + } diff --git a/64370c4b-libxl-MigrateBegin.patch b/64370c4b-libxl-MigrateBegin.patch new file mode 100644 index 0000000..203dca1 --- /dev/null +++ b/64370c4b-libxl-MigrateBegin.patch @@ -0,0 +1,82 @@ +commit 64370c4b81f04ca73c195854966c6740e01483f2 +Author: Jim Fehlig +Date: Mon Mar 12 11:51:43 2018 -0600 + + libxl: MigrateBegin: Dont call EndAPI in helper function + + The libxlDomainMigrateBegin3Params API locks and ref counts the associated + virDomainObj but relies on the helper function libxlDomainMigrationBegin + to unref/unlock the object. libxlDomainMigrationBegin is also used by + libxlDomainMigratePerform3Params for p2p migration, but in that case the + lock/ref and unref/unlock are properly handled in the API entry point. So + p2p migrations suffer a double unref/unlock in the Perform API. + + Remove the unref/unlock (virDomainObjEndAPI) from libxlDomainMigrationBegin + and adjust libxlDomainMigrateBegin3Params to properly unref/unlock + the virDomainObj on success and error paths. + + Signed-off-by: Jim Fehlig + Reviewed-by: John Ferlan + +Index: libvirt-4.1.0/src/libxl/libxl_driver.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_driver.c ++++ libvirt-4.1.0/src/libxl/libxl_driver.c +@@ -5876,6 +5876,7 @@ libxlDomainMigrateBegin3Params(virDomain + { + const char *xmlin = NULL; + virDomainObjPtr vm = NULL; ++ char *xmlout = NULL; + + #ifdef LIBXL_HAVE_NO_SUSPEND_RESUME + virReportUnsupportedError(); +@@ -5895,25 +5896,26 @@ libxlDomainMigrateBegin3Params(virDomain + return NULL; + + if (STREQ_NULLABLE(vm->def->name, "Domain-0")) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", +- _("Domain-0 cannot be migrated")); +- return NULL; ++ virReportError(VIR_ERR_OPERATION_INVALID, "%s", ++ _("Domain-0 cannot be migrated")); ++ goto cleanup; + } + +- if (virDomainMigrateBegin3ParamsEnsureACL(domain->conn, vm->def) < 0) { +- virObjectUnlock(vm); +- return NULL; +- } ++ if (virDomainMigrateBegin3ParamsEnsureACL(domain->conn, vm->def) < 0) ++ goto cleanup; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); +- virObjectUnlock(vm); +- return NULL; ++ goto cleanup; + } + +- return libxlDomainMigrationBegin(domain->conn, vm, xmlin, +- cookieout, cookieoutlen); ++ xmlout = libxlDomainMigrationBegin(domain->conn, vm, xmlin, ++ cookieout, cookieoutlen); ++ ++ cleanup: ++ virDomainObjEndAPI(&vm); ++ return xmlout; + } + + static int +Index: libvirt-4.1.0/src/libxl/libxl_migration.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_migration.c ++++ libvirt-4.1.0/src/libxl/libxl_migration.c +@@ -443,7 +443,6 @@ libxlDomainMigrationBegin(virConnectPtr + + cleanup: + libxlMigrationCookieFree(mig); +- virDomainObjEndAPI(&vm); + virDomainDefFree(tmpdef); + virObjectUnref(cfg); + return xml; diff --git a/83edaf44-libxl-dont-hardcode-sched-weight.patch b/83edaf44-libxl-dont-hardcode-sched-weight.patch new file mode 100644 index 0000000..7ad636d --- /dev/null +++ b/83edaf44-libxl-dont-hardcode-sched-weight.patch @@ -0,0 +1,265 @@ +commit 83edaf4435f9c2d1fa5afd1dfbb1643b4f564fd1 +Author: Jim Fehlig +Date: Thu Feb 22 11:52:56 2018 -0700 + + libxl: don't hardcode scheduler weight + + Long ago in commit dfa1e1dd53 the scheduler weight was accidentally + hardcoded to 1000. Weight is a setting with no unit since it is + relative to the weight of other domains. If no weight is specified, + libxl defaults to 256. + + Instead of hardcoding the weight to 1000, honor any specified + in . libvirt's notion of shares is synonomous to libxl's + scheduler weight setting. If shares is unspecified, defer default + weight setting to libxl. + + Removing the hardcoded weight required some test fixup. While at it, + add an explicit test for conversion to scheduler weight. + + Signed-off-by: Jim Fehlig + Reviewed-by: John Ferlan + +Index: libvirt-4.1.0/src/libxl/libxl_conf.c +=================================================================== +--- libvirt-4.1.0.orig/src/libxl/libxl_conf.c ++++ libvirt-4.1.0/src/libxl/libxl_conf.c +@@ -366,7 +366,9 @@ libxlMakeDomBuildInfo(virDomainDefPtr de + } + } + +- b_info->sched_params.weight = 1000; ++ if (def->cputune.sharesSpecified) ++ b_info->sched_params.weight = def->cputune.shares; ++ + /* Xen requires the memory sizes to be rounded to 1MiB increments */ + virDomainDefSetMemoryTotal(def, + VIR_ROUND_UP(virDomainDefGetMemoryInitial(def), 1024)); +Index: libvirt-4.1.0/tests/libxlxml2domconfigdata/basic-hvm.json +=================================================================== +--- libvirt-4.1.0.orig/tests/libxlxml2domconfigdata/basic-hvm.json ++++ libvirt-4.1.0/tests/libxlxml2domconfigdata/basic-hvm.json +@@ -19,7 +19,7 @@ + "device_model_version": "qemu_xen", + "device_model": "/bin/true", + "sched_params": { +- "weight": 1000 ++ + }, + "type.hvm": { + "pae": "True", +Index: libvirt-4.1.0/tests/libxlxml2domconfigdata/basic-pv.json +=================================================================== +--- libvirt-4.1.0.orig/tests/libxlxml2domconfigdata/basic-pv.json ++++ libvirt-4.1.0/tests/libxlxml2domconfigdata/basic-pv.json +@@ -15,7 +15,7 @@ + "max_memkb": 524288, + "target_memkb": 524288, + "sched_params": { +- "weight": 1000 ++ + }, + "type.pv": { + "bootloader": "pygrub" +Index: libvirt-4.1.0/tests/libxlxml2domconfigdata/cpu-shares-hvm.json +=================================================================== +--- /dev/null ++++ libvirt-4.1.0/tests/libxlxml2domconfigdata/cpu-shares-hvm.json +@@ -0,0 +1,89 @@ ++{ ++ "c_info": { ++ "type": "hvm", ++ "name": "test-hvm", ++ "uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b" ++ }, ++ "b_info": { ++ "max_vcpus": 4, ++ "avail_vcpus": [ ++ 0, ++ 1, ++ 2, ++ 3 ++ ], ++ "max_memkb": 1048576, ++ "target_memkb": 1048576, ++ "video_memkb": 8192, ++ "shadow_memkb": 12288, ++ "device_model_version": "qemu_xen", ++ "device_model": "/bin/true", ++ "sched_params": { ++ "weight": 1500 ++ }, ++ "type.hvm": { ++ "pae": "True", ++ "apic": "True", ++ "acpi": "True", ++ "vga": { ++ "kind": "cirrus" ++ }, ++ "vnc": { ++ "enable": "True", ++ "listen": "0.0.0.0", ++ "findunused": "False" ++ }, ++ "sdl": { ++ "enable": "False" ++ }, ++ "spice": { ++ ++ }, ++ "boot": "c", ++ "rdm": { ++ ++ } ++ }, ++ "arch_arm": { ++ ++ } ++ }, ++ "disks": [ ++ { ++ "pdev_path": "/var/lib/xen/images/test-hvm.img", ++ "vdev": "hda", ++ "backend": "qdisk", ++ "format": "raw", ++ "removable": 1, ++ "readwrite": 1 ++ } ++ ], ++ "nics": [ ++ { ++ "devid": 0, ++ "mac": "00:16:3e:66:12:b4", ++ "bridge": "br0", ++ "script": "/etc/xen/scripts/vif-bridge", ++ "nictype": "vif_ioemu" ++ } ++ ], ++ "vfbs": [ ++ { ++ "devid": -1, ++ "vnc": { ++ "enable": "True", ++ "listen": "0.0.0.0", ++ "findunused": "False" ++ }, ++ "sdl": { ++ "enable": "False" ++ } ++ } ++ ], ++ "vkbs": [ ++ { ++ "devid": -1 ++ } ++ ], ++ "on_reboot": "restart" ++} +Index: libvirt-4.1.0/tests/libxlxml2domconfigdata/cpu-shares-hvm.xml +=================================================================== +--- /dev/null ++++ libvirt-4.1.0/tests/libxlxml2domconfigdata/cpu-shares-hvm.xml +@@ -0,0 +1,39 @@ ++ ++ test-hvm ++ None ++ 2147d599-9cc6-c0dc-92ab-4064b5446e9b ++ 1048576 ++ 1048576 ++ 4 ++ ++ 1500 ++ ++ destroy ++ restart ++ destroy ++ ++ ++ hvm ++ /usr/lib/xen/boot/hvmloader ++ ++ ++ ++ ++ ++ ++ ++ ++ /bin/true ++ ++ ++ ++ ++ ++ ++ ++ ++