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
This commit is contained in:
James Fehlig 2018-03-22 00:33:49 +00:00 committed by Git OBS Bridge
parent 535a5085f7
commit 1ea77165a0
17 changed files with 1138 additions and 11 deletions

View File

@ -0,0 +1,25 @@
commit 13e81fc6fad03aa6b6ecf4230f44b2ea55078229
Author: Jim Fehlig <jfehlig@suse.com>
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 <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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;
}

View File

@ -0,0 +1,132 @@
commit 3c89868c5fef3d0cfbc40d0185447d13a6242620
Author: Jim Fehlig <jfehlig@suse.com>
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 <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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)

View File

@ -0,0 +1,269 @@
commit 4e6fcdb6fa838d57a278dacd21bc6932edabec67
Author: John Ferlan <jferlan@redhat.com>
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 <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
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;
}

View File

@ -0,0 +1,43 @@
commit 594b8b996c83724d6b1c73641daf277307afe5f7
Author: Jim Fehlig <jfehlig@suse.com>
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 <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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);

View File

@ -0,0 +1,74 @@
commit 60b3fcd90cbd83e5721484d72414dfee1706dab8
Author: Jim Fehlig <jfehlig@suse.com>
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 <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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;
}

View File

@ -0,0 +1,82 @@
commit 64370c4b81f04ca73c195854966c6740e01483f2
Author: Jim Fehlig <jfehlig@suse.com>
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 <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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;

View File

@ -0,0 +1,265 @@
commit 83edaf4435f9c2d1fa5afd1dfbb1643b4f564fd1
Author: Jim Fehlig <jfehlig@suse.com>
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 <shares> specified
in <cputune>. 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 <shares> conversion to scheduler weight.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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 @@
+<domain type='xen'>
+ <name>test-hvm</name>
+ <description>None</description>
+ <uuid>2147d599-9cc6-c0dc-92ab-4064b5446e9b</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>4</vcpu>
+ <cputune>
+ <shares>1500</shares>
+ </cputune>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <clock offset='utc'/>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <apic/>
+ <acpi/>
+ <pae/>
+ </features>
+ <devices>
+ <emulator>/bin/true</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu'/>
+ <source file='/var/lib/xen/images/test-hvm.img'/>
+ <target dev='hda'/>
+ </disk>
+ <interface type='bridge'>
+ <source bridge='br0'/>
+ <mac address='00:16:3e:66:12:b4'/>
+ <script path='/etc/xen/scripts/vif-bridge'/>
+ </interface>
+ <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
+ </devices>
+</domain>
Index: libvirt-4.1.0/tests/libxlxml2domconfigdata/moredevs-hvm.json
===================================================================
--- libvirt-4.1.0.orig/tests/libxlxml2domconfigdata/moredevs-hvm.json
+++ libvirt-4.1.0/tests/libxlxml2domconfigdata/moredevs-hvm.json
@@ -21,7 +21,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/multiple-ip.json
===================================================================
--- libvirt-4.1.0.orig/tests/libxlxml2domconfigdata/multiple-ip.json
+++ libvirt-4.1.0/tests/libxlxml2domconfigdata/multiple-ip.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/variable-clock-hvm.json
===================================================================
--- libvirt-4.1.0.orig/tests/libxlxml2domconfigdata/variable-clock-hvm.json
+++ libvirt-4.1.0/tests/libxlxml2domconfigdata/variable-clock-hvm.json
@@ -21,7 +21,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/vnuma-hvm.json
===================================================================
--- libvirt-4.1.0.orig/tests/libxlxml2domconfigdata/vnuma-hvm.json
+++ libvirt-4.1.0/tests/libxlxml2domconfigdata/vnuma-hvm.json
@@ -107,7 +107,7 @@
"device_model_version": "qemu_xen",
"device_model": "/bin/true",
"sched_params": {
- "weight": 1000
+
},
"type.hvm": {
"pae": "True",
Index: libvirt-4.1.0/tests/libxlxml2domconfigtest.c
===================================================================
--- libvirt-4.1.0.orig/tests/libxlxml2domconfigtest.c
+++ libvirt-4.1.0/tests/libxlxml2domconfigtest.c
@@ -192,6 +192,7 @@ mymain(void)
DO_TEST("basic-pv");
DO_TEST("basic-hvm");
+ DO_TEST("cpu-shares-hvm");
DO_TEST("variable-clock-hvm");
DO_TEST("moredevs-hvm");
DO_TEST("vnuma-hvm");

View File

@ -0,0 +1,75 @@
commit 99486799c3f911caa009d64889fc05ec3b07f986
Author: Jim Fehlig <jfehlig@suse.com>
Date: Mon Mar 12 12:22:34 2018 -0600
libxl: MigrateConfirm: Dont unlock virDomainObj in helper function
The libxlDomainMigrateConfirm3Params API locks and ref counts the associated
virDomainObj but relies on the helper function libxlDomainMigrationConfirm
to unlock the object. Unref'ing the object is not done in either function.
libxlDomainMigrationConfirm 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.
Remove the unlock from libxlDomainMigrationConfirm and adjust
libxlDomainMigrateConfirm3Params to properly unref/unlock the virDomainObj
on success and error paths.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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
@@ -6161,6 +6161,7 @@ libxlDomainMigrateConfirm3Params(virDoma
{
libxlDriverPrivatePtr driver = domain->conn->privateData;
virDomainObjPtr vm = NULL;
+ int ret = -1;
#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
virReportUnsupportedError();
@@ -6174,12 +6175,14 @@ libxlDomainMigrateConfirm3Params(virDoma
if (!(vm = libxlDomObjFromDomain(domain)))
return -1;
- if (virDomainMigrateConfirm3ParamsEnsureACL(domain->conn, vm->def) < 0) {
- virObjectUnlock(vm);
- return -1;
- }
+ if (virDomainMigrateConfirm3ParamsEnsureACL(domain->conn, vm->def) < 0)
+ goto cleanup;
+
+ ret = libxlDomainMigrationConfirm(driver, vm, flags, cancelled);
- return libxlDomainMigrationConfirm(driver, vm, flags, cancelled);
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
}
static int libxlNodeGetSecurityModel(virConnectPtr conn,
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
@@ -1392,7 +1392,8 @@ libxlDomainMigrationConfirm(libxlDriverP
if (!vm->persistent || (flags & VIR_MIGRATE_UNDEFINE_SOURCE)) {
virDomainObjListRemove(driver->domains, vm);
- vm = NULL;
+ /* Caller passed a locked vm and expects the same on return */
+ virObjectLock(vm);
}
ret = 0;
@@ -1400,8 +1401,6 @@ libxlDomainMigrationConfirm(libxlDriverP
cleanup:
if (event)
libxlDomainEventQueue(driver, event);
- if (vm)
- virObjectUnlock(vm);
virObjectUnref(cfg);
return ret;
}

View File

@ -0,0 +1,30 @@
commit c66e344e38269227c93e598f599108a65b066fc0
Author: Jim Fehlig <jfehlig@suse.com>
Date: Fri Mar 16 15:00:17 2018 -0600
libxl: dont dereference NULL libxlDomainObjPrivatePtr
In libxlDomainMigrationPrepare it is possible to dereference a NULL
libxlDomainObjPrivatePtr in early error paths. Check for a valid
'priv' before using it.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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
@@ -804,8 +804,10 @@ libxlDomainMigrationPrepare(virConnectPt
}
VIR_FREE(socks);
virObjectUnref(args);
- virPortAllocatorRelease(priv->migrationPort);
- priv->migrationPort = 0;
+ if (priv) {
+ virPortAllocatorRelease(priv->migrationPort);
+ priv->migrationPort = 0;
+ }
/* Remove virDomainObj from domain list */
if (vm) {

View File

@ -0,0 +1,27 @@
commit f5eacf2a9ad2b7ba07dd0fc745c098cd2d26b6ee
Author: Jim Fehlig <jfehlig@suse.com>
Date: Tue Mar 13 11:05:36 2018 -0600
libxl: MigratePerform: properly cleanup after libxlDomObjFromDomain
libxlDomObjFromDomain to returns locked and ref counted virDomainObj but
libxlDomainMigratePerform3Params only unlocks the object on exit. Convert
it to use the virDomainObjEndAPI function for cleanup.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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
@@ -6086,8 +6086,7 @@ libxlDomainMigratePerform3Params(virDoma
ret = 0;
cleanup:
- if (vm)
- virObjectUnlock(vm);
+ virDomainObjEndAPI(&vm);
return ret;
}

View File

@ -0,0 +1,60 @@
commit fe51dbda56b5e51e17b238210a19e3c9887a3f15
Author: John Ferlan <jferlan@redhat.com>
Date: Fri Mar 9 11:48:00 2018 -0500
libxl: Use virDomainObjListFindBy{UUID|ID}Ref
For libxlDomainLookupByID and libxlDomainLookupByUUID let's
return a locked and referenced @vm object so that callers can
then use the common and more consistent virDomainObjEndAPI in
order to handle cleanup rather than needing to know that the
returned object is locked and calling virObjectUnlock.
The LookupByName already returns the ref counted and locked object,
so this will make things more consistent.
Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
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
@@ -1090,7 +1090,7 @@ libxlDomainLookupByID(virConnectPtr conn
virDomainObjPtr vm;
virDomainPtr dom = NULL;
- vm = virDomainObjListFindByID(driver->domains, id);
+ vm = virDomainObjListFindByIDRef(driver->domains, id);
if (!vm) {
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
@@ -1102,8 +1102,7 @@ libxlDomainLookupByID(virConnectPtr conn
dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
cleanup:
- if (vm)
- virObjectUnlock(vm);
+ virDomainObjEndAPI(&vm);
return dom;
}
@@ -1114,7 +1113,7 @@ libxlDomainLookupByUUID(virConnectPtr co
virDomainObjPtr vm;
virDomainPtr dom = NULL;
- vm = virDomainObjListFindByUUID(driver->domains, uuid);
+ vm = virDomainObjListFindByUUIDRef(driver->domains, uuid);
if (!vm) {
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
@@ -1126,8 +1125,7 @@ libxlDomainLookupByUUID(virConnectPtr co
dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
cleanup:
- if (vm)
- virObjectUnlock(vm);
+ virDomainObjEndAPI(&vm);
return dom;
}

View File

@ -1,3 +1,26 @@
-------------------------------------------------------------------
Wed Mar 21 22:43:28 UTC 2018 - jfehlig@suse.com
- libxl: don't hardcode scheduler weight
83edaf44-libxl-dont-hardcode-sched-weight.patch
bsc#1086377
-------------------------------------------------------------------
Tue Mar 20 20:20:18 UTC 2018 - jfehlig@suse.com
- 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
-------------------------------------------------------------------
Thu Mar 15 15:44:28 UTC 2018 - jfehlig@suse.com

View File

@ -334,6 +334,17 @@ Patch5: 86cae503-rpc-fix-pre-exec.patch
Patch6: eefabb38-rpc-virtlockd-virtlogd-single-thread.patch
Patch7: fbf31e1a-CVE-2018-1064.patch
Patch8: fb327ac2-virtlockd-admin-socket.patch
Patch9: 64370c4b-libxl-MigrateBegin.patch
Patch10: 99486799-libxl-MigrateConfirm.patch
Patch11: f5eacf2a-libxl-MigratePerform.patch
Patch12: 4e6fcdb6-libxl-libxlDomObjFromDomain-cleanup.patch
Patch13: fe51dbda-libxl-use-FindByRef.patch
Patch14: 60b3fcd9-libxl-MigratePrepare.patch
Patch15: 3c89868c-libxl-lock-after-ListRemove.patch
Patch16: 13e81fc6-libxl-EndJob-on-error.patch
Patch17: 594b8b99-libxl-DefineXMLFlags-API-pattern.patch
Patch18: c66e344e-libxl-dont-deref-NULL.patch
Patch19: 83edaf44-libxl-dont-hardcode-sched-weight.patch
# Patches pending upstream review
Patch100: libxl-dom-reset.patch
Patch101: network-don-t-use-dhcp-authoritative-on-static-netwo.patch
@ -948,6 +959,17 @@ popd
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch100 -p1
%patch101 -p1
%patch150 -p1

View File

@ -12,7 +12,7 @@ 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
@@ -1380,6 +1380,61 @@ libxlDomainReboot(virDomainPtr dom, unsi
@@ -1375,6 +1375,61 @@ libxlDomainReboot(virDomainPtr dom, unsi
}
static int
@ -74,7 +74,7 @@ Index: libvirt-4.1.0/src/libxl/libxl_driver.c
libxlDomainDestroyFlags(virDomainPtr dom,
unsigned int flags)
{
@@ -6496,6 +6551,7 @@ static virHypervisorDriver libxlHypervis
@@ -6476,6 +6531,7 @@ static virHypervisorDriver libxlHypervis
.domainShutdown = libxlDomainShutdown, /* 0.9.0 */
.domainShutdownFlags = libxlDomainShutdownFlags, /* 0.9.10 */
.domainReboot = libxlDomainReboot, /* 0.9.0 */

View File

@ -7,7 +7,7 @@ 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
@@ -769,6 +769,30 @@ libxlDiskSetDiscard(libxl_device_disk *x
@@ -771,6 +771,30 @@ libxlDiskSetDiscard(libxl_device_disk *x
#endif
}
@ -38,7 +38,7 @@ Index: libvirt-4.1.0/src/libxl/libxl_conf.c
static char *
libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src,
const char *username,
@@ -1017,6 +1041,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk
@@ -1019,6 +1043,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
if (libxlDiskSetDiscard(x_disk, l_disk->discard) < 0)
return -1;

View File

@ -56,7 +56,7 @@ 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
@@ -6098,6 +6098,9 @@ libxlDomainMigratePerform3Params(virDoma
@@ -6076,6 +6076,9 @@ libxlDomainMigratePerform3Params(virDoma
const char *dname = NULL;
const char *uri = NULL;
int ret = -1;
@ -66,7 +66,7 @@ Index: libvirt-4.1.0/src/libxl/libxl_driver.c
#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
virReportUnsupportedError();
@@ -6114,6 +6117,18 @@ libxlDomainMigratePerform3Params(virDoma
@@ -6092,6 +6095,18 @@ libxlDomainMigratePerform3Params(virDoma
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_DEST_NAME,
&dname) < 0 ||
@ -85,7 +85,7 @@ Index: libvirt-4.1.0/src/libxl/libxl_driver.c
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_URI,
&uri) < 0)
@@ -6128,11 +6143,11 @@ libxlDomainMigratePerform3Params(virDoma
@@ -6106,11 +6121,11 @@ libxlDomainMigratePerform3Params(virDoma
if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
if (libxlDomainMigrationPerformP2P(driver, vm, dom->conn, dom_xml,

View File

@ -11,7 +11,7 @@ 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
@@ -769,6 +769,25 @@ libxlDiskSetDiscard(libxl_device_disk *x
@@ -771,6 +771,25 @@ libxlDiskSetDiscard(libxl_device_disk *x
#endif
}
@ -37,7 +37,7 @@ Index: libvirt-4.1.0/src/libxl/libxl_conf.c
static void
libxlDiskSetCacheMode(libxl_device_disk *x_disk, int cachemode)
{
@@ -914,6 +933,7 @@ libxlMakeNetworkDiskSrc(virStorageSource
@@ -916,6 +935,7 @@ libxlMakeNetworkDiskSrc(virStorageSource
int
libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
{
@ -45,7 +45,7 @@ Index: libvirt-4.1.0/src/libxl/libxl_conf.c
const char *driver = virDomainDiskGetDriver(l_disk);
int format = virDomainDiskGetFormat(l_disk);
int actual_type = virStorageSourceGetActualType(l_disk->src);
@@ -929,7 +949,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk
@@ -931,7 +951,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk
if (libxlMakeNetworkDiskSrc(l_disk->src, &x_disk->pdev_path) < 0)
return -1;
} else {
@ -54,7 +54,7 @@ Index: libvirt-4.1.0/src/libxl/libxl_conf.c
return -1;
}
@@ -1042,6 +1062,9 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk
@@ -1044,6 +1064,9 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk
if (libxlDiskSetDiscard(x_disk, l_disk->discard) < 0)
return -1;
libxlDiskSetCacheMode(x_disk, l_disk->cachemode);