From nobody Tue May 7 09:33:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594930340; cv=none; d=zohomail.com; s=zohoarc; b=VzlZGFzQAWPdfHb6x9TrjopMhqk7sQlyYRWyohD22yTg2r2ukhtGH45oxWStiThhcubruPid8gU3nzjWAs6rLWwFwe2pWjwk9b703z08VddmmPZx766SK0JbnvnwjdxBkAQHRt+alWNZ1du84hC9fPBZEyQE5eeziyE/feastXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594930340; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UEdGdUnHZfF7evPEBwI1hrFVDY7/RTwDXdYvkX0n4T0=; b=m6YDC3T0IrDtSrmhVZSMmpqRGGZt9x/gSKUelsjbXVcrGH0Wux3rEts/z3uSuBtZzvlscbyAK5VQ6C1NfTL0g2EFecAqCYVP//m8uIN7bi/HhI4d9aB0xC6zN7lsPT+I7SqWAhOQs/VgA7ZSk8RcENER1AKha1ogVRNI68AXi6k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 159493034086458.73536210517966; Thu, 16 Jul 2020 13:12:20 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-171-9o7bixGNP7y4gC6t5_xYHw-1; Thu, 16 Jul 2020 16:12:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F5D810059AA; Thu, 16 Jul 2020 20:12:12 +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 E410772AE0; Thu, 16 Jul 2020 20:12:11 +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 58A2F1809554; Thu, 16 Jul 2020 20:12:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06GK97fb009554 for ; Thu, 16 Jul 2020 16:09:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A59B19D7B; Thu, 16 Jul 2020 20:09:07 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B24919D7D for ; Thu, 16 Jul 2020 20:09:04 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id CC2C52406B8; Thu, 16 Jul 2020 22:09:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594930339; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UEdGdUnHZfF7evPEBwI1hrFVDY7/RTwDXdYvkX0n4T0=; b=YgE62bS50GPiyAyS+oAG0/d5kDj6xILSpgu4WbPHMiahIx+IfmdOWi/2foUFpCbmrpRZ2B /4VY/MZf2DbboGgxeD0ZwdUHfd1lZnjW8RAMSXyIA0DOz/5cY2BFgoz64owlxJ3uSoMdwZ 2+u3le8ewIZYL3rear+gPmwPlTlv1G0= X-MC-Unique: 9o7bixGNP7y4gC6t5_xYHw-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 1/3] qemu_monitor: Add API for checking CPU migratable property Date: Thu, 16 Jul 2020 22:08:46 +0200 Message-Id: <19e8b0318698e58fbf8e0e1fd3020c914e3e1d8a.1594930068.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Mark Mielke 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_monitor.c | 18 ++++++++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ 4 files changed, 53 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 2c66397f8b..637361d24d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4526,6 +4526,24 @@ qemuMonitorGetJobInfo(qemuMonitorPtr mon, } =20 =20 +/* qemuMonitorGetCPUMigratable: + * + * Get the migratable property of the CPU object. + * + * Returns -1 on error, + * 1 when the property is not supported, + * 0 on success (@migratable is set accordingly). + */ +int +qemuMonitorGetCPUMigratable(qemuMonitorPtr mon, + bool *migratable) +{ + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetCPUMigratable(mon, migratable); +} + + int qemuMonitorTransactionBitmapAdd(virJSONValuePtr actions, const char *node, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 50a337715d..1c1b0c9b89 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1377,6 +1377,10 @@ int qemuMonitorGetJobInfo(qemuMonitorPtr mon, qemuMonitorJobInfoPtr **jobs, size_t *njobs); =20 +int +qemuMonitorGetCPUMigratable(qemuMonitorPtr mon, + bool *migratable); + int qemuMonitorTransactionBitmapAdd(virJSONValuePtr actions, const char *node, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index d808c4b55b..83f169e31b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9388,3 +9388,30 @@ qemuMonitorJSONGetJobInfo(qemuMonitorPtr mon, =20 return 0; } + + +int +qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, + bool *migratable) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-get", + "s:path", QOM_CPU_PATH, + "s:property", "migratable", + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONHasError(reply, "GenericError")) + return 1; + + if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_BOOLEAN) < 0) + return -1; + + return virJSONValueGetBoolean(virJSONValueObjectGet(reply, "return"), + migratable); +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 83c5e25ca5..84fea25983 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -690,3 +690,7 @@ int qemuMonitorJSONSetDBusVMStateIdList(qemuMonitorPtr = mon, const char *vmstatepath, const char **list) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); + +int +qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, + bool *migratable); --=20 2.27.0 From nobody Tue May 7 09:33:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594930244; cv=none; d=zohomail.com; s=zohoarc; b=Mhu9kNlsPuYK69RCvZjWBeBx0Wist71kZ3Pr9oHmYFAyEDZi32Dii4sOQjfvmMYqCc3QNle/d64x6MKYbtxvHGXDo3NnzNLPdlLuzViHyK781ZwzBDXfk6mSYu1hZ3D5g7IPHTrcRAR2OedjyObLz6nlUDlJp7iiQ0FnDrM6uDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594930244; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ae32HqL1NCTlWbdtVH+KZ0W9B2RMAEd7UpRqIbsyzZk=; b=hjPnvwqMjPokAYvBwaC1pCj7mgjcTIVTwjjkKEeUIbklL02jnjS/xz8d7igd7TOzmx2YQEEEKhilZ97Gfi9JDR5yYsJHaaOw60NEN0oRehPRn+CcHW/UK7+q8LkKhSvibbuxiqTzpJC0Re658M4gRjCx1hBTmlMMhM3snaeanas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594930244691986.8447892918584; Thu, 16 Jul 2020 13:10:44 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-511-V6RgZuYJOb-Os0Gmdd2g2A-1; Thu, 16 Jul 2020 16:10:41 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D49F7107ACCA; Thu, 16 Jul 2020 20:10:34 +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 B941D5C1D3; Thu, 16 Jul 2020 20:10:33 +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 A62FE1809554; Thu, 16 Jul 2020 20:10:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06GK97Hr009553 for ; Thu, 16 Jul 2020 16:09:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A9B219D82; Thu, 16 Jul 2020 20:09:07 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B8F819D7F for ; Thu, 16 Jul 2020 20:09:04 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id CE2602406BC; Thu, 16 Jul 2020 22:09:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594930243; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ae32HqL1NCTlWbdtVH+KZ0W9B2RMAEd7UpRqIbsyzZk=; b=Ck5lp0hpq78V4KgoUrS9/QWBRl7WEeja0xuZR7oMR0blmx/ECYUT8CbhezZe97kH2+AJAV 07hraI85K6/IOiMCGoXgDMf5qPPeCh4dc1ZZ+6Y5iozDU3BrZr6saOKi4l4iSNJYNyCLfs sTSznTPjlaBBkX5aHL3VGLjcugPKRYQ= X-MC-Unique: V6RgZuYJOb-Os0Gmdd2g2A-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] qemu: Do not set //cpu/@migratable for running domains in post-parse Date: Thu, 16 Jul 2020 22:08:47 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Mark Mielke 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Commit v6.4.0-61-g201bd5db63 started to fill the default value for //cpu/@migratable attribute according to QEMU support. However, active domains either have the migratable attribute already set or the capabilities we use for checking the QEMU support were created by older libvirt which didn't probe for this specific capability. Thus we should leave active domains alone when parsing their XMLs. https://bugzilla.redhat.com/show_bug.cgi?id=3D1857967 Reported-by: Mark Mielke Signed-off-by: Jiri Denemark Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4a2daffc0a..2c944ce051 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3986,9 +3986,13 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def, } } =20 - if (qemuCaps && + /* Running domains were either started before QEMU_CAPS_CPU_MIGRATABLE= was + * introduced and thus we can't rely on it or they already have the + * migratable default set. */ + if (def->id =3D=3D -1 && + qemuCaps && def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH && - !def->cpu->migratable) { + def->cpu->migratable =3D=3D VIR_TRISTATE_SWITCH_ABSENT) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_MIGRATABLE)) def->cpu->migratable =3D VIR_TRISTATE_SWITCH_ON; else if (ARCH_IS_X86(def->os.arch)) --=20 2.27.0 From nobody Tue May 7 09:33:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594930349; cv=none; d=zohomail.com; s=zohoarc; b=EGMnkl0mBS7qIJ5FWMzJrkEIOA4QKbhXFFEUrsB/oXtOLydL2AD9RGRDYwgW50oO5vDad/O1TEcp5NKDkeBgDydSv9rbHGwmqBknkwBCXGAQzZ5h1lf8EMjorxDmrEbRL13vKPdBI8pIdKDmcQoshRnPVojs2v11dA4Fq1KQ5ys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594930349; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rBsaPXJdspF5vy/ZO3bZFHiAmQxnOhLmnmMbeEudXD8=; b=izp6tsXQ+cKeXy163VX0g5thIbZWfpRSuT/hWeeQmVN8V555ZLRDHTz5tVn/H4MIo+F2UcMj0LEut0Kk2okL9VYFf15DJ8aZrU0gGQw0ihhaZ6MAK5M/GjeHc35OzD6HGkJ5EhsMkowxgpCkDJqt0BHn4v9I0tVW7ZPBebKKoao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594930349324541.9034205871872; Thu, 16 Jul 2020 13:12:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-T7P5FlNNOF690wcwZW_ebQ-1; Thu, 16 Jul 2020 16:12:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89D978064AA; Thu, 16 Jul 2020 20:12:16 +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 6B84B72ADF; Thu, 16 Jul 2020 20:12:16 +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 3D0D51809561; Thu, 16 Jul 2020 20:12:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06GK98bK009571 for ; Thu, 16 Jul 2020 16:09:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id E59341024889; Thu, 16 Jul 2020 20:09:08 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6F2B101E58A for ; Thu, 16 Jul 2020 20:09:04 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D165F2406BE; Thu, 16 Jul 2020 22:09:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594930348; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rBsaPXJdspF5vy/ZO3bZFHiAmQxnOhLmnmMbeEudXD8=; b=AK7ulZoFsLmobNGW3KmdXZj288JbT0YAWGDIraoyCO5a792wWd9wjgOZFdcBNH0PsZuLrZ sREe1haXrYGn3pmSoXlxzTF220opCB90cf6bttMyZpmXgtql9lp4OHXPSetiYGRClblphb s0E7yU4+xLja2n+xa18FrPtfrwCGcHI= X-MC-Unique: T7P5FlNNOF690wcwZW_ebQ-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 3/3] qemu: Properly set //cpu/@migratable default value for running domains Date: Thu, 16 Jul 2020 22:08:49 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Mark Mielke 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since active domains which do not have the attribute already set were not started by libvirt that probed for CPU migratable property, we need to check this property on reconnect and update the domain definition accordingly. https://bugzilla.redhat.com/show_bug.cgi?id=3D1857967 Reported-by: Mark Mielke Signed-off-by: Jiri Denemark Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_process.c | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 70fc24b993..d5ac8af37e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7755,6 +7755,52 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver, } =20 =20 +static int +qemuProcessRefreshCPUMigratability(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virDomainDefPtr def =3D vm->def; + bool migratable; + int rc; + + if (def->cpu->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH) + return 0; + + /* If the cpu.migratable capability is present, the migratable attribu= te + * is set correctly. */ + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CPU_MIGRATABLE)) + return 0; + + if (!ARCH_IS_X86(def->os.arch)) + return 0; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + rc =3D qemuMonitorGetCPUMigratable(priv->mon, &migratable); + + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + return -1; + + if (rc =3D=3D 1) + migratable =3D false; + + /* Libvirt 6.5.0 would set migratable=3D'off' for running domains even= though + * the actual default used by QEMU was 'on'. */ + if (def->cpu->migratable =3D=3D VIR_TRISTATE_SWITCH_OFF && migratable)= { + VIR_DEBUG("Fixing CPU migratable attribute"); + def->cpu->migratable =3D VIR_TRISTATE_SWITCH_ON; + } + + if (def->cpu->migratable =3D=3D VIR_TRISTATE_SWITCH_ABSENT) + def->cpu->migratable =3D virTristateSwitchFromBool(migratable); + + return 0; +} + + static int qemuProcessRefreshCPU(virQEMUDriverPtr driver, virDomainObjPtr vm) @@ -7770,6 +7816,9 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver, if (!vm->def->cpu) return 0; =20 + if (qemuProcessRefreshCPUMigratability(driver, vm, QEMU_ASYNC_JOB_NONE= ) < 0) + return -1; + if (!(host =3D virQEMUDriverGetHostCPU(driver))) { virResetLastError(); return 0; --=20 2.27.0