From nobody Fri May 17 18:41:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1697441772; cv=none; d=zohomail.com; s=zohoarc; b=TrR3E2eEhNrx7lbrYYWizeXpAv8agnrTFM68sKwC+ssBLWODlmypLPe03Uc260e/BWPV7rI+ICFZfZ06YS6cn8x8gGpcg88L1e5zLAvodl5wYgyJyKRD+GL3c3qUpUe54wyclhGHQ+IU3fxaPTda5fnEn/lx1YmHw14sQldN7oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697441772; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=srAGwbP/s8ZbbtH+QKo5HKkmhNoO/2K5kzlnm6gVsc8=; b=ZmlwKLlQ25VqfuFPIB+xU3trVlIb2RzipyyNjCbwwsdESZFdkkuw0E+2KlO9ZvFMC5mPCK/uzR7fAeuDhUGhmESwsxpqorqVzLwHH0tAhVQBuRmXfVFuSvDGdedZReMA6U4iEc/wvAY7tS9Ozosk27u2ea8tUhQWHs05Ih0pytM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1697441772797989.0781501597515; Mon, 16 Oct 2023 00:36:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-xUptxa30Odul0yojbZpyUg-1; Mon, 16 Oct 2023 03:36:01 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0E3781DB7F; Mon, 16 Oct 2023 07:35:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01404492BFA; Mon, 16 Oct 2023 07:35:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BD7571946588; Mon, 16 Oct 2023 07:35:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7EEAD1946587 for ; Mon, 16 Oct 2023 07:35:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5A9491C060B1; Mon, 16 Oct 2023 07:35:57 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 009321C060B0 for ; Mon, 16 Oct 2023 07:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697441771; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=srAGwbP/s8ZbbtH+QKo5HKkmhNoO/2K5kzlnm6gVsc8=; b=EWsDR6YFepsKKj9KUfy86AoGUpfgIcnfNubpCSpZeCUr0w/GH5e5P5oDnLEKuPsz7SkbHP RUVIPu9QsM3bqVj9d3iVGDh1OFvfIXPVJ7/U1Ez0uL9QO6gVgSXy96MtyA2IOd0nCkk4M2 PPILx1FRzxiUoPacbYxb3oqRmC7zWvg= X-MC-Unique: xUptxa30Odul0yojbZpyUg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virDomainMemoryDefValidate: Skip the same device on validation on memory device update Date: Mon, 16 Oct 2023 09:35:54 +0200 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697441773301100001 Content-Type: text/plain; charset="utf-8"; x-default="true" In my recent commit of v9.8.0-rc1~7 I've introduced validation wrt other memory devices. And mostly works, except when doing memory device update ('virsh update-memory-device') because then @mem is just parsed device XML and thus its pointer is not in the vm->def->mem, yet. Thus my algorithm which skips over the same entry fails. Fortunately, we require full device XML on device update and thus we can use device address and aliases to detect duplicity. Fixes: 3fd64fb0e236fc80ffa2cc977c0d471f11fc39bf Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_validate.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 6962fe76bf..bc3d00f89c 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2387,6 +2387,21 @@ virDomainMemoryDefValidate(const virDomainMemoryDef = *mem, if (other =3D=3D mem) continue; =20 + /* In case we're updating an existing memory device (e.g. virtio-m= em), + * then pointers will be different. But addresses and aliases are = the + * same. However, STREQ_NULLABLE() returns true if both strings are + * NULL which is not what we want. */ + if (virDomainDeviceInfoAddressIsEqual(&other->info, + &mem->info)) { + continue; + } + + if (mem->info.alias && + STREQ_NULLABLE(other->info.alias, + mem->info.alias)) { + continue; + } + switch (other->model) { case VIR_DOMAIN_MEMORY_MODEL_NONE: case VIR_DOMAIN_MEMORY_MODEL_DIMM: --=20 2.41.0