From nobody Sun Apr 28 07:32:34 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1505742626875688.7296604721954; Mon, 18 Sep 2017 06:50:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82610C0587C6; Mon, 18 Sep 2017 13:50:24 +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 5F5CE5C670; Mon, 18 Sep 2017 13:50:24 +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 1B9751864DC7; Mon, 18 Sep 2017 13:50:24 +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 v8IDlRIk011536 for ; Mon, 18 Sep 2017 09:47:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A5835C3FA; Mon, 18 Sep 2017 13:47:27 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 952DA5C88D for ; Mon, 18 Sep 2017 13:47:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 82610C0587C6 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 18 Sep 2017 15:47:18 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Mark graphics ports used on reconnect 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 18 Sep 2017 13:50:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is an issue that's bugging me for a long time. I don't know exactly when and who is to blame but on daemon reconnect we lose qemu's port allocator internal state. That's okay as we should be able to rebuild it later. However, now I'm seeing port allocator biding successfully to ports that are already taken by qemu (either VNC or Spice). Thus any attempt to start another domain after daemon is restarted fails because libvirt instructs qemu to take port 5900 which is already taken. Now, I don't want to mask the real problem, but one can advocate that we should be marking graphics ports as already in use on qemuProcessReconnect anyway, because we already know that they are taken. Signed-off-by: Michal Privoznik --- src/qemu/qemu_process.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d3155e4e7..053aba1a6 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4035,7 +4035,8 @@ qemuProcessStartHook(virQEMUDriverPtr driver, =20 static int qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver, - virDomainGraphicsDefPtr graphics) + virDomainGraphicsDefPtr graphics, + bool reconnect) { virDomainGraphicsListenDefPtr glisten; =20 @@ -4050,7 +4051,8 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driv= er, =20 switch (graphics->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - if (!graphics->data.vnc.autoport) { + if (!graphics->data.vnc.autoport || + reconnect) { if (virPortAllocatorSetUsed(driver->remotePorts, graphics->data.vnc.port, true) < 0) @@ -4065,7 +4067,7 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driv= er, break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (graphics->data.spice.autoport) + if (graphics->data.spice.autoport && !reconnect) return 0; =20 if (graphics->data.spice.port > 0) { @@ -4269,7 +4271,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (i =3D 0; i < vm->def->ngraphics; i++) { graphics =3D vm->def->graphics[i]; =20 - if (qemuProcessGraphicsReservePorts(driver, graphics) < 0) + if (qemuProcessGraphicsReservePorts(driver, graphics, false) <= 0) goto cleanup; } } @@ -6881,6 +6883,13 @@ qemuProcessReconnect(void *opaque) goto error; } =20 + for (i =3D 0; i < obj->def->ngraphics; i++) { + if (qemuProcessGraphicsReservePorts(driver, + obj->def->graphics[i], + true) < 0) + goto error; + } + if (qemuProcessUpdateState(driver, obj) < 0) goto error; =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list