From nobody Thu May 2 11:11:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; arc=fail (BodyHash is different from the expected one) Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571089620222593.7529192198389; Mon, 14 Oct 2019 14:47:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2DC65859E; Mon, 14 Oct 2019 21:46:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C71801001B20; Mon, 14 Oct 2019 21:46:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 049F1180085A; Mon, 14 Oct 2019 21:46:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9ELdfT8009678 for ; Mon, 14 Oct 2019 17:39:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDA3D5C219; Mon, 14 Oct 2019 21:39:41 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6E4E5C1D6 for ; Mon, 14 Oct 2019 21:39:39 +0000 (UTC) Received: from m9a0002g.houston.softwaregrp.com (m9a0002g.houston.softwaregrp.com [15.124.64.67]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C912307CDD1 for ; Mon, 14 Oct 2019 21:39:36 +0000 (UTC) Received: FROM m9a0002g.houston.softwaregrp.com (15.121.0.190) BY m9a0002g.houston.softwaregrp.com WITH ESMTP FOR libvir-list@redhat.com; Mon, 14 Oct 2019 21:38:58 +0000 Received: from M9W0068.microfocus.com (2002:f79:bf::f79:bf) by M9W0067.microfocus.com (2002:f79:be::f79:be) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 14 Oct 2019 21:39:34 +0000 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (15.124.72.14) by M9W0068.microfocus.com (15.121.0.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Mon, 14 Oct 2019 21:39:33 +0000 Received: from BY5PR18MB3315.namprd18.prod.outlook.com (10.255.139.204) by BY5PR18MB3155.namprd18.prod.outlook.com (10.255.136.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Mon, 14 Oct 2019 21:39:31 +0000 Received: from BY5PR18MB3315.namprd18.prod.outlook.com ([fe80::3546:b32d:1b4:5b1c]) by BY5PR18MB3315.namprd18.prod.outlook.com ([fe80::3546:b32d:1b4:5b1c%7]) with mapi id 15.20.2347.023; Mon, 14 Oct 2019 21:39:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LqFzNwSaWTVdmoHqNxGmyPyQBAHhLHsXpWJOUow03wi4ZaXO+6G0vA+oZnpK/bfuSbqMv0bpP8YDAibFNGmKbGYalIzB41kqdJR6KSCsds7BNNdyQNe4laG7uKa+Cu8EQraR+uL9cpS+T7aqW/Cd4eV8bZY7L6tmDUpgnxjNDsWXLN7lFXMeZWXCP3QIFz7/V258CYaDP2S07+5GnMXK9aVmrfJDfl2pD/f9JwPBdv4anbOGAn6LiletxgkIArAgMTFbqbJ5q0T72zuDPXiqGXsPXSaN21swIPEwVrT5MwStUJadjBV9j07uX9lj+gumf4oTFLfj/e3aoCmGpWZmEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Md1uFdlUIiJN12nTMoZDpMKdZc1EsmKOg96MW0sxnZM=; b=CgQYtcCWj5dcxHDeFJYVy2jn4R4yXK84+cG1meM+qwjEIshSNplX4n+5jx879WJ6WGVtlRD4pBVn+7N524ZTGk84NeD2Na7IHeodzymUzcbmnjthy4QGFnZLhdaxu5pRDcvzYKAzTddWld2BP6aHbmg0b0gxuMYjAV5SWmI6lvK/HxDnAyQYwTGbfEs95ud5yKQ8iIGlxvmdIRCQq5JtGnhNVWSeLfdpYzHJCzrybzts7tDGZhEz1vu/fA3ej4bIqxOD5TL5awAMsnM8pm9277/54jvosEsTJ9wQ5WxIfYDYk1kzSJqiZXVNnBhdGbYcWL6ys403R+FOjxVcHEpe6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none From: Jim Fehlig To: "libvir-list@redhat.com" Thread-Topic: [PATCH] libxl: Fix lock manager lock ordering Thread-Index: AQHVgtfcv2/utT85lEmwMuz6QUpmFA== Date: Mon, 14 Oct 2019 21:39:30 +0000 Message-ID: <20191014213910.25181-1-jfehlig@suse.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR08CA0009.namprd08.prod.outlook.com (2603:10b6:a03:100::22) To BY5PR18MB3315.namprd18.prod.outlook.com (2603:10b6:a03:196::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jfehlig@suse.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [69.51.74.242] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 887911e8-e27a-4858-a1cb-08d750eefef9 x-ms-traffictypediagnostic: BY5PR18MB3155: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:935; x-forefront-prvs: 01901B3451 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(396003)(136003)(346002)(366004)(376002)(189003)(199004)(478600001)(107886003)(71200400001)(71190400001)(305945005)(6916009)(81166006)(4326008)(36756003)(81156014)(1076003)(6436002)(50226002)(256004)(8676002)(14444005)(102836004)(86362001)(14454004)(5660300002)(476003)(66476007)(66946007)(316002)(6116002)(486006)(3846002)(66446008)(64756008)(66556008)(66066001)(2616005)(6512007)(7736002)(26005)(99286004)(186003)(2501003)(6506007)(386003)(2906002)(5640700003)(8936002)(2351001)(6486002)(25786009)(52116002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY5PR18MB3155; H:BY5PR18MB3315.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; received-spf: None (protection.outlook.com: suse.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PW0n5JHdZ7QuUpWez06pJeMsehTijCNGhT9J9f8Pzd2MjIsS5IpTfeqc1PjwL0JqvyfHWMmFDD/Zje5uU+VcAqDH40HkxIJQNTNejTlBq8UAyvN92R+WuEmQVEzTWY5prek4dbe2zXfYDm+cMFJKv4fuHIaJj1o0l3W9YXoHH4ceFDb6m5tJ4wZ4g40bbKhJf8DlFgkyZLxtwx77sngmJinaHrLh8kw1x2YyE4sEFj94xt6vIiHIG3Q6JbrsG/mHSt2P3CRZwOMh5UAwtvnFuIwNKFaxavbrW0Y9VgZi0luZC+2engxn5bU50R0L78b8dmP/gej4CvDnMflFRT77X2R5rX30HQ+y253541pI8R7N2y7huoMC+eBsY84kPQjNxbwSuW8932zpe5CvchHiAnjXtgQ30pjuSYgxWf3T4dw= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 887911e8-e27a-4858-a1cb-08d750eefef9 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2019 21:39:30.9823 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3XuXAOmn5x8SpiCqr4nj9K7xnBpAfuZLVihVHXq2BgboMLimx3Kwr7PMJq2N1l9LN0L7vjyJx1/VjskYNTz9KA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR18MB3155 X-OriginatorOrg: suse.com X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 14 Oct 2019 21:39:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 14 Oct 2019 21:39:37 +0000 (UTC) for IP:'15.124.64.67' DOMAIN:'m9a0002g.houston.softwaregrp.com' HELO:'m9a0002g.houston.softwaregrp.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: 0.001 (RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY) 15.124.64.67 m9a0002g.houston.softwaregrp.com 15.124.64.67 m9a0002g.houston.softwaregrp.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id x9ELdfT8009678 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] libxl: Fix lock manager lock ordering X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 14 Oct 2019 21:46:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The ordering of lock manager locks in the libxl driver has a flaw that was uncovered by a migration error path. In the perform phase of migration, the source host calls virDomainLockProcessPause to release the lock before sending the VM to the destination host. If the send fails an attempt is made to reacquire the lock with virDomainLockProcessResume, but that too can fail if the destination host has not finished cleaning up the failed VM and releasing the lock it acquired when starting to receive the VM. This change delays calling virDomainLockProcessResume in libxlDomainStart until the VM is successfully created, but before it is unpaused. A similar approach is used by the qemu driver, avoiding the need to release the lock if VM creation fails. In the migration perform phase, releasing the lock with virDomainLockProcessPause is delayed until the VM is successfully sent to the destination, which avoids reacquiring the lock if the send fails. Signed-off-by: Jim Fehlig Reviewed-by: Cole Robinson --- src/libxl/libxl_domain.c | 14 +++++++------- src/libxl/libxl_migration.c | 14 +++++--------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 4073bf8d46..a830a19b99 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1364,13 +1364,6 @@ libxlDomainStart(libxlDriverPrivatePtr driver, NULL) < 0) goto cleanup; =20 - if (virDomainLockProcessResume(driver->lockManager, - "xen:///system", - vm, - priv->lockState) < 0) - goto cleanup; - VIR_FREE(priv->lockState); - if (libxlNetworkPrepareDevices(vm->def) < 0) goto cleanup_dom; =20 @@ -1453,6 +1446,13 @@ libxlDomainStart(libxlDriverPrivatePtr driver, =20 libxlLoggerOpenFile(cfg->logger, domid, vm->def->name, config_json); =20 + if (virDomainLockProcessResume(driver->lockManager, + "xen:///system", + vm, + priv->lockState) < 0) + goto destroy_dom; + VIR_FREE(priv->lockState); + /* Always enable domain death events */ if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->death= W)) goto destroy_dom; diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index a1021d499b..8e64dc5d04 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -1253,20 +1253,16 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivatePt= r driver, sockfd =3D virNetSocketDupFD(sock, true); virObjectUnref(sock); =20 - if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockStat= e) < 0) - VIR_WARN("Unable to release lease on %s", vm->def->name); - VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); - /* suspend vm and send saved data to dst through socket fd */ virObjectUnlock(vm); ret =3D libxlDoMigrateSrcSend(driver, vm, flags, sockfd); virObjectLock(vm); =20 - if (ret < 0) { - virDomainLockProcessResume(driver->lockManager, - "xen:///system", - vm, - priv->lockState); + if (ret =3D=3D 0) { + if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lock= State) < 0) + VIR_WARN("Unable to release lease on %s", vm->def->name); + VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); + } else { /* * Confirm phase will not be executed if perform fails. End the * job started in begin phase. --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list