From nobody Fri May 17 07:55:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1618328326; cv=none; d=zohomail.com; s=zohoarc; b=AglA0PhqEVvnVJSL4vsjTWMh089aCkcfHM8ya4jyEoqD/enhvaGKOU7hIx6WcgTDIzjieRdQhXOgu+YMvumzuzwNGLpOPQANRjdl5UO61GQQ6UsBnmd6RUUIGyF6ofLwt9Egt0xrM8AFGHYcMZgu24UF69NB7B+DAhd60R2Uh0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618328326; h=Content-Type:Content-Transfer-Encoding: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=t/h4n+r3BxDyaLXLUbFUyroCQY2kMvMg4kWl66xGwho=; b=k8xOxUHKQHT3BPJ3v6w4rH9dunpWleVuQmGEypXzG281jlRFCHJu42AaskSMeXKcPVB3UB3vO/iR2QOa4DgDyVwnohy29t5i7xrJa4hxuXqTOD8IRyoh+/j0J7gtJ7X4dXMeIHLHzWZl5wan09JSYmxZCTDK3Y0rNv1jbvaX4FU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618328326816222.22683714730965; Tue, 13 Apr 2021 08:38:46 -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-231-Nkl9-Z67OjW3E7km2VMv5g-1; Tue, 13 Apr 2021 11:38:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CBA3E835B47; Tue, 13 Apr 2021 15:38:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A23F55D9CA; Tue, 13 Apr 2021 15:38:35 +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 09CF544A5B; Tue, 13 Apr 2021 15:38:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DFcYMX012886 for ; Tue, 13 Apr 2021 11:38:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 71CBD2B0AB; Tue, 13 Apr 2021 15:38:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB6F560DA0 for ; Tue, 13 Apr 2021 15:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618328325; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=t/h4n+r3BxDyaLXLUbFUyroCQY2kMvMg4kWl66xGwho=; b=h7zOPKPbToQRAvTXl2VDMbhGr6XhrN04BLpxRpAwMmrj1CTYZXn7b3ReaMP7YaQUvwsYpk JpAr66VBVI1SCDDArT+tWL2ie4kJ0R8ehR98IC0Y47A0K/Dpl4+KtG8bo5ZbI61t3IZbrT iNtE26GSYKPf6za7E/A9xNgkROxDL70= X-MC-Unique: Nkl9-Z67OjW3E7km2VMv5g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 1/7] util: xml: Introduce virXMLFormatElementEmpty Date: Tue, 13 Apr 2021 17:38:21 +0200 Message-Id: <338ef258418f23c61092a7506a78511251982a53.1618328187.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Add a helper which will format an XML element with attributes and children, but compared to virXMLFormatElement it also formats an empty element if both buffers are empty. Signed-off-by: Peter Krempa Reviewed-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virxml.c | 42 ++++++++++++++++++++++++++-------------- src/util/virxml.h | 7 +++++++ 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b3f9c9681a..64002de39a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3541,6 +3541,7 @@ virXMLBufferCreate; virXMLCheckIllegalChars; virXMLExtractNamespaceXML; virXMLFormatElement; +virXMLFormatElementEmpty; virXMLNewNode; virXMLNodeContentString; virXMLNodeNameEqual; diff --git a/src/util/virxml.c b/src/util/virxml.c index 117f50f2bf..c2a49cbef2 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1314,6 +1314,32 @@ virXMLValidatorFree(virXMLValidator *validator) } +/* same as virXMLFormatElement but outputs an empty element if @attrBuf and + * @childBuf are both empty */ +void +virXMLFormatElementEmpty(virBuffer *buf, + const char *name, + virBuffer *attrBuf, + virBuffer *childBuf) +{ + virBufferAsprintf(buf, "<%s", name); + + if (attrBuf && virBufferUse(attrBuf) > 0) + virBufferAddBuffer(buf, attrBuf); + + if (childBuf && virBufferUse(childBuf) > 0) { + virBufferAddLit(buf, ">\n"); + virBufferAddBuffer(buf, childBuf); + virBufferAsprintf(buf, "\n", name); + } else { + virBufferAddLit(buf, "/>\n"); + } + + virBufferFreeAndReset(attrBuf); + virBufferFreeAndReset(childBuf); +} + + /** * virXMLFormatElement * @buf: the parent buffer where the element will be placed @@ -1338,21 +1364,7 @@ virXMLFormatElement(virBuffer *buf, (!childBuf || virBufferUse(childBuf) =3D=3D 0)) return; - virBufferAsprintf(buf, "<%s", name); - - if (attrBuf && virBufferUse(attrBuf) > 0) - virBufferAddBuffer(buf, attrBuf); - - if (childBuf && virBufferUse(childBuf) > 0) { - virBufferAddLit(buf, ">\n"); - virBufferAddBuffer(buf, childBuf); - virBufferAsprintf(buf, "\n", name); - } else { - virBufferAddLit(buf, "/>\n"); - } - - virBufferFreeAndReset(attrBuf); - virBufferFreeAndReset(childBuf); + virXMLFormatElementEmpty(buf, name, attrBuf, childBuf); } diff --git a/src/util/virxml.h b/src/util/virxml.h index de171dce12..a81db478f0 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -226,6 +226,13 @@ virXMLFormatElement(virBuffer *buf, virBuffer *attrBuf, virBuffer *childBuf); +void +virXMLFormatElementEmpty(virBuffer *buf, + const char *name, + virBuffer *attrBuf, + virBuffer *childBuf); + + struct _virXPathContextNodeSave { xmlXPathContextPtr ctxt; xmlNodePtr node; --=20 2.30.2 From nobody Fri May 17 07:55:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1618328330; cv=none; d=zohomail.com; s=zohoarc; b=HWyWImtniQXOmwK9EcjxDTA4JPa+YZO7aEp0o5OJi05rJKPLNGYzY6R6OE9uHvJW4vsodvhvZO4pEqFAmkPgl9aDi3z3rvj6PvD5NbGUnxz9LKdebI8puPO2VhIkBFYrSOCzIFDx4z69J9poQeiCV9vRYxA39m4vqhimsh1IyIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618328330; h=Content-Type:Content-Transfer-Encoding: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=II41heZUWkbazAdUB2jZjGMkm7DPV1avZIe/iqe82qQ=; b=mMzExKx5fcWlXQZ2+rYPH+jIKQcbRtQXiLNVcBCT2lqJSOlHj+QFqooAnqJdL/unK1t7xmAOYlrCd/XzI5Au9zvBPs7jNHYc3lfEB8NNPNgU3jTsn1balRA1HjGzJPLEvhe1F9G7rbng4sN2FZ6rtWBceJjal+dx8Y8f0Gj3tM0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618328330452700.2751140393337; Tue, 13 Apr 2021 08:38:50 -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-578-rW9qzLmwOzOk1CYG8xeUOA-1; Tue, 13 Apr 2021 11:38:46 -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 F087C19251A2; Tue, 13 Apr 2021 15:38:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCC305C26D; Tue, 13 Apr 2021 15:38:40 +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 93D4244A62; Tue, 13 Apr 2021 15:38:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DFcZpb012893 for ; Tue, 13 Apr 2021 11:38:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8697A2B0A9; Tue, 13 Apr 2021 15:38:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E410550D15 for ; Tue, 13 Apr 2021 15:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618328328; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=II41heZUWkbazAdUB2jZjGMkm7DPV1avZIe/iqe82qQ=; b=FMJXrlsKBg+D2YQgIG1bt1mLiKdh+kLu8Ox89Zji819vVmIjm4aAu0EKGLpP0QoTsnCxzX SI03DvNyQqTbHi8IUuOdrHd99vnk/CNl+02Bs5FlYBDF6gsuxshzVOuk2uhv6N0q4+0YTh rmsZzoSO3L6RgQP0Chm31mLj/wTkgp0= X-MC-Unique: rW9qzLmwOzOk1CYG8xeUOA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 2/7] qemuMigrationCookieNBDXMLFormat: Format empty element Date: Tue, 13 Apr 2021 17:38:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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 518be41aaa3 refactored qemuMigrationCookieNBDXMLFormat to use virXMLFormatElement which in comparison to the previous code doesn't format the element if it's empty. Unfortunately some crusty bits of our migration code use questionable logic to assert use of the old-style storage migration parameters which breaks if no disks are being migrated and the element is not present. While later patches will fix the code, re-instate formatting of empty for increased compatibility. Signed-off-by: Peter Krempa Reviewed-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 41533e4549..52998ddd1b 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -790,7 +790,7 @@ qemuMigrationCookieNBDXMLFormat(qemuMigrationCookieNBD = *nbd, virBufferAsprintf(&childBuf, " capacity=3D'%llu'/>\n", nbd->disks[= i].capacity); } - virXMLFormatElement(buf, "nbd", &attrBuf, &childBuf); + virXMLFormatElementEmpty(buf, "nbd", &attrBuf, &childBuf); } --=20 2.30.2 From nobody Fri May 17 07:55:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1618328330; cv=none; d=zohomail.com; s=zohoarc; b=SgMemS986tV/xJ6kFmTzTh3BRntagHogUAeBxSdAarVeV20qHliNEeMjvLMws2WCDoO3x9rJTQQgpsUNjveShjaFn2aqqpffGL+PTVwhD6DB65rIh/UFUVdtrRJw/rxSeWhrYtxD6aCircBSTPL6egVOjy+dfd7sgG+zIlqO47E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618328330; h=Content-Type:Content-Transfer-Encoding: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=8p3fsRS5tXAkdd5vLzNqP3EBZ5jivuJ26Ve2OrNj9pY=; b=AiqsEihdDwaseSGwZ+R7xKa9Ae8jIRkplb2B2Hdpudie/s7/ysT5L7l5eKBzCN6v5F7G4/i08aUUQjG2eSnWI9yZy8AesCPaF5L/S0EhjHXasb0wUe8kj7+k7Nie6EyC4sK+dmBdb+CLL3ZjZK8h5GXFxe3S+68/92gyvOScP3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618328330919326.3985119270244; Tue, 13 Apr 2021 08:38:50 -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-15-B77WZdM9NSai8FK-r9iiRA-1; Tue, 13 Apr 2021 11:38:46 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F9D46D24D; Tue, 13 Apr 2021 15:38:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E52BA2B0A9; Tue, 13 Apr 2021 15:38:38 +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 AC7A844A5E; Tue, 13 Apr 2021 15:38:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DFcajh012906 for ; Tue, 13 Apr 2021 11:38:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1167226E2; Tue, 13 Apr 2021 15:38:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF88C226E0 for ; Tue, 13 Apr 2021 15:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618328329; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=8p3fsRS5tXAkdd5vLzNqP3EBZ5jivuJ26Ve2OrNj9pY=; b=EEFCQO0aTyAA5m16IZqmxdLCn7bIg2mOwO65Za+D271pnGR6eTwJ2NyeeaQBEt3JWMUZDw itqhtsI7X4c4XOBMdXpHpP+uW+QZuLIDXT+IWh/C/cz8tlp2YR1b836KoUC286wUONp0Go QYREl/VzEWpBiwj8c+dwDn6VjWG2Dm0= X-MC-Unique: B77WZdM9NSai8FK-r9iiRA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 3/7] qemuMigrationSrcNBDStorageCopy: Return error code on error Date: Tue, 13 Apr 2021 17:38:23 +0200 Message-Id: <5f017bb40059875df9a3913e211eb72e8fbda1d2.1618328187.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" In case the 'nbdURI' schema is not known the code would report an error but wouldn't return failure. Fixes: 49186372dbe Signed-off-by: Peter Krempa Reviewed-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index df88f954ed..1c3e599128 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1154,6 +1154,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriver *driver, virReportError(VIR_ERR_INVALID_ARG, _("Unsupported scheme in disks URI: %s"), uri->scheme); + return -1; } } --=20 2.30.2 From nobody Fri May 17 07:55:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1618328336; cv=none; d=zohomail.com; s=zohoarc; b=OkBlQ6aapPEQSaLOEY4vVWmSCUYBJ1nE7rWku6tc0ffm7dfBJbwyjlEcPnHwLBugF5XAfD0EWt3nSvBsgFSLiXzvJjelMRHODwRKhjQK/vRv8WzBu9JunXsrlm/Dk2FqZqx0hAdmRsywv/BE2MSejKWX8bfuwxcBtAlW8//0NH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618328336; h=Content-Type:Content-Transfer-Encoding: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=2hyrfxJB1cJJhZUAgB2Q5DHsaABeQvxhxkhwj/aNwfQ=; b=YFtBIxonLcJYWus57WRLAcKOG+BFeDJk5mb4XsR5hJEeWN9K/B5+3bFZPk1W6guA8v7wlf3bom5rXLSXzDvV/vDrnBvh9XG7rY1kbUPblZRVxjiW5Scwr6lfrS5UMM+RhAubY84JAFOQjtyT9vZmCJvyCBUceR9p/tl5/b4+CQs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618328336852589.6984736802567; Tue, 13 Apr 2021 08:38:56 -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-540-opdk09NfPquTzWsz76ti3g-1; Tue, 13 Apr 2021 11:38:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2C5A6D252; Tue, 13 Apr 2021 15:38:41 +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 C2E9D226E0; Tue, 13 Apr 2021 15:38:41 +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 8E0CF1806D17; Tue, 13 Apr 2021 15:38:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DFcbXY012911 for ; Tue, 13 Apr 2021 11:38:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id C9FE7226E0; Tue, 13 Apr 2021 15:38:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EA412B0AB for ; Tue, 13 Apr 2021 15:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618328335; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=2hyrfxJB1cJJhZUAgB2Q5DHsaABeQvxhxkhwj/aNwfQ=; b=CqMEDi+ceH/kAgTnwuTbtu3UFuxLlS8NYSSjaZHMGcW7S0/kbZtFx3+FsatLY5yc89ubwy 2ffYleyXo+stdZfsxjiP+MWpAYYCEFJDdchb0f0YPJdCtpXZLwPnHKFFZDnSmAHIBZl7mc mMn3+h0LpIZeznUxHpvtvnoWEuuerDY= X-MC-Unique: opdk09NfPquTzWsz76ti3g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 4/7] qemuMigrationSrcNBDStorageCopy: Don't pass migrate_flags Date: Tue, 13 Apr 2021 17:38:24 +0200 Message-Id: <1a7b3fd68fa35971645f2a74fd4b1b81abcc1d24.1618328187.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" 'migrate_flags' can be updated in the only caller and since qemuMigrationSrcNBDStorageCopy already takes @flags which contains VIR_MIGRATE_NON_SHARED_INC (used to set QEMU_MONITOR_MIGRATE_NON_SHARED_INC) we can completely remove the parameter. Signed-off-by: Peter Krempa Reviewed-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1c3e599128..99b278e218 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1074,14 +1074,11 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriver *dr= iver, * @mig: migration cookie * @host: where are we migrating to * @speed: bandwidth limit in MiB/s - * @migrate_flags: migrate monitor command flags * * Migrate non-shared storage using the NBD protocol to the server running * inside the qemu process on dst and wait until the copy converges. - * On success update @migrate_flags so we don't tell 'migrate' command - * to do the very same operation. On failure, the caller is - * expected to call qemuMigrationSrcNBDCopyCancel to stop all - * running copy operations. + * On failure, the caller is expected to call qemuMigrationSrcNBDCopyCancel + * to stop all running copy operations. * * Returns 0 on success (@migrate_flags updated), * -1 otherwise. @@ -1092,7 +1089,6 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriver *driver, qemuMigrationCookie *mig, const char *host, unsigned long speed, - unsigned int *migrate_flags, size_t nmigrate_disks, const char **migrate_disks, virConnectPtr dconn, @@ -1104,7 +1100,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriver *driver, int port; size_t i; unsigned long long mirror_speed =3D speed; - bool mirror_shallow =3D *migrate_flags & QEMU_MONITOR_MIGRATE_NON_SHAR= ED_INC; + bool mirror_shallow =3D flags & VIR_MIGRATE_NON_SHARED_INC; int rv; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virURI) uri =3D NULL; @@ -1201,11 +1197,6 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriver *driver, qemuMigrationSrcFetchMirrorStats(driver, vm, QEMU_ASYNC_JOB_MIGRATION_= OUT, priv->job.current); - - /* Okay, all disks are ready. Modify migrate_flags */ - *migrate_flags &=3D ~(QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | - QEMU_MONITOR_MIGRATE_NON_SHARED_INC); - return 0; } @@ -4130,17 +4121,20 @@ qemuMigrationSrcRun(virQEMUDriver *driver, goto error; } - /* This will update migrate_flags on success */ if (qemuMigrationSrcNBDStorageCopy(driver, vm, mig, host, migrate_speed, - &migrate_flags, nmigrate_disks, migrate_disks, dconn, tlsAlias, nbdURI, flags) < 0) { goto error; } + + /* mask out the legacy migration flags if we are using NBD */ + migrate_flags &=3D ~(QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | + QEMU_MONITOR_MIGRATE_NON_SHARED_INC); + } else { /* Destination doesn't support NBD server. * Fall back to previous implementation. */ --=20 2.30.2 From nobody Fri May 17 07:55:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1618328415; cv=none; d=zohomail.com; s=zohoarc; b=YlOM1xTWKNKg8PbLZBt1++vF19ZsYBYjvwIGpYsg+aLKQfHxGa/5m8WRyA97BswIAy7VYaM9ZViSK1kMeMzJKqtUYW9R7EZzByyHVKcD6puJz7ybXEBi+hW18k4vHyRaKIQVr77XclNej/++hhZKDtp/wu0uOYVdhQ0esuJwe6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618328415; h=Content-Type:Content-Transfer-Encoding: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=qozwfH8gWK+0tY2oEF8Y33u0kJ2jNgumw7CwXpledEc=; b=aHZ7c3e0F8JiOLOjzEtIl/UPDPYWQLOBX9d78pT+9S3xiBwz+3h+MDZQ1aR3k+tNS+Mab9StX5UgI59LaNZ/CoMa8oEohh1oszC+qLJq0Ve7FxWEZ44+r8eWcULdA65jjvAFpfEBAfuzt0ZrU0oVP9si8Tfp16guH6X5LpgwNxQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618328415635280.8339363422914; Tue, 13 Apr 2021 08:40:15 -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-312-xffcjytZPoa7khUl87mY3Q-1; Tue, 13 Apr 2021 11:38:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5A3919251A0; Tue, 13 Apr 2021 15:38:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 807025D9DE; Tue, 13 Apr 2021 15:38:44 +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 48ECC44A67; Tue, 13 Apr 2021 15:38:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DFccnL012922 for ; Tue, 13 Apr 2021 11:38:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id D2969226E2; Tue, 13 Apr 2021 15:38:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 373BA226E0 for ; Tue, 13 Apr 2021 15:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618328413; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=qozwfH8gWK+0tY2oEF8Y33u0kJ2jNgumw7CwXpledEc=; b=gTvwjWTVmil1pRPou5aJ0RxbF0jvA5Noksx9FDlHYBvKvEHkr7bTimSBLB5/YWCDvled0r bvt0zZoEXlSQYPdfjzm4nX7awReNh2KECOBq0ooHSFJ5tzwWI4WFUWhP+gncTzf0asiL+C Xrm7xGLnmdriWO1qZ3d6S4b/sw2xa1E= X-MC-Unique: xffcjytZPoa7khUl87mY3Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 5/7] qemuMigrationSrcRun: Sanitize setting of cookieFlags and migrate_flags on storage migration Date: Tue, 13 Apr 2021 17:38:25 +0200 Message-Id: <8c9a49b0ddd0e03af6f52fb4a37a89042ed896ca.1618328187.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Base the decision on the main API flags (VIR_MIGRATE_NON_SHARED_DISK, QEMU_MONITOR_MIGRATE_NON_SHARED_INC) via a boolean 'storageMigration' rather than juggling everything trhough 'migration_flags'. After this patch 'migration_flags' is updated to contain the legacy storage migration flags only when we'll be about to use it rather than setting it and then resetting it. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 99b278e218..9ea008836c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3995,6 +3995,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, bool abort_on_error =3D !!(flags & VIR_MIGRATE_ABORT_ON_ERROR); bool events =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVE= NT); bool bwParam =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PA= RAM_BANDWIDTH); + bool storageMigration =3D flags & (VIR_MIGRATE_NON_SHARED_DISK | QEMU_= MONITOR_MIGRATE_NON_SHARED_INC); bool cancel =3D false; unsigned int waitFlags; g_autoptr(virDomainDef) persistDef =3D NULL; @@ -4010,20 +4011,14 @@ qemuMigrationSrcRun(virQEMUDriver *driver, spec, spec->destType, spec->fwdType, dconn, NULLSTR(graphicsuri), nmigrate_disks, migrate_disks); - if (flags & VIR_MIGRATE_NON_SHARED_DISK) { - migrate_flags |=3D QEMU_MONITOR_MIGRATE_NON_SHARED_DISK; + if (storageMigration) { cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; - } - if (flags & VIR_MIGRATE_NON_SHARED_INC) { - migrate_flags |=3D QEMU_MONITOR_MIGRATE_NON_SHARED_INC; - cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; + if (virQEMUCapsGet(priv->qemuCaps, + QEMU_CAPS_MIGRATION_PARAM_BLOCK_BITMAP_MAPPING)) + cookieFlags |=3D QEMU_MIGRATION_COOKIE_BLOCK_DIRTY_BITMAPS; } - if (cookieFlags & QEMU_MIGRATION_COOKIE_NBD && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BIT= MAP_MAPPING)) - cookieFlags |=3D QEMU_MIGRATION_COOKIE_BLOCK_DIRTY_BITMAPS; - if (virLockManagerPluginUsesState(driver->lockManager) && !cookieout) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4100,8 +4095,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver, migParams) < 0) goto error; - if (migrate_flags & (QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | - QEMU_MONITOR_MIGRATE_NON_SHARED_INC)) { + + if (storageMigration) { if (mig->nbd) { const char *host =3D ""; @@ -4130,16 +4125,17 @@ qemuMigrationSrcRun(virQEMUDriver *driver, nbdURI, flags) < 0) { goto error; } - - /* mask out the legacy migration flags if we are using NBD */ - migrate_flags &=3D ~(QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | - QEMU_MONITOR_MIGRATE_NON_SHARED_INC); - } else { /* Destination doesn't support NBD server. * Fall back to previous implementation. */ VIR_DEBUG("Destination doesn't support NBD server " "Falling back to previous implementation."); + + if (flags & VIR_MIGRATE_NON_SHARED_DISK) + migrate_flags |=3D QEMU_MONITOR_MIGRATE_NON_SHARED_DISK; + + if (flags & VIR_MIGRATE_NON_SHARED_INC) + migrate_flags |=3D QEMU_MONITOR_MIGRATE_NON_SHARED_INC; } } --=20 2.30.2 From nobody Fri May 17 07:55:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1618328337; cv=none; d=zohomail.com; s=zohoarc; b=P5FVsossP4P8pIucLV3Vel8jqHPAmapbz/bQUKLwUnlI+07wMtmpjEcl4Vip+gL5WQR0YjLBOAIVyMsBzhMLpVtf5YKbQpv4wzUM0unid3suBSXwnUXiHfRQjprxd9gCyy0poHME7kyBSVYOPQXDXmtsyG0Ac63++vSbPrISWQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618328337; h=Content-Type:Content-Transfer-Encoding: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=DYUm/YpV8jXG9QU7IpRQHDXVprsvLC2dXwUTPbOChas=; b=TunZolQ3CwPWND0dWWMUdjSHRoQd0agrkT/S0Ur78PfU/zRgjfrbI6E7C8lJ9LYpJThle5EqP57qohr8hE1sBzGErQ9Sbyss8pPorrS5t2mJnnvFIpodoKsWWhYgGDKI9YYGSfNs5rtyf50iXcriRVH5CFXdH0W0nXvgpbpNtx0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618328337200320.03921938275096; Tue, 13 Apr 2021 08:38:57 -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-195-dVBYWfwYM-KZKV8KOu44pw-1; Tue, 13 Apr 2021 11:38:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1CEF8018A7; Tue, 13 Apr 2021 15:38:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEBD45D9DE; Tue, 13 Apr 2021 15:38:46 +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 7929644A6C; Tue, 13 Apr 2021 15:38:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DFcdhr012932 for ; Tue, 13 Apr 2021 11:38:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id DD31F226E0; Tue, 13 Apr 2021 15:38:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A3DD2B0A9 for ; Tue, 13 Apr 2021 15:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618328335; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=DYUm/YpV8jXG9QU7IpRQHDXVprsvLC2dXwUTPbOChas=; b=RcjhszZ33orpuLBERfXh268x5gV6Mz2YdbhsjhpieQblD/Ngj4RYwPI8HXelbmfGYFpEOX SzoPuksxLfMTfFeztpWeJ4mWdsui9+q8IZ/VNlg+mKKMJ+f+2aLBqBUDkV2yVHJg8Yh7n0 j/ccOoobQQmDy+Wj2BE1o9IfgxyJ9Dk= X-MC-Unique: dVBYWfwYM-KZKV8KOu44pw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 6/7] qemuMigrationSrcRun: Don't attempt any storage migration if no disks will be migrated Date: Tue, 13 Apr 2021 17:38:26 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Don't even try to setup storage migration if there are no eligible disks. This also fixes migration from older libvirts which didn't format an empty element in the migration cookie if there weren't any disks to migrate. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9ea008836c..119459342e 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -312,6 +312,22 @@ qemuMigrationAnyCopyDisk(virDomainDiskDef const *disk, } +static bool +qemuMigrationHasAnyStorageMigrationDisks(virDomainDef *def, + const char **migrate_disks, + size_t nmigrate_disks) +{ + size_t i; + + for (i =3D 0; i < def->ndisks; i++) { + if (qemuMigrationAnyCopyDisk(def->disks[i], nmigrate_disks, migrat= e_disks)) + return true; + } + + return false; +} + + static int qemuMigrationDstPrecreateStorage(virDomainObj *vm, qemuMigrationCookieNBD *nbd, @@ -4011,6 +4027,11 @@ qemuMigrationSrcRun(virQEMUDriver *driver, spec, spec->destType, spec->fwdType, dconn, NULLSTR(graphicsuri), nmigrate_disks, migrate_disks); + if (storageMigration) + storageMigration =3D qemuMigrationHasAnyStorageMigrationDisks(vm->= def, + migrat= e_disks, + nmigra= te_disks); + if (storageMigration) { cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; --=20 2.30.2 From nobody Fri May 17 07:55:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1618328423; cv=none; d=zohomail.com; s=zohoarc; b=nYeI4w5ypavDKhBli269Mpcol+c6FHNrd7suxkc6Z0ROjcXYBcFtOYQJsVvADF+Q/xjz2BmNMC5bwsyKEuOqDGw+OuCL8kcs3PiqpO9xAgpTtRIFasIP/MLB4FURIwxJTlsOPOPIsg9/dv9WC0ao9uG5ROashSwREWqPn9q4oOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618328423; h=Content-Type:Content-Transfer-Encoding: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=fbNgDPmOc6vAU5SzwCXtILfOKJEnpIaQby8KhrQEV2k=; b=bh6Vq+2f7SjIHb2tFVsz6dztYqoUdiHjZf3KqW99paXg+cpRW901GvSNc3H6D6CNlEhUsHdfFk4NDyE5gCUKoulCrOxiQ2WAqahrab2cZsle9zIzyY8ll5JMGCsK8IGQ9Wx+KQaRM1uXE7/fbNXSxo5VJIAK2DyN9viYh93qLVQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1618328423081612.1754316647649; Tue, 13 Apr 2021 08:40:23 -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-318-h7fhet-5NEuQfwf5IZJJlw-1; Tue, 13 Apr 2021 11:38:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 163E4107ACF3; Tue, 13 Apr 2021 15:38:43 +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 E4AC12E06F; Tue, 13 Apr 2021 15:38:42 +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 ADFDD1806D1B; Tue, 13 Apr 2021 15:38:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DFcf51012945 for ; Tue, 13 Apr 2021 11:38:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0BB0F2B0A9; Tue, 13 Apr 2021 15:38:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5906D226E0 for ; Tue, 13 Apr 2021 15:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618328421; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=fbNgDPmOc6vAU5SzwCXtILfOKJEnpIaQby8KhrQEV2k=; b=gpdWanFtc03aqFGrUMBemoeK+UH2J2trXGcRISZpjRV+q1u+2WKxeTYwhqgQmaa7nZrjd1 3cjBKfB5/VRw/Pty3tRf4fO0gq3n2ERhZYnjWLA7SV6Rr4BnfttMW4Yv0uka5hfvWsvqa3 AITUsBnEs2yIWQ5EJRZRh6SfH04+sJ0= X-MC-Unique: h7fhet-5NEuQfwf5IZJJlw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 7/7] qemuMigrationSrcBeginPhase: Don't offer 'nbd' in cookie if there are no disks to migrate Date: Tue, 13 Apr 2021 17:38:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Don't try to setup disk migration and the NBD stuff if we end up migrating nothing. The destination side has luckily no setup for the non-NBD cases so omitting the element fully is okay. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 119459342e..3a622d38cd 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2365,26 +2365,30 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, return NULL; } } else { - cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; - priv->nbdPort =3D 0; - } - - if (nmigrate_disks) { - size_t i, j; - /* Check user requested only known disk targets. */ - for (i =3D 0; i < nmigrate_disks; i++) { - for (j =3D 0; j < vm->def->ndisks; j++) { - if (STREQ(vm->def->disks[j]->dst, migrate_disks[i])) - break; - } + if (nmigrate_disks) { + size_t i, j; + /* Check user requested only known disk targets. */ + for (i =3D 0; i < nmigrate_disks; i++) { + for (j =3D 0; j < vm->def->ndisks; j++) { + if (STREQ(vm->def->disks[j]->dst, migrate_disks[i]= )) + break; + } - if (j =3D=3D vm->def->ndisks) { - virReportError(VIR_ERR_INVALID_ARG, - _("disk target %s not found"), - migrate_disks[i]); - return NULL; + if (j =3D=3D vm->def->ndisks) { + virReportError(VIR_ERR_INVALID_ARG, + _("disk target %s not found"), + migrate_disks[i]); + return NULL; + } } } + + priv->nbdPort =3D 0; + + if (qemuMigrationHasAnyStorageMigrationDisks(vm->def, + migrate_disks, + nmigrate_disks)) + cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; } } --=20 2.30.2