提交 c62e79c8 编写于 作者: N Nikolay Shirokovskiy 提交者: John Ferlan

qemu: Filter cur_balloon ABI check for certain transactions

Since the domain lock is not held during preparation of an external XML
config, it is possible that the value can change resulting in unexpected
failures during ABI consistency checking for some save and migrate
operations.

This patch adds a new flag to skip the checking of the cur_balloon value
and then sets the destination value to the source value to ensure
subsequent checks without the skip flag will succeed.

This way it is protected from forges and is keeped up to date too.
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 90e9817e
......@@ -18775,8 +18775,9 @@ virDomainDefVcpuCheckAbiStability(virDomainDefPtr src,
* validation of custom XML config passed in during migration
*/
bool
virDomainDefCheckABIStability(virDomainDefPtr src,
virDomainDefPtr dst)
virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
virDomainDefPtr dst,
unsigned int flags)
{
size_t i;
virErrorPtr err;
......@@ -18820,7 +18821,8 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
virDomainDefGetMemoryInitial(src));
goto error;
}
if (src->mem.cur_balloon != dst->mem.cur_balloon) {
if (!(flags & VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE) &&
src->mem.cur_balloon != dst->mem.cur_balloon) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain current memory %lld does not match source %lld"),
dst->mem.cur_balloon, src->mem.cur_balloon);
......@@ -19264,6 +19266,14 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
}
bool
virDomainDefCheckABIStability(virDomainDefPtr src,
virDomainDefPtr dst)
{
return virDomainDefCheckABIStabilityFlags(src, dst, 0);
}
static int
virDomainDefAddDiskControllersForType(virDomainDefPtr def,
int controllerType,
......
......@@ -2644,6 +2644,15 @@ typedef enum {
VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST = 1 << 9,
} virDomainDefFormatFlags;
/* Use these flags to skip specific domain ABI consistency checks done
* in virDomainDefCheckABIStabilityFlags.
*/
typedef enum {
/* Set when domain lock must be released and there exists the possibility
* that some external action could alter the value, such as cur_balloon. */
VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE = 1 << 0,
} virDomainDefABICheckFlags;
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
const virDomainDef *def,
virCapsPtr caps,
......@@ -2679,6 +2688,10 @@ virDomainObjPtr virDomainObjParseFile(const char *filename,
bool virDomainDefCheckABIStability(virDomainDefPtr src,
virDomainDefPtr dst);
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
virDomainDefPtr dst,
unsigned int flags);
int virDomainDefAddImplicitDevices(virDomainDefPtr def);
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
......
......@@ -219,6 +219,7 @@ virDomainDefAddController;
virDomainDefAddImplicitDevices;
virDomainDefAddUSBController;
virDomainDefCheckABIStability;
virDomainDefCheckABIStabilityFlags;
virDomainDefCompatibleDevice;
virDomainDefCopy;
virDomainDefFindDevice;
......
......@@ -4989,14 +4989,25 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
{
virDomainDefPtr migratableDefSrc = NULL;
virDomainDefPtr migratableDefDst = NULL;
const int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE;
const unsigned int flags = VIR_DOMAIN_XML_SECURE |
VIR_DOMAIN_XML_UPDATE_CPU |
VIR_DOMAIN_XML_MIGRATABLE;
const unsigned int check_flags = VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE;
bool ret = false;
if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) ||
!(migratableDefDst = qemuDomainDefCopy(driver, dst, flags)))
goto cleanup;
ret = virDomainDefCheckABIStability(migratableDefSrc, migratableDefDst);
if (!virDomainDefCheckABIStabilityFlags(migratableDefSrc,
migratableDefDst,
check_flags))
goto cleanup;
/* Force update any skipped values from the volatile flag */
dst->mem.cur_balloon = src->mem.cur_balloon;
ret = true;
cleanup:
virDomainDefFree(migratableDefSrc);
......
......@@ -15279,7 +15279,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
/* Transitions 5, 6, 8, 9 */
/* Check for ABI compatibility. We need to do this check against
* the migratable XML or it will always fail otherwise */
if (config && !qemuDomainDefCheckABIStability(driver, vm->def, config)) {
if (config &&
!qemuDomainDefCheckABIStability(driver, vm->def, config)) {
virErrorPtr err = virGetLastError();
if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册