From nobody Fri Dec 19 00:09:53 2025 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=1608304197; cv=none; d=zohomail.com; s=zohoarc; b=GIZaxu81FDDOzb1Ox+opXXnEwUmDTeCgSHxWp5y1zqUo6HfB1AtnBdM/xPl0UVY2htvRwlaVmjJslL6ZgVWgGGO0gwFM3dBQFUPNhpMCetfOP7paMG7EArQX1kn6n9NoO2/5nsA5GKTtyt77rN1iOYSZKTEutk8T4J0tD7AugOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304197; 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=qBVIvRT/PJiT6gJh725NI+Y5L/rHPjJ7wYaAE8VoC9g=; b=FDnYk0CRou6293VZcmOCRXWsw11iubCfSKdpxQCwPy0esyqE6hfOQI5soh1i//GmT+nd2iP5S+0hEl8OiD1pTzqFW9XuY24BPTbjDfr5vosh3tJwz2PiWs/Cg8ZYFWgF8OAvlSXsjPQcgw6cfhwa6gpA9dVQlHqcNbWp56cYxFk= 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 16083041973431023.9725472821702; Fri, 18 Dec 2020 07:09:57 -0800 (PST) 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-228-F7aJXjS9OneyMbK1YnZtLQ-1; Fri, 18 Dec 2020 10:09:50 -0500 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 3E7C2B8107; Fri, 18 Dec 2020 15:09:45 +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 1DE745D9E8; Fri, 18 Dec 2020 15:09:45 +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 D494F1809CA5; Fri, 18 Dec 2020 15:09:44 +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 0BIF9RxX014061 for ; Fri, 18 Dec 2020 10:09:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id A2BE8100238C; Fri, 18 Dec 2020 15:09:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 149BC1002382 for ; Fri, 18 Dec 2020 15:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304193; 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=qBVIvRT/PJiT6gJh725NI+Y5L/rHPjJ7wYaAE8VoC9g=; b=ART8NFf98PT2uDPCEGlvUQqmKZ3w8EO5H9YmEROiIAUszwhCBkp3of1GNQyJS8z1BQ4yu5 YHu4oSCNLTFF9ac5UPoD8tRhr9v9+Jx+NY4BMZB/b6DgGDCeuYOP0FvCvVALsArfQ6DEW1 gQ/tpwfxTOjtpad3K2uczFFyTc8ZYqk= X-MC-Unique: F7aJXjS9OneyMbK1YnZtLQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/10] virlease: Allow infinite lease expiry time Date: Fri, 18 Dec 2020 16:09:11 +0100 Message-Id: <4728b5dd7eb69caf2cc2864b1e0d318308b094d6.1608303776.git.mprivozn@redhat.com> 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 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" When adding a new lease by our leaseshelper then virLeaseNew() is called. Here, we check for DNSMASQ_LEASE_EXPIRES environment variable which is the expiration time for the lease. For infinite lease time the value is zero. However, our code is not prepared for that and adds "expiry-time" into the JSON file only if lease expiry time is non-zero. This breaks the assumption that the "expiry-time" attribute is always present (as can be seen in virLeaseReadCustomLeaseFile() and virLeasePrintLeases()). Store "expiry-time" always. Signed-off-by: Michal Privoznik --- src/util/virlease.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/util/virlease.c b/src/util/virlease.c index edfdc6477a..3d68bb660c 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -227,14 +227,13 @@ virLeaseNew(virJSONValuePtr *lease_ret, /* Removed extraneous trailing space in DNSMASQ_LEASE_EXPIRES * (dnsmasq < 2.52) */ virTrimSpaces(exptime, NULL); - } =20 - if (!exptime || - virStrToLong_ll(exptime, NULL, 10, &expirytime) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to convert lease expiry time to long long= : %s"), - NULLSTR(exptime)); - return -1; + if (virStrToLong_ll(exptime, NULL, 10, &expirytime) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to convert lease expiry time to long = long: %s"), + NULLSTR(exptime)); + return -1; + } } =20 /* Create new lease */ @@ -252,7 +251,7 @@ virLeaseNew(virJSONValuePtr *lease_ret, return -1; if (server_duid && virJSONValueObjectAppendString(lease_new, "server-d= uid", server_duid) < 0) return -1; - if (expirytime && virJSONValueObjectAppendNumberLong(lease_new, "expir= y-time", expirytime) < 0) + if (virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expir= ytime) < 0) return -1; =20 *lease_ret =3D lease_new; --=20 2.26.2